summaryrefslogtreecommitdiff
path: root/type.cpp
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2023-07-06 13:40:52 -0400
committerGlenn Smith <glenn@vector35.com>2023-07-07 17:42:18 -0400
commit7598688466960427890036590239565364310171 (patch)
tree1c8680da5ef239926c9dbd78345c4083aed95aba /type.cpp
parent94e476e947cf4cb0734fbd0563286e8443c75b96 (diff)
Expose function "pure" flag to api and typesystem
Diffstat (limited to 'type.cpp')
-rw-r--r--type.cpp54
1 files changed, 48 insertions, 6 deletions
diff --git a/type.cpp b/type.cpp
index 5b5811cd..8affdc37 100644
--- a/type.cpp
+++ b/type.cpp
@@ -635,6 +635,13 @@ Confidence<bool> Type::CanReturn() const
}
+Confidence<bool> Type::IsPure() const
+{
+ BNBoolWithConfidence result = BNIsTypePure(m_object);
+ return Confidence<bool>(result.value, result.confidence);
+}
+
+
Ref<Structure> Type::GetStructure() const
{
BNStructure* s = BNGetTypeStructure(m_object);
@@ -936,9 +943,13 @@ Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
returnRegsConf.count = 0;
returnRegsConf.confidence = 0;
+ BNBoolWithConfidence pureConf;
+ pureConf.value = false;
+ pureConf.confidence = 0;
+
Type* type = new Type(BNCreateFunctionType(
&returnValueConf, &callingConventionConf, paramArray, params.size(), &varArgConf,
- &canReturnConf, &stackAdjustConf, nullptr, nullptr, 0, &returnRegsConf, NoNameType));
+ &canReturnConf, &stackAdjustConf, nullptr, nullptr, 0, &returnRegsConf, NoNameType, &pureConf));
delete[] paramArray;
return type;
}
@@ -952,7 +963,8 @@ Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
const Confidence<int64_t>& stackAdjust,
const std::map<uint32_t, Confidence<int32_t>>& regStackAdjust,
const Confidence<std::vector<uint32_t>>& returnRegs,
- BNNameType ft)
+ BNNameType ft,
+ const Confidence<bool>& pure)
{
BNTypeWithConfidence returnValueConf;
returnValueConf.type = returnValue->GetObject();
@@ -1004,10 +1016,14 @@ Ref<Type> Type::FunctionType(const Confidence<Ref<Type>>& returnValue,
returnRegsConf.count = returnRegs->size();
returnRegsConf.confidence = returnRegs.GetConfidence();
+ BNBoolWithConfidence pureConf;
+ pureConf.value = pure.GetValue();
+ pureConf.confidence = pure.GetConfidence();
+
Type* type = new Type(BNCreateFunctionType(
&returnValueConf, &callingConventionConf, paramArray, params.size(), &varArgConf,
&canReturnConf, &stackAdjustConf, regStackAdjustRegs.data(),
- regStackAdjustValues.data(), regStackAdjust.size(), &returnRegsConf, NoNameType));
+ regStackAdjustValues.data(), regStackAdjust.size(), &returnRegsConf, NoNameType, &pureConf));
delete[] paramArray;
return type;
}
@@ -1432,6 +1448,13 @@ Confidence<bool> TypeBuilder::CanReturn() const
}
+Confidence<bool> TypeBuilder::IsPure() const
+{
+ BNBoolWithConfidence result = BNIsTypeBuilderPure(m_object);
+ return Confidence<bool>(result.value, result.confidence);
+}
+
+
Ref<Structure> TypeBuilder::GetStructure() const
{
BNStructure* s = BNGetTypeBuilderStructure(m_object);
@@ -1772,9 +1795,13 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue,
returnRegsConf.count = 0;
returnRegsConf.confidence = 0;
+ BNBoolWithConfidence pureConf;
+ pureConf.value = false;
+ pureConf.confidence = 0;
+
TypeBuilder type(BNCreateFunctionTypeBuilder(
&returnValueConf, &callingConventionConf, paramArray, paramCount, &varArgConf,
- &canReturnConf, &stackAdjustConf, nullptr, nullptr, 0, &returnRegsConf, NoNameType));
+ &canReturnConf, &stackAdjustConf, nullptr, nullptr, 0, &returnRegsConf, NoNameType, &pureConf));
delete[] paramArray;
return type;
}
@@ -1788,7 +1815,8 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue,
const Confidence<int64_t>& stackAdjust,
const std::map<uint32_t, Confidence<int32_t>>& regStackAdjust,
const Confidence<std::vector<uint32_t>>& returnRegs,
- BNNameType ft)
+ BNNameType ft,
+ const Confidence<bool>& pure)
{
BNTypeWithConfidence returnValueConf;
returnValueConf.type = returnValue->GetObject();
@@ -1840,10 +1868,14 @@ TypeBuilder TypeBuilder::FunctionType(const Confidence<Ref<Type>>& returnValue,
returnRegsConf.count = returnRegs->size();
returnRegsConf.confidence = returnRegs.GetConfidence();
+ BNBoolWithConfidence pureConf;
+ pureConf.value = pure.GetValue();
+ pureConf.confidence = pure.GetConfidence();
+
TypeBuilder type(BNCreateFunctionTypeBuilder(
&returnValueConf, &callingConventionConf, paramArray, params.size(), &varArgConf,
&canReturnConf, &stackAdjustConf, regStackAdjustRegs.data(),
- regStackAdjustValues.data(), regStackAdjust.size(), &returnRegsConf, NoNameType));
+ regStackAdjustValues.data(), regStackAdjust.size(), &returnRegsConf, NoNameType, &pureConf));
delete[] paramArray;
return type;
}
@@ -1859,6 +1891,16 @@ TypeBuilder& TypeBuilder::SetFunctionCanReturn(const Confidence<bool>& canReturn
}
+TypeBuilder& TypeBuilder::SetPure(const Confidence<bool>& pure)
+{
+ BNBoolWithConfidence bc;
+ bc.value = pure.GetValue();
+ bc.confidence = pure.GetConfidence();
+ BNSetTypeBuilderPure(m_object, &bc);
+ return *this;
+}
+
+
TypeBuilder& TypeBuilder::SetParameters(const std::vector<FunctionParameter>& params)
{
size_t paramCount = 0;