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 Details

  • Constructor Details

  • 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
    • encodeCompositeZeroSizePlaceholder

      public void encodeCompositeZeroSizePlaceholder(Encoder encoder, DataType type) throws IOException
      Encode a Structure to the stream that has its size reported as zero.
      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