Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.core
Class ControlFlowGraph.Block

    java.lang.Object
      avrora.core.ControlFlowGraph.Block

Enclosing class:
  ControlFlowGraph

public class ControlFlowGraph.Block
extends java.lang.Object

The `Block` class represents a basic block of code within the program. A basic block contains a straight-line piece of code that ends with a control instruction (e.g. a skip, a jump, a branch, or a call) or an implicit fall-through to the next basic block. It contains at most two references to successor basic blocks.

For fallthroughs (no ending control instruction), the `next` field refers to the block immediately following this block, and the `other` field is null.

For jumps, the `other` field refers to the block that is the target of the jump, and the `next` field is null.

For skips, branches, and calls, the `next` field refers to the block immediately following this block (i.e. not-taken for branches, the return address for calls). The `other` field refers to the target address of the branch if it is taken or the address to be called.

For indirect jumps both the `next` and `other` fields are null.

For indirect calls the `next` field refers to the block immediately following this block (i.e. the return address). The `other` field is null because the target of the call cannot be known.

Method Summary
`void` | `addInstr(Instr i)` The `addInstr()` method adds an instruction to the end of this basic block.
`boolean` | `equals(java.lang.Object o)` The `equals()` method computes object equality for basic blocks.
`int` | `getAddress()` The `getAddress()` method gets the starting byte address of this basic block.
`java.util.Iterator` | `getEdgeIterator()`
`java.util.Iterator` | `getInstrIterator()` The `getInstrIterator()` method returns an iterator over the instructions in this basic block.
`int` | `getLastAddress()` The `getLastAddress()` gets the last address that this block covers.
`int` | `getLength()` The `getLength()` returns the length of this basic block in terms of the number of instructions
`int` | `getSize()` The `getSize()` method returns the size of the basic block in bytes.
`int` | `hashCode()` The `hashCode()` method computes the hash code of this block.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### addInstr

    public void addInstr(Instr i)

  The `addInstr()` method adds an instruction to the end of this basic block. It is not recommended for general use: it is generally used by the `CFGBuilder` class. No enforcement of invariants is made: this method does not check whether the instruction being added changes the control flow or branches to another block, etc.

  Parameters:
    `i` - the instruction to add to this basic block

### hashCode

    public int hashCode()

  The `hashCode()` method computes the hash code of this block. In the initial implementation, the hash code is simply the byte address of the block

  Returns:
    an integer value that is the hash code of this object

### equals

    public boolean equals(java.lang.Object o)

  The `equals()` method computes object equality for basic blocks. It simply compares the addresses of the basic blocks and returns true if they match.

  Parameters:
    `o` - the other object to compare to
  Returns:
    true if these two basic blocks are equivalent; false otherwise

### getAddress

    public int getAddress()

  The `getAddress()` method gets the starting byte address of this basic block.

  Returns:
    the starting address of this basic block

### getLastAddress

    public int getLastAddress()

  The `getLastAddress()` gets the last address that this block covers.

  Returns:
    the last address that this block covers

### getSize

    public int getSize()

  The `getSize()` method returns the size of the basic block in bytes.

  Returns:
    the number of bytes in this basic block

### getLength

    public int getLength()

  The `getLength()` returns the length of this basic block in terms of the number of instructions

  Returns:
    the number of instructions in this basic block

### getInstrIterator

    public java.util.Iterator getInstrIterator()

  The `getInstrIterator()` method returns an iterator over the instructions in this basic block. The resulting iterator can be used to iterate over the instructions in the basic block in order.

  Returns:
    an iterator over the instructions in this block.

### getEdgeIterator

    public java.util.Iterator getEdgeIterator()

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD