Package serp.bytecode
Class LineNumberTable
java.lang.Object
serp.bytecode.Attributes
serp.bytecode.Attribute
serp.bytecode.LineNumberTable
- All Implemented Interfaces:
BCEntity
,InstructionPtr
,VisitAcceptor
Code blocks compiled from source have line number tables mapping
opcodes to source lines. This table automatically maintains line
numbers in ascending order by their start program counter position
at all times.
- Author:
- Abe White
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Add a new line number to this table.addLineNumber
(int startPc, int line) Add a new line number to this table.addLineNumber
(Instruction start, int line) Add a new line number to this table.Import a line number from another method.void
clear()
Clear the line numbers.getCode()
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.getLineNumber
(int pc) Return the line number for the given program counter, or null if none.getLineNumber
(Instruction ins) Return the line number for the given instruction, or null if none.Return the line numbers held in this table.boolean
removeLineNumber
(int pc) Remove the line number for the given program counter.boolean
Remove the line number for the given instruction.boolean
Remove the given line.void
replaceTarget
(Instruction oldTarget, Instruction newTarget) Replace the given old, likely invalid, target with a new target.void
setLineNumbers
(LineNumber[] lines) Set the line numbers for the table.void
Use the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr.Methods inherited from class serp.bytecode.Attribute
getClassLoader, getName, getNameIndex, getOwner, getPool, getProject, isValid
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, removeAttribute, removeAttribute, setAttributes
-
Method Details
-
getLineNumbers
Return the line numbers held in this table. -
getLineNumber
Return the line number for the given program counter, or null if none. -
getLineNumber
Return the line number for the given instruction, or null if none. -
setLineNumbers
Set the line numbers for the table. This method is useful when importing line numbers from another method. -
addLineNumber
Import a line number from another method.- Returns:
- the newly added line number
-
addLineNumber
Add a new line number to this table. -
addLineNumber
Add a new line number to this table. -
addLineNumber
Add a new line number to this table. -
clear
public void clear()Clear the line numbers. -
removeLineNumber
Remove the given line.- Returns:
- true if the line was removed, false otherwise
-
removeLineNumber
public boolean removeLineNumber(int pc) Remove the line number for the given program counter.- Returns:
- true if the line was removed, false otherwise
-
removeLineNumber
Remove the line number for the given instruction.- Returns:
- true if the line was removed, false otherwise
-
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
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
-
acceptVisit
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
-
getCode
Description copied from interface:InstructionPtr
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.- Specified by:
getCode
in interfaceInstructionPtr
-