summaryrefslogtreecommitdiff
path: root/src/arch/arm/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/arm/instruction.c')
-rw-r--r--src/arch/arm/instruction.c65
1 files changed, 49 insertions, 16 deletions
diff --git a/src/arch/arm/instruction.c b/src/arch/arm/instruction.c
index 2c1f3b8..4c08c9a 100644
--- a/src/arch/arm/instruction.c
+++ b/src/arch/arm/instruction.c
@@ -24,6 +24,7 @@
#include "instruction.h"
+#include <malloc.h>
#include <string.h>
@@ -44,8 +45,8 @@ static void g_arm_instruction_dispose(GArmInstruction *);
/* Procède à la libération totale de la mémoire. */
static void g_arm_instruction_finalize(GArmInstruction *);
-/* Reconstruit le cache complet d'une désignation d'instruction. */
-static void g_arm_instruction_build_keyword(const GArmInstruction *, AsmSyntax);
+/* Fournit le nom humain de l'instruction manipulée. */
+static const char *g_arm_instruction_get_keyword(GArmInstruction *, AsmSyntax);
@@ -76,7 +77,7 @@ static void g_arm_instruction_class_init(GArmInstructionClass *klass)
object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_instruction_dispose;
object_class->finalize = (GObjectFinalizeFunc)g_arm_instruction_finalize;
- instr->build_key = (build_instruction_keyword_fc)g_arm_instruction_build_keyword;
+ instr->get_keyword = (get_instruction_keyword_fc)g_arm_instruction_get_keyword;
}
@@ -133,6 +134,12 @@ static void g_arm_instruction_dispose(GArmInstruction *instr)
static void g_arm_instruction_finalize(GArmInstruction *instr)
{
+ if (instr->suffix != NULL)
+ free(instr->suffix);
+
+ if (instr->cached_keyword != NULL)
+ free(instr->cached_keyword);
+
G_OBJECT_CLASS(g_arm_instruction_parent_class)->finalize(G_OBJECT(instr));
}
@@ -140,10 +147,38 @@ static void g_arm_instruction_finalize(GArmInstruction *instr)
/******************************************************************************
* *
-* Paramètres : instr = instruction à traiter. *
+* Paramètres : instr = instruction quelconque à modifier. *
+* suffix = chaîne de caractères fournie en complément. *
+* *
+* Description : Etend la désignation d'un nom d'instruction. *
+* *
+* Retour : true. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_arm_instruction_extend_keyword(GArmInstruction *instr, const char *suffix)
+{
+ instr->suffix = stradd(instr->suffix, suffix);
+
+ if (instr->cached_keyword != NULL)
+ {
+ free(instr->cached_keyword);
+ instr->cached_keyword = NULL;
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction d'assemblage à consulter. *
* syntax = type de représentation demandée. *
* *
-* Description : Reconstruit le cache complet d'une désignation d'instruction.*
+* Description : Fournit le nom humain de l'instruction manipulée. *
* *
* Retour : Mot clef de bas niveau. *
* *
@@ -151,20 +186,18 @@ static void g_arm_instruction_finalize(GArmInstruction *instr)
* *
******************************************************************************/
-static void g_arm_instruction_build_keyword(const GArmInstruction *instr, AsmSyntax syntax)
+static const char *g_arm_instruction_get_keyword(GArmInstruction *instr, AsmSyntax syntax)
{
- GArchInstruction *base; /* Instruction, vue générique */
-
- /* FIXME : tout bouger dans la base des instructions ? */
+ if (instr->cached_keyword == NULL)
+ {
+ instr->cached_keyword = strdup(instr->keyword);
- base = G_ARCH_INSTRUCTION(instr);
+ if (instr->suffix != NULL)
+ instr->cached_keyword = stradd(instr->cached_keyword, instr->suffix);
- base->cached_keyword = strdup(instr->keyword);
+ }
- /*
- if (base->suffix != NULL)
- base->cached_keyword = stradd(base->cached_keyword, base->suffix);
- */
+ return instr->cached_keyword;
}
@@ -210,7 +243,7 @@ bool g_arm_instruction_set_cond(GArmInstruction *instr, ArmCondCode cond)
}
if (suffix != NULL)
- result = g_arch_instruction_extend_keyword(G_ARCH_INSTRUCTION(instr), suffix);
+ result = g_arm_instruction_extend_keyword(instr, suffix);
else
result = true;