eb3b02cd42d955bd319218a7b0b28a36d8ac4e65
[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 //I don't like the name, we may want to change it later --HG
35 struct BooleanInterOrder{
36         Boolean base;
37         Order* order1;
38         uint64_t first;
39         Order* order2;
40         uint64_t second;
41 };
42
43 struct BooleanVar {
44         Boolean base;
45         VarType vtype;
46         Edge var;
47 };
48
49 struct BooleanLogic {
50         Boolean base;
51         LogicOp op;
52         ArrayBoolean inputs;
53 };
54
55 struct BooleanPredicate {
56         Boolean base;
57         Predicate * predicate;
58         FunctionEncoding encoding;
59         ArrayElement inputs;
60         Boolean* undefStatus;
61 };
62
63 Boolean * allocBooleanVar(VarType t);
64 Boolean * allocBooleanOrder(Order * order, uint64_t first, uint64_t second);
65 Boolean * allocBooleanInterOrder(Order * order1, uint64_t first,Order* order2, uint64_t second);
66 Boolean * allocBooleanPredicate(Predicate * predicate, Element ** inputs, uint numInputs, Boolean* undefinedStatus);
67 Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array, uint asize);
68 void deleteBoolean(Boolean * This);
69 Polarity negatePolarity(Polarity This);
70 BooleanValue negateBooleanValue(BooleanValue This);
71 static inline FunctionEncoding* getPredicateFunctionEncoding(BooleanPredicate* func){
72         return &func->encoding;
73 }
74
75 #endif