diff options
Diffstat (limited to 'type.cpp')
| -rw-r--r-- | type.cpp | 62 |
1 files changed, 42 insertions, 20 deletions
@@ -892,12 +892,6 @@ string Type::GetAutoDebugTypeIdSource() } -bool Type::IsReferenceOfType(BNNamedTypeReferenceClass refType) -{ - return (GetClass() == NamedTypeReferenceClass) && (GetNamedTypeReference()->GetTypeClass() == refType); -} - - QualifiedName Type::GetTypeName() const { BNQualifiedName name = BNTypeGetTypeName(m_object); @@ -1140,6 +1134,16 @@ TypeBuilder& TypeBuilder::SetVolatile(const Confidence<bool>& vltl) } +TypeBuilder& TypeBuilder::SetSigned(const Confidence<bool>& s) +{ + BNBoolWithConfidence bc; + bc.value = s.GetValue(); + bc.confidence = s.GetConfidence(); + BNTypeBuilderSetSigned(m_object, &bc); + return *this; +} + + Confidence<Ref<Type>> TypeBuilder::GetChildType() const { BNTypeWithConfidence type = BNGetTypeBuilderChildType(m_object); @@ -1452,6 +1456,23 @@ TypeBuilder TypeBuilder::ArrayType(const Confidence<Ref<Type>>& type, uint64_t e } +static BNFunctionParameter* GetParamArray(const std::vector<FunctionParameter>& params, size_t& count) +{ + BNFunctionParameter* paramArray = new BNFunctionParameter[params.size()]; + for (size_t i = 0; i < params.size(); i++) + { + paramArray[i].name = (char*)params[i].name.c_str(); + paramArray[i].type = params[i].type->GetObject(); + paramArray[i].typeConfidence = params[i].type.GetConfidence(); + paramArray[i].defaultLocation = params[i].defaultLocation; + paramArray[i].location.type = params[i].location.type; + paramArray[i].location.index = params[i].location.index; + paramArray[i].location.storage = params[i].location.storage; + } + count = params.size(); + return paramArray; +} + TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue, const Confidence<Ref<CallingConvention>>& callingConvention, const std::vector<FunctionParameter>& params, const Confidence<bool>& varArg, @@ -1465,17 +1486,8 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue, callingConventionConf.convention = callingConvention ? callingConvention->GetObject() : nullptr; callingConventionConf.confidence = callingConvention.GetConfidence(); - BNFunctionParameter* paramArray = new BNFunctionParameter[params.size()]; - for (size_t i = 0; i < params.size(); i++) - { - paramArray[i].name = (char*)params[i].name.c_str(); - paramArray[i].type = params[i].type->GetObject(); - paramArray[i].typeConfidence = params[i].type.GetConfidence(); - paramArray[i].defaultLocation = params[i].defaultLocation; - paramArray[i].location.type = params[i].location.type; - paramArray[i].location.index = params[i].location.index; - paramArray[i].location.storage = params[i].location.storage; - } + size_t paramCount = 0; + BNFunctionParameter* paramArray = GetParamArray(params, paramCount); BNBoolWithConfidence varArgConf; varArgConf.value = varArg.GetValue(); @@ -1486,7 +1498,7 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue, stackAdjustConf.confidence = stackAdjust.GetConfidence(); TypeBuilder type(BNCreateFunctionTypeBuilder(&returnValueConf, &callingConventionConf, - paramArray, params.size(), &varArgConf, &stackAdjustConf)); + paramArray, paramCount, &varArgConf, &stackAdjustConf)); delete[] paramArray; return type; } @@ -1502,9 +1514,12 @@ TypeBuilder& TypeBuilder::SetFunctionCanReturn(const Confidence<bool>& canReturn } -bool TypeBuilder::IsReferenceOfType(BNNamedTypeReferenceClass refType) +TypeBuilder& TypeBuilder::SetParameters(const std::vector<FunctionParameter>& params) { - return (GetClass() == NamedTypeReferenceClass) && (GetNamedTypeReference()->GetTypeClass() == refType); + size_t paramCount = 0; + BNFunctionParameter* paramArray = GetParamArray(params, paramCount); + BNSetFunctionTypeBuilderParameters(m_object, paramArray, paramCount); + return *this; } @@ -1526,6 +1541,13 @@ TypeBuilder& TypeBuilder::SetTypeName(const QualifiedName& names) } +TypeBuilder& TypeBuilder::SetAlternateName(const string& name) +{ + BNTypeBuilderSetAlternateName(m_object, name.c_str()); + return *this; +} + + QualifiedName TypeBuilder::GetStructureName() const { BNQualifiedName name = BNTypeBuilderGetStructureName(m_object); |
