#include "classlist.h"
#include "mymemory.h"
#include "ops.h"
+#include "astops.h"
#include "structs.h"
#include "astnode.h"
#include "functionencoding.h"
#include "constraint.h"
-/**
- This is a little sketchy, but apparently legit.
- https://www.python.org/dev/peps/pep-3123/ */
-#define GETBOOLEANTYPE(o) (o->type)
-#define GETBOOLEANPARENTS(o) (&(o->parents))
-#define GETBOOLEANPOLARITY(b) (b->polarity)
-#define GETBOOLEANVALUE(b) (b->boolVal)
class Boolean : public ASTNode {
public:
Boolean(ASTNodeType _type);
virtual ~Boolean() {}
- virtual Boolean *clone(CSolver *solver, CloneMap *map) { ASSERT(0); return NULL; }
+ virtual Boolean *clone(CSolver *solver, CloneMap *map) = 0;
+ virtual bool isTrue() {return boolVal == BV_MUSTBETRUE;}
+ virtual bool isFalse() {return boolVal == BV_MUSTBEFALSE;}
Polarity polarity;
BooleanValue boolVal;
Vector<Boolean *> parents;
- MEMALLOC;
+
+ CMEMALLOC;
+};
+
+class BooleanConst : public Boolean {
+public:
+ BooleanConst(bool isTrue);
+ Boolean *clone(CSolver *solver, CloneMap *map);
+ bool isTrue() {return istrue;}
+ bool isFalse() {return !istrue;}
+ bool istrue;
+ CMEMALLOC;
};
class BooleanVar : public Boolean {
VarType vtype;
Edge var;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanOrder : public Boolean {
Order *order;
uint64_t first;
uint64_t second;
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanPredicate : public Boolean {
public:
- BooleanPredicate(Predicate *_predicate, Element **_inputs, uint _numInputs, Boolean *_undefinedStatus);
+ BooleanPredicate(Predicate *_predicate, Element **_inputs, uint _numInputs, BooleanEdge _undefinedStatus);
Boolean *clone(CSolver *solver, CloneMap *map);
Predicate *predicate;
FunctionEncoding encoding;
Array<Element *> inputs;
- Boolean *undefStatus;
+ BooleanEdge undefStatus;
FunctionEncoding *getFunctionEncoding() {return &encoding;}
- MEMALLOC;
+ CMEMALLOC;
};
class BooleanLogic : public Boolean {
public:
- BooleanLogic(CSolver *solver, LogicOp _op, Boolean **array, uint asize);
+ BooleanLogic(CSolver *solver, LogicOp _op, BooleanEdge *array, uint asize);
Boolean *clone(CSolver *solver, CloneMap *map);
LogicOp op;
- Array<Boolean *> inputs;
- MEMALLOC;
+ bool replaced;
+ Array<BooleanEdge> inputs;
+ CMEMALLOC;
};
#endif