ElementSet* elemSet= ((ElementSet*)This);
uint size = getSetSize(elemSet->set);
for(uint i=0; i<size; i++){
- if( GETELEMENTENCODING(elemSet)->encodingArray[i]==value){
- return generateBinaryConstraint(GETELEMENTENCODING(elemSet)->numVars,
- GETELEMENTENCODING(elemSet)->variables, i);
+ if( getElementEncoding(elemSet)->encodingArray[i]==value){
+ return generateBinaryConstraint(getElementEncoding(elemSet)->numVars,
+ getElementEncoding(elemSet)->variables, i);
}
}
break;
#define GETELEMENTTYPE(o) GETASTNODETYPE(o)
#define GETELEMENTPARENTS(o) (&((Element*)o)->parents)
-#define GETELEMENTENCODING(e) (GETELEMENTTYPE(e)==ELEMSET? \
- &((ElementSet*)e)->encoding: \
- GETELEMENTTYPE(e)==ELEMFUNCRETURN? \
- &((ElementFunction*)e)->domainencoding: NULL)
-// Should be called on the element or boolean
-#define GETFUNCTIONENCODING(f) (GETASTNODETYPE(f) == ELEMFUNCRETURN? \
- &((ElementFunction*)f)->functionencoding: \
- GETASTNODETYPE(f) == PREDICATEOP? \
- &((BooleanPredicate*)f)->encoding: NULL)
struct Element {
ASTNode base;
Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
void deleteElement(Element *This);
+inline ElementEncoding* getElementEncoding(Element* This){
+ switch(GETELEMENTTYPE(This)){
+ case ELEMSET:
+ return &((ElementSet*)This)->encoding;
+ case ELEMFUNCRETURN:
+ return &((ElementFunction*)This)->domainencoding;
+ default:
+ ASSERT(0);
+ }
+ return NULL;
+}
+
uint getElementSize(Element* This);
Constraint * getElementValueConstraint(Element* This, uint64_t value);
#endif
ElementPredicate op;
};
+inline FunctionEncoding* getFunctionEncoding(ASTNode func){
+ switch(GETASTNODETYPE(func)){
+ case ELEMFUNCRETURN:
+ return &((ElementFunction*)func)->functionencoding;
+ case PREDICATEOP:
+ return &((BooleanPredicate*)func)->encoding;
+ default:
+ ASSERT(0);
+ }
+ return NULL;
+}
+
void initFunctionEncoding(FunctionEncoding *encoding, Element *function);
void initPredicateEncoding(FunctionEncoding *encoding, Boolean *predicate);
void setFunctionEncodingType(FunctionEncoding* encoding, FunctionEncodingType type);
Element* element = getVectorElement(csolver->allElements, i);
switch(GETELEMENTTYPE(element)){
case ELEMSET:
- setElementEncodingType(GETELEMENTENCODING(element), BINARYINDEX);
- baseBinaryIndexElementAssign(GETELEMENTENCODING(element));
- generateElementEncodingVariables(encoder,GETELEMENTENCODING(element));
+ setElementEncodingType(getElementEncoding(element), BINARYINDEX);
+ baseBinaryIndexElementAssign(getElementEncoding(element));
+ generateElementEncodingVariables(encoder,getElementEncoding(element));
break;
case ELEMFUNCRETURN:
- setFunctionEncodingType(GETFUNCTIONENCODING(element), ENUMERATEIMPLICATIONS);
+ setFunctionEncodingType(getFunctionEncoding(element), ENUMERATEIMPLICATIONS);
break;
default:
ASSERT(0);
Boolean* predicate = getVectorBoolean(csolver->allBooleans, i);
switch(GETBOOLEANTYPE(predicate)){
case PREDICATEOP:
- setFunctionEncodingType(GETFUNCTIONENCODING(predicate), ENUMERATEIMPLICATIONS);
+ setFunctionEncodingType(getFunctionEncoding(predicate), ENUMERATEIMPLICATIONS);
break;
default:
continue;
Element* element = getVectorElement(csolver->allElements, i);
switch(GETELEMENTTYPE(element)){
case ELEMFUNCRETURN:
- naiveEncodeFunctionPredicate(encoder, GETFUNCTIONENCODING(element));
+ naiveEncodeFunctionPredicate(encoder, getFunctionEncoding(element));
break;
default:
continue;
Boolean* predicate = getVectorBoolean(csolver->allBooleans, i);
switch(GETBOOLEANTYPE(predicate)){
case PREDICATEOP:
- naiveEncodeFunctionPredicate(encoder, GETFUNCTIONENCODING(predicate));
+ naiveEncodeFunctionPredicate(encoder, getFunctionEncoding(predicate));
break;
default:
continue;