CodeAnalyzer merged into MethodAnalyzer

getCanonic()


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@889 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 3a71bd529e
commit 2f91b6544d
  1. 25
      jode/jode/expr/GetFieldOperator.java

@ -23,7 +23,7 @@ import jode.type.NullType;
import jode.type.ClassInterfacesType; import jode.type.ClassInterfacesType;
import jode.bytecode.ClassInfo; import jode.bytecode.ClassInfo;
import jode.bytecode.Reference; import jode.bytecode.Reference;
import jode.decompiler.CodeAnalyzer; import jode.decompiler.MethodAnalyzer;
import jode.decompiler.ClassAnalyzer; import jode.decompiler.ClassAnalyzer;
import jode.decompiler.MethodAnalyzer; import jode.decompiler.MethodAnalyzer;
import jode.decompiler.FieldAnalyzer; import jode.decompiler.FieldAnalyzer;
@ -32,19 +32,19 @@ import jode.decompiler.Scope;
public class GetFieldOperator extends Operator { public class GetFieldOperator extends Operator {
boolean staticFlag; boolean staticFlag;
CodeAnalyzer codeAnalyzer; MethodAnalyzer methodAnalyzer;
Reference ref; Reference ref;
Type classType; Type classType;
public GetFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag, public GetFieldOperator(MethodAnalyzer methodAnalyzer, boolean staticFlag,
Reference ref) { Reference ref) {
super(Type.tType(ref.getType()), 0); super(Type.tType(ref.getType()), 0);
this.codeAnalyzer = codeAnalyzer; this.methodAnalyzer = methodAnalyzer;
this.staticFlag = staticFlag; this.staticFlag = staticFlag;
this.classType = Type.tType(ref.getClazz()); this.classType = Type.tType(ref.getClazz());
this.ref = ref; this.ref = ref;
if (staticFlag) if (staticFlag)
codeAnalyzer.useType(classType); methodAnalyzer.useType(classType);
initOperands(staticFlag ? 0 : 1); initOperands(staticFlag ? 0 : 1);
} }
@ -66,7 +66,7 @@ public class GetFieldOperator extends Operator {
public boolean isOuter() { public boolean isOuter() {
if (classType instanceof ClassInterfacesType) { if (classType instanceof ClassInterfacesType) {
ClassInfo clazz = ((ClassInterfacesType) classType).getClassInfo(); ClassInfo clazz = ((ClassInterfacesType) classType).getClassInfo();
ClassAnalyzer ana = codeAnalyzer.getClassAnalyzer(); ClassAnalyzer ana = methodAnalyzer.getClassAnalyzer();
while (true) { while (true) {
if (clazz == ana.getClazz()) if (clazz == ana.getClazz())
return true; return true;
@ -91,7 +91,7 @@ public class GetFieldOperator extends Operator {
public FieldAnalyzer getField() { public FieldAnalyzer getField() {
ClassInfo clazz = getClassInfo(); ClassInfo clazz = getClassInfo();
if (clazz != null) { if (clazz != null) {
ClassAnalyzer ana = codeAnalyzer.getClassAnalyzer(); ClassAnalyzer ana = methodAnalyzer.getClassAnalyzer();
while (true) { while (true) {
if (clazz == ana.getClazz()) { if (clazz == ana.getClazz()) {
return ana.getField(ref.getName(), return ana.getField(ref.getName(),
@ -99,8 +99,8 @@ public class GetFieldOperator extends Operator {
} }
if (ana.getParent() == null) if (ana.getParent() == null)
return null; return null;
if (ana.getParent() instanceof CodeAnalyzer) if (ana.getParent() instanceof MethodAnalyzer)
ana = ((CodeAnalyzer) ana.getParent()) ana = ((MethodAnalyzer) ana.getParent())
.getClassAnalyzer(); .getClassAnalyzer();
else if (ana.getParent() instanceof ClassAnalyzer) else if (ana.getParent() instanceof ClassAnalyzer)
ana = (ClassAnalyzer) ana.getParent(); ana = (ClassAnalyzer) ana.getParent();
@ -117,13 +117,14 @@ public class GetFieldOperator extends Operator {
&& subExpressions[0] instanceof ThisOperator; && subExpressions[0] instanceof ThisOperator;
String fieldName = ref.getName(); String fieldName = ref.getName();
if (staticFlag) { if (staticFlag) {
if (!classType.equals(Type.tClass(codeAnalyzer.getClazz())) if (!classType.equals(Type.tClass(methodAnalyzer.getClazz()))
|| codeAnalyzer.findLocal(fieldName) != null) { || methodAnalyzer.findLocal(fieldName) != null) {
writer.printType(classType); writer.printType(classType);
writer.print("."); writer.print(".");
} }
writer.print(fieldName); writer.print(fieldName);
} else if (subExpressions[0].getType() instanceof NullType) { } else if (subExpressions[0].getType().getCanonic()
instanceof NullType) {
writer.print("(("); writer.print("((");
writer.printType(classType); writer.printType(classType);
writer.print(") "); writer.print(") ");

Loading…
Cancel
Save