inputs(_inputs, _numInputs),
undefStatus(_undefinedStatus) {
for (uint i = 0; i < _numInputs; i++) {
- GETELEMENTPARENTS(_inputs[i])->push(this);
+ _inputs[i]->parents.push(this);
}
}
#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);
overflowstatus(_overflowstatus),
functionencoding(this) {
for (uint i = 0; i < numArrays; i++)
- GETELEMENTPARENTS(array[i])->push(this);
+ array[i]->parents.push(this);
}
ElementConst::ElementConst(uint64_t _value, VarType _type, Set *_set) :
}
Set *getElementSet(Element *This) {
- switch (GETELEMENTTYPE(This)) {
+ switch (This->type) {
case ELEMSET:
return ((ElementSet *)This)->set;
case ELEMCONST:
return ((ElementConst *)This)->set;
case ELEMFUNCRETURN: {
Function *func = ((ElementFunction *)This)->function;
- switch (GETFUNCTIONTYPE(func)) {
+ switch (func->type) {
case TABLEFUNC:
return ((FunctionTable *)func)->table->range;
case OPERATORFUNC:
#include "elementencoding.h"
#include "boolean.h"
-#define GETELEMENTTYPE(o) (o->type)
-#define GETELEMENTPARENTS(o) (&((Element *)o)->parents)
class Element : public ASTNode {
public:
Element(ASTNodeType type);
#include "ops.h"
#include "structs.h"
-#define GETFUNCTIONTYPE(o) (((Function *)o)->type)
-
class Function {
public:
Function(FunctionType _type) : type(_type) {}
#include "structs.h"
#include "common.h"
-#define GETPREDICATETYPE(o) (((Predicate *)(o))->type)
-
class Predicate {
public:
Predicate(PredicateType _type) : type(_type) {}
}
void computePolarityAndBooleanValue(Boolean *This) {
- switch (GETBOOLEANTYPE(This)) {
+ switch (This->type) {
case BOOLEANVAR:
case ORDERCONST:
return;
}
void computeLogicOpPolarity(BooleanLogic *This) {
- Polarity parentpolarity = GETBOOLEANPOLARITY(This);
+ Polarity parentpolarity = This->polarity;
switch (This->op) {
case L_AND:
case L_OR: {
}
void computeLogicOpBooleanValue(BooleanLogic *This) {
- BooleanValue parentbv = GETBOOLEANVALUE(This);
+ BooleanValue parentbv = This->boolVal;
switch (This->op) {
case L_AND: {
if (parentbv == BV_MUSTBETRUE || parentbv == BV_UNSAT) {
}
Edge SATEncoder::getElementValueBinaryIndexConstraint(Element *elem, uint64_t value) {
- ASTNodeType type = GETELEMENTTYPE(elem);
+ ASTNodeType type = elem->type;
ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
ElementEncoding *elemEnc = getElementEncoding(elem);
for (uint i = 0; i < elemEnc->encArraySize; i++) {
}
Edge SATEncoder::getElementValueOneHotConstraint(Element *elem, uint64_t value) {
- ASTNodeType type = GETELEMENTTYPE(elem);
+ ASTNodeType type = elem->type;
ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
ElementEncoding *elemEnc = getElementEncoding(elem);
for (uint i = 0; i < elemEnc->encArraySize; i++) {
}
Edge SATEncoder::getElementValueUnaryConstraint(Element *elem, uint64_t value) {
- ASTNodeType type = GETELEMENTTYPE(elem);
+ ASTNodeType type = elem->type;
ASSERT(type == ELEMSET || type == ELEMFUNCRETURN || type == ELEMCONST);
ElementEncoding *elemEnc = getElementEncoding(elem);
for (uint i = 0; i < elemEnc->encArraySize; i++) {
}
Edge SATEncoder::getElementValueBinaryValueConstraint(Element *element, uint64_t value) {
- ASTNodeType type = GETELEMENTTYPE(element);
+ ASTNodeType type = element->type;
ASSERT(type == ELEMSET || type == ELEMFUNCRETURN);
ElementEncoding *elemEnc = getElementEncoding(element);
if (elemEnc->low <= elemEnc->high) {
}
Edge SATEncoder::encodeConstraintSATEncoder(Boolean *constraint) {
- switch (GETBOOLEANTYPE(constraint)) {
+ switch (constraint->type) {
case ORDERCONST:
return encodeOrderSATEncoder((BooleanOrder *) constraint);
case BOOLEANVAR:
case PREDICATEOP:
return encodePredicateSATEncoder((BooleanPredicate *) constraint);
default:
- model_print("Unhandled case in encodeConstraintSATEncoder %u", GETBOOLEANTYPE(constraint));
+ model_print("Unhandled case in encodeConstraintSATEncoder %u", constraint->type);
exit(-1);
}
}
}
Edge SATEncoder::encodePredicateSATEncoder(BooleanPredicate *constraint) {
- switch (GETPREDICATETYPE(constraint->predicate) ) {
+ switch (constraint->predicate->type) {
case TABLEPRED:
return encodeTablePredicateSATEncoder(constraint);
case OPERATORPRED:
}
void SATEncoder::encodeElementSATEncoder(Element *element) {
- switch ( GETELEMENTTYPE(element) ) {
+ switch ( element->type) {
case ELEMFUNCRETURN:
generateElementEncoding(element);
encodeElementFunctionSATEncoder((ElementFunction *) element);
}
void SATEncoder::encodeElementFunctionSATEncoder(ElementFunction *function) {
- switch (GETFUNCTIONTYPE(function->function)) {
+ switch (function->function->type) {
case TABLEFUNC:
encodeTableElementFunctionSATEncoder(function);
break;
#include "common.h"
Edge SATEncoder::encodeEnumEntriesTablePredicateSATEncoder(BooleanPredicate *constraint) {
- ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
+ ASSERT(constraint->predicate->type == TABLEPRED);
UndefinedBehavior undefStatus = ((PredicateTable *)constraint->predicate)->undefinedbehavior;
ASSERT(undefStatus == IGNOREBEHAVIOR || undefStatus == FLAGFORCEUNDEFINED);
Table *table = ((PredicateTable *)constraint->predicate)->table;
#ifdef TRACE_DEBUG
model_print("Enumeration Table Predicate ...\n");
#endif
- ASSERT(GETPREDICATETYPE(constraint->predicate) == TABLEPRED);
+ ASSERT(constraint->predicate->type == TABLEPRED);
//First encode children
Array<Element *> *inputs = &constraint->inputs;
uint inputNum = inputs->getSize();
#ifdef TRACE_DEBUG
model_print("Enumeration Table functions ...\n");
#endif
- ASSERT(GETFUNCTIONTYPE(elemFunc->function) == TABLEFUNC);
+ ASSERT(elemFunc->function->type == TABLEFUNC);
//First encode children
Array<Element *> *elements = &elemFunc->inputs;
for (uint i = 0; i < elements->getSize(); i++) {
}
void naiveEncodingConstraint(Boolean *This) {
- switch (GETBOOLEANTYPE(This)) {
+ switch (This->type) {
case BOOLEANVAR: {
return;
}
encoding->encodingArrayInitialization();
}
- if (GETELEMENTTYPE(This) == ELEMFUNCRETURN) {
+ if (This->type == ELEMFUNCRETURN) {
ElementFunction *function = (ElementFunction *) This;
for (uint i = 0; i < function->inputs.getSize(); i++) {
Element *element = function->inputs.get(i);
}
uint64_t CSolver::getElementValue(Element *element) {
- switch (GETELEMENTTYPE(element)) {
+ switch (element->type) {
case ELEMSET:
case ELEMCONST:
case ELEMFUNCRETURN:
}
bool CSolver::getBooleanValue(Boolean *boolean) {
- switch (GETBOOLEANTYPE(boolean)) {
+ switch (boolean->type) {
case BOOLEANVAR:
return getBooleanVariableValueSATTranslator(this, boolean);
default: