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() {
15 String st="type="+type+"\n";
16 st+="rightposition="+rightposition+"\n";
18 st+="rightexpr="+rightexpr.name()+"\n";
20 st+="leftexpr="+leftexpr.name()+"\n";
21 st+="opcode="+opcode+"\n";
22 st+="negate="+negate+"\n";
26 public Updates(Expr lexpr, Expr rexpr, Opcode op, boolean negate) {
30 /* remove negation through opcode translation */
33 else if (op==Opcode.GE)
35 else if (op==Opcode.EQ)
37 else if (op==Opcode.NE)
39 else if (op==Opcode.LT)
41 else if (op==Opcode.LE)
46 /* Get rid of everything but NE */
48 rightexpr=new OpExpr(Opcode.ADD,rexpr,new IntegerLiteralExpr(1));
49 } else if (op==Opcode.GE) {
51 } else if (op==Opcode.LT) {
52 rightexpr=new OpExpr(Opcode.SUB,rexpr,new IntegerLiteralExpr(1));
53 } else if (op==Opcode.LE) {
55 } else if (op==Opcode.EQ) {
57 } else if (op==Opcode.NE) {
63 if (leftexpr instanceof VarExpr)
70 Descriptor getDescriptor() {
72 return ((VarExpr)leftexpr).getVar();
73 } else if (isField()) {
74 return ((DotExpr)leftexpr).getField();
76 System.out.println(toString());
77 throw new Error("Unrecognized Update");
82 if (leftexpr instanceof DotExpr) {
83 assert ((DotExpr)leftexpr).getIndex()==null;
94 public Updates(Expr lexpr, Expr rexpr) {
101 public Updates(Expr lexpr, int rpos) {
104 type=Updates.POSITION;
108 boolean isAbstract() {
109 return type==Updates.ABSTRACT;
112 public Updates(Expr lexpr,boolean negates) {
114 type=Updates.ABSTRACT;
119 public int getType() {
122 public Expr getLeftExpr() {
125 public int getRightPos() {
126 assert type==Updates.POSITION;
127 return rightposition;
129 public Expr getRightExpr() {
130 assert type==Updates.EXPR;