Package ghidra.program.model.listing

# Class VariableOffset

java.lang.Object
ghidra.program.model.listing.VariableOffset

public class VariableOffset extends Object
`VariableOffset` can be used as an operand or sub-operand representation object. The toString() method should be used to obtain the displayable representation string. This object is intended to correspond to a explicit or implicit register/stack variable reference. If an offset other than 0 is specified, the original Scalar should be specified.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VariableOffset(Variable var, long offset, boolean indirect, boolean dataAccess)`
  Constructor for an implied variable reference.
  `VariableOffset(Reference ref, Variable var)`
  Constructor for an explicit variable reference.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String`
  `getDataTypeDisplayText()`
  Returns the data type access portion of this variable offset as a string
  `List<Object>`
  `getObjects()`
  Get list of markup objects
  `long`
  `getOffset()`
  `Object`
  `getReplacedElement()`
  Returns the Scalar or Register sub-operand replaced by this VariableOffset object.
  `Variable`
  `getVariable()`
  `int`
  `hashCode()`
  `boolean`
  `isDataAccess()`
  `boolean`
  `isIndirect()`
  `void`
  `setReplacedElement(Register reg)`
  Sets the original replaced sub-operand Register.
  `void`
  `setReplacedElement(Scalar s, boolean includeScalarAdjustment)`
  Sets the original replaced sub-operand Scalar.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### VariableOffset

    public VariableOffset(Variable var, long offset, boolean indirect, boolean dataAccess)
    Constructor for an implied variable reference.
    Parameters:
      `var` - function variable
      `offset` - offset into variable
      `indirect` - if true and variable data-type is a pointer, the offset is relative to underlying data-type of the pointer-type. This should generally be true for register use which would contain a structure pointer not a structure instance, whereas it would be false for stack-references.
      `dataAccess` - true if content of variable is being read and/or written

  - ### VariableOffset

    public VariableOffset(Reference ref, Variable var)
    Constructor for an explicit variable reference.
    Parameters:
      `ref` - the reference
      `var` - the variable being referenced

- ## Method Details

  - ### setReplacedElement

    public void setReplacedElement(Scalar s, boolean includeScalarAdjustment)
    Sets the original replaced sub-operand Scalar.
    Parameters:
      `s` - scalar
      `includeScalarAdjustment` - if true scalar adjustment will be included with object list or string representation

  - ### setReplacedElement

    public void setReplacedElement(Register reg)
    Sets the original replaced sub-operand Register.
    Parameters:
      `reg` - the register

  - ### getReplacedElement

    public Object getReplacedElement()
    Returns the Scalar or Register sub-operand replaced by this VariableOffset object.
    Returns:
      object or null

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getDataTypeDisplayText

    public String getDataTypeDisplayText()
    Returns the data type access portion of this variable offset as a string
    Returns:
      the text

  - ### getObjects

    public List<Object> getObjects()
    Get list of markup objects
    Returns:
      list of markup objects

  - ### getVariable

    public Variable getVariable()

  - ### isIndirect

    public boolean isIndirect()

  - ### isDataAccess

    public boolean isDataAccess()

  - ### getOffset

    public long getOffset()

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`