b829a47f07a14d32a6c7a4006cd4098c17d3a19d
[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         Array<Element *> inputs;
50         BooleanEdge overflowstatus;
51         FunctionEncoding functionencoding;
52         Element *clone(CSolver *solver, CloneMap *map);
53         virtual void serialize(Serializer* serializer);
54         Set * getRange();
55         void updateParents();
56         Function * getFunction() {return function;}
57         CMEMALLOC;
58  private:
59         Function *function;
60 };
61
62 static inline ElementEncoding *getElementEncoding(Element *e) {
63         return &e->encoding;
64 }
65
66 static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
67         return &func->functionencoding;
68 }
69 #endif