3e05452019f17d6a576e68a610889ed2b81f4187
[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) :
8         ASTNode(_type),
9         polarity(P_UNDEFINED),
10         boolVal(BV_UNDEFINED),
11         parents() {
12 }
13
14 BooleanVar::BooleanVar(VarType t) :
15         Boolean(BOOLEANVAR),
16         vtype(t),
17         var(E_NULL) {
18 }
19
20 BooleanOrder::BooleanOrder(Order *_order, uint64_t _first, uint64_t _second) :
21         Boolean(ORDERCONST),
22         order(_order),
23         first(_first),
24         second(_second) {
25         order->constraints.push(this);
26 }
27
28 BooleanPredicate::BooleanPredicate(Predicate *_predicate, Element **_inputs, uint _numInputs, Boolean *_undefinedStatus) :
29         Boolean(PREDICATEOP),
30         predicate(_predicate),
31         inputs(_inputs, _numInputs),
32         undefStatus(_undefinedStatus) {
33         for (uint i = 0; i < _numInputs; i++) {
34                 GETELEMENTPARENTS(_inputs[i])->push(this);
35         }
36         initPredicateEncoding(&encoding, this);
37 }
38
39 BooleanLogic::BooleanLogic(CSolver *solver, LogicOp _op, Boolean **array, uint asize) :
40         Boolean(LOGICOP),
41         op(_op),
42         inputs(array, asize) {
43         solver->allBooleans.push(this);
44 }
45
46 BooleanPredicate::~BooleanPredicate() {
47         deleteFunctionEncoding(&encoding);
48 }