|
|
@ -61,28 +61,31 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean createFunny(FlowBlock flow) { |
|
|
|
public boolean createFunny(FlowBlock flow) { |
|
|
|
|
|
|
|
|
|
|
|
Expression[] e = new Expression[3]; |
|
|
|
if (!(flow.lastModified instanceof ConditionalBlock)) |
|
|
|
IfThenElseBlock ifBlock; |
|
|
|
return false; |
|
|
|
try { |
|
|
|
|
|
|
|
ConditionalBlock conditional = |
|
|
|
|
|
|
|
(ConditionalBlock) flow.lastModified; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(conditional.trueBlock instanceof EmptyBlock) |
|
|
|
ConditionalBlock conditional = (ConditionalBlock) flow.lastModified; |
|
|
|
|| conditional.trueBlock.jump == null |
|
|
|
|
|
|
|
|| conditional.jump == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompareUnaryOperator compare = |
|
|
|
if (!(conditional.trueBlock instanceof EmptyBlock) |
|
|
|
(CompareUnaryOperator) conditional.getInstruction(); |
|
|
|
|| conditional.trueBlock.jump == null |
|
|
|
|
|
|
|
|| conditional.jump == null |
|
|
|
|
|
|
|
|| !(conditional.getInstruction() instanceof CompareUnaryOperator)) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompareUnaryOperator compare = |
|
|
|
|
|
|
|
(CompareUnaryOperator) conditional.getInstruction(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FlowBlock trueDestination; |
|
|
|
|
|
|
|
if (compare.getOperatorIndex() == compare.EQUALS_OP) |
|
|
|
|
|
|
|
trueDestination = conditional.jump.destination; |
|
|
|
|
|
|
|
else if (compare.getOperatorIndex() == compare.NOTEQUALS_OP) |
|
|
|
|
|
|
|
trueDestination = conditional.trueBlock.jump.destination; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
FlowBlock trueDestination; |
|
|
|
Expression[] e = new Expression[3]; |
|
|
|
if (compare.getOperatorIndex() == compare.EQUALS_OP) |
|
|
|
IfThenElseBlock ifBlock; |
|
|
|
trueDestination = conditional.jump.destination; |
|
|
|
try { |
|
|
|
else if (compare.getOperatorIndex() == compare.NOTEQUALS_OP) |
|
|
|
|
|
|
|
trueDestination = conditional.trueBlock.jump.destination; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SequentialBlock sequBlock = |
|
|
|
SequentialBlock sequBlock = |
|
|
|
(SequentialBlock) conditional.outer; |
|
|
|
(SequentialBlock) conditional.outer; |
|
|
|
|
|
|
|
|
|
|
@ -129,9 +132,11 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
Expression cond = (Expression) condBlock.getInstruction(); |
|
|
|
Expression cond = (Expression) condBlock.getInstruction(); |
|
|
|
|
|
|
|
flow.removeSuccessor(condBlock.trueBlock.jump); |
|
|
|
condBlock.trueBlock.removeJump(); |
|
|
|
condBlock.trueBlock.removeJump(); |
|
|
|
pushBlock.setInstruction(cond); |
|
|
|
pushBlock.setInstruction(cond); |
|
|
|
pushBlock.replace(sequBlock, pushBlock); |
|
|
|
pushBlock.replace(sequBlock, pushBlock); |
|
|
|
|
|
|
|
|
|
|
|
e[i+1] = cond; |
|
|
|
e[i+1] = cond; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
@ -141,7 +146,7 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (jode.Decompiler.isVerbose) |
|
|
|
if (jode.Decompiler.isVerbose) |
|
|
|
System.err.print("?"); |
|
|
|
System.err.print('?'); |
|
|
|
|
|
|
|
|
|
|
|
IfThenElseOperator iteo = new IfThenElseOperator |
|
|
|
IfThenElseOperator iteo = new IfThenElseOperator |
|
|
|
(e[1].getType().intersection(e[2].getType())); |
|
|
|
(e[1].getType().intersection(e[2].getType())); |
|
|
@ -170,6 +175,7 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean create(FlowBlock flow) { |
|
|
|
public boolean create(FlowBlock flow) { |
|
|
|
Expression e[] = new Expression[3]; |
|
|
|
Expression e[] = new Expression[3]; |
|
|
|
|
|
|
|
InstructionBlock thenBlock; |
|
|
|
try { |
|
|
|
try { |
|
|
|
InstructionBlock elseBlock = (InstructionBlock) flow.lastModified; |
|
|
|
InstructionBlock elseBlock = (InstructionBlock) flow.lastModified; |
|
|
|
|
|
|
|
|
|
|
@ -181,7 +187,7 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
if (ifBlock.elseBlock != null) |
|
|
|
if (ifBlock.elseBlock != null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
InstructionBlock thenBlock = (InstructionBlock) ifBlock.thenBlock; |
|
|
|
thenBlock = (InstructionBlock) ifBlock.thenBlock; |
|
|
|
|
|
|
|
|
|
|
|
if (thenBlock.jump.destination != elseBlock.jump.destination) |
|
|
|
if (thenBlock.jump.destination != elseBlock.jump.destination) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -194,7 +200,6 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
e[0] = (Expression) ifBlock.cond; |
|
|
|
e[0] = (Expression) ifBlock.cond; |
|
|
|
|
|
|
|
|
|
|
|
thenBlock.removeJump(); |
|
|
|
|
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} catch (NullPointerException ex) { |
|
|
|
} catch (NullPointerException ex) { |
|
|
@ -202,7 +207,10 @@ public class CreateIfThenElseOperator implements Transformation { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (jode.Decompiler.isVerbose) |
|
|
|
if (jode.Decompiler.isVerbose) |
|
|
|
System.err.print("?"); |
|
|
|
System.err.print('?'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flow.removeSuccessor(thenBlock.jump); |
|
|
|
|
|
|
|
thenBlock.removeJump(); |
|
|
|
|
|
|
|
|
|
|
|
IfThenElseOperator iteo = new IfThenElseOperator |
|
|
|
IfThenElseOperator iteo = new IfThenElseOperator |
|
|
|
(e[1].getType().intersection(e[2].getType())); |
|
|
|
(e[1].getType().intersection(e[2].getType())); |
|
|
|