joeq.Compiler.Quad
Class QuadIterator

java.lang.Object
  extended by joeq.Compiler.Quad.QuadIterator
All Implemented Interfaces:
Iterator, ListIterator, ListIterator.Quad

public class QuadIterator
extends Object
implements ListIterator.Quad

Version:
$Id: QuadIterator.java 1931 2004-09-22 22:17:47Z joewhaley $
Author:
John Whaley

Field Summary
protected  ControlFlowGraph cfg
          A reference to the control flow graph that we are iterating over.
protected  BasicBlock currentBasicBlock
          References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.
protected  int lastIndex
          The index of the last quad that was returned.
protected  Quad lastQuad
          The last quad that was returned.
protected  BasicBlock nextBasicBlock
          References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.
protected  BasicBlock previousBasicBlock
          References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.
protected  ListIterator.Quad quadsInCurrentBasicBlock
          An iteration of the quads in the current basic block.
protected  ListIterator.BasicBlock rpoBasicBlocks
          The reverse post order iteration of basic blocks in the control flow graph.
 
Constructor Summary
QuadIterator(ControlFlowGraph cfg)
          Initialize the iterator to iterate over the quads in the given control flow graph in reverse post order.
QuadIterator(ControlFlowGraph cfg, boolean direction)
          Initialize the iterator to iterate over the quads in the given control flow graph.
 
Method Summary
 void add(Object obj)
          Adds a quad to the underlying quad list.
 BasicBlock getCurrentBasicBlock()
           
 Quad getCurrentQuad()
           
protected  Quad getFirstQuad(BasicBlock bb)
          Returns the first quad reachable from the start of the given basic block.
protected  Quad getLastQuad(BasicBlock bb)
          Returns the last quad reachable from the end of the given basic block.
 jwutil.graphs.Navigator getNavigator()
           
 boolean hasNext()
          Returns whether there is a next quad in this iteration.
 boolean hasPrevious()
          Returns whether this iteration has a previous quad.
 Object next()
          Return the next quad in the iteration.
 int nextIndex()
          Returns the index of the next quad to be returned.
 Quad nextQuad()
          Return the next quad in the iteration.
 Iterator predecessors()
           
 Collection predecessors1()
           
 Object previous()
          Returns the previous quad in the iteration.
 int previousIndex()
          Returns the index of the previous quad.
 Quad previousQuad()
          Returns the previous quad in the iteration.
 void remove()
          Removes the last-returned-quad from the underlying list.
 boolean searchBackward(Object node)
           
 boolean searchForward(Object node)
           
 void set(Object obj)
          Sets the current quad.
 Iterator successors()
          Return an iterator of the possible successor quads of the most recently returned quad.
 Collection successors1()
           
protected  void updateNextBB()
          Update the nextBasicBlock field to point to the next non-empty basic block from the reverse post order, or null if there are no more non-empty basic blocks.
protected  void updatePreviousBB()
          Update the previousBasicBlock field to point to the previous non-empty basic block from the reverse post order, or null if there are no more previous non-empty basic blocks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cfg

protected final ControlFlowGraph cfg
A reference to the control flow graph that we are iterating over.


rpoBasicBlocks

protected final ListIterator.BasicBlock rpoBasicBlocks
The reverse post order iteration of basic blocks in the control flow graph. When going forward, nextBasicBlock should always be the last basic block returned by this iterator.


previousBasicBlock

protected BasicBlock previousBasicBlock
References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.


currentBasicBlock

protected BasicBlock currentBasicBlock
References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.


nextBasicBlock

protected BasicBlock nextBasicBlock
References to the previous non-empty basic block, the current basic block, and the next non-empty basic block.


quadsInCurrentBasicBlock

protected ListIterator.Quad quadsInCurrentBasicBlock
An iteration of the quads in the current basic block.


lastIndex

protected int lastIndex
The index of the last quad that was returned.


lastQuad

protected Quad lastQuad
The last quad that was returned.

Constructor Detail

QuadIterator

public QuadIterator(ControlFlowGraph cfg)
Initialize the iterator to iterate over the quads in the given control flow graph in reverse post order.

Parameters:
cfg - the control flow graph

QuadIterator

public QuadIterator(ControlFlowGraph cfg,
                    boolean direction)
Initialize the iterator to iterate over the quads in the given control flow graph. If direction is true, the order is reverse post order and the iteration starts at the first quad. If direction is false, the order is post order on the reverse graph and the iteration starts at the last quad.

Parameters:
direction - the direction to iterate, forward==true
cfg - the control flow graph
Method Detail

updateNextBB

protected void updateNextBB()
Update the nextBasicBlock field to point to the next non-empty basic block from the reverse post order, or null if there are no more non-empty basic blocks.


updatePreviousBB

protected void updatePreviousBB()
Update the previousBasicBlock field to point to the previous non-empty basic block from the reverse post order, or null if there are no more previous non-empty basic blocks.


getCurrentBasicBlock

public BasicBlock getCurrentBasicBlock()

getCurrentQuad

public Quad getCurrentQuad()

nextQuad

public Quad nextQuad()
Return the next quad in the iteration.

Specified by:
nextQuad in interface ListIterator.Quad

next

public Object next()
Return the next quad in the iteration. Use nextQuad to avoid the type cast.

Specified by:
next in interface Iterator
Specified by:
next in interface ListIterator

hasNext

public boolean hasNext()
Returns whether there is a next quad in this iteration.

Specified by:
hasNext in interface Iterator
Specified by:
hasNext in interface ListIterator

getFirstQuad

protected Quad getFirstQuad(BasicBlock bb)
Returns the first quad reachable from the start of the given basic block.


getLastQuad

protected Quad getLastQuad(BasicBlock bb)
Returns the last quad reachable from the end of the given basic block.


set

public void set(Object obj)
Sets the current quad.

Specified by:
set in interface ListIterator

nextIndex

public int nextIndex()
Returns the index of the next quad to be returned.

Specified by:
nextIndex in interface ListIterator

previousQuad

public Quad previousQuad()
Returns the previous quad in the iteration.

Specified by:
previousQuad in interface ListIterator.Quad

previous

public Object previous()
Returns the previous quad in the iteration. Use previousQuad to avoid the type cast.

Specified by:
previous in interface ListIterator

remove

public void remove()
Removes the last-returned-quad from the underlying list.

Specified by:
remove in interface Iterator
Specified by:
remove in interface ListIterator

previousIndex

public int previousIndex()
Returns the index of the previous quad.

Specified by:
previousIndex in interface ListIterator

hasPrevious

public boolean hasPrevious()
Returns whether this iteration has a previous quad.

Specified by:
hasPrevious in interface ListIterator

add

public void add(Object obj)
Adds a quad to the underlying quad list.

Specified by:
add in interface ListIterator

successors

public Iterator successors()
Return an iterator of the possible successor quads of the most recently returned quad. If a possible successor is the method exit, it includes the "null" value in the iteration.

Throws:
IllegalStateException - if the nextQuad method has not yet been called.

successors1

public Collection successors1()

predecessors

public Iterator predecessors()

predecessors1

public Collection predecessors1()

getNavigator

public jwutil.graphs.Navigator getNavigator()

searchForward

public boolean searchForward(Object node)

searchBackward

public boolean searchBackward(Object node)


Copyright © 2001-2008 John Whaley. All Rights Reserved.