summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
Diffstat (limited to 'lang')
-rw-r--r--lang/c/pseudoc.cpp193
-rw-r--r--lang/c/pseudoc.h10
-rw-r--r--lang/rust/pseudorust.cpp203
-rw-r--r--lang/rust/pseudorust.h14
4 files changed, 208 insertions, 212 deletions
diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp
index 4f2174d6..47d566d1 100644
--- a/lang/c/pseudoc.cpp
+++ b/lang/c/pseudoc.cpp
@@ -246,20 +246,20 @@ void PseudoCFunction::AppendSingleSizeToken(
void PseudoCFunction::AppendComparison(const string& comparison, const HighLevelILInstruction& instr,
- HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence,
+ HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence,
std::optional<bool> signedHint)
{
const auto leftExpr = instr.GetLeftExpr();
const auto rightExpr = instr.GetRightExpr();
- GetExprTextInternal(leftExpr, emitter, settings, asFullAst, precedence, false, signedHint);
+ GetExprTextInternal(leftExpr, emitter, settings, precedence, false, signedHint);
emitter.Append(OperationToken, comparison);
- GetExprTextInternal(rightExpr, emitter, settings, asFullAst, precedence, false, signedHint);
+ GetExprTextInternal(rightExpr, emitter, settings, precedence, false, signedHint);
}
void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILInstruction& instr,
- HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence,
+ HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence,
std::optional<bool> signedHint)
{
const auto& twoOperand = instr.AsTwoOperand();
@@ -291,9 +291,9 @@ void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILI
emitter.Append(OperationToken, "COMBINE");
emitter.AppendOpenParen();
- GetExprTextInternal(high, emitter, settings, asFullAst);
+ GetExprTextInternal(high, emitter, settings);
emitter.Append(TextToken, ", ");
- GetExprTextInternal(low, emitter, settings, asFullAst);
+ GetExprTextInternal(low, emitter, settings);
emitter.AppendCloseParen();
}
@@ -317,7 +317,7 @@ void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILI
}
}
- GetExprTextInternal(leftExpr, emitter, settings, asFullAst, leftPrecedence, false, signedHint);
+ GetExprTextInternal(leftExpr, emitter, settings, leftPrecedence, false, signedHint);
auto lessThanZero = [](uint64_t value, uint64_t width) -> bool {
return ((1UL << ((width * 8) - 1UL)) & value) != 0;
@@ -343,7 +343,7 @@ void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILI
}
emitter.Append(OperationToken, operand);
- GetExprTextInternal(rightExpr, emitter, settings, asFullAst, precedence, false, signedHint);
+ GetExprTextInternal(rightExpr, emitter, settings, precedence, false, signedHint);
}
@@ -521,15 +521,14 @@ void PseudoCFunction::AppendFieldTextTokens(const HighLevelILInstruction& var, u
void PseudoCFunction::GetExprText(const HighLevelILInstruction& instr, HighLevelILTokenEmitter& tokens,
- DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence, bool statement)
+ DisassemblySettings* settings, BNOperatorPrecedence precedence, bool statement)
{
- GetExprTextInternal(instr, tokens, settings, asFullAst, precedence, statement);
+ GetExprTextInternal(instr, tokens, settings, precedence, statement);
}
void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, HighLevelILTokenEmitter& tokens,
- DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence, bool statement,
- optional<bool> signedHint)
+ DisassemblySettings* settings, BNOperatorPrecedence precedence, bool statement, optional<bool> signedHint)
{
// The lambdas in this function are here to reduce stack frame size of this function. Without them,
// complex expression can cause the process to crash from a stack overflow.
@@ -699,9 +698,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
// normal source code.
auto next = i;
++next;
- if (asFullAst && (instr.exprIndex == GetHighLevelILFunction()->GetRootExpr().exprIndex) && (exprs.size() > 1) &&
- (next == exprs.end()) && ((*i).operation == HLIL_RET) &&
- ((*i).GetSourceExprs<HLIL_RET>().size() == 0))
+ if (instr.ast && (instr.exprIndex == GetHighLevelILFunction()->GetRootExpr().exprIndex)
+ && (exprs.size() > 1) && (next == exprs.end()) && ((*i).operation == HLIL_RET)
+ && ((*i).GetSourceExprs<HLIL_RET>().size() == 0))
continue;
// If the statement is one that contains additional blocks of code, insert a scope separator
@@ -730,7 +729,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
needSeparator = hasBlocks;
// Emit the lines for the statement itself
- GetExprTextInternal(*i, tokens, settings, true, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(*i, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.NewLine();
}
}();
@@ -743,18 +742,18 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto updateExpr = instr.GetUpdateExpr<HLIL_FOR>();
const auto loopExpr = instr.GetLoopExpr<HLIL_FOR>();
- if (asFullAst)
+ if (instr.ast)
{
tokens.Append(KeywordToken, "for ");
tokens.AppendOpenParen();
if (initExpr.operation != HLIL_NOP)
- GetExprTextInternal(initExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(initExpr, tokens, settings);
tokens.Append(TextToken, "; ");
if (condExpr.operation != HLIL_NOP)
- GetExprTextInternal(condExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(condExpr, tokens, settings);
tokens.Append(TextToken, "; ");
if (updateExpr.operation != HLIL_NOP)
- GetExprTextInternal(updateExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(updateExpr, tokens, settings);
tokens.AppendCloseParen();
if (function->IsInstructionCollapsed(instr))
{
@@ -764,7 +763,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprTextInternal(loopExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(loopExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -789,9 +788,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(KeywordToken, "if ");
tokens.AppendOpenParen();
- GetExprTextInternal(condExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(condExpr, tokens, settings);
tokens.AppendCloseParen();
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -802,7 +801,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
auto scopeType = HighLevelILFunction::GetExprScopeType(trueExpr);
tokens.BeginScope(scopeType);
- GetExprTextInternal(trueExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(trueExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(scopeType);
}
//tokens.SetCurrentExpr(falseExpr);
@@ -810,7 +809,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
tokens.ScopeContinuation(false);
tokens.Append(KeywordToken, "else ");
- GetExprTextInternal(falseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(falseExpr, tokens, settings, TopLevelOperatorPrecedence, true);
}
else if (falseExpr.operation != HLIL_NOP)
{
@@ -826,7 +825,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
auto scopeType = HighLevelILFunction::GetExprScopeType(falseExpr);
tokens.BeginScope(scopeType);
- GetExprTextInternal(falseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(falseExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -847,7 +846,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
GetExprTextInternal(condExpr, tokens, settings);
tokens.AppendCloseParen();
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -858,7 +857,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprTextInternal(loopExpr, tokens, settings, true, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(loopExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -870,7 +869,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
[&]() {
const auto loopExpr = instr.GetLoopExpr<HLIL_DO_WHILE>();
const auto condExpr = instr.GetConditionExpr<HLIL_DO_WHILE>();
- if (asFullAst)
+ if (instr.ast)
{
tokens.Append(KeywordToken, "do");
if (function->IsInstructionCollapsed(instr))
@@ -887,7 +886,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprTextInternal(loopExpr, tokens, settings, true, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(loopExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(scopeType);
tokens.ScopeContinuation(true);
@@ -918,9 +917,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(KeywordToken, "switch ");
tokens.AppendOpenParen();
- GetExprTextInternal(condExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(condExpr, tokens, settings);
tokens.AppendCloseParen();
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -932,7 +931,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.BeginScope(SwitchScopeType);
for (const auto caseExpr: caseExprs)
{
- GetExprTextInternal(caseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(caseExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.NewLine();
}
@@ -948,7 +947,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
else
{
tokens.BeginScope(CaseScopeType);
- GetExprTextInternal(defaultExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(defaultExpr, tokens, settings, TopLevelOperatorPrecedence, true);
tokens.EndScope(CaseScopeType);
tokens.FinalizeScope();
}
@@ -969,13 +968,13 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
const auto& valueExpr = valueExprs[index];
tokens.Append(KeywordToken, "case ");
- GetExprTextInternal(valueExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(valueExpr, tokens, settings);
tokens.Append(TextToken, ":");
if (index != valueExprs.size() - 1)
tokens.NewLine();
}
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -986,7 +985,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
tokens.PrependCollapseIndicator(function, instr);
tokens.BeginScope(CaseScopeType);
- GetExprTextInternal(trueExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, true);
+ GetExprTextInternal(trueExpr, tokens, settings, TopLevelOperatorPrecedence, true);
static const std::vector<BNHighLevelILOperation> operations {
HLIL_CONTINUE, HLIL_NORET, HLIL_UNREACHABLE, HLIL_JUMP, HLIL_GOTO, HLIL_TAILCALL};
@@ -1048,7 +1047,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_ZX>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > UnaryOperatorPrecedence;
@@ -1057,7 +1056,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
AppendSizeToken(instr.size, false, tokens);
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence, false, false);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence, false, false);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1070,7 +1069,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_SX>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > UnaryOperatorPrecedence;
@@ -1079,7 +1078,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
AppendSizeToken(instr.size, true, tokens);
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence, false, true);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence, false, true);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1092,7 +1091,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto destExpr = instr.GetDestExpr<HLIL_CALL>();
const auto parameterExprs = instr.GetParameterExprs<HLIL_CALL>();
- GetExprTextInternal(destExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(destExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenParen();
vector<FunctionParameter> namedParams;
@@ -1129,7 +1128,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
if (!renderedAsString)
- GetExprText(parameterExpr, tokens, settings, asFullAst);
+ GetExprText(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (statement)
@@ -1162,9 +1161,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_ARRAY_INDEX>();
const auto indexExpr = instr.GetIndexExpr<HLIL_ARRAY_INDEX>();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenBracket();
- GetExprTextInternal(indexExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(indexExpr, tokens, settings);
tokens.AppendCloseBracket();
if (statement)
tokens.AppendSemicolon();
@@ -1229,7 +1228,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
appearsDead = false;
}
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, AssignmentOperatorPrecedence);
if (appearsDead)
tokens.EndForceZeroConfidence();
@@ -1454,16 +1453,16 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto high = destExpr.GetHighExpr<HLIL_SPLIT>();
const auto low = destExpr.GetLowExpr<HLIL_SPLIT>();
- GetExprTextInternal(high, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(high, tokens, settings, precedence);
tokens.Append(OperationToken, " = ");
tokens.Append(OperationToken, "HIGH");
AppendSingleSizeToken(high.size, OperationToken, tokens);
tokens.AppendOpenParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
tokens.AppendCloseParen();
tokens.AppendSemicolon();
tokens.NewLine();
- GetExprTextInternal(low, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(low, tokens, settings, precedence);
}
else
{
@@ -1577,7 +1576,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
}
- GetExprTextInternal(destExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(destExpr, tokens, settings, precedence);
if (assignUpdateOperator.has_value() && assignUpdateSource.has_value())
tokens.Append(OperationToken, assignUpdateOperator.value());
else
@@ -1612,14 +1611,13 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else
{
- GetExprTextInternal(assignUpdateSource.value(), tokens, settings, asFullAst,
- AssignmentOperatorPrecedence, false, assignSignedHint);
+ GetExprTextInternal(assignUpdateSource.value(), tokens, settings, AssignmentOperatorPrecedence,
+ false, assignSignedHint);
}
}
else
{
- GetExprTextInternal(
- srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence, false, assignSignedHint);
+ GetExprTextInternal(srcExpr, tokens, settings, AssignmentOperatorPrecedence, false, assignSignedHint);
}
if (isSplit)
@@ -1638,9 +1636,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto destExprs = instr.GetDestExprs<HLIL_ASSIGN_UNPACK>();
const auto firstExpr = destExprs[0];
- GetExprTextInternal(firstExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprTextInternal(firstExpr, tokens, settings, AssignmentOperatorPrecedence);
tokens.Append(OperationToken, " = ");
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, AssignmentOperatorPrecedence);
if (statement)
tokens.AppendSemicolon();
}();
@@ -1672,7 +1670,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(TextToken, "*");
tokens.AppendCloseParen();
}
- GetExprTextInternal(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.Append(OperationToken, " + ");
tokens.AppendIntegerTextToken(instr, fieldOffset, instr.size);
@@ -1700,7 +1698,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(TextToken, "*");
tokens.AppendCloseParen();
}
- GetExprTextInternal(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
if (!settings || settings->IsOptionSet(ShowTypeCasts))
{
tokens.AppendCloseParen();
@@ -1709,7 +1707,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else
{
- GetExprTextInternal(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
}
AppendFieldTextTokens(srcExpr, fieldOffset, memberIndex, instr.size, tokens, false);
@@ -1829,7 +1827,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendCloseParen();
}
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
}
@@ -1847,13 +1845,13 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.Append(AnnotationToken, "/* tailcall */");
tokens.NewLine();
tokens.Append(KeywordToken, "return ");
- GetExprTextInternal(destExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(destExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenParen();
for (size_t index{}; index < parameterExprs.size(); index++)
{
const auto& parameterExpr = parameterExprs[index];
if (index != 0) tokens.Append(TextToken, ", ");
- GetExprTextInternal(parameterExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (statement)
@@ -1868,7 +1866,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
if (parens)
tokens.AppendOpenParen();
tokens.Append(OperationToken, "&");
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1881,7 +1879,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" == ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" == ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1908,7 +1906,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" == ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" == ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
}
@@ -1922,7 +1920,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" != ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" != ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1943,7 +1941,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" != ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" != ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
}
@@ -1964,7 +1962,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SLT)
cmpSigned = true;
- AppendComparison(" < ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" < ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -1984,7 +1982,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SLE)
cmpSigned = true;
- AppendComparison(" <= ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" <= ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2004,7 +2002,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SGE)
cmpSigned = true;
- AppendComparison(" >= ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" >= ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2024,7 +2022,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SGT)
cmpSigned = true;
- AppendComparison(" > ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" > ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2041,7 +2039,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(instr.size == 0 ? " && " : " & ", instr, tokens, settings, asFullAst,
+ AppendTwoOperand(instr.size == 0 ? " && " : " & ", instr, tokens, settings,
instr.size == 0 ? LogicalAndOperatorPrecedence : BitwiseAndOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
@@ -2058,7 +2056,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(instr.size == 0 ? " || " : " | ", instr, tokens, settings, asFullAst,
+ AppendTwoOperand(instr.size == 0 ? " || " : " | ", instr, tokens, settings,
instr.size == 0 ? LogicalOrOperatorPrecedence : BitwiseOrOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
@@ -2073,7 +2071,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseOrOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" ^ ", instr, tokens, settings, asFullAst, BitwiseXorOperatorPrecedence);
+ AppendTwoOperand(" ^ ", instr, tokens, settings, BitwiseXorOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2091,7 +2089,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" + ", instr, tokens, settings, asFullAst, AddOperatorPrecedence);
+ AppendTwoOperand(" + ", instr, tokens, settings, AddOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2117,7 +2115,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
// Yes
tokens.Append(OperationToken, "ADJ");
tokens.AppendOpenParen();
- GetExprTextInternal(left, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(left, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendCloseParen();
return;
}
@@ -2129,7 +2127,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" - ", instr, tokens, settings, asFullAst, SubOperatorPrecedence);
+ AppendTwoOperand(" - ", instr, tokens, settings, SubOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2144,7 +2142,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" - ", instr, tokens, settings, asFullAst, SubOperatorPrecedence);
+ AppendTwoOperand(" - ", instr, tokens, settings, SubOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2157,7 +2155,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > ShiftOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" << ", instr, tokens, settings, asFullAst, ShiftOperatorPrecedence);
+ AppendTwoOperand(" << ", instr, tokens, settings, ShiftOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2171,7 +2169,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > ShiftOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" >> ", instr, tokens, settings, asFullAst, ShiftOperatorPrecedence);
+ AppendTwoOperand(" >> ", instr, tokens, settings, ShiftOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2195,7 +2193,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
mulSigned = false;
else if (instr.operation == HLIL_MULS_DP)
mulSigned = true;
- AppendTwoOperand(" * ", instr, tokens, settings, asFullAst, MultiplyOperatorPrecedence, mulSigned);
+ AppendTwoOperand(" * ", instr, tokens, settings, MultiplyOperatorPrecedence, mulSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2219,7 +2217,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
divSigned = false;
else if (instr.operation == HLIL_DIVS || instr.operation == HLIL_DIVS_DP)
divSigned = true;
- AppendTwoOperand(" / ", instr, tokens, settings, asFullAst, DivideOperatorPrecedence, divSigned);
+ AppendTwoOperand(" / ", instr, tokens, settings, DivideOperatorPrecedence, divSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2242,7 +2240,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
modSigned = false;
else if (instr.operation == HLIL_MODS || instr.operation == HLIL_MODS_DP)
modSigned = true;
- AppendTwoOperand(" % ", instr, tokens, settings, asFullAst, DivideOperatorPrecedence, modSigned);
+ AppendTwoOperand(" % ", instr, tokens, settings, DivideOperatorPrecedence, modSigned);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2425,7 +2423,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
tokens.Append(OperationToken, "-");
tokens.AppendOpenParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence, false, true);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence, false, true);
tokens.AppendCloseParen();
if (parens)
tokens.AppendCloseParen();
@@ -2439,7 +2437,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_FLOAT_CONV>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
const auto floatType =
@@ -2454,7 +2452,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
tokens.Append(TypeNameToken, floatType.c_str());
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2467,7 +2465,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_FLOAT_TO_INT>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
@@ -2477,7 +2475,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
AppendSizeToken(instr.size, true, tokens);
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2492,7 +2490,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool parens = precedence > TernaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, TernaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, TernaryOperatorPrecedence);
tokens.Append(OperationToken, " ? ");
tokens.AppendIntegerTextToken(instr, 1, 1);
tokens.Append(OperationToken, " : ");
@@ -2509,7 +2507,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_INT_TO_FLOAT>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
const auto floatType =
@@ -2524,7 +2522,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
tokens.Append(TypeNameToken, floatType.c_str());
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
@@ -2544,7 +2542,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
{
const auto& parameterExpr = parameterExprs[index];
if (index != 0) tokens.Append(TextToken, ", ");
- GetExprTextInternal(parameterExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (statement)
@@ -2562,7 +2560,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto& srcExpr = srcExprs[index];
if (index == 0) tokens.Append(TextToken, " ");
if (index != 0) tokens.Append(TextToken, ", ");
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst);
+ GetExprTextInternal(srcExpr, tokens, settings);
}
if (statement)
tokens.AppendSemicolon();
@@ -2641,8 +2639,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else
{
- GetExprTextInternal(
- srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
symbolType = OtherSymbolResult;
}
@@ -2698,7 +2695,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else
{
- GetExprTextInternal(srcExpr, tokens, settings, true, AddOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, AddOperatorPrecedence);
}
tokens.Append(OperationToken, " + ");
@@ -2849,7 +2846,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
const auto srcExpr = instr.GetSourceExpr<HLIL_LOW_PART>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprTextInternal(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > UnaryOperatorPrecedence;
@@ -2858,7 +2855,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
tokens.AppendOpenParen();
AppendSizeToken(instr.size, signedHint.value_or(true), tokens);
tokens.AppendCloseParen();
- GetExprTextInternal(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprTextInternal(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (statement)
diff --git a/lang/c/pseudoc.h b/lang/c/pseudoc.h
index 664e7695..024be2f1 100644
--- a/lang/c/pseudoc.h
+++ b/lang/c/pseudoc.h
@@ -24,10 +24,10 @@ class PseudoCFunction: public BinaryNinja::LanguageRepresentationFunction
void AppendSizeToken(size_t size, bool isSigned, BinaryNinja::HighLevelILTokenEmitter& emitter);
void AppendSingleSizeToken(size_t size, BNInstructionTextTokenType type, BinaryNinja::HighLevelILTokenEmitter& emitter);
void AppendComparison(const std::string& comparison, const BinaryNinja::HighLevelILInstruction& instr,
- BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings, bool asFullAst,
+ BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings,
BNOperatorPrecedence precedence, std::optional<bool> signedHint = std::nullopt);
void AppendTwoOperand(const std::string& operand, const BinaryNinja::HighLevelILInstruction& instr,
- BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings, bool asFullAst,
+ BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings,
BNOperatorPrecedence precedence, std::optional<bool> signedHint = std::nullopt);
void AppendTwoOperandFunction(const std::string& function, const BinaryNinja::HighLevelILInstruction& instr,
BinaryNinja::HighLevelILTokenEmitter& tokens, BinaryNinja::DisassemblySettings* settings, bool sizeToken = true);
@@ -36,15 +36,15 @@ class PseudoCFunction: public BinaryNinja::LanguageRepresentationFunction
void AppendFieldTextTokens(const BinaryNinja::HighLevelILInstruction& var, uint64_t offset, size_t memberIndex, size_t size,
BinaryNinja::HighLevelILTokenEmitter& tokens, bool deref, bool displayDeref = true);
void GetExprTextInternal(const BinaryNinja::HighLevelILInstruction& instr,
- BinaryNinja::HighLevelILTokenEmitter& tokens, BinaryNinja::DisassemblySettings* settings, bool asFullAst = true,
+ BinaryNinja::HighLevelILTokenEmitter& tokens, BinaryNinja::DisassemblySettings* settings,
BNOperatorPrecedence precedence = TopLevelOperatorPrecedence, bool statement = false,
std::optional<bool> signedHint = std::nullopt);
protected:
void InitTokenEmitter(BinaryNinja::HighLevelILTokenEmitter& tokens) override;
void GetExprText(const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens,
- BinaryNinja::DisassemblySettings* settings, bool asFullAst = true,
- BNOperatorPrecedence precedence = TopLevelOperatorPrecedence, bool statement = false) override;
+ BinaryNinja::DisassemblySettings* settings, BNOperatorPrecedence precedence = TopLevelOperatorPrecedence,
+ bool statement = false) override;
void BeginLines(
const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens) override;
void EndLines(
diff --git a/lang/rust/pseudorust.cpp b/lang/rust/pseudorust.cpp
index 0f41678f..d12b8e32 100644
--- a/lang/rust/pseudorust.cpp
+++ b/lang/rust/pseudorust.cpp
@@ -250,20 +250,20 @@ void PseudoRustFunction::AppendSingleSizeToken(
void PseudoRustFunction::AppendComparison(const string& comparison, const HighLevelILInstruction& instr,
- HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence,
+ HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence,
std::optional<bool> signedHint)
{
const auto leftExpr = instr.GetLeftExpr();
const auto rightExpr = instr.GetRightExpr();
- GetExprText(leftExpr, emitter, settings, asFullAst, precedence, InnerExpression, signedHint);
+ GetExprText(leftExpr, emitter, settings, precedence, InnerExpression, signedHint);
emitter.Append(OperationToken, comparison);
- GetExprText(rightExpr, emitter, settings, asFullAst, precedence, InnerExpression, signedHint);
+ GetExprText(rightExpr, emitter, settings, precedence, InnerExpression, signedHint);
}
void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevelILInstruction& instr,
- HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence,
+ HighLevelILTokenEmitter& emitter, DisassemblySettings* settings, BNOperatorPrecedence precedence,
std::optional<bool> signedHint)
{
const auto& twoOperand = instr.AsTwoOperand();
@@ -295,9 +295,9 @@ void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevel
emitter.Append(OperationToken, "COMBINE");
emitter.AppendOpenParen();
- GetExprText(high, emitter, settings, asFullAst);
+ GetExprText(high, emitter, settings);
emitter.Append(TextToken, ", ");
- GetExprText(low, emitter, settings, asFullAst);
+ GetExprText(low, emitter, settings);
emitter.AppendCloseParen();
}
@@ -306,25 +306,25 @@ void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevel
const auto exprType = leftExpr.GetType();
if (exprType && exprType->IsPointer())
{
- GetExprText(leftExpr, emitter, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprText(leftExpr, emitter, settings, MemberAndFunctionOperatorPrecedence);
emitter.Append(TextToken, ".");
emitter.Append(OperationToken, "byte_offset");
emitter.AppendOpenParen();
if (operand == " - ")
{
emitter.Append(OperationToken, "-");
- GetExprText(rightExpr, emitter, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprText(rightExpr, emitter, settings, UnaryOperatorPrecedence);
}
else
{
- GetExprText(rightExpr, emitter, settings, asFullAst);
+ GetExprText(rightExpr, emitter, settings);
}
emitter.AppendCloseParen();
return;
}
}
- GetExprText(leftExpr, emitter, settings, asFullAst, leftPrecedence, InnerExpression, signedHint);
+ GetExprText(leftExpr, emitter, settings, leftPrecedence, InnerExpression, signedHint);
auto lessThanZero = [](uint64_t value, uint64_t width) -> bool {
return ((1UL << ((width * 8) - 1UL)) & value) != 0;
@@ -350,7 +350,7 @@ void PseudoRustFunction::AppendTwoOperand(const string& operand, const HighLevel
}
emitter.Append(OperationToken, operand);
- GetExprText(rightExpr, emitter, settings, asFullAst, precedence, InnerExpression, signedHint);
+ GetExprText(rightExpr, emitter, settings, precedence, InnerExpression, signedHint);
}
@@ -563,7 +563,7 @@ bool PseudoRustFunction::IsMutable(const Variable& var) const
void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLevelILTokenEmitter& tokens,
- DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence, ExpressionType exprType,
+ DisassemblySettings* settings, BNOperatorPrecedence precedence, ExpressionType exprType,
std::optional<bool> signedHint)
{
// The lambdas in this function are here to reduce stack frame size of this function. Without them,
@@ -731,9 +731,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
// normal source code.
auto next = i;
++next;
- if (asFullAst && (instr.exprIndex == GetHighLevelILFunction()->GetRootExpr().exprIndex) && (exprs.size() > 1) &&
- (next == exprs.end()) && ((*i).operation == HLIL_RET) &&
- ((*i).GetSourceExprs<HLIL_RET>().size() == 0))
+ if (instr.ast && (instr.exprIndex == GetHighLevelILFunction()->GetRootExpr().exprIndex)
+ && (exprs.size() > 1) && (next == exprs.end()) && ((*i).operation == HLIL_RET)
+ && ((*i).GetSourceExprs<HLIL_RET>().size() == 0))
continue;
// If the statement is one that contains additional blocks of code, insert a scope separator
@@ -762,7 +762,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
needSeparator = hasBlocks;
// Emit the lines for the statement itself
- GetExprText(*i, tokens, settings, true, TopLevelOperatorPrecedence,
+ GetExprText(*i, tokens, settings, TopLevelOperatorPrecedence,
exprType == TrailingStatementExpression && next == exprs.end() ?
TrailingStatementExpression : StatementExpression);
tokens.NewLine();
@@ -777,7 +777,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto updateExpr = instr.GetUpdateExpr<HLIL_FOR>();
const auto loopExpr = instr.GetLoopExpr<HLIL_FOR>();
- if (asFullAst)
+ if (instr.ast)
{
tokens.Append(KeywordToken, "for ");
@@ -804,12 +804,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (stepBy)
tokens.AppendOpenParen();
- GetExprText(initExpr.GetSourceExpr<HLIL_VAR_INIT>(), tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprText(
+ initExpr.GetSourceExpr<HLIL_VAR_INIT>(), tokens, settings, AssignmentOperatorPrecedence);
if (condExpr.operation == HLIL_CMP_SLT || condExpr.operation == HLIL_CMP_ULT)
tokens.Append(TextToken, "..");
else
tokens.Append(TextToken, "..=");
- GetExprText(condExpr.GetRightExpr(), tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprText(condExpr.GetRightExpr(), tokens, settings, AssignmentOperatorPrecedence);
if (stepBy)
{
@@ -817,8 +818,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.Append(TextToken, ".");
tokens.Append(OperationToken, "step_by");
tokens.AppendOpenParen();
- GetExprText(updateExpr.GetSourceExpr<HLIL_ASSIGN>().GetRightExpr<HLIL_ADD>(),
- tokens, settings, asFullAst);
+ GetExprText(updateExpr.GetSourceExpr<HLIL_ASSIGN>().GetRightExpr<HLIL_ADD>(), tokens, settings);
tokens.AppendCloseParen();
}
}
@@ -826,13 +826,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
// For loop isn't directly representable in standard Rust
if (initExpr.operation != HLIL_NOP)
- GetExprText(initExpr, tokens, settings, asFullAst);
+ GetExprText(initExpr, tokens, settings);
tokens.Append(TextToken, "; ");
if (condExpr.operation != HLIL_NOP)
- GetExprText(condExpr, tokens, settings, asFullAst);
+ GetExprText(condExpr, tokens, settings);
tokens.Append(TextToken, "; ");
if (updateExpr.operation != HLIL_NOP)
- GetExprText(updateExpr, tokens, settings, asFullAst);
+ GetExprText(updateExpr, tokens, settings);
}
if (function->IsInstructionCollapsed(instr))
@@ -843,7 +843,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprText(loopExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, StatementExpression);
+ GetExprText(loopExpr, tokens, settings, TopLevelOperatorPrecedence, StatementExpression);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -863,8 +863,8 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto falseExpr = instr.GetFalseExpr<HLIL_IF>();
tokens.Append(KeywordToken, "if ");
- GetExprText(condExpr, tokens, settings, asFullAst);
- if (!asFullAst)
+ GetExprText(condExpr, tokens, settings);
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -875,7 +875,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
auto scopeType = HighLevelILFunction::GetExprScopeType(trueExpr);
tokens.BeginScope(scopeType);
- GetExprText(trueExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(trueExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
tokens.EndScope(scopeType);
}
//tokens.SetCurrentExpr(falseExpr);
@@ -883,7 +883,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
tokens.ScopeContinuation(false);
tokens.Append(KeywordToken, "else ");
- GetExprText(falseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(falseExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
}
else if (falseExpr.operation != HLIL_NOP)
{
@@ -898,7 +898,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
auto scopeType = HighLevelILFunction::GetExprScopeType(falseExpr);
tokens.BeginScope(scopeType);
- GetExprText(falseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(falseExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -924,7 +924,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.Append(KeywordToken, "while ");
GetExprText(condExpr, tokens, settings);
}
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -935,7 +935,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprText(loopExpr, tokens, settings, true, TopLevelOperatorPrecedence, StatementExpression);
+ GetExprText(loopExpr, tokens, settings, TopLevelOperatorPrecedence, StatementExpression);
tokens.EndScope(scopeType);
tokens.FinalizeScope();
}
@@ -946,7 +946,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
[&]() {
const auto loopExpr = instr.GetLoopExpr<HLIL_DO_WHILE>();
const auto condExpr = instr.GetConditionExpr<HLIL_DO_WHILE>();
- if (asFullAst)
+ if (instr.ast)
{
tokens.Append(KeywordToken, "do");
if (function->IsInstructionCollapsed(instr))
@@ -961,7 +961,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
auto scopeType = HighLevelILFunction::GetExprScopeType(loopExpr);
tokens.BeginScope(scopeType);
- GetExprText(loopExpr, tokens, settings, true, TopLevelOperatorPrecedence, StatementExpression);
+ GetExprText(loopExpr, tokens, settings, TopLevelOperatorPrecedence, StatementExpression);
tokens.EndScope(scopeType);
tokens.ScopeContinuation(true);
tokens.Append(KeywordToken, "while ");
@@ -986,9 +986,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto defaultExpr = instr.GetDefaultExpr<HLIL_SWITCH>();
tokens.Append(KeywordToken, "match ");
- GetExprText(condExpr, tokens, settings, asFullAst);
+ GetExprText(condExpr, tokens, settings);
tokens.BeginScope(SwitchScopeType);
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -999,7 +999,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
for (const auto caseExpr: caseExprs)
{
- GetExprText(caseExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(caseExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
tokens.NewLine();
}
@@ -1015,7 +1015,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
else
{
tokens.BeginScope(CaseScopeType);
- GetExprText(defaultExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(defaultExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
tokens.EndScope(CaseScopeType);
tokens.FinalizeScope();
}
@@ -1038,11 +1038,11 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto& valueExpr = valueExprs[index];
if (index != 0)
tokens.Append(TextToken, " | ");
- GetExprText(valueExpr, tokens, settings, asFullAst);
+ GetExprText(valueExpr, tokens, settings);
}
tokens.Append(TextToken, " =>");
- if (!asFullAst)
+ if (!instr.ast)
return;
if (function->IsInstructionCollapsed(instr))
@@ -1052,7 +1052,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
else
{
tokens.BeginScope(CaseScopeType);
- GetExprText(trueExpr, tokens, settings, asFullAst, TopLevelOperatorPrecedence, exprType);
+ GetExprText(trueExpr, tokens, settings, TopLevelOperatorPrecedence, exprType);
tokens.EndScope(CaseScopeType);
tokens.FinalizeScope();
}
@@ -1080,13 +1080,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_ZX>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence, InnerExpression, false);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence, InnerExpression, false);
tokens.Append(KeywordToken, " as ");
AppendSizeToken(instr.size, false, tokens);
if (parens)
@@ -1101,13 +1101,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_SX>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence, InnerExpression, true);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence, InnerExpression, true);
tokens.Append(KeywordToken, " as ");
AppendSizeToken(instr.size, true, tokens);
if (parens)
@@ -1122,7 +1122,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto destExpr = instr.GetDestExpr<HLIL_CALL>();
const auto parameterExprs = instr.GetParameterExprs<HLIL_CALL>();
- GetExprText(destExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprText(destExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenParen();
vector<FunctionParameter> namedParams;
@@ -1159,7 +1159,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
if (!renderedAsString)
- GetExprText(parameterExpr, tokens, settings, asFullAst);
+ GetExprText(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -1192,9 +1192,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_ARRAY_INDEX>();
const auto indexExpr = instr.GetIndexExpr<HLIL_ARRAY_INDEX>();
- GetExprText(srcExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenBracket();
- GetExprText(indexExpr, tokens, settings, asFullAst);
+ GetExprText(indexExpr, tokens, settings);
tokens.AppendCloseBracket();
if (exprType != InnerExpression)
tokens.AppendSemicolon();
@@ -1263,7 +1263,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
appearsDead = false;
}
- GetExprText(srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, AssignmentOperatorPrecedence);
if (appearsDead)
tokens.EndForceZeroConfidence();
@@ -1494,16 +1494,16 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto high = destExpr.GetHighExpr<HLIL_SPLIT>();
const auto low = destExpr.GetLowExpr<HLIL_SPLIT>();
- GetExprText(high, tokens, settings, asFullAst, precedence);
+ GetExprText(high, tokens, settings, precedence);
tokens.Append(OperationToken, " = ");
tokens.Append(OperationToken, "HIGH");
AppendSingleSizeToken(high.size, OperationToken, tokens);
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
tokens.AppendCloseParen();
tokens.AppendSemicolon();
tokens.NewLine();
- GetExprText(low, tokens, settings, asFullAst, precedence);
+ GetExprText(low, tokens, settings, precedence);
}
else
{
@@ -1617,7 +1617,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
}
- GetExprText(destExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(destExpr, tokens, settings, precedence);
if (assignUpdateOperator.has_value() && assignUpdateSource.has_value())
tokens.Append(OperationToken, assignUpdateOperator.value());
else
@@ -1652,14 +1652,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
else
{
- GetExprText(assignUpdateSource.value(), tokens, settings, asFullAst, AssignmentOperatorPrecedence,
+ GetExprText(assignUpdateSource.value(), tokens, settings, AssignmentOperatorPrecedence,
InnerExpression, assignSignHint);
}
}
else
{
- GetExprText(srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence, InnerExpression,
- assignSignHint);
+ GetExprText(srcExpr, tokens, settings, AssignmentOperatorPrecedence, InnerExpression, assignSignHint);
}
if (isSplit)
@@ -1678,9 +1677,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto destExprs = instr.GetDestExprs<HLIL_ASSIGN_UNPACK>();
const auto firstExpr = destExprs[0];
- GetExprText(firstExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprText(firstExpr, tokens, settings, AssignmentOperatorPrecedence);
tokens.Append(OperationToken, " = ");
- GetExprText(srcExpr, tokens, settings, asFullAst, AssignmentOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, AssignmentOperatorPrecedence);
if (exprType != InnerExpression)
tokens.AppendSemicolon();
}();
@@ -1700,7 +1699,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (!settings || settings->IsOptionSet(ShowTypeCasts))
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.Append(TextToken, ".");
tokens.Append(OperationToken, "byte_offset");
@@ -1737,7 +1736,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.AppendOpenParen();
srcPrecedence = LowUnaryOperatorPrecedence;
}
- GetExprText(srcExpr, tokens, settings, true, srcPrecedence);
+ GetExprText(srcExpr, tokens, settings, srcPrecedence);
if (!settings || settings->IsOptionSet(ShowTypeCasts))
{
tokens.Append(KeywordToken, " as ");
@@ -1754,7 +1753,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
else
{
- GetExprText(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
}
AppendFieldTextTokens(srcExpr, fieldOffset, memberIndex, instr.size, tokens, false);
@@ -1878,7 +1877,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
srcPrecedence = LowUnaryOperatorPrecedence;
}
- GetExprText(srcExpr, tokens, settings, asFullAst, srcPrecedence);
+ GetExprText(srcExpr, tokens, settings, srcPrecedence);
if (!settings || settings->IsOptionSet(ShowTypeCasts))
{
@@ -1911,13 +1910,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.NewLine();
if (exprType != TrailingStatementExpression)
tokens.Append(KeywordToken, "return ");
- GetExprText(destExpr, tokens, settings, asFullAst, MemberAndFunctionOperatorPrecedence);
+ GetExprText(destExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendOpenParen();
for (size_t index{}; index < parameterExprs.size(); index++)
{
const auto& parameterExpr = parameterExprs[index];
if (index != 0) tokens.Append(TextToken, ", ");
- GetExprText(parameterExpr, tokens, settings, asFullAst);
+ GetExprText(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (exprType == StatementExpression)
@@ -1932,7 +1931,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (parens)
tokens.AppendOpenParen();
tokens.Append(OperationToken, "&");
- GetExprText(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, UnaryOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -1946,7 +1945,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" == ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" == ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -1960,7 +1959,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > EqualityOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendComparison(" != ", instr, tokens, settings, asFullAst, EqualityOperatorPrecedence);
+ AppendComparison(" != ", instr, tokens, settings, EqualityOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -1980,7 +1979,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SLT)
cmpSigned = true;
- AppendComparison(" < ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" < ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2000,7 +1999,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SLE)
cmpSigned = true;
- AppendComparison(" <= ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" <= ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2020,7 +2019,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SGE)
cmpSigned = true;
- AppendComparison(" >= ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" >= ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2040,7 +2039,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
cmpSigned = false;
else if (instr.operation == HLIL_CMP_SGT)
cmpSigned = true;
- AppendComparison(" > ", instr, tokens, settings, asFullAst, CompareOperatorPrecedence, cmpSigned);
+ AppendComparison(" > ", instr, tokens, settings, CompareOperatorPrecedence, cmpSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2057,7 +2056,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(instr.size == 0 ? " && " : " & ", instr, tokens, settings, asFullAst,
+ AppendTwoOperand(instr.size == 0 ? " && " : " & ", instr, tokens, settings,
instr.size == 0 ? LogicalAndOperatorPrecedence : BitwiseAndOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
@@ -2074,7 +2073,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(instr.size == 0 ? " || " : " | ", instr, tokens, settings, asFullAst,
+ AppendTwoOperand(instr.size == 0 ? " || " : " | ", instr, tokens, settings,
instr.size == 0 ? LogicalOrOperatorPrecedence : BitwiseOrOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
@@ -2089,7 +2088,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
precedence == BitwiseOrOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" ^ ", instr, tokens, settings, asFullAst, BitwiseXorOperatorPrecedence);
+ AppendTwoOperand(" ^ ", instr, tokens, settings, BitwiseXorOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2119,7 +2118,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" + ", instr, tokens, settings, asFullAst, opPrecedence);
+ AppendTwoOperand(" + ", instr, tokens, settings, opPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2145,7 +2144,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
// Yes
tokens.Append(OperationToken, "ADJ");
tokens.AppendOpenParen();
- GetExprText(left, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprText(left, tokens, settings, MemberAndFunctionOperatorPrecedence);
tokens.AppendCloseParen();
return;
}
@@ -2168,7 +2167,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" - ", instr, tokens, settings, asFullAst, opPrecedence);
+ AppendTwoOperand(" - ", instr, tokens, settings, opPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2183,7 +2182,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
precedence == BitwiseXorOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" - ", instr, tokens, settings, asFullAst, SubOperatorPrecedence);
+ AppendTwoOperand(" - ", instr, tokens, settings, SubOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2196,7 +2195,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > ShiftOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" << ", instr, tokens, settings, asFullAst, ShiftOperatorPrecedence);
+ AppendTwoOperand(" << ", instr, tokens, settings, ShiftOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2210,7 +2209,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > ShiftOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- AppendTwoOperand(" >> ", instr, tokens, settings, asFullAst, ShiftOperatorPrecedence);
+ AppendTwoOperand(" >> ", instr, tokens, settings, ShiftOperatorPrecedence);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2234,7 +2233,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
mulSigned = false;
else if (instr.operation == HLIL_MULS_DP)
mulSigned = true;
- AppendTwoOperand(" * ", instr, tokens, settings, asFullAst, MultiplyOperatorPrecedence, mulSigned);
+ AppendTwoOperand(" * ", instr, tokens, settings, MultiplyOperatorPrecedence, mulSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2258,7 +2257,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
divSigned = false;
else if (instr.operation == HLIL_DIVS || instr.operation == HLIL_DIVS_DP)
divSigned = true;
- AppendTwoOperand(" / ", instr, tokens, settings, asFullAst, DivideOperatorPrecedence, divSigned);
+ AppendTwoOperand(" / ", instr, tokens, settings, DivideOperatorPrecedence, divSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2281,7 +2280,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
modSigned = false;
else if (instr.operation == HLIL_MODS || instr.operation == HLIL_MODS_DP)
modSigned = true;
- AppendTwoOperand(" % ", instr, tokens, settings, asFullAst, DivideOperatorPrecedence, modSigned);
+ AppendTwoOperand(" % ", instr, tokens, settings, DivideOperatorPrecedence, modSigned);
if (parens)
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2443,7 +2442,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
tokens.AppendOpenParen();
tokens.Append(OperationToken, "-");
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, UnaryOperatorPrecedence, InnerExpression, true);
+ GetExprText(srcExpr, tokens, settings, UnaryOperatorPrecedence, InnerExpression, true);
tokens.AppendCloseParen();
if (parens)
tokens.AppendCloseParen();
@@ -2457,7 +2456,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_FLOAT_CONV>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
const auto floatType = "f" + std::to_string(instr.size * 8);
@@ -2465,7 +2464,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
tokens.Append(TypeNameToken, floatType.c_str());
if (parens)
@@ -2480,14 +2479,14 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_FLOAT_TO_INT>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
AppendSizeToken(instr.size, true, tokens);
if (parens)
@@ -2504,7 +2503,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
AppendSizeToken(instr.size, true, tokens);
if (parens)
@@ -2519,7 +2518,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_INT_TO_FLOAT>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
const auto floatType = "f" + std::to_string(instr.size * 8);
@@ -2527,7 +2526,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
tokens.Append(TypeNameToken, floatType.c_str());
if (parens)
@@ -2549,7 +2548,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
{
const auto& parameterExpr = parameterExprs[index];
if (index != 0) tokens.Append(TextToken, ", ");
- GetExprText(parameterExpr, tokens, settings, asFullAst);
+ GetExprText(parameterExpr, tokens, settings);
}
tokens.AppendCloseParen();
if (exprType != InnerExpression)
@@ -2561,11 +2560,11 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
[&]() {
const auto srcExprs = instr.GetSourceExprs<HLIL_RET>();
- if (!asFullAst || exprType != TrailingStatementExpression)
+ if (!instr.ast || exprType != TrailingStatementExpression)
tokens.Append(KeywordToken, "return");
if (srcExprs.size() != 0)
{
- if (!asFullAst || exprType != TrailingStatementExpression)
+ if (!instr.ast || exprType != TrailingStatementExpression)
tokens.Append(TextToken, " ");
if (srcExprs.size() > 1)
tokens.AppendOpenParen();
@@ -2574,7 +2573,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto& srcExpr = srcExprs[index];
if (index != 0)
tokens.Append(TextToken, ", ");
- GetExprText(srcExpr, tokens, settings, asFullAst);
+ GetExprText(srcExpr, tokens, settings);
}
if (srcExprs.size() > 1)
tokens.AppendCloseParen();
@@ -2656,7 +2655,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
else
{
- GetExprText(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
symbolType = OtherSymbolResult;
}
@@ -2699,7 +2698,7 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
}
else
{
- GetExprText(srcExpr, tokens, settings, true, MemberAndFunctionOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, MemberAndFunctionOperatorPrecedence);
}
tokens.Append(TextToken, ".");
@@ -2866,13 +2865,13 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
const auto srcExpr = instr.GetSourceExpr<HLIL_LOW_PART>();
if (settings && !settings->IsOptionSet(ShowTypeCasts))
{
- GetExprText(srcExpr, tokens, settings, asFullAst, precedence);
+ GetExprText(srcExpr, tokens, settings, precedence);
return;
}
bool parens = precedence > LowUnaryOperatorPrecedence;
if (parens)
tokens.AppendOpenParen();
- GetExprText(srcExpr, tokens, settings, asFullAst, LowUnaryOperatorPrecedence);
+ GetExprText(srcExpr, tokens, settings, LowUnaryOperatorPrecedence);
tokens.Append(KeywordToken, " as ");
AppendSizeToken(instr.size, signedHint.value_or(true), tokens);
if (parens)
@@ -2900,9 +2899,9 @@ void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLe
void PseudoRustFunction::GetExprText(const HighLevelILInstruction& instr, HighLevelILTokenEmitter& tokens,
- DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence, bool statement)
+ DisassemblySettings* settings, BNOperatorPrecedence precedence, bool statement)
{
- GetExprText(instr, tokens, settings, asFullAst, precedence, statement ? TrailingStatementExpression : InnerExpression);
+ GetExprText(instr, tokens, settings, precedence, statement ? TrailingStatementExpression : InnerExpression);
}
diff --git a/lang/rust/pseudorust.h b/lang/rust/pseudorust.h
index a6494319..a2ab9584 100644
--- a/lang/rust/pseudorust.h
+++ b/lang/rust/pseudorust.h
@@ -31,10 +31,10 @@ class PseudoRustFunction: public BinaryNinja::LanguageRepresentationFunction
void AppendSizeToken(size_t size, bool isSigned, BinaryNinja::HighLevelILTokenEmitter& emitter);
void AppendSingleSizeToken(size_t size, BNInstructionTextTokenType type, BinaryNinja::HighLevelILTokenEmitter& emitter);
void AppendComparison(const std::string& comparison, const BinaryNinja::HighLevelILInstruction& instr,
- BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings, bool asFullAst,
+ BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings,
BNOperatorPrecedence precedence, std::optional<bool> signedHint = std::nullopt);
void AppendTwoOperand(const std::string& operand, const BinaryNinja::HighLevelILInstruction& instr,
- BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings, bool asFullAst,
+ BinaryNinja::HighLevelILTokenEmitter& emitter, BinaryNinja::DisassemblySettings* settings,
BNOperatorPrecedence precedence, std::optional<bool> signedHint = std::nullopt);
void AppendTwoOperandFunction(const std::string& function, const BinaryNinja::HighLevelILInstruction& instr,
BinaryNinja::HighLevelILTokenEmitter& tokens, BinaryNinja::DisassemblySettings* settings, bool sizeToken = true);
@@ -47,14 +47,14 @@ class PseudoRustFunction: public BinaryNinja::LanguageRepresentationFunction
bool IsMutable(const BinaryNinja::Variable& var) const;
void GetExprText(const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens,
- BinaryNinja::DisassemblySettings* settings, bool asFullAst = true,
- BNOperatorPrecedence precedence = TopLevelOperatorPrecedence, ExpressionType exprType = InnerExpression,
- std::optional<bool> signedHint = std::nullopt);
+ BinaryNinja::DisassemblySettings* settings, BNOperatorPrecedence precedence = TopLevelOperatorPrecedence,
+ ExpressionType exprType = InnerExpression, std::optional<bool> signedHint = std::nullopt);
protected:
virtual void InitTokenEmitter(BinaryNinja::HighLevelILTokenEmitter& tokens) override;
- virtual void GetExprText(const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens,
- BinaryNinja::DisassemblySettings* settings, bool asFullAst, BNOperatorPrecedence precedence, bool statement) override;
+ virtual void GetExprText(const BinaryNinja::HighLevelILInstruction& instr,
+ BinaryNinja::HighLevelILTokenEmitter& tokens, BinaryNinja::DisassemblySettings* settings,
+ BNOperatorPrecedence precedence, bool statement) override;
virtual void BeginLines(const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens) override;
virtual void EndLines(const BinaryNinja::HighLevelILInstruction& instr, BinaryNinja::HighLevelILTokenEmitter& tokens) override;