Add all C files to tabbing file
[satune.git] / src / AST / element.c
1 #include "element.h"
2 #include "structs.h"
3
4 Element *allocElementSet(Set * s) {
5         ElementSet * tmp=(ElementSet *)ourmalloc(sizeof(ElementSet));
6         GETELEMENTTYPE(tmp)= ELEMSET;
7         tmp->set=s;
8         tmp->encoding=NULL;
9         allocInlineDefVectorASTNode(GETELEMENTPARENTS(tmp));
10         return &tmp->base;
11 }
12
13 Element* allocElementFunction(Function * function, Element ** array, uint numArrays, Boolean * overflowstatus){
14         ElementFunction* tmp = (ElementFunction*) ourmalloc(sizeof(ElementFunction));
15         GETELEMENTTYPE(tmp)= ELEMFUNCRETURN;
16         tmp->function=function;
17         tmp->overflowstatus = overflowstatus;
18         allocInlineArrayInitElement(&tmp->inputs, array, numArrays);
19         allocInlineDefVectorASTNode(GETELEMENTPARENTS(tmp));
20         for(uint i=0;i<numArrays;i++)
21                 pushVectorASTNode(GETELEMENTPARENTS(array[i]), (ASTNode *) tmp);
22         return &tmp->base;
23 }
24
25 void deleteElement(Element *This) {
26         switch(GETELEMENTTYPE(This)) {
27         case ELEMFUNCRETURN:
28                 deleteInlineArrayElement(&((ElementFunction *)This)->inputs);
29                 break;
30         default:
31                 ;
32         }
33         deleteVectorArrayASTNode(GETELEMENTPARENTS(This));
34         ourfree(This);
35 }