summaryrefslogtreecommitdiff
path: root/src/decomp
diff options
context:
space:
mode:
Diffstat (limited to 'src/decomp')
-rw-r--r--src/decomp/expr/access.c18
-rw-r--r--src/decomp/expr/arithm.c17
-rw-r--r--src/decomp/expr/array.c20
-rw-r--r--src/decomp/expr/assign.c18
-rw-r--r--src/decomp/expr/block.c15
-rw-r--r--src/decomp/expr/call.c18
-rw-r--r--src/decomp/expr/cond.c18
-rw-r--r--src/decomp/expr/immediate.c6
-rw-r--r--src/decomp/expr/pseudo.c6
-rw-r--r--src/decomp/expr/return.c13
-rw-r--r--src/decomp/expr/text.c6
-rw-r--r--src/decomp/instr/ite.c51
-rw-r--r--src/decomp/instr/ite.h3
-rw-r--r--src/decomp/instruction-int.h6
-rw-r--r--src/decomp/instruction.c36
-rw-r--r--src/decomp/instruction.h9
-rw-r--r--src/decomp/lang/java.c84
-rw-r--r--src/decomp/output-int.h8
-rw-r--r--src/decomp/output.c58
-rw-r--r--src/decomp/output.h5
20 files changed, 335 insertions, 80 deletions
diff --git a/src/decomp/expr/access.c b/src/decomp/expr/access.c
index e2cbf19..277209a 100644
--- a/src/decomp/expr/access.c
+++ b/src/decomp/expr/access.c
@@ -55,7 +55,7 @@ static void g_access_expression_class_init(GAccessExpressionClass *);
static void g_access_expression_init(GAccessExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_access_expression_print(const GAccessExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_access_expression_print(const GAccessExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -146,14 +146,18 @@ GDecInstruction *g_access_expression_new(GDecExpression *owner, GDecExpression *
* *
******************************************************************************/
-static void g_access_expression_print(const GAccessExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_access_expression_print(const GAccessExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->owner),
- buffer, line, output);
+ GBufferLine *result; /* Ligne à retourner */
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, ".", 3, RTT_PUNCT);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->owner),
+ buffer, line, output);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->target),
- buffer, line, output);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, ".", 3, RTT_PUNCT);
+
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->target),
+ buffer, result, output);
+
+ return result;
}
diff --git a/src/decomp/expr/arithm.c b/src/decomp/expr/arithm.c
index 0ca73ac..d91e080 100644
--- a/src/decomp/expr/arithm.c
+++ b/src/decomp/expr/arithm.c
@@ -57,7 +57,7 @@ static void g_arithm_expression_class_init(GArithmExpressionClass *);
static void g_arithm_expression_init(GArithmExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_arithm_expression_print(const GArithmExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_arithm_expression_print(const GArithmExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -151,12 +151,13 @@ GDecInstruction *g_arithm_expression_new(GDecExpression *op1, ArithmOperationTyp
* *
******************************************************************************/
-static void g_arithm_expression_print(const GArithmExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_arithm_expression_print(const GArithmExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
+ GBufferLine *result; /* Ligne à retourner */
const char *sign; /* Symbole de l'opération */
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->op1),
- buffer, line, output);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->op1),
+ buffer, line, output);
switch (expr->type)
{
@@ -189,9 +190,11 @@ static void g_arithm_expression_print(const GArithmExpression *expr, GCodeBuffer
break;
}
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, sign, 3, RTT_SIGNS);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, sign, 3, RTT_SIGNS);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->op2),
- buffer, line, output);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->op2),
+ buffer, result, output);
+
+ return result;
}
diff --git a/src/decomp/expr/array.c b/src/decomp/expr/array.c
index c14374b..dc487ee 100644
--- a/src/decomp/expr/array.c
+++ b/src/decomp/expr/array.c
@@ -55,7 +55,7 @@ static void g_array_access_class_init(GArrayAccessClass *);
static void g_array_access_init(GArrayAccess *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_array_access_print(const GArrayAccess *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_array_access_print(const GArrayAccess *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -146,16 +146,20 @@ GDecInstruction *g_array_access_new(GDecExpression *array, GDecExpression *index
* *
******************************************************************************/
-static void g_array_access_print(const GArrayAccess *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_array_access_print(const GArrayAccess *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->array),
- buffer, line, output);
+ GBufferLine *result; /* Ligne à retourner */
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "[", 1, RTT_RAW);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->array),
+ buffer, line, output);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->index),
- buffer, line, output);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "[", 1, RTT_RAW);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "]", 1, RTT_RAW);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->index),
+ buffer, result, output);
+
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "]", 1, RTT_RAW);
+
+ return result;
}
diff --git a/src/decomp/expr/assign.c b/src/decomp/expr/assign.c
index 0843776..fd86021 100644
--- a/src/decomp/expr/assign.c
+++ b/src/decomp/expr/assign.c
@@ -55,7 +55,7 @@ static void g_assign_expression_class_init(GAssignExpressionClass *);
static void g_assign_expression_init(GAssignExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_assign_expression_print(const GAssignExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_assign_expression_print(const GAssignExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -146,15 +146,19 @@ GDecInstruction *g_assign_expression_new(GDecExpression *dest, GDecExpression *s
* *
******************************************************************************/
-static void g_assign_expression_print(const GAssignExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_assign_expression_print(const GAssignExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->dest),
- buffer, line, output);
+ GBufferLine *result; /* Ligne à retourner */
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " = ", 3, RTT_SIGNS);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->dest),
+ buffer, line, output);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->src),
- buffer, line, output);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " = ", 3, RTT_SIGNS);
+
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->src),
+ buffer, result, output);
+
+ return result;
}
diff --git a/src/decomp/expr/block.c b/src/decomp/expr/block.c
index 1ec15a7..5124204 100644
--- a/src/decomp/expr/block.c
+++ b/src/decomp/expr/block.c
@@ -58,7 +58,7 @@ static void g_expr_block_class_init(GExprBlockClass *);
static void g_expr_block_init(GExprBlock *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_expr_block_print(const GExprBlock *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_expr_block_print(const GExprBlock *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -147,19 +147,26 @@ GDecInstruction *g_expr_block_new(GDecInstruction *item)
* *
******************************************************************************/
-static void g_expr_block_print(const GExprBlock *block, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_expr_block_print(const GExprBlock *block, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
+ GBufferLine *result; /* Ligne à retourner */
size_t i; /* Boucle de parcours */
+ result = g_lang_output_start_code_block(output, buffer, line, block->count);
+
for (i = 0; i < block->count; i++)
{
if (i > 0)
- line = g_code_buffer_append_new_line_fixme(buffer); /* FIXME : n° de ligne */
+ result = g_code_buffer_append_new_line_fixme(buffer); /* FIXME : n° de ligne */
- g_dec_instruction_print(block->list[i], buffer, line, output);
+ result = g_dec_instruction_print(block->list[i], buffer, result, output);
}
+ result = g_lang_output_end_code_block(output, buffer, result, block->count);
+
+ return result;
+
}
diff --git a/src/decomp/expr/call.c b/src/decomp/expr/call.c
index aaf9883..e518c6f 100644
--- a/src/decomp/expr/call.c
+++ b/src/decomp/expr/call.c
@@ -61,7 +61,7 @@ static void g_routine_call_class_init(GRoutineCallClass *);
static void g_routine_call_init(GRoutineCall *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_routine_call_print(const GRoutineCall *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_routine_call_print(const GRoutineCall *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -150,8 +150,9 @@ GDecInstruction *g_routine_call_new(GBinRoutine *routine)
* *
******************************************************************************/
-static void g_routine_call_print(const GRoutineCall *call, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_routine_call_print(const GRoutineCall *call, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
+ GBufferLine *result; /* Ligne à retourner */
const char *name; /* Désignation de la routine */
size_t i; /* Boucle de parcours */
@@ -162,20 +163,23 @@ static void g_routine_call_print(const GRoutineCall *call, GCodeBuffer *buffer,
if (call->count > 0)
{
- g_dec_instruction_print(call->args[0], buffer, line, output);
+ result = g_dec_instruction_print(call->args[0], buffer, line, output);
for (i = 1; i < call->count; i++)
{
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, ",", 1, RTT_PUNCT);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, ",", 1, RTT_PUNCT);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
- g_dec_instruction_print(call->args[i], buffer, line, output);
+ g_dec_instruction_print(call->args[i], buffer, result, output);
}
}
+ else result = line;
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, ")", 1, RTT_PUNCT);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, ")", 1, RTT_PUNCT);
+
+ return result;
}
diff --git a/src/decomp/expr/cond.c b/src/decomp/expr/cond.c
index 51309ca..4a9b63b 100644
--- a/src/decomp/expr/cond.c
+++ b/src/decomp/expr/cond.c
@@ -56,7 +56,7 @@ static void g_cond_expression_class_init(GCondExpressionClass *);
static void g_cond_expression_init(GCondExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_cond_expression_print(const GCondExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_cond_expression_print(const GCondExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -149,14 +149,18 @@ GDecInstruction *g_cond_expression_new(GDecExpression *a, CompSignType sign, GDe
* *
******************************************************************************/
-static void g_cond_expression_print(const GCondExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_cond_expression_print(const GCondExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->a),
- buffer, line, output);
+ GBufferLine *result; /* Ligne à retourner */
- g_lang_output_write_comp_sign(output, line, expr->sign);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->a),
+ buffer, line, output);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->b),
- buffer, line, output);
+ g_lang_output_write_comp_sign(output, result, expr->sign);
+
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->b),
+ buffer, result, output);
+
+ return result;
}
diff --git a/src/decomp/expr/immediate.c b/src/decomp/expr/immediate.c
index a97c8bd..a17b2a1 100644
--- a/src/decomp/expr/immediate.c
+++ b/src/decomp/expr/immediate.c
@@ -54,7 +54,7 @@ static void g_imm_expression_class_init(GImmExpressionClass *);
static void g_imm_expression_init(GImmExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_imm_expression_print(const GImmExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_imm_expression_print(const GImmExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -143,8 +143,10 @@ GDecInstruction *g_imm_expression_new(GImmOperand *operand)
* *
******************************************************************************/
-static void g_imm_expression_print(const GImmExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_imm_expression_print(const GImmExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
g_arch_operand_print(G_ARCH_OPERAND(expr->operand), line, ASX_COUNT);
+ return line;
+
}
diff --git a/src/decomp/expr/pseudo.c b/src/decomp/expr/pseudo.c
index e73cb3d..9da76e7 100644
--- a/src/decomp/expr/pseudo.c
+++ b/src/decomp/expr/pseudo.c
@@ -61,7 +61,7 @@ static void g_pseudo_register_class_init(GPseudoRegisterClass *);
static void g_pseudo_register_init(GPseudoRegister *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_pseudo_register_print(const GPseudoRegister *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_pseudo_register_print(const GPseudoRegister *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -148,7 +148,7 @@ GDecInstruction *g_pseudo_register_new(void)
* *
******************************************************************************/
-static void g_pseudo_register_print(const GPseudoRegister *reg, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_pseudo_register_print(const GPseudoRegister *reg, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
char label[32];
char *name;
@@ -165,6 +165,8 @@ static void g_pseudo_register_print(const GPseudoRegister *reg, GCodeBuffer *buf
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, label, strlen(label), RTT_RAW);
}
+ return line;
+
}
diff --git a/src/decomp/expr/return.c b/src/decomp/expr/return.c
index e29f022..a9c10d9 100644
--- a/src/decomp/expr/return.c
+++ b/src/decomp/expr/return.c
@@ -54,7 +54,7 @@ static void g_return_expression_class_init(GReturnExpressionClass *);
static void g_return_expression_init(GReturnExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_return_expression_print(const GReturnExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_return_expression_print(const GReturnExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -143,17 +143,22 @@ GDecInstruction *g_return_expression_new(GDecExpression *payload)
* *
******************************************************************************/
-static void g_return_expression_print(const GReturnExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_return_expression_print(const GReturnExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
+ GBufferLine *result; /* Ligne à retourner */
+
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "return", 6, RTT_KEY_WORD);
if (expr->payload != NULL)
{
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
- g_dec_instruction_print(G_DEC_INSTRUCTION(expr->payload),
- buffer, line, output);
+ result = g_dec_instruction_print(G_DEC_INSTRUCTION(expr->payload),
+ buffer, line, output);
}
+ else result = line;
+
+ return result;
}
diff --git a/src/decomp/expr/text.c b/src/decomp/expr/text.c
index d62e689..8fa7e34 100644
--- a/src/decomp/expr/text.c
+++ b/src/decomp/expr/text.c
@@ -58,7 +58,7 @@ static void g_str_expression_class_init(GStrExpressionClass *);
static void g_str_expression_init(GStrExpression *);
/* Imprime pour l'écran un version humaine d'une expression. */
-static void g_str_expression_print(const GStrExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+static GBufferLine *g_str_expression_print(const GStrExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *);
@@ -148,10 +148,12 @@ GDecInstruction *g_str_expression_new(const char *value)
* *
******************************************************************************/
-static void g_str_expression_print(const GStrExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+static GBufferLine *g_str_expression_print(const GStrExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "\"", 1, RTT_STRING);
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, expr->value, expr->len, RTT_STRING);
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "\"", 1, RTT_STRING);
+ return line;
+
}
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;
}
diff --git a/src/decomp/instr/ite.h b/src/decomp/instr/ite.h
index cff073a..e53abe8 100644
--- a/src/decomp/instr/ite.h
+++ b/src/decomp/instr/ite.h
@@ -52,6 +52,9 @@ typedef struct _GITEInstructionClass GITEInstructionClass;
/* Indique le type défini pour un aiguillage du flux d'exécution. */
GType g_ite_instruction_get_type(void);
+/* Détermine le corps des différentes branches possibles. */
+void g_ite_instruction_set_branches(GITEInstruction *, GDecInstruction *, GDecInstruction *);
+
/* Exprime un aiguillage du flux en fonction d'une condition. */
GDecInstruction *g_ite_instruction_new(GDecExpression *, vmpa_t, vmpa_t);
diff --git a/src/decomp/instruction-int.h b/src/decomp/instruction-int.h
index 2721b7f..9b29162 100644
--- a/src/decomp/instruction-int.h
+++ b/src/decomp/instruction-int.h
@@ -31,8 +31,11 @@
+/* Visite un ensemble hiérarchique d'instructions décompilées. */
+typedef void (* dec_instr_visit_fc) (GDecInstruction *, process_decomp_fc, void *, bool);
+
/* Imprime pour l'écran un version humaine d'une instruction. */
-typedef void (* dec_instr_print_fc) (GDecInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+typedef GBufferLine * (* dec_instr_print_fc) (const GDecInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
/* Définition d'une instruction décompilée (instance) */
@@ -44,6 +47,7 @@ struct _GDecInstruction
vmpa_t address; /* Position associée */
+ dec_instr_visit_fc visit; /* Visite des instructions */
dec_instr_print_fc print; /* Impression pour à l'écran */
};
diff --git a/src/decomp/instruction.c b/src/decomp/instruction.c
index c48ac7b..2d42e71 100644
--- a/src/decomp/instruction.c
+++ b/src/decomp/instruction.c
@@ -79,6 +79,35 @@ static void g_dec_instruction_init(GDecInstruction *instr)
/******************************************************************************
* *
+* Paramètres : instr = première instruction à venir visiter. *
+* process = procédure à appeler à chaque instruction visitée. *
+* data = données quelconques associées au visiteur. *
+* order = précise le sens de la visite. *
+* *
+* Description : Visite un ensemble hiérarchique d'instructions décompilées. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_dec_instruction_visit(GDecInstruction *instr, process_decomp_fc process, void *data, bool order)
+{
+ if (order)
+ process(instr, data);
+
+ if (instr->visit)
+ instr->visit(instr, process, data, order);
+
+ if (!order)
+ process(instr, data);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction à transcrire en version humaine. *
* buffer = tampon où doit se réaliser l'insertion. *
* line = ligne d'impression prête à emploi ou NULL. *
@@ -92,12 +121,9 @@ static void g_dec_instruction_init(GDecInstruction *instr)
* *
******************************************************************************/
-void g_dec_instruction_print(const GDecInstruction *instr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+GBufferLine *g_dec_instruction_print(const GDecInstruction *instr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
{
- if (line == NULL)
- line = g_code_buffer_append_new_line_fixme(buffer); /* FIXME : n° de ligne */
-
- instr->print(instr, buffer, line, output);
+ return instr->print(instr, buffer, line, output);
}
diff --git a/src/decomp/instruction.h b/src/decomp/instruction.h
index d8fe46c..810be79 100644
--- a/src/decomp/instruction.h
+++ b/src/decomp/instruction.h
@@ -48,11 +48,18 @@ typedef struct _GDecInstruction GDecInstruction;
typedef struct _GDecInstructionClass GDecInstructionClass;
+/* Visite un ensemble hiérarchique d'instructions décompilées. */
+typedef void (* process_decomp_fc) (GDecInstruction *, void *);
+
+
/* Indique le type défini pour une instruction décompilée. */
GType g_dec_instruction_get_type(void);
+/* Visite un ensemble hiérarchique d'instructions décompilées. */
+void g_dec_instruction_visit(GDecInstruction *, process_decomp_fc, void *, bool);
+
/* Imprime pour l'écran un version humaine d'une expression. */
-void g_dec_instruction_print(const GDecInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+GBufferLine *g_dec_instruction_print(const GDecInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
diff --git a/src/decomp/lang/java.c b/src/decomp/lang/java.c
index ae7fb70..f4466a5 100644
--- a/src/decomp/lang/java.c
+++ b/src/decomp/lang/java.c
@@ -84,6 +84,12 @@ static void g_java_output_start_routine_body(GJavaOutput *, GCodeBuffer *, GBuff
/* Termine la définition du corps d'une routine. */
static void g_java_output_end_routine_body(GJavaOutput *, GCodeBuffer *);
+/* Commence la définition d'un bloc de code. */
+static GBufferLine *g_java_output_start_code_block(GJavaOutput *, GCodeBuffer *, GBufferLine *, size_t);
+
+/* Termine la définition d'un bloc de code. */
+static GBufferLine *g_java_output_end_code_block(GJavaOutput *, GCodeBuffer *, GBufferLine *, size_t);
+
/* Indique le type défini pour une sortie en langage Java. */
@@ -142,6 +148,9 @@ static void g_java_output_init(GJavaOutput *output)
lang->start_routine_body = (lgbufln_fc)g_java_output_start_routine_body;
lang->end_routine_body = (lgbuf_fc)g_java_output_end_routine_body;
+ lang->start_code_block = (rlgbuflnsz_fc)g_java_output_start_code_block;
+ lang->end_code_block = (rlgbuflnsz_fc)g_java_output_end_code_block;
+
}
@@ -465,11 +474,12 @@ static void g_java_output_end_routine_prototype(GJavaOutput *output, GCodeBuffer
static void g_java_output_start_routine_body(GJavaOutput *output, GCodeBuffer *buffer, GBufferLine *line)
{
+ /*
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
- g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "{", 2, RTT_HOOK);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "{", 1, RTT_HOOK);
g_code_buffer_inc_indentation(buffer);
-
+ */
}
@@ -489,11 +499,79 @@ static void g_java_output_start_routine_body(GJavaOutput *output, GCodeBuffer *b
static void g_java_output_end_routine_body(GJavaOutput *output, GCodeBuffer *buffer)
{
GBufferLine *line; /* Nouvelle ligne à constituer */
-
+ /*
g_code_buffer_dec_indentation(buffer);
line = g_code_buffer_append_new_line_fixme(buffer);
g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "}", 1, RTT_HOOK);
+ */
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
+* line = ligne contenant le prototype de la routine traitée. *
+* count = nombre d'éléments du bloc. *
+* *
+* Description : Commence la définition d'un bloc de code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBufferLine *g_java_output_start_code_block(GJavaOutput *output, GCodeBuffer *buffer, GBufferLine *line, size_t count)
+{
+ GBufferLine *result; /* Nouvelle ligne à utiliser */
+
+ if (count > 1)
+ {
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "{", 1, RTT_HOOK);
+ }
+
+ g_code_buffer_inc_indentation(buffer);
+
+ result = g_code_buffer_append_new_line_fixme(buffer); /* FIXME : n° de ligne */
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
+* line = ligne contenant le prototype de la routine traitée. *
+* count = nombre d'éléments du bloc. *
+* *
+* Description : Termine la définition d'un bloc de code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBufferLine *g_java_output_end_code_block(GJavaOutput *output, GCodeBuffer *buffer, GBufferLine *line, size_t count)
+{
+ GBufferLine *result; /* Nouvelle ligne à constituer */
+
+ g_code_buffer_dec_indentation(buffer);
+
+ result = g_code_buffer_append_new_line_fixme(buffer);
+
+ if (count > 1)
+ {
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "}", 1, RTT_HOOK);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
+ }
+
+ return result;
}
diff --git a/src/decomp/output-int.h b/src/decomp/output-int.h
index 6c5f588..8ee7dd4 100644
--- a/src/decomp/output-int.h
+++ b/src/decomp/output-int.h
@@ -50,6 +50,11 @@ typedef void (* lgbuf_fc) (GLangOutput *, GCodeBuffer *);
/* Xxx. */
typedef void (* lgbufln_fc) (GLangOutput *, GCodeBuffer *, GBufferLine *);
+/* Xxx. */
+typedef GBufferLine * (* rlgbufln_fc) (GLangOutput *, GCodeBuffer *, GBufferLine *);
+
+/* Xxx. */
+typedef GBufferLine * (* rlgbuflnsz_fc) (GLangOutput *, GCodeBuffer *, GBufferLine *, size_t);
/* Sortie selon un langage de programmation (instance) */
@@ -73,7 +78,8 @@ struct _GLangOutput
lgbufln_fc end_routine_proto; /* Fin de prototype */
lgbufln_fc start_routine_body; /* Début de définition */
lgbuf_fc end_routine_body; /* Fin de définition de corps */
-
+ rlgbuflnsz_fc start_code_block; /* Début de définition */
+ rlgbuflnsz_fc end_code_block; /* Fin de définition de corps */
};
diff --git a/src/decomp/output.c b/src/decomp/output.c
index fd10921..648dddc 100644
--- a/src/decomp/output.c
+++ b/src/decomp/output.c
@@ -373,3 +373,61 @@ void g_lang_output_end_routine_body(GLangOutput *output, GCodeBuffer *buffer)
output->end_routine_body(output, buffer);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
+* line = ligne contenant le prototype de la routine traitée. *
+* count = nombre d'éléments du bloc. *
+* *
+* Description : Commence la définition d'un bloc de code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBufferLine *g_lang_output_start_code_block(GLangOutput *output, GCodeBuffer *buffer, GBufferLine *line, size_t count)
+{
+ GBufferLine *result; /* Nouvelle ligne à utiliser */
+
+ if (output->start_code_block != NULL)
+ result = output->start_code_block(output, buffer, line, count);
+ else
+ result = NULL;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
+* line = ligne contenant le prototype de la routine traitée. *
+* count = nombre d'éléments du bloc. *
+* *
+* Description : Termine la définition d'un bloc de code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBufferLine *g_lang_output_end_code_block(GLangOutput *output, GCodeBuffer *buffer, GBufferLine *line, size_t count)
+{
+ GBufferLine *result; /* Nouvelle ligne à utiliser */
+
+ if (output->end_code_block != NULL)
+ result = output->end_code_block(output, buffer, line, count);
+ else
+ result = NULL;
+
+ return result;
+
+}
diff --git a/src/decomp/output.h b/src/decomp/output.h
index f9ccd1d..dc81a98 100644
--- a/src/decomp/output.h
+++ b/src/decomp/output.h
@@ -99,6 +99,11 @@ void g_lang_output_start_routine_body(GLangOutput *, GCodeBuffer *, GBufferLine
/* Termine la définition du corps d'une routine. */
void g_lang_output_end_routine_body(GLangOutput *, GCodeBuffer *);
+/* Commence la définition d'un bloc de code. */
+GBufferLine *g_lang_output_start_code_block(GLangOutput *, GCodeBuffer *, GBufferLine *, size_t);
+
+/* Termine la définition d'un bloc de code. */
+GBufferLine *g_lang_output_end_code_block(GLangOutput *, GCodeBuffer *, GBufferLine *, size_t);