decompiler  1.0.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
TypeFactory Class Reference

Container class for all Datatype objects in an Architecture. More...

#include <type.hh>

Inheritance diagram for TypeFactory:
TypeFactoryGhidra

Public Member Functions

 TypeFactory (Architecture *g)
 Construct a factory. More...
 
void setupSizes (void)
 Derive some size information from Architecture. More...
 
void clear (void)
 Clear out all types. More...
 
void clearNoncore (void)
 Clear out non-core types. More...
 
virtual ~TypeFactory (void)
 Destructor.
 
void setStructAlign (int4 al)
 Set the default structure alignment.
 
int4 getStructAlign (void) const
 Get the default structure alignment.
 
int4 getSizeOfInt (void) const
 Get the size of the default "int".
 
ArchitecturegetArch (void) const
 Get the Architecture object.
 
DatatypefindByName (const string &n)
 Return type of given name. More...
 
DatatypesetName (Datatype *ct, const string &n)
 Set the given types name. More...
 
bool setFields (vector< TypeField > &fd, TypeStruct *ot, int4 fixedsize)
 Set fields on a TypeStruct. More...
 
bool setEnumValues (const vector< string > &namelist, const vector< uintb > &vallist, const vector< bool > &assignlist, TypeEnum *te)
 Set named values for an enumeration. More...
 
DatatyperestoreXmlType (const Element *el)
 Restore Datatype from XML. More...
 
DatatyperestoreXmlTypeWithCodeFlags (const Element *el, bool hasThisPtr, bool isConstructor, bool isDestructor)
 Restore data-type from XML with extra "code" flags. More...
 
TypeVoidgetTypeVoid (void)
 Get the "void" data-type. More...
 
DatatypegetBaseNoChar (int4 s, type_metatype m)
 Get atomic type excluding "char". More...
 
DatatypegetBase (int4 s, type_metatype m)
 Get atomic type. More...
 
DatatypegetBase (int4 s, type_metatype m, const string &n)
 Get named atomic type. More...
 
TypeCodegetTypeCode (void)
 Get an "anonymous" function data-type. More...
 
TypePointergetTypePointer (int4 s, Datatype *pt, uint4 ws)
 Construct a pointer data-type. More...
 
TypePointergetTypePointerAbsolute (int4 s, Datatype *pt, uint4 ws)
 Construct an absolute pointer data-type. More...
 
TypePointergetTypePointerNoDepth (int4 s, Datatype *pt, uint4 ws)
 Construct a depth limited pointer data-type. More...
 
TypeArraygetTypeArray (int4 as, Datatype *ao)
 Construct an array data-type. More...
 
TypeStructgetTypeStruct (const string &n)
 Create an (empty) structure. More...
 
TypeEnumgetTypeEnum (const string &n)
 Create an (empty) enumeration. More...
 
TypeSpacebasegetTypeSpacebase (AddrSpace *id, const Address &addr)
 Create a "spacebase" type. More...
 
TypeCodegetTypeCode (ProtoModel *model, Datatype *outtype, const vector< Datatype * > &intypes, bool dotdotdot)
 Create a "function" datatype. More...
 
void destroyType (Datatype *ct)
 Remove a data-type from this. More...
 
DatatypedownChain (Datatype *ptrtype, uintb &off)
 Find a sub-type matching a pointer and offset. More...
 
void dependentOrder (vector< Datatype * > &deporder) const
 Place all data-types in dependency order. More...
 
void saveXml (ostream &s) const
 Save this container to stream. More...
 
void saveXmlCoreTypes (ostream &s) const
 Save core types to stream. More...
 
void restoreXml (const Element *el)
 Restore this container from a stream. More...
 
void restoreXmlCoreTypes (const Element *el)
 Initialize basic type names. More...
 
void parseDataOrganization (const Element *el)
 Parse the <data_organization> tag. More...
 
void parseEnumConfig (const Element *el)
 Parse the <enum> tag. More...
 
void setCoreType (const string &name, int4 size, type_metatype meta, bool chartp)
 Create a core data-type. More...
 
