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.c96
1 files changed, 73 insertions, 23 deletions
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index 4bbd712..cfa7cd5 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -43,17 +43,15 @@ struct _GBinRoutine
RoutineType type; /* Type de routine */
- variable *ret_type; /* Type retourné */
+ GOpenidaType *ret_type; /* Type retourné */
char *name; /* Désignation humaine */
+ GOpenidaType *full_name; /* Désignation très complète */
- variable **args_types; /* Types d'arguments */
- size_t old_args_count; /* Nombre d'arguments */
-
- GUnknownVariable **args; /* Arguments de la routines */
+ GBinVariable **args; /* Arguments de la routines */
size_t args_count; /* Nombre d'arguments */
- GUnknownVariable **locals; /* Variables locales du code */
+ GBinVariable **locals; /* Variables locales du code */
size_t locals_count; /* Nombre de variables locales */
};
@@ -356,6 +354,9 @@ void g_binary_routine_set_name(GBinRoutine *routine, char *name)
const char *g_binary_routine_get_name(const GBinRoutine *routine)
{
+ if (routine->name == NULL && routine->full_name != NULL)
+ g_binary_routine_set_name(routine, g_openida_type_to_string(routine->full_name));
+
return routine->name;
}
@@ -364,7 +365,49 @@ const char *g_binary_routine_get_name(const GBinRoutine *routine)
/******************************************************************************
* *
* Paramètres : routine = routine à mettre à jour. *
-* var = variable représentant un type de retour. *
+* type = désignation complète du nom de la routine. *
+* *
+* Description : Définit de façon indirecte le nom humain d'une routine. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_binary_routine_set_name_from_type(GBinRoutine *routine, GOpenidaType *type)
+{
+ if (routine->full_name != NULL)
+ g_object_unref(G_OBJECT(routine->full_name));
+
+ routine->full_name = type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à consulter. *
+* *
+* Description : Fournit le type construisant le nom humain d'une routine. *
+* *
+* Retour : Eventuel type à l'origine du nom ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const GOpenidaType *g_binary_routine_get_type_from_name(const GBinRoutine *routine)
+{
+ return routine->full_name;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : routine = routine à mettre à jour. *
+* type = indication sur le type de retour. *
* *
* Description : Définit le type de retour d'une routine. *
* *
@@ -374,12 +417,13 @@ const char *g_binary_routine_get_name(const GBinRoutine *routine)
* *
******************************************************************************/
-void g_binary_routine_set_return_type(GBinRoutine *routine, variable *var)
+void g_binary_routine_set_return_type(GBinRoutine *routine, GOpenidaType *type)
{
if (routine->ret_type != NULL)
- delete_var(routine->ret_type);
+ g_object_unref(G_OBJECT(routine->ret_type));
- routine->ret_type = var;
+ routine->ret_type = type;
+ g_object_ref(G_OBJECT(type));
}
@@ -397,14 +441,14 @@ void g_binary_routine_set_return_type(GBinRoutine *routine, variable *var)
* *
******************************************************************************/
-void g_binary_routine_add_arg(GBinRoutine *routine, variable *var)
+void g_binary_routine_add_arg(GBinRoutine *routine, GBinVariable *var)
{
- routine->old_args_count++;
+ routine->args_count++;
- routine->args_types = (variable **)realloc(routine->args_types,
- routine->old_args_count * sizeof(variable *));
+ routine->args = (GBinVariable **)realloc(routine->args,
+ routine->args_count * sizeof(GBinVariable *));
- routine->args_types[routine->old_args_count - 1] = var;
+ routine->args[routine->args_count - 1] = var;
}
@@ -425,6 +469,7 @@ void g_binary_routine_add_arg(GBinRoutine *routine, variable *var)
void g_binary_routine_register_if_needed(GBinRoutine *routine, size_t offset, bool local)
{
+#if 0 /* FIXME */
GUnknownVariable ***list; /* Liste à manipuler */
size_t *count; /* Taille de la liste */
bool found; /* Indication de présence */
@@ -464,7 +509,7 @@ void g_binary_routine_register_if_needed(GBinRoutine *routine, size_t offset, bo
}
-
+#endif
}
@@ -484,6 +529,7 @@ void g_binary_routine_register_if_needed(GBinRoutine *routine, size_t offset, bo
size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *routine, size_t offset, bool local)
{
+#if 0 /* FIXME */
size_t result; /* Indice à renvoyer */
GUnknownVariable ***list; /* Liste à manipuler */
size_t *count; /* Taille de la liste */
@@ -507,6 +553,9 @@ size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *routine, si
result = i;
return result;
+#endif
+
+ return SIZE_MAX;
}
@@ -534,12 +583,12 @@ char *g_binary_routine_to_string(const GBinRoutine *routine)
switch (routine->type)
{
case RTT_CONSTRUCTOR:
- result = strdup(routine->name);
+ result = strdup(g_binary_routine_get_name(routine));
result = stradd(result, "::");
break;
case RTT_DESTRUCTOR:
- result = strdup(routine->name);
+ result = strdup(g_binary_routine_get_name(routine));
result = stradd(result, "::~");
break;
@@ -548,8 +597,9 @@ char *g_binary_routine_to_string(const GBinRoutine *routine)
if (routine->ret_type == NULL) result = strdup("??? ");
else
{
- result = var_to_string(routine->ret_type);
- result = stradd(result, " ");
+ result = g_openida_type_to_string(routine->ret_type);
+ if (!g_openida_type_is_pointer(routine->ret_type, true))
+ result = stradd(result, " ");
}
break;
@@ -557,17 +607,17 @@ char *g_binary_routine_to_string(const GBinRoutine *routine)
/* Nom de la routine */
- result = stradd(result, routine->name);
+ result = stradd(result, g_binary_routine_get_name(routine));
/* Liste des arguments */
result = stradd(result, "(");
- for (i = 0; i < routine->old_args_count; i++)
+ for (i = 0; i < routine->args_count; i++)
{
if (i > 0) result = stradd(result, ", ");
- typestr = var_to_string(routine->args_types[i]);
+ typestr = g_binary_variable_to_string(routine->args[i]);
result = stradd(result, typestr);
free(typestr);