Boolean* allocBoolean(VarType t) {
Boolean* tmp=(Boolean*) ourmalloc(sizeof (Boolean));
- tmp->vtype=t;
- tmp->btype=_BOOLEAN;
+ tmp->btype=BOOLEANVAR;
+ tmp->var.vtype=t;
return tmp;
}
-Boolean* allocBooleanOrder(Order* order,uint64_t first, uint64_t second) {
+Boolean* allocBooleanOrder(Order* order, uint64_t first, uint64_t second) {
Boolean* tmp=(Boolean*) ourmalloc(sizeof (Boolean));
- tmp->btype=_ORDER;
- tmp->order=order;
- tmp->first=first;
- tmp->second=second;
+ tmp->btype=ORDERCONST;
+ tmp->order.order=order;
+ tmp->order.first=first;
+ tmp->order.second=second;
return tmp;
}
#include "classlist.h"
#include "mymemory.h"
#include "ops.h"
-struct Boolean {
- VarType vtype;
- enum BooleanType btype;
+
+struct BooleanOrder {
Order* order;
uint64_t first;
uint64_t second;
};
-Boolean* allocBoolean(VarType t);
-Boolean* allocBooleanOrder(Order* order,uint64_t first, uint64_t second);
+struct BooleanVar {
+ VarType vtype;
+};
+
+struct BooleanLogic {
+ LogicOp op;
+ Boolean * left;
+ Boolean * right;
+};
+
+struct BooleanComp {
+ CompOp op;
+ Boolean * left;
+ Boolean * right;
+};
+
+struct Boolean {
+ BooleanType btype;
+ union {
+ BooleanOrder order;
+ BooleanVar var;
+ BooleanLogic logic;
+ BooleanComp comp;
+ };
+};
+
+Boolean * allocBoolean(VarType t);
+Boolean * allocBooleanOrder(Order * order, uint64_t first, uint64_t second);
void deleteBoolean(Boolean * this);
#endif
*/
enum OverFlowBehavior {IGNORE, WRAPAROUND, FLAGFORCESOVERFLOW, OVERFLOWSETSFLAG, FLAGIFFOVERFLOW, NOOVERFLOW};
-enum BooleanType {_ORDER, _BOOLEAN};
+enum BooleanType {ORDERCONST, BOOLEANVAR, LOGICOP, COMPARE};
#endif
ElementEncoding * this=(ElementEncoding *)ourmalloc(sizeof(ElementEncoding));
this->element=element;
this->type=type;
+ this->variables=NULL;
+ this->encodingArray=NULL;
+ this->numVars=0;
return this;
}
void deleteElementEncoding(ElementEncoding *this) {
+ if (this->variables!=NULL)
+ ourfree(this->variables);
+ if (this->encodingArray!=NULL)
+ ourfree(this->encodingArray);
ourfree(this);
}
struct ElementEncoding {
ElementEncodingType type;
Element * element;
+ Boolean ** variables; /* List Variables Use To Encode Element */
+ uint64_t * encodingArray; /* List the Variables in the appropriate order */
+ uint numVars; /* Number of variables */
};
ElementEncoding * allocElementEncoding(ElementEncodingType type, Element *element);
struct Constraint;
typedef struct Constraint Constraint;
+typedef struct BooleanOrder BooleanOrder;
+typedef struct BooleanVar BooleanVar;
+typedef struct BooleanLogic BooleanLogic;
+typedef struct BooleanComp BooleanComp;
+
struct Boolean;
typedef struct Boolean Boolean;
typedef enum LogicOp LogicOp;
typedef enum CompOp CompOp;
typedef enum OrderType OrderType;
+typedef enum BooleanType BooleanType;
typedef enum OverFlowBehavior OverFlowBehavior;
typedef unsigned int uint;