mjc

org.multijava.util.backend
Class BasicBlock

java.lang.Object
  extended byorg.multijava.util.classfile.AbstractInstructionAccessor
      extended byorg.multijava.util.backend.BasicBlock
All Implemented Interfaces:
AccessorContainer, InstructionAccessor

class BasicBlock
extends AbstractInstructionAccessor
implements AccessorContainer

This class replaces all references to instructions by their associated handle. At the same time, it adds line numbers to the handles and checks if they are references by an instruction, handler or local variable info.


Field Summary
private  QTemporary[] entryStack
           
private  InstructionHandle firstInstruction
           
private  InstructionHandle[] insns
           
private  boolean marked
           
private  BasicBlock next
           
private  int pos
           
private  QNode[] quads
           
private  QTemporary[] remainingStack
           
private  QQuadruple[][] successorAccess
           
private  BasicBlock[] successors
           
 
Constructor Summary
BasicBlock(int pos)
          Creates a new basic block
 
Method Summary
 void attachTo(AccessorContainer container)
          Notifies this handle that is has been attached to the specified container.
 void buildQuadruples(MethodEnv env)
          Builds quadruples
private  BasicBlock[] buildSuccessorList()
           
 void generateQuadruple(CodeSequence seq)
          Generates the flow of instructions
 InstructionHandle getFirstInstruction()
          Returns the first instruction of the basic block
 QNode getLastNode()
          Returns the last instruction of the basic block
 int getPosition()
          Returns the position of the BasicBlock in the list
 QNode[] getQuadruples()
          Returns the quadruples of this block
 QNode[][] getSuccessorAccess()
          Returns the successors of this block
 QNode[] getSuccessorNodes(int pos, int branch)
          Returns the successors of this block
 BasicBlock[] getSuccessors()
          Returns the successors of this block
private  QQuadruple[] getTransition(BasicBlock target)
           
 boolean isMarked()
          Sets this block to be marked
private  void optimizeOrder(BasicBlock[] bblocks, CodeSequence seq)
           
 void resolveJump()
          Resolves the jumps Make jumps point to basic block instead of instructions
 void setBody(InstructionHandle[] insns)
          Sets the body of this basic block
 void setBody(QQuadruple[] quads)
          Sets the body of this basic block
 void setMarked(boolean marked)
          Sets this block to be marked
 void setNext(BasicBlock next)
          Sets the next basic block in textual order
 String toString()
          Human readable form
 void transformAccessors(AccessorTransformer transformer)
          Transforms the accessors contained in this class.
 
Methods inherited from class org.multijava.util.classfile.AbstractInstructionAccessor
transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

insns

private InstructionHandle[] insns

firstInstruction

private InstructionHandle firstInstruction

quads

private QNode[] quads

remainingStack

private QTemporary[] remainingStack

entryStack

private QTemporary[] entryStack

marked

private boolean marked

next

private BasicBlock next

successors

private BasicBlock[] successors

successorAccess

private QQuadruple[][] successorAccess

pos

private int pos
Constructor Detail

BasicBlock

public BasicBlock(int pos)
Creates a new basic block

Method Detail

getPosition

public int getPosition()
Returns the position of the BasicBlock in the list


getQuadruples

public QNode[] getQuadruples()
Returns the quadruples of this block


getSuccessors

public BasicBlock[] getSuccessors()
Returns the successors of this block


getSuccessorAccess

public QNode[][] getSuccessorAccess()
Returns the successors of this block


getSuccessorNodes

public QNode[] getSuccessorNodes(int pos,
                                 int branch)
Returns the successors of this block


setNext

public void setNext(BasicBlock next)
Sets the next basic block in textual order


setBody

public void setBody(InstructionHandle[] insns)
Sets the body of this basic block

Parameters:
insns - the array of instructions

setBody

public void setBody(QQuadruple[] quads)
Sets the body of this basic block

Parameters:
quads - the array of quadruples

getFirstInstruction

public final InstructionHandle getFirstInstruction()
Returns the first instruction of the basic block


getLastNode

public final QNode getLastNode()
Returns the last instruction of the basic block


buildQuadruples

public void buildQuadruples(MethodEnv env)
Builds quadruples


generateQuadruple

public void generateQuadruple(CodeSequence seq)
Generates the flow of instructions


resolveJump

public void resolveJump()
Resolves the jumps Make jumps point to basic block instead of instructions


setMarked

public void setMarked(boolean marked)
Sets this block to be marked


isMarked

public boolean isMarked()
Sets this block to be marked


toString

public String toString()
Human readable form

Overrides:
toString in class Object

optimizeOrder

private void optimizeOrder(BasicBlock[] bblocks,
                           CodeSequence seq)

buildSuccessorList

private BasicBlock[] buildSuccessorList()

getTransition

private QQuadruple[] getTransition(BasicBlock target)

transformAccessors

public void transformAccessors(AccessorTransformer transformer)
                        throws BadAccessorException
Transforms the accessors contained in this class.

Specified by:
transformAccessors in interface AccessorContainer
Parameters:
transformer - the transformer used to transform accessors
Throws:
BadAccessorException

attachTo

public void attachTo(AccessorContainer container)
Notifies this handle that is has been attached to the specified container.


mjc

mjc is Copyright (C) 2000-2004 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.