summaryrefslogtreecommitdiff
path: root/src/decomp/instr
diff options
context:
space:
mode:
Diffstat (limited to 'src/decomp/instr')
-rw-r--r--src/decomp/instr/ite.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/decomp/instr/ite.c b/src/decomp/instr/ite.c
index 7c68031..c12d314 100644
--- a/src/decomp/instr/ite.c
+++ b/src/decomp/instr/ite.c
@@ -33,6 +33,8 @@ struct _GITEInstruction
{
GDecInstruction parent; /* A laisser en premier */
+ bool inverse; /* Condition inversée */
+
GDecExpression *cond; /* Condition prise en compte */
GDecInstruction *true_branch; /* Condition vérifiée */
@@ -165,8 +167,20 @@ GDecInstruction *g_ite_instruction_new(GDecExpression *cond, vmpa_t if_true, vmp
void g_ite_instruction_set_branches(GITEInstruction *expr, GDecInstruction *true_branch, GDecInstruction *false_branch)
{
- expr->true_branch = true_branch;
- expr->false_branch = false_branch;
+
+ if (true_branch == NULL)
+ {
+ expr->inverse = true;
+
+ expr->true_branch = false_branch;
+ expr->false_branch = true_branch;
+
+ }
+ else
+ {
+ expr->true_branch = true_branch;
+ expr->false_branch = false_branch;
+ }
}
@@ -192,6 +206,9 @@ static GBufferLine *g_ite_instruction_print(const GITEInstruction *expr, GCodeBu
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "if ", 3, RTT_KEY_WORD);
+ if (expr->inverse)
+ g_buffer_line_insert_text(line /* FIXME */, BLC_ASSEMBLY_HEAD, "!", 1, RTT_KEY_WORD);
+
result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->cond),
buffer, line, output);