diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-11-28 09:43:50 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-11-28 09:43:50 (GMT) |
commit | f95598b68b98f6eda701f8f02bc09cb13f65fc72 (patch) | |
tree | eefee33963448a1ce53a7eb80dacabbcdce8fc21 /src/decomp/expr | |
parent | fbb4b6f53d2189ba9f61c1fd149534d8aef82dcd (diff) |
Followed the excution flow to decompile instructions.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@293 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp/expr')
-rw-r--r-- | src/decomp/expr/access.c | 18 | ||||
-rw-r--r-- | src/decomp/expr/arithm.c | 17 | ||||
-rw-r--r-- | src/decomp/expr/array.c | 20 | ||||
-rw-r--r-- | src/decomp/expr/assign.c | 18 | ||||
-rw-r--r-- | src/decomp/expr/block.c | 15 | ||||
-rw-r--r-- | src/decomp/expr/call.c | 18 | ||||
-rw-r--r-- | src/decomp/expr/cond.c | 18 | ||||
-rw-r--r-- | src/decomp/expr/immediate.c | 6 | ||||
-rw-r--r-- | src/decomp/expr/pseudo.c | 6 | ||||
-rw-r--r-- | src/decomp/expr/return.c | 13 | ||||
-rw-r--r-- | src/decomp/expr/text.c | 6 |
11 files changed, 98 insertions, 57 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; + } |