add more comments
[IRC.git] / Robust / src / IR / Tree / OpNode.java
1 package IR.Tree;
2 import IR.Operation;
3 import IR.TypeDescriptor;
4
5 public class OpNode extends ExpressionNode {
6     ExpressionNode left;
7     ExpressionNode right;
8     Operation op;
9     TypeDescriptor td;
10     TypeDescriptor lefttype;
11     TypeDescriptor righttype;
12
13     public OpNode(ExpressionNode l, ExpressionNode r, Operation o) {
14         left=l;
15         right=r;
16         op=o;
17     }
18
19     public OpNode(ExpressionNode l, Operation o) {
20         left=l;
21         right=null;
22         op=o;
23     }
24
25     public ExpressionNode getLeft() {
26         return left;
27     }
28
29     public ExpressionNode getRight() {
30         return right;
31     }
32
33     public Operation getOp() {
34         return op;
35     }
36
37     public String printNode(int indent) {
38         if (right==null)
39             return op.toString()+"("+left.printNode(indent)+")";
40         else
41             return left.printNode(indent)+" "+op.toString()+" "+right.printNode(indent);
42     }
43
44     public void setLeftType(TypeDescriptor argtype) {
45         this.lefttype=argtype;
46     }
47
48     public TypeDescriptor getLeftType() {
49         return lefttype;
50     }
51
52     public void setRightType(TypeDescriptor argtype) {
53         this.righttype=argtype;
54     }
55
56     public TypeDescriptor getRightType() {
57         return righttype;
58     }
59
60     public TypeDescriptor getType() {
61         return td;
62     }
63
64     public void setType(TypeDescriptor td) {
65         this.td=td;
66     }
67
68     public int kind() {
69         return Kind.OpNode;
70     }
71 }