Package ghidra.program.model.pcode

# Class PcodeDataTypeManager

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

public class PcodeDataTypeManager extends Object
Class for marshaling DataType objects to and from the Decompiler.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `TYPE_ARRAY`
  `static final int`
  `TYPE_BOOL`
  `static final int`
  `TYPE_CODE`
  `static final int`
  `TYPE_FLOAT`
  `static final int`
  `TYPE_INT`
  `static final int`
  `TYPE_PTR`
  `static final int`
  `TYPE_PTRREL`
  `static final int`
  `TYPE_STRUCT`
  `static final int`
  `TYPE_UINT`
  `static final int`
  `TYPE_UNION`
  `static final int`
  `TYPE_UNKNOWN`
  `static final int`
  `TYPE_VOID`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PcodeDataTypeManager(Program prog, NameTransformer simplifier)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearTemporaryIds()`
  Throw out any temporary ids (from previous function decompilation) and reset the counter.
  `DataType`
  `decodeDataType(Decoder decoder)`
  Decode a data-type from the stream
  `void`
  `encodeCompositePlaceholder(Encoder encoder, DataType type)`
  Encode a Structure/Union to the stream without listing its fields
  `void`
  `encodeCoreTypes(Encoder encoder)`
  Encode the core data-types to the stream
  `void`
  `encodeType(Encoder encoder, DataType type, int size)`
  Encode information for a data-type to the stream
  `void`
  `encodeTypeRef(Encoder encoder, DataType type, int size)`
  Encode a reference to the given data-type to stream.
  `void`
  `encodeUnion(Encoder encoder, Union unionType)`
  Encode a Union data-type to the stream
  `DataType`
  `findBaseType(String nm, long id)`
  Find a base/built-in data-type with the given name and/or id.
  `static DataType`
  `findPointerRelativeInner(DataType base, int offset)`
  Get the inner data-type being referred to by an offset from a relative/shifted pointer.
  `static int`
  `getMetatype(DataType tp)`
  Get the decompiler meta-type associated with a data-type.
  `static int`
  `getMetatype(String metaString)`
  Convert an XML marshaling string to a metatype code
  `static String`
  `getMetatypeString(int meta)`
  Convert a decompiler metatype code to a string for XML marshaling
  `NameTransformer`
  `getNameTransformer()`
  `Program`
  `getProgram()`
  `void`
  `setNameTransformer(NameTransformer newTransformer)`

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

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

- ## Field Details

  - ### TYPE_VOID

    public static final int TYPE_VOID
    See Also:
      - Constant Field Values

  - ### TYPE_UNKNOWN

    public static final int TYPE_UNKNOWN
    See Also:
      - Constant Field Values

  - ### TYPE_INT

    public static final int TYPE_INT
    See Also:
      - Constant Field Values

  - ### TYPE_UINT

    public static final int TYPE_UINT
    See Also:
      - Constant Field Values

  - ### TYPE_BOOL

    public static final int TYPE_BOOL
    See Also:
      - Constant Field Values

  - ### TYPE_CODE

    public static final int TYPE_CODE
    See Also:
      - Constant Field Values

  - ### TYPE_FLOAT

    public static final int TYPE_FLOAT
    See Also:
      - Constant Field Values

  - ### TYPE_PTR

    public static final int TYPE_PTR
    See Also:
      - Constant Field Values

  - ### TYPE_PTRREL

    public static final int TYPE_PTRREL
    See Also:
      - Constant Field Values

  - ### TYPE_ARRAY

    public static final int TYPE_ARRAY
    See Also:
      - Constant Field Values

  - ### TYPE_STRUCT

    public static final int TYPE_STRUCT
    See Also:
      - Constant Field Values

  - ### TYPE_UNION

    public static final int TYPE_UNION
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### PcodeDataTypeManager

    public PcodeDataTypeManager(Program prog, NameTransformer simplifier)

- ## Method Details

  - ### getProgram

    public Program getProgram()

  - ### getNameTransformer

    public NameTransformer getNameTransformer()

  - ### setNameTransformer

    public void setNameTransformer(NameTransformer newTransformer)

  - ### findBaseType

    public DataType findBaseType(String nm, long id)
    Find a base/built-in data-type with the given name and/or id. If an id is provided and a corresponding data-type exists, this data-type is returned. Otherwise the first built-in data-type with a matching name is returned
    Parameters:
      `nm` - name of data-type
      `id` - is an optional data-type id number
    Returns:
      the data-type object or null if no matching data-type exists

  - ### decodeDataType

    public DataType decodeDataType(Decoder decoder) throws DecoderException
    Decode a data-type from the stream
    Parameters:
      `decoder` - is the stream decoder
    Returns:
      the decoded data-type object
    Throws:
      `DecoderException` - for invalid encodings

  - ### findPointerRelativeInner

    public static DataType findPointerRelativeInner(DataType base, int offset)
    Get the inner data-type being referred to by an offset from a relative/shifted pointer. Generally we expect the base of the relative pointer to be a structure and the offset refers to a (possibly nested) field. In this case, we return the data-type of the field. Otherwise return an "undefined" data-type.
    Parameters:
      `base` - is the base data-type of the relative pointer
      `offset` - is the offset into the base data-type
    Returns:
      the inner data-type

  - ### encodeUnion

    public void encodeUnion(Encoder encoder, Union unionType) throws IOException
    Encode a Union data-type to the stream
    Parameters:
      `encoder` - is the stream encoder
      `unionType` - is the Union data-type
    Throws:
      `IOException` - for errors in the underlying stream

  - ### encodeCompositePlaceholder

    public void encodeCompositePlaceholder(Encoder encoder, DataType type) throws IOException
    Encode a Structure/Union to the stream without listing its fields
    Parameters:
      `encoder` - is the stream encoder
      `type` - data type to encode
    Throws:
      `IOException` - for errors in the underlying stream

  - ### encodeTypeRef

    public void encodeTypeRef(Encoder encoder, DataType type, int size) throws IOException
    Encode a reference to the given data-type to stream. Most data-types produce a `<type>` element, fully describing the data-type. Where possible a `<typeref>` element is produced, which just encodes the name of the data-type, deferring a full description of the data-type. For certain simple or nameless data-types, a `<type>` element is emitted giving a full description.
    Parameters:
      `encoder` - is the stream encoder
      `type` - is the data-type to be converted
      `size` - is the size in bytes of the specific instance of the data-type
    Throws:
      `IOException` - for errors in the underlying stream

  - ### clearTemporaryIds

    public void clearTemporaryIds()
    Throw out any temporary ids (from previous function decompilation) and reset the counter.

  - ### encodeType

    public void encodeType(Encoder encoder, DataType type, int size) throws IOException
    Encode information for a data-type to the stream
    Parameters:
      `encoder` - is the stream encoder
      `type` - is the data-type to encode
      `size` - is the size of the data-type
    Throws:
      `IOException` - for errors in the underlying stream

  - ### encodeCoreTypes

    public void encodeCoreTypes(Encoder encoder) throws IOException
    Encode the core data-types to the stream
    Parameters:
      `encoder` - is the stream encoder
    Throws:
      `IOException` - for errors in the underlying stream

  - ### getMetatype

    public static int getMetatype(DataType tp)
    Get the decompiler meta-type associated with a data-type.
    Parameters:
      `tp` - is the data-type
    Returns:
      the meta-type

  - ### getMetatype

    public static int getMetatype(String metaString) throws XmlParseException
    Convert an XML marshaling string to a metatype code
    Parameters:
      `metaString` - is the string
    Returns:
      the metatype code
    Throws:
      `XmlParseException` - if the string does not represent a valid metatype

  - ### getMetatypeString

    public static String getMetatypeString(int meta) throws IOException
    Convert a decompiler metatype code to a string for XML marshaling
    Parameters:
      `meta` - is the metatype
    Returns:
      the marshaling string
    Throws:
      `IOException` - is the metatype is invalid