Jode 1.90-CVS
Build Aug 6, 2004

net.sf.jode.bytecode
Class Block

java.lang.Object
  extended bynet.sf.jode.bytecode.Block

public final class Block
extends java.lang.Object

Represents a single basic block. It contains a list of instructions and the successor blocks.

All jump instructions must be at the end of the block. These jump instructions are opc_lookupswitch, opc_ifxxx, opc_jsr, opc_ret, opc_xreturn and opc_return. An opc_goto is implicit if the basic block doesn't end with a jump instructions, or if it ends with an conditional jump or jsr.

The jump instructions don't remember their destinations, instead the Block does it. This are the successor block. There are several cases:

If any successor is null it represents end of method, i.e. a return instruction. You can also use null successors for conditional jumps and switch instruction. You normally shouldn't use opc_return instructions. They are only necessary, if you want to return with a non-empty stack.

Author:
Jochen Hoenicke
See Also:
BasicBlocks, Instruction

Constructor Summary
Block()
          Creates a new block uninitialized block.
 
Method Summary
 void dumpCode(java.io.PrintWriter output)
           
 int getBlockNr()
          Gets the block number.
 Handler[] getHandlers()
          Gets the exception handlers whose try region contains this block.
 Instruction[] getInstructions()
          Gets the list of instructions.
 int getStackHeight()
          Returns the stack height at the beginning of the block.
 void getStackPopPush(int[] poppush)
           
 Block[] getSuccs()
          Gets the successor array.
 void setCode(Instruction[] instrs, Block[] succs)
          Set the code, i.e. instructions and successor blocks.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Block

public Block()
Creates a new block uninitialized block. You mustn't really use it (except as successor for other blocks) until you have set the code.

Method Detail

getInstructions

public Instruction[] getInstructions()
Gets the list of instructions. The returned list should not be modified, except that the instructions (but not their opcodes) may be modified.


getSuccs

public Block[] getSuccs()
Gets the successor array. The last successor is the next basic block that is jumped to via goto or the default part of a switch. For conditional jumps and jsrs the second successor gives the destination.


getHandlers

public Handler[] getHandlers()
Gets the exception handlers whose try region contains this block. You can't set them since they are calculated automatically.

Returns:
the exception handlers.
See Also:
BasicBlocks.setBlocks(net.sf.jode.bytecode.Block[], net.sf.jode.bytecode.Block, net.sf.jode.bytecode.Handler[])

getBlockNr

public int getBlockNr()
Gets the block number. The block numbers are consecutive number from 0 to the number of blocks in a method. The equation
 BasicBlocks.getBlock()[i].getBlockNr() == i 
always holds (as long as you don't do something dirty, like adding the same block to different BasicBlocks, or to the same but more than once).

Returns:
the block number.

getStackHeight

public int getStackHeight()
Returns the stack height at the beginning of the block. This is automatically calculated, when the block is inserted in a basic block.


getStackPopPush

public void getStackPopPush(int[] poppush)

setCode

public void setCode(Instruction[] instrs,
                    Block[] succs)
Set the code, i.e. instructions and successor blocks. The instructions must be valid and match the successors.


dumpCode

public void dumpCode(java.io.PrintWriter output)

toString

public java.lang.String toString()

Jode 1.90-CVS
Build Aug 6, 2004

Copyright © 1998-2004 by Jochen Hoenicke.