void cacheCoreTypes (void)
 Cache common types. More...
 

Protected Member Functions

DatatypefindByIdLocal (const string &nm, uint8 id) const
 Search locally by name and id. More...
 
virtual DatatypefindById (const string &n, uint8 id)
 Search by name and id. More...
 

Protected Attributes

Architectureglb
 The Architecture object that owns this TypeFactory.
 

Private Member Functions

DatatypefindNoName (Datatype &ct)
 Find data-type (in this container) by function. More...
 
DatatypefindAdd (Datatype &ct)
 Find data-type in this container or add it. More...
 
void orderRecurse (vector< Datatype * > &deporder, DatatypeSet &mark, Datatype *ct) const
 Write out dependency list. More...
 
DatatyperestoreXmlTypeNoRef (const Element *el, bool forcecore)
 Restore from an XML tag. More...
 
void clearCache (void)
 Clear the common type cache. More...
 
TypeChargetTypeChar (const string &n)
 Create a default "char" type. More...
 
TypeUnicodegetTypeUnicode (const string &nm, int4 sz, type_metatype m)
 Create a default "unicode" type. More...
 
TypeCodegetTypeCode (const string &n)
 Create a default "code" type. More...
 

Private Attributes

int4 sizeOfInt
 Size of the core "int" datatype.
 
int4 align
 Alignment of structures.
 
int4 enumsize
 Size of an enumerated type.
 
type_metatype enumtype
 Default enumeration meta-type (when parsing C)
 
DatatypeSet tree
 Datatypes within this factory (sorted by function)
 
DatatypeNameSet nametree
 Cross-reference by name.
 
Datatypetypecache [9][8]
 Matrix of the most common atomic data-types.
 
Datatypetypecache10
 Specially cached 10-byte float type.
 
Datatypetypecache16
 Specially cached 16-byte float type.
 
Datatypetype_nochar
 Same dimensions as char but acts and displays as an INT.
 

Detailed Description

Container class for all Datatype objects in an Architecture.

Constructor & Destructor Documentation

◆ TypeFactory()

TypeFactory::TypeFactory ( Architecture g)

Construct a factory.

Initialize an empty container

Parameters
gis the owning Architecture

Member Function Documentation

◆ cacheCoreTypes()

void TypeFactory::cacheCoreTypes ( void  )

Cache common types.

Run through the list of "core" data-types and cache the most commonly accessed ones for quick access (avoiding the tree lookup). The "core" data-types must have been previously initialized.

References Datatype::getMetatype(), Datatype::getSize(), Datatype::isASCII(), Datatype::isCharPrint(), Datatype::isCoreType(), Datatype::isEnumType(), tree, TYPE_BOOL, TYPE_CODE, TYPE_FLOAT, TYPE_INT, type_nochar, TYPE_UINT, TYPE_UNKNOWN, TYPE_VOID, typecache, typecache10, and typecache16.

Referenced by ArchitectureGhidra::buildTypegrp(), Architecture::buildTypegrp(), and restoreXmlCoreTypes().

◆ clear()

void TypeFactory::clear ( void  )

Clear out all types.

Remove all Datatype objects owned by this TypeFactory.

References clearCache(), nametree, and tree.

Referenced by restoreXmlCoreTypes(), and ~TypeFactory().

◆ clearCache()

void TypeFactory::clearCache ( void  )
private

Clear the common type cache.

Clear the matrix of commonly used atomic types.

Referenced by clear().

◆ clearNoncore()

void TypeFactory::clearNoncore ( void  )

Clear out non-core types.

Delete anything that isn't a core type.

References Datatype::isCoreType(), nametree, and tree.

Referenced by FlushNative::rawAction().

◆ dependentOrder()

void TypeFactory::dependentOrder ( vector< Datatype * > &  deporder) const

Place all data-types in dependency order.

Place data-types in an order such that if the definition of data-type "a" depends on the definition of data-type "b", then "b" occurs earlier in the order

Parameters
deporderwill hold the generated dependency list of data-types

References orderRecurse(), and tree.

Referenced by PrintC::docTypeDefinitions(), and saveXml().

