diff options
Diffstat (limited to 'src/decomp/expr/call.c')
-rw-r--r-- | src/decomp/expr/call.c | 60 |
1 files changed, 51 insertions, 9 deletions
diff --git a/src/decomp/expr/call.c b/src/decomp/expr/call.c index 05e596a..aaf9883 100644 --- a/src/decomp/expr/call.c +++ b/src/decomp/expr/call.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * call.c - encadrement des appels de routine * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -24,6 +24,7 @@ #include "call.h" +#include <malloc.h> #include <string.h> @@ -37,7 +38,9 @@ struct _GRoutineCall GDecExpression parent; /* A laisser en premier */ GBinRoutine *routine; /* Routine sollicitée */ - bool is_object; /* Nature de l'argument n°1 */ + + GDecInstruction **args; /* Arguments à associer */ + size_t count; /* Nombre d'arguments présents */ }; @@ -109,8 +112,7 @@ static void g_routine_call_init(GRoutineCall *expr) /****************************************************************************** * * -* Paramètres : routine = routine dont il est fait appel. * -* is_object = indique la nature du premier argument. * +* Paramètres : routine = routine dont il est fait appel. * * * * Description : Exprime un appel à une routine quelconque. * * * @@ -120,14 +122,13 @@ static void g_routine_call_init(GRoutineCall *expr) * * ******************************************************************************/ -GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object) +GDecInstruction *g_routine_call_new(GBinRoutine *routine) { GRoutineCall *result; /* Expression à retourner */ result = g_object_new(G_TYPE_ROUTINE_CALL, NULL); result->routine = routine; - result->is_object = is_object; return G_DEC_INSTRUCTION(result); @@ -136,7 +137,7 @@ GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object) /****************************************************************************** * * -* Paramètres : expr = expression à transcrire en version humaine. * +* Paramètres : call = expression à transcrire en version humaine. * * buffer = tampon où doit se réaliser l'insertion. * * line = ligne d'impression prête à emploi ou NULL. * * output = langage de programmation de sortie. * @@ -149,15 +150,56 @@ GDecInstruction *g_routine_call_new(GBinRoutine *routine, bool is_object) * * ******************************************************************************/ -static void g_routine_call_print(const GRoutineCall *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output) +static void g_routine_call_print(const GRoutineCall *call, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output) { const char *name; /* Désignation de la routine */ + size_t i; /* Boucle de parcours */ - name = g_binary_routine_get_name(expr->routine); + name = g_binary_routine_get_name(call->routine); g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, name, strlen(name), RTT_RAW); g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "(", 1, RTT_PUNCT); + if (call->count > 0) + { + 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_dec_instruction_print(call->args[i], buffer, line, output); + + } + + } + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, ")", 1, RTT_PUNCT); } + + +/****************************************************************************** +* * +* Paramètres : call = expression d'appel à mettre à jour. * +* arg = nouvel argument à associer à l'appel. * +* * +* Description : Enregistre un nouvel argument pour l'appel de routine. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_routine_call_add_arg(GRoutineCall *call, GDecInstruction *arg) +{ + call->args = (GDecInstruction **)realloc(call->args, + ++call->count * sizeof(GDecInstruction *)); + + call->args[call->count - 1] = arg; + + /* TODO : synchroniser avec la routine (cf. constructeurs construits à la volée) */ + +} |