Incremental solver works and the test case passes
[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         inline void freezeElement(){frozen = true;}
19         inline bool isFrozen(){return frozen;}
20         virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
21         virtual void serialize(Serializer *serializer) = 0;
22         virtual void print() = 0;
23         virtual void updateParents() {}
24         virtual Set *getRange() = 0;
25         CMEMALLOC;
26         bool anyValue;
27         bool frozen;
28 };
29
30 class ElementSet : public Element {
31 public:
32         ElementSet(ASTNodeType type, Set *s);
33         virtual ~ElementSet() {}
34         ElementSet(Set *s);
35         virtual Element *clone(CSolver *solver, CloneMap *map);
36         virtual void serialize(Serializer *serializer);
37         virtual void print();
38         CMEMALLOC;
39         Set *getRange() {return set;}
40 protected:
41         Set *set;
42         friend class ElementOpt;
43 };
44
45 class ElementConst : public ElementSet {
46 public:
47         ElementConst(uint64_t value, Set *_set);
48         virtual ~ElementConst() {}
49         uint64_t value;
50         virtual void serialize(Serializer *serializer);
51         virtual void print();
52         Element *clone(CSolver *solver, CloneMap *map);
53         CMEMALLOC;
54 };
55
56 class ElementFunction : public Element {
57 public:
58         virtual ~ElementFunction() {}
59         ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
60         Array<Element *> inputs;
61         BooleanEdge overflowstatus;
62         FunctionEncoding functionencoding;
63         Element *clone(CSolver *solver, CloneMap *map);
64         virtual void serialize(Serializer *serializer);
65         virtual void print();
66         Set *getRange();
67         void updateParents();
68         Function *getFunction() {return function;}
69         inline FunctionEncoding *getElementFunctionEncoding() {return &functionencoding;}
70         CMEMALLOC;
71 private:
72         Function *function;
73 };
74
75
76 #endif