|
|
@ -200,16 +200,26 @@ public class FlowBlock { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
StructuredBlock elseBlock = |
|
|
|
StructuredBlock elseBlock = |
|
|
|
jump.prev.outer.getNextBlock(jump.prev); |
|
|
|
jump.prev.outer.getNextBlock(jump.prev); |
|
|
|
if (elseBlock != null && |
|
|
|
if (elseBlock != null |
|
|
|
elseBlock.outer != null && |
|
|
|
&& elseBlock.outer != null |
|
|
|
elseBlock.outer instanceof SequentialBlock && |
|
|
|
&& elseBlock.outer instanceof SequentialBlock |
|
|
|
elseBlock.outer.getSubBlocks()[0] instanceof IfThenElseBlock && |
|
|
|
&& elseBlock.outer.getSubBlocks()[0] instanceof IfThenElseBlock |
|
|
|
(elseBlock.outer.getNextFlowBlock() == successor || |
|
|
|
&& (elseBlock.outer.getNextFlowBlock() == successor |
|
|
|
elseBlock.outer.jumpMayBeChanged())) { |
|
|
|
|| elseBlock.outer.jumpMayBeChanged())) { |
|
|
|
|
|
|
|
|
|
|
|
IfThenElseBlock ifBlock = |
|
|
|
IfThenElseBlock ifBlock = |
|
|
|
(IfThenElseBlock)elseBlock.outer.getSubBlocks()[0]; |
|
|
|
(IfThenElseBlock)elseBlock.outer.getSubBlocks()[0]; |
|
|
|
|
|
|
|
|
|
|
|
if (ifBlock.getSubBlocks().length == 1) { |
|
|
|
if (ifBlock.getSubBlocks().length == 1) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* make sure that only sequential blocks are between |
|
|
|
|
|
|
|
* jump.prev and the ifBlock |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
StructuredBlock block = jump.prev.outer; |
|
|
|
|
|
|
|
while (block instanceof SequentialBlock) |
|
|
|
|
|
|
|
block = block.outer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (block == ifBlock) { |
|
|
|
elseBlock.outer.removeJump(); |
|
|
|
elseBlock.outer.removeJump(); |
|
|
|
ifBlock.replace(elseBlock.outer, elseBlock); |
|
|
|
ifBlock.replace(elseBlock.outer, elseBlock); |
|
|
|
if (appendBlock == elseBlock.outer) |
|
|
|
if (appendBlock == elseBlock.outer) |
|
|
@ -219,6 +229,7 @@ public class FlowBlock { |
|
|
|
continue same_jump; |
|
|
|
continue same_jump; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* if the successor is the dummy return instruction, replace all |
|
|
|
/* if the successor is the dummy return instruction, replace all |
|
|
|
* jumps with a return. |
|
|
|
* jumps with a return. |
|
|
@ -838,7 +849,7 @@ public class FlowBlock { |
|
|
|
|
|
|
|
|
|
|
|
int continuelevel = 1; |
|
|
|
int continuelevel = 1; |
|
|
|
for (StructuredBlock surrounder = jump.prev.outer; |
|
|
|
for (StructuredBlock surrounder = jump.prev.outer; |
|
|
|
surrounder != null; |
|
|
|
surrounder != whileBlock; |
|
|
|
surrounder = surrounder.outer) { |
|
|
|
surrounder = surrounder.outer) { |
|
|
|
if (surrounder instanceof LoopBlock) { |
|
|
|
if (surrounder instanceof LoopBlock) { |
|
|
|
continuelevel++; |
|
|
|
continuelevel++; |
|
|
@ -878,6 +889,10 @@ public class FlowBlock { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void makeDeclaration() { |
|
|
|
|
|
|
|
block.makeDeclaration(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Resolves the destinations of all jumps. |
|
|
|
* Resolves the destinations of all jumps. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|