#include "function.h"
- FunctionOperator* This = (FunctionOperator*) ourmalloc(sizeof(FunctionOperator));
- GETFUNCTIONTYPE(This)=OPERATORFUNC;
- This->domains = allocVectorArraySet(numDomain, domain);
- This->op=op;
- This->overflowbehavior = overflowbehavior;
- This->range=range;
- return &This->base;
+ #include "table.h"
+ #include "set.h"
+
+
+ Function* allocFunctionOperator( ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior){
- FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable));
- GETFUNCTIONTYPE(This)=TABLEFUNC;
- This->table = table;
++ FunctionOperator* This = (FunctionOperator*) ourmalloc(sizeof(FunctionOperator));
++ GETFUNCTIONTYPE(This)=OPERATORFUNC;
++ This->domains = allocVectorArraySet(numDomain, domain);
++ This->op=op;
++ This->overflowbehavior = overflowbehavior;
++ This->range=range;
++ return &This->base;
+ }
+
+ Function* allocFunctionTable (Table* table){
- switch( GETFUNCTIONTYPE(This)){
++ FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable));
++ GETFUNCTIONTYPE(This)=TABLEFUNC;
++ This->table = table;
++ return &This->base;
+ }
+
+ void deleteFunction(Function* This){
- ourfree((FunctionTable*)This);
- break;
++ switch(GETFUNCTIONTYPE(This)){
+ case TABLEFUNC:
- ourfree((FunctionOperator*) This);
- break;
++ ourfree((FunctionTable*)This);
++ break;
+ case OPERATORFUNC:
- ASSERT(0);
- }
++ ourfree((FunctionOperator*) This);
++ break;
+ default:
++ ASSERT(0);
++ }
+ }
#include "ops.h"
#include "structs.h"
- struct Function {
- ArithOp op;
- VectorSet* domains;
- Set * range;
- OverFlowBehavior overflowbehavior;
- Table* table;
-
+ #define GETFUNCTIONTYPE(o) (((Function*)o)->type)
+
+ struct Function{
+ FunctionType type;
+ };
+
+ struct FunctionOperator {
+ Function base;
+ ArithOp op;
+ VectorSet* domains;
+ Set * range;
+ OverFlowBehavior overflowbehavior;
};
+
+ struct FunctionTable{
+ Function base;
+ Table* table;
+ };
+
+ Function* allocFunctionOperator( ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior);
+ Function* allocFunctionTable (Table* table);
+ void deleteFunction(Function* This);
+
#endif
for(uint i=0;i<size;i++) {
deleteElement(getVectorElement(This->allElements, i));
}
- //FIXME: Freeing alltables and allpredicates
- deleteVectorElement(This->allElements);
+ size=getSizeVectorTable(This->allTables);
+ for(uint i=0;i<size;i++) {
+ deleteTable(getVectorTable(This->allTables, i));
+ }
+ size=getSizeVectorPredicate(This->allPredicates);
+ for(uint i=0;i<size;i++) {
+ deletePredicate(getVectorPredicate(This->allPredicates, i));
+ }
+ size=getSizeVectorOrder(This->allOrders);
+ for(uint i=0;i<size;i++) {
+ deleteOrder(getVectorOrder(This->allOrders, i));
+ }
+ deleteVectorOrder(This->allOrders);
+ size=getSizeVectorFunction(This->allFunctions);
+ for(uint i=0;i<size;i++) {
+ deleteFunction(getVectorFunction(This->allFunctions, i));
+ }
- deleteVectorOrder(This->allFunctions);
++ deleteVectorFunction(This->allFunctions);
ourfree(This);
}