Expression rework (ComplexExpression removed)

bug fix for inner classes


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@777 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent f368f4ce33
commit abf370c1d7
  1. 94
      jode/jode/flow/TransformConstructors.java

@ -18,12 +18,15 @@
*/ */
package jode.flow; package jode.flow;
import java.lang.reflect.Modifier;
import jode.GlobalOptions; import jode.GlobalOptions;
import jode.Decompiler;
import jode.decompiler.Analyzer; import jode.decompiler.Analyzer;
import jode.decompiler.ClassAnalyzer; import jode.decompiler.ClassAnalyzer;
import jode.decompiler.MethodAnalyzer; import jode.decompiler.MethodAnalyzer;
import jode.expr.*; import jode.expr.*;
import jode.bytecode.ClassInfo; import jode.bytecode.ClassInfo;
import jode.bytecode.InnerClassInfo;
/** /**
* *
@ -65,15 +68,14 @@ public class TransformConstructors {
Expression instr = ib.getInstruction(); Expression instr = ib.getInstruction();
if (!(instr instanceof ComplexExpression) if (!(instr instanceof InvokeOperator)
|| !(instr.getOperator() instanceof InvokeOperator) || instr.getFreeOperandCount() != 0)
|| !isThis(((ComplexExpression)instr) return;
.getSubExpressions()[0],
clazzAnalyzer.getClazz()))
return;
InvokeOperator invoke = (InvokeOperator) instr.getOperator(); InvokeOperator invoke = (InvokeOperator) instr;
if (!invoke.isConstructor() || !invoke.isSuperOrThis()) if (!invoke.isConstructor() || !invoke.isSuperOrThis()
|| !isThis(invoke.getSubExpressions()[0],
clazzAnalyzer.getClazz()))
return; return;
if (invoke.isThis()) { if (invoke.isThis()) {
@ -90,8 +92,19 @@ public class TransformConstructors {
* expected. If the super() has no parameters, we * expected. If the super() has no parameters, we
* can remove it as it is implicit. * can remove it as it is implicit.
*/ */
if (invoke.getMethodType().getParameterTypes().length == 0) InnerClassInfo outer = invoke.getOuterClassInfo();
if (outer != null && outer.outer != null
&& !Modifier.isStatic(outer.modifiers)) {
if ((Decompiler.options & Decompiler.OPTION_INNER) != 0
&& (invoke.getMethodType().getParameterTypes()
.length == 1)
&& (invoke.getSubExpressions()[1]
instanceof ThisOperator))
ib.removeBlock();
} else if (invoke.getMethodType().getParameterTypes()
.length == 0)
ib.removeBlock(); ib.removeBlock();
if (sb[i] instanceof SequentialBlock) if (sb[i] instanceof SequentialBlock)
sb[i] = sb[i].getSubBlocks()[1]; sb[i] = sb[i].getSubBlocks()[1];
else else
@ -123,17 +136,19 @@ public class TransformConstructors {
Expression instr Expression instr
= ((InstructionBlock) ib).getInstruction().simplify(); = ((InstructionBlock) ib).getInstruction().simplify();
if (!(instr instanceof ComplexExpression) if (!(instr instanceof StoreInstruction)
|| !(instr.getOperator() instanceof PutFieldOperator) || instr.getFreeOperandCount() != 0)
|| ((PutFieldOperator)instr.getOperator()).isStatic())
break this_loop; break this_loop;
PutFieldOperator pfo = (PutFieldOperator) instr.getOperator(); StoreInstruction store = (StoreInstruction) instr;
if (!pfo.isThis()) if (!(store.getLValue() instanceof PutFieldOperator))
break this_loop; break this_loop;
Expression expr = ((ComplexExpression)instr) PutFieldOperator pfo = (PutFieldOperator) store.getLValue();
.getSubExpressions()[isStatic ? 0 : 1]; if (pfo.isStatic() || !pfo.isThis())
break this_loop;
Expression expr = store.getSubExpressions()[1];
if (isMember) { if (isMember) {
if (!(expr instanceof ThisOperator)) if (!(expr instanceof ThisOperator))
@ -147,8 +162,7 @@ public class TransformConstructors {
& GlobalOptions.DEBUG_CONSTRS) != 0) & GlobalOptions.DEBUG_CONSTRS) != 0)
GlobalOptions.err.println("field "+pfo.getFieldName() GlobalOptions.err.println("field "+pfo.getFieldName()
+ " = " + expr); + " = " + expr);
if (!isThis(((ComplexExpression)instr) if (!isThis(pfo.getSubExpressions()[0],
.getSubExpressions()[0],
clazzAnalyzer.getClazz())) { clazzAnalyzer.getClazz())) {
if ((GlobalOptions.debuggingFlags if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_CONSTRS) != 0) & GlobalOptions.DEBUG_CONSTRS) != 0)
@ -215,31 +229,21 @@ public class TransformConstructors {
Expression instr Expression instr
= ((InstructionBlock) ib).getInstruction().simplify(); = ((InstructionBlock) ib).getInstruction().simplify();
if (!(instr instanceof ComplexExpression)
|| !(instr.getOperator() instanceof PutFieldOperator)
|| (((PutFieldOperator)instr.getOperator()).isStatic()
!= isStatic))
break big_loop;
PutFieldOperator pfo = (PutFieldOperator) instr.getOperator(); if (!(instr instanceof StoreInstruction)
Expression expr = ((ComplexExpression)instr) || instr.getFreeOperandCount() != 0)
.getSubExpressions()[isStatic ? 0 : 1]; break big_loop;
StoreInstruction store = (StoreInstruction) instr;
if (!(store.getLValue() instanceof PutFieldOperator))
break big_loop;
if (!pfo.isThis() || !expr.isConstant()) { PutFieldOperator pfo = (PutFieldOperator) store.getLValue();
if ((GlobalOptions.debuggingFlags if (pfo.isStatic() != isStatic || !pfo.isThis())
& GlobalOptions.DEBUG_CONSTRS) != 0) break big_loop;
GlobalOptions.err.println("not constant: "+expr);
break big_loop;
}
if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_CONSTRS) != 0)
GlobalOptions.err.println("field "+pfo.getFieldName()+ " = "+expr);
if (!isStatic) { if (!isStatic) {
if (!isThis(((ComplexExpression)instr) if (!isThis(pfo.getSubExpressions()[0],
.getSubExpressions()[0],
clazzAnalyzer.getClazz())) { clazzAnalyzer.getClazz())) {
if ((GlobalOptions.debuggingFlags if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_CONSTRS) != 0) & GlobalOptions.DEBUG_CONSTRS) != 0)
@ -248,6 +252,20 @@ public class TransformConstructors {
} }
} }
Expression expr = store.getSubExpressions()[1];
if (!expr.isConstant()) {
if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_CONSTRS) != 0)
GlobalOptions.err.println("not constant: "+expr);
break big_loop;
}
if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_CONSTRS) != 0)
GlobalOptions.err.println("field " + pfo.getFieldName()
+ " = " + expr);
for (int i=1; i< constrCount; i++) { for (int i=1; i< constrCount; i++) {
ib = (sb[i] instanceof SequentialBlock) ib = (sb[i] instanceof SequentialBlock)
? sb[i].getSubBlocks()[0] ? sb[i].getSubBlocks()[0]

Loading…
Cancel
Save