Package ghidra.program.util
Class OperandFieldLocation
- java.lang.Object
-
- ghidra.program.util.ProgramLocation
-
- ghidra.program.util.CodeUnitLocation
-
- ghidra.program.util.OperandFieldLocation
-
- All Implemented Interfaces:
java.lang.Comparable<ProgramLocation>
- Direct Known Subclasses:
ArrayElementFieldLocation
,EquateOperandFieldLocation
,ResourceFieldLocation
public class OperandFieldLocation extends CodeUnitLocation
TheOperandFieldLocation
class contains specific location information within the OPERAND field of a CodeUnitLocation object.
-
-
Field Summary
-
Fields inherited from class ghidra.program.util.ProgramLocation
addr, program, refAddr
-
-
Constructor Summary
Constructors Constructor Description OperandFieldLocation()
Default constructor needed for restoring an operand field location from XML.OperandFieldLocation(Program program, Address addr, int[] componentPath, Address refAddr, java.lang.String rep, int opIndex, int characterOffset)
Construct a new OperandFieldLocation object.OperandFieldLocation(Program program, Address addr, int[] componentPath, Address refAddr, java.lang.String rep, int opIndex, int subOpIndex, int characterOffset)
Construct a new OperandFieldLocation object.OperandFieldLocation(Program program, Address addr, VariableOffset variableOffset, Address refAddr, java.lang.String rep, int opIndex, int subOpIndex, int characterOffset)
Construct a new OperandFieldLocation object for an instruction operand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
getOperandIndex()
Returns the index of the operand at this location.java.lang.String
getOperandRepresentation()
Returns a string representation of the opernand at this location.int
getSubOperandIndex()
Returns the sub operand index at this location.VariableOffset
getVariableOffset()
Returns VariableOffset object if applicable or nullint
hashCode()
void
restoreState(Program p, SaveState obj)
Restore this program location using the given program and save state object.void
saveState(SaveState obj)
Save this program location to the given save state object.java.lang.String
toString()
Returns a String representation of this location.-
Methods inherited from class ghidra.program.util.CodeUnitLocation
isValid
-
Methods inherited from class ghidra.program.util.ProgramLocation
compareAddr, compareTo, getAddress, getByteAddress, getCharOffset, getColumn, getComponentPath, getLocation, getProgram, getRefAddress, getRow
-
-
-
-
Constructor Detail
-
OperandFieldLocation
public OperandFieldLocation(Program program, Address addr, int[] componentPath, Address refAddr, java.lang.String rep, int opIndex, int characterOffset)
Construct a new OperandFieldLocation object.- Parameters:
program
- the program of the locationaddr
- address of the location; should not be nullcomponentPath
- array of indexes for each nested data component; the index is the data component's index within its parent; may be nullrep
- the String representation of the operand.opIndex
- the index of the operand at this location.characterOffset
- the character position from the beginning of the operand.
-
OperandFieldLocation
public OperandFieldLocation(Program program, Address addr, int[] componentPath, Address refAddr, java.lang.String rep, int opIndex, int subOpIndex, int characterOffset)
Construct a new OperandFieldLocation object.- Parameters:
program
- the program of the locationaddr
- address of the location; should not 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 nullrep
- the String representation of the operand.opIndex
- the index indicating the operand the location is on.subOpIndex
- the index of the Object within the operand, this can be used to call an instructions getOpObjects() methodcharacterOffset
- the character position from the beginning of the operand field
-
OperandFieldLocation
public OperandFieldLocation(Program program, Address addr, VariableOffset variableOffset, Address refAddr, java.lang.String rep, int opIndex, int subOpIndex, int characterOffset)
Construct a new OperandFieldLocation object for an instruction operand.- Parameters:
program
- the program of the locationaddr
- address of the location; should not be nullvariableOffset
- associated variable offset or nullrefAddr
- the "referred to" address if the location is over a reference; may be nullrep
- the String representation of the operand.opIndex
- the index indicating the operand the location is on.subOpIndex
- the index of the Object within the operand, this can be used to call an instructions getOpObjects() methodcharacterOffset
- the character position from the beginning of the operand field
-
OperandFieldLocation
public OperandFieldLocation()
Default constructor needed for restoring an operand field location from XML.
-
-
Method Detail
-
getVariableOffset
public VariableOffset getVariableOffset()
Returns VariableOffset object if applicable or null
-
getOperandRepresentation
public java.lang.String getOperandRepresentation()
Returns a string representation of the opernand at this location.
-
getOperandIndex
public int getOperandIndex()
Returns the index of the operand at this location.
-
getSubOperandIndex
public int getSubOperandIndex()
Returns the sub operand index at this location. This index can be used on the instruction.getOpObjects() to find the actual object (Address, Register, Scalar) the cursor is over.- Returns:
- 0-n if over a valid OpObject, -1 otherwise
-
toString
public java.lang.String toString()
Returns a String representation of this location.- Overrides:
toString
in classProgramLocation
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classProgramLocation
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classProgramLocation
-
restoreState
public void restoreState(Program p, SaveState obj)
Description copied from class:ProgramLocation
Restore this program location using the given program and save state object.- Overrides:
restoreState
in classProgramLocation
- Parameters:
p
- program to restore fromobj
- the save state to restore from
-
saveState
public void saveState(SaveState obj)
Description copied from class:ProgramLocation
Save this program location to the given save state object.- Overrides:
saveState
in classProgramLocation
- Parameters:
obj
- the save state object for saving the location
-
-