Merge branch 'hamed'
[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) GETASTNODETYPE(o)
16 #define GETBOOLEANPARENTS(o) (&((Boolean *)(o))->parents)
17 #define GETBOOLEANPOLARITY(b) (((Boolean *)b)->polarity)
18 #define GETBOOLEANVALUE(b) (((Boolean *)b)->boolVal)
19
20 struct Boolean {
21         ASTNode base;
22         Polarity polarity;
23         BooleanValue boolVal;
24         VectorBoolean parents;
25 };
26
27 struct BooleanOrder {
28         Boolean base;
29         Order *order;
30         uint64_t first;
31         uint64_t second;
32 };
33
34 struct BooleanVar {
35         Boolean base;
36         VarType vtype;
37         Edge var;
38 };
39
40 struct BooleanLogic {
41         Boolean base;
42         LogicOp op;
43         ArrayBoolean inputs;
44 };
45
46 struct BooleanPredicate {
47         Boolean base;
48         Predicate *predicate;
49         FunctionEncoding encoding;
50         ArrayElement inputs;
51         Boolean *undefStatus;
52 };
53
54 Boolean *allocBooleanVar(VarType t);
55 Boolean *allocBooleanOrder(Order *order, uint64_t first, uint64_t second);
56 Boolean *allocBooleanPredicate(Predicate *predicate, Element **inputs, uint numInputs, Boolean *undefinedStatus);
57 Boolean *allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean **array, uint asize);
58 void deleteBoolean(Boolean *This);
59 static inline FunctionEncoding *getPredicateFunctionEncoding(BooleanPredicate *func) {
60         return &func->encoding;
61 }
62
63 #endif