Merge branch 'hamed' into brian
[satune.git] / src / AST / element.h
index 7886e4cc8d3073eb307851b24be86a0a5eff9204..509ee8c3d34566c21faf9f4e8d78d2fca84f6e4d 100644 (file)
@@ -4,10 +4,12 @@
 #include "mymemory.h"
 #include "structs.h"
 #include "astnode.h"
+#include "functionencoding.h"
+#include "elementencoding.h"
+#include "boolean.h"
 
 #define GETELEMENTTYPE(o) GETASTNODETYPE(o)
-#define GETELEMENTPARENTS(o) (&((Element*)o)->parents)
-
+#define GETELEMENTPARENTS(o) (&((Element*)o)->parents)         
 struct Element {
        ASTNode base;
        VectorASTNode parents;
@@ -16,7 +18,7 @@ struct Element {
 struct ElementSet {
        Element base;
        Set * set;
-       ElementEncoding encoding;
+       ElementEncoding encoding;
 };
 
 struct ElementFunction {
@@ -24,9 +26,29 @@ struct ElementFunction {
        Function * function;
        ArrayElement inputs;
        Boolean * overflowstatus;
+       FunctionEncoding functionencoding;
+       ElementEncoding domainencoding;
 };
 
 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)->domainencoding;
+               default:
+                       ASSERT(0);
+       }
+       return NULL;
+}
+
+
+static inline FunctionEncoding* getElementFunctionEncoding(ElementFunction* func){
+       return &func->functionencoding;
+}
+
 #endif