#include "boolean.h"
+
+Boolean* allocBoolean(VarType t){
+ Boolean* tmp = (Boolean*) ourmalloc(sizeof (Boolean));
+ tmp->vtype=t;
+ tmp->btype=_BOOLEAN;
+ return tmp;
+}
+
+Boolean* allocBooleanOrder(Order* order,uint64_t first, uint64_t second){
+ Boolean* tmp = (Boolean*) ourmalloc(sizeof (Boolean));
+ tmp ->btype= _ORDER;
+ tmp->order = order;
+ tmp->first=first;
+ tmp->second=second;
+}
\ No newline at end of file
#define BOOLEAN_H
#include "classlist.h"
#include "mymemory.h"
-
+#include "ops.h"
struct Boolean {
+ VarType vtype;
+ enum BooleanType btype;
+ Order* order;
+ uint64_t first;
+ uint64_t second;
};
+
+Boolean* allocBoolean(VarType t);
+Boolean* allocBooleanOrder(Order* order,uint64_t first, uint64_t second);
#endif
#include "set.h"
#include "mutableset.h"
#include "element.h"
+#include "boolean.h"
+#include "predicate.h"
CSolver * allocCSolver() {
CSolver * tmp=(CSolver *) ourmalloc(sizeof(CSolver));
}
Boolean * getBooleanVar(CSolver *solver, VarType type) {
- return NULL;
+ Boolean* boolean= allocBoolean(type);
+ pushVectorBoolean(solver->constraints, boolean);
+ return boolean;
}
-Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus) {
+Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, uint numDomain, Set * range,
+ enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus) {
return NULL;
}
-Function * createFunctionOperatorPure(CSolver *solver, enum ArithOp op) {
- return NULL;
-}
+//Function * createFunctionOperatorPure(CSolver *solver, enum ArithOp op) {
+// return NULL;
+//}
-Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain) {
- return NULL;
+Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain, uint numDomain) {
+ return allocPredicate(op, domain,numDomain);
}
-Table * createTable(CSolver *solver, Set **domains, Set * range) {
+Table * createTable(CSolver *solver, Set **domains, uint numDomain, Set * range) {
return NULL;
}
-void addTableEntry(CSolver *solver, Element ** inputs, Element *result) {
+void addTableEntry(CSolver *solver, uint64_t* inputs, uint inputSize, uint64_t result) {
}
Function * completeTable(CSolver *solver, Table * table) {
}
Order * createOrder(CSolver *solver, enum OrderType type, Set * set) {
- return NULL;
+ return allocOrder(type, set);
}
Boolean * orderConstraint(CSolver *solver, Order * order, uint64_t first, uint64_t second) {
- return NULL;
+ Boolean* constraint = allocBooleanOrder(order, first, second);
+ pushVectorBoolean(solver->constraints,constraint);
+ return constraint;
}
Element * getElementVar(CSolver *, Set * set);
Boolean * getBooleanVar(CSolver *, VarType type);
-Function * createFunctionOperator(CSolver *, enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus);
+Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, uint numDomain, Set * range,
+ enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus);
//Does Not Overflow
-Function * createFunctionOperatorPure(CSolver *, enum ArithOp op);
-Predicate * createPredicateOperator(CSolver *, enum CompOp op, Set ** domain);
+//Function * createFunctionOperatorPure(CSolver *, enum ArithOp op);
+Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain, uint numDomain);
-Table * createTable(CSolver *, Set **domains, Set * range);
-void addTableEntry(CSolver *, Element ** inputs, Element *result);
-Function * completeTable(CSolver *, struct Table *);
+Table * createTable(CSolver *solver, Set **domains, uint numDomain, Set * range);
+void addTableEntry(CSolver *solver, uint64_t* inputs, uint inputSize, uint64_t result);
+Function * completeTable(CSolver *, Table *);
Element * applyFunction(CSolver *, Function * function, Element ** array);
Boolean * applyPredicate(CSolver *, Predicate * predicate, Element ** inputs);
#include "mymemory.h"
struct Function {
+
+ Table* table;
};
#endif
*/
enum OverFlowBehavior {IGNORE, WRAPAROUND, FLAGFORCESOVERFLOW, OVERFLOWSETSFLAG, FLAGIFFOVERFLOW};
+enum BooleanType {_ORDER, _BOOLEAN};
+
#endif
#include "order.h"
+#include "structs.h"
+#include "set.h"
+
+
+Order* allocOrder(enum OrderType type, Set * set){
+ Order* order = (Order*)ourmalloc(sizeof(Order));
+ order->set=set;
+ order->constraints = allocDefVectorBoolean();
+ order->type=type;
+ return order;
+}
+
+Boolean* getOrderConstraint(Order* order, uint64_t first, uint64_t second){
+ uint size = getSizeVectorInt(order->set->members);
+ //First we need to make sure that first and second are part of the list!
+ bool exist1=false, exist2=false;
+ for(int i=0; i<size; i++){
+ if(getVectorInt(order->set->members, i)==first){
+ exist1=true;
+ }else if(getVectorInt(order->set->members, i) == second){
+ exist2=true;
+ }else if(exist1 && exist2){
+ break;
+ }
+ }
+ ASSERT(exist1 && exist2);
+
+}
\ No newline at end of file
#define ORDER_H
#include "classlist.h"
#include "mymemory.h"
-
+#include "structs.h"
+#include "ops.h"
struct Order {
+ enum OrderType type;
+ Set * set;
+ VectorBoolean* constraints;
};
+
+Order* allocOrder(enum OrderType type, Set * set);
+Boolean* getOrderConstraint(Order* order,uint64_t first, uint64_t second);
#endif
#include "predicate.h"
+#include "structs.h"
+
+
+Predicate* allocPredicate(enum CompOp op, Set ** domain, uint numDomain){
+ Predicate* predicate = (Predicate*) ourmalloc(sizeof(Predicate));
+ predicate->domains = allocDefVectorSet();
+ for(uint i=0; i<numDomain; i++)
+ pushVectorSet(predicate->domains,domain[i]);
+ predicate->op=op;
+ return predicate;
+}
\ No newline at end of file
#define PREDICATE_H
#include "classlist.h"
#include "mymemory.h"
+#include "ops.h"
+#include "structs.h"
struct Predicate {
-
+ enum CompOp op;
+ VectorSet* domains;
};
+
+
+Predicate* allocPredicate(enum CompOp op, Set ** domain, uint numDomain);
#endif