|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jode.flow.StructuredBlock
public abstract class StructuredBlock
A structured block is the building block of the source programm. For every program construct like if, while, try, or blocks there is a corresponding structured block. Some of these Block are only intermediate representation, that get converted to another block later. Every block has to handle the local variables that it contains. This is done by the in/out vectors and the local variable structure themself. Every local variable used in this structured block is either in or out. There are following types of structured blocks:
Constructor Summary | |
---|---|
StructuredBlock()
|
Method Summary | |
---|---|
StructuredBlock |
appendBlock(StructuredBlock block)
Appends a block to this block. |
void |
checkConsistent()
|
boolean |
contains(StructuredBlock child)
Returns if this block contains the given block. |
void |
copyJump(Jump jump)
This function copies the jump to this block. |
boolean |
doTransformations()
Do simple transformation on the structuredBlock. |
abstract void |
dumpInstruction(TabbedPrintWriter writer)
Print the instruction expressing this structured block. |
void |
dumpSource(TabbedPrintWriter writer)
Print the source code for this structured block. |
void |
fillInGenSet(Set in,
Set gen)
Fill all in variables into the given VariableSet. |
boolean |
flowMayBeChanged()
Determines if there is a path, that flows through the end of this block. |
List<InstructionHandle> |
getBCELInstructions()
|
List<Instruction> |
getBytecodeInstructions()
Returns the list of bytecode instructions that represents this block. |
Set |
getDeclarables()
|
StructuredBlock |
getNextBlock()
Returns the block where the control will normally flow to, when this block is finished. |
StructuredBlock |
getNextBlock(StructuredBlock subBlock)
Returns the block where the control will normally flow to, when the given sub block is finished. |
FlowBlock |
getNextFlowBlock()
Returns the flow block where the control will normally flow to, when this block is finished. |
FlowBlock |
getNextFlowBlock(StructuredBlock subBlock)
|
StructuredBlock[] |
getSubBlocks()
Returns all sub block of this structured block. |
boolean |
isEmpty()
Tells if this block is empty and only changes control flow. |
boolean |
isSingleExit(StructuredBlock subBlock)
Tells if the sub block is the single exit point of the current block. |
boolean |
jumpMayBeChanged()
|
void |
makeDeclaration(Set done)
Make the declarations, i.e. |
VariableStack |
mapStackToLocal(VariableStack stack)
This is called after the analysis is completely done. |
void |
moveJump(Jump jump)
This function moves the jump to this block. |
boolean |
needsBraces()
Tells if this block needs braces when used in a if or while block. |
StructuredBlock |
prependBlock(StructuredBlock block)
Prepends a block to this block. |
Set |
propagateUsage()
Propagate the used set. |
void |
removeBlock()
Removes this block, or replaces it with an EmptyBlock. |
void |
removeJump()
Removes the jump. |
void |
removeOnetimeLocals()
This method should remove local variables that are only written and read one time directly after another. |
void |
removePush()
This is called after mapStackToLocal to do the stack to local transformation. |
void |
replace(StructuredBlock sb)
This function replaces sb with this block. |
boolean |
replaceSubBlock(StructuredBlock oldBlock,
StructuredBlock newBlock)
Replaces the given sub block with a new block. |
void |
setFlowBlock(FlowBlock flowBlock)
Set the flow block of this block and all sub blocks. |
void |
setJump(Jump jump)
|
void |
setSuccessors(Jump[] jumps)
Sets the successors of this structured block. |
void |
simplify()
|
void |
swapJump(StructuredBlock block)
This function swaps the jump with another block. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StructuredBlock()
Method Detail |
---|
public StructuredBlock getNextBlock()
public void setSuccessors(Jump[] jumps)
public void setJump(Jump jump)
public FlowBlock getNextFlowBlock()
public StructuredBlock getNextBlock(StructuredBlock subBlock)
public FlowBlock getNextFlowBlock(StructuredBlock subBlock)
public boolean isEmpty()
public boolean isSingleExit(StructuredBlock subBlock)
subBlock
- the sub block.
public boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock)
oldBlock
- the old sub block.newBlock
- the new sub block.
public StructuredBlock[] getSubBlocks()
public List<Instruction> getBytecodeInstructions()
public List<InstructionHandle> getBCELInstructions()
public boolean contains(StructuredBlock child)
child
- the block which should be contained by this block.
public final void removeJump()
public void replace(StructuredBlock sb)
It will also move the definitions of sb and childs to this block, but only descend to sub and not further. It is assumed that sub will become a sub block of this block.
sb
- The structured block that should be replaced.public void swapJump(StructuredBlock block)
block
- The block whose jump is swapped.public void moveJump(Jump jump)
jump
- The jump that should be moved, may be null.public void copyJump(Jump jump)
jump
- The jump that should be moved, may be null.public StructuredBlock appendBlock(StructuredBlock block)
public StructuredBlock prependBlock(StructuredBlock block)
public final void removeBlock()
public boolean flowMayBeChanged()
public boolean jumpMayBeChanged()
public Set getDeclarables()
public Set propagateUsage()
public VariableStack mapStackToLocal(VariableStack stack)
The default implementation merges the stack after each sub block. This may not be, what you want.
stack
- the stackmap at begin of the block
RuntimeException
- if something did get wrong.public void removePush()
public void removeOnetimeLocals()
public void makeDeclaration(Set done)
done
- The set of the already declare variables.public void checkConsistent()
public void setFlowBlock(FlowBlock flowBlock)
flowBlock
- the new flow blockpublic boolean needsBraces()
public void fillInGenSet(Set in, Set gen)
in
- The VariableSet, the in variables should be stored to.public void dumpSource(TabbedPrintWriter writer) throws IOException
writer
- The tabbed print writer, where we print to.
IOException
public abstract void dumpInstruction(TabbedPrintWriter writer) throws IOException
writer
- The tabbed print writer, where we print to.
IOException
public String toString()
toString
in class Object
public void simplify()
public boolean doTransformations()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |