Add AST Hashing and Equals Functions
[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         
19         MEMALLOC;
20 };
21
22 class ElementConst : public Element {
23 public:
24         ElementConst(uint64_t value, VarType type, Set *_set);
25         Set *set;
26         uint64_t value;
27         Element *clone(CSolver *solver, CloneMap *map);
28         MEMALLOC;
29 };
30
31 class ElementSet : public Element {
32 public:
33         ElementSet(Set *s);
34         Set *set;
35         Element *clone(CSolver *solver, CloneMap *map);
36         MEMALLOC;
37 };
38
39 class ElementFunction : public Element {
40 public:
41         ElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
42         Function *function;
43         Array<Element *> inputs;
44         Boolean *overflowstatus;
45         FunctionEncoding functionencoding;
46         Element *clone(CSolver *solver, CloneMap *map);
47         MEMALLOC;
48 };
49
50 Set *getElementSet(Element *This);
51
52 static inline ElementEncoding *getElementEncoding(Element *e) {
53         return &e->encoding;
54 }
55
56 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
57         return &func->functionencoding;
58 }
59 #endif