From: bdemsky Date: Tue, 20 Jun 2017 01:51:52 +0000 (-0700) Subject: Fix warnings, merge, and check my code in X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c507619d06bc6fbddc5fc26016be9bb47daa0ae0;p=satune.git Fix warnings, merge, and check my code in --- c507619d06bc6fbddc5fc26016be9bb47daa0ae0 diff --cc src/AST/function.c index d4b693e,c9d0717..c816363 --- a/src/AST/function.c +++ b/src/AST/function.c @@@ -1,1 -1,33 +1,34 @@@ #include "function.h" + #include "table.h" + #include "set.h" + + + Function* allocFunctionOperator( ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior){ - 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; ++ 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){ - FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable)); - GETFUNCTIONTYPE(This)=TABLEFUNC; - This->table = table; ++ FunctionTable* This = (FunctionTable*) ourmalloc(sizeof(FunctionTable)); ++ GETFUNCTIONTYPE(This)=TABLEFUNC; ++ This->table = table; ++ return &This->base; + } + + void deleteFunction(Function* This){ - switch( GETFUNCTIONTYPE(This)){ ++ switch(GETFUNCTIONTYPE(This)){ + case TABLEFUNC: - ourfree((FunctionTable*)This); - break; ++ ourfree((FunctionTable*)This); ++ break; + case OPERATORFUNC: - ourfree((FunctionOperator*) This); - break; ++ ourfree((FunctionOperator*) This); ++ break; + default: - ASSERT(0); - } ++ ASSERT(0); ++ } + } diff --cc src/AST/function.h index 65a4b29,e22ec75..3f2a1a9 --- a/src/AST/function.h +++ b/src/AST/function.h @@@ -5,11 -5,28 +5,27 @@@ #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 diff --cc src/csolver.c index 7179222,62f4acd..7a9d1e0 --- a/src/csolver.c +++ b/src/csolver.c @@@ -41,8 -44,24 +44,24 @@@ void deleteSolver(CSolver *This) for(uint i=0;iallElements, i)); } - //FIXME: Freeing alltables and allpredicates - deleteVectorElement(This->allElements); + size=getSizeVectorTable(This->allTables); + for(uint i=0;iallTables, i)); + } + size=getSizeVectorPredicate(This->allPredicates); + for(uint i=0;iallPredicates, i)); + } + size=getSizeVectorOrder(This->allOrders); + for(uint i=0;iallOrders, i)); + } + deleteVectorOrder(This->allOrders); + size=getSizeVectorFunction(This->allFunctions); + for(uint i=0;iallFunctions, i)); + } - deleteVectorOrder(This->allFunctions); ++ deleteVectorFunction(This->allFunctions); ourfree(This); }