summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-10-16 16:03:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-10-16 16:03:28 (GMT)
commit6f9563a0184e36fab8d0c2c38d151827784e331e (patch)
tree2d0e13667bc9efcc0f26c17572c9d38dabd89db7
parentc7a14e50bd002e3922969e9bae7816753aefb073 (diff)
Properly output routines documentation.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@268 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog28
-rw-r--r--src/analysis/disass/output.c2
-rw-r--r--src/analysis/routine.c173
-rw-r--r--src/analysis/routine.h13
-rw-r--r--src/analysis/type.c23
-rw-r--r--src/analysis/type.h7
-rw-r--r--src/analysis/types/basic.c36
-rw-r--r--src/analysis/types/cse-int.h3
-rw-r--r--src/analysis/types/cse.c25
-rw-r--r--src/analysis/types/encaps.c27
-rw-r--r--src/analysis/types/literal.c36
-rw-r--r--src/analysis/types/template.c42
-rw-r--r--src/analysis/variable.c35
-rw-r--r--src/analysis/variable.h3
-rw-r--r--src/decomp/lang/asm.c32
-rw-r--r--src/decomp/lang/java.c1
-rw-r--r--src/decomp/output-int.h7
-rw-r--r--src/decomp/output.c34
-rw-r--r--src/decomp/output.h8
-rw-r--r--src/glibext/gbufferline.c7
-rw-r--r--src/glibext/gbufferline.h4
21 files changed, 471 insertions, 75 deletions
diff --git a/ChangeLog b/ChangeLog
index 0acfbff..5d3e7c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+12-10-16 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/analysis/disass/output.c:
+ * src/analysis/routine.c:
+ * src/analysis/routine.h:
+ * src/analysis/type.c:
+ * src/analysis/type.h:
+ * src/analysis/types/basic.c:
+ * src/analysis/types/cse.c:
+ * src/analysis/types/cse-int.h:
+ * src/analysis/types/encaps.c:
+ * src/analysis/types/literal.c:
+ * src/analysis/types/template.c:
+ * src/analysis/variable.c:
+ * src/analysis/variable.h:
+ Properly output routines documentation.
+
+ * src/decomp/lang/asm.c:
+ * src/decomp/lang/java.c:
+ * src/decomp/output.c:
+ * src/decomp/output.h:
+ * src/decomp/output-int.h:
+ Provide a function to start routines documentation.
+
+ * src/glibext/gbufferline.c:
+ * src/glibext/gbufferline.h:
+ Remember last used column.
+
12-10-12 Cyrille Bagard <nocbos@gmail.com>
* configure.ac:
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 343973f..812b811 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -75,7 +75,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
if (raddr > iaddr) break;
- g_binary_routine_print_code(routines[i], output, buffer, false);
+ g_binary_routine_output_info(routines[i], output, buffer);
}
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index c26886f..a21b6e7 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -723,6 +723,90 @@ size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *routine, si
* *
* Paramètres : routine = routine à consulter. *
* *
+* Description : Fournit les instructions natives correspondantes. *
+* *
+* Retour : Ensemble d'instructions décompilées ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *routine)
+{
+ return routine->instr;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à mettre à jour. *
+* instr = série d'instructions à conserver. *
+* *
+* Description : Définit les instructions natives de la routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_routine_set_instructions(GBinRoutine *routine, GArchInstruction *instr)
+{
+ if (routine->instr != NULL)
+ g_object_unref(G_OBJECT(routine->instr));
+
+ routine->instr = instr;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à consulter. *
+* *
+* Description : Fournit les instructions décompilées correspondantes. *
+* *
+* Retour : Ensemble d'instructions décompilées ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDecInstruction *g_binary_routine_get_decomp_instructions(const GBinRoutine *routine)
+{
+ return routine->dinstr;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à mettre à jour. *
+* instr = série d'instructions à conserver. *
+* *
+* Description : Définit les instructions décompilées de la routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_routine_set_decomp_instructions(GBinRoutine *routine, GDecInstruction *instr)
+{
+ if (routine->dinstr != NULL)
+ g_object_unref(G_OBJECT(routine->dinstr));
+
+ routine->dinstr = instr;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à consulter. *
+* *
* Description : Décrit le prototype de la routine sous forme de caractères. *
* *
* Retour : Chaîne de caractères à libérer de la mémoire. *
@@ -803,84 +887,61 @@ char *_g_binary_routine_to_string(const GBinRoutine *routine, Routine2StringOpti
/******************************************************************************
* *
-* Paramètres : routine = routine à consulter. *
+* Paramètres : routine = routine à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
* *
-* Description : Fournit les instructions natives correspondantes. *
+* Description : Procède à l'impression de la description d'une routine. *
* *
-* Retour : Ensemble d'instructions décompilées ou NULL. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *routine)
+void g_binary_routine_output_info(const GBinRoutine *routine, GLangOutput *lang, GCodeBuffer *buffer)
{
- return routine->instr;
+ GBufferLine *line; /* Adresse d'une ligne nouvelle*/
+ const char *name; /* Nom humain de la routine */
+ size_t len; /* Taille de ce nom */
+ size_t i; /* Boucle de parcours */
-}
+ /* Type de retour */
+ line = g_lang_output_start_routine_info(lang, buffer);
-/******************************************************************************
-* *
-* Paramètres : routine = routine à mettre à jour. *
-* instr = série d'instructions à conserver. *
-* *
-* Description : Définit les instructions natives de la routine. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ g_data_type_output(routine->ret_type, lang, line, true, false);
-void g_binary_routine_set_instructions(GBinRoutine *routine, GArchInstruction *instr)
-{
- if (routine->instr != NULL)
- g_object_unref(G_OBJECT(routine->instr));
+ g_buffer_line_insert_text(line, BLC_LAST_USED, " ", 1, RTT_COMMENT);
- routine->instr = instr;
+ /* Nom de la routine */
-}
+ name = g_binary_routine_get_name(routine);
+ if (name != NULL) len = strlen(name);
+ else
+ {
+ name = "???";
+ len = 3;
+ }
+ g_buffer_line_insert_text(line, BLC_LAST_USED, name, len, RTT_COMMENT);
-/******************************************************************************
-* *
-* Paramètres : routine = routine à consulter. *
-* *
-* Description : Fournit les instructions décompilées correspondantes. *
-* *
-* Retour : Ensemble d'instructions décompilées ou NULL. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ /* Arguments éventuels... */
-GDecInstruction *g_binary_routine_get_decomp_instructions(const GBinRoutine *routine)
-{
- return routine->dinstr;
+ g_buffer_line_insert_text(line, BLC_LAST_USED, "(", 1, RTT_COMMENT);
-}
+ for (i = 0; i < routine->args_count; i++)
+ {
+ if (i > 0)
+ g_buffer_line_insert_text(line, BLC_LAST_USED, ", ", 2, RTT_COMMENT);
+ g_binary_variable_output(routine->args[i], lang, line, true, false);
-/******************************************************************************
-* *
-* Paramètres : routine = routine à mettre à jour. *
-* instr = série d'instructions à conserver. *
-* *
-* Description : Définit les instructions décompilées de la routine. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ }
-void g_binary_routine_set_decomp_instructions(GBinRoutine *routine, GDecInstruction *instr)
-{
- if (routine->dinstr != NULL)
- g_object_unref(G_OBJECT(routine->dinstr));
+ g_buffer_line_insert_text(line, BLC_LAST_USED, ")", 1, RTT_COMMENT);
- routine->dinstr = instr;
+ //g_lang_output_end_routine_prototype(lang, buffer, line);
}
diff --git a/src/analysis/routine.h b/src/analysis/routine.h
index 3622630..a13c460 100644
--- a/src/analysis/routine.h
+++ b/src/analysis/routine.h
@@ -142,11 +142,6 @@ void g_binary_routine_register_if_needed(GBinRoutine *, size_t, bool);
/* Donne l'indice d'une variable dans la liste d'une routine. */
size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *, size_t, bool);
-/* Décrit le prototype de la routine sous forme de caractères. */
-char *_g_binary_routine_to_string(const GBinRoutine *, Routine2StringOptions);
-
-#define g_binary_routine_to_string(r) _g_binary_routine_to_string((r), RSO_ALL)
-
/* Fournit les instructions natives correspondantes. */
GArchInstruction *g_binary_routine_get_instructions(const GBinRoutine *);
@@ -159,6 +154,14 @@ GDecInstruction *g_binary_routine_get_decomp_instructions(const GBinRoutine *);
/* Définit les instructions décompilées de la routine. */
void g_binary_routine_set_decomp_instructions(GBinRoutine *, GDecInstruction *);
+/* Décrit le prototype de la routine sous forme de caractères. */
+char *_g_binary_routine_to_string(const GBinRoutine *, Routine2StringOptions);
+
+#define g_binary_routine_to_string(r) _g_binary_routine_to_string((r), RSO_ALL)
+
+/* Procède à l'impression de la description d'une routine. */
+void g_binary_routine_output_info(const GBinRoutine *, GLangOutput *, GCodeBuffer *);
+
/* Procède à l'impression de la décompilation d'une routine. */
void g_binary_routine_print_code(const GBinRoutine *, GLangOutput *, GCodeBuffer *, bool);
diff --git a/src/analysis/type.c b/src/analysis/type.c
index ef75080..1f8cd0a 100644
--- a/src/analysis/type.c
+++ b/src/analysis/type.c
@@ -205,6 +205,29 @@ char *_g_data_type_to_string(const GDataType *type, bool simple)
/******************************************************************************
* *
+* Paramètres : type = routine à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_data_type_output(const GDataType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ type->output(type, lang, line, info, full);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = instance à mettre à jour. *
* qualifier = nouveau qualificatif pour la variable. *
* *
diff --git a/src/analysis/type.h b/src/analysis/type.h
index dde256e..5ce94ab 100644
--- a/src/analysis/type.h
+++ b/src/analysis/type.h
@@ -31,6 +31,8 @@
#include "../arch/archbase.h"
+#include "../decomp/output.h"
+#include "../glibext/gbufferline.h"
@@ -74,7 +76,7 @@ void g_data_type_set_namespace(GDataType *, GDataType *);
/* Décrit le type fourni sous forme de caractères. */
char *_g_data_type_to_string(const GDataType *, bool);
-#define g_data_type_to_string(t) _g_data_type_to_string((t), false)
+#define g_data_type_to_string(t) _g_data_type_to_string((t), true)
/* Ajoute un qualificatif à une instance de type. */
void g_data_type_add_qualifier(GDataType *, TypeQualifier);
@@ -82,7 +84,8 @@ void g_data_type_add_qualifier(GDataType *, TypeQualifier);
/* Indique la terminaison de la représentation du type. */
bool g_data_type_is_pointer(const GDataType *, bool);
-
+/* Procède à l'impression de la description d'un type. */
+void g_data_type_output(const GDataType *, GLangOutput *, GBufferLine *, bool, bool);
diff --git a/src/analysis/types/basic.c b/src/analysis/types/basic.c
index 436b04e..f8b3100 100644
--- a/src/analysis/types/basic.c
+++ b/src/analysis/types/basic.c
@@ -24,6 +24,7 @@
#include "basic.h"
+#include <malloc.h>
#include <string.h>
@@ -60,6 +61,9 @@ static GDataType *g_basic_type_dup(const GBasicType *);
/* Décrit le type fourni sous forme de caractères. */
static char *g_basic_type_to_string(const GBasicType *);
+/* Procède à l'impression de la description d'un type. */
+static void g_basic_type_output(const GBasicType *, GLangOutput *, GBufferLine *, bool, bool);
+
/* Indique le type défini pour un type basique. */
@@ -104,6 +108,7 @@ static void g_basic_type_init(GBasicType *type)
data_type->dup = (type_dup_fc)g_basic_type_dup;
data_type->to_string = (type_to_string_fc)g_basic_type_to_string;
+ data_type->output = (output_type_fc)g_basic_type_output;
}
@@ -292,6 +297,37 @@ static char *g_basic_type_to_string(const GBasicType *type)
/******************************************************************************
* *
+* Paramètres : type = type à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_basic_type_output(const GBasicType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ char *text; /* Version humaine à imprimer */
+ size_t len; /* Taille de cette version */
+
+ text = g_basic_type_to_string(type);
+ len = strlen(text);
+
+ g_buffer_line_insert_text(line, BLC_LAST_USED, text, len, info ? RTT_COMMENT : RTT_RAW);
+
+ free(text);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type à consulter. *
* *
* Description : Fournit le type de base géré par le type. *
diff --git a/src/analysis/types/cse-int.h b/src/analysis/types/cse-int.h
index 2599329..9ee020f 100644
--- a/src/analysis/types/cse-int.h
+++ b/src/analysis/types/cse-int.h
@@ -51,6 +51,9 @@ struct _GClassEnumTypeClass
/* Décrit le type fourni sous forme de caractères. */
char *g_class_enum_type_to_string(const GClassEnumType *);
+/* Procède à l'impression de la description d'un type. */
+void g_class_enum_type_output(const GClassEnumType *, GLangOutput *, GBufferLine *, bool, bool);
+
#endif /* _ANALYSIS_TYPES_CSE_INT_H */
diff --git a/src/analysis/types/cse.c b/src/analysis/types/cse.c
index 40d726e..4ee03ef 100644
--- a/src/analysis/types/cse.c
+++ b/src/analysis/types/cse.c
@@ -84,6 +84,7 @@ static void g_class_enum_type_init(GClassEnumType *type)
data_type->dup = (type_dup_fc)g_class_enum_type_dup;
data_type->to_string = (type_to_string_fc)g_class_enum_type_to_string;
+ data_type->output = (output_type_fc)g_class_enum_type_output;
}
@@ -151,3 +152,27 @@ char *g_class_enum_type_to_string(const GClassEnumType *type)
return strdup(type->name);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_class_enum_type_output(const GClassEnumType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ g_buffer_line_insert_text(line, BLC_LAST_USED, type->name, strlen(type->name),
+ info ? RTT_COMMENT : RTT_RAW);
+
+}
diff --git a/src/analysis/types/encaps.c b/src/analysis/types/encaps.c
index 492fd46..1d4b6f4 100644
--- a/src/analysis/types/encaps.c
+++ b/src/analysis/types/encaps.c
@@ -61,6 +61,9 @@ static GDataType *g_encapsulated_type_dup(const GEncapsulatedType *);
/* Décrit le type fourni sous forme de caractères. */
static char *g_encapsulated_type_to_string(const GEncapsulatedType *);
+/* Procède à l'impression de la description d'un type. */
+static void g_encapsulated_type_output(const GEncapsulatedType *, GLangOutput *, GBufferLine *, bool, bool);
+
/* Indique le type défini pour un type encapsulé. */
@@ -105,6 +108,7 @@ static void g_encapsulated_type_init(GEncapsulatedType *type)
data_type->dup = (type_dup_fc)g_encapsulated_type_dup;
data_type->to_string = (type_to_string_fc)g_encapsulated_type_to_string;
+ data_type->output = (output_type_fc)g_encapsulated_type_output;
}
@@ -256,6 +260,29 @@ static char *g_encapsulated_type_to_string(const GEncapsulatedType *type)
/******************************************************************************
* *
+* Paramètres : type = type à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_encapsulated_type_output(const GEncapsulatedType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ g_buffer_line_insert_text(line, BLC_LAST_USED, "!TODO!", 6, info ? RTT_COMMENT : RTT_RAW);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type à consulter. *
* *
* Description : Fournit le type d'encapsulation gérée par le type. *
diff --git a/src/analysis/types/literal.c b/src/analysis/types/literal.c
index 92c8254..50212ac 100644
--- a/src/analysis/types/literal.c
+++ b/src/analysis/types/literal.c
@@ -24,6 +24,7 @@
#include "literal.h"
+#include <malloc.h>
#include <stdio.h>
#include <string.h>
@@ -63,6 +64,9 @@ static GDataType *g_literal_type_dup(const GLiteralType *);
/* Décrit le type fourni sous forme de caractères. */
static char *g_literal_type_to_string(const GLiteralType *);
+/* Procède à l'impression de la description d'un type. */
+static void g_literal_type_output(const GLiteralType *, GLangOutput *, GBufferLine *, bool, bool);
+
/* Indique le type défini pour un type reposant sur des gabarits. */
@@ -107,6 +111,7 @@ static void g_literal_type_init(GLiteralType *type)
data_type->dup = (type_dup_fc)g_literal_type_dup;
data_type->to_string = (type_to_string_fc)g_literal_type_to_string;
+ data_type->output = (output_type_fc)g_literal_type_output;
}
@@ -203,3 +208,34 @@ static char *g_literal_type_to_string(const GLiteralType *type)
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_literal_type_output(const GLiteralType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ char *text; /* Version humaine à imprimer */
+ size_t len; /* Taille de cette version */
+
+ text = g_literal_type_to_string(type);
+ len = strlen(text);
+
+ g_buffer_line_insert_text(line, BLC_LAST_USED, text, len, info ? RTT_COMMENT : RTT_RAW);
+
+ free(text);
+
+}
diff --git a/src/analysis/types/template.c b/src/analysis/types/template.c
index 29d39bc..f26e038 100644
--- a/src/analysis/types/template.c
+++ b/src/analysis/types/template.c
@@ -64,6 +64,9 @@ static GDataType *g_template_type_dup(const GTemplateType *);
/* Décrit le type fourni sous forme de caractères. */
static char *g_template_type_to_string(const GTemplateType *);
+/* Procède à l'impression de la description d'un type. */
+static void g_template_type_output(const GTemplateType *, GLangOutput *, GBufferLine *, bool, bool);
+
/* Indique le type défini pour un type reposant sur des gabarits. */
@@ -109,6 +112,7 @@ static void g_template_type_init(GTemplateType *type)
data_type->dup = (type_dup_fc)g_template_type_dup;
data_type->to_string = (type_to_string_fc)g_template_type_to_string;
+ data_type->output = (output_type_fc)g_template_type_output;
ce_type = G_CLASS_ENUM_TYPE(type);
@@ -216,6 +220,44 @@ static char *g_template_type_to_string(const GTemplateType *type)
/******************************************************************************
* *
+* Paramètres : type = type à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'un type. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_template_type_output(const GTemplateType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ size_t i; /* Boucle de parcours */
+
+ g_class_enum_type_output(G_CLASS_ENUM_TYPE(type), lang, line, info, full);
+
+ g_buffer_line_insert_text(line, BLC_LAST_USED, "<", 1, info ? RTT_COMMENT : RTT_LTGT);
+
+ for (i = 0; i < type->models_count; i++)
+ {
+ if (i > 0)
+ g_buffer_line_insert_text(line, BLC_LAST_USED, ", ", 2, info ? RTT_COMMENT : RTT_SIGNS);
+
+ g_data_type_output(type->models[i], lang, line, info, full);
+
+ }
+
+ g_buffer_line_insert_text(line, BLC_LAST_USED, ">", 1, info ? RTT_COMMENT : RTT_LTGT);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type à mettre à jour. *
* list = élements du modèle sur lequel doit reposer le type. *
* *
diff --git a/src/analysis/variable.c b/src/analysis/variable.c
index 7ecf793..6a7c145 100644
--- a/src/analysis/variable.c
+++ b/src/analysis/variable.c
@@ -253,12 +253,12 @@ char *g_binary_variable_to_string(const GBinVariable *var, bool simple)
{
char *result; /* Valeur à retourner */
- result = strdup(""); /* FIXME : arg _g_data_type_to_string(var->type, simple);*/
+ result = _g_data_type_to_string(var->type, simple);
if (var->name != NULL)
{
if (!g_data_type_is_pointer(var->type, true))
- /*result = stradd(result, " ")*/;
+ result = stradd(result, " ");
result = stradd(result, var->name);
@@ -269,6 +269,37 @@ char *g_binary_variable_to_string(const GBinVariable *var, bool simple)
}
+/******************************************************************************
+* *
+* Paramètres : var = variable à afficher. *
+* lang = langage à utiliser pour la sortie humaine. *
+* buffer = tampon mis à disposition pour la sortie. *
+* info = nature du cadre de destination. *
+* full = besoin de descriptions étendues ? *
+* *
+* Description : Procède à l'impression de la description d'une variable. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_variable_output(const GBinVariable *var, GLangOutput *lang, GBufferLine *line, bool info, bool full)
+{
+ g_data_type_output(var->type, lang, line, info, full);
+
+ if (var->name != NULL)
+ {
+ if (!g_data_type_is_pointer(var->type, true))
+ g_buffer_line_insert_text(line, BLC_LAST_USED, " ", 1, RTT_COMMENT);
+
+ g_buffer_line_insert_text(line, BLC_LAST_USED, var->name, strlen(var->name), RTT_COMMENT);
+
+ }
+
+}
+
diff --git a/src/analysis/variable.h b/src/analysis/variable.h
index a68eac2..72b95e0 100644
--- a/src/analysis/variable.h
+++ b/src/analysis/variable.h
@@ -76,7 +76,8 @@ void g_binary_variable_set_owner(GBinVariable *, GDataType *);
/* Décrit la variable donnée sous forme de caractères. */
char *g_binary_variable_to_string(const GBinVariable *, bool);
-
+/* Procède à l'impression de la description d'une variable. */
+void g_binary_variable_output(const GBinVariable *, GLangOutput *, GBufferLine *, bool, bool);
diff --git a/src/decomp/lang/asm.c b/src/decomp/lang/asm.c
index 30c56cc..1767706 100644
--- a/src/decomp/lang/asm.c
+++ b/src/decomp/lang/asm.c
@@ -25,6 +25,7 @@
#include "../output-int.h"
+#include "../../analysis/type.h" /* TODO : remme */
@@ -56,6 +57,9 @@ static GBufferLine *g_asm_output_write_comments(GAsmOutput *, GCodeBuffer *, con
/* Imprime dans un tampon donné une méthode de comparaison. */
static void g_asm_output_write_comp_sign(GAsmOutput *, GBufferLine *, CompSignType);
+/* Débute la documentation d'une routine. */
+static GBufferLine *g_asm_output_start_routine_info(const GAsmOutput *, GCodeBuffer *);
+
/* Débute la définition d'une routine. */
static GBufferLine *g_asm_output_start_routine_prototype(GAsmOutput *, GCodeBuffer *, const GDataType *);
@@ -109,6 +113,8 @@ static void g_asm_output_init(GAsmOutput *output)
lang->comp_sign = (write_comp_sign_fc)g_asm_output_write_comp_sign;
+ lang->start_info = (start_rtn_info_fc)g_asm_output_start_routine_info;
+
lang->start_routine_proto = (rlgbuftp_fc)g_asm_output_start_routine_prototype;
lang->end_routine_proto = (lgbufln_fc)g_asm_output_end_routine_prototype;
@@ -221,6 +227,32 @@ static void g_asm_output_write_comp_sign(GAsmOutput *output, GBufferLine *line,
* *
* Paramètres : output = encadrant de l'impression en langage de prog. *
* buffer = tampon de sortie à disposition. *
+* *
+* Description : Débute la documentation d'une routine. *
+* *
+* Retour : Ligne nouvellement créée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBufferLine *g_asm_output_start_routine_info(const GAsmOutput *output, GCodeBuffer *buffer)
+{
+ GBufferLine *result; /* Adresse nouvelle à remonter */
+
+ result = g_code_buffer_append_new_line_fixme(buffer);
+
+ g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, "; ", 2, RTT_COMMENT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
* ret = type de retour de la routine traitée. *
* *
* Description : Débute la définition d'une routine. *
diff --git a/src/decomp/lang/java.c b/src/decomp/lang/java.c
index 5092f32..ae7fb70 100644
--- a/src/decomp/lang/java.c
+++ b/src/decomp/lang/java.c
@@ -25,6 +25,7 @@
#include "../output-int.h"
+#include "../../analysis/type.h" /* TODO : remme */
diff --git a/src/decomp/output-int.h b/src/decomp/output-int.h
index be057af..6c5f588 100644
--- a/src/decomp/output-int.h
+++ b/src/decomp/output-int.h
@@ -38,8 +38,11 @@ typedef GBufferLine * (* write_comments_fc) (GLangOutput *, GCodeBuffer *, const
/* Imprime dans un tampon donné une méthode de comparaison. */
typedef void (* write_comp_sign_fc) (GLangOutput *, GBufferLine *, CompSignType);
+/* Débute la documentation d'une routine. */
+typedef GBufferLine * (* start_rtn_info_fc) (const GLangOutput *, GCodeBuffer *);
+
/* Xxx. */
-typedef GBufferLine * (* rlgbuftp_fc) (GLangOutput *, GCodeBuffer *, const GDataType *);
+typedef GBufferLine * (* rlgbuftp_fc) (GLangOutput *, GCodeBuffer *, const void /*GDataType*/ *);
/* Xxx. */
typedef void (* lgbuf_fc) (GLangOutput *, GCodeBuffer *);
@@ -64,6 +67,8 @@ struct _GLangOutput
rlgbuftp_fc start_class; /* Début de définition */
lgbuf_fc end_class; /* Fin de définition de classe */
+ start_rtn_info_fc start_info; /* Début de documentation */
+
rlgbuftp_fc start_routine_proto; /* Début de prototype */
lgbufln_fc end_routine_proto; /* Fin de prototype */
lgbufln_fc start_routine_body; /* Début de définition */
diff --git a/src/decomp/output.c b/src/decomp/output.c
index 698ce0d..20e18a9 100644
--- a/src/decomp/output.c
+++ b/src/decomp/output.c
@@ -25,6 +25,7 @@
#include "output-int.h"
+#include "../analysis/type.h" /* TODO : remme */
@@ -216,12 +217,12 @@ void g_lang_output_write_comp_sign(GLangOutput *output, GBufferLine *line, CompS
* *
******************************************************************************/
-GBufferLine *g_lang_output_start_class(GLangOutput *output, GCodeBuffer *buffer, const GDataType *type)
+GBufferLine *g_lang_output_start_class(GLangOutput *output, GCodeBuffer *buffer, const void *type)
{
GBufferLine *result; /* Adresse nouvelle à remonter */
if (output->start_class != NULL)
- result = output->start_class(output, buffer, type);
+ result = output->start_class(output, buffer, (const GDataType *)type);
else result = NULL;
@@ -255,6 +256,33 @@ void g_lang_output_end_class(GLangOutput *output, GCodeBuffer *buffer)
* *
* Paramètres : output = encadrant de l'impression en langage de prog. *
* buffer = tampon de sortie à disposition. *
+* *
+* Description : Débute la documentation d'une routine. *
+* *
+* Retour : Ligne nouvellement créée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBufferLine *g_lang_output_start_routine_info(const GLangOutput *output, GCodeBuffer *buffer)
+{
+ GBufferLine *result; /* Adresse nouvelle à remonter */
+
+ if (output->start_routine_proto != NULL)
+ result = output->start_info(output, buffer);
+
+ else result = NULL;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : output = encadrant de l'impression en langage de prog. *
+* buffer = tampon de sortie à disposition. *
* ret = type de retour de la routine traitée. *
* *
* Description : Débute la définition d'une routine. *
@@ -265,7 +293,7 @@ void g_lang_output_end_class(GLangOutput *output, GCodeBuffer *buffer)
* *
******************************************************************************/
-GBufferLine *g_lang_output_start_routine_prototype(GLangOutput *output, GCodeBuffer *buffer, const GDataType *ret)
+GBufferLine *g_lang_output_start_routine_prototype(GLangOutput *output, GCodeBuffer *buffer, const void *ret)
{
GBufferLine *result; /* Adresse nouvelle à remonter */
diff --git a/src/decomp/output.h b/src/decomp/output.h
index 7eac6d8..f9ccd1d 100644
--- a/src/decomp/output.h
+++ b/src/decomp/output.h
@@ -25,7 +25,6 @@
#define _DECOMP_OUTPUT_H
-#include "../analysis/type.h"
#include "../glibext/gcodebuffer.h"
@@ -80,13 +79,16 @@ void g_lang_output_write_comp_sign(GLangOutput *, GBufferLine *, CompSignType);
/* Débute la définition d'une classe. */
-GBufferLine *g_lang_output_start_class(GLangOutput *, GCodeBuffer *, const GDataType *);
+GBufferLine *g_lang_output_start_class(GLangOutput *, GCodeBuffer *, const void *);
/* Termine la définition d'une classe. */
void g_lang_output_end_class(GLangOutput *, GCodeBuffer *);
+/* Débute la documentation d'une routine. */
+GBufferLine *g_lang_output_start_routine_info(const GLangOutput *, GCodeBuffer *);
+
/* Définit le prototype d'une routine. */
-GBufferLine *g_lang_output_start_routine_prototype(GLangOutput *, GCodeBuffer *, const GDataType *);
+GBufferLine *g_lang_output_start_routine_prototype(GLangOutput *, GCodeBuffer *, const void *);
/* Marque la fin du prototype d'une routine. */
void g_lang_output_end_routine_prototype(GLangOutput *, GCodeBuffer *, GBufferLine *);
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index 7f88bff..6e3c928 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -87,6 +87,7 @@ struct _GBufferLine
buffer_line_column columns[BLC_COUNT]; /* Répartition du texte */
BufferLineColumn merge_start; /* Début de la zone globale */
+ BufferLineColumn last_used; /* Dernière colonne utilisée */
};
@@ -472,6 +473,7 @@ static void g_buffer_line_init(GBufferLine *line)
reset_column(&line->columns[i]);
line->merge_start = BLC_COUNT;
+ line->last_used = BLC_COUNT;
}
@@ -623,6 +625,11 @@ void g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn column, const
class = G_BUFFER_LINE_GET_CLASS(line);
+ if (column == BLC_LAST_USED)
+ column = line->last_used;
+ else
+ line->last_used = column;
+
segment = g_buffer_segment_new(class->context, class->attribs[type], text, length);
g_buffer_line_add_segment(line, column, segment);
diff --git a/src/glibext/gbufferline.h b/src/glibext/gbufferline.h
index 1bba0ba..3f0676a 100644
--- a/src/glibext/gbufferline.h
+++ b/src/glibext/gbufferline.h
@@ -59,7 +59,9 @@ typedef enum _BufferLineColumn
BLC_ASSEMBLY, /* Code pour assembleur */
BLC_COMMENTS, /* Commentaires éventuels */
- BLC_COUNT
+ BLC_COUNT,
+
+ BLC_LAST_USED /* Dernière colonne utilisée */
} BufferLineColumn;