Package ghidra.program.model.pcode
Class PcodeDataTypeManager
java.lang.Object
ghidra.program.model.pcode.PcodeDataTypeManager
Class for marshaling DataType objects to and from the Decompiler.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Throw out any temporary ids (from previous function decompilation) and reset the counter.decodeDataType
(Decoder decoder) Decode a data-type from the streamvoid
encodeCompositeZeroSizePlaceholder
(Encoder encoder, DataType type) Encode a Structure to the stream that has its size reported as zero.void
encodeCoreTypes
(Encoder encoder) Encode the core data-types to the streamvoid
encodeType
(Encoder encoder, DataType type, int size) Encode information for a data-type to the streamvoid
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 streamfindBaseType
(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 codestatic String
getMetatypeString
(int meta) Convert a decompiler metatype code to a string for XML marshalingvoid
setNameTransformer
(NameTransformer newTransformer)
-
Field Details
-
TYPE_VOID
public static final int TYPE_VOID- See Also:
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN- See Also:
-
TYPE_INT
public static final int TYPE_INT- See Also:
-
TYPE_UINT
public static final int TYPE_UINT- See Also:
-
TYPE_BOOL
public static final int TYPE_BOOL- See Also:
-
TYPE_CODE
public static final int TYPE_CODE- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOAT- See Also:
-
TYPE_PTR
public static final int TYPE_PTR- See Also:
-
TYPE_PTRREL
public static final int TYPE_PTRREL- See Also:
-
TYPE_ARRAY
public static final int TYPE_ARRAY- See Also:
-
TYPE_STRUCT
public static final int TYPE_STRUCT- See Also:
-
TYPE_UNION
public static final int TYPE_UNION- See Also:
-
-
Constructor Details
-
PcodeDataTypeManager
-
-
Method Details
-
getProgram
-
getNameTransformer
-
setNameTransformer
-
findBaseType
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-typeid
- is an optional data-type id number- Returns:
- the data-type object or null if no matching data-type exists
-
decodeDataType
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
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 pointeroffset
- is the offset into the base data-type- Returns:
- the inner data-type
-
encodeUnion
Encode a Union data-type to the stream- Parameters:
encoder
- is the stream encoderunionType
- is the Union data-type- Throws:
IOException
- for errors in the underlying stream
-
encodeCompositeZeroSizePlaceholder
Encode a Structure to the stream that has its size reported as zero.- Parameters:
encoder
- is the stream encodertype
- data type to encode- Throws:
IOException
- for errors in the underlying stream
-
encodeTypeRef
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 encodertype
- is the data-type to be convertedsize
- 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
Encode information for a data-type to the stream- Parameters:
encoder
- is the stream encodertype
- is the data-type to encodesize
- is the size of the data-type- Throws:
IOException
- for errors in the underlying stream
-
encodeCoreTypes
Encode the core data-types to the stream- Parameters:
encoder
- is the stream encoder- Throws:
IOException
- for errors in the underlying stream
-
getMetatype
Get the decompiler meta-type associated with a data-type.- Parameters:
tp
- is the data-type- Returns:
- the meta-type
-
getMetatype
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
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
-