diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-07-02 22:39:25 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-07-02 22:40:18 (GMT) |
commit | de2cb8e2fad4a3031d7b7c2cb189a6dbdaf8d5a9 (patch) | |
tree | eb9b01fc893ace47e0311ebca7511162769c36be /src/analysis/routine.c | |
parent | 4630eb7a2b0b61a4e9ea3a99e7a8cdaba05392cd (diff) |
Extented the types definitions.
Diffstat (limited to 'src/analysis/routine.c')
-rw-r--r-- | src/analysis/routine.c | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/src/analysis/routine.c b/src/analysis/routine.c index 6e56e2d..08160b8 100644 --- a/src/analysis/routine.c +++ b/src/analysis/routine.c @@ -183,7 +183,7 @@ GBinRoutine *g_binary_routine_new_constructor(GDataType *type) result = g_object_new(G_TYPE_BIN_ROUTINE, NULL); - g_binary_routine_set_name(result, _g_data_type_to_string(type, true)); + g_binary_routine_set_name(result, g_data_type_to_string(type, true)); return result; @@ -257,6 +257,9 @@ void g_binary_routine_set_type(GBinRoutine *routine, RoutineType type) void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace, const char *sep) { + if (routine->namespace != NULL) + g_object_unref(G_OBJECT(routine->namespace)); + routine->namespace = namespace; routine->ns_sep = sep; @@ -267,11 +270,11 @@ void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace, /****************************************************************************** * * -* Paramètres : routine = routine à mettre à jour. * +* Paramètres : routine = routine à consulter. * * * * Description : Fournit le groupe d'appartenance d'une routine donnée. * * * -* Retour : éventuelle instance d'appartenance ou NULL. * +* Retour : Eventuelle instance d'appartenance ou NULL. * * * * Remarques : - * * * @@ -279,7 +282,14 @@ void g_binary_routine_set_namespace(GBinRoutine *routine, GDataType *namespace, GDataType *g_binary_routine_get_namespace(const GBinRoutine *routine) { - return routine->namespace; + GDataType *result; /* Espace à renvoyer */ + + result = routine->namespace; + + if (result != NULL) + g_object_ref(G_OBJECT(result)); + + return result; } @@ -375,7 +385,7 @@ GDataType *g_binary_routine_get_type_from_name(const GBinRoutine *routine) /****************************************************************************** * * * Paramètres : routine = routine à mettre à jour. * -* type = indication sur le type de retour. * +* ret = indication sur le type de retour. * * * * Description : Définit le type de retour d'une routine. * * * @@ -385,15 +395,12 @@ GDataType *g_binary_routine_get_type_from_name(const GBinRoutine *routine) * * ******************************************************************************/ -void g_binary_routine_set_return_type(GBinRoutine *routine, GDataType *type) +void g_binary_routine_set_return_type(GBinRoutine *routine, GDataType *ret) { if (routine->ret_type != NULL) g_object_unref(G_OBJECT(routine->ret_type)); - routine->ret_type = type; - - if (type != NULL) - g_object_ref(G_OBJECT(type)); + routine->ret_type = ret; } @@ -412,7 +419,14 @@ void g_binary_routine_set_return_type(GBinRoutine *routine, GDataType *type) GDataType *g_binary_routine_get_return_type(const GBinRoutine *routine) { - return routine->ret_type; + GDataType *result; /* Type de retour à renvoyer */ + + result = routine->ret_type; + + if (result != NULL) + g_object_ref(G_OBJECT(result)); + + return result; } @@ -544,7 +558,7 @@ static void g_binary_routine_reset_declarator(GBinRoutine *routine, bool full) /****************************************************************************** * * * Paramètres : routine = routine à mettre à jour. * -* full = indique si la liste des arguments est à ajouter. * +* include = doit-on inclure les espaces de noms ? * * * * Description : Fournit le nom humain d'une routine. * * * @@ -554,7 +568,7 @@ static void g_binary_routine_reset_declarator(GBinRoutine *routine, bool full) * * ******************************************************************************/ -const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) +const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool include) { char *new; /* Nouvelle description */ char *namespace; /* Groupe d'appartenance */ @@ -564,13 +578,13 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) if (routine->cached_decl == NULL) { if (routine->full_name != NULL) - new = _g_data_type_to_string(routine->full_name, false); + 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, false); + namespace = g_data_type_to_string(routine->namespace, include); new = strprep(new, routine->ns_sep); new = strprep(new, namespace); @@ -585,7 +599,7 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) } - if (full && routine->cached_full_decl == NULL) + if (include && routine->cached_full_decl == NULL) { /* Type de retour */ @@ -593,9 +607,11 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) new = strdup("??? "); else { - new = _g_data_type_to_string(routine->ret_type, true); - if (!g_data_type_is_pointer(routine->ret_type, true)) + 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 */ @@ -610,7 +626,7 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) { if (i > 0) new = stradd(new, ", "); - typestr = g_binary_variable_to_string(routine->args[i], true); + typestr = g_binary_variable_to_string(routine->args[i], include); new = stradd(new, typestr); free(typestr); @@ -624,7 +640,7 @@ const char *g_binary_routine_get_declarator(GBinRoutine *routine, bool full) } - return (full ? routine->cached_full_decl : routine->cached_decl); + return (include ? routine->cached_full_decl : routine->cached_decl); } @@ -844,6 +860,7 @@ void g_binary_routine_set_decomp_instructions(GBinRoutine *routine, GDecInstruct /****************************************************************************** * * * Paramètres : routine = routine à consulter. * +* include = doit-on inclure les espaces de noms ? * * * * Description : Décrit le prototype de la routine sous forme de caractères. * * * @@ -853,7 +870,7 @@ void g_binary_routine_set_decomp_instructions(GBinRoutine *routine, GDecInstruct * * ******************************************************************************/ -char *_g_binary_routine_to_string(const GBinRoutine *routine, Routine2StringOptions options) +char *g_binary_routine_to_string(const GBinRoutine *routine, bool include) { char *result; /* Chaîne à renvoyer */ char *namespace; /* Groupe d'appartenance */ @@ -880,9 +897,11 @@ char *_g_binary_routine_to_string(const GBinRoutine *routine, Routine2StringOpti if (routine->ret_type == NULL) result = strdup("??? "); else { - result = _g_data_type_to_string(routine->ret_type, !(options & RSO_LONG_TYPE)); - if (!g_data_type_is_pointer(routine->ret_type, true)) + result = 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))) result = stradd(result, " "); + } break; @@ -890,12 +909,12 @@ char *_g_binary_routine_to_string(const GBinRoutine *routine, Routine2StringOpti /* Nom de la routine */ - if (options & RSO_NAMESPACE && routine->namespace != NULL) + if (routine->namespace != NULL) { - namespace = g_data_type_to_string(routine->namespace); + namespace = g_data_type_to_string(routine->namespace, include); result = stradd(result, namespace); - result = stradd(result, "." /* FIXME */); + result = stradd(result, routine->ns_sep); free(namespace); @@ -914,7 +933,7 @@ char *_g_binary_routine_to_string(const GBinRoutine *routine, Routine2StringOpti { if (i > 0) result = stradd(result, ", "); - typestr = g_binary_variable_to_string(routine->args[i], !(options & RSO_LONG_TYPE)); + typestr = g_binary_variable_to_string(routine->args[i], include); result = stradd(result, typestr); free(typestr); |