◆ destroyType()

void TypeFactory::destroyType ( Datatype ct)

Remove a data-type from this.

The indicated Datatype object is removed from this container. Indirect references (via TypeArray TypeStruct etc.) are not affected

Parameters
ctis the data-type to destroy

References Datatype::isCoreType(), nametree, and tree.

◆ downChain()

Datatype * TypeFactory::downChain ( Datatype ptrtype,
uintb &  off 
)

Find a sub-type matching a pointer and offset.

Add a constant offset to a pointer with known data-type. If there is a valid component at that offset, return a pointer to the data-type of the component or NULL otherwise. This routine only goes down one level at most. Pass back the renormalized offset relative to the new data-type

Parameters
ptrtypeis the pointer data-type being added to
offis a reference to the offset to add
Returns
a pointer datatype for the component or NULL

References Datatype::getSubType(), getTypePointer(), TypePointer::getWordSize(), Datatype::metatype, TypePointer::ptrto, Datatype::size, and TYPE_PTR.

Referenced by TypeOpPtrsub::getOutputToken(), and ActionInferTypes::propagateAddIn2Out().

◆ findAdd()

Datatype * TypeFactory::findAdd ( Datatype ct)
private

Find data-type in this container or add it.

Use quickest method (name or id is possible) to locate the matching data-type. If its not currently in this container, clone the data-type and add it to the container.

Parameters
ctis the data-type to match
Returns
the matching Datatype object in this container

References Datatype::clone(), Datatype::compareDependency(), findByIdLocal(), findNoName(), Datatype::getId(), Datatype::id, Datatype::name, nametree, Datatype::printRaw(), and tree.

Referenced by getBase(), getTypeArray(), getTypeChar(), getTypeCode(), getTypeEnum(), getTypePointer(), getTypePointerAbsolute(), getTypeSpacebase(), getTypeStruct(), getTypeUnicode(), restoreXmlTypeNoRef(), and restoreXmlTypeWithCodeFlags().

◆ findById()

Datatype * TypeFactory::findById ( const string &  n,
uint8  id 
)
protectedvirtual

Search by name and id.

Search for a Datatype by name and/or id. Derived classes may search outside this container.

Parameters
nis the name of the data-type
idis the type id of the data-type
Returns
the matching Datatype object

Reimplemented in TypeFactoryGhidra.

References findByIdLocal().

Referenced by TypeFactoryGhidra::findById(), findByName(), and restoreXmlType().

◆ findByIdLocal()

Datatype * TypeFactory::findByIdLocal ( const string &  n,
uint8  id 
) const
protected

Search locally by name and id.

Looking just within this container, find a Datatype by name and/or id.

Parameters
nis the name of the data-type
idis the type id of the data-type
Returns
the matching Datatype object

References Datatype::id, nametree, and TYPE_UNKNOWN.

Referenced by findAdd(), findById(), and restoreXmlTypeNoRef().

◆ findByName()

Datatype * TypeFactory::findByName ( const string &  n)

Return type of given name.

Find type with given name. If there are more than, return first.

Parameters
nis the name to search for
Returns
a Datatype object with the name or NULL

References findById().

◆ findNoName()

Datatype * TypeFactory::findNoName ( Datatype ct)
private

Find data-type (in this container) by function.

Find data-type without reference to name, using the functional comparators For this to work, the type must be built out of dependencies that are already present in this type factory

Parameters
ctis the data-type to match
Returns
the matching Datatype or NULL

References tree.

Referenced by findAdd().

◆ getBase() [1/2]

Datatype * TypeFactory::getBase ( int4  s,
type_metatype  m 
)

Get atomic type.

Get one of the "base" datatypes. This routine is called a lot, so we go through a cache first.

Parameters
sis the desired size
mis the desired meta-type
Returns
the Datatype object

References findAdd(), getTypeArray(), glb, Architecture::max_basetype_size, TYPE_FLOAT, TYPE_UNKNOWN, typecache, typecache10, and typecache16.

