towards cloning
[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 "structs.h"
7
8 #define GETFUNCTIONTYPE(o) (((Function *)o)->type)
9
10 class Function {
11 public:
12         Function(FunctionType _type) : type(_type) {}
13         FunctionType type;
14         virtual ~Function() {}
15         virtual Function * clone(CSolver * solver, CloneMap *map);
16         MEMALLOC;
17 };
18
19 class FunctionOperator : public Function {
20 public:
21         ArithOp op;
22         Array<Set *> domains;
23         Set *range;
24         OverFlowBehavior overflowbehavior;
25         FunctionOperator(ArithOp op, Set **domain, uint numDomain, Set *range, OverFlowBehavior overflowbehavior);
26         uint64_t applyFunctionOperator(uint numVals, uint64_t *values);
27         bool isInRangeFunction(uint64_t val);
28         Function * clone(CSolver * solver, CloneMap *map);
29         MEMALLOC;
30 };
31
32 class FunctionTable : public Function {
33 public:
34         Table *table;
35         UndefinedBehavior undefBehavior;
36         FunctionTable (Table *table, UndefinedBehavior behavior);
37         Function * clone(CSolver * solver, CloneMap *map);
38         MEMALLOC;
39 };
40
41 #endif