completed serializer/deserializer
[satune.git] / src / AST / function.h
index 459f0b55d3b3c8ee1c2195b7ef173f048d27cac0..98ef53641b926a0b78132e5ee65ffcfd3cce95a6 100644 (file)
@@ -3,12 +3,44 @@
 #include "classlist.h"
 #include "mymemory.h"
 #include "ops.h"
+#include "astops.h"
 #include "structs.h"
-struct Function {
+
+class Function {
+public:
+       Function(FunctionType _type) : type(_type) {}
+       FunctionType type;
+       virtual ~Function() {}
+       virtual Function *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
+       virtual void serialize(Serializer* serialiezr) =0;
+       virtual Set * getRange() = 0;
+       CMEMALLOC;
+};
+
+class FunctionOperator : public Function {
+public:
        ArithOp op;
-       VectorSet* domains;
-       Set * range;
+       Array<Set *> domains;
+       Set *range;
        OverFlowBehavior overflowbehavior;
-       Table* table;
+       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);
+       virtual void serialize(Serializer* serialiezr);
+       Set * getRange() {return range;}
+       CMEMALLOC;
+};
+
+class FunctionTable : public Function {
+public:
+       Table *table;
+       UndefinedBehavior undefBehavior;
+       FunctionTable (Table *table, UndefinedBehavior behavior);
+       Function *clone(CSolver *solver, CloneMap *map);
+       virtual void serialize(Serializer* serialiezr);
+       Set * getRange();
+       CMEMALLOC;
 };
+
 #endif