Referenced by RuleSubRight::applyOp(), CastStrategyC::arithmeticOutputStandard(), LabSymbol::buildType(), getBaseNoChar(), TypeOp::getInputLocal(), TypeOpBinary::getInputLocal(), TypeOpUnary::getInputLocal(), TypeOpFunc::getInputLocal(), TypeOpCbranch::getInputLocal(), TypeOpPtradd::getInputLocal(), TypeOpPtrsub::getInputLocal(), TypeOpCpoolref::getInputLocal(), TypeOp::getOutputLocal(), TypeOpBinary::getOutputLocal(), TypeOpUnary::getOutputLocal(), TypeOpFunc::getOutputLocal(), TypeOpPtradd::getOutputLocal(), TypeOpPtrsub::getOutputLocal(), TypeOpCpoolref::getOutputLocal(), TypeOpIntLeft::getOutputToken(), TypeOpIntRight::getOutputToken(), TypeOpIntSright::getOutputToken(), TypeOpPiece::getOutputToken(), TypeOpSubpiece::getOutputToken(), getTypePointerNoDepth(), Funcdata::mapGlobals(), Funcdata::newConstant(), Funcdata::newUnique(), Funcdata::newUniqueOut(), Funcdata::newVarnode(), Funcdata::newVarnodeCallSpecs(), Funcdata::newVarnodeIop(), Funcdata::newVarnodeOut(), Funcdata::newVarnodeSpace(), FuncProto::paramShift(), ActionInferTypes::propagateAddIn2Out(), ActionInferTypes::propagateTypeEdge(), PrintC::pushAnnotation(), Scope::resetSizeLockType(), ParameterBasic::resetSizeLockType(), EquateSymbol::restoreXml(), setCoreType(), FuncProto::updateInputNoTypes(), and FuncProto::updateOutputNoTypes().

◆ getBase() [2/2]

Datatype * TypeFactory::getBase ( int4  s,
type_metatype  m,
const string &  n 
)

Get named atomic type.

Get or create a "base" type with a specified name and properties

Parameters
sis the desired size
mis the desired meta-type
nis the desired name
Returns
the Database object

References findAdd(), Datatype::hashName(), and Datatype::id.

◆ getBaseNoChar()

Datatype * TypeFactory::getBaseNoChar ( int4  s,
type_metatype  m 
)

Get atomic type excluding "char".

Get a "base" data-type, given its size and metatype. If a 1-byte integer is requested, do NOT return a TypeChar

Parameters
sis the size of the data-type
mis the meta-type of the data-type
Returns
the Datatype object

References getBase(), TYPE_INT, and type_nochar.

Referenced by TypeOpIntLeft::getInputLocal(), TypeOpIntRight::getInputLocal(), and TypeOpIntSright::getInputLocal().

◆ getTypeArray()

TypeArray * TypeFactory::getTypeArray ( int4  as,
Datatype ao 
)

Construct an array data-type.

Parameters
asis the number of elements in the desired array
aois the data-type of the array element
Returns
the TypeArray object

References findAdd().

Referenced by FunctionSymbol::buildType(), and getBase().

◆ getTypeChar()

TypeChar * TypeFactory::getTypeChar ( const string &  n)
private

Create a default "char" type.

This creates a 1-byte character datatype (assumed to use UTF8 encoding)

Parameters
nis the name to give the data-type
Returns
the new character Datatype object

References findAdd(), Datatype::hashName(), and Datatype::id.

Referenced by setCoreType().

◆ getTypeCode() [1/3]

TypeCode * TypeFactory::getTypeCode ( const string &  nm)
private

Create a default "code" type.

Create a "function" or "executable" Datatype object This is used for anonymous function pointers with no prototype

Parameters
nmis the name of the data-type
Returns
the new Datatype object

References findAdd(), getTypeCode(), Datatype::hashName(), and Datatype::id.

Referenced by ExternRefSymbol::buildNameType(), FunctionSymbol::buildType(), TypeOpCbranch::getInputLocal(), TypeOpCallind::getInputLocal(), TypeOpIndirect::getInputLocal(), and Funcdata::newCodeRef().

◆ getTypeCode() [2/3]

