Class DefaultDataType
- java.lang.Object
-
- ghidra.program.model.data.AbstractDataType
-
- ghidra.program.model.data.DataTypeImpl
-
- ghidra.program.model.data.DefaultDataType
-
- All Implemented Interfaces:
DataType
public class DefaultDataType extends DataTypeImpl
Provides an implementation of a byte that has not been defined yet as a particular type of data in the program.
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultDataType
dataType
A statically defined DefaultDataType used when an Undefined byte is needed.-
Fields inherited from class ghidra.program.model.data.DataTypeImpl
defaultSettings
-
Fields inherited from class ghidra.program.model.data.AbstractDataType
categoryPath, dataMgr, name
-
Fields inherited from interface ghidra.program.model.data.DataType
CONFLICT_SUFFIX, DEFAULT, NO_LAST_CHANGE_TIME, NO_SOURCE_SYNC_TIME, VOID
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParent(DataType dt)
Inform this datatype that it has the given parentDataType
clone(DataTypeManager dtm)
Returns an instance of this DataType with its universalID and SourceArchive identity retained.DataType
copy(DataTypeManager dtm)
Returns a new instance (shallow copy) of this DataType with a new identity.void
dataTypeDeleted(DataType dt)
Informs this datatype that the given datatype has been deleted.void
dataTypeNameChanged(DataType dt, java.lang.String oldName)
Informs this datatype that its name has changed from the indicated old name.void
dataTypeReplaced(DataType oldDt, DataType newDt)
Informs this datatype that the given oldDT has been replaced with newDTvoid
dataTypeSizeChanged(DataType dt)
Notification that the given datatype's size has changed.boolean
dependsOn(DataType dt)
Check if this datatype depends on the existence of the given datatype.java.lang.String
getDescription()
Get a String briefly describing this DataType.long
getLastChangeTime()
Get the timestamp corresponding to the last time this type was changed within its datatype managerint
getLength()
Get the length (number of 8-bit bytes) of this DataType.java.lang.String
getMnemonic(Settings settings)
Get the mnemonic for this DataType.java.lang.String
getRepresentation(MemBuffer buf, Settings settings, int length)
Get bytes from memory in a printable format for this type.java.lang.Object
getValue(MemBuffer buf, Settings settings, int length)
Get the Undefined byte as a Scalar.boolean
isEquivalent(DataType dt)
Check if the given datatype is equivalent to this datatype.void
removeParent(DataType dt)
Remove a parent datatypevoid
setCategoryPath(CategoryPath path)
Set the categoryPath associated with this datatypevoid
setName(java.lang.String name)
Sets the name of the datatypevoid
setNameAndCategory(CategoryPath path, java.lang.String name)
Sets the name and category of a datatype at the same time.-
Methods inherited from class ghidra.program.model.data.DataTypeImpl
equals, getAlignment, getDefaultSettings, getLastChangeTimeInSourceArchive, getParents, getPathName, getSettingsDefinitions, getSourceArchive, getUniversalID, getValueClass, hashCode, notifyAlignmentChanged, notifyDeleted, notifyNameChanged, notifyParents, notifyReplaced, notifySizeChanged, replaceWith, setDefaultSettings, setDescription, setLastChangeTime, setLastChangeTimeInSourceArchive, setSourceArchive
-
Methods inherited from class ghidra.program.model.data.AbstractDataType
dataTypeAlignmentChanged, encodeRepresentation, encodeValue, getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDisplayName, getDocs, getName, hasLanguageDependantLength, isDeleted, isEncodable, isNotYetDefined, isZeroLength, toString
-
-
-
-
Field Detail
-
dataType
public static DefaultDataType dataType
A statically defined DefaultDataType used when an Undefined byte is needed.
-
-
Method Detail
-
getMnemonic
public java.lang.String getMnemonic(Settings settings)
Description copied from interface:DataType
Get the mnemonic for this DataType.- Specified by:
getMnemonic
in interfaceDataType
- Overrides:
getMnemonic
in classAbstractDataType
- Parameters:
settings
- settings which may influence the result or null- Returns:
- the mnemonic for this DataType.
- See Also:
DataType.getMnemonic(Settings)
-
getLength
public int getLength()
Description copied from interface:DataType
Get the length (number of 8-bit bytes) of this DataType.NOTE: No datatype should ever return 0, even if
DataType.isZeroLength()
, and onlyDynamic
datatypes should return -1. IfDataType.isZeroLength()
is true a length of 1 should be returned. Where a zero-length datatype can be handled (e.g.,Composite
) theDataType.isZeroLength()
method should be used.- Returns:
- the length of this DataType
- See Also:
DataType.getLength()
-
getDescription
public java.lang.String getDescription()
Description copied from interface:DataType
Get a String briefly describing this DataType.- Returns:
- a one-liner describing this DataType.
- See Also:
DataType.getDescription()
-
getRepresentation
public java.lang.String getRepresentation(MemBuffer buf, Settings settings, int length)
Description copied from interface:DataType
Get bytes from memory in a printable format for this type.- Parameters:
buf
- the data.settings
- the settings to use for the representation.length
- the number of bytes to represent.- Returns:
- the representation of the data in this format, never null.
- See Also:
DataType.getRepresentation(MemBuffer, Settings, int)
-
getValue
public java.lang.Object getValue(MemBuffer buf, Settings settings, int length)
Get the Undefined byte as a Scalar.- Parameters:
buf
- the data buffer.settings
- the display settings to use.length
- the number of bytes to get the value from.- Returns:
- the data Object.
-
clone
public DataType clone(DataTypeManager dtm)
Description copied from interface:DataType
Returns an instance of this DataType with its universalID and SourceArchive identity retained.The current instanceof will be returned if this datatype's DataTypeManager matches the specified dtm. The recursion depth of a clone will stop on any datatype whose DataTypeManager matches the specified dtm and simply use the existing datatype instance.
- Parameters:
dtm
- the data-type manager instance whose data-organization should apply.- Returns:
- cloned instance which may be the same as this instance
-
copy
public DataType copy(DataTypeManager dtm)
Description copied from interface:DataType
Returns a new instance (shallow copy) of this DataType with a new identity.Any reference to other datatypes will use
DataType.clone(DataTypeManager)
.- Parameters:
dtm
- the data-type manager instance whose data-organization should apply.- Returns:
- new instanceof of this datatype
-
dataTypeSizeChanged
public void dataTypeSizeChanged(DataType dt)
Description copied from interface:DataType
Notification 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:
dataTypeSizeChanged
in interfaceDataType
- Overrides:
dataTypeSizeChanged
in classAbstractDataType
- Parameters:
dt
- the datatype that has changed.- See Also:
DataType.dataTypeSizeChanged(ghidra.program.model.data.DataType)
-
isEquivalent
public boolean isEquivalent(DataType dt)
Description copied from interface:DataType
Check if the given datatype is equivalent to this datatype.The precise meaning of "equivalent" is datatype dependent.
NOTE: if invoked by a DB object or manager it should be invoked on the DataTypeDB object passing the other datatype as the argument.- Parameters:
dt
- the datatype being tested for equivalence.- Returns:
- true if the if the given datatype is equivalent to this datatype.
- See Also:
DataType.isEquivalent(ghidra.program.model.data.DataType)
-
setCategoryPath
public void setCategoryPath(CategoryPath path) throws DuplicateNameException
Description copied from interface:DataType
Set the categoryPath associated with this datatype- Specified by:
setCategoryPath
in interfaceDataType
- Overrides:
setCategoryPath
in classAbstractDataType
- 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.- See Also:
DataType.setCategoryPath(ghidra.program.model.data.CategoryPath)
-
setName
public void setName(java.lang.String name)
Description copied from interface:DataType
Sets the name of the datatype- Specified by:
setName
in interfaceDataType
- Overrides:
setName
in classAbstractDataType
- Parameters:
name
- the new name for this datatype.- See Also:
DataType.setName(java.lang.String)
-
setNameAndCategory
public void setNameAndCategory(CategoryPath path, java.lang.String name) throws InvalidNameException, DuplicateNameException
Description copied from interface:DataType
Sets the name and category of a datatype at the same time.- Specified by:
setNameAndCategory
in interfaceDataType
- Overrides:
setNameAndCategory
in classAbstractDataType
- Parameters:
path
- the new category path.name
- the new name- Throws:
InvalidNameException
- if the name is invalidDuplicateNameException
- if name change on storedDataType
is a duplicate of another datatype within the same category (only applies to DB storedDataType
).- See Also:
DataType.setNameAndCategory(ghidra.program.model.data.CategoryPath, java.lang.String)
-
dataTypeDeleted
public void dataTypeDeleted(DataType dt)
Description copied from interface:DataType
Informs this datatype that the given datatype has been deleted.TODO: This method is reserved for internal DB use.
- Specified by:
dataTypeDeleted
in interfaceDataType
- Overrides:
dataTypeDeleted
in classAbstractDataType
- Parameters:
dt
- the datatype that has been deleted.- See Also:
DataType.dataTypeDeleted(ghidra.program.model.data.DataType)
-
dataTypeNameChanged
public void dataTypeNameChanged(DataType dt, java.lang.String oldName)
Description copied from interface:DataType
Informs this datatype that its name has changed from the indicated old name.TODO: This method is reserved for internal DB use.
- Specified by:
dataTypeNameChanged
in interfaceDataType
- Overrides:
dataTypeNameChanged
in classAbstractDataType
- Parameters:
dt
- the datatype whose name changedoldName
- the datatype's old name- See Also:
DataType.dataTypeNameChanged(ghidra.program.model.data.DataType, java.lang.String)
-
dataTypeReplaced
public void dataTypeReplaced(DataType oldDt, DataType newDt)
Description copied from interface:DataType
Informs this datatype that the given oldDT has been replaced with newDTTODO: This method is reserved for internal DB use.
- Specified by:
dataTypeReplaced
in interfaceDataType
- Overrides:
dataTypeReplaced
in classAbstractDataType
- Parameters:
oldDt
- old datatypenewDt
- new datatype- See Also:
DataType.dataTypeReplaced(ghidra.program.model.data.DataType, ghidra.program.model.data.DataType)
-
dependsOn
public boolean dependsOn(DataType dt)
Description copied from interface:DataType
Check 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.
- Specified by:
dependsOn
in interfaceDataType
- Overrides:
dependsOn
in classAbstractDataType
- Parameters:
dt
- the datatype to test that this datatype depends on.- Returns:
- true if the existence of this datatype relies on the existence of the specified datatype dt.
- See Also:
DataType.dependsOn(ghidra.program.model.data.DataType)
-
addParent
public void addParent(DataType dt)
Description copied from interface:DataType
Inform this datatype that it has the given parentTODO: This method is reserved for internal DB use.
- Specified by:
addParent
in interfaceDataType
- Overrides:
addParent
in classDataTypeImpl
- Parameters:
dt
- parent datatype- See Also:
DataType.addParent(ghidra.program.model.data.DataType)
-
removeParent
public void removeParent(DataType dt)
Description copied from interface:DataType
Remove a parent datatypeTODO: This method is reserved for internal DB use.
- Specified by:
removeParent
in interfaceDataType
- Overrides:
removeParent
in classDataTypeImpl
- Parameters:
dt
- parent datatype- See Also:
DataType.removeParent(ghidra.program.model.data.DataType)
-
getLastChangeTime
public long getLastChangeTime()
Description copied from interface:DataType
Get the timestamp corresponding to the last time this type was changed within its datatype manager- Specified by:
getLastChangeTime
in interfaceDataType
- Overrides:
getLastChangeTime
in classDataTypeImpl
- Returns:
- timestamp of last change within datatype manager
-
-