Binary encoding for ElementSet and table-based ElementFunction
[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 #define GETELEMENTENCODING(e) (GETELEMENTTYPE(e)==ELEMSET?      \
14                 &((ElementSet*)e)->encoding:    \
15                 GETELEMENTTYPE(e)==ELEMFUNCRETURN?      \
16                 &((ElementFunction*)e)->domainencoding: NULL)
17 // Should be called on the element or boolean
18 #define GETFUNCTIONENCODING(f) (GETASTNODETYPE(f) == ELEMFUNCRETURN?    \
19                 &((ElementFunction*)f)->functionencoding:       \
20                 GETASTNODETYPE(f) == PREDICATEOP?       \
21                 &((BooleanPredicate*)f)->encoding: NULL)
22                 
23 struct Element {
24         ASTNode base;
25         VectorASTNode parents;
26 };
27
28 struct ElementSet {
29         Element base;
30         Set * set;
31         ElementEncoding encoding;
32 };
33
34 struct ElementFunction {
35         Element base;
36         Function * function;
37         ArrayElement inputs;
38         Boolean * overflowstatus;
39         FunctionEncoding functionencoding;
40         ElementEncoding domainencoding;
41 };
42
43 Element * allocElementSet(Set *s);
44 Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
45 void deleteElement(Element *This);
46
47 uint getElementSize(Element* This);
48 Constraint * getElementValueConstraint(Element* This, uint64_t value);
49 #endif