TypeCode * TypeFactory::getTypeCode ( void  )

Get an "anonymous" function data-type.

Retrieve or create the core "code" Datatype object This has no prototype attached to it and is appropriate for anonymous function pointers.

Returns
the TypeCode object

References findAdd(), TYPE_CODE, TYPE_FLOAT, and typecache.

Referenced by getTypeCode(), and setCoreType().

◆ getTypeCode() [3/3]

TypeCode * TypeFactory::getTypeCode ( ProtoModel model,
Datatype outtype,
const vector< Datatype * > &  intypes,
bool  dotdotdot 
)

Create a "function" datatype.

Creates a TypeCode object and associates a specific function prototype with it.

Parameters
modelis the prototype model associated with the function
outtypeis the return type of the function
intypesis the array of input parameters of the function
dotdotdotis true if the function takes variable arguments
Returns
the TypeCode object

References findAdd(), getTypeVoid(), and TypeCode::set().

◆ getTypeEnum()

TypeEnum * TypeFactory::getTypeEnum ( const string &  n)

Create an (empty) enumeration.

The created enumeration will have no named values and a default configuration Named values must be added later.

Parameters
nis the name of the enumeration
Returns
the TypeEnum object

References enumsize, enumtype, findAdd(), Datatype::hashName(), and Datatype::id.

◆ getTypePointer()

TypePointer * TypeFactory::getTypePointer ( int4  s,
Datatype pt,
uint4  ws 
)

Construct a pointer data-type.

This creates a pointer to a given data-type. It doesn't allow a "pointer to array" to be created however and will drill-down to the first non-array data-type

Parameters
sis the size of the pointer
ptis the pointed-to data-type
wsis the wordsize associated with the pointer
Returns
the TypePointer object

References findAdd(), Datatype::getMetatype(), and TYPE_ARRAY.

Referenced by ExternRefSymbol::buildNameType(), downChain(), TypeOpLoad::getInputCast(), TypeOpStore::getInputCast(), TypeOpCbranch::getInputLocal(), TypeOpCallind::getInputLocal(), TypeOpIndirect::getInputLocal(), getTypePointerNoDepth(), ActionInferTypes::propagateAddIn2Out(), ActionInferTypes::propagateTypeEdge(), Funcdata::spacebase(), and Funcdata::spacebaseConstant().

◆ getTypePointerAbsolute()

TypePointer * TypeFactory::getTypePointerAbsolute ( int4  s,
Datatype pt,
uint4  ws 
)

Construct an absolute pointer data-type.

Allows "pointer to array" to be constructed

Parameters
sis the size of the pointer
ptis the pointed-to data-type
wsis the wordsize associated with the pointer
Returns
the TypePointer object

References findAdd().

Referenced by ParamListStandard::assignMap(), and ParamListStandardOut::assignMap().

◆ getTypePointerNoDepth()

TypePointer * TypeFactory::getTypePointerNoDepth ( int4  s,
Datatype pt,
uint4  ws 
)

Construct a depth limited pointer data-type.

Parameters
sis the size of the pointer
ptis the pointed-to data-type
wsis the wordsize associated with the pointer
Returns
the TypePointer object

References getBase(), Datatype::getMetatype(), Datatype::getSize(), getTypePointer(), TYPE_PTR, and TYPE_UNKNOWN.

Referenced by ActionInferTypes::propagateTypeEdge().

◆ getTypeSpacebase()

TypeSpacebase * TypeFactory::getTypeSpacebase ( AddrSpace id,
const Address addr 
)

Create a "spacebase" type.

Creates the special TypeSpacebase with an associated address space and scope

Parameters
idis the address space
addrspecifies the function scope, or isInvalid() for global scope
Returns
the TypeSpacebase object

References findAdd(), and glb.

Referenced by Funcdata::spacebase(), and Funcdata::spacebaseConstant().

◆ getTypeStruct()

TypeStruct * TypeFactory::getTypeStruct ( const string &  n)

Create an (empty) structure.

The created structure will have no fields. They must be added later.

Parameters
nis the name of the structure
Returns
the TypeStruct object

