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