Class AbstractDataType
- All Implemented Interfaces:
DataType
- Direct Known Subclasses:
BitFieldDataType,DataTypeImpl,PartialUnion
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CategoryPathprotected final DataTypeManagerprotected StringFields inherited from interface ghidra.program.model.data.DataType
CONFLICT_SUFFIX, DEFAULT, NO_LAST_CHANGE_TIME, NO_SOURCE_SYNC_TIME, TYPEDEF_ATTRIBUTE_PREFIX, TYPEDEF_ATTRIBUTE_SUFFIX, VOID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDataType(CategoryPath path, String name, DataTypeManager dataTypeManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidInform this data type that it has the given parent
TODO: This method is reserved for internal DB use.voidNotification that the given datatype's alignment has changed.voidInforms this datatype that the given datatype has been deleted.voiddataTypeNameChanged(DataType dt, String oldName) Informs this datatype that its name has changed from the indicated old name.voiddataTypeReplaced(DataType oldDt, DataType newDt) Informs this datatype that the given oldDT has been replaced with newDTvoidNotification that the given datatype's size has changed.booleanCheck if this datatype depends on the existence of the given datatype.byte[]encodeRepresentation(String repr, MemBuffer buf, Settings settings, int length) Encode bytes according to the display format for this type.byte[]encodeValue(Object value, MemBuffer buf, Settings settings, int length) Encode bytes from an Object appropriate for this DataType.Gets the categoryPath associated with this datatypefinal DataOrganizationReturns the DataOrganization associated with this data-typeprotected static DataOrganizationgetDataOrganization(DataTypeManager dataMgr) Get theDataOrganizationwhich should be used by aAbstractDataTypewhen associated with a specifieddataMgr.final DataTypeManagerGet the DataTypeManager containing this datatype.Returns the dataTypePath for this datatype;Returns the prefix to use for this datatype when an abbreviated prefix is desired.Returns the appropriate string to use as the default label prefix in the absence of any data.getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options) Returns the appropriate string to use as the default label prefix.getDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutLength) Returns the appropriate string to use as the default label prefix.Gets the name for referring to this datatype.longGet the timestamp corresponding to the last time this type was changed within its datatype managerlongGet the timestamp corresponding to the last time this type was sync'd within its source archivegetMnemonic(Settings settings) Get the mnemonic for this DataType.getName()Get the name of this datatype.Get the parents of this datatype.Get the full category path name that includes this datatype's name.Get the source archive where this type originatedGet the list of all settings definitions for this datatype that may be used for an associatedTypeDef.Get the universal ID for this datatype.booleanIndicates if the length of this data-type is determined based upon theDataOrganizationobtained from the associatedDataTypeManager.booleanReturns true if this datatype has been deleted and is no longer validbooleanCheck if this type supports encoding (patching)booleanIndicates if this datatype has not yet been fully defined.booleanIndicates this datatype is defined with a zero length.voidremoveParent(DataType dt) Remove a parent datatypevoidreplaceWith(DataType dataType) For datatypes that support change, this method replaces the internals of this datatype with the internals of the given datatype.voidsetCategoryPath(CategoryPath path) Set the categoryPath associated with this datatypevoidsetDescription(String description) Sets a String briefly describing this DataType.voidsetLastChangeTime(long lastChangeTime) Sets the lastChangeTime for this datatype.voidsetLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive) Sets the lastChangeTimeInSourceArchive for this datatype.voidSets the name of the datatypevoidsetNameAndCategory(CategoryPath path, String name) Sets the name and category of a datatype at the same time.voidsetSourceArchive(SourceArchive archive) Set the source archive where this type originatedtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.data.DataType
clone, copy, getAlignedLength, getAlignment, getDefaultSettings, getDescription, getLength, getRepresentation, getSettingsDefinitions, getValue, getValueClass, isEquivalent
-
Field Details
-
name
-
categoryPath
-
dataMgr
-
-
Constructor Details
-
AbstractDataType
-
-
Method Details
-
getTypeDefSettingsDefinitions
Description copied from interface:DataTypeGet the list of all settings definitions for this datatype that may be used for an associatedTypeDef. When used for an associatedTypeDef, these settings will be considered during aDataType.isEquivalent(DataType)check and will be preserved during the resolve process.- Specified by:
getTypeDefSettingsDefinitionsin interfaceDataType- Returns:
- a list of the settings definitions for a
TypeDefassociated with this datatype.
-
getCategoryPath
Description copied from interface:DataTypeGets the categoryPath associated with this datatype- Specified by:
getCategoryPathin interfaceDataType- Returns:
- the datatype's category path
-
getDataTypeManager
Description copied from interface:DataTypeGet the DataTypeManager containing this datatype.This association should not be used to indicate whether this DataType has been resolved, but is intended to indicate whether the appropriate DataOrganization is being used.
- Specified by:
getDataTypeManagerin interfaceDataType- Returns:
- the DataTypeManager that is associated with this datatype.
- See Also:
-
getDataOrganization
Description copied from interface:DataTypeReturns the DataOrganization associated with this data-type- Specified by:
getDataOrganizationin interfaceDataType- Returns:
- associated data organization
-
getDataOrganization
Get theDataOrganizationwhich should be used by aAbstractDataTypewhen associated with a specifieddataMgr. If a nulldataMgris specified the defaultDataOrganizationwill be returned.- Parameters:
dataMgr- datatype manager- Returns:
- the
DataOrganizationwhich should be used by aAbstractDataTypeinstance.
-
getDataTypePath
Description copied from interface:DataTypeReturns the dataTypePath for this datatype;- Specified by:
getDataTypePathin interfaceDataType- Returns:
- the dataTypePath for this datatype;
-
getName
Description copied from interface:DataTypeGet the name of this datatype. -
getPathName
Description copied from interface:DataTypeGet the full category path name that includes this datatype's name.If the category is null, then this just the datatype's name is returned.
- Specified by:
getPathNamein interfaceDataType- Returns:
- the path, or just this type's name
-
getDisplayName
Description copied from interface:DataTypeGets the name for referring to this datatype.- Specified by:
getDisplayNamein interfaceDataType- Returns:
- generic name for this Data Type (i.e.: Word)
-
getMnemonic
Description copied from interface:DataTypeGet the mnemonic for this DataType.- Specified by:
getMnemonicin interfaceDataType- Parameters:
settings- settings which may influence the result or null- Returns:
- the mnemonic for this DataType.
-
isNotYetDefined
public boolean isNotYetDefined()Description copied from interface:DataTypeIndicates if this datatype has not yet been fully defined.Such datatypes should always return a
DataType.getLength()of 1 and true forDataType.isZeroLength(). (example: empty structure)- Specified by:
isNotYetDefinedin interfaceDataType- Returns:
- true if this type is not yet defined.
-
isZeroLength
public boolean isZeroLength()Description copied from interface:DataTypeIndicates this datatype is defined with a zero length.This method should not be confused with
DataType.isNotYetDefined()which indicates that nothing but the name and basic type is known.NOTE: a zero-length datatype must return a length of 1 via
DataType.getLength(). Zero-length datatypes used as a component within aCompositemay, or may not, be assigned a component length of 0. The methodDataTypeComponent.usesZeroLengthComponent(DataType)is used to make this determination.- Specified by:
isZeroLengthin interfaceDataType- Returns:
- true if type definition has a length of 0, else false
-
toString
-
isDeleted
public boolean isDeleted()Description copied from interface:DataTypeReturns true if this datatype has been deleted and is no longer valid -
setName
Description copied from interface:DataTypeSets the name of the datatype- Specified by:
setNamein interfaceDataType- Parameters:
name- the new name for this datatype.- Throws:
InvalidNameException- if the given name does not form a valid name.
-
setNameAndCategory
public void setNameAndCategory(CategoryPath path, String name) throws InvalidNameException, DuplicateNameException Description copied from interface:DataTypeSets the name and category of a datatype at the same time.- Specified by:
setNameAndCategoryin interfaceDataType- Parameters:
path- the new category path.name- the new name- Throws:
InvalidNameException- if the name is invalidDuplicateNameException- if name change on storedDataTypeis a duplicate of another datatype within the same category (only applies to DB storedDataType).
-
dataTypeSizeChanged
Description copied from interface:DataTypeNotification that the given datatype's size has changed.DataTypes may need to make internal changes in response.
TODO: This method is reserved for internal DB use.- Specified by:
dataTypeSizeChangedin interfaceDataType- Parameters:
dt- the datatype that has changed.
-
dataTypeAlignmentChanged
Description copied from interface:DataTypeNotification that the given datatype's alignment has changed.DataTypes may need to make internal changes in response.
TODO: This method is reserved for internal DB use.- Specified by:
dataTypeAlignmentChangedin interfaceDataType- Parameters:
dt- the datatype that has changed.
-
dataTypeDeleted
Description copied from interface:DataTypeInforms this datatype that the given datatype has been deleted.TODO: This method is reserved for internal DB use.
- Specified by:
dataTypeDeletedin interfaceDataType- Parameters:
dt- the datatype that has been deleted.
-
dataTypeReplaced
Description copied from interface:DataTypeInforms this datatype that the given oldDT has been replaced with newDTTODO: This method is reserved for internal DB use.
- Specified by:
dataTypeReplacedin interfaceDataType- Parameters:
oldDt- old datatypenewDt- new datatype
-
addParent
Description copied from interface:DataTypeInform this data type that it has the given parent
TODO: This method is reserved for internal DB use. -
removeParent
Description copied from interface:DataTypeRemove a parent datatypeTODO: This method is reserved for internal DB use.
- Specified by:
removeParentin interfaceDataType- Parameters:
dt- parent datatype
-
getParents
Description copied from interface:DataTypeGet the parents of this datatype. NOTE: This method is intended to be used on a DB-managed datatype only and is not fully supported for use with non-DB datatype instances.- Specified by:
getParentsin interfaceDataType- Returns:
- parents of this datatype
-
dependsOn
Description copied from interface:DataTypeCheck if this datatype depends on the existence of the given datatype.For example byte[] depends on byte. If byte were deleted, then byte[] would also be deleted.
-
getSourceArchive
Description copied from interface:DataTypeGet the source archive where this type originated- Specified by:
getSourceArchivein interfaceDataType- Returns:
- source archive object
-
setSourceArchive
Description copied from interface:DataTypeSet the source archive where this type originated- Specified by:
setSourceArchivein interfaceDataType- Parameters:
archive- source archive object
-
getLastChangeTime
public long getLastChangeTime()Description copied from interface:DataTypeGet the timestamp corresponding to the last time this type was changed within its datatype manager- Specified by:
getLastChangeTimein interfaceDataType- Returns:
- timestamp of last change within datatype manager
-
getLastChangeTimeInSourceArchive
public long getLastChangeTimeInSourceArchive()Description copied from interface:DataTypeGet the timestamp corresponding to the last time this type was sync'd within its source archive- Specified by:
getLastChangeTimeInSourceArchivein interfaceDataType- Returns:
- timestamp of last sync with source archive
-
getUniversalID
Description copied from interface:DataTypeGet the universal ID for this datatype.This value is intended to be a unique identifier across all programs and archives. The same ID indicates that two datatypes were originally the same one. Keep in mind names, categories, and component makeup may differ and have changed since there origin.
- Specified by:
getUniversalIDin interfaceDataType- Returns:
- datatype UniversalID
-
dataTypeNameChanged
Description copied from interface:DataTypeInforms this datatype that its name has changed from the indicated old name.TODO: This method is reserved for internal DB use.
- Specified by:
dataTypeNameChangedin interfaceDataType- Parameters:
dt- the datatype whose name changedoldName- the datatype's old name
-
replaceWith
Description copied from interface:DataTypeFor datatypes that support change, this method replaces the internals of this datatype with the internals of the given datatype.The datatypes must be of the same "type" (i.e. structure can only be replacedWith another structure.
- Specified by:
replaceWithin interfaceDataType- Parameters:
dataType- the datatype that contains the internals to upgrade to.
-
setLastChangeTime
public void setLastChangeTime(long lastChangeTime) Description copied from interface:DataTypeSets the lastChangeTime for this datatype.Normally, this is updated automatically when a datatype is changed, but when committing or updating while synchronizing an archive, the lastChangeTime may need to be updated externally.
- Specified by:
setLastChangeTimein interfaceDataType- Parameters:
lastChangeTime- the time to use as the lastChangeTime for this datatype
-
setLastChangeTimeInSourceArchive
public void setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive) Description copied from interface:DataTypeSets the lastChangeTimeInSourceArchive for this datatype.This is used by when a datatype change is committed back to its source archive.
- Specified by:
setLastChangeTimeInSourceArchivein interfaceDataType- Parameters:
lastChangeTimeInSourceArchive- the time to use as the lastChangeTimeInSourceArchive for this datatype
-
setDescription
Description copied from interface:DataTypeSets a String briefly describing this DataType.- Specified by:
setDescriptionin interfaceDataType- Parameters:
description- a one-liner describing this DataType.- Throws:
UnsupportedOperationException- if the description is not allowed to be set for this datatype.
-
hasLanguageDependantLength
public boolean hasLanguageDependantLength()Description copied from interface:DataTypeIndicates if the length of this data-type is determined based upon theDataOrganizationobtained from the associatedDataTypeManager.- Specified by:
hasLanguageDependantLengthin interfaceDataType- Returns:
- true length is language/compiler-specification dependent, else false
-
getDefaultLabelPrefix
Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix in the absence of any data.- Specified by:
getDefaultLabelPrefixin interfaceDataType- Returns:
- the default label prefix or null if none specified.
-
getDefaultAbbreviatedLabelPrefix
Description copied from interface:DataTypeReturns the prefix to use for this datatype when an abbreviated prefix is desired.For example, some datatypes will build a large default label, at which it is more desirable to have a shortened prefix.
- Specified by:
getDefaultAbbreviatedLabelPrefixin interfaceDataType- Returns:
- the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
-
setCategoryPath
Description copied from interface:DataTypeSet the categoryPath associated with this datatype- Specified by:
setCategoryPathin interfaceDataType- Parameters:
path- the new path- Throws:
DuplicateNameException- if an attempt to place this datatype into the specified category resulted in a name collision. This should not occur for non-DB DataType instances.
-
getDefaultLabelPrefix
public String getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options) Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix.- Specified by:
getDefaultLabelPrefixin interfaceDataType- Parameters:
buf- memory buffer containing the bytes.settings- the Settings objectlen- the length of the data.options- options for how to format the default label prefix.- Returns:
- the default label prefix or null if none specified.
-
getDefaultOffcutLabelPrefix
public String getDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutLength) Description copied from interface:DataTypeReturns the appropriate string to use as the default label prefix.This takes into account the fact that there exists a reference to the data that references
offcutLengthbytes into this type- Specified by:
getDefaultOffcutLabelPrefixin interfaceDataType- Parameters:
buf- memory buffer containing the bytes.settings- the Settings objectlen- the length of the data.options- options for how to format the default label prefix.offcutLength- offset into datatype- Returns:
- the default label prefix.
-
isEncodable
public boolean isEncodable()Description copied from interface:DataTypeCheck if this type supports encoding (patching)If unsupported,
DataType.encodeValue(Object, MemBuffer, Settings, int)andDataType.encodeRepresentation(String, MemBuffer, Settings, int)will always throw an exception. Actions which rely on eitherencodemethod should not be displayed if the applicable datatype is not encodable.- Specified by:
isEncodablein interfaceDataType- Returns:
- true if encoding is supported
-
encodeValue
public byte[] encodeValue(Object value, MemBuffer buf, Settings settings, int length) throws DataTypeEncodeException Description copied from interface:DataTypeEncode bytes from an Object appropriate for this DataType.Converts the given object to the byte encoding and returns it. When appropriate, this should seek the nearest encoding to the specified value, since the object may come from a user script. For example, a floating-point value may be rounded. Invalid values should be rejected with a
DataTypeEncodeException.- Specified by:
encodeValuein interfaceDataType- Parameters:
value- the desired value.buf- a buffer representing the eventual destination of the bytes.settings- the settings to use.length- the expected length of the result, usually the length of the data unit, or -1 to let the type choose the length. It may be ignored, e.g., for fixed-length types.- Returns:
- the encoded value.
- Throws:
DataTypeEncodeException- if the value cannot be encoded for any reason, e.g., incorrect type, not enough space, buffer overflow, unsupported (seeDataType.isEncodable()).
-
encodeRepresentation
public byte[] encodeRepresentation(String repr, MemBuffer buf, Settings settings, int length) throws DataTypeEncodeException Description copied from interface:DataTypeEncode bytes according to the display format for this type.Converts the given representation to the byte encoding and returns it. When appropriate, this should seek the nearest encoding to the specified value, since the representation is likely coming from user input. For example, a floating-point value may be rounded. Invalid representations should be rejected with a
DataTypeEncodeException.- Specified by:
encodeRepresentationin interfaceDataType- Parameters:
repr- the representation of the desired value, as inDataType.getRepresentation(MemBuffer, Settings, int). The supported formats depend on the specific datatype and its settings.buf- a buffer representing the eventual destination of the bytes.settings- the settings to use for the representation.length- the expected length of the result, usually the length of the data unit, or -1 to let the type choose the length. It may be ignored, e.g., for fixed-length types.- Returns:
- the encoded value.
- Throws:
DataTypeEncodeException- if the value cannot be encoded for any reason, e.g., incorrect format, not enough space, buffer overflow, unsupported (seeDataType.isEncodable()).
-