Bug Fix
[satune.git] / src / AST / function.h
index e22ec7524bcb9194418082da8d7f25e4b940141d..fcb5068ad7703b296130450f6cebad838edacae5 100644 (file)
@@ -3,30 +3,38 @@
 #include "classlist.h"
 #include "mymemory.h"
 #include "ops.h"
+#include "astops.h"
 #include "structs.h"
 
-
-#define GETFUNCTIONTYPE(o) (((Function*)o)->type)
-
-struct Function{
-    FunctionType type;
+class Function {
+public:
+       Function(FunctionType _type) : type(_type) {}
+       FunctionType type;
+       virtual ~Function() {}
+       virtual Function *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
+       CMEMALLOC;
 };
 
-struct FunctionOperator {
-    Function base;
-    ArithOp op;
-    VectorSet* domains;
-    Set * range;
-    OverFlowBehavior overflowbehavior;
+class FunctionOperator : public Function {
+public:
+       ArithOp op;
+       Array<Set *> domains;
+       Set *range;
+       OverFlowBehavior overflowbehavior;
+       FunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
+       uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
+       bool isInRangeFunction(uint64_t val);
+       Function *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
 };
 
-struct FunctionTable{
-    Function base;
-    Table* table;
+class FunctionTable : public Function {
+public:
+       Table *table;
+       UndefinedBehavior undefBehavior;
+       FunctionTable (Table *table, UndefinedBehavior behavior);
+       Function *clone(CSolver *solver, CloneMap *map);
+       CMEMALLOC;
 };
 
-Function* allocFunctionOperator( ArithOp op, Set ** domain, uint numDomain, Set * range,OverFlowBehavior overflowbehavior);
-Function* allocFunctionTable (Table* table);
-void deleteFunction(Function* This);
-
 #endif