-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestAATBuildTree.java
More file actions
72 lines (63 loc) · 2.89 KB
/
Copy pathTestAATBuildTree.java
File metadata and controls
72 lines (63 loc) · 2.89 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.Vector;
class TestAATBuildTree {
public static void main(String args[]) {
AATBuildTree bt = new AATBuildTree();
AATPrintTree pt = new AATPrintTree();
AATExpression exptree, exptree2, exptree3;
AATStatement stmtree, functiondefs;
Vector actuals;
System.out.println("=================== ");
System.out.println("Testing Expressions ");
System.out.println("=================== ");
System.out.println("----------------------------");
System.out.println("Testing literal constat : 15 ");
System.out.println("----------------------------");
exptree = bt.constantExpression(15);
exptree.Accept(pt);
System.out.println("--------------------------");
System.out.println("Testing expression : 4 + 5 ");
System.out.println("--------------------------");
exptree = bt.operatorExpression(bt.constantExpression(4),bt.constantExpression(5),
AATOperator.PLUS);
exptree.Accept(pt);
System.out.println("================= ");
System.out.println("Testing Variables ");
System.out.println("================= ");
System.out.println("-------------------------------");
System.out.println("Testing base variable, offset 4 ");
System.out.println("-------------------------------");
exptree = bt.baseVariable(4);
exptree.Accept(pt);
System.out.println("-------------------------------");
System.out.println("Testing array variable, offset 0, index is 2, elementSize is 4");
System.out.println("-------------------------------");
exptree = bt.baseVariable(4);
exptree2 = bt.constantExpression(2);
exptree = bt.arrayVariable(exptree, exptree2, 4);
exptree.Accept(pt);
System.out.println("-------------------------------");
System.out.println("Testing class variable, offset for base 0, offset for var 8");
System.out.println("-------------------------------");
exptree = bt.baseVariable(0);
exptree = bt.classVariable(exptree, 8);
exptree.Accept(pt);
System.out.println("----------------------------------------");
System.out.println("Assingment: x := 3 (x local, offset = 4)");
System.out.println("----------------------------------------");
stmtree = bt.assignmentStatement(bt.baseVariable(4), bt.constantExpression(3));
stmtree.Accept(pt);
System.out.println("-----------------------------------------------------------");
System.out.println("For: for(i=0; i < 10; i++) x := 0; x offset 4, i offset 8 ");
System.out.println("------------------------------------------------------------");
stmtree = bt.forStatement(bt.assignmentStatement(bt.baseVariable(8), bt.constantExpression(0)),
bt.operatorExpression(bt.baseVariable(8), bt.constantExpression(10), AATOperator.LESS_THAN),
bt.assignmentStatement(bt.baseVariable(8),
bt.operatorExpression(bt.baseVariable(8),
bt.constantExpression(1),
AATOperator.PLUS)),
bt.assignmentStatement(bt.baseVariable(4),
bt.constantExpression(0)));
stmtree.Accept(pt);
/* Add more tests !!! */
}
}