Fix warnings, merge, and check my code in
authorbdemsky <bdemsky@uci.edu>
Tue, 20 Jun 2017 01:51:52 +0000 (18:51 -0700)
committerbdemsky <bdemsky@uci.edu>
Tue, 20 Jun 2017 01:51:52 +0000 (18:51 -0700)
1  2 
src/AST/function.c
src/AST/function.h
src/AST/ops.h
src/Encoders/functionencoding.c
src/classlist.h
src/csolver.c

@@@ -1,1 -1,33 +1,34 @@@
  #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);
++      }
+ }
@@@ -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/AST/ops.h
Simple merge
Simple merge
diff --cc src/classlist.h
Simple merge
diff --cc src/csolver.c
@@@ -41,8 -44,24 +44,24 @@@ void deleteSolver(CSolver *This) 
        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);
  }