summaryrefslogtreecommitdiff
path: root/languagerepresentation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'languagerepresentation.cpp')
-rw-r--r--languagerepresentation.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/languagerepresentation.cpp b/languagerepresentation.cpp
index 0930c0b8..1af38b4b 100644
--- a/languagerepresentation.cpp
+++ b/languagerepresentation.cpp
@@ -4,7 +4,8 @@
using namespace BinaryNinja;
using namespace std;
-LanguageRepresentationFunction::LanguageRepresentationFunction(Architecture* arch, Function* func, HighLevelILFunction* highLevelIL)
+LanguageRepresentationFunction::LanguageRepresentationFunction(
+ LanguageRepresentationFunctionType* type, Architecture* arch, Function* func, HighLevelILFunction* highLevelIL)
{
BNCustomLanguageRepresentationFunction callbacks;
callbacks.context = this;
@@ -20,8 +21,8 @@ LanguageRepresentationFunction::LanguageRepresentationFunction(Architecture* arc
callbacks.getAnnotationStartString = GetAnnotationStartStringCallback;
callbacks.getAnnotationEndString = GetAnnotationEndStringCallback;
AddRefForRegistration();
- m_object = BNCreateCustomLanguageRepresentationFunction(arch->GetObject(), func->GetObject(),
- highLevelIL->GetObject(), &callbacks);
+ m_object = BNCreateCustomLanguageRepresentationFunction(
+ type->GetObject(), arch->GetObject(), func->GetObject(), highLevelIL->GetObject(), &callbacks);
}
@@ -112,6 +113,12 @@ BNHighlightColor LanguageRepresentationFunction::GetHighlight(BasicBlock* block)
}
+Ref<LanguageRepresentationFunctionType> LanguageRepresentationFunction::GetLanguage() const
+{
+ return new CoreLanguageRepresentationFunctionType(BNGetLanguageRepresentationType(m_object));
+}
+
+
Ref<Architecture> LanguageRepresentationFunction::GetArchitecture() const
{
return new CoreArchitecture(BNGetLanguageRepresentationArchitecture(m_object));
@@ -312,6 +319,7 @@ void LanguageRepresentationFunctionType::Register(LanguageRepresentationFunction
callbacks.isValid = IsValidCallback;
callbacks.getTypePrinter = GetTypePrinterCallback;
callbacks.getTypeParser = GetTypeParserCallback;
+ callbacks.getLineFormatter = GetLineFormatterCallback;
callbacks.getFunctionTypeTokens = GetFunctionTypeTokensCallback;
callbacks.freeLines = FreeLinesCallback;
@@ -363,6 +371,16 @@ BNTypeParser* LanguageRepresentationFunctionType::GetTypeParserCallback(void* ct
}
+BNLineFormatter* LanguageRepresentationFunctionType::GetLineFormatterCallback(void* ctxt)
+{
+ LanguageRepresentationFunctionType* type = (LanguageRepresentationFunctionType*)ctxt;
+ Ref<LineFormatter> result = type->GetLineFormatter();
+ if (!result)
+ return nullptr;
+ return result->GetObject();
+}
+
+
BNDisassemblyTextLine* LanguageRepresentationFunctionType::GetFunctionTypeTokensCallback(
void* ctxt, BNFunction* func, BNDisassemblySettings* settings, size_t* count)
{
@@ -472,6 +490,15 @@ Ref<TypeParser> CoreLanguageRepresentationFunctionType::GetTypeParser()
}
+Ref<LineFormatter> CoreLanguageRepresentationFunctionType::GetLineFormatter()
+{
+ BNLineFormatter* formatter = BNGetLanguageRepresentationFunctionTypeLineFormatter(m_object);
+ if (!formatter)
+ return nullptr;
+ return new CoreLineFormatter(formatter);
+}
+
+
vector<DisassemblyTextLine> CoreLanguageRepresentationFunctionType::GetFunctionTypeTokens(
Function* func, DisassemblySettings* settings)
{