Merge branch 'master' of ssh://plrg.eecs.uci.edu/home/git/constraint_compiler
[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 class Element : public ASTNode {
12 public:
13         Element(ASTNodeType type);
14         virtual ~Element() {}
15         Vector<ASTNode *> parents;
16         ElementEncoding encoding;
17         virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
18         virtual void updateParents() {}
19         virtual Set * getRange() = 0;
20         CMEMALLOC;
21 };
22
23 class ElementSet : public Element {
24 public:
25         ElementSet(ASTNodeType type, Set *s);
26         ElementSet(Set *s);
27         virtual Element *clone(CSolver *solver, CloneMap *map);
28         CMEMALLOC;
29         Set *getRange() {return set;}
30  private:
31         Set *set;
32
33 };
34
35 class ElementConst : public ElementSet {
36 public:
37         ElementConst(uint64_t value, Set *_set);
38         uint64_t value;
39         Element *clone(CSolver *solver, CloneMap *map);
40         CMEMALLOC;
41 };
42
43 class ElementFunction : public Element {
44 public:
45         ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
46         Array<Element *> inputs;
47         BooleanEdge overflowstatus;
48         FunctionEncoding functionencoding;
49         Element *clone(CSolver *solver, CloneMap *map);
50         Set * getRange();
51         void updateParents();
52         Function * getFunction() {return function;}
53         CMEMALLOC;
54  private:
55         Function *function;
56 };
57
58 static inline ElementEncoding *getElementEncoding(Element *e) {
59         return &e->encoding;
60 }
61
62 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
63         return &func->functionencoding;
64 }
65 #endif