summaryrefslogtreecommitdiff
path: root/type.cpp
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2020-11-16 17:51:46 +0800
committerXusheng <xusheng@vector35.com>2021-02-17 12:05:47 +0800
commitd9b1df165f9daad6a5229718ecd0ee50a5ef6bf1 (patch)
tree6307b8c16c80f8203bdb96ebc3d54a8d9f10b3bf /type.cpp
parentb651141704a555cf0b6c53152ab0f70d011ec8af (diff)
add support for type xref and variable xref
Diffstat (limited to 'type.cpp')
-rw-r--r--type.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/type.cpp b/type.cpp
index 0ffb1c63..ead27768 100644
--- a/type.cpp
+++ b/type.cpp
@@ -91,6 +91,12 @@ bool NameList::operator<(const NameList& other) const
}
+bool NameList::operator>(const NameList& other) const
+{
+ return m_name > other.m_name;
+}
+
+
NameList NameList::operator+(const NameList& other) const
{
NameList result(*this);
@@ -962,6 +968,32 @@ Ref<Type> Type::WithReplacedNamedTypeReference(NamedTypeReference* from, NamedTy
}
+bool Type::AddTypeMemberTokens(BinaryView* data, vector<InstructionTextToken>& tokens, int64_t offset,
+ vector<string>& nameList, size_t size, bool indirect)
+{
+ size_t tokenCount;
+ BNInstructionTextToken* list;
+
+ size_t nameCount;
+ char** names = nullptr;
+
+ if (!BNAddTypeMemberTokens(m_object, data->GetObject(), &list, &tokenCount, offset, &names, &nameCount, size, indirect))
+ return false;
+
+ vector<InstructionTextToken> newTokens = InstructionTextToken::ConvertAndFreeInstructionTextTokenList(list, tokenCount);
+ tokens.insert(tokens.end(), newTokens.begin(), newTokens.end());
+
+ nameList.clear();
+ nameList.reserve(nameCount);
+ for (size_t i = 0; i < nameCount; i++)
+ nameList.emplace_back(names[i]);
+
+ BNFreeStringList(names, nameCount);
+
+ return true;
+}
+
+
TypeBuilder::TypeBuilder()
{
m_object = BNCreateVoidTypeBuilder();