backout changes
[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         inline ElementEncoding *getElementEncoding(){ return &encoding; }
18         virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
19         virtual void serialize(Serializer* serializer) =0;
20         virtual void updateParents() {}
21         virtual Set * getRange() = 0;
22         CMEMALLOC;
23 };
24
25 class ElementSet : public Element {
26 public:
27         ElementSet(ASTNodeType type, Set *s);
28         ElementSet(Set *s);
29         virtual Element *clone(CSolver *solver, CloneMap *map);
30         virtual void serialize(Serializer* serializer);
31         CMEMALLOC;
32         Set *getRange() {return set;}
33  protected:
34         Set *set;
35
36 };
37
38 class ElementConst : public ElementSet {
39 public:
40         ElementConst(uint64_t value, Set *_set);
41         uint64_t value;
42         virtual void serialize(Serializer* serializer);
43         Element *clone(CSolver *solver, CloneMap *map);
44         CMEMALLOC;
45 };
46
47 class ElementFunction : public Element {
48 public:
49         ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
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         Function * getFunction() {return function;}
58         inline FunctionEncoding *getElementFunctionEncoding() {return &functionencoding;}
59         CMEMALLOC;
60  private:
61         Function *function;
62 };
63
64
65 #endif