jikes constructor's outerValue[0] parameter handling

bug fixes


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@913 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent c1b1a9dc6e
commit 8368c6ef37
  1. 30
      jode/jode/decompiler/MethodAnalyzer.java

@ -76,6 +76,7 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
StructuredBlock insertBlock = null; StructuredBlock insertBlock = null;
boolean isJikesConstructor; boolean isJikesConstructor;
boolean hasJikesOuterValue;
boolean isImplicitAnonymousConstructor; boolean isImplicitAnonymousConstructor;
/** /**
@ -193,6 +194,10 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
isJikesConstructor = value; isJikesConstructor = value;
} }
public final void setHasOuterValue(boolean value) {
hasJikesOuterValue = value;
}
public final void setAnonymousConstructor(boolean value) { public final void setAnonymousConstructor(boolean value) {
isImplicitAnonymousConstructor = value; isImplicitAnonymousConstructor = value;
} }
@ -379,13 +384,18 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
public void makeDeclaration() { public void makeDeclaration() {
if (isConstructor() && !isStatic() if (isConstructor() && !isStatic()
&& classAnalyzer.outerValues != null) { && classAnalyzer.outerValues != null
&& (Decompiler.options & Decompiler.OPTION_CONTRAFO) != 0) {
Expression[] outerValues = classAnalyzer.outerValues; Expression[] outerValues = classAnalyzer.outerValues;
for (int i=0; i< outerValues.length; i++) { for (int i=0; i< outerValues.length; i++) {
LocalInfo local = getParamInfo(1+i); LocalInfo local = getParamInfo(1+i);
local.setExpression(outerValues[i]); local.setExpression(outerValues[i]);
} }
} }
if (isJikesConstructor && hasJikesOuterValue
&& classAnalyzer.outerValues != null
&& classAnalyzer.outerValues.length > 0)
getParamInfo(1).setExpression(classAnalyzer.outerValues[0]);
for (Enumeration enum = allLocals.elements(); for (Enumeration enum = allLocals.elements();
enum.hasMoreElements(); ) { enum.hasMoreElements(); ) {
@ -393,6 +403,7 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
if (!li.isShadow()) if (!li.isShadow())
imports.useType(li.getType()); imports.useType(li.getType());
} }
if (code != null) {
for (int i=0; i < param.length; i++) { for (int i=0; i < param.length; i++) {
param[i].guessName(); param[i].guessName();
for (int j=0; j < i; j++) { for (int j=0; j < i; j++) {
@ -403,9 +414,10 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
} }
} }
} }
methodHeader.makeDeclaration(param); methodHeader.makeDeclaration(param);
methodHeader.simplify(); methodHeader.simplify();
}
if (innerAnalyzers != null) { if (innerAnalyzers != null) {
for (Enumeration enum = innerAnalyzers.elements(); for (Enumeration enum = innerAnalyzers.elements();
enum.hasMoreElements(); ) { enum.hasMoreElements(); ) {
@ -452,7 +464,8 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
if (isJikesConstructor) { if (isJikesConstructor) {
// This is the real part of a jikes constructor // This is the real part of a jikes constructor
declareAsConstructor = true; declareAsConstructor = true;
skipParams = 1; skipParams = hasJikesOuterValue
&& classAnalyzer.outerValues.length > 0 ? 1 : 0;
} }
if (declareAsConstructor if (declareAsConstructor
@ -488,12 +501,13 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
if (isJikesConstructor) { if (isJikesConstructor) {
// This is the real part of a jikes constructor // This is the real part of a jikes constructor
declareAsConstructor = true; declareAsConstructor = true;
skipParams = 1; skipParams = hasJikesOuterValue
&& classAnalyzer.outerValues.length > 0 ? 1 : 0;
} }
if ((Decompiler.options & Decompiler.OPTION_IMMEDIATE) != 0 if ((Decompiler.options & Decompiler.OPTION_IMMEDIATE) != 0
&& code != null) { && code != null) {
// We do the code.analyze() here, to get // We do the analyzeCode() here, to get
// immediate output. // immediate output.
analyzeCode(); analyzeCode();
@ -738,12 +752,12 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
} }
public void done() { public void done() {
shrinkTo = -1; limits = null;
} }
public void shrinkingOuterValues public void shrinkingOuterValues
(ClassAnalyzer other, int newCount) { (ClassAnalyzer other, int newCount) {
if (shrinkTo != -1) { if (limits != null) {
int limit = ((Integer) limits.get(other) int limit = ((Integer) limits.get(other)
).intValue(); ).intValue();
if (newCount <= limit) { if (newCount <= limit) {
@ -768,7 +782,7 @@ public class MethodAnalyzer implements Analyzer, Scope, ClassDeclarer {
return false; return false;
} }
ClassAnalyzer ca1 = method2.classAnalyzer; ClassAnalyzer ca1 = method1.classAnalyzer;
int slot = li1.getSlot(); int slot = li1.getSlot();
Expression[] ov = ca1.getOuterValues(); Expression[] ov = ca1.getOuterValues();
if (ov == null) { if (ov == null) {

Loading…
Cancel
Save