Fixing memory leak bug ...
[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 serialize(Serializer* serializer) =0;
19         virtual void updateParents() {}
20         virtual Set * getRange() = 0;
21         CMEMALLOC;
22 };
23
24 class ElementSet : public Element {
25 public:
26         ElementSet(ASTNodeType type, Set *s);
27         ElementSet(Set *s);
28         virtual Element *clone(CSolver *solver, CloneMap *map);
29         virtual void serialize(Serializer* serializer);
30         CMEMALLOC;
31         Set *getRange() {return set;}
32  protected:
33         Set *set;
34
35 };
36
37 class ElementConst : public ElementSet {
38 public:
39         ElementConst(uint64_t value, Set *_set);
40         uint64_t value;
41         virtual void serialize(Serializer* serializer);
42         Element *clone(CSolver *solver, CloneMap *map);
43         CMEMALLOC;
44 };
45
46 class ElementFunction : public Element {
47 public:
48         ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
49         Function *function;
50         Array<Element *> inputs;
51         BooleanEdge overflowstatus;
52         FunctionEncoding functionencoding;
53         Element *clone(CSolver *solver, CloneMap *map);
54         virtual void serialize(Serializer* serializer);
55         Set * getRange();
56         void updateParents();
57         CMEMALLOC;
58 };
59
60 static inline ElementEncoding *getElementEncoding(Element *e) {
61         return &e->encoding;
62 }
63
64 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
65         return &func->functionencoding;
66 }
67 #endif