summaryrefslogtreecommitdiff
path: root/src/decomp/instr/ite.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/decomp/instr/ite.c')
-rw-r--r--src/decomp/instr/ite.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/decomp/instr/ite.c b/src/decomp/instr/ite.c
index f08df1e..7c68031 100644
--- a/src/decomp/instr/ite.c
+++ b/src/decomp/instr/ite.c
@@ -35,6 +35,9 @@ struct _GITEInstruction
GDecExpression *cond; /* Condition prise en compte */
+ GDecInstruction *true_branch; /* Condition vérifiée */
+ GDecInstruction *false_branch; /* Condition non vérifiée */
+
union
{
vmpa_t addr; /* Adresse de saut */
@@ -68,7 +71,7 @@ static void g_ite_instruction_class_init(GITEInstructionClass *);
static void g_ite_instruction_init(GITEInstruction *);
/* Imprime pour l'écran un version humaine d'une instruction. */
-static void g_ite_instruction_print(const GITEInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_ite_instruction_print(const GITEInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -148,6 +151,28 @@ GDecInstruction *g_ite_instruction_new(GDecExpression *cond, vmpa_t if_true, vmp
/******************************************************************************
* *
+* Paramètres : cond = expression fixant le choix de l'aiguillage. *
+* true_branch = instructions si la condition est vérifiée. *
+* false_branch = instructions si la cond. n'est pas vérifiée. *
+* *
+* Description : Détermine le corps des différentes branches possibles. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_ite_instruction_set_branches(GITEInstruction *expr, GDecInstruction *true_branch, GDecInstruction *false_branch)
+{
+ expr->true_branch = true_branch;
+ expr->false_branch = false_branch;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : expr = instruction à transcrire en version humaine. *
* buffer = tampon où doit se réaliser l'insertion. *
* line = ligne d'impression prête à emploi ou NULL. *
@@ -161,22 +186,24 @@ GDecInstruction *g_ite_instruction_new(GDecExpression *cond, vmpa_t if_true, vmp
* *
******************************************************************************/
-static void g_ite_instruction_print(const GITEInstruction *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_ite_instruction_print(const GITEInstruction *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "if ", 3, RTT_KEY_WORD);
+ GBufferLine *result; /* Ligne à retourner */
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->cond),
- buffer, line, output);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "if ", 3, RTT_KEY_WORD);
- /*
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->dest),
- buffer, line, output);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->cond),
+ buffer, line, output);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " = ", 3, RTT_SIGNS);
+ if (expr->true_branch != NULL)
+ result = g_dec_instruction_print(expr->true_branch, buffer, result, output);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->src),
- buffer, line, output);
- */
+ if (expr->false_branch != NULL)
+ {
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "else", 4, RTT_KEY_WORD);
+ result = g_dec_instruction_print(expr->false_branch, buffer, result, output);
+ }
+ return result;
}