Found bug... Don't update parent's list until we know we aren't going to be freed
[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         
20         CMEMALLOC;
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         CMEMALLOC;
30 };
31
32 class ElementSet : public Element {
33 public:
34         ElementSet(Set *s);
35         Set *set;
36         Element *clone(CSolver *solver, CloneMap *map);
37         CMEMALLOC;
38 };
39
40 class ElementFunction : public Element {
41 public:
42         ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
43         Function *function;
44         Array<Element *> inputs;
45         BooleanEdge overflowstatus;
46         FunctionEncoding functionencoding;
47         Element *clone(CSolver *solver, CloneMap *map);
48         void updateParents();
49         CMEMALLOC;
50 };
51
52 Set *getElementSet(Element *This);
53
54 static inline ElementEncoding *getElementEncoding(Element *e) {
55         return &e->encoding;
56 }
57
58 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
59         return &func->functionencoding;
60 }
61 #endif