Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.flow
Class SwitchBlock

java.lang.Object
  extended bynet.sf.jode.flow.StructuredBlock
      extended bynet.sf.jode.flow.InstructionContainer
          extended bynet.sf.jode.flow.SwitchBlock
All Implemented Interfaces:
BreakableBlock

public class SwitchBlock
extends InstructionContainer
implements BreakableBlock

This is the structured block for an empty block.


Constructor Summary
SwitchBlock(Expression instr, int[] cases)
           
 
Method Summary
 void doJumpTrafo()
           
 boolean doTransformations()
          Do simple transformation on the structuredBlock.
 void dumpInstruction(TabbedPrintWriter writer)
          Print the instruction expressing this structured block.
 StructuredBlock findCase(FlowBlock destination)
          Find the case that jumps directly to destination.
 java.lang.String getLabel()
          Returns the label of this block and creates a new label, if there wasn't a label previously.
 StructuredBlock getNextBlock(StructuredBlock subBlock)
          Returns the block where the control will normally flow to, when the given sub block is finished (not ignoring the jump after this block).
 FlowBlock getNextFlowBlock(StructuredBlock subBlock)
           
 StructuredBlock[] getSubBlocks()
          Returns all sub block of this structured block.
 boolean jumpMayBeChanged()
          Determines if there is a sub block, that flows through to the end of this block.
 VariableStack mapStackToLocal(VariableStack stack)
          This does take the instr into account and modifies stack accordingly.
 void mergeBreakedStack(VariableStack stack)
          Is called by BreakBlock, to tell us what the stack can be after a break.
 StructuredBlock prevCase(StructuredBlock block)
          Find the case that precedes the given case.
 void removePush()
          This is called after mapStackToLocal to do the stack to local transformation.
 void setBreaked()
          Is called by BreakBlock, to tell us that this block is breaked.
 void setSuccessors(Jump[] jumps)
          Sets the successors of this structured block.
 
Methods inherited from class net.sf.jode.flow.InstructionContainer
fillInGenSet, getDeclarables, getInstruction, makeDeclaration, removeOnetimeLocals, setInstruction, simplify
 
Methods inherited from class net.sf.jode.flow.StructuredBlock
appendBlock, checkConsistent, contains, copyJump, dumpSource, flowMayBeChanged, getNextBlock, getNextFlowBlock, isEmpty, isSingleExit, moveJump, needsBraces, prependBlock, propagateUsage, removeBlock, removeJump, replace, replaceSubBlock, setFlowBlock, setJump, swapJump, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SwitchBlock

public SwitchBlock(Expression instr,
                   int[] cases)
Method Detail

setSuccessors

public void setSuccessors(Jump[] jumps)
Sets the successors of this structured block. This should be only called once, by FlowBlock.setSuccessors().

Overrides:
setSuccessors in class StructuredBlock

doTransformations

public boolean doTransformations()
Description copied from class: StructuredBlock
Do simple transformation on the structuredBlock.

Overrides:
doTransformations in class InstructionContainer

doJumpTrafo

public void doJumpTrafo()

mapStackToLocal

public VariableStack mapStackToLocal(VariableStack stack)
This does take the instr into account and modifies stack accordingly. It then calls super.mapStackToLocal.

Overrides:
mapStackToLocal in class StructuredBlock
Parameters:
stack - the stack before the instruction is called
Returns:
stack the stack afterwards.

mergeBreakedStack

public void mergeBreakedStack(VariableStack stack)
Is called by BreakBlock, to tell us what the stack can be after a break.

Specified by:
mergeBreakedStack in interface BreakableBlock
Parameters:
stack - the stack at the break.

removePush

public void removePush()
Description copied from class: StructuredBlock
This is called after mapStackToLocal to do the stack to local transformation.

Overrides:
removePush in class StructuredBlock

findCase

public StructuredBlock findCase(FlowBlock destination)
Find the case that jumps directly to destination.

Returns:
The sub block of the case block, which jumps to destination.

prevCase

public StructuredBlock prevCase(StructuredBlock block)
Find the case that precedes the given case.

Parameters:
block - The sub block of the case, whose predecessor should be returned.
Returns:
The sub block of the case precedes the given case.

getNextBlock

public StructuredBlock getNextBlock(StructuredBlock subBlock)
Returns the block where the control will normally flow to, when the given sub block is finished (not ignoring the jump after this block). (This is overwritten by SequentialBlock and SwitchBlock). If this isn't called with a direct sub block, the behaviour is undefined, so take care.

Overrides:
getNextBlock in class StructuredBlock
Returns:
null, if the control flows to another FlowBlock.

getNextFlowBlock

public FlowBlock getNextFlowBlock(StructuredBlock subBlock)
Overrides:
getNextFlowBlock in class StructuredBlock

dumpInstruction

public void dumpInstruction(TabbedPrintWriter writer)
                     throws java.io.IOException
Description copied from class: StructuredBlock
Print the instruction expressing this structured block.

Specified by:
dumpInstruction in class StructuredBlock
Parameters:
writer - The tabbed print writer, where we print to.
Throws:
java.io.IOException

getSubBlocks

public StructuredBlock[] getSubBlocks()
Returns all sub block of this structured block.

Overrides:
getSubBlocks in class StructuredBlock

getLabel

public java.lang.String getLabel()
Returns the label of this block and creates a new label, if there wasn't a label previously.

Specified by:
getLabel in interface BreakableBlock

setBreaked

public void setBreaked()
Is called by BreakBlock, to tell us that this block is breaked.

Specified by:
setBreaked in interface BreakableBlock

jumpMayBeChanged

public boolean jumpMayBeChanged()
Determines if there is a sub block, that flows through to the end of this block. If this returns true, you know that jump is null.

Overrides:
jumpMayBeChanged in class StructuredBlock
Returns:
true, if the jump may be safely changed.

Jode 1.90-CVS
Build Aug 6, 2004

Copyright © 1998-2004 by Jochen Hoenicke.