Adding naive encoding pass. functionEncoding partially is added
[satune.git] / src / Encoders / naivefunctionencoder.c
1
2 #include "naivefunctionencoder.h"
3 #include "functionencoding.h"
4 #include "common.h"
5 #include "element.h"
6 #include "boolean.h"
7 #include "function.h"
8 #include "table.h"
9 #include "tableentry.h"
10
11 void naiveEncodeFunctionPredicate(Encodings* encodings, FunctionEncoding *This){
12         if(This->isFunction) {
13                 ASSERT(GETELEMENTTYPE(This->op.function)==ELEMFUNCRETURN);
14                 if(This->type==CIRCUIT){
15                         naiveEncodeCircuitFunction(encodings, This);
16                 } else if( This->type == ENUMERATEIMPLICATIONS){
17                         naiveEncodeEnumeratedFunction(encodings, This);
18                 } else
19                         ASSERT(0);
20                         
21         }else {
22                 ASSERT(GETBOOLEANTYPE(This->op.predicate) == PREDICATEOP);
23                 BooleanPredicate* predicate = (BooleanPredicate*)This->op.predicate;
24                 //FIXME
25                 
26         }
27 }
28
29
30 void naiveEncodeCircuitFunction(Encodings* encodings, FunctionEncoding* This){
31         
32 }
33
34 void naiveEncodeEnumeratedFunction(Encodings* encodings, FunctionEncoding* This){
35         ElementFunction* ef =(ElementFunction*)This->op.function;
36         Function * function = ef->function;
37         if(GETFUNCTIONTYPE(function)==TABLEFUNC){
38                 naiveEncodeEnumTableFunc(encodings, ef);
39         }else if (GETFUNCTIONTYPE(function)== OPERATORFUNC){
40                 naiveEncodeEnumOperatingFunc(encodings, ef);
41         }else 
42                 ASSERT(0);
43 }
44
45 void naiveEncodeEnumTableFunc(Encodings* encodings, ElementFunction* This){
46         ASSERT(GETFUNCTIONTYPE(This->function)==TABLEFUNC);
47         VectorElement* elements= This->Elements;
48         Table* table = ((FunctionTable*) This->function)->table;
49         uint size = getSizeVectorTableEntry(table->entries);
50         for(uint i=0; i<size; i++){
51                 TableEntry* entry = getVectorTableEntry(table->entries, i);
52                 //FIXME: generate Constraints
53         }
54         
55 }
56
57 void naiveEncodeEnumOperatingFunc(Encodings* encodings, ElementFunction* This){
58         
59 }