summaryrefslogtreecommitdiff
path: root/src/arch/instruction.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-03-21 18:54:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-03-21 18:54:20 (GMT)
commit8123d9342f92a2cf6fd999b350252c001f403092 (patch)
tree5030aa5d40fa8551937649cdd3377062ec8991d0 /src/arch/instruction.c
parenta6acb5629572e6da4d72f4419b01672c2ea5ddf2 (diff)
Allowed a simple export of an assembly content.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@144 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r--src/arch/instruction.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 16e5c81..ee220a5 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -38,6 +38,9 @@ static void g_arch_instruction_class_init(GArchInstructionClass *);
/* Initialise une instance d'opérande d'architecture. */
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 texte GTK le contenu d'une instruction. */
static void g_arch_instruction_add_to_gtk_buffer(const GArchInstruction *, const GExeFormat *, AsmSyntax, GtkTextBuffer *, GtkTextIter *);
@@ -83,6 +86,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->add_arch_to_gtk_buffer = (add_arch_to_gtk_buffer_fc)g_arch_instruction_add_to_gtk_buffer;
}
@@ -90,6 +94,60 @@ static void g_arch_instruction_init(GArchInstruction *instr)
/******************************************************************************
* *
+* Paramètres : instr = instruction à transcrire. *
+* options = options de rendu. *
+* rendering = support effectif final des lignes de code. *
+* stream = flux ouvert en écriture. *
+* *
+* Description : Ajoute du texte simple à un fichier ouvert en écriture. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arch_instruction_add_text(const GArchInstruction *instr, GRenderingOptions *options, MainRendering rendering, FILE *stream)
+{
+ GContentExporter *exporter; /* Autre vision de la ligne */
+ 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_text(exporter, stream, key, klen, RTT_INSTRUCTION);
+
+ if (instr->operands_count > 0)
+ {
+ g_content_exporter_insert_text(exporter, stream, "\t", 1, RTT_NONE);
+
+ g_content_exporter_add_text(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[0]),
+ options, rendering, stream);
+
+ for (i = 1; i < instr->operands_count; i++)
+ {
+ g_content_exporter_insert_text(exporter, stream, ",", 1, RTT_NONE/* FIXME */);
+
+ g_content_exporter_insert_text(exporter, stream, " ", 1, RTT_NONE);
+
+ g_content_exporter_add_text(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[i]),
+ options, rendering, stream);
+
+ }
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction à transcrire. *
* format = format du binaire manipulé. *
* syntax = type de représentation demandée. *