edit
[satune.git] / src / AST / function.h
1 #ifndef FUNCTION_H
2 #define FUNCTION_H
3 #include "classlist.h"
4 #include "mymemory.h"
5 #include "ops.h"
6 #include "astops.h"
7 #include "structs.h"
8
9 class Function {
10 public:
11         Function(FunctionType _type) : type(_type) {}
12         FunctionType type;
13         virtual ~Function() {}
14         virtual Function *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;}
15         virtual void serialize(Serializer *serialiezr) = 0;
16         virtual void print() = 0;
17         virtual Set *getRange() = 0;
18         CMEMALLOC;
19 };
20
21 class FunctionOperator : public Function {
22 public:
23         ArithOp op;
24         Array<Set *> domains;
25         Set *range;
26         OverFlowBehavior overflowbehavior;
27         FunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
28         uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
29         bool isInRangeFunction(uint64_t val);
30         Function *clone(CSolver *solver, CloneMap *map);
31         virtual void serialize(Serializer *serialiezr);
32         virtual void print();
33         Set *getRange() {return range;}
34         CMEMALLOC;
35 };
36
37 class FunctionTable : public Function {
38 public:
39         Table *table;
40         UndefinedBehavior undefBehavior;
41         FunctionTable (Table *table, UndefinedBehavior behavior);
42         Function *clone(CSolver *solver, CloneMap *map);
43         virtual void serialize(Serializer *serialiezr);
44         virtual void print();
45         Set *getRange();
46         CMEMALLOC;
47 };
48
49 #endif