towards cloning
[satune.git] / src / AST / boolean.h
1 #ifndef BOOLEAN_H
2 #define BOOLEAN_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "ops.h"
6 #include "structs.h"
7 #include "astnode.h"
8 #include "functionencoding.h"
9 #include "constraint.h"
10
11 /**
12     This is a little sketchy, but apparently legit.
13     https://www.python.org/dev/peps/pep-3123/ */
14
15 #define GETBOOLEANTYPE(o) (o->type)
16 #define GETBOOLEANPARENTS(o) (&(o->parents))
17 #define GETBOOLEANPOLARITY(b) (b->polarity)
18 #define GETBOOLEANVALUE(b) (b->boolVal)
19
20 class Boolean : public ASTNode {
21 public:
22         Boolean(ASTNodeType _type);
23         virtual ~Boolean() {}
24         virtual Boolean * clone(CSolver * solver, CloneMap *map);
25         Polarity polarity;
26         BooleanValue boolVal;
27         Vector<Boolean *> parents;
28         MEMALLOC;
29 };
30
31 class BooleanVar : public Boolean {
32 public:
33         BooleanVar(VarType t);
34         Boolean * clone(CSolver * solver, CloneMap *map);
35         
36         VarType vtype;
37         Edge var;
38         MEMALLOC;
39 };
40
41 class BooleanOrder : public Boolean {
42 public:
43         BooleanOrder(Order *_order, uint64_t _first, uint64_t _second);
44         Boolean * clone(CSolver * solver, CloneMap *map);
45         
46         Order *order;
47         uint64_t first;
48         uint64_t second;
49         MEMALLOC;
50 };
51
52 class BooleanPredicate : public Boolean {
53 public:
54         BooleanPredicate(Predicate *_predicate, Element **_inputs, uint _numInputs, Boolean *_undefinedStatus);
55         Boolean * clone(CSolver * solver, CloneMap *map);
56         
57         Predicate *predicate;
58         FunctionEncoding encoding;
59         Array<Element *> inputs;
60         Boolean *undefStatus;
61         FunctionEncoding *getFunctionEncoding() {return &encoding;}
62         MEMALLOC;
63 };
64
65 class BooleanLogic : public Boolean {
66 public:
67         BooleanLogic(CSolver *solver, LogicOp _op, Boolean **array, uint asize);
68         Boolean * clone(CSolver * solver, CloneMap *map);
69
70         LogicOp op;
71         Array<Boolean *> inputs;
72         MEMALLOC;
73 };
74 #endif