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) {
64 if (leftexpr instanceof VarExpr)
71 Descriptor getDescriptor() {
73 return ((VarExpr)leftexpr).getVar();
74 } else if (isField()) {
75 return ((DotExpr)leftexpr).getField();
77 System.out.println(toString());
78 throw new Error("Unrecognized Update");
83 if (leftexpr instanceof DotExpr) {
84 assert ((DotExpr)leftexpr).getIndex()==null;
95 public Updates(Expr lexpr, Expr rexpr) {
102 public Updates(Expr lexpr, int rpos) {
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;