From 15207e1ea262b3cbd01e857db7532a131274edce Mon Sep 17 00:00:00 2001 From: Hamed Date: Tue, 20 Jun 2017 12:16:10 -0700 Subject: [PATCH] fixing elementSet and TablePredicate --- src/AST/boolean.h | 12 +++++------- src/AST/element.c | 8 ++++---- src/AST/element.h | 5 ++--- src/AST/ops.h | 2 +- src/AST/predicate.h | 5 ----- src/Encoders/naiveelementencoder.c | 3 ++- src/classlist.h | 1 - src/csolver.c | 2 +- 8 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/AST/boolean.h b/src/AST/boolean.h index 0222fc7..9b7c121 100644 --- a/src/AST/boolean.h +++ b/src/AST/boolean.h @@ -35,19 +35,17 @@ struct BooleanLogic { Boolean * right; }; -struct BooleanComp { - Boolean base; - CompOp op; - Boolean * left; - Boolean * right; -}; - struct BooleanPredicate{ Boolean base; Predicate * predicate; VectorElement* inputs; }; +struct TablePredicate{ + BooleanPredicate predicate; + Table* table; +}; + Boolean * allocBoolean(VarType t); Boolean * allocBooleanOrder(Order * order, uint64_t first, uint64_t second); diff --git a/src/AST/element.c b/src/AST/element.c index 3746d25..1fb49aa 100644 --- a/src/AST/element.c +++ b/src/AST/element.c @@ -1,12 +1,12 @@ #include "element.h" #include "structs.h" -//FIXME: ELEMENTSET? -Element *allocElement(Set * s) { - Element * tmp=(Element *)ourmalloc(sizeof(Element)); + +Element *allocElementSet(Set * s) { + ElementSet * tmp=(ElementSet *)ourmalloc(sizeof(ElementSet)); GETELEMENTTYPE(tmp)= ELEMSET; tmp->set=s; tmp->encoding=NULL; - return tmp; + return &tmp->base; } Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus){ diff --git a/src/AST/element.h b/src/AST/element.h index 0a23d88..986e380 100644 --- a/src/AST/element.h +++ b/src/AST/element.h @@ -10,13 +10,12 @@ //FIXME:TALK ABOUT ELEMENT struct Element { ElementType type; - Set * set; - ElementEncoding * encoding; }; struct ElementSet { Element base; Set * set; + ElementEncoding * encoding; }; struct ElementFunction{ @@ -26,7 +25,7 @@ struct ElementFunction{ Boolean * overflowstatus; }; -Element * allocElement(Set *s); +Element * allocElementSet(Set *s); Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus); void deleteElement(Element *This); #endif diff --git a/src/AST/ops.h b/src/AST/ops.h index 9fa2966..19decc2 100644 --- a/src/AST/ops.h +++ b/src/AST/ops.h @@ -23,7 +23,7 @@ typedef enum OrderType OrderType; enum OverFlowBehavior {IGNORE, WRAPAROUND, FLAGFORCESOVERFLOW, OVERFLOWSETSFLAG, FLAGIFFOVERFLOW, NOOVERFLOW}; typedef enum OverFlowBehavior OverFlowBehavior; -enum BooleanType {ORDERCONST, BOOLEANVAR, LOGICOP, COMPARE, PREDICATEOP}; +enum BooleanType {ORDERCONST, BOOLEANVAR, LOGICOP, COMPARE, PREDICATEOP, TABLEPREDICATEOP}; typedef enum BooleanType BooleanType; enum FunctionType {TABLEFUNC, OPERATORFUNC}; diff --git a/src/AST/predicate.h b/src/AST/predicate.h index 78cf2f6..513e386 100644 --- a/src/AST/predicate.h +++ b/src/AST/predicate.h @@ -10,11 +10,6 @@ struct Predicate { VectorSet* domains; }; -struct TablePredicate{ - CompOp op; - Table* table; -}; - Predicate* allocPredicate(CompOp op, Set ** domain, uint numDomain); void deletePredicate(Predicate* predicate); diff --git a/src/Encoders/naiveelementencoder.c b/src/Encoders/naiveelementencoder.c index bb6e91a..242a4e7 100644 --- a/src/Encoders/naiveelementencoder.c +++ b/src/Encoders/naiveelementencoder.c @@ -8,7 +8,8 @@ void baseBinaryIndexElementAssign(ElementEncoding *This) { Element * element=This->element; - Set * set=element->set; + ASSERT(element->type == ELEMSET); + Set * set= ((ElementSet*)element)->set; ASSERT(set->isRange==false); uint size=getSizeVectorInt(set->members); uint encSize=NEXTPOW2(size); diff --git a/src/classlist.h b/src/classlist.h index 3306ffe..4a961af 100644 --- a/src/classlist.h +++ b/src/classlist.h @@ -28,7 +28,6 @@ typedef struct Constraint Constraint; typedef struct BooleanOrder BooleanOrder; typedef struct BooleanVar BooleanVar; typedef struct BooleanLogic BooleanLogic; -typedef struct BooleanComp BooleanComp; typedef struct BooleanPredicate BooleanPredicate; struct Boolean; diff --git a/src/csolver.c b/src/csolver.c index b35680c..4c20e33 100644 --- a/src/csolver.c +++ b/src/csolver.c @@ -99,7 +99,7 @@ uint64_t createUniqueItem(CSolver *solver, MutableSet * set) { } Element * getElementVar(CSolver *This, Set * set) { - Element * element=allocElement(set); + Element * element=allocElementSet(set); pushVectorElement(This->allElements, element); return element; } -- 2.34.1