Fix some bugs, Moving backend codes to SATEncoder
[satune.git] / src / AST / element.h
1 #ifndef ELEMENT_H
2 #define ELEMENT_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "structs.h"
6 #include "astnode.h"
7 #include "functionencoding.h"
8 #include "elementencoding.h"
9 #include "boolean.h"
10
11 #define GETELEMENTTYPE(o) GETASTNODETYPE(o)
12 #define GETELEMENTPARENTS(o) (&((Element*)o)->parents)
13                 
14 struct Element {
15         ASTNode base;
16         VectorASTNode parents;
17 };
18
19 struct ElementSet {
20         Element base;
21         Set * set;
22         ElementEncoding encoding;
23 };
24
25 struct ElementFunction {
26         Element base;
27         Function * function;
28         ArrayElement inputs;
29         Boolean * overflowstatus;
30         FunctionEncoding functionencoding;
31         ElementEncoding domainencoding;
32 };
33
34 Element * allocElementSet(Set *s);
35 Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
36 void deleteElement(Element *This);
37
38 inline ElementEncoding* getElementEncoding(Element* This){
39         switch(GETELEMENTTYPE(This)){
40                 case ELEMSET:
41                         return &((ElementSet*)This)->encoding;
42                 case ELEMFUNCRETURN:            
43                         return &((ElementFunction*)This)->domainencoding;
44                 default:
45                         ASSERT(0);
46         }
47         return NULL;
48 }
49
50
51 inline FunctionEncoding* getElementFunctionEncoding(ElementFunction* func){
52         return &func->functionencoding;
53 }
54
55 uint getElementSize(Element* This);
56 Constraint * getElementValueConstraint(Element* This, uint64_t value);
57 #endif