4 static public final int EXPR=0;
5 static public final int POSITION=1;
6 static public final int ABSTRACT=2;
14 public String toString() {
16 return leftexpr.name()+opcode.toString()+rightexpr.name();
17 else if (type==POSITION)
18 return leftexpr.name()+opcode.toString()+"Position("+String.valueOf(rightposition)+")";
19 else if (type==ABSTRACT) {
20 if (negate) return "!"+leftexpr.name();
21 else return leftexpr.name();
22 } else throw new Error("Unrecognized type");
25 public Updates(Expr lexpr, Expr rexpr, Opcode op, boolean negate) {
27 System.out.println("Building invalid update");
31 /* remove negation through opcode translation */
34 else if (op==Opcode.GE)
36 else if (op==Opcode.EQ)
38 else if (op==Opcode.NE)
40 else if (op==Opcode.LT)
42 else if (op==Opcode.LE)
50 if (leftexpr instanceof VarExpr)
55 VarDescriptor getVar() {
57 return ((VarExpr)leftexpr).getVar();
58 } else if (isField()) {
61 for(;e instanceof DotExpr;e=((DotExpr)e).getExpr()) ;
62 if (e instanceof VarExpr)
64 if (e instanceof CastExpr)
65 e=((CastExpr)e).getExpr();
66 else throw new Error("Unrecognized Expr:"+e.name());
68 return ((VarExpr)e).getVar();
70 System.out.println(toString());
71 throw new Error("Unrecognized Update");
75 Descriptor getDescriptor() {
77 return ((VarExpr)leftexpr).getVar();
78 } else if (isField()) {
79 return ((DotExpr)leftexpr).getField();
81 System.out.println(toString());
82 throw new Error("Unrecognized Update");
87 if (leftexpr instanceof DotExpr) {
88 assert ((DotExpr)leftexpr).getIndex()==null;
95 return type==Updates.EXPR;
103 public Updates(Expr lexpr, Expr rexpr) {
104 if (!lexpr.isValue())
105 System.out.println("Building invalid update");
112 public Updates(Expr lexpr, int rpos) {
113 if (!lexpr.isValue())
114 System.out.println("Building invalid update");
117 type=Updates.POSITION;
121 boolean isAbstract() {
122 return type==Updates.ABSTRACT;
125 public Updates(Expr lexpr,boolean negates) {
127 type=Updates.ABSTRACT;
132 public int getType() {
135 public Expr getLeftExpr() {
138 public int getRightPos() {
139 assert type==Updates.POSITION;
140 return rightposition;
142 public Expr getRightExpr() {
143 assert type==Updates.EXPR;