getInnerClassAnalyzer and initialize added

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1180 379699f6-c40d-0410-875b-85095c16579e
branch_1_1
jochen 25 years ago
parent 0270969c56
commit d8e2746780
  1. 63
      jode/jode/decompiler/ClassAnalyzer.java

@ -87,7 +87,6 @@ public class ClassAnalyzer
this.imports = imports; this.imports = imports;
this.outerValues = outerValues; this.outerValues = outerValues;
modifiers = clazz.getModifiers(); modifiers = clazz.getModifiers();
name = clazz.getName();
if (parent != null) { if (parent != null) {
InnerClassInfo[] outerInfos = clazz.getOuterClasses(); InnerClassInfo[] outerInfos = clazz.getOuterClasses();
@ -227,16 +226,7 @@ public class ClassAnalyzer
return jikesAnonymousInner; return jikesAnonymousInner;
} }
public void analyze() { public void initialize() {
if (GlobalOptions.verboseLevel > 0)
GlobalOptions.err.println("Class " + clazz.getName());
imports.useClass(clazz);
if (clazz.getSuperclass() != null)
imports.useClass(clazz.getSuperclass());
ClassInfo[] interfaces = clazz.getInterfaces();
for (int j=0; j< interfaces.length; j++)
imports.useClass(interfaces[j]);
FieldInfo[] finfos = clazz.getFields(); FieldInfo[] finfos = clazz.getFields();
MethodInfo[] minfos = clazz.getMethods(); MethodInfo[] minfos = clazz.getMethods();
InnerClassInfo[] innerInfos = clazz.getInnerClasses(); InnerClassInfo[] innerInfos = clazz.getInnerClasses();
@ -250,6 +240,7 @@ public class ClassAnalyzer
if ((Decompiler.options & Decompiler.OPTION_INNER) != 0 if ((Decompiler.options & Decompiler.OPTION_INNER) != 0
&& innerInfos != null) { && innerInfos != null) {
/* Create inner classes */
Expression[] outerThis = new Expression[] { Expression[] outerThis = new Expression[] {
new ThisOperator(clazz) new ThisOperator(clazz)
}; };
@ -285,11 +276,40 @@ public class ClassAnalyzer
} }
} }
constructors = new MethodAnalyzer[constrVector.size()];
constrVector.copyInto(constructors);
// // initialize the methods.
// for (int j=0; j < methods.length; j++)
// methods[j].initialize();
// initialize the inner classes.
for (int j=0; j < inners.length; j++) {
inners[j].initialize();
}
}
public void analyze() {
if (GlobalOptions.verboseLevel > 0)
GlobalOptions.err.println("Class " + clazz.getName());
imports.useClass(clazz);
if (clazz.getSuperclass() != null)
imports.useClass(clazz.getSuperclass());
ClassInfo[] interfaces = clazz.getInterfaces();
for (int j=0; j< interfaces.length; j++)
imports.useClass(interfaces[j]);
if (fields == null) {
/* This means that the class could not be loaded.
* give up.
*/
return;
}
// First analyze constructors and synthetic fields: // First analyze constructors and synthetic fields:
constrAna = null; constrAna = null;
constructors = new MethodAnalyzer[constrVector.size()];
if (constructors.length > 0) { if (constructors.length > 0) {
constrVector.copyInto(constructors);
for (int j=0; j< constructors.length; j++) for (int j=0; j< constructors.length; j++)
constructors[j].analyze(); constructors[j].analyze();
constrAna = new TransformConstructors(this, false, constructors); constrAna = new TransformConstructors(this, false, constructors);
@ -490,6 +510,7 @@ public class ClassAnalyzer
public void dumpJavaFile(TabbedPrintWriter writer) throws IOException { public void dumpJavaFile(TabbedPrintWriter writer) throws IOException {
imports.init(clazz.getName()); imports.init(clazz.getName());
LocalInfo.init(); LocalInfo.init();
initialize();
analyze(); analyze();
analyzeInnerClasses(); analyzeInnerClasses();
makeDeclaration(); makeDeclaration();
@ -560,6 +581,22 @@ public class ClassAnalyzer
return getParent().getClassAnalyzer(cinfo); return getParent().getClassAnalyzer(cinfo);
} }
/**
* Get the class analyzer for the given inner class.
* @param name the short name of the inner class
* @return the class analyzer, or null if there is no inner
* class with the given name.
*/
public ClassAnalyzer getInnerClassAnalyzer(String name) {
/** precondition name != null; **/
int innerCount = inners.length;
for (int i=0; i < innerCount; i++) {
if (inners[i].name.equals(name))
return inners[i];
}
return null;
}
public void addClassAnalyzer(ClassAnalyzer clazzAna) { public void addClassAnalyzer(ClassAnalyzer clazzAna) {
if (parent != null) if (parent != null)
parent.addClassAnalyzer(clazzAna); parent.addClassAnalyzer(clazzAna);

Loading…
Cancel
Save