Merge branch 'hamed' into brian
[satune.git] / src / AST / element.h
1 #ifndef ELEMENT_H
2 #define ELEMENT_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "structs.h"
6 #include "astnode.h"
7 #include "functionencoding.h"
8 #include "elementencoding.h"
9 #include "boolean.h"
10
11 #define GETELEMENTTYPE(o) GETASTNODETYPE(o)
12 #define GETELEMENTPARENTS(o) (&((Element*)o)->parents)          
13 struct Element {
14         ASTNode base;
15         VectorASTNode parents;
16 };
17
18 struct ElementSet {
19         Element base;
20         Set * set;
21         ElementEncoding encoding;
22 };
23
24 struct ElementFunction {
25         Element base;
26         Function * function;
27         ArrayElement inputs;
28         Boolean * overflowstatus;
29         FunctionEncoding functionencoding;
30         ElementEncoding domainencoding;
31 };
32
33 Element * allocElementSet(Set *s);
34 Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus);
35 void deleteElement(Element *This);
36 Set* getElementSet(Element* This);
37 static inline ElementEncoding* getElementEncoding(Element* This){
38         switch(GETELEMENTTYPE(This)){
39                 case ELEMSET:
40                         return &((ElementSet*)This)->encoding;
41                 case ELEMFUNCRETURN:            
42                         return &((ElementFunction*)This)->domainencoding;
43                 default:
44                         ASSERT(0);
45         }
46         return NULL;
47 }
48
49
50 static inline FunctionEncoding* getElementFunctionEncoding(ElementFunction* func){
51         return &func->functionencoding;
52 }
53
54 #endif