#include "elementencoding.h"
#include "boolean.h"
-#define GETELEMENTTYPE(o) GETASTNODETYPE(o)
-#define GETELEMENTPARENTS(o) (&((Element *)o)->parents)
-struct Element {
- ASTNode base;
- VectorASTNode parents;
+class Element : public ASTNode {
+public:
+ Element(ASTNodeType type);
+ virtual ~Element() {}
+ Vector<ASTNode *> parents;
+ ElementEncoding encoding;
+ virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
+
+ CMEMALLOC;
};
-struct ElementConst {
- Element base;
+class ElementConst : public Element {
+public:
+ ElementConst(uint64_t value, VarType type, Set *_set);
Set *set;
uint64_t value;
- ElementEncoding encoding;
+ Element *clone(CSolver *solver, CloneMap *map);
+ CMEMALLOC;
};
-struct ElementSet {
- Element base;
+class ElementSet : public Element {
+public:
+ ElementSet(Set *s);
Set *set;
- ElementEncoding encoding;
+ Element *clone(CSolver *solver, CloneMap *map);
+ CMEMALLOC;
};
-struct ElementFunction {
- Element base;
+class ElementFunction : public Element {
+public:
+ ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
Function *function;
- ArrayElement inputs;
- Boolean *overflowstatus;
+ Array<Element *> inputs;
+ BooleanEdge overflowstatus;
FunctionEncoding functionencoding;
- ElementEncoding rangeencoding;
+ Element *clone(CSolver *solver, CloneMap *map);
+ CMEMALLOC;
};
-Element *allocElementConst(uint64_t value, VarType type);
-Element *allocElementSet(Set *s);
-Element *allocElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
-void deleteElement(Element *This);
Set *getElementSet(Element *This);
-static inline ElementEncoding *getElementEncoding(Element *This) {
- switch (GETELEMENTTYPE(This)) {
- case ELEMSET:
- return &((ElementSet *)This)->encoding;
- case ELEMFUNCRETURN:
- return &((ElementFunction *)This)->rangeencoding;
- case ELEMCONST:
- return &((ElementConst *)This)->encoding;
- default:
- ASSERT(0);
- }
- return NULL;
+static inline ElementEncoding *getElementEncoding(Element *e) {
+ return &e->encoding;
}
static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {