4 static public final int EXPR=0;
5 static public final int POSITION=1;
6 static public final int ACCESSPATH=2;
7 static public final int ABSTRACT=3;
15 ArrayAnalysis.AccessPath ap;
18 public Updates(Expr lexpr, int fieldnum, ArrayAnalysis.AccessPath ap, Expr rexpr, int slot) {
20 this.fieldnum=fieldnum;
22 this.rightposition=slot;
24 this.type=Updates.ACCESSPATH;
25 this.opcode=Opcode.EQ;
28 public Updates(Expr lexpr, Expr rexpr, Opcode op, boolean negate) {
29 if (!lexpr.isValue(null))
30 System.out.println("Building invalid update");
34 op=Opcode.translateOpcode(negate,op);
40 public Updates(Expr lexpr, Expr rexpr) {
41 if (!lexpr.isValue(null))
42 System.out.println("Building invalid update");
49 public Updates(Expr lexpr, int rpos, TypeDescriptor td) {
50 if (!lexpr.isValue(td))
51 System.out.println("Building invalid update");
54 type=Updates.POSITION;
58 public Updates(Expr lexpr,boolean negates) {
60 type=Updates.ABSTRACT;
65 VarDescriptor getVar() {
67 return ((VarExpr)leftexpr).getVar();
68 } else if (isField()) {
71 for(;e instanceof DotExpr;e=((DotExpr)e).getExpr()) ;
72 if (e instanceof VarExpr)
74 if (e instanceof CastExpr)
75 e=((CastExpr)e).getExpr();
76 else throw new Error("Unrecognized Expr:"+e.name());
78 return ((VarExpr)e).getVar();
80 System.out.println(toString());
81 throw new Error("Unrecognized Update");
85 Descriptor getDescriptor() {
87 while (lexpr instanceof CastExpr)
88 lexpr=((CastExpr)lexpr).getExpr();
91 return ((VarExpr)lexpr).getVar();
92 } else if (isField()) {
93 return ((DotExpr)lexpr).getField();
95 System.out.println(toString());
96 throw new Error("Unrecognized Update");
102 while (lexpr instanceof CastExpr)
103 lexpr=((CastExpr)lexpr).getExpr();
105 if (lexpr instanceof VarExpr)
112 while (lexpr instanceof CastExpr)
113 lexpr=((CastExpr)lexpr).getExpr();
115 if (lexpr instanceof DotExpr) {
116 assert ((DotExpr)lexpr).getIndex()==null;
123 return type==Updates.EXPR;
131 boolean isAbstract() {
132 return type==Updates.ABSTRACT;
135 public int getType() {
139 public Expr getLeftExpr() {
143 public int getRightPos() {
144 assert type==Updates.POSITION||type==Updates.ACCESSPATH;
145 return rightposition;
148 public Expr getRightExpr() {
149 assert type==Updates.EXPR;
153 public int getFieldNum() {
154 assert type==Updates.ACCESSPATH;
158 public ArrayAnalysis.AccessPath getAccessPath() {
159 assert type==Updates.ACCESSPATH;
163 public String toString() {
165 return leftexpr.name()+opcode.toString()+rightexpr.name();
166 else if (type==POSITION)
167 return leftexpr.name()+opcode.toString()+"Position("+String.valueOf(rightposition)+")";
168 else if (type==ACCESSPATH) {
169 return leftexpr.name()+opcode.toString()+"Field("+fieldnum+","+ap+") of Position("+String.valueOf(rightposition)+")";
170 } else if (type==ABSTRACT) {
171 if (negate) return "!"+leftexpr.name();
172 else return leftexpr.name();
173 } else throw new Error("Unrecognized type");