call useType for static fields

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@82 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent a050ca96df
commit e1aca5c144
  1. 38
      jode/jode/expr/GetFieldOperator.java
  2. 42
      jode/jode/expr/PutFieldOperator.java

@ -24,6 +24,7 @@ public class GetFieldOperator extends Operator {
boolean staticFlag; boolean staticFlag;
CpoolRef field; CpoolRef field;
CodeAnalyzer codeAnalyzer; CodeAnalyzer codeAnalyzer;
Type classType;
public GetFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag, public GetFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag,
CpoolRef field) { CpoolRef field) {
@ -31,6 +32,9 @@ public class GetFieldOperator extends Operator {
this.codeAnalyzer = codeAnalyzer; this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag; this.staticFlag = staticFlag;
this.field = field; this.field = field;
classType = Type.tClass(field.getCpoolClass().getName().getString());
if (staticFlag)
classType.useType();
} }
public int getPriority() { public int getPriority() {
@ -42,41 +46,25 @@ public class GetFieldOperator extends Operator {
} }
public int getOperandPriority(int i) { public int getOperandPriority(int i) {
if (staticFlag) {
/* shouldn't be called */
throw new RuntimeException("Field is static");
}
return 900; return 900;
} }
public Type getOperandType(int i) { public Type getOperandType(int i) {
if (staticFlag) { return classType;
/* shouldn't be called */
throw new RuntimeException("Field is static");
}
return Type.tClass(field.getCpoolClass()
.getName().getString());
} }
public void setOperandType(Type types[]) { public void setOperandType(Type types[]) {
} }
public String toString(String[] operands) { public String toString(String[] operands) {
String object; String fieldName = field.getNameAndType().getName().getString();
if (staticFlag) { return staticFlag
if (field.getCpoolClass().getName().getString() ? (classType.equals(Type.tType(codeAnalyzer.getClazz()))
.equals(codeAnalyzer.getClazz().getName())) ? fieldName
return field.getNameAndType().getName().getString(); : classType.toString() + "." + fieldName)
object = : (operands[0].equals("this")
codeAnalyzer.getTypeString ? fieldName
(Type.tClass(field.getCpoolClass() : operands[0] + "." + fieldName);
.getName().getString()));
} else {
if (operands[0].equals("this"))
return field.getNameAndType().getName().getString();
object = operands[0];
}
return object + "." + field.getNameAndType().getName().getString();
} }
public boolean equals(Object o) { public boolean equals(Object o) {

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

Loading…
Cancel
Save