org.quilt.cl
Class CodeVertex

java.lang.Object
  |
  +--org.quilt.graph.Vertex
        |
        +--org.quilt.cl.CodeVertex
Direct Known Subclasses:
CounterVertex

public class CodeVertex
extends Vertex

A Vertex extended to carry the initial bytecode offset, line number, and an instruction list.

Author:
Jim Dixon

Field Summary
protected  org.apache.bcel.generic.Instruction connInst_
          Instruction connecting this vertex to other(s).
protected  int endLine_
          Line number in source code corresponding to the connecting instruction, or if there is no such instruction, to the last instruction in the block
protected  org.apache.bcel.generic.InstructionList ilist
          the bytecode iteself
protected  int pos
          initial offset of first instruction in bytecode
protected  int startLine_
          Line number in source code corresponding to first instruction, or if there is no such instruction, of the connecting instruction.
 
Fields inherited from class org.quilt.graph.Vertex
connector, graph, index, label_
 
Constructor Summary
CodeVertex(ControlFlowGraph g)
          Create a code vertex with default bytecode offset, line number, empty instruction list, and no label.
CodeVertex(ControlFlowGraph g, int position)
          Create a code vertex, specifying a non-negative bytecode offset.
CodeVertex(ControlFlowGraph g, java.lang.String l)
          Create a code vertex, specifying a label
 
Method Summary
 org.apache.bcel.generic.Instruction getConnInst()
          Get connecting instruction.
 int getEndLine()
          Get the line number in source code corresponding to the connecting instruction or last instruction in the block.
 org.apache.bcel.generic.InstructionList getInstructionList()
          Get a reference to the InstructionList carried by the vertex.
 int getPosition()
          Get the bytecode offset of the first instruction.
 int getStartLine()
          Get the source code line number of the first instruction in a code vertex.
 void moveGoto(CodeVertex target)
          Move this code vertex's Goto to another code vertex.
 void setConnInst(org.apache.bcel.generic.Instruction i)
          Set the connecting instruction for this vertex.
 void setEndLine(int n)
          Set the source line number of the connecting instruction, or of the last line number in the block if there is no connecting instruction.
 void setPos(int position)
          Set the bytecode offset for the first instruction.
 void setStartLine(int n)
          Set the source code line number.
 java.lang.String toString()
          Less verbose toString.
 java.lang.String toString(boolean b)
          Optionally more verbose method.
 
Methods inherited from class org.quilt.graph.Vertex
above, checkForNull, getConnector, getEdge, getGraph, getIndex, getLabel, getTarget, makeBinary, makeComplex, makeMulti, setConnector, setLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pos

protected int pos
initial offset of first instruction in bytecode


ilist

protected org.apache.bcel.generic.InstructionList ilist
the bytecode iteself


startLine_

protected int startLine_
Line number in source code corresponding to first instruction, or if there is no such instruction, of the connecting instruction.


endLine_

protected int endLine_
Line number in source code corresponding to the connecting instruction, or if there is no such instruction, to the last instruction in the block


connInst_

protected org.apache.bcel.generic.Instruction connInst_
Instruction connecting this vertex to other(s).

Constructor Detail

CodeVertex

public CodeVertex(ControlFlowGraph g)
Create a code vertex with default bytecode offset, line number, empty instruction list, and no label.

Parameters:
g - Graph which the vertex belongs to.

CodeVertex

public CodeVertex(ControlFlowGraph g,
                  int position)
Create a code vertex, specifying a non-negative bytecode offset.

Parameters:
g - Graph which the vertex belongs to.
position - Offset of the first instruction in the bytecode.

CodeVertex

public CodeVertex(ControlFlowGraph g,
                  java.lang.String l)
Create a code vertex, specifying a label

Parameters:
g - Graph which the vertex belongs to.
l - The String label applied to the vertex.
Method Detail

getConnInst

public org.apache.bcel.generic.Instruction getConnInst()
Get connecting instruction.


setConnInst

public void setConnInst(org.apache.bcel.generic.Instruction i)
Set the connecting instruction for this vertex.


getInstructionList

public org.apache.bcel.generic.InstructionList getInstructionList()
Get a reference to the InstructionList carried by the vertex. This is a doubly indirect reference to the first instruction in the list.

Returns:
Instruction list.

getStartLine

public int getStartLine()
Get the source code line number of the first instruction in a code vertex.

Returns:
Non-negative integer or -1, meaning no line number assigned.

setStartLine

public void setStartLine(int n)
Set the source code line number.

Parameters:
n - Source code line number.

getEndLine

public int getEndLine()
Get the line number in source code corresponding to the connecting instruction or last instruction in the block.


setEndLine

public void setEndLine(int n)
Set the source line number of the connecting instruction, or of the last line number in the block if there is no connecting instruction.

Parameters:
n - Source code end line number.

getPosition

public int getPosition()
Get the bytecode offset of the first instruction.

Returns:
The initial bytecode offset of the first instruction carried by the vertex (excluding any connection instruction.

setPos

public void setPos(int position)
Set the bytecode offset for the first instruction. XXX Should rename this to setPosition to match the get method.

Parameters:
position - A non-negative integer representing the bytecode position of the first instruction.

moveGoto

public void moveGoto(CodeVertex target)
Move this code vertex's Goto to another code vertex. The second vertex will be the target on the otherEdge from this vertex. This vertex has a BinaryConnector. The second vertex has a UnaryConnector. The goto instruction does NOT point to the target. The target is some sort of instrumentation being inserted into the graph.


toString

public java.lang.String toString()
Less verbose toString.

Overrides:
toString in class Vertex
Returns:
Graph index and Vertex index in a neatly formatted String, *not* newline-terminated.

toString

public java.lang.String toString(boolean b)
Optionally more verbose method.

Parameters:
b - If true, add label (if any) and instruction list.
Returns:
A neatly formatted String.


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.