return &This->base;
}
+Element * allocElementConst(uint64_t value, VarType type) {
+ ElementConst * This=(ElementConst *)ourmalloc(sizeof(ElementConst));
+ GETELEMENTTYPE(This)= ELEMCONST;
+ This->value=value;
+ This->set=allocSet(type, (uint64_t[]){value}, 1);
+ initDefVectorASTNode(GETELEMENTPARENTS(This));
+ initElementEncoding(&This->encoding, (Element *) This);
+ return &This->base;
+}
+
Set* getElementSet(Element* This){
switch(GETELEMENTTYPE(This)){
case ELEMSET:
return ((ElementSet*)This)->set;
+ case ELEMCONST:
+ return ((ElementConst*)This)->set;
case ELEMFUNCRETURN: {
Function* func = ((ElementFunction*)This)->function;
switch(GETFUNCTIONTYPE(func)){
deleteElementEncoding(&es->encoding);
break;
}
+ case ELEMCONST: {
+ ElementConst *ec = (ElementConst *) This;
+ deleteSet(ec->set);//Client did not create, so we free it
+ deleteElementEncoding(&ec->encoding);
+ break;
+ }
default:
ASSERT(0);
}
VectorASTNode parents;
};
+struct ElementConst {
+ Element base;
+ Set * set;
+ uint64_t value;
+ ElementEncoding encoding;
+};
+
struct ElementSet {
Element base;
Set * set;
ElementEncoding rangeencoding;
};
+Element * allocElementConst(uint64_t value, VarType type);
Element * allocElementSet(Set *s);
Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
void deleteElement(Element *This);
enum PredicateType {TABLEPRED, OPERATORPRED};
typedef enum PredicateType PredicateType;
-enum ASTNodeType {ORDERCONST, BOOLEANVAR, LOGICOP, PREDICATEOP, ELEMSET, ELEMFUNCRETURN};
+enum ASTNodeType {ORDERCONST, BOOLEANVAR, LOGICOP, PREDICATEOP, ELEMSET, ELEMFUNCRETURN, ELEMCONST};
typedef enum ASTNodeType ASTNodeType;
#endif
typedef struct ElementFunction ElementFunction;
typedef struct ElementSet ElementSet;
+typedef struct ElementConst ElementConst;
struct Element;
typedef struct Element Element;
return element;
}
+Element * getElementConst(CSolver *This, VarType type, uint64_t value) {
+ Element * element=allocElementConst(value, type);
+ pushVectorElement(This->allElements, element);
+ return element;
+}
+
Boolean * getBooleanVar(CSolver *This, VarType type) {
Boolean* boolean= allocBooleanVar(type);
pushVectorBoolean(This->allBooleans, boolean);
Element * getElementVar(CSolver *, Set * set);
+/** This function creates an element constrant. */
+Element * getElementConst(CSolver *, VarType type, uint64_t value);
+
/** This function creates a boolean variable. */
Boolean * getBooleanVar(CSolver *, VarType type);