X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=src%2FAST%2Ffunction.h;h=2d65f61a009d0e4d6d744b527bbb7aadf37edf21;hb=85d422935f1a6ebdb689f4108185521b022a51d9;hp=37e13762c512076905270524a37b533470bc48d0;hpb=5f7ad155a72a38dda20e1ffd4e8bf8c7c1132251;p=satune.git diff --git a/src/AST/function.h b/src/AST/function.h index 37e1376..2d65f61 100644 --- a/src/AST/function.h +++ b/src/AST/function.h @@ -3,32 +3,46 @@ #include "classlist.h" #include "mymemory.h" #include "ops.h" +#include "astops.h" #include "structs.h" -#define GETFUNCTIONTYPE(o) (((Function *)o)->type) - -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 void print() = 0; + virtual Set *getRange() = 0; + CMEMALLOC; }; -struct FunctionOperator { - Function base; +class FunctionOperator : public Function { +public: ArithOp op; - ArraySet domains; Set *range; OverFlowBehavior overflowbehavior; + FunctionOperator(ArithOp op, 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); + virtual void print(); + Set *getRange() {return range;} + CMEMALLOC; }; -struct FunctionTable { - Function base; +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); + virtual void print(); + Set *getRange(); + CMEMALLOC; }; -Function *allocFunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior); -Function *allocFunctionTable (Table *table, UndefinedBehavior behavior); -uint64_t applyFunctionOperator(FunctionOperator *This, uint numVals, uint64_t *values); -bool isInRangeFunction(FunctionOperator *This, uint64_t val); -void deleteFunction(Function *This); - #endif