summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-07-14 09:49:51 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-07-14 09:49:51 (GMT)
commit9371129c1b7aa830ed889abd4481cb505d90c4a7 (patch)
tree579dd07fc31bab09c30e0dcdc60a356d5eaac99e
parent412f9fd31e625dbb2b00c25b6cc6b4753acd409d (diff)
Indented the output of decompilations.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@249 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog7
-rw-r--r--src/decomp/lang/java.c14
-rw-r--r--src/glibext/gcodebuffer.c46
-rw-r--r--src/glibext/gcodebuffer.h6
4 files changed, 71 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ec0c67..c66d0fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+12-07-14 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/decomp/lang/java.c:
+ * src/glibext/gcodebuffer.c:
+ * src/glibext/gcodebuffer.h:
+ Indent the output of decompilations.
+
12-07-08 Cyrille Bagard <nocbos@gmail.com>
* po/fr.po:
diff --git a/src/decomp/lang/java.c b/src/decomp/lang/java.c
index 7c5750b..e5ebdf9 100644
--- a/src/decomp/lang/java.c
+++ b/src/decomp/lang/java.c
@@ -346,18 +346,24 @@ static void g_java_output_write_comp_sign(GJavaOutput *output, GBufferLine *line
static GBufferLine *g_java_output_start_class(GJavaOutput *output, GCodeBuffer *buffer, const GOpenidaType *type)
{
GBufferLine *result; /* Adresse nouvelle à remonter */
+ char *name; /* Désignation humaine */
result = g_code_buffer_append_new_line_fixme(buffer);
g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "class", 5, RTT_KEY_WORD);
g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
- /* TODO */
- g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "XXX", 3, RTT_RAW);
+ name = _g_openida_type_to_string(type, true);
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, name, strlen(name), RTT_RAW);
+ free(name);
g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " ", 1, RTT_RAW);
g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "{", 1, RTT_HOOK);
+ result = g_code_buffer_append_new_line_fixme(buffer);
+
+ g_code_buffer_inc_indentation(buffer);
+
return result;
}
@@ -380,10 +386,14 @@ static void g_java_output_end_class(GJavaOutput *output, GCodeBuffer *buffer)
{
GBufferLine *result; /* Adresse nouvelle à remonter */
+ g_code_buffer_dec_indentation(buffer);
+
result = g_code_buffer_append_new_line_fixme(buffer);
g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "}", 1, RTT_HOOK);
+ result = g_code_buffer_append_new_line_fixme(buffer);
+
return result;
}
diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c
index 97d6505..fe00e2d 100644
--- a/src/glibext/gcodebuffer.c
+++ b/src/glibext/gcodebuffer.c
@@ -97,6 +97,8 @@ struct _GCodeBuffer
size_t count; /* Quantité en cache */
size_t used; /* Quantité utilisée */
+ size_t indent; /* Indentation des lignes */
+
};
/* Tampon pour code désassemblé (classe) */
@@ -420,6 +422,7 @@ static size_t g_code_buffer_get_index_from_address(GCodeBuffer *buffer, vmpa_t a
GBufferLine *g_code_buffer_append_new_line(GCodeBuffer *buffer, vmpa_t addr)
{
GBufferLine *result; /* Instance à retourner */
+ size_t i; /* Boucle de parcours */
if (buffer->used == buffer->count)
{
@@ -431,6 +434,9 @@ GBufferLine *g_code_buffer_append_new_line(GCodeBuffer *buffer, vmpa_t addr)
result = g_buffer_line_new(addr);
buffer->lines[buffer->used++] = result;
+ for (i = 0; i < buffer->indent; i++)
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, " ", 4, RTT_RAW);
+
return result;
}
@@ -438,6 +444,46 @@ GBufferLine *g_code_buffer_append_new_line(GCodeBuffer *buffer, vmpa_t addr)
/******************************************************************************
* *
+* Paramètres : buffer = composant GTK à mettre à jour. *
+* *
+* Description : Augmente l'indentation des prochaines lignes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_code_buffer_inc_indentation(GCodeBuffer *buffer)
+{
+ buffer->indent++;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : buffer = composant GTK à mettre à jour. *
+* *
+* Description : Diminue l'indentation des prochaines lignes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_code_buffer_dec_indentation(GCodeBuffer *buffer)
+{
+ /* BUG_ON(buffer->indent == 0) */
+
+ buffer->indent--;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : buffer = tampon de données à utiliser. *
* start = première adresse visée ou 0. *
* end = dernière adresse visée ou VMPA_MAX. *
diff --git a/src/glibext/gcodebuffer.h b/src/glibext/gcodebuffer.h
index 3fc6155..1cac790 100644
--- a/src/glibext/gcodebuffer.h
+++ b/src/glibext/gcodebuffer.h
@@ -62,6 +62,12 @@ GCodeBuffer *g_code_buffer_new(void);
/* Ajoute une nouvelle ligne à un tampon pour code désassemblé. */
GBufferLine *g_code_buffer_append_new_line(GCodeBuffer *, vmpa_t);
+/* Augmente l'indentation des prochaines lignes. */
+void g_code_buffer_inc_indentation(GCodeBuffer *);
+
+/* Diminue l'indentation des prochaines lignes. */
+void g_code_buffer_dec_indentation(GCodeBuffer *);
+
/* Traitement d'une ligne parcourue. */
typedef bool (* process_line_fc) (GCodeBuffer *, GBufferLine *, void *);