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 op=Opcode.translateOpcode(negate,op);
38 if (leftexpr instanceof VarExpr)
43 VarDescriptor getVar() {
45 return ((VarExpr)leftexpr).getVar();
46 } else if (isField()) {
49 for(;e instanceof DotExpr;e=((DotExpr)e).getExpr()) ;
50 if (e instanceof VarExpr)
52 if (e instanceof CastExpr)
53 e=((CastExpr)e).getExpr();
54 else throw new Error("Unrecognized Expr:"+e.name());
56 return ((VarExpr)e).getVar();
58 System.out.println(toString());
59 throw new Error("Unrecognized Update");
63 Descriptor getDescriptor() {
65 return ((VarExpr)leftexpr).getVar();
66 } else if (isField()) {
67 return ((DotExpr)leftexpr).getField();
69 System.out.println(toString());
70 throw new Error("Unrecognized Update");
75 if (leftexpr instanceof DotExpr) {
76 assert ((DotExpr)leftexpr).getIndex()==null;
83 return type==Updates.EXPR;
91 public Updates(Expr lexpr, Expr rexpr) {
93 System.out.println("Building invalid update");
100 public Updates(Expr lexpr, int rpos) {
101 if (!lexpr.isValue())
102 System.out.println("Building invalid update");
105 type=Updates.POSITION;
109 boolean isAbstract() {
110 return type==Updates.ABSTRACT;
113 public Updates(Expr lexpr,boolean negates) {
115 type=Updates.ABSTRACT;
120 public int getType() {
123 public Expr getLeftExpr() {
126 public int getRightPos() {
127 assert type==Updates.POSITION;
128 return rightposition;
130 public Expr getRightExpr() {
131 assert type==Updates.EXPR;