d0cec9fbaaa5d262b61c4c419b40b904b61bde7c
[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) (o->type)
12 #define GETELEMENTPARENTS(o) (&((Element *)o)->parents)
13 class Element : public ASTNode {
14 public:
15         Element(ASTNodeType type);
16         virtual ~Element() {}
17         Vector<ASTNode *> parents;
18         ElementEncoding encoding;
19         virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
20         MEMALLOC;
21 };
22
23 class ElementConst : public Element {
24 public:
25         ElementConst(uint64_t value, VarType type, Set *_set);
26         Set *set;
27         uint64_t value;
28         Element *clone(CSolver *solver, CloneMap *map);
29         MEMALLOC;
30 };
31
32 class ElementSet : public Element {
33 public:
34         ElementSet(Set *s);
35         Set *set;
36         Element *clone(CSolver *solver, CloneMap *map);
37         MEMALLOC;
38 };
39
40 class ElementFunction : public Element {
41 public:
42         ElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
43         Function *function;
44         Array<Element *> inputs;
45         Boolean *overflowstatus;
46         FunctionEncoding functionencoding;
47         Element *clone(CSolver *solver, CloneMap *map);
48         MEMALLOC;
49 };
50
51 Set *getElementSet(Element *This);
52
53 static inline ElementEncoding *getElementEncoding(Element *e) {
54         return &e->encoding;
55 }
56
57 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
58         return &func->functionencoding;
59 }
60 #endif