summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/operand-int.h15
-rw-r--r--src/arch/operand.c39
2 files changed, 35 insertions, 19 deletions
diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h
index 6aa15e8..eb1a1d7 100644
--- a/src/arch/operand-int.h
+++ b/src/arch/operand-int.h
@@ -37,16 +37,23 @@ typedef int (* operand_compare_fc) (const GArchOperand * const *, const GArchOpe
typedef void (* operand_print_fc) (const GArchOperand *, GBufferLine *, AsmSyntax);
+/* Adjonction de rendu alternatif */
+typedef struct _alt_rendering
+{
+ RenderingTagType tag; /* Type de rendu */
+ char text[0]; /* Texte alternatif */
+
+} alt_rendering;
+
+
/* Définition générique d'un opérande d'architecture (instance) */
struct _GArchOperand
{
GObject parent; /* A laisser en premier */
- unsigned int shared_count; /* Compteur de partages */
+ alt_rendering *alt_info; /* Autre rendu éventuel */
- char *alt_text; /* Eventuel texte alternatif */
- size_t alt_len; /* Taille de ce texte */
- RenderingTagType alt_tag; /* Type de rendu */
+ unsigned int shared_count; /* Compteur de partages */
};
diff --git a/src/arch/operand.c b/src/arch/operand.c
index dc0559a..731c757 100644
--- a/src/arch/operand.c
+++ b/src/arch/operand.c
@@ -333,20 +333,23 @@ int g_arch_operand_compare(const GArchOperand * const *a, const GArchOperand * c
void g_arch_operand_set_alt_text(GArchOperand *operand, const char *text, RenderingTagType tag)
{
- if (operand->alt_text != NULL)
- free(operand->alt_text);
+ size_t alt_len; /* Taille du texte alternatif */
+
+ if (operand->alt_info != NULL)
+ free(operand->alt_info);
+
+ if (text == NULL)
+ operand->alt_info = NULL;
- if (text != NULL)
- {
- operand->alt_text = strdup(text);
- operand->alt_len = strlen(text);
- operand->alt_tag = tag;
- }
else
{
- operand->alt_text = NULL;
- operand->alt_len = 0;
- operand->alt_tag = RTT_COUNT;
+ alt_len = strlen(text);
+
+ operand->alt_info = (alt_rendering *)malloc(sizeof(RenderingTagType) + alt_len + 1);
+
+ operand->alt_info->tag = tag;
+ strcpy(operand->alt_info->text, text);
+
}
}
@@ -368,13 +371,19 @@ void g_arch_operand_set_alt_text(GArchOperand *operand, const char *text, Render
void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyntax syntax)
{
- if (operand->alt_text != NULL)
+ size_t alt_len; /* Taille du texte alternatif */
+
+ if (operand->alt_info != NULL)
+ {
+ alt_len = strlen(operand->alt_info->text);
+
g_buffer_line_append_text(line, BLC_ASSEMBLY,
- operand->alt_text,
- operand->alt_len,
- operand->alt_tag,
+ operand->alt_info->text,
+ alt_len,
+ operand->alt_info->tag,
NULL);
+ }
else
G_ARCH_OPERAND_GET_CLASS(operand)->print(operand, line, syntax);