|
|
@ -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) |
|
|
|
|
|
|
|
.getSubExpressions()[0], |
|
|
|
|
|
|
|
clazzAnalyzer.getClazz())) |
|
|
|
|
|
|
|
return; |
|
|
|
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(); |
|
|
|
ib.removeBlock(); |
|
|
|
|
|
|
|
} else if (invoke.getMethodType().getParameterTypes() |
|
|
|
|
|
|
|
.length == 0) |
|
|
|
|
|
|
|
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,38 +229,42 @@ public class TransformConstructors { |
|
|
|
|
|
|
|
|
|
|
|
Expression instr |
|
|
|
Expression instr |
|
|
|
= ((InstructionBlock) ib).getInstruction().simplify(); |
|
|
|
= ((InstructionBlock) ib).getInstruction().simplify(); |
|
|
|
if (!(instr instanceof ComplexExpression) |
|
|
|
|
|
|
|
|| !(instr.getOperator() instanceof PutFieldOperator) |
|
|
|
if (!(instr instanceof StoreInstruction) |
|
|
|
|| (((PutFieldOperator)instr.getOperator()).isStatic() |
|
|
|
|| instr.getFreeOperandCount() != 0) |
|
|
|
!= isStatic)) |
|
|
|
|
|
|
|
break big_loop; |
|
|
|
break big_loop; |
|
|
|
|
|
|
|
|
|
|
|
PutFieldOperator pfo = (PutFieldOperator) instr.getOperator(); |
|
|
|
StoreInstruction store = (StoreInstruction) instr; |
|
|
|
Expression expr = ((ComplexExpression)instr) |
|
|
|
if (!(store.getLValue() instanceof PutFieldOperator)) |
|
|
|
.getSubExpressions()[isStatic ? 0 : 1]; |
|
|
|
break big_loop; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PutFieldOperator pfo = (PutFieldOperator) store.getLValue(); |
|
|
|
|
|
|
|
if (pfo.isStatic() != isStatic || !pfo.isThis()) |
|
|
|
|
|
|
|
break big_loop; |
|
|
|
|
|
|
|
|
|
|
|
if (!pfo.isThis() || !expr.isConstant()) { |
|
|
|
if (!isStatic) { |
|
|
|
|
|
|
|
if (!isThis(pfo.getSubExpressions()[0], |
|
|
|
|
|
|
|
clazzAnalyzer.getClazz())) { |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
GlobalOptions.err.println("not constant: "+expr); |
|
|
|
GlobalOptions.err.println("not this: "+instr); |
|
|
|
break big_loop; |
|
|
|
break big_loop; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Expression expr = store.getSubExpressions()[1]; |
|
|
|
|
|
|
|
if (!expr.isConstant()) { |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
GlobalOptions.err.println("field "+pfo.getFieldName()+ " = "+expr); |
|
|
|
GlobalOptions.err.println("not constant: "+expr); |
|
|
|
|
|
|
|
break big_loop; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!isStatic) { |
|
|
|
|
|
|
|
if (!isThis(((ComplexExpression)instr) |
|
|
|
|
|
|
|
.getSubExpressions()[0], |
|
|
|
|
|
|
|
clazzAnalyzer.getClazz())) { |
|
|
|
|
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
if ((GlobalOptions.debuggingFlags |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
& GlobalOptions.DEBUG_CONSTRS) != 0) |
|
|
|
GlobalOptions.err.println("not this: "+instr); |
|
|
|
GlobalOptions.err.println("field " + pfo.getFieldName() |
|
|
|
break big_loop; |
|
|
|
+ " = " + 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) |
|
|
|