diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-14 15:52:32 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-14 15:52:32 (GMT) |
commit | 6178efcee9fc18d11a773827dca8b95304e75731 (patch) | |
tree | 77c664dfac355b7af803d33b1afded7925647b6d /src/arch/instruction.c | |
parent | aba51093c8ebe4b0550557281f8d0d025027b1cb (diff) |
Used unique identifiers for instructions everywhere.
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 962b0e8..be7ff37 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -34,16 +34,6 @@ -/* Accès aux décrochages */ -static const char *_hook_names[IPH_COUNT] = { - - [IPH_FETCH] = "IPH_FETCH", - [IPH_LINK] = "IPH_LINK", - [IPH_POST] = "IPH_POST" - -}; - - /* Initialise la classe générique des instructions. */ static void g_arch_instruction_class_init(GArchInstructionClass *); @@ -287,30 +277,6 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr) /****************************************************************************** * * -* Paramètres : instr = instruction quelconque à modifier. * -* type = type de procédure à mémoriser. * -* hook = fonction à appeler sur commande. * -* * -* Description : Définit un traitement complémentare au désassemblage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc hooks[IPH_COUNT]) -{ - InstrProcessHook i; /* Boucle de parcours */ - - for (i = 0; i < IPH_COUNT; i++) - g_object_set_data(G_OBJECT(instr), _hook_names[i], hooks[i]); - -} - - -/****************************************************************************** -* * * Paramètres : instr = instruction quelconque à traiter. * * type = type de procédure à utiliser. * * proc = représentation de l'architecture utilisée. * @@ -327,23 +293,12 @@ void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc h void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type, GArchProcessor *proc, GProcContext *context, GExeFormat *format) { - instr_hook_fc hook; - - assert(type < IPH_COUNT); - - hook = g_object_get_data(G_OBJECT(instr), _hook_names[type]); - - if (hook != NULL) - { - /** - * Comme ce genre d'appel n'est effectué normalement qu'une seule fois - * par instruction, on libère la mémoire au moment de cet unique appel. - */ - g_object_set_data(G_OBJECT(instr), _hook_names[type], NULL); + GArchInstructionClass *class; /* Classe des instructions */ - hook(instr, proc, context, format); + class = G_ARCH_INSTRUCTION_GET_CLASS(instr); - } + if (class->call_hook != NULL) + class->call_hook(instr, type, proc, context, format); } |