1 #include "naiveencoder.h"
2 #include "elementencoding.h"
4 #include "functionencoding.h"
11 void baseBinaryIndexElementAssign(ElementEncoding *This) {
12 Element * element=This->element;
13 ASSERT(element->type == ELEMSET);
14 Set * set= ((ElementSet*)element)->set;
15 ASSERT(set->isRange==false);
16 uint size=getSizeVectorInt(set->members);
17 uint encSize=NEXTPOW2(size);
18 allocEncodingArrayElement(This, encSize);
19 allocInUseArrayElement(This, encSize);
21 for(uint i=0;i<size;i++) {
22 This->encodingArray[i]=getVectorInt(set->members, i);
23 setInUseElement(This, i);
28 void naiveEncodeFunctionPredicate(Encodings* encodings, FunctionEncoding *This){
29 if(This->isFunction) {
30 ASSERT(GETELEMENTTYPE(This->op.function)==ELEMFUNCRETURN);
31 if(This->type==CIRCUIT){
32 naiveEncodeCircuitFunction(encodings, This);
33 } else if( This->type == ENUMERATEIMPLICATIONS){
34 naiveEncodeEnumeratedFunction(encodings, This);
39 ASSERT(GETBOOLEANTYPE(This->op.predicate) == PREDICATEOP);
40 BooleanPredicate* predicate = (BooleanPredicate*)This->op.predicate;
47 void naiveEncodeCircuitFunction(Encodings* encodings, FunctionEncoding* This){
51 void naiveEncodeEnumeratedFunction(Encodings* encodings, FunctionEncoding* This){
52 ElementFunction* ef =(ElementFunction*)This->op.function;
53 Function * function = ef->function;
54 if(GETFUNCTIONTYPE(function)==TABLEFUNC){
55 naiveEncodeEnumTableFunc(encodings, ef);
56 }else if (GETFUNCTIONTYPE(function)== OPERATORFUNC){
57 naiveEncodeEnumOperatingFunc(encodings, ef);
62 void naiveEncodeEnumTableFunc(Encodings* encodings, ElementFunction* This){
63 ASSERT(GETFUNCTIONTYPE(This->function)==TABLEFUNC);
64 ArrayElement* elements= &This->inputs;
65 Table* table = ((FunctionTable*) (This->function))->table;
66 uint size = getSizeVectorTableEntry(&table->entries);
67 for(uint i=0; i<size; i++){
68 TableEntry* entry = getVectorTableEntry(&table->entries, i);
69 //FIXME: generate Constraints
74 void naiveEncodeEnumOperatingFunc(Encodings* encodings, ElementFunction* This){