|
|
|
@ -23,11 +23,50 @@ package jode.flow; |
|
|
|
|
* |
|
|
|
|
* @author Jochen Hoenicke |
|
|
|
|
*/ |
|
|
|
|
public class FinallyBlock extends CatchBlock { |
|
|
|
|
public class FinallyBlock extends StructuredBlock { |
|
|
|
|
/** |
|
|
|
|
* The catch block. |
|
|
|
|
*/ |
|
|
|
|
StructuredBlock subBlock; |
|
|
|
|
|
|
|
|
|
public FinallyBlock() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Sets the catch block. |
|
|
|
|
* @param subBlock the catch block. |
|
|
|
|
*/ |
|
|
|
|
public void setCatchBlock(StructuredBlock subBlock) { |
|
|
|
|
this.subBlock = subBlock; |
|
|
|
|
subBlock.outer = this; |
|
|
|
|
subBlock.setFlowBlock(flowBlock); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* The implementation of getNext[Flow]Block is the standard |
|
|
|
|
* implementation */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Replaces the given sub block with a new block. |
|
|
|
|
* @param oldBlock the old sub block. |
|
|
|
|
* @param newBlock the new sub block. |
|
|
|
|
* @return false, if oldBlock wasn't a direct sub block. |
|
|
|
|
*/ |
|
|
|
|
public boolean replaceSubBlock(StructuredBlock oldBlock, |
|
|
|
|
StructuredBlock newBlock) { |
|
|
|
|
if (subBlock == oldBlock) |
|
|
|
|
subBlock = newBlock; |
|
|
|
|
else |
|
|
|
|
return false; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns all sub block of this structured block. |
|
|
|
|
*/ |
|
|
|
|
public StructuredBlock[] getSubBlocks() { |
|
|
|
|
return new StructuredBlock[] { subBlock }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the block where the control will normally flow to, when |
|
|
|
|
* the given sub block is finished (<em>not</em> ignoring the jump |
|
|
|
@ -51,7 +90,7 @@ public class FinallyBlock extends CatchBlock { |
|
|
|
|
writer.print("finally"); |
|
|
|
|
writer.openBrace(); |
|
|
|
|
writer.tab(); |
|
|
|
|
catchBlock.dumpSource(writer); |
|
|
|
|
subBlock.dumpSource(writer); |
|
|
|
|
writer.untab(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|