summaryrefslogtreecommitdiff
path: root/src/decomp
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-01-10 22:47:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-01-10 22:47:37 (GMT)
commit221bcaeeb06415d501f9abbb9bc4b7d8339af1fe (patch)
tree243a1709589d3733d6525b0a143ecf0c539caae7 /src/decomp
parentc455057e634b30c3214a49db009bad5fd0c631ff (diff)
Simplified the decompilation process by using links between basic blocks.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@322 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp')
-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);