References findAdd(), Datatype::hashName(), and Datatype::id.

◆ getTypeUnicode()

TypeUnicode * TypeFactory::getTypeUnicode ( const string &  nm,
int4  sz,
type_metatype  m 
)
private

Create a default "unicode" type.

This creates a multi-byte character data-type (using UTF16 or UTF32 encoding)

Parameters
nmis the name to give the data-type
szis the size of the data-type in bytes
mis the presumed meta-type when treating the character as an integer
Returns
the new character Datatype object

References findAdd(), Datatype::hashName(), and Datatype::id.

Referenced by setCoreType().

◆ getTypeVoid()

TypeVoid * TypeFactory::getTypeVoid ( void  )

◆ orderRecurse()

void TypeFactory::orderRecurse ( vector< Datatype * > &  deporder,
DatatypeSet mark,
Datatype ct 
) const
private

Write out dependency list.

Recursively write out all the components of a data-type in dependency order Component data-types will come before the data-type containing them in the list.

Parameters
deporderholds the ordered list of data-types to construct
markis a "marking" container to prevent cycles
ctis the data-type to have written out

References Datatype::getDepend(), and Datatype::numDepend().

Referenced by dependentOrder().

◆ parseDataOrganization()

void TypeFactory::parseDataOrganization ( const Element el)

Parse the <data_organization> tag.

Recover various sizes relevant to this container, such as the default size of "int" and structure alignment, by parsing the <data_organization> tag.

Parameters
elis the XML element

References align, and sizeOfInt.

Referenced by Architecture::parseCompilerConfig().

◆ parseEnumConfig()

void TypeFactory::parseEnumConfig ( const Element el)

Parse the <enum> tag.

Recover default enumeration properties (size and meta-type) from an <enum> XML tag. Should probably consider this deprecated. These values are only used by the internal C parser. param el is the XML element

References enumsize, enumtype, TYPE_INT, and TYPE_UINT.

Referenced by Architecture::parseCompilerConfig().

◆ restoreXml()

void TypeFactory::restoreXml ( const Element el)

Restore this container from a stream.

Read data-types into this container from an XML stream

Parameters
elis the root XML element

References align, enumsize, enumtype, restoreXmlTypeNoRef(), sizeOfInt, TYPE_INT, and TYPE_UINT.

Referenced by Architecture::restoreXml().

◆ restoreXmlCoreTypes()

void TypeFactory::restoreXmlCoreTypes ( const Element el)

Initialize basic type names.

Restore data-types from an XML stream into this container This stream is presumed to contain "core" datatypes and the cached matrix will be populated from this set.

Parameters
elis the root XML element

References cacheCoreTypes(), clear(), and restoreXmlTypeNoRef().

Referenced by ArchitectureGhidra::buildTypegrp(), and Architecture::buildTypegrp().

◆ restoreXmlType()

Datatype * TypeFactory::restoreXmlType ( const Element el)

Restore Datatype from XML.

Restore a Datatype object from an XML tag description: either <type>, <typeref>, or <void>

Parameters
elis the XML element describing the data-type
Returns
the restored Datatype object

References findById(), Datatype::hashName(), and restoreXmlTypeNoRef().

Referenced by TypeFactoryGhidra::findById(), CPoolRecord::restoreXml(), ProtoStoreInternal::restoreXml(), FuncProto::restoreXml(), and Symbol::restoreXmlBody().

◆ restoreXmlTypeNoRef()

Datatype * TypeFactory::restoreXmlTypeNoRef ( const Element el,
bool  forcecore 
)
private

◆ restoreXmlTypeWithCodeFlags()

Datatype * TypeFactory::restoreXmlTypeWithCodeFlags ( const Element el,
bool  hasThisPtr,
bool  isConstructor,
bool  isDestructor 
)

Restore data-type from XML with extra "code" flags.

Kludge to get flags into code pointer types, when they can't come through XML

Parameters
elis the XML element describing the Datatype
hasThisPtrtoggles "this" pointer property on "function" datatypes
isConstructortoggles "constructor" property on "function" datatypes
isDestructortoggles "destructor" property on "function" datatypes
Returns
the restored Datatype object

