Merge branch 'hamed' of ssh://plrg.eecs.uci.edu/home/git/constraint_compiler
[satune.git] / src / AST / boolean.cc
1 #include "boolean.h"
2 #include "structs.h"
3 #include "csolver.h"
4 #include "element.h"
5 #include "order.h"
6
7 Boolean::Boolean(ASTNodeType _type) : ASTNode(_type), polarity(P_UNDEFINED), boolVal(BV_UNDEFINED) {
8         initDefVectorBoolean(GETBOOLEANPARENTS(this));  
9 }
10
11 BooleanVar::BooleanVar(VarType t) : Boolean(BOOLEANVAR), vtype(t), var(E_NULL) {
12 }
13
14 BooleanOrder::BooleanOrder(Order *_order, uint64_t _first, uint64_t _second) : Boolean(ORDERCONST), order(_order), first(_first), second(_second) {
15         pushVectorBooleanOrder(&order->constraints, this);
16 }
17
18 BooleanPredicate::BooleanPredicate(Predicate *_predicate, Element **_inputs, uint _numInputs, Boolean *_undefinedStatus) : Boolean(PREDICATEOP), predicate(_predicate), undefStatus(_undefinedStatus) {
19         initArrayInitElement(&inputs, _inputs, _numInputs);
20
21         for (uint i = 0; i < _numInputs; i++) {
22                 pushVectorASTNode(GETELEMENTPARENTS(_inputs[i]), this);
23         }
24         initPredicateEncoding(&encoding, this);
25 }
26
27 BooleanLogic::BooleanLogic(CSolver *solver, LogicOp _op, Boolean **array, uint asize) : Boolean(LOGICOP), op(_op) {
28         initArrayInitBoolean(&inputs, array, asize);
29         pushVectorBoolean(solver->allBooleans, (Boolean *) this);
30 }
31
32 Boolean::~Boolean() {
33         deleteVectorArrayBoolean(GETBOOLEANPARENTS(this));
34 }
35
36 BooleanPredicate::~BooleanPredicate() {
37         deleteInlineArrayElement(&inputs );
38         deleteFunctionEncoding(&encoding);
39 }
40
41 BooleanLogic::~BooleanLogic() {
42         deleteInlineArrayBoolean(&inputs);
43 }