Package ghidra.program.model.data
Class DataTypeInstance
java.lang.Object
ghidra.program.model.data.DataTypeInstance
An instance of a DataType that is applicable for a given context. Most
dataTypes are not context sensitive and are suitable for use anywhere.
Others like dynamic structures need to create an instance that wraps the
data type.
It helps for situations where a data type must have a length.
-
Constructor Summary
ModifierConstructorDescriptionprotected
DataTypeInstance
(DataType dt, int length) Create an instance of a data type with the given length. -
Method Summary
Modifier and TypeMethodDescriptionstatic DataTypeInstance
getDataTypeInstance
(DataType dataType, int length, boolean useAlignedLength) Attempt to create a fixed-length data-type instance.static DataTypeInstance
getDataTypeInstance
(DataType dataType, MemBuffer buf, boolean useAlignedLength) Generate a data-type instance Factory and Dynamic data-types are NOT handled.static DataTypeInstance
getDataTypeInstance
(DataType dataType, MemBuffer buf, int length, boolean useAlignedLength) Attempt to create a data-type instance associated with a specific memory location.int
void
setLength
(int length) Set the length of this data type instancetoString()
-
Constructor Details
-
DataTypeInstance
Create an instance of a data type with the given length.
NOTE: fixed-length primitive datatypes assumeraw datatype length
intended forData
use.- Parameters:
dt
- data typelength
- fixed length of the data type
-
-
Method Details
-
getDataType
- Returns:
- the data type
-
getLength
public int getLength()- Returns:
- the fixed length of the data type
-
setLength
public void setLength(int length) Set the length of this data type instance -
toString
-
getDataTypeInstance
public static DataTypeInstance getDataTypeInstance(DataType dataType, MemBuffer buf, boolean useAlignedLength) Generate a data-type instance Factory and Dynamic data-types are NOT handled.
This container does not dictate the placement of a fixed-length type within this container. It is suggested that big-endian use should evaulate the datatype at the far end of the container.- Parameters:
dataType
- data typebuf
- memory bufferuseAlignedLength
- if true a fixed-length primitive data type will use itsaligned-length
, otherwise it will use itsraw length
. NOTE: This generally only relates to float datatypes whose raw encoding length may be shorter than their aligned-length generally corresponding to a compiler's "sizeof(type)" value. This should generally be true forDataTypeComponent
and false for simpleData
instances.- Returns:
- data-type instance or null if one could not be determined
-
getDataTypeInstance
public static DataTypeInstance getDataTypeInstance(DataType dataType, int length, boolean useAlignedLength) Attempt to create a fixed-length data-type instance. Factory and non-sizable Dynamic data-types are NOT handled.
This container does not dictate the placement of a fixed-length type within this container. It is suggested that big-endian use should evaulate the datatype at the far end of the container.- Parameters:
dataType
- data typelength
- length for sizable Dynamic data-types, otherwise ignoreduseAlignedLength
- if true a fixed-length primitive data type will use itsaligned-length
, otherwise it will use itsraw length
. NOTE: This generally only relates to float datatypes whose raw encoding length may be shorter than their aligned-length generally corresponding to a compiler's "sizeof(type)" value. This should generally be true forDataTypeComponent
and false for simpleData
instances.- Returns:
- data-type instance or null if unable to create instance.
-
getDataTypeInstance
public static DataTypeInstance getDataTypeInstance(DataType dataType, MemBuffer buf, int length, boolean useAlignedLength) Attempt to create a data-type instance associated with a specific memory location. Factory and Dynamic data-types are handled.
This container does not dictate the placement of a fixed-length type within this container. It is suggested that big-endian use should evaulate the datatype at the far end of the container.- Parameters:
dataType
- the data typebuf
- memory locationlength
- length for sizable Dynamic data-types, otherwise ignoreduseAlignedLength
- if true a fixed-length primitive data type will use itsaligned-length
, otherwise it will use itsraw length
. NOTE: This generally only relates to float datatypes whose raw encoding length may be shorter than their aligned-length generally corresponding to a compiler's "sizeof(type)" value. This should generally be true forDataTypeComponent
and false for simpleData
instances.- Returns:
- data-type instance or null if unable to create instance.
-