BooleanPredicate* This = (BooleanPredicate*) ourmalloc(sizeof(BooleanPredicate));
GETBOOLEANTYPE(This)= PREDICATEOP;
This->predicate=predicate;
- This->inputs= allocVectorArrayElement (numInputs,inputs);
+ This->inputs=ourmalloc(sizeof(Element*)*numInputs);
+ memcpy(This->inputs, inputs, sizeof(Element*)*numInputs);
+ This->numInputs=numInputs;
allocInlineDefVectorBoolean(GETBOOLEANPARENTS(This));
for(uint i=0;i<numInputs;i++) {
Boolean * allocBooleanLogicArray(CSolver *solver, LogicOp op, Boolean ** array, uint asize){
BooleanLogic * This = ourmalloc(sizeof(BooleanLogic));
allocInlineDefVectorBoolean(GETBOOLEANPARENTS(This));
- This->array = ourmalloc(sizeof(Boolean *)*asize);
+ This->array=ourmalloc(sizeof(Boolean *)*asize);
memcpy(This->array, array, sizeof(Boolean *)*asize);
for(uint i=0;i<asize;i++) {
pushVectorBoolean(GETBOOLEANPARENTS(array[i]), (Boolean *)This);
void deleteBoolean(Boolean * This) {
switch(GETBOOLEANTYPE(This)){
case PREDICATEOP:
- deleteVectorArrayElement( ((BooleanPredicate*)This)->inputs );
+ ourfree(((BooleanPredicate*)This)->inputs );
break;
default:
break;
struct BooleanPredicate {
Boolean base;
Predicate * predicate;
- VectorElement* inputs;
+ Element** inputs;
+ int numInputs;
};
Boolean * allocBoolean(VarType t);
GETELEMENTTYPE(tmp)= ELEMFUNCRETURN;
tmp->function=function;
tmp->overflowstatus = overflowstatus;
- tmp->Elements = allocVectorArrayElement(numArrays, array);
+ tmp->inputs=ourmalloc(sizeof(Element *)*numArrays);
+ tmp->numInputs=numArrays;
+ memcpy(tmp->inputs, array, numArrays*sizeof(Element *));
allocInlineDefVectorASTNode(GETELEMENTPARENTS(tmp));
for(uint i=0;i<numArrays;i++)
pushVectorASTNode(GETELEMENTPARENTS(array[i]), (ASTNode *) tmp);
}
void deleteElement(Element *This) {
+ switch(GETELEMENTTYPE(This)) {
+ case ELEMFUNCRETURN:
+ ourfree(((ElementFunction *)This)->inputs);
+ break;
+ default:
+ ;
+ }
deleteVectorArrayASTNode(GETELEMENTPARENTS(This));
ourfree(This);
}
struct ElementFunction {
Element base;
Function * function;
- VectorElement* Elements;
+ Element ** inputs;
+ uint numInputs;
Boolean * overflowstatus;
};
#include "csolver.h"
#include "boolean.h"
#include "constraint.h"
+#include "common.h"
SATEncoder * allocSATEncoder() {
SATEncoder *This=ourmalloc(sizeof (SATEncoder));
case LOGICOP:
return encodeLogicSATEncoder(This, (BooleanLogic *) constraint);
default:
- printf("Unhandled case in encodeConstraintSATEncoder %u", GETBOOLEANTYPE(constraint));
+ model_print("Unhandled case in encodeConstraintSATEncoder %u", GETBOOLEANTYPE(constraint));
exit(-1);
}
}
case L_IMPLIES:
return allocConstraint(IMPLIES, array[0], array[1]);
default:
- printf("Unhandled case in encodeLogicSATEncoder %u", constraint->op);
+ model_print("Unhandled case in encodeLogicSATEncoder %u", constraint->op);
exit(-1);
}
-
- return NULL;
}