Add array object to standardize arrays
[satune.git] / src / AST / function.c
1 #include "function.h"
2 #include "table.h"
3 #include "set.h"
4
5
6 Function* allocFunctionOperator( ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior){
7         FunctionOperator* This = (FunctionOperator*) ourmalloc(sizeof(FunctionOperator));
8         GETFUNCTIONTYPE(This)=OPERATORFUNC;
9         allocInlineArrayInitSet(&This->domains, domain, numDomain);
10         This->op=op;
11         This->overflowbehavior = overflowbehavior;
12         This->range=range;
13         return &This->base;
14 }
15
16 Function* allocFunctionTable (Table* table){
17         FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable));
18         GETFUNCTIONTYPE(This)=TABLEFUNC;
19         This->table = table;
20         return &This->base;
21 }
22
23 void deleteFunction(Function* This){
24         switch(GETFUNCTIONTYPE(This)){
25         case TABLEFUNC:
26                 break;
27         case OPERATORFUNC:
28                 deleteInlineArraySet(&((FunctionOperator*) This)->domains);
29                 break;
30         default:
31                 ASSERT(0);
32         }
33         ourfree(This);
34 }