References findAdd(), Datatype::getMetatype(), TypePointer::ptrto, TypeCode::restoreXml(), Datatype::restoreXmlBasic(), TypeCode::setProperties(), TYPE_PTR, and TypePointer::wordsize.

Referenced by CPoolRecord::restoreXml().

◆ saveXml()

void TypeFactory::saveXml ( ostream &  s) const

Save this container to stream.

All data-types, in dependency order, are written out to an XML stream

Parameters
sis the output stream

References align, dependentOrder(), enumsize, enumtype, sizeOfInt, TYPE_ARRAY, TYPE_INT, TYPE_PTR, and TYPE_STRUCT.

Referenced by Architecture::saveXml().

◆ saveXmlCoreTypes()

void TypeFactory::saveXmlCoreTypes ( ostream &  s) const

Save core types to stream.

Any data-type within this container marked as "core" will be written to an XML <coretypes> stream.

Parameters
sis the output stream

References Datatype::getMetatype(), Datatype::isCoreType(), Datatype::saveXml(), tree, TYPE_ARRAY, TYPE_PTR, and TYPE_STRUCT.

Referenced by XmlArchitecture::saveXml(), RawBinaryArchitecture::saveXml(), and BfdArchitecture::saveXml().

◆ setCoreType()

void TypeFactory::setCoreType ( const string &  name,
int4  size,
type_metatype  meta,
bool  chartp 
)

Create a core data-type.

Manually create a "base" core type. This currently must be called before any pointers or arrays are defined off of the type.

Parameters
nameis the data-type name
sizeis the size of the data-type
metais the meta-type of the data-type
chartpis true if a character type should be created

References Datatype::coretype, Datatype::flags, getBase(), getTypeChar(), getTypeCode(), getTypeUnicode(), getTypeVoid(), TYPE_CODE, and TYPE_VOID.

Referenced by ArchitectureGhidra::buildTypegrp(), and Architecture::buildTypegrp().

◆ setEnumValues()

bool TypeFactory::setEnumValues ( const vector< string > &  namelist,
const vector< uintb > &  vallist,
const vector< bool > &  assignlist,
TypeEnum te 
)

Set named values for an enumeration.

Set the list of enumeration values and identifiers for a TypeEnum Fill in any values for any names that weren't explicitly assigned and check for duplicates.

Parameters
namelistis the list of names in the enumeration
vallistis the corresponding list of values assigned to names in namelist
assignlistis true if the corresponding name in namelist has an assigned value
teis the enumeration object to modify
Returns
true if the modification is successful (no duplicate names)

References calc_mask(), Datatype::getSize(), TypeEnum::setNameMap(), and tree.

◆ setFields()

bool TypeFactory::setFields ( vector< TypeField > &  fd,
TypeStruct ot,
int4  fixedsize 
)

Set fields on a TypeStruct.

Make sure all the offsets are fully established then set fields of the structure If -fixedsize- is greater than 0, force the final structure to have that size

Parameters
fdis the list of fields to set
otis the TypeStruct object to modify
fixedsizeis 0 or the forced size of the structure
Returns
true if modification was successful

References align, Datatype::getMetatype(), Datatype::getName(), Datatype::getSize(), TypeStruct::setFields(), Datatype::size, tree, and TYPE_VOID.

Referenced by restoreXmlTypeNoRef().

◆ setName()

Datatype * TypeFactory::setName ( Datatype ct,
const string &  n 
)

Set the given types name.

This routine renames a Datatype object and fixes up cross-referencing

Parameters
ctis the data-type to rename
nis the new name
Returns
the renamed Datatype object

References Datatype::hashName(), Datatype::id, Datatype::name, nametree, and tree.

◆ setupSizes()

void TypeFactory::setupSizes ( void  )

Derive some size information from Architecture.

Set up default values for size of "int", structure alignment, and enums.

References VarnodeData::size.

Referenced by Architecture::parseCompilerConfig().


The documentation for this class was generated from the following files: