summaryrefslogtreecommitdiff
path: root/lang/c/pseudoc.cpp
diff options
context:
space:
mode:
authorGalen Williamson <galen@vector35.com>2025-08-12 20:30:02 -0400
committerGalen Williamson <galen@vector35.com>2025-08-13 13:30:03 -0400
commitc54d5833a9c7089fa605a05c12d465acb6bb18cf (patch)
tree86b12bdff68ff63a404f2cb4df573abaefd1b581 /lang/c/pseudoc.cpp
parent72020bd61d4577846ca205079a640f5326d4e0c1 (diff)
Fix round and single-operand uses of COMBINE in Pseudo-C
Diffstat (limited to 'lang/c/pseudoc.cpp')
-rw-r--r--lang/c/pseudoc.cpp52
1 files changed, 33 insertions, 19 deletions
diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp
index b7ced55a..8d806d79 100644
--- a/lang/c/pseudoc.cpp
+++ b/lang/c/pseudoc.cpp
@@ -274,20 +274,6 @@ void PseudoCFunction::AppendTwoOperand(const string& operand, const HighLevelILI
break;
}
- if (leftExpr.operation == HLIL_SPLIT)
- {
- const auto low = leftExpr.GetLowExpr();
- const auto high = leftExpr.GetHighExpr();
-
- emitter.Append(OperationToken, "COMBINE");
- emitter.AppendOpenParen();
- GetExprTextInternal(high, emitter, settings);
- emitter.Append(TextToken, ", ");
- GetExprTextInternal(low, emitter, settings);
- emitter.AppendCloseParen();
- }
-
-
if (!settings || settings->IsOptionSet(ShowTypeCasts))
{
if (leftExpr.operation == HLIL_VAR && (operand == " + " || operand == " - "))
@@ -1511,7 +1497,8 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
}
- GetExprTextInternal(destExpr, tokens, settings, precedence);
+ if (!destIsSplit)
+ GetExprTextInternal(destExpr, tokens, settings, precedence);
if (assignUpdateOperator.has_value() && assignUpdateSource.has_value())
tokens.Append(OperationToken, assignUpdateOperator.value());
else
@@ -2326,7 +2313,20 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
case HLIL_ROUND_TO_INT:
[&]() {
- AppendTwoOperandFunction("round", instr, tokens, settings, false);
+ auto src = instr.GetSourceExpr<HLIL_ROUND_TO_INT>();
+ string round;
+ if (src.size == 4)
+ round = "roundf";
+ else if (src.size == 8)
+ round = "round";
+ else if (src.size == 10)
+ round = "roundl";
+ else
+ round = "round" + std::to_string(src.size) + "f";
+ tokens.Append(OperationToken, round);
+ tokens.AppendOpenParen();
+ GetExprTextInternal(src, tokens, settings);
+ tokens.AppendCloseParen();
if (statement)
tokens.AppendSemicolon();
}();
@@ -2616,7 +2616,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
bool hasOffset = offset != 0;
bool needsOuterParens = precedence > UnaryOperatorPrecedence;
bool showTypeCasts = !settings || settings->IsOptionSet(ShowTypeCasts);
-
+
if (needsOuterParens)
tokens.AppendOpenParen();
@@ -2652,7 +2652,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}
else
{
- GetExprTextInternal(srcExpr, tokens, settings,
+ GetExprTextInternal(srcExpr, tokens, settings,
hasOffset ? AddOperatorPrecedence : UnaryOperatorPrecedence);
}
@@ -2854,7 +2854,21 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
}();
break;
- case HLIL_SPLIT: break;
+ case HLIL_SPLIT:
+ [&]() {
+ const auto low = instr.GetLowExpr();
+ const auto high = instr.GetHighExpr();
+
+ tokens.Append(OperationToken, "COMBINE");
+ tokens.AppendOpenParen();
+ GetExprTextInternal(high, tokens, settings);
+ tokens.Append(TextToken, ", ");
+ GetExprTextInternal(low, tokens, settings);
+ tokens.AppendCloseParen();
+ if (statement)
+ tokens.AppendSemicolon();
+ }();
+ break;
default:
[&]() {
char buf[64]{};