backout changes
[satune.git] / src / AST / element.h
index 4119b7d2f3dede9555fc7767167a3ae9882ac6af..72b2ea636c47b238b38a75ebf5dba316c2ac413c 100644 (file)
@@ -2,28 +2,64 @@
 #define ELEMENT_H
 #include "classlist.h"
 #include "mymemory.h"
-#include "ops.h"
 #include "structs.h"
+#include "astnode.h"
+#include "functionencoding.h"
+#include "elementencoding.h"
+#include "boolean.h"
 
-#define GETELEMENTTYPE(o) (((Element*)o)->type)
+class Element : public ASTNode {
+public:
+       Element(ASTNodeType type);
+       virtual ~Element() {}
+       Vector<ASTNode *> parents;
+       ElementEncoding encoding;
+       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 ElementSet : public Element {
+public:
+       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;
 
-struct Element {
-       ElementType type;
 };
 
-struct ElementSet {
-    Element base;
-    Set * set;
+class ElementConst : public ElementSet {
+public:
+       ElementConst(uint64_t value, Set *_set);
+       uint64_t value;
+       virtual void serialize(Serializer* serializer);
+       Element *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
 };
 
-struct ElementFunction{
-    Element base;
-    Function * function;
-    VectorElement* Elements;
-    Boolean * overflowstatus;
+class ElementFunction : public Element {
+public:
+       ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
+       Array<Element *> inputs;
+       BooleanEdge overflowstatus;
+       FunctionEncoding functionencoding;
+       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;
 };
 
-Element * allocElementSet(Set *s);
-Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
-void deleteElement(Element *This);
+
 #endif