|
|
|
@ -24,6 +24,7 @@ public class PutFieldOperator extends StoreInstruction { |
|
|
|
|
CodeAnalyzer codeAnalyzer; |
|
|
|
|
boolean staticFlag; |
|
|
|
|
CpoolRef field; |
|
|
|
|
Type classType; |
|
|
|
|
|
|
|
|
|
public PutFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag, |
|
|
|
|
CpoolRef field) { |
|
|
|
@ -31,6 +32,9 @@ public class PutFieldOperator extends StoreInstruction { |
|
|
|
|
this.codeAnalyzer = codeAnalyzer; |
|
|
|
|
this.staticFlag = staticFlag; |
|
|
|
|
this.field = field; |
|
|
|
|
classType = Type.tClass(field.getCpoolClass().getName().getString()); |
|
|
|
|
if (staticFlag) |
|
|
|
|
classType.useType(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean matches(Operator loadop) { |
|
|
|
@ -43,45 +47,25 @@ public class PutFieldOperator extends StoreInstruction { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getLValueOperandPriority(int i) { |
|
|
|
|
if (staticFlag) { |
|
|
|
|
/* shouldn't be called */ |
|
|
|
|
throw new RuntimeException("Field is static"); |
|
|
|
|
} |
|
|
|
|
return 900; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Type getLValueOperandType(int i) { |
|
|
|
|
if (staticFlag) { |
|
|
|
|
/* shouldn't be called */ |
|
|
|
|
throw new AssertError("Field is static"); |
|
|
|
|
} |
|
|
|
|
return Type.tClass(field.getCpoolClass() |
|
|
|
|
.getName().getString()); |
|
|
|
|
return classType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setLValueOperandType(Type[] t) { |
|
|
|
|
if (staticFlag) { |
|
|
|
|
/* shouldn't be called */ |
|
|
|
|
throw new AssertError("Field is static"); |
|
|
|
|
} |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getLValueString(String[] operands) { |
|
|
|
|
String object; |
|
|
|
|
if (staticFlag) { |
|
|
|
|
if (field.getCpoolClass().getName().getString() |
|
|
|
|
.replace(java.io.File.separatorChar, '.') |
|
|
|
|
.equals(codeAnalyzer.getClazz().getName())) |
|
|
|
|
return field.getNameAndType().getName().getString(); |
|
|
|
|
object = codeAnalyzer.getTypeString |
|
|
|
|
(Type.tClass(field.getCpoolClass().getName().getString())); |
|
|
|
|
} else { |
|
|
|
|
if (operands[0].equals("this")) |
|
|
|
|
return field.getNameAndType().getName().getString(); |
|
|
|
|
object = operands[0]; |
|
|
|
|
} |
|
|
|
|
return object + "." + field.getNameAndType().getName().getString(); |
|
|
|
|
String fieldName = field.getNameAndType().getName().getString(); |
|
|
|
|
return staticFlag |
|
|
|
|
? (classType.equals(Type.tType(codeAnalyzer.getClazz())) |
|
|
|
|
? fieldName |
|
|
|
|
: classType.toString() + "." + fieldName) |
|
|
|
|
: (operands[0].equals("this") |
|
|
|
|
? fieldName |
|
|
|
|
: operands[0] + "." + fieldName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean equals(Object o) { |
|
|
|
|