#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);
virtual ~Element() {}
Vector<ASTNode *> parents;
ElementEncoding encoding;
- virtual Element * clone(CSolver * solver, CloneMap * map);
- MEMALLOC;
+ inline ElementEncoding *getElementEncoding(){ return &encoding; }
+ virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
+ virtual void serialize(Serializer* serializer) =0;
+ virtual void updateParents() {}
+ virtual Set * getRange() = 0;
+ CMEMALLOC;
};
-class ElementConst : public Element {
+class ElementSet : public Element {
public:
- ElementConst(uint64_t value, VarType type, Set *_set);
+ ElementSet(ASTNodeType type, Set *s);
+ ElementSet(Set *s);
+ virtual Element *clone(CSolver *solver, CloneMap *map);
+ virtual void serialize(Serializer* serializer);
+ CMEMALLOC;
+ Set *getRange() {return set;}
+ protected:
Set *set;
- uint64_t value;
- Element * clone(CSolver * solver, CloneMap * map);
- MEMALLOC;
+
};
-class ElementSet : public Element {
+class ElementConst : public ElementSet {
public:
- ElementSet(Set *s);
- Set *set;
- Element * clone(CSolver * solver, CloneMap * map);
- MEMALLOC;
+ ElementConst(uint64_t value, Set *_set);
+ uint64_t value;
+ virtual void serialize(Serializer* serializer);
+ Element *clone(CSolver *solver, CloneMap *map);
+ CMEMALLOC;
};
class ElementFunction : public Element {
public:
- ElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
- Function *function;
+ ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
Array<Element *> inputs;
- Boolean *overflowstatus;
+ BooleanEdge overflowstatus;
FunctionEncoding functionencoding;
- Element * clone(CSolver * solver, CloneMap * map);
- MEMALLOC;
+ Element *clone(CSolver *solver, CloneMap *map);
+ virtual void serialize(Serializer* serializer);
+ Set * getRange();
+ void updateParents();
+ Function * getFunction() {return function;}
+ inline FunctionEncoding *getElementFunctionEncoding() {return &functionencoding;}
+ CMEMALLOC;
+ private:
+ Function *function;
};
-Set *getElementSet(Element *This);
-
-static inline ElementEncoding *getElementEncoding(Element *e) {
- return &e->encoding;
-}
-static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
- return &func->functionencoding;
-}
#endif