Package ghidra.program.util
Class OperandFieldLocation
java.lang.Object
ghidra.program.util.ProgramLocation
ghidra.program.util.CodeUnitLocation
ghidra.program.util.OperandFieldLocation
- All Implemented Interfaces:
Cloneable
,Comparable<ProgramLocation>
- Direct Known Subclasses:
ArrayElementFieldLocation
,EquateOperandFieldLocation
,ResourceFieldLocation
The
OperandFieldLocation
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
ConstructorDescriptionDefault constructor needed for restoring an operand field location from XML.OperandFieldLocation
(Program program, Address addr, int[] componentPath, Address refAddr, String rep, int opIndex, int characterOffset) Construct a new OperandFieldLocation object.OperandFieldLocation
(Program program, Address addr, int[] componentPath, Address refAddr, String rep, int opIndex, int subOpIndex, int characterOffset) Construct a new OperandFieldLocation object.OperandFieldLocation
(Program program, Address addr, VariableOffset variableOffset, Address refAddr, String rep, int opIndex, int subOpIndex, int characterOffset) Construct a new OperandFieldLocation object for an instruction operand. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Returns the index of the operand at this location.Returns a string representation of the operand at this location.int
Returns the sub operand index at this location.Returns VariableOffset object if applicable or null.int
hashCode()
void
restoreState
(Program p, 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()
Methods inherited from class ghidra.program.util.CodeUnitLocation
isValid
Methods inherited from class ghidra.program.util.ProgramLocation
clone, compareAddr, compareTo, getAddress, getByteAddress, getCharOffset, getColumn, getComponentPath, getLocation, getProgram, getRefAddress, getRow, getTranslatedCopy
-
Constructor Details
-
OperandFieldLocation
public OperandFieldLocation(Program program, Address addr, int[] componentPath, Address refAddr, String rep, int opIndex, int characterOffset) Construct a new OperandFieldLocation object.- Parameters:
program
- the program of the location.addr
- address of the location; should not be null.componentPath
- array of indexes for each nested data component; the index is the data component's index within its parent; may be null.refAddr
- the reference 'to' address.rep
- 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, String rep, int opIndex, int subOpIndex, int characterOffset) Construct a new OperandFieldLocation object.- Parameters:
program
- the program of the location.addr
- address of the location; should not be null.componentPath
- array of indexes for each nested data component; the index is the data component's index within its parent; may be null .refAddr
- the "referred to" address if the location is over a reference; may be null.rep
- 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() method.characterOffset
- the character position from the beginning of the operand field.
-
OperandFieldLocation
public OperandFieldLocation(Program program, Address addr, VariableOffset variableOffset, Address refAddr, String rep, int opIndex, int subOpIndex, int characterOffset) Construct a new OperandFieldLocation object for an instruction operand.- Parameters:
program
- the program of the location.addr
- address of the location; should not be null.variableOffset
- associated variable offset or null.refAddr
- the "referred to" address if the location is over a reference; may be null.rep
- 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() method.characterOffset
- 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 Details
-
getVariableOffset
Returns VariableOffset object if applicable or null.- Returns:
- the variable offset.
-
getOperandRepresentation
Returns a string representation of the operand at this location.- Returns:
- the representation.
-
getOperandIndex
public int getOperandIndex()Returns the index of the operand at this location.- Returns:
- the index
-
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
- Overrides:
toString
in classProgramLocation
-
hashCode
public int hashCode()- Overrides:
hashCode
in classProgramLocation
-
equals
- Overrides:
equals
in classProgramLocation
-
restoreState
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
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
-