Commit after resolving conflicts
[satune.git] / src / AST / boolean.c
1 #include "boolean.h"
2 #include "structs.h"
3 #include "csolver.h"
4
5 Boolean* allocBoolean(VarType t) {
6         BooleanVar* tmp=(BooleanVar *) ourmalloc(sizeof (BooleanVar));
7         GETBOOLEANTYPE(tmp)=BOOLEANVAR;
8         tmp->vtype=t;
9         tmp->var=NULL;
10         return & tmp->base;
11 }
12
13 Boolean* allocBooleanOrder(Order* order, uint64_t first, uint64_t second) {
14         BooleanOrder* tmp=(BooleanOrder *) ourmalloc(sizeof (BooleanOrder));
15         GETBOOLEANTYPE(tmp)=ORDERCONST;
16         tmp->order=order;
17         tmp->first=first;
18         tmp->second=second;
19         return & tmp -> base;
20 }
21
22 Boolean * allocBooleanPredicate(Predicate * predicate, Element ** inputs, uint numInputs){
23     BooleanPredicate* bp = (BooleanPredicate*) ourmalloc(sizeof(BooleanPredicate));
24     GETBOOLEANTYPE(bp)= PREDICATEOP;
25     bp->predicate=predicate;
26     bp->inputs= allocVectorArrayElement (numInputs,inputs);
27     return & bp->base;
28 }
29
30 Boolean * allocBooleanLogic(LogicOp op, Boolean * left, Boolean* right){
31     BooleanLogic* bl = (BooleanLogic*) ourmalloc(sizeof(BooleanLogic));
32     GETBOOLEANTYPE(bl) = LOGICOP;
33     bl->op=op;
34     bl->left=left;
35     bl->right=right;
36     return &bl->base;
37 }
38 Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array, uint asize){
39     ASSERT(asize>=2);
40     Boolean* boolean = allocBooleanLogic(op,array[0], array[1]);
41     pushVectorBoolean(solver->allBooleans,boolean);
42     for(uint i=2; i<asize; i++){
43         boolean=allocBooleanLogic(op,boolean, array[i]);
44         pushVectorBoolean(solver->allBooleans,boolean);
45     }
46     return boolean;
47 }
48
49 void deleteBoolean(Boolean * This) {
50         ourfree(This);
51 }