Handle null objects

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@277 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 861edb2456
commit 26c0de9c34
  1. 7
      jode/jode/expr/GetFieldOperator.java
  2. 13
      jode/jode/expr/PutFieldOperator.java

@ -26,6 +26,7 @@ public class GetFieldOperator extends Operator {
CodeAnalyzer codeAnalyzer;
String fieldName;
Type classType;
boolean needCast = false;
public GetFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag,
Type classType, Type type, String fieldName) {
@ -55,6 +56,8 @@ public class GetFieldOperator extends Operator {
}
public void setOperandType(Type types[]) {
if (!staticFlag)
needCast = types[0].getTop().equals(Type.tUnknown);
}
public String toString(String[] operands) {
@ -63,10 +66,12 @@ public class GetFieldOperator extends Operator {
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: classType.toString() + "." + fieldName)
: (operands[0].equals("null")
? "((" + classType + ") null)." + fieldName
: (operands[0].equals("this")
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: operands[0] + "." + fieldName);
: operands[0] + "." + fieldName));
}
public boolean equals(Object o) {

@ -44,6 +44,13 @@ public class PutFieldOperator extends StoreInstruction {
return staticFlag;
}
public boolean isSynthetic() {
if (!classType.equals(Type.tClass(codeAnalyzer.getClazz().getName())))
return false;
return codeAnalyzer.getClassAnalyzer()
.getField(fieldName, fieldType).isSynthetic();
}
public String getFieldName() {
return fieldName;
}
@ -79,10 +86,12 @@ public class PutFieldOperator extends StoreInstruction {
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: classType.toString() + "." + fieldName)
: (operands[0].equals("this")
: ((operands[0].equals("this")
&& codeAnalyzer.findLocal(fieldName) == null
? fieldName
: operands[0] + "." + fieldName);
: operands[0].equals("null")
? "((" + classType + ") null)." + fieldName
: operands[0] + "." + fieldName));
}
public boolean equals(Object o) {

Loading…
Cancel
Save