Class ProgramLocation
- All Implemented Interfaces:
Cloneable
,Comparable<ProgramLocation>
- Direct Known Subclasses:
AssignedVariableLocation
,CodeUnitLocation
,DecompilerLocation
,DividerLocation
,FunctionLocation
,FunctionPurgeFieldLocation
,InstructionMaskValueFieldLocation
,ParallelInstructionLocation
,PcodeFieldLocation
,RegisterFieldLocation
,RegisterTransitionFieldLocation
,StackDepthFieldLocation
ProgramLocation
provides information about a location in a program in the most
generic way.
ProgramLocations refer to a specific location in a program and can be specified down to an address, a field at that address, and within that field, a row, col, and character offset. The field is not recorded directly, but by the subclass of the ProgramLocation. The "cursor position" within a field is specified by three variables: row, col, and character offset. The row is literally the row (line #) the cursor is on within the field, the column represents the display item on that row (For example, in the bytes field the column will represent which "byte" the cursor is on. Most fields only have one column item per row.) And finally, the character offset is the character position within the display item specified by the row and column. Simple fields like the address field and Mnemonic field will always have a row and column of 0.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefault constructor required for restoring a program location from XML.ProgramLocation
(Program program, Address addr) Construct a new ProgramLocation for the given address.ProgramLocation
(Program program, Address addr, int[] componentPath, Address refAddr, int row, int col, int charOffset) Construct a new ProgramLocation for the given address.ProgramLocation
(Program program, Address addr, int row, int col, int charOffset) Construct a new ProgramLocation for the given address.ProgramLocation
(Program program, Address addr, Address refAddr) Construct a new ProgramLocation for the given address.ProgramLocation
(Program program, Address addr, Address byteAddr, int[] componentPath, Address refAddr, int row, int col, int charOffset) Construct a new ProgramLocation. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Object
clone()
protected static int
compareAddr
(Address addr1, Address addr2) int
compareTo
(ProgramLocation other) boolean
Returns the address associated with this location.Returns the byte level address associated with this location.int
Returns the character offset in the display item at the (row,col).int
Returns the column index of the display piece represented by this location.int[]
Returns the componentPath for thecode unit
.static ProgramLocation
getLocation
(Program program, SaveState saveState) Get the program location for the given program and save state object.Returns the program associated with this location.Returns the "referred to" address if the location is over an address in some field.int
getRow()
Returns the row within the program location.static ProgramLocation
getTranslatedCopy
(ProgramLocation loc, Program program, Address translatedAddress) Create a new translated copy of the specifiedProgramLocation
using the specifiedprogram
int
hashCode()
boolean
Returns true if this location represents a valid location in the given program.void
restoreState
(Program program1, SaveState obj) Restore this program location using the given program and save state object.void
Save this program location to the given save state object.toString()
-
Field Details
-
program
-
addr
-
refAddr
-
-
Constructor Details
-
ProgramLocation
public ProgramLocation(Program program, Address addr, Address byteAddr, int[] componentPath, Address refAddr, int row, int col, int charOffset) Construct a new ProgramLocation.- Parameters:
program
- the program of the locationaddr
- address of the location; cannot be null; This could be a code unit minimum address where the byteAddr is within the code unit.byteAddr
- address of the location; cannot be nullcomponentPath
- array of indexes for each nested data component; the data index is the data component's index within its parent; may be nullrefAddr
- the "referred to" address if the location is over a reference; may be nullrow
- the row within the field.col
- the display item index on the given row. (Note most fields only have one display item per row)charOffset
- the character offset within the display item.- Throws:
NullPointerException
- ifaddr
orprogram
is null
-
ProgramLocation
public ProgramLocation(Program program, Address addr, int[] componentPath, Address refAddr, int row, int col, int charOffset) Construct a new ProgramLocation for the given address. The address will be adjusted to the beginning of thecode unit
containing that address (if it exists). The original address can be retrieved using thegetByteAddress()
" method.- Parameters:
program
- the program associated with this program location (also used to obtain a code-unit-aligned address)addr
- address of the location; cannot be nullcomponentPath
- array of indexes for each nested data component; the index is the data component's index within its parent; may be nullrefAddr
- the "referred to" address if the location is over a reference; may be nullrow
- the row within the field.col
- the display item index on the given row. (Note most fields only have one display item per row)charOffset
- the character offset within the display item.- Throws:
NullPointerException
- ifaddr
orprogram
is null
-
ProgramLocation
Construct a new ProgramLocation for the given address. The address will be adjusted to the beginning of thecode unit
containing that address (if it exists). The original address can be retrieved using thegetByteAddress()
method.- Parameters:
program
- the program associated with this program location (also used to obtain a code-unit-aligned address)addr
- address for the location- Throws:
NullPointerException
- ifaddr
orprogram
is null
-
ProgramLocation
Construct a new ProgramLocation for the given address. The address will be adjusted to the beginning of thecode unit
containing that address (if it exists). The original address can be retrieved using thegetByteAddress()
method.- Parameters:
program
- the program associated with this program location (also used to obtain a code-unit-aligned address)addr
- address for the locationrow
- the row within the field.col
- the display item index on the given row. (Note most fields only have one display item per row)charOffset
- the character offset within the display item.- Throws:
NullPointerException
- ifaddr
orprogram
is null
-
ProgramLocation
Construct a new ProgramLocation for the given address. The address will be adjusted to the beginning of thecode unit
containing that address (if it exists). The original address can be retrieved using thegetByteAddress()
method.- Parameters:
program
- the program associated with this program location (also used to obtain a code-unit-aligned address)addr
- address for the locationrefAddr
- the "referred to" address if the location is over a reference- Throws:
NullPointerException
- ifaddr
orprogram
is null
-
ProgramLocation
public ProgramLocation()Default constructor required for restoring a program location from XML.
-
-
Method Details
-
getComponentPath
public int[] getComponentPath()Returns the componentPath for thecode unit
. Null will be returned if the object is anInstruction
or a top-levelData
object.- Returns:
- the path.
-
getProgram
Returns the program associated with this location.- Returns:
- the program.
-
getAddress
Returns the address associated with this location.Note: this may not be the same as the byte address. For example, in a
code unit
location this may be the minimum address of the code unit that contains the byte address.- Returns:
- the address.
-
getByteAddress
Returns the byte level address associated with this location.- Returns:
- the byte address.
-
getRefAddress
Returns the "referred to" address if the location is over an address in some field.- Returns:
- the address.
-
saveState
Save this program location to the given save state object.- Parameters:
obj
- the save state object for saving the location
-
restoreState
Restore this program location using the given program and save state object.- Parameters:
program1
- program to restore fromobj
- the save state to restore from
-
getLocation
Get the program location for the given program and save state object.- Parameters:
program
- the program for the locationsaveState
- the state to restore- Returns:
- the restored program location
-
hashCode
public int hashCode() -
toString
-
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ProgramLocation>
-
compareAddr
-
isValid
Returns true if this location represents a valid location in the given program.- Parameters:
testProgram
- the program to test if this location is valid.- Returns:
- true if this location represents a valid location in the given program.
-
getRow
public int getRow()Returns the row within the program location.- Returns:
- the row within the program location.
-
getColumn
public int getColumn()Returns the column index of the display piece represented by this location. For most locations, there is only one display item per row, in which case this value will be 0.- Returns:
- the column.
-
getCharOffset
public int getCharOffset()Returns the character offset in the display item at the (row,col).- Returns:
- the character offset in the display item at the (row,col).
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
getTranslatedCopy
public static ProgramLocation getTranslatedCopy(ProgramLocation loc, Program program, Address translatedAddress) Create a new translated copy of the specifiedProgramLocation
using the specifiedprogram
- Parameters:
loc
- original program locationprogram
- updated programtranslatedAddress
- original loc address translated for using within specified program- Returns:
- translated program location
-