|
decompiler 1.0.0
|
Container class for all Datatype objects in an Architecture. More...
#include <type.hh>
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". | |
| int4 | getSizeOfLong (void) const |
| Get the size of the default "long". | |
| Architecture * | getArch (void) const |
| Get the Architecture object. | |
| Datatype * | findByName (const string &n) |
| Return type of given name. More... | |
| Datatype * | setName (Datatype *ct, const string &n) |
| Set the given types name. More... | |
| void | setDisplayFormat (Datatype *ct, uint4 format) |
| Set the display format associated with the given data-type. More... | |
| bool | setFields (vector< TypeField > &fd, TypeStruct *ot, int4 fixedsize, uint4 flags) |
| Set fields on a TypeStruct. More... | |
| bool | setFields (vector< TypeField > &fd, TypeUnion *ot, int4 fixedsize, uint4 flags) |
| Set fields on a TypeUnion. More... | |
| void | setPrototype (const FuncProto *fp, TypeCode *newCode, uint4 flags) |
| Set the prototype on a TypeCode. More... | |
| bool | setEnumValues (const vector< string > &namelist, const vector< uintb > &vallist, const vector< bool > &assignlist, TypeEnum *te) |
| Set named values for an enumeration. More... | |
| Datatype * | decodeType (Decoder &decoder) |
| Restore Datatype from a stream. More... | |
| Datatype * | decodeTypeWithCodeFlags (Decoder &decoder, bool isConstructor, bool isDestructor) |
| Restore data-type from an element and extra "code" flags. More... | |
| TypeVoid * | getTypeVoid (void) |
| Get the "void" data-type. More... | |
| Datatype * | getBaseNoChar (int4 s, type_metatype m) |
| Get atomic type excluding "char". More... | |
| Datatype * | getBase (int4 s, type_metatype m) |
| Get atomic type. More... | |
| Datatype * | getBase (int4 s, type_metatype m, const string &n) |
| Get named atomic type. More... | |
| TypeCode * | getTypeCode (void) |
| Get an "anonymous" function data-type. More... | |
| TypePointer * | getTypePointerStripArray (int4 s, Datatype *pt, uint4 ws) |
| Construct a pointer data-type, stripping an ARRAY level. More... | |
| TypePointer * | getTypePointer (int4 s, Datatype *pt, uint4 ws) |
| Construct an absolute pointer data-type. More... | |
| TypePointer * | getTypePointer (int4 s, Datatype *pt, uint4 ws, const string &n) |
| Construct a named pointer data-type. More... | |
| TypePointer * | getTypePointerNoDepth (int4 s, Datatype *pt, uint4 ws) |
| Construct a depth limited pointer data-type. More... | |
| TypeArray * | getTypeArray (int4 as, Datatype *ao) |
| Construct an array data-type. More... | |
| TypeStruct * | getTypeStruct (const string &n) |
| Create an (empty) structure. More... | |
| TypeUnion * | getTypeUnion (const string &n) |
| Create an (empty) union. More... | |
| TypePartialUnion * | getTypePartialUnion (TypeUnion *contain, int4 off, int4 sz) |
| Create a partial union. | |
| TypeEnum * | getTypeEnum (const string &n) |
| Create an (empty) enumeration. More... | |
| TypeSpacebase * | getTypeSpacebase (AddrSpace *id, const Address &addr) |
| Create a "spacebase" type. More... | |
| TypeCode * | getTypeCode (ProtoModel *model, Datatype *outtype, const vector< Datatype * > &intypes, bool dotdotdot) |
| Create a "function" datatype. More... | |
| Datatype * | getTypedef (Datatype *ct, const string &name, uint8 id, uint4 format) |
| Create a new typedef data-type. More... | |
| TypePointerRel * | getTypePointerRel (TypePointer *parentPtr, Datatype *ptrTo, int4 off) |
| Get pointer offset relative to a container. More... | |
| TypePointerRel * | getTypePointerRel (int4 sz, Datatype *parent, Datatype *ptrTo, int4 ws, int4 off, const string &nm) |
| Build a named pointer offset into a larger container. More... | |
| TypePointer * | getTypePointerWithSpace (Datatype *ptrTo, AddrSpace *spc, const string &nm) |
| Build a named pointer with an address space attribute. More... | |
| void | destroyType (Datatype *ct) |
| Remove a data-type from this. More... | |
| Datatype * | concretize (Datatype *ct) |
| Convert given data-type to concrete form. More... | |
| void | dependentOrder (vector< Datatype * > &deporder) const |
| Place all data-types in dependency order. More... | |
| void | encode (Encoder &encoder) const |
| Encode this container to stream. More... | |
| void | encodeCoreTypes (Encoder &encoder) const |
| Encode core types to stream. More... | |
| void | decode (Decoder &decoder) |
| Decode this from a <typegrp> element. More... | |
| void | decodeCoreTypes (Decoder &decoder) |
| Initialize basic data-types from a stream. More... | |
| void | decodeDataOrganization (Decoder &decoder) |
| Parse a <data_organization> element. More... | |
| void | parseEnumConfig (Decoder &decoder) |
| 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 | |
| Datatype * | findByIdLocal (const string &nm, uint8 id) const |
| Search locally by name and id. More... | |
| virtual Datatype * | findById (const string &n, uint8 id, int4 sz) |
| Search by name and/or id. More... | |
Protected Attributes | |
| Architecture * | glb |
| The Architecture object that owns this TypeFactory. | |
Private Member Functions | |
| Datatype * | findNoName (Datatype &ct) |
| Find data-type (in this container) by function. More... | |
| void | insert (Datatype *newtype) |
| Insert pointer into the cross-reference sets. More... | |
| Datatype * | findAdd (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... | |
| Datatype * | decodeTypedef (Decoder &decoder) |
| Restore a <def> element describing a typedef. More... | |
| Datatype * | decodeStruct (Decoder &decoder, bool forcecore) |
| Restore a <type> element describing a structure. More... | |
| Datatype * | decodeUnion (Decoder &decoder, bool forcecore) |
| Restore a <type> element describing a union. More... | |
| Datatype * | decodeCode (Decoder &decoder, bool isConstructor, bool isDestructor, bool forcecore) |
| Restore an element describing a code object. More... | |
| Datatype * | decodeTypeNoRef (Decoder &decoder, bool forcecore) |
| Restore from a stream. More... | |
| void | clearCache (void) |
| Clear the common type cache. More... | |
| TypeChar * | getTypeChar (const string &n) |
| Create a default "char" type. More... | |
| TypeUnicode * | getTypeUnicode (const string &nm, int4 sz, type_metatype m) |
| Create a default "unicode" type. More... | |
| TypeCode * | getTypeCode (const string &n) |
| Create a default "code" type. More... | |
| void | recalcPointerSubmeta (Datatype *base, sub_metatype sub) |
| Recalculate submeta for pointers to given base data-type. More... | |
Private Attributes | |
| int4 | sizeOfInt |
| Size of the core "int" datatype. | |
| int4 | sizeOfLong |
| Size of the core "long" 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. | |
| Datatype * | typecache [9][8] |
| Matrix of the most common atomic data-types. | |
| Datatype * | typecache10 |
| Specially cached 10-byte float type. | |
| Datatype * | typecache16 |
| Specially cached 16-byte float type. | |
| Datatype * | type_nochar |
| Same dimensions as char but acts and displays as an INT. | |
Container class for all Datatype objects in an Architecture.
| TypeFactory::TypeFactory | ( | Architecture * | g | ) |
Construct a factory.
Initialize an empty container
| g | is the owning Architecture |
References align, clearCache(), enumsize, glb, sizeOfInt, and sizeOfLong.
| 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(), SleighArchitecture::buildTypegrp(), and decodeCoreTypes().
| void TypeFactory::clear | ( | void | ) |
Clear out all types.
Remove all Datatype objects owned by this TypeFactory.
References clearCache(), nametree, and tree.
Referenced by decodeCoreTypes(), and ~TypeFactory().
|
private |
Clear the common type cache.
Clear the matrix of commonly used atomic types.
References type_nochar, typecache, typecache10, and typecache16.
Referenced by clear(), and TypeFactory().
| 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().
Convert given data-type to concrete form.
The data-type propagation system can push around data-types that are partial or are otherwise unrepresentable in the source language. This method substitutes those data-types with a concrete data-type that is representable, or returns the same data-type if is already concrete. Its important that the returned data-type have the same size as the original data-type regardless.
| ct | is the given data-type |
References getBase(), Datatype::getMetatype(), Datatype::getSize(), TYPE_CODE, and TYPE_UNKNOWN.
Referenced by ScopeLocal::createEntry().
| void TypeFactory::decode | ( | Decoder & | decoder | ) |
Decode this from a <typegrp> element.
Scan configuration parameters of the factory and parse elements describing data-types into this container.
| decoder | is the stream decoder |
References align, ATTRIB_ENUMSIGNED, ATTRIB_ENUMSIZE, ATTRIB_INTSIZE, ATTRIB_LONGSIZE, ATTRIB_STRUCTALIGN, Decoder::closeElement(), decodeTypeNoRef(), ELEM_TYPEGRP, enumsize, enumtype, Decoder::openElement(), Decoder::peekElement(), Decoder::readBool(), Decoder::readSignedInteger(), sizeOfInt, sizeOfLong, TYPE_INT, and TYPE_UINT.
Referenced by Architecture::restoreXml().
|
private |
Restore an element describing a code object.
If necessary create a stub object before parsing the prototype description, to deal with recursive definitions
| decoder | is the stream decoder |
| isConstructor | is true if any prototype should be treated as a constructor |
| isDestructor | is true if any prototype should be treated as a destructor |
| forcecore | is true if the data-type is considered core |
References Datatype::compareDependency(), Datatype::coretype, TypeCode::decodePrototype(), TypeCode::decodeStub(), findAdd(), findByIdLocal(), Datatype::flags, Datatype::getMetatype(), Datatype::id, Datatype::isIncomplete(), Datatype::name, TypeCode::proto, setPrototype(), and TYPE_CODE.
Referenced by decodeTypeNoRef(), and decodeTypeWithCodeFlags().
| void TypeFactory::decodeCoreTypes | ( | Decoder & | decoder | ) |
Initialize basic data-types from a stream.
Parse data-type elements into this container. This stream is presumed to contain "core" datatypes and the cached matrix will be populated from this set.
| decoder | is the stream decoder |
References cacheCoreTypes(), clear(), Decoder::closeElement(), decodeTypeNoRef(), ELEM_CORETYPES, Decoder::openElement(), and Decoder::peekElement().
Referenced by ArchitectureGhidra::buildTypegrp(), and SleighArchitecture::buildTypegrp().
| void TypeFactory::decodeDataOrganization | ( | Decoder & | decoder | ) |
Parse a <data_organization> element.
Recover various sizes relevant to this container, such as the default size of "int" and structure alignment, by parsing a <data_organization> element.
| decoder | is the stream decoder |
References align, ATTRIB_ALIGNMENT, Decoder::closeElement(), Decoder::closeElementSkipping(), ELEM_DATA_ORGANIZATION, ELEM_ENTRY, ELEM_INTEGER_SIZE, ELEM_LONG_SIZE, ELEM_SIZE_ALIGNMENT_MAP, Decoder::openElement(), Decoder::readSignedInteger(), sizeOfInt, and sizeOfLong.
Referenced by Architecture::parseCompilerConfig().
Restore a <type> element describing a structure.
If necessary create a stub object before parsing the field descriptions, to deal with recursive definitions
| decoder | is the stream decoder |
| forcecore | is true if the data-type is considered core |
References Datatype::compareDependency(), Datatype::coretype, Datatype::decodeBasic(), TypeStruct::decodeFields(), TypeStruct::field, findAdd(), findByIdLocal(), Datatype::flags, Datatype::getMetatype(), Datatype::id, Datatype::isIncomplete(), Datatype::name, setFields(), Datatype::size, and TYPE_STRUCT.
Referenced by decodeTypeNoRef().
Restore Datatype from a stream.
Restore a Datatype object from an element: either <type>, <typeref>, or <void>
| decoder | is the stream decoder |
References Decoder::closeElement(), decodeTypeNoRef(), ELEM_TYPEREF, findById(), Decoder::getNextAttributeId(), Datatype::hashName(), Decoder::openElement(), Decoder::peekElement(), Decoder::readSignedInteger(), Decoder::readString(), and Decoder::readUnsignedInteger().
Referenced by ProtoStoreInternal::decode(), CPoolRecord::decode(), TypePointer::decode(), TypeArray::decode(), TypePointerRel::decode(), Symbol::decodeBody(), decodeTypedef(), TypeFactoryGhidra::findById(), and TypeField::TypeField().
Restore a <def> element describing a typedef.
Scan the new id and name. A subtag references the data-type being typedefed. Construct the new data-type based on the referenced data-type but with new name and id.
| decoder | is the stream decoder |
References decodeType(), Datatype::encodeIntegerFormat(), TypeStruct::field, TypeUnion::field, findByIdLocal(), Datatype::flags, Datatype::getMetatype(), Decoder::getNextAttributeId(), getTypedef(), Datatype::getTypedef(), Datatype::hashName(), Datatype::hashSize(), Datatype::isVariableLength(), Datatype::name, Decoder::readString(), Decoder::readUnsignedInteger(), setFields(), Datatype::size, TYPE_STRUCT, and TYPE_UNION.
Referenced by decodeTypeNoRef().
Restore from a stream.
Restore a Datatype object from a <type> element. (Don't use for <typeref> elements) The new Datatype is added to this container.
| decoder | is the stream decoder |
| forcecore | is true if the new type should be labeled as a core type |
References ATTRIB_CHAR, ATTRIB_ENUM, ATTRIB_UTF, Decoder::closeElement(), Datatype::coretype, TypeChar::decode(), TypeUnicode::decode(), TypePointer::decode(), TypeArray::decode(), TypeEnum::decode(), TypePointerRel::decode(), TypeSpacebase::decode(), Datatype::decodeBasic(), decodeCode(), decodeStruct(), decodeTypedef(), decodeUnion(), ELEM_DEF, findAdd(), Datatype::flags, Decoder::getNextAttributeId(), getTypeVoid(), glb, Decoder::openElement(), Decoder::readBool(), Decoder::readString(), Decoder::rewindAttributes(), string2metatype(), TYPE_ARRAY, TYPE_CODE, TYPE_INT, TYPE_PTR, TYPE_PTRREL, TYPE_SPACEBASE, TYPE_STRUCT, TYPE_UNION, and TYPE_UNKNOWN.
Referenced by decode(), decodeCoreTypes(), and decodeType().
| Datatype * TypeFactory::decodeTypeWithCodeFlags | ( | Decoder & | decoder, |
| bool | isConstructor, | ||
| bool | isDestructor | ||
| ) |
Restore data-type from an element and extra "code" flags.
Kludge to get flags into code pointer types, when they can't come through the stream
| decoder | is the stream decoder |
| isConstructor | toggles "constructor" property on "function" datatypes |
| isDestructor | toggles "destructor" property on "function" datatypes |
References Decoder::closeElement(), Datatype::decodeBasic(), decodeCode(), findAdd(), Datatype::getMetatype(), Decoder::getNextAttributeId(), Decoder::openElement(), TypePointer::ptrto, Decoder::readUnsignedInteger(), TYPE_PTR, and TypePointer::wordsize.
Referenced by CPoolRecord::decode().
Restore a <type> element describing a union.
If necessary create a stub object before parsing the field descriptions, to deal with recursive definitions
| decoder | is the stream decoder |
| forcecore | is true if the data-type is considered core |
References Datatype::compareDependency(), Datatype::coretype, Datatype::decodeBasic(), TypeUnion::decodeFields(), TypeUnion::field, findAdd(), findByIdLocal(), Datatype::flags, Datatype::getMetatype(), Datatype::id, Datatype::isIncomplete(), Datatype::name, setFields(), Datatype::size, and TYPE_UNION.
Referenced by decodeTypeNoRef().
| 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
| deporder | will hold the generated dependency list of data-types |
References orderRecurse(), and tree.
Referenced by PrintC::docTypeDefinitions(), and encode().
| 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
| ct | is the data-type to destroy |
References Datatype::isCoreType(), nametree, and tree.
| void TypeFactory::encode | ( | Encoder & | encoder | ) | const |
Encode this container to stream.
All data-types, in dependency order, are encoded to a stream
| encoder | is the stream encoder |
References align, ATTRIB_ENUMSIGNED, ATTRIB_ENUMSIZE, ATTRIB_INTSIZE, ATTRIB_LONGSIZE, ATTRIB_STRUCTALIGN, Encoder::closeElement(), dependentOrder(), ELEM_TYPEGRP, enumsize, enumtype, Encoder::openElement(), sizeOfInt, sizeOfLong, TYPE_ARRAY, TYPE_INT, TYPE_PTR, TYPE_STRUCT, TYPE_UNION, Encoder::writeBool(), and Encoder::writeSignedInteger().
Referenced by Architecture::encode().
| void TypeFactory::encodeCoreTypes | ( | Encoder & | encoder | ) | const |
Encode core types to stream.
Any data-type within this container marked as core will be encodeded as a <coretypes> element.
| encoder | is the stream encoder |
References Encoder::closeElement(), ELEM_CORETYPES, Datatype::encode(), Datatype::getMetatype(), Datatype::isCoreType(), Encoder::openElement(), tree, TYPE_ARRAY, TYPE_PTR, TYPE_STRUCT, and TYPE_UNION.
Referenced by BfdArchitecture::encode(), RawBinaryArchitecture::encode(), and XmlArchitecture::encode().
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.
| ct | is the data-type to match |
References Datatype::clone(), Datatype::compareDependency(), findByIdLocal(), findNoName(), Datatype::id, insert(), and Datatype::name.
Referenced by decodeCode(), decodeStruct(), decodeTypeNoRef(), decodeTypeWithCodeFlags(), decodeUnion(), getBase(), getTypeArray(), getTypeChar(), getTypeCode(), getTypeEnum(), getTypePartialUnion(), getTypePointer(), getTypePointerRel(), getTypePointerStripArray(), getTypePointerWithSpace(), getTypeSpacebase(), getTypeStruct(), getTypeUnicode(), and getTypeUnion().
|
protectedvirtual |
Search by name and/or id.
The id is expected to resolve uniquely. Internally, different length instances of a variable length data-type are stored as separate Datatype objects. A non-zero size can be given to distinguish these cases. Derived classes may search outside this container.
| n | is the name of the data-type |
| id | is the type id of the data-type |
| sz | is the given distinguishing size if non-zero |
Reimplemented in TypeFactoryGhidra.
References findByIdLocal(), and Datatype::hashSize().
Referenced by decodeType(), TypeFactoryGhidra::findById(), and findByName().
|
protected |
Search locally by name and id.
Looking just within this container, find a Datatype by name and/or id.
| n | is the name of the data-type |
| id | is the type id of the data-type |
References Datatype::id, nametree, and TYPE_UNKNOWN.
Referenced by decodeCode(), decodeStruct(), decodeTypedef(), decodeUnion(), findAdd(), findById(), and getTypedef().
| Datatype * TypeFactory::findByName | ( | const string & | n | ) |
Return type of given name.
Find type with given name. If there are more than, return first.
| n | is the name to search for |
References findById().
Referenced by IfcMapunionfacet::execute(), IfcForceDatatypeFormat::execute(), and IfcPointerSetting::execute().
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
| ct | is the data-type to match |
References tree.
Referenced by findAdd().
| 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.
| s | is the desired size |
| m | is the desired meta-type |
References findAdd(), getTypeArray(), glb, Architecture::max_basetype_size, TYPE_FLOAT, TYPE_UNKNOWN, typecache, typecache10, and typecache16.
Referenced by MapState::addGuard(), RuleSubRight::applyOp(), CastStrategyC::arithmeticOutputStandard(), SleighArchitecture::buildSymbols(), LabSymbol::buildType(), concretize(), EquateSymbol::decode(), ScopeInternal::decodeCollision(), EquateSymbol::EquateSymbol(), IfcNameVarnode::execute(), IfcGlobalRegisters::execute(), ScopeLocal::fakeInputSymbols(), getBaseNoChar(), TypeOp::getInputLocal(), TypeOpBinary::getInputLocal(), TypeOpUnary::getInputLocal(), TypeOpFunc::getInputLocal(), TypeOpCbranch::getInputLocal(), TypeOpPtradd::getInputLocal(), TypeOpPtrsub::getInputLocal(), TypeOpCpoolref::getInputLocal(), TypeOpInsert::getInputLocal(), TypeOpExtract::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(), TypeOpPtrsub::getOutputToken(), TypePointerRel::getPtrToFromParent(), TypeCode::getSubType(), TypeSpacebase::getSubType(), getTypePartialUnion(), getTypePointerNoDepth(), Funcdata::mapGlobals(), RangeHint::merge(), Funcdata::newConstant(), Funcdata::newUnique(), Funcdata::newUniqueOut(), Funcdata::newVarnode(), Funcdata::newVarnodeCallSpecs(), Funcdata::newVarnodeIop(), Funcdata::newVarnodeOut(), Funcdata::newVarnodeSpace(), FuncProto::paramShift(), TypeOpEqual::propagateAcrossCompare(), TypeOpIntAdd::propagateAddIn2Out(), TypeOpCopy::propagateType(), TypeOpIntXor::propagateType(), TypeOpIntAnd::propagateType(), TypeOpIntOr::propagateType(), TypeOpMulti::propagateType(), TypeOpIndirect::propagateType(), Scope::resetSizeLockType(), ParameterBasic::resetSizeLockType(), ScopeLocal::restructureHigh(), ScopeLocal::restructureVarnode(), setCoreType(), FuncProto::updateInputNoTypes(), FuncProto::updateInputTypes(), and FuncProto::updateOutputNoTypes().
| 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
| s | is the desired size |
| m | is the desired meta-type |
| n | is the desired name |
References findAdd(), Datatype::hashName(), and Datatype::id.
| 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
| s | is the size of the data-type |
| m | is the meta-type of the data-type |
References getBase(), TYPE_INT, and type_nochar.
Referenced by TypeOpIntLeft::getInputLocal(), TypeOpIntRight::getInputLocal(), and TypeOpIntSright::getInputLocal().
Construct an array data-type.
| as | is the number of elements in the desired array |
| ao | is the data-type of the array element |
References findAdd(), Datatype::getStripped(), and Datatype::hasStripped().
Referenced by ScopeLocal::createEntry(), and getBase().
|
private |
Create a default "char" type.
This creates a 1-byte character datatype (assumed to use UTF8 encoding)
| n | is the name to give the data-type |
References findAdd(), Datatype::hashName(), and Datatype::id.
Referenced by setCoreType().
|
private |
Create a default "code" type.
Create a "function" or "executable" Datatype object This is used for anonymous function pointers with no prototype
| nm | is the name of the data-type |
References findAdd(), getTypeCode(), Datatype::hashName(), Datatype::id, Datatype::markComplete(), and Datatype::name.
Referenced by ExternRefSymbol::buildNameType(), FunctionSymbol::buildType(), TypeOpCbranch::getInputLocal(), TypeOpCallind::getInputLocal(), TypeOpIndirect::getInputLocal(), and Funcdata::newCodeRef().
| 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.
| model | is the prototype model associated with the function |
| outtype | is the return type of the function |
| intypes | is the array of input parameters of the function |
| dotdotdot | is true if the function takes variable arguments |
References findAdd(), getTypeVoid(), Datatype::markComplete(), and TypeCode::setPrototype().
| 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.
References findAdd(), Datatype::markComplete(), TYPE_CODE, TYPE_FLOAT, and typecache.
Referenced by getTypeCode(), and setCoreType().
Create a new typedef data-type.
Find or create a data-type identical to the given data-type except for its name and id. If the name and id already describe an incompatible data-type, an exception is thrown.
| ct | is the given data-type to clone |
| name | is the new name for the clone |
| id | is the new id for the clone (or 0) |
| format | is a particular format to force when printing (or zero) |
References Datatype::clone(), Datatype::coretype, findByIdLocal(), Datatype::flags, Datatype::getTypedef(), Datatype::hashName(), Datatype::id, insert(), Datatype::name, Datatype::setDisplayFormat(), and Datatype::typedefImm.
Referenced by decodeTypedef().
| 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.
| n | is the name of the enumeration |
References enumsize, enumtype, findAdd(), Datatype::hashName(), and Datatype::id.
| TypePointer * TypeFactory::getTypePointer | ( | int4 | s, |
| Datatype * | pt, | ||
| uint4 | ws | ||
| ) |
Construct an absolute pointer data-type.
Allows "pointer to array" to be constructed
| s | is the size of the pointer |
| pt | is the pointed-to data-type |
| ws | is the wordsize associated with the pointer |
References findAdd(), Datatype::getStripped(), and Datatype::hasStripped().
Referenced by ParamListStandard::assignMap(), ParamListStandardOut::assignMap(), ExternRefSymbol::buildNameType(), TypePointer::downChain(), TypePointerRel::downChain(), Funcdata::forceFacingType(), TypeOpLoad::getInputCast(), TypeOpStore::getInputCast(), TypeOpCbranch::getInputLocal(), TypeOpCallind::getInputLocal(), TypeOpIndirect::getInputLocal(), TypeOpPtrsub::getOutputToken(), getTypePointerNoDepth(), TypePointerRel::markEphemeral(), Funcdata::prepareThisPointer(), TypeOpEqual::propagateAcrossCompare(), TypeOpIntAdd::propagateAddIn2Out(), TypeOpCopy::propagateType(), TypeOpIntXor::propagateType(), TypeOpIntAnd::propagateType(), TypeOpIntOr::propagateType(), TypeOpMulti::propagateType(), TypeOpIndirect::propagateType(), TypeOpSegment::propagateType(), ResolvedUnion::ResolvedUnion(), ScoreUnionFields::scoreTrialUp(), Funcdata::spacebase(), and Funcdata::spacebaseConstant().
| TypePointer * TypeFactory::getTypePointer | ( | int4 | s, |
| Datatype * | pt, | ||
| uint4 | ws, | ||
| const string & | n | ||
| ) |
Construct a named pointer data-type.
The given name is attached, which distinguishes the returned data-type from other unnamed (or differently named) pointers that otherwise have the same attributes.
| s | is the size of the pointer |
| pt | is the pointed-to data-type |
| ws | is the wordsize associated with the pointer |
| n | is the given name to attach to the pointer |
References findAdd(), Datatype::getStripped(), Datatype::hashName(), Datatype::hasStripped(), Datatype::id, and Datatype::name.
| TypePointer * TypeFactory::getTypePointerNoDepth | ( | int4 | s, |
| Datatype * | pt, | ||
| uint4 | ws | ||
| ) |
Construct a depth limited pointer data-type.
| s | is the size of the pointer |
| pt | is the pointed-to data-type |
| ws | is the wordsize associated with the pointer |
References getBase(), Datatype::getMetatype(), Datatype::getSize(), getTypePointer(), TYPE_PTR, and TYPE_UNKNOWN.
Referenced by TypeOpLoad::propagateType(), and TypeOpStore::propagateType().
| TypePointerRel * TypeFactory::getTypePointerRel | ( | int4 | sz, |
| Datatype * | parent, | ||
| Datatype * | ptrTo, | ||
| int4 | ws, | ||
| int4 | off, | ||
| const string & | nm | ||
| ) |
Build a named pointer offset into a larger container.
The resulting data-type is named and not ephemeral and will display as a formal data-type in decompiler output.
| sz | is the size in bytes of the pointer |
| parent | is data-type of the parent container being indirectly pointed to |
| ptrTo | is the data-type being pointed directly to |
| ws | is the addressable unit size of pointed to data |
| off | is the offset of the pointed-to data-type relative to the container |
| nm | is the name to associate with the pointer |
References findAdd(), Datatype::hashName(), Datatype::id, and Datatype::name.
| TypePointerRel * TypeFactory::getTypePointerRel | ( | TypePointer * | parentPtr, |
| Datatype * | ptrTo, | ||
| int4 | off | ||
| ) |
Get pointer offset relative to a container.
Find/create a pointer data-type that points at a known offset relative to a containing data-type. The resulting data-type is unnamed and ephemeral.
| parentPtr | is a model pointer data-type, pointing to the containing data-type |
| ptrTo | is the data-type being pointed directly to |
| off | is the offset of the pointed-to data-type relative to the container |
References findAdd(), TypePointerRel::markEphemeral(), TypePointer::ptrto, Datatype::size, and TypePointer::wordsize.
Referenced by IfcPointerSetting::execute(), and TypeOpIntAdd::propagateAddIn2Out().
| TypePointer * TypeFactory::getTypePointerStripArray | ( | int4 | s, |
| Datatype * | pt, | ||
| uint4 | ws | ||
| ) |
Construct a pointer data-type, stripping an ARRAY level.
This creates a pointer to a given data-type. If the given data-type is an array, the TYPE_ARRAY property is stripped off, and a pointer to the array element data-type is returned.
| s | is the size of the pointer |
| pt | is the pointed-to data-type |
| ws | is the wordsize associated with the pointer |
References findAdd(), Datatype::getMetatype(), Datatype::getStripped(), Datatype::hasStripped(), and TYPE_ARRAY.
Referenced by TypePointer::downChain(), ScoreUnionFields::ScoreUnionFields(), and Funcdata::spacebaseConstant().
| TypePointer * TypeFactory::getTypePointerWithSpace | ( | Datatype * | ptrTo, |
| AddrSpace * | spc, | ||
| const string & | nm | ||
| ) |
Build a named pointer with an address space attribute.
The new data-type acts like a typedef of a normal pointer but can affect the resolution of constants by the type propagation system.
| ptrTo | is the data-type being pointed directly to |
| spc | is the address space to associate with the pointer |
| nm | is the name to associate with the pointer |
References findAdd(), Datatype::hashName(), Datatype::id, and Datatype::name.
Referenced by IfcPointerSetting::execute().
| TypeSpacebase * TypeFactory::getTypeSpacebase | ( | AddrSpace * | id, |
| const Address & | addr | ||
| ) |
Create a "spacebase" type.
Creates the special TypeSpacebase with an associated address space and scope
| id | is the address space |
| addr | specifies the function scope, or isInvalid() for global scope |
References findAdd(), and glb.
Referenced by Funcdata::spacebase(), and Funcdata::spacebaseConstant().
| TypeStruct * TypeFactory::getTypeStruct | ( | const string & | n | ) |
Create an (empty) structure.
The created structure will be incomplete and have no fields. They must be added later.
| n | is the name of the structure |
References findAdd(), Datatype::hashName(), Datatype::id, and Datatype::name.
|
private |
Create a default "unicode" type.
This creates a multi-byte character data-type (using UTF16 or UTF32 encoding)
| nm | is the name to give the data-type |
| sz | is the size of the data-type in bytes |
| m | is the presumed meta-type when treating the character as an integer |
References findAdd(), Datatype::hashName(), and Datatype::id.
Referenced by setCoreType().
| TypeUnion * TypeFactory::getTypeUnion | ( | const string & | n | ) |
Create an (empty) union.
The created union will be incomplete and have no fields. They must be added later.
| n | is the name of the union |
References findAdd(), Datatype::hashName(), Datatype::id, and Datatype::name.
| TypeVoid * TypeFactory::getTypeVoid | ( | void | ) |
Get the "void" data-type.
There should be exactly one instance of the "void" Datatype object, which this fetches
References TypeVoid::clone(), Datatype::getName(), Datatype::hashName(), Datatype::id, nametree, tree, TYPE_FLOAT, TYPE_VOID, and typecache.
Referenced by ActionDefaultParams::apply(), ProtoModel::assignParameterStorage(), PrintC::buildTypeStack(), ProtoStoreSymbol::clearOutput(), Override::decode(), TypeCode::decodePrototype(), decodeTypeNoRef(), IfcProtooverride::execute(), getTypeCode(), FuncProto::paramShift(), Funcdata::prepareThisPointer(), ProtoStoreSymbol::ProtoStoreSymbol(), PrintJava::pushTypeStart(), and setCoreType().
|
private |
Insert pointer into the cross-reference sets.
Internal method for finally inserting a new Datatype pointer
| newtype | is the new pointer |
References Datatype::getId(), Datatype::id, nametree, Datatype::printRaw(), and tree.
Referenced by findAdd(), and getTypedef().
|
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.
| deporder | holds the ordered list of data-types to construct |
| mark | is a "marking" container to prevent cycles |
| ct | is the data-type to have written out |
References Datatype::getDepend(), Datatype::numDepend(), orderRecurse(), and Datatype::typedefImm.
Referenced by dependentOrder(), and orderRecurse().
| void TypeFactory::parseEnumConfig | ( | Decoder & | decoder | ) |
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 ATTRIB_SIGNED, Decoder::closeElement(), ELEM_ENUM, enumsize, enumtype, Decoder::openElement(), Decoder::readBool(), Decoder::readSignedInteger(), TYPE_INT, and TYPE_UINT.
Referenced by Architecture::parseCompilerConfig().
|
private |
Recalculate submeta for pointers to given base data-type.
Search for pointers that match the given ptrto and sub-metatype and change it to the current calculated sub-metatype. A change in the sub-metatype may involve reinserting the pointer data-type in the functional tree.
| base | is the given base data-type |
| sub | is the type of pointer to search for |
References Datatype::getMetatype(), TypePointer::ptrto, Datatype::submeta, tree, and TYPE_PTR.
Referenced by setFields().
| 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.
| name | is the data-type name |
| size | is the size of the data-type |
| meta | is the meta-type of the data-type |
| chartp | is 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 SleighArchitecture::buildTypegrp().
| void TypeFactory::setDisplayFormat | ( | Datatype * | ct, |
| uint4 | format | ||
| ) |
Set the display format associated with the given data-type.
The display format for the data-type is changed based on the given format. A value of zero clears any preexisting format. Otherwise the value can be one of: 1=hex, 2=dec, 4=oct, 8=bin, 16=char
| ct | is the given data-type to change |
| format | is the given format |
References Datatype::setDisplayFormat().
Referenced by IfcForceDatatypeFormat::execute().
| 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.
| namelist | is the list of names in the enumeration |
| vallist | is the corresponding list of values assigned to names in namelist |
| assignlist | is true if the corresponding name in namelist has an assigned value |
| te | is the enumeration object to modify |
References calc_mask(), Datatype::getSize(), TypeEnum::setNameMap(), and tree.
| bool TypeFactory::setFields | ( | vector< TypeField > & | fd, |
| TypeStruct * | ot, | ||
| int4 | fixedsize, | ||
| uint4 | flags | ||
| ) |
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. This method should only be used on an incomplete structure. It will mark the structure as complete.
| fd | is the list of fields to set |
| ot | is the TypeStruct object to modify |
| fixedsize | is 0 or the forced size of the structure |
| flags | are other flags to set on the structure |
References Datatype::flags, Datatype::getMetatype(), Datatype::getName(), Datatype::getSize(), Datatype::isIncomplete(), Datatype::opaque_string, recalcPointerSubmeta(), TypeStruct::setFields(), Datatype::size, SUB_PTR, SUB_PTR_STRUCT, tree, Datatype::type_incomplete, TYPE_VOID, and Datatype::variable_length.
Referenced by decodeStruct(), decodeTypedef(), and decodeUnion().
| bool TypeFactory::setFields | ( | vector< TypeField > & | fd, |
| TypeUnion * | ot, | ||
| int4 | fixedsize, | ||
| uint4 | flags | ||
| ) |
Set fields on a TypeUnion.
If fixedsize is greater than 0, force the final structure to have that size. This method should only be used on an incomplete union. It will mark the union as complete.
| fd | is the list of fields to set |
| ot | is the TypeUnion object to modify |
| fixedsize | is 0 or the forced size of the union |
| flags | are other flags to set on the union |
References Datatype::flags, Datatype::getMetatype(), Datatype::getName(), Datatype::isIncomplete(), TypeUnion::setFields(), Datatype::size, tree, Datatype::type_incomplete, TYPE_VOID, and Datatype::variable_length.
Set the given types name.
This routine renames a Datatype object and fixes up cross-referencing
| ct | is the data-type to rename |
| n | is the new name |
References Datatype::hashName(), Datatype::id, Datatype::name, nametree, and tree.
Set the prototype on a TypeCode.
The given prototype is copied into the given code data-type This method should only be used on an incomplete TypeCode. It will mark the TypeCode as complete.
| fp | is the given prototype to copy |
| newCode | is the given code data-type |
| flags | are additional flags to transfer into the code data-type |
References Datatype::flags, Datatype::isIncomplete(), TypeCode::setPrototype(), tree, Datatype::type_incomplete, and Datatype::variable_length.
Referenced by decodeCode().
| void TypeFactory::setupSizes | ( | void | ) |
Derive some size information from Architecture.
Set up default values for size of "int", structure alignment, and enums.
References align, enumsize, enumtype, AddrSpaceManager::getDefaultSize(), AddrSpace::getSpacebase(), AddrSpaceManager::getStackSpace(), glb, VarnodeData::size, sizeOfInt, sizeOfLong, and TYPE_UINT.
Referenced by Architecture::parseCompilerConfig().