Package serp.bytecode
Class LineNumber
- java.lang.Object
-
- serp.bytecode.LineNumber
-
- All Implemented Interfaces:
java.lang.Comparable
,BCEntity
,InstructionPtr
,VisitAcceptor
public class LineNumber extends java.lang.Object implements java.lang.Comparable, InstructionPtr, BCEntity, VisitAcceptor
A line number corresponds to a sequence of opcodes that map logically to a line of source code.
-
-
Field Summary
Fields Modifier and Type Field Description private int
_line
private LineNumberTable
_owner
(package private) InstructionPtrStrategy
_target
-
Constructor Summary
Constructors Constructor Description LineNumber(LineNumberTable owner)
LineNumber(LineNumberTable owner, int startPc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisit(BCVisitor visit)
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.int
compareTo(java.lang.Object other)
java.lang.ClassLoader
getClassLoader()
Return the class loader to use when loading related classes.Code
getCode()
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.int
getLine()
Return source line number.ConstantPool
getPool()
Return the constant pool of the current class.Project
getProject()
Return the project of the current class.Instruction
getStart()
Return the instruction marking the beginning of this line.int
getStartPc()
Return the index into the code byte array at which this line starts.LineNumberTable
getTable()
Line numbers are stored in aLineNumberTable
.(package private) void
invalidate()
boolean
isValid()
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.(package private) void
read(java.io.DataInput in)
void
replaceTarget(Instruction oldTarget, Instruction newTarget)
Replace the given old, likely invalid, target with a new target.void
setLine(int lineNumber)
Set the source line number.void
setStart(Instruction instruction)
Set theInstruction
marking the beginning this line.void
setStartPc(int startPc)
Set the index into the code byte array at which this line starts.void
updateTargets()
Use the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr.(package private) void
write(java.io.DataOutput out)
-
-
-
Field Detail
-
_line
private int _line
-
_owner
private LineNumberTable _owner
-
_target
InstructionPtrStrategy _target
-
-
Constructor Detail
-
LineNumber
LineNumber(LineNumberTable owner)
-
LineNumber
LineNumber(LineNumberTable owner, int startPc)
-
-
Method Detail
-
getTable
public LineNumberTable getTable()
Line numbers are stored in aLineNumberTable
.
-
invalidate
void invalidate()
-
getLine
public int getLine()
Return source line number.
-
setLine
public void setLine(int lineNumber)
Set the source line number.
-
getStart
public Instruction getStart()
Return the instruction marking the beginning of this line.
-
getStartPc
public int getStartPc()
Return the index into the code byte array at which this line starts.
-
setStartPc
public void setStartPc(int startPc)
Set the index into the code byte array at which this line starts.
-
setStart
public void setStart(Instruction instruction)
Set theInstruction
marking the beginning this line. The instruction must already be a part of the method.
-
updateTargets
public void updateTargets()
Description copied from interface:InstructionPtr
Use the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr. This method will be called after the byte code has been read in for the first time and before it is written after modification.- Specified by:
updateTargets
in interfaceInstructionPtr
-
replaceTarget
public void replaceTarget(Instruction oldTarget, Instruction newTarget)
Description copied from interface:InstructionPtr
Replace the given old, likely invalid, target with a new target. The new target Instruction is guaranteed to be in the same code block as this InstructionPtr.- Specified by:
replaceTarget
in interfaceInstructionPtr
-
getProject
public Project getProject()
Description copied from interface:BCEntity
Return the project of the current class.- Specified by:
getProject
in interfaceBCEntity
-
getPool
public ConstantPool getPool()
Description copied from interface:BCEntity
Return the constant pool of the current class.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:BCEntity
Return the class loader to use when loading related classes.- Specified by:
getClassLoader
in interfaceBCEntity
-
isValid
public boolean isValid()
Description copied from interface:BCEntity
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.
-
acceptVisit
public void acceptVisit(BCVisitor visit)
Description copied from interface:VisitAcceptor
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.- Specified by:
acceptVisit
in interfaceVisitAcceptor
-
compareTo
public int compareTo(java.lang.Object other)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
read
void read(java.io.DataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
write
void write(java.io.DataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
getCode
public Code getCode()
Description copied from interface:InstructionPtr
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.- Specified by:
getCode
in interfaceInstructionPtr
-
-