-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunction.h
More file actions
52 lines (35 loc) · 1.13 KB
/
Function.h
File metadata and controls
52 lines (35 loc) · 1.13 KB
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
52
#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;
int returnsInt;
public:
Function();
// 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(Schema *schema);
// applies the function to the given record and returns the result
Type Apply(Record &toMe, int &intResult, double &doubleResult);
};
#endif