#include "boolean.h"
#include "predicate.h"
#include "order.h"
+#include "table.h"
+#include "function.h"
CSolver * allocCSolver() {
CSolver * tmp=(CSolver *) ourmalloc(sizeof(CSolver));
tmp->constraints=allocDefVectorBoolean();
- tmp->sets=allocDefVectorSet();
- tmp->elements=allocDefVectorElement();
+ tmp->allBooleans=allocDefVectorBoolean();
+ tmp->allSets=allocDefVectorSet();
+ tmp->allElements=allocDefVectorElement();
+ tmp->allPredicates = allocDefVectorPredicate();
+ tmp->allTables = allocDefVectorTable();
+ tmp->allOrders = allocDefVectorOrder();
+ tmp->allFunctions = allocDefVectorFunction();
return tmp;
}
/** This function tears down the solver and the entire AST */
-void deleteSolver(CSolver *this) {
- deleteVectorBoolean(this->constraints);
- uint size=getSizeVectorSet(this->sets);
+void deleteSolver(CSolver *This) {
+ deleteVectorBoolean(This->constraints);
+
+ uint size=getSizeVectorBoolean(This->allBooleans);
+ for(uint i=0;i<size;i++) {
+ deleteBoolean(getVectorBoolean(This->allBooleans, i));
+ }
+ deleteVectorBoolean(This->allBooleans);
+
+ size=getSizeVectorSet(This->allSets);
for(uint i=0;i<size;i++) {
- deleteSet(getVectorSet(this->sets, i));
+ deleteSet(getVectorSet(This->allSets, i));
}
+ deleteVectorSet(This->allSets);
- deleteVectorSet(this->sets);
+ size=getSizeVectorElement(This->allElements);
+ for(uint i=0;i<size;i++) {
+ deleteElement(getVectorElement(This->allElements, i));
+ }
+ deleteVectorElement(This->allElements);
- size=getSizeVectorElement(this->elements);
+ size=getSizeVectorTable(This->allTables);
+ for(uint i=0;i<size;i++) {
+ deleteTable(getVectorTable(This->allTables, i));
+ }
+ deleteVectorTable(This->allTables);
+
+ size=getSizeVectorPredicate(This->allPredicates);
for(uint i=0;i<size;i++) {
- deleteElement(getVectorElement(this->elements, i));
+ deletePredicate(getVectorPredicate(This->allPredicates, i));
}
+ deleteVectorPredicate(This->allPredicates);
- deleteVectorElement(this->elements);
- ourfree(this);
+ size=getSizeVectorOrder(This->allOrders);
+ for(uint i=0;i<size;i++) {
+ deleteOrder(getVectorOrder(This->allOrders, i));
+ }
+ deleteVectorOrder(This->allOrders);
+
+ size=getSizeVectorFunction(This->allFunctions);
+ for(uint i=0;i<size;i++) {
+ deleteFunction(getVectorFunction(This->allFunctions, i));
+ }
+ deleteVectorFunction(This->allFunctions);
+ ourfree(This);
}
-Set * createSet(CSolver * this, VarType type, uint64_t * elements, uint numelements) {
+Set * createSet(CSolver * This, VarType type, uint64_t * elements, uint numelements) {
Set * set=allocSet(type, elements, numelements);
- pushVectorSet(this->sets, set);
+ pushVectorSet(This->allSets, set);
return set;
}
-Set * createRangeSet(CSolver * this, VarType type, uint64_t lowrange, uint64_t highrange) {
+Set * createRangeSet(CSolver * This, VarType type, uint64_t lowrange, uint64_t highrange) {
Set * set=allocSetRange(type, lowrange, highrange);
- pushVectorSet(this->sets, set);
+ pushVectorSet(This->allSets, set);
return set;
}
-MutableSet * createMutableSet(CSolver * this, VarType type) {
+MutableSet * createMutableSet(CSolver * This, VarType type) {
MutableSet * set=allocMutableSet(type);
- pushVectorSet(this->sets, set);
+ pushVectorSet(This->allSets, set);
return set;
}
return element;
}
-Element * getElementVar(CSolver *this, Set * set) {
+Element * getElementVar(CSolver *This, Set * set) {
Element * element=allocElement(set);
- pushVectorElement(this->elements, element);
+ pushVectorElement(This->allElements, element);
return element;
}
Boolean * getBooleanVar(CSolver *solver, VarType type) {
- Boolean* boolean= allocBoolean(type);
- pushVectorBoolean(solver->constraints, boolean);
- return boolean;
+ Boolean* boolean= allocBoolean(type);
+ pushVectorBoolean(solver->allBooleans, boolean);
+ return boolean;
}
-Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, uint numDomain, Set * range,
- enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus) {
- return NULL;
+Function * createFunctionOperator(CSolver *solver, ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior) {
+ Function* function = allocFunctionOperator(op, domain, numDomain, range, overflowbehavior);
+ pushVectorFunction(solver->allFunctions, function);
+ return function;
}
-//Function * createFunctionOperatorPure(CSolver *solver, enum ArithOp op) {
-// return NULL;
-//}
-
-Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain, uint numDomain) {
- return allocPredicate(op, domain,numDomain);
+Predicate * createPredicateOperator(CSolver *solver, CompOp op, Set ** domain, uint numDomain) {
+ Predicate* predicate= allocPredicate(op, domain,numDomain);
+ pushVectorPredicate(solver->allPredicates, predicate);
+ return predicate;
}
Table * createTable(CSolver *solver, Set **domains, uint numDomain, Set * range) {
- return NULL;
+ Table* table= allocTable(domains,numDomain,range);
+ pushVectorTable(solver->allTables, table);
+ return table;
}
-void addTableEntry(CSolver *solver, uint64_t* inputs, uint inputSize, uint64_t result) {
+void addTableEntry(CSolver *solver, Table* table, uint64_t* inputs, uint inputSize, uint64_t result) {
+ addNewTableEntry(table,inputs, inputSize,result);
}
Function * completeTable(CSolver *solver, Table * table) {
- return NULL;
+ Function* function = allocFunctionTable(table);
+ pushVectorFunction(solver->allFunctions,function);
+ return function;
}
-Element * applyFunction(CSolver *solver, Function * function, Element ** array) {
- return NULL;
+Element * applyFunction(CSolver *solver, Function * function, Element ** array, uint numArrays, Boolean * overflowstatus) {
+ Element* element= allocElementFunction(function,array,numArrays,overflowstatus);
+ pushVectorElement(solver->allElements, element);
+ return element;
}
-Boolean * applyPredicate(CSolver *solver, Predicate * predicate, Element ** inputs) {
- return NULL;
+Boolean * applyPredicate(CSolver *solver, Predicate * predicate, Element ** inputs, uint numInputs) {
+ Boolean* boolean= allocBooleanPredicate(predicate, inputs, numInputs);
+ pushVectorBoolean(solver->allBooleans, boolean);
+ return boolean;
}
-Boolean * applyLogicalOperation(CSolver *solver, enum LogicOp op, Boolean ** array) {
- return NULL;
+Boolean * applyLogicalOperation(CSolver *solver, LogicOp op, Boolean ** array, uint asize) {
+ return allocBooleanLogicArray(solver, op, array, asize);
}
-void addBoolean(CSolver *this, Boolean * constraint) {
- pushVectorBoolean(this->constraints, constraint);
+void addBoolean(CSolver *This, Boolean * constraint) {
+ pushVectorBoolean(This->constraints, constraint);
}
-Order * createOrder(CSolver *solver, enum OrderType type, Set * set) {
- return allocOrder(type, set);
+Order * createOrder(CSolver *solver, OrderType type, Set * set) {
+ Order* order = allocOrder(type, set);
+ pushVectorOrder(solver->allOrders, order);
+ return order;
}
Boolean * orderConstraint(CSolver *solver, Order * order, uint64_t first, uint64_t second) {
- Boolean* constraint = allocBooleanOrder(order, first, second);
- pushVectorBoolean(solver->constraints,constraint);
- return constraint;
+ Boolean* constraint = allocBooleanOrder(order, first, second);
+ pushVectorBoolean(solver->allBooleans,constraint);
+ return constraint;
}