backout changes
[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 Set * getRange() = 0;
17         CMEMALLOC;
18 };
19
20 class FunctionOperator : public Function {
21 public:
22         ArithOp op;
23         Array<Set *> domains;
24         Set *range;
25         OverFlowBehavior overflowbehavior;
26         FunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
27         uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
28         bool isInRangeFunction(uint64_t val);
29         Function *clone(CSolver *solver, CloneMap *map);
30         virtual void serialize(Serializer* serialiezr);
31         Set * getRange() {return range;}
32         CMEMALLOC;
33 };
34
35 class FunctionTable : public Function {
36 public:
37         Table *table;
38         UndefinedBehavior undefBehavior;
39         FunctionTable (Table *table, UndefinedBehavior behavior);
40         Function *clone(CSolver *solver, CloneMap *map);
41         virtual void serialize(Serializer* serialiezr);
42         Set * getRange();
43         CMEMALLOC;
44 };
45
46 #endif