CodeAnalyzer merged into MethodAnalyzer

fixed bug in inner classes fillDeclarable


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@887 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent dc168fe811
commit 4422b47b32
  1. 58
      jode/jode/expr/ConstructorOperator.java

@ -26,7 +26,7 @@ import jode.bytecode.ClassInfo;
import jode.bytecode.InnerClassInfo; import jode.bytecode.InnerClassInfo;
import jode.bytecode.Reference; import jode.bytecode.Reference;
import jode.Decompiler; import jode.Decompiler;
import jode.decompiler.CodeAnalyzer; import jode.decompiler.MethodAnalyzer;
import jode.decompiler.ClassAnalyzer; import jode.decompiler.ClassAnalyzer;
import jode.decompiler.TabbedPrintWriter; import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.Scope; import jode.decompiler.Scope;
@ -42,35 +42,35 @@ public class ConstructorOperator extends Operator
implements MatchableOperator { implements MatchableOperator {
MethodType methodType; MethodType methodType;
Type classType; Type classType;
CodeAnalyzer codeAnalyzer; MethodAnalyzer methodAnalyzer;
public ConstructorOperator(Type classType, MethodType methodType, public ConstructorOperator(Type classType, MethodType methodType,
CodeAnalyzer codeAna, boolean isVoid) { MethodAnalyzer methodAna, boolean isVoid) {
super(isVoid ? Type.tVoid : classType, 0); super(isVoid ? Type.tVoid : classType, 0);
this.classType = classType; this.classType = classType;
this.methodType = methodType; this.methodType = methodType;
this.codeAnalyzer = codeAna; this.methodAnalyzer = methodAna;
initOperands(methodType.getParameterTypes().length); initOperands(methodType.getParameterTypes().length);
checkAnonymousClasses(); checkAnonymousClasses();
} }
public ConstructorOperator(Reference ref, CodeAnalyzer codeAna, public ConstructorOperator(Reference ref, MethodAnalyzer methodAna,
boolean isVoid) { boolean isVoid) {
this (Type.tType(ref.getClazz()), Type.tMethod(ref.getType()), this (Type.tType(ref.getClazz()), Type.tMethod(ref.getType()),
codeAna, isVoid); methodAna, isVoid);
} }
public ConstructorOperator(InvokeOperator invoke, boolean isVoid) { public ConstructorOperator(InvokeOperator invoke, boolean isVoid) {
this (invoke.getClassType(), invoke.getMethodType(), this (invoke.getClassType(), invoke.getMethodType(),
invoke.codeAnalyzer, isVoid); invoke.methodAnalyzer, isVoid);
} }
public MethodType getMethodType() { public MethodType getMethodType() {
return methodType; return methodType;
} }
public CodeAnalyzer getCodeAnalyzer() { public MethodAnalyzer getMethodAnalyzer() {
return codeAnalyzer; return methodAnalyzer;
} }
/** /**
@ -123,7 +123,7 @@ public class ConstructorOperator extends Operator
} }
public InnerClassInfo getOuterClassInfo(ClassInfo ci) { public InnerClassInfo getOuterClassInfo(ClassInfo ci) {
if (ci != null && ci.getName().indexOf('$') >= 0) { if (ci != null) {
InnerClassInfo[] outers = ci.getOuterClasses(); InnerClassInfo[] outers = ci.getOuterClasses();
if (outers != null) if (outers != null)
return outers[0]; return outers[0];
@ -137,7 +137,7 @@ public class ConstructorOperator extends Operator
ClassInfo clazz = getClassInfo(); ClassInfo clazz = getClassInfo();
InnerClassInfo outer = getOuterClassInfo(clazz); InnerClassInfo outer = getOuterClassInfo(clazz);
if (outer != null && (outer.outer == null || outer.name == null)) { if (outer != null && (outer.outer == null || outer.name == null)) {
codeAnalyzer.addAnonymousConstructor(this); methodAnalyzer.addAnonymousConstructor(this);
if (outer.name == null) { if (outer.name == null) {
if (clazz.getInterfaces().length > 0) if (clazz.getInterfaces().length > 0)
@ -159,17 +159,21 @@ public class ConstructorOperator extends Operator
///#endif ///#endif
ClassInfo clazz = getClassInfo(); ClassInfo clazz = getClassInfo();
InnerClassInfo outer = getOuterClassInfo(clazz); InnerClassInfo outer = getOuterClassInfo(clazz);
ClassAnalyzer anonymousClass = null; ClassAnalyzer clazzAna = methodAnalyzer.getClassAnalyzer(clazz);
int arg = 0; int arg = 0;
int length = subExpressions.length; int length = subExpressions.length;
boolean jikesAnonymousInner = false; boolean jikesAnonymousInner = false;
if ((Decompiler.options & Decompiler.OPTION_ANON) != 0 if ((Decompiler.options & Decompiler.OPTION_ANON) != 0
&& clazzAna != null
&& outer != null && (outer.outer == null || outer.name == null)) { && outer != null && (outer.outer == null || outer.name == null)) {
anonymousClass = codeAnalyzer.getAnonymousClass(clazz); arg += clazzAna.getOuterValues().length;
jikesAnonymousInner = clazzAna.isJikesAnonymousInner();
if (outer.name != null) { if (outer.name != null) {
/* This is a named method scope class, declare it */ if (clazzAna.getParent() == methodAnalyzer)
used.add(anonymousClass); /* This is a named method scope class, declare it */
used.add(clazzAna);
} else { } else {
/* This is an anonymous class */ /* This is an anonymous class */
ClassInfo superClazz = clazz.getSuperclass(); ClassInfo superClazz = clazz.getSuperclass();
@ -183,8 +187,6 @@ public class ConstructorOperator extends Operator
? superClazz : ClassInfo.javaLangObject); ? superClazz : ClassInfo.javaLangObject);
} }
outer = getOuterClassInfo(clazz); outer = getOuterClassInfo(clazz);
arg += anonymousClass.getOuterValues().length;
jikesAnonymousInner = anonymousClass.isJikesAnonymousInner();
} }
} }
if ((Decompiler.options & Decompiler.OPTION_INNER) != 0 if ((Decompiler.options & Decompiler.OPTION_INNER) != 0
@ -212,15 +214,15 @@ public class ConstructorOperator extends Operator
boolean jikesAnonymousInner = false; boolean jikesAnonymousInner = false;
ClassInfo clazz = getClassInfo(); ClassInfo clazz = getClassInfo();
InnerClassInfo outer = getOuterClassInfo(clazz); InnerClassInfo outer = getOuterClassInfo(clazz);
ClassAnalyzer clazzAna = methodAnalyzer.getClassAnalyzer(clazz);
ClassAnalyzer anonymousClass = null;
boolean dumpBlock = false; boolean dumpBlock = false;
if ((Decompiler.options & if ((Decompiler.options &
(Decompiler.OPTION_ANON | Decompiler.OPTION_CONTRAFO)) != 0 (Decompiler.OPTION_ANON | Decompiler.OPTION_CONTRAFO)) != 0
&& codeAnalyzer.hasAnalyzedAnonymous() && clazzAna != null
&& outer != null && (outer.outer == null || outer.name == null)) { && outer != null && (outer.outer == null || outer.name == null)) {
anonymousClass = codeAnalyzer.getAnonymousClass(getClassInfo()); arg += clazzAna.getOuterValues().length;
jikesAnonymousInner = anonymousClass.isJikesAnonymousInner(); jikesAnonymousInner = clazzAna.isJikesAnonymousInner();
if (outer.name == null) { if (outer.name == null) {
/* This is an anonymous class */ /* This is an anonymous class */
@ -248,11 +250,10 @@ public class ConstructorOperator extends Operator
} }
if (!(thisExpr instanceof ThisOperator) if (!(thisExpr instanceof ThisOperator)
|| (((ThisOperator) thisExpr).getClassInfo() || (((ThisOperator) thisExpr).getClassInfo()
!= codeAnalyzer.getClazz())) != methodAnalyzer.getClazz()))
writer.print("ILLEGAL ANON CONSTR"); writer.print("ILLEGAL ANON CONSTR");
} }
} }
arg += anonymousClass.getOuterValues().length;
} }
if (outer != null && outer.outer != null && outer.name != null if (outer != null && outer.outer != null && outer.name != null
@ -266,11 +267,13 @@ public class ConstructorOperator extends Operator
if (outerExpr instanceof CheckNullOperator) { if (outerExpr instanceof CheckNullOperator) {
CheckNullOperator cno = (CheckNullOperator) outerExpr; CheckNullOperator cno = (CheckNullOperator) outerExpr;
outerExpr = cno.subExpressions[0]; outerExpr = cno.subExpressions[0];
} else if (!(outerExpr instanceof ThisOperator)) } else if (!(outerExpr instanceof ThisOperator)) {
// Bug in jikes: it doesn't do a check null.
// We don't complain here.
if (!jikesAnonymousInner) if (!jikesAnonymousInner)
// Bug in jikes: it doesn't do a check null.
// We don't complain here.
writer.print("MISSING CHECKNULL "); writer.print("MISSING CHECKNULL ");
}
if (outerExpr instanceof ThisOperator) { if (outerExpr instanceof ThisOperator) {
Scope scope = writer.getScope Scope scope = writer.getScope
(((ThisOperator) outerExpr).getClassInfo(), (((ThisOperator) outerExpr).getClassInfo(),
@ -305,10 +308,9 @@ public class ConstructorOperator extends Operator
if (dumpBlock) { if (dumpBlock) {
writer.openBrace(); writer.openBrace();
writer.tab(); writer.tab();
anonymousClass.dumpBlock(writer); clazzAna.dumpBlock(writer);
writer.untab(); writer.untab();
writer.closeBraceNoSpace(); writer.closeBraceNoSpace();
} }
} }
} }

Loading…
Cancel
Save