diff options
Diffstat (limited to 'src/arch/instruction.c')
| -rw-r--r-- | src/arch/instruction.c | 60 | 
1 files changed, 59 insertions, 1 deletions
| diff --git a/src/arch/instruction.c b/src/arch/instruction.c index ee220a5..eb8ec28 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -41,6 +41,9 @@ static void g_arch_instruction_init(GArchInstruction *);  /* Ajoute du texte simple à un fichier ouvert en écriture. */  static void g_arch_instruction_add_text(const GArchInstruction *, GRenderingOptions *, MainRendering, FILE *); +/*  Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ +static void g_arch_instruction_to_buffer(const GArchInstruction *, GBufferLine *, GRenderingOptions *); +  /* Ajoute à un texte GTK le contenu d'une instruction. */  static void g_arch_instruction_add_to_gtk_buffer(const GArchInstruction *, const GExeFormat *, AsmSyntax, GtkTextBuffer *, GtkTextIter *); @@ -87,6 +90,7 @@ static void g_arch_instruction_init(GArchInstruction *instr)      parent = G_CONTENT_EXPORTER(instr);      parent->add_text = (add_text_fc)g_arch_instruction_add_text; +    parent->export_buffer = (export_buffer_fc)g_arch_instruction_to_buffer;      parent->add_arch_to_gtk_buffer = (add_arch_to_gtk_buffer_fc)g_arch_instruction_add_to_gtk_buffer;  } @@ -109,7 +113,7 @@ static void g_arch_instruction_init(GArchInstruction *instr)  static void g_arch_instruction_add_text(const GArchInstruction *instr, GRenderingOptions *options, MainRendering rendering, FILE *stream)  { -    GContentExporter *exporter;             /* Autre vision de la ligne    */ +    GContentExporter *exporter;             /* Autre vision de l'objet     */      const char *key;                        /* Mot clef principal          */      size_t klen;                            /* Taille de ce mot clef       */      size_t i;                               /* Boucle de parcours          */ @@ -148,6 +152,60 @@ static void g_arch_instruction_add_text(const GArchInstruction *instr, GRenderin  /******************************************************************************  *                                                                             * +*  Paramètres  : instr   = instruction d'assemblage à représenter.            * +*                buffer  = espace où placer ledit contenu.                    * +*                options = options de rendu.                                  * +*                                                                             * +*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_arch_instruction_to_buffer(const GArchInstruction *instr, GBufferLine *buffer, GRenderingOptions *options) +{ +    GContentExporter *exporter;             /* Autre vision de l'objet     */ +    const char *key;                        /* Mot clef principal          */ +    size_t klen;                            /* Taille de ce mot clef       */ +    size_t i;                               /* Boucle de parcours          */ + +    exporter = G_CONTENT_EXPORTER(instr); + +    key = instr->get_text(instr, +                          g_rendering_options_get_format(options), +                          g_rendering_options_get_syntax(options)); +    klen = strlen(key); + +    g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY_HEAD, +                                          key, klen, RTT_INSTRUCTION); + +    if (instr->operands_count > 0) +    { +        g_content_exporter_to_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[0]), +                                     buffer, options); + +        for (i = 1; i < instr->operands_count; i++) +        { +            g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, +                                                  ",", 1, RTT_NONE/* FIXME */); + +            g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, +                                                  " ", 1, RTT_NONE); + +            g_content_exporter_to_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[i]), +                                         buffer, options); + +        } + +    } + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : instr   = instruction à transcrire.                          *  *                format = format du binaire manipulé.                         *  *                syntax = type de représentation demandée.                    * | 
