Package ghidra.program.model.pcode

# Class LocalSymbolMap

java.lang.Object
ghidra.program.model.pcode.LocalSymbolMap

public class LocalSymbolMap extends Object
A container for local symbols within the decompiler's model of a function. It contains HighSymbol objects for any symbol within the scope of the function, including parameters. The container is populated either from the underlying Function object (when sending information to the decompiler) or read in from an XML description (when receiving a function model from the decompiler). HighSymbols can be obtained via Address using findLocal() or by id using getSymbol(). Parameters can be accessed specifically using getParamSymbol().

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LocalSymbolMap(HighFunction highFunc, AddressSpace spc)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `decodeScope(Decoder decoder)`
  Decode a local symbol scope from the stream
  `void`
  `decodeSymbolList(Decoder decoder)`
  Add mapped symbols to this LocalVariableMap, by decoding the <symbollist> and <mapsym> elements
  `void`
  `encodeLocalDb(Encoder encoder, Namespace namespace, NameTransformer transformer)`
  Encode all the variables in this local variable map to the stream
  `HighSymbol`
  `findLocal(Address addr, Address pc)`
  Find any local variable (including input params) by address
  `HighSymbol`
  `findLocal(VariableStorage store, Address pc)`
  Find any local variable (including input params) by address
  `HighFunction`
  `getHighFunction()`
  Get the decompiler's function model owning this container
  `Map<String,HighSymbol>`
  `getNameToSymbolMap()`
  Construct and return a map from a HighSymbol's name to the HighSymbol object
  `int`
  `getNumParams()`
  Get the number of parameter symbols in this scope
  `HighParam`
  `getParam(int i)`
  `HighSymbol`
  `getParamSymbol(int i)`
  `HighSymbol`
  `getSymbol(long id)`
  Lookup high variable based upon its symbol-id
  `Iterator<HighSymbol>`
  `getSymbols()`
  Get all the symbols mapped for this program, Param, Locals.
  `void`
  `grabFromFunction(boolean includeDefaultNames)`
  Populate the local variable map from information attached to the Program DB's function.
  `protected HighSymbol`
  `newDynamicSymbol(long id, String nm, DataType dt, long hash, Address pcaddr)`
  `protected HighSymbol`
  `newMappedSymbol(long id, String nm, DataType dt, VariableStorage store, Address pcaddr, int slot)`

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

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LocalSymbolMap

    public LocalSymbolMap(HighFunction highFunc, AddressSpace spc)
    Parameters:
      `highFunc` - HighFunction the local variables are defined within.
      `spc` - the address space the local variables are defined within.

- ## Method Details

  - ### getHighFunction

    public HighFunction getHighFunction()
    Get the decompiler's function model owning this container
    Returns:
      the owning HighFunction

  - ### getNameToSymbolMap

    public Map<String,HighSymbol> getNameToSymbolMap()
    Construct and return a map from a HighSymbol's name to the HighSymbol object
    Returns:
      the new name to symbol map

  - ### grabFromFunction

    public void grabFromFunction(boolean includeDefaultNames)
    Populate the local variable map from information attached to the Program DB's function.
    Parameters:
      `includeDefaultNames` - is true if default symbol names should be considered locked

  - ### decodeScope

    public void decodeScope(Decoder decoder) throws DecoderException
    Decode a local symbol scope from the stream
    Parameters:
      `decoder` - is the stream decoder
    Throws:
      `DecoderException` - for invalid encodings

  - ### decodeSymbolList

    public void decodeSymbolList(Decoder decoder) throws DecoderException
    Add mapped symbols to this LocalVariableMap, by decoding the <symbollist> and <mapsym> elements
    Parameters:
      `decoder` - is the stream decoder
    Throws:
      `DecoderException` - for invalid encodings

  - ### encodeLocalDb

    public void encodeLocalDb(Encoder encoder, Namespace namespace, NameTransformer transformer) throws IOException
    Encode all the variables in this local variable map to the stream
    Parameters:
      `encoder` - is the stream encoder
      `namespace` - if the namespace of the function
      `transformer` - is used to compute a simplified version of the namespace name
    Throws:
      `IOException` - for errors in the underlying stream

  - ### getSymbols

    public Iterator<HighSymbol> getSymbols()
    Get all the symbols mapped for this program, Param, Locals. The HighSymbol can either be a HighParam, or HighLocal
    Returns:
      an iterator over all mapped symbols.

  - ### findLocal

    public HighSymbol findLocal(VariableStorage store, Address pc)
    Find any local variable (including input params) by address
    Parameters:
      `store` - - variable storage
      `pc` - = Address of first use, or null if address is valid throughout the entire scope
    Returns:
      HighLocal or null

  - ### findLocal

    public HighSymbol findLocal(Address addr, Address pc)
    Find any local variable (including input params) by address
    Parameters:
      `addr` - - variable storage address
      `pc` - = Address of first use, or null if address is valid throughout the entire scope
    Returns:
      HighLocal or null

  - ### getSymbol

    public HighSymbol getSymbol(long id)
    Lookup high variable based upon its symbol-id
    Parameters:
      `id` - symbol-id
    Returns:
      variable or null if not found

  - ### getNumParams

    public int getNumParams()
    Get the number of parameter symbols in this scope
    Returns:
      the number of parameters

  - ### getParamSymbol

    public HighSymbol getParamSymbol(int i)
    Parameters:
      `i` - is the desired parameter position
    Returns:
      the i-th parameter HighSymbol

  - ### getParam

    public HighParam getParam(int i)
    Parameters:
      `i` - is the desired parameter position
    Returns:
      the i-th parameter variable

  - ### newMappedSymbol

    protected HighSymbol newMappedSymbol(long id, String nm, DataType dt, VariableStorage store, Address pcaddr, int slot)

  - ### newDynamicSymbol

    protected HighSymbol newDynamicSymbol(long id, String nm, DataType dt, long hash, Address pcaddr)