076e83186209ea9f9e3dee0da2ed603c58cba6be
[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         Function *function;
47         Array<Element *> inputs;
48         BooleanEdge overflowstatus;
49         FunctionEncoding functionencoding;
50         Element *clone(CSolver *solver, CloneMap *map);
51         Set * getRange();
52         void updateParents();
53         CMEMALLOC;
54 };
55
56 static inline ElementEncoding *getElementEncoding(Element *e) {
57         return &e->encoding;
58 }
59
60 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
61         return &func->functionencoding;
62 }
63 #endif