Package ghidra.program.model.pcode

# Class UnionFacetSymbol

java.lang.Object
ghidra.program.model.pcode.HighSymbol
ghidra.program.model.pcode.UnionFacetSymbol

public class UnionFacetSymbol extends HighSymbol
A specialized HighSymbol that directs the decompiler to use a specific field of a union, when interpreting a particular PcodeOp that accesses a Varnode whose data-type involves the union. The symbol is stored as a dynamic variable annotation. The data-type must either be the union itself or a pointer to the union. The firstUseOffset and dynamic hash identify the particular PcodeOp and Varnode affected. The field number is the ordinal of the desired field (DataTypeComponent) within the union. It is currently stored by encoding it in the symbol name.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static String`
  `BASENAME`

  ### Fields inherited from class ghidra.program.model.pcode.HighSymbol

  `category, categoryIndex, dtmanage, entryList, function, ID_BASE, name, type`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `UnionFacetSymbol(long uniqueId, String nm, DataType dt, int fldNum, HighFunction func)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `buildSymbolName(int fldNum, Address addr)`
  Generate an automatic symbol name, given a field number and address
  `void`
  `encode(Encoder encoder)`
  Encode the symbol description as an element to the stream.
  `static int`
  `extractFieldNumber(String nm)`
  The actual field number is encoded in the symbol name
  `static boolean`
  `isUnionType(DataType dt)`
  Return true if the given data-type is either a union or a pointer to a union and is suitable for being the data-type of UnionFacetSymbol

  ### Methods inherited from class ghidra.program.model.pcode.HighSymbol

  `addMapEntry, decode, decodeHeader, decodeMapSym, encodeHeader, encodeMapSym, getCategoryIndex, getDataType, getFirstUseOffset, getFirstWholeMap, getHighFunction, getHighVariable, getId, getName, getNamespace, getPCAddress, getProgram, getSize, getStorage, getSymbol, isGlobal, isHiddenReturn, isIsolated, isNameLocked, isParameter, isReadOnly, isThisPointer, isTypeLocked, setCategory, setNameLock, setTypeLock`

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

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

- ## Field Details

  - ### BASENAME

    public static String BASENAME

- ## Constructor Details

  - ### UnionFacetSymbol

    public UnionFacetSymbol(long uniqueId, String nm, DataType dt, int fldNum, HighFunction func)

- ## Method Details

  - ### encode

    public void encode(Encoder encoder) throws IOException
    Description copied from class: `HighSymbol`
    Encode the symbol description as an element to the stream. This does NOT save the mappings.
    Overrides:
      `encode` in class `HighSymbol`
    Parameters:
      `encoder` - is the stream encoder
    Throws:
      `IOException` - for errors in the underlying stream

  - ### buildSymbolName

    public static String buildSymbolName(int fldNum, Address addr)
    Generate an automatic symbol name, given a field number and address
    Parameters:
      `fldNum` - is the field number
      `addr` - is the Address
    Returns:
      the name

  - ### extractFieldNumber

    public static int extractFieldNumber(String nm)
    The actual field number is encoded in the symbol name
    Parameters:
      `nm` - is the symbol name
    Returns:
      the field number or -1 if we cannot parse

  - ### isUnionType

    public static boolean isUnionType(DataType dt)
    Return true if the given data-type is either a union or a pointer to a union and is suitable for being the data-type of UnionFacetSymbol
    Parameters:
      `dt` - is the given data-type
    Returns:
      true if the data-type is a union or a pointer to a union