summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h3
-rw-r--r--binaryninjacore.h1
-rw-r--r--highlevelil.cpp8
-rw-r--r--lang/c/pseudoc.cpp5
-rw-r--r--lang/rust/pseudorust.cpp2
5 files changed, 18 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index bcd1ec97..17b9cfa8 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -18489,6 +18489,9 @@ namespace BinaryNinja {
void SetHasCollapsableRegions(bool state);
/*! Starts a new line in the output. */
+ void InitLine();
+
+ /*! Starts a new line in the output. */
void NewLine();
/*! Increases the indentation level by one. */
diff --git a/binaryninjacore.h b/binaryninjacore.h
index b27351ab..bf8de702 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -7961,6 +7961,7 @@ extern "C"
BINARYNINJACOREAPI void BNHighLevelILTokenEmitterSetHasCollapsableRegions(BNHighLevelILTokenEmitter* emitter, bool state);
BINARYNINJACOREAPI void BNFreeHighLevelILTokenEmitter(BNHighLevelILTokenEmitter* emitter);
BINARYNINJACOREAPI void BNHighLevelILTokenEmitterAppend(BNHighLevelILTokenEmitter* emitter, BNInstructionTextToken* token);
+ BINARYNINJACOREAPI void BNHighLevelILTokenEmitterInitLine(BNHighLevelILTokenEmitter* emitter);
BINARYNINJACOREAPI void BNHighLevelILTokenEmitterNewLine(BNHighLevelILTokenEmitter* emitter);
BINARYNINJACOREAPI void BNHighLevelILTokenEmitterIncreaseIndent(BNHighLevelILTokenEmitter* emitter);
BINARYNINJACOREAPI void BNHighLevelILTokenEmitterDecreaseIndent(BNHighLevelILTokenEmitter* emitter);
diff --git a/highlevelil.cpp b/highlevelil.cpp
index 10e2cd6a..606cc772 100644
--- a/highlevelil.cpp
+++ b/highlevelil.cpp
@@ -685,6 +685,12 @@ void HighLevelILTokenEmitter::SetHasCollapsableRegions(bool state)
}
+void HighLevelILTokenEmitter::InitLine()
+{
+ BNHighLevelILTokenEmitterInitLine(m_object);
+}
+
+
void HighLevelILTokenEmitter::NewLine()
{
BNHighLevelILTokenEmitterNewLine(m_object);
@@ -944,4 +950,4 @@ void HighLevelILTokenEmitter::AddNamesForOuterStructureMembers(
newNames.push_back(names[i]);
BNFreeStringList(names, nameCount);
nameList.insert(nameList.begin(), newNames.begin(), newNames.end());
-} \ No newline at end of file
+}
diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp
index 8de510a7..4f2174d6 100644
--- a/lang/c/pseudoc.cpp
+++ b/lang/c/pseudoc.cpp
@@ -681,6 +681,11 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
auto function = m_highLevelIL->GetFunction();
if (instr.ast)
tokens.PrependCollapseIndicator(function, instr);
+
+ // ensure we claim the line address for top level instrs on a line
+ if (instr.operation != HLIL_BLOCK)
+ tokens.InitLine();
+
switch (instr.operation)
{
case HLIL_BLOCK:
diff --git a/lang/rust/pseudorust.cpp b/lang/rust/pseudorust.cpp
index d7e18efc..0f41678f 100644
--- a/lang/rust/pseudorust.cpp
+++ b/lang/rust/pseudorust.cpp
@@ -716,6 +716,8 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
auto function = m_highLevelIL->GetFunction();
if (instr.ast)
tokens.PrependCollapseIndicator(function, instr);
+ if (instr.operation != HLIL_BLOCK)
+ tokens.InitLine();
switch (instr.operation)
{
case HLIL_BLOCK: