summaryrefslogtreecommitdiff
path: root/src/analysis/routine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/routine.c')
-rw-r--r--src/analysis/routine.c164
1 files changed, 25 insertions, 139 deletions
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index 08160b8..43097cc 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -57,9 +57,6 @@ struct _GBinRoutine
GBinVariable **args; /* Arguments de la routines */
size_t args_count; /* Nombre d'arguments */
- char *cached_decl; /* Cache pour désignation #1 */
- char *cached_full_decl; /* Cache pour désignation #2 */
-
GBinVariable **locals; /* Variables locales du code */
size_t locals_count; /* Nombre de variables locales */
@@ -83,11 +80,8 @@ static void g_bin_routine_class_init(GBinRoutineClass *);
/* Initialise une instance représentation de routine. */
static void g_bin_routine_init(GBinRoutine *);
-/* Vide le cache des descriptions humaines. */
-static void g_binary_routine_reset_declarator(GBinRoutine *, bool);
-
/* Fournit une étiquette pour viser une routine. */
-static const char *g_binary_routine_get_label(const GBinRoutine *);
+static char *g_binary_routine_get_label(const GBinRoutine *);
@@ -263,8 +257,6 @@ void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace,
routine->namespace = namespace;
routine->ns_sep = sep;
- g_binary_routine_reset_declarator(routine, false);
-
}
@@ -314,8 +306,6 @@ void g_binary_routine_set_name(GBinRoutine *routine, char *name)
routine->name = name;
- g_binary_routine_reset_declarator(routine, true);
-
}
@@ -358,8 +348,6 @@ void g_binary_routine_set_name_from_type(GBinRoutine *routine, GDataType *type)
routine->full_name = type;
- g_binary_routine_reset_declarator(routine, true);
-
}
@@ -377,7 +365,14 @@ void g_binary_routine_set_name_from_type(GBinRoutine *routine, GDataType *type)
GDataType *g_binary_routine_get_type_from_name(const GBinRoutine *routine)
{
- return routine->full_name;
+ GDataType *result; /* Type à retourner */
+
+ result = routine->full_name;
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
}
@@ -527,40 +522,9 @@ void g_binary_routine_remove_arg(GBinRoutine *routine, size_t index)
/******************************************************************************
* *
-* Paramètres : routine = routine à mettre à jour. *
-* full = indique la portée de la réinitialisation. *
-* *
-* Description : Vide le cache des descriptions humaines. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_binary_routine_reset_declarator(GBinRoutine *routine, bool full)
-{
- if (full && routine->cached_decl != NULL)
- {
- free(routine->cached_decl);
- routine->cached_decl = NULL;
- }
-
- if (routine->cached_full_decl != NULL)
- {
- free(routine->cached_full_decl);
- routine->cached_full_decl = NULL;
- }
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : routine = routine à mettre à jour. *
-* include = doit-on inclure les espaces de noms ? *
+* Paramètres : routine = routine à manipuler. *
* *
-* Description : Fournit le nom humain d'une routine. *
+* Description : Fournit une étiquette pour viser une routine. *
* *
* Retour : Désignation humainement lisible ou NULL si non définie. *
* *
@@ -568,98 +532,17 @@ static void g_binary_routine_reset_declarator(GBinRoutine *routine, bool full)
* *
******************************************************************************/
-const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool include)
+static char *g_binary_routine_get_label(const GBinRoutine *routine)
{
- char *new; /* Nouvelle description */
- char *namespace; /* Groupe d'appartenance */
- size_t i; /* Boucle de parcours */
- char *typestr; /* Stockage de nom temporaire */
-
- if (routine->cached_decl == NULL)
- {
- if (routine->full_name != NULL)
- new = g_data_type_to_string(routine->full_name, include);
- else
- new = strdup(routine->name != NULL ? routine->name : "");
-
- if (routine->namespace != NULL)
- {
- namespace = g_data_type_to_string(routine->namespace, include);
-
- new = strprep(new, routine->ns_sep);
- new = strprep(new, namespace);
-
- free(namespace);
-
- }
-
- /* Mémorisation finale */
-
- routine->cached_decl = new;
-
- }
-
- if (include && routine->cached_full_decl == NULL)
- {
- /* Type de retour */
-
- if (routine->ret_type == NULL)
- new = strdup("??? ");
- else
- {
- new = g_data_type_to_string(routine->ret_type, include);
-
- if (!(g_data_type_is_pointer(routine->ret_type) || g_data_type_is_reference(routine->ret_type)))
- new = stradd(new, " ");
-
- }
-
- /* Nom de la routine */
-
- new = stradd(new, routine->cached_decl);
-
- /* Liste des arguments */
-
- new = stradd(new, "(");
-
- for (i = 0; i < routine->args_count; i++)
- {
- if (i > 0) new = stradd(new, ", ");
-
- typestr = g_binary_variable_to_string(routine->args[i], include);
- new = stradd(new, typestr);
- free(typestr);
-
- }
-
- new = stradd(new, ")");
-
- /* Mémorisation finale */
-
- routine->cached_full_decl = new;
-
- }
-
- return (include ? routine->cached_full_decl : routine->cached_decl);
-
-}
+ char *result; /* Etiquette à renvoyer */
+ if (routine->full_name != NULL)
+ result = g_data_type_to_string(routine->full_name, false);
-/******************************************************************************
-* *
-* Paramètres : routine = routine à manipuler. *
-* *
-* Description : Fournit une étiquette pour viser une routine. *
-* *
-* Retour : Désignation humainement lisible ou NULL si non définie. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ else
+ result = strdup(routine->name != NULL ? routine->name : "");
-static const char *g_binary_routine_get_label(const GBinRoutine *routine)
-{
- return g_binary_routine_get_declarator(routine, false);
+ return result;
}
@@ -874,7 +757,7 @@ char *g_binary_routine_to_string(const GBinRoutine *routine, bool include)
{
char *result; /* Chaîne à renvoyer */
char *namespace; /* Groupe d'appartenance */
- const char *name; /* Désignation de la routine */
+ char *name; /* Désignation de la routine */
size_t i; /* Boucle de parcours */
char *typestr; /* Stockage de nom temporaire */
@@ -883,12 +766,12 @@ char *g_binary_routine_to_string(const GBinRoutine *routine, bool include)
switch (routine->type)
{
case RTT_CONSTRUCTOR:
- result = strdup(g_binary_routine_get_name(routine));
+ result = g_binary_routine_get_label(routine);
result = stradd(result, "." /* FIXME */);
break;
case RTT_DESTRUCTOR:
- result = strdup(g_binary_routine_get_name(routine));
+ result = g_binary_routine_get_label(routine);
result = stradd(result, "::~");
break;
@@ -920,10 +803,13 @@ char *g_binary_routine_to_string(const GBinRoutine *routine, bool include)
}
- name = g_binary_routine_get_name(routine);
+ name = g_binary_routine_get_label(routine);
if (name != NULL)
+ {
result = stradd(result, name);
+ free(name);
+ }
/* Liste des arguments */