Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.flow
Class SequentialBlock

java.lang.Object
  extended bynet.sf.jode.flow.StructuredBlock
      extended bynet.sf.jode.flow.SequentialBlock

public class SequentialBlock
extends StructuredBlock

A sequential block combines exactly two structured blocks to a new one. The first sub block mustn't be another sequential block, instead the second sub block should be used for this.


Constructor Summary
SequentialBlock()
           
 
Method Summary
 void checkConsistent()
           
 void dumpInstruction(TabbedPrintWriter writer)
          Print the instruction expressing this structured block.
 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 isSingleExit(StructuredBlock subBlock)
          Tells if the sub block is the single exit point of the current block.
 boolean jumpMayBeChanged()
          Determines if there is a sub block, that flows through to the end of this block.
 void makeDeclaration(java.util.Set done)
          Make the declarations, i.e. initialize the declare variable to correct values.
 VariableStack mapStackToLocal(VariableStack stack)
          This does take the instr into account and modifies stack accordingly.
 java.util.Set propagateUsage()
          Propagate the used set.
 void removeOnetimeLocals()
          This method should remove local variables that are only written and read one time directly after another.
 boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock)
          Replaces the given sub block with a new block.
 void setFirst(StructuredBlock sb)
           
 void setSecond(StructuredBlock sb)
           
 
Methods inherited from class net.sf.jode.flow.StructuredBlock
appendBlock, contains, copyJump, doTransformations, dumpSource, fillInGenSet, flowMayBeChanged, getDeclarables, getNextBlock, getNextFlowBlock, isEmpty, moveJump, needsBraces, prependBlock, removeBlock, removeJump, removePush, replace, setFlowBlock, setJump, setSuccessors, simplify, swapJump, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequentialBlock

public SequentialBlock()
Method Detail

setFirst

public void setFirst(StructuredBlock sb)

setSecond

public void setSecond(StructuredBlock sb)

checkConsistent

public void checkConsistent()
Overrides:
checkConsistent in class StructuredBlock

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.

removeOnetimeLocals

public void removeOnetimeLocals()
This method should remove local variables that are only written and read one time directly after another.
This is especially important for stack locals, that are created when there are unusual swap or dup instructions, but also makes inlined functions more pretty (but not that close to the bytecode).

Overrides:
removeOnetimeLocals in class StructuredBlock

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

isSingleExit

public boolean isSingleExit(StructuredBlock subBlock)
Tells if the sub block is the single exit point of the current block.

Overrides:
isSingleExit in class StructuredBlock
Parameters:
subBlock - the sub block.
Returns:
true, if the sub block is the single exit point of the current block.

propagateUsage

public java.util.Set propagateUsage()
Propagate the used set. Sequential blocks are special, because they "use" everything the first block uses. This is, because the first block can't declare something that is only visible in the first block.

Overrides:
propagateUsage in class StructuredBlock
Returns:
all locals that are used in this block or in some sub block (this is not the used set).

makeDeclaration

public void makeDeclaration(java.util.Set done)
Make the declarations, i.e. initialize the declare variable to correct values. This will declare every variable that is marked as used, but not done.

Overrides:
makeDeclaration in class StructuredBlock
Parameters:
done - The set of the already declare variables.

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

replaceSubBlock

public boolean replaceSubBlock(StructuredBlock oldBlock,
                               StructuredBlock newBlock)
Replaces the given sub block with a new block.

Overrides:
replaceSubBlock in class StructuredBlock
Parameters:
oldBlock - the old sub block.
newBlock - the new sub block.
Returns:
false, if oldBlock wasn't a direct sub block.

getSubBlocks

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

Overrides:
getSubBlocks in class StructuredBlock

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.