-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.h
executable file
·51 lines (35 loc) · 1.12 KB
/
Function.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef FUNCTION_H
#define FUNCTION_H
#include "Record.h"
#include "ParseTree.h"
#define MAX_DEPTH 100
enum ArithOp {PushInt, PushDouble, ToDouble, ToDouble2Down,
IntUnaryMinus, IntMinus, IntPlus, IntDivide, IntMultiply,
DblUnaryMinus, DblMinus, DblPlus, DblDivide, DblMultiply};
struct Arithmatic {
ArithOp myOp;
int recInput;
void *litInput;
};
class Function {
private:
Arithmatic *opList;
int numOps;
public:
Function ();
int returnsInt;
// this grows the specified function from a parse tree and converts
// it into an accumulator-based computation over the attributes in
// a record with the given schema; the record "literal" is produced
// by the GrowFromParseTree method
void GrowFromParseTree (struct FuncOperator *parseTree, Schema &mySchema);
// helper function
Type RecursivelyBuild (struct FuncOperator *parseTree, Schema &mySchema);
// prints out the function to the screen
void Print ();
// applies the function to the given record and returns the result
Type Apply (Record &toMe, int &intResult, double &doubleResult);
//Returns the type of the result
Type getReturnType ();
};
#endif