|
|
@ -21,8 +21,8 @@ package jode.flow; |
|
|
|
import jode.type.Type; |
|
|
|
import jode.type.Type; |
|
|
|
import jode.decompiler.TabbedPrintWriter; |
|
|
|
import jode.decompiler.TabbedPrintWriter; |
|
|
|
import jode.decompiler.LocalInfo; |
|
|
|
import jode.decompiler.LocalInfo; |
|
|
|
import jode.expr.ComplexExpression; |
|
|
|
|
|
|
|
import jode.expr.Expression; |
|
|
|
import jode.expr.Expression; |
|
|
|
|
|
|
|
import jode.expr.StoreInstruction; |
|
|
|
import jode.expr.LocalStoreOperator; |
|
|
|
import jode.expr.LocalStoreOperator; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -60,7 +60,7 @@ public class InstructionBlock extends InstructionContainer { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public VariableStack mapStackToLocal(VariableStack stack) { |
|
|
|
public VariableStack mapStackToLocal(VariableStack stack) { |
|
|
|
VariableStack newStack; |
|
|
|
VariableStack newStack; |
|
|
|
int params = instr.getOperandCount(); |
|
|
|
int params = instr.getFreeOperandCount(); |
|
|
|
if (params > 0) |
|
|
|
if (params > 0) |
|
|
|
this.stack = stack.peek(params); |
|
|
|
this.stack = stack.peek(params); |
|
|
|
|
|
|
|
|
|
|
@ -79,10 +79,10 @@ public class InstructionBlock extends InstructionContainer { |
|
|
|
if (stack != null) |
|
|
|
if (stack != null) |
|
|
|
instr = stack.mergeIntoExpression(instr, used); |
|
|
|
instr = stack.mergeIntoExpression(instr, used); |
|
|
|
if (pushedLocal != null) { |
|
|
|
if (pushedLocal != null) { |
|
|
|
LocalStoreOperator store = new LocalStoreOperator |
|
|
|
Expression store = new StoreInstruction |
|
|
|
(pushedLocal.getType(), pushedLocal, |
|
|
|
(new LocalStoreOperator |
|
|
|
LocalStoreOperator.ASSIGN_OP); |
|
|
|
(pushedLocal.getType(), pushedLocal)).addOperand(instr); |
|
|
|
instr = new ComplexExpression(store, new Expression[] { instr }); |
|
|
|
instr = store; |
|
|
|
used.addElement(pushedLocal); |
|
|
|
used.addElement(pushedLocal); |
|
|
|
} |
|
|
|
} |
|
|
|
super.removePush(); |
|
|
|
super.removePush(); |
|
|
@ -102,18 +102,19 @@ public class InstructionBlock extends InstructionContainer { |
|
|
|
* variable. |
|
|
|
* variable. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void checkDeclaration(VariableSet declareSet) { |
|
|
|
public void checkDeclaration(VariableSet declareSet) { |
|
|
|
if (instr.getOperator() instanceof LocalStoreOperator) { |
|
|
|
if (instr instanceof StoreInstruction |
|
|
|
|
|
|
|
&& (((StoreInstruction)instr).getLValue() |
|
|
|
|
|
|
|
instanceof LocalStoreOperator)) { |
|
|
|
|
|
|
|
StoreInstruction storeOp = (StoreInstruction) instr; |
|
|
|
LocalInfo local = |
|
|
|
LocalInfo local = |
|
|
|
((LocalStoreOperator) instr.getOperator()).getLocalInfo(); |
|
|
|
((LocalStoreOperator) storeOp.getLValue()).getLocalInfo(); |
|
|
|
if (declareSet.contains(local)) { |
|
|
|
if (declareSet.contains(local)) { |
|
|
|
/* Special case: This is a variable assignment, and |
|
|
|
/* Special case: This is a variable assignment, and |
|
|
|
* the variable has not been declared before. We can |
|
|
|
* the variable has not been declared before. We can |
|
|
|
* change this to a initializing variable declaration. |
|
|
|
* change this to a initializing variable declaration. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
isDeclaration = true; |
|
|
|
isDeclaration = true; |
|
|
|
if (instr instanceof ComplexExpression) |
|
|
|
storeOp.getSubExpressions()[1].makeInitializer(); |
|
|
|
((ComplexExpression) instr) |
|
|
|
|
|
|
|
.getSubExpressions()[0].makeInitializer(); |
|
|
|
|
|
|
|
declareSet.removeElement(local); |
|
|
|
declareSet.removeElement(local); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -136,7 +137,8 @@ public class InstructionBlock extends InstructionContainer { |
|
|
|
if (instr.getType() != Type.tVoid) |
|
|
|
if (instr.getType() != Type.tVoid) |
|
|
|
writer.print("PUSH "); |
|
|
|
writer.print("PUSH "); |
|
|
|
else if (isDeclaration) { |
|
|
|
else if (isDeclaration) { |
|
|
|
LocalInfo local = ((LocalStoreOperator) instr.getOperator()) |
|
|
|
LocalInfo local = |
|
|
|
|
|
|
|
((LocalStoreOperator) ((StoreInstruction) instr).getLValue()) |
|
|
|
.getLocalInfo(); |
|
|
|
.getLocalInfo(); |
|
|
|
writer.printType(local.getType().getHint()); |
|
|
|
writer.printType(local.getType().getHint()); |
|
|
|
writer.print(" "); |
|
|
|
writer.print(" "); |
|
|
|