Compiles
[satune.git] / src / AST / element.h
index da9b994e7df39219659b087c2631d9d7ff39c99b..c3a3ed9fe2bd764207756b8fdfbc755cd1dfd0cc 100644 (file)
@@ -2,30 +2,58 @@
 #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;
+       virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
 
-//FIXME:TALK ABOUT ELEMENT
-struct Element {
-       ElementType type;
+       CMEMALLOC;
 };
 
-struct ElementSet {
-       Element base;
-       Set * set;
-       ElementEncoding * encoding;
+class ElementConst : public Element {
+public:
+       ElementConst(uint64_t value, VarType type, Set *_set);
+       Set *set;
+       uint64_t value;
+       Element *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
 };
 
-struct ElementFunction {
-       Element base;
-       Function * function;
-       VectorElement* Elements;
-       Boolean * overflowstatus;
+class ElementSet : public Element {
+public:
+       ElementSet(Set *s);
+       Set *set;
+       Element *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
 };
 
-Element * allocElementSet(Set *s);
-Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
-void deleteElement(Element *This);
+class ElementFunction : public Element {
+public:
+       ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
+       Function *function;
+       Array<Element *> inputs;
+       BooleanEdge overflowstatus;
+       FunctionEncoding functionencoding;
+       Element *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
+};
+
+Set *getElementSet(Element *This);
+
+static inline ElementEncoding *getElementEncoding(Element *e) {
+       return &e->encoding;
+}
+
+static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
+       return &func->functionencoding;
+}
 #endif