diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/instruction.c | 91 | ||||
| -rw-r--r-- | src/arch/instruction.h | 6 | 
2 files changed, 97 insertions, 0 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 55aee49..1bf3c9b 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -25,6 +25,7 @@  #include <assert.h> +#include <malloc.h>  #include <stdarg.h>  #include <string.h> @@ -947,6 +948,51 @@ const instr_link_t *g_arch_instruction_get_source(GArchInstruction *instr, size_  /******************************************************************************  *                                                                             *  *  Paramètres  : instr = instruction dont les informations sont à consulter.  * +*                count = quantié de liens présents. [OUT]                     * +*                                                                             * +*  Description : Fournit tous les détails d'origine d'une instruction donnée. * +*                                                                             * +*  Retour      : Liens vers des instructions d'origine à libérer.             * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +instr_link_t *g_arch_instruction_get_sources(GArchInstruction *instr, size_t *count) +{ +    instr_link_t *result;                   /* Détails présents à renvoyer */ +    size_t i;                               /* Boucle de parcours          */ +    const instr_link_t *link;               /* Lien à fournir              */ + +    g_arch_instruction_lock_src(instr); + +    *count = g_arch_instruction_count_sources(instr); + +    if (*count == 0) +        result = NULL; + +    else +    { +        result = (instr_link_t *)malloc(*count * sizeof(instr_link_t)); + +        for (i = 0; i < *count; i++) +        { +            link = g_arch_instruction_get_source(instr, i); +            memcpy(&result[i], link, sizeof(instr_link_t)); +        } + +    } + +    g_arch_instruction_unlock_src(instr); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : instr = instruction dont les informations sont à consulter.  *  *                                                                             *  *  Description : Donne le nombre d'instructions non naturellement suivantes.  *  *                                                                             * @@ -1040,6 +1086,51 @@ GArchInstruction *g_arch_instruction_get_given_destination(GArchInstruction *ins  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : instr = instruction dont les informations sont à consulter.  * +*                count = quantié de liens présents. [OUT]                     * +*                                                                             * +*  Description : Fournit tous les détails de destination d'une instruction.   * +*                                                                             * +*  Retour      : Liens vers des instructions de destination à libérer.        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +instr_link_t *g_arch_instruction_get_destinations(GArchInstruction *instr, size_t *count) +{ +    instr_link_t *result;                   /* Détails présents à renvoyer */ +    size_t i;                               /* Boucle de parcours          */ +    const instr_link_t *link;               /* Lien à fournir              */ + +    g_arch_instruction_lock_dest(instr); + +    *count = g_arch_instruction_count_destinations(instr); + +    if (*count == 0) +        result = NULL; + +    else +    { +        result = (instr_link_t *)malloc(*count * sizeof(instr_link_t)); + +        for (i = 0; i < *count; i++) +        { +            link = g_arch_instruction_get_destination(instr, i); +            memcpy(&result[i], link, sizeof(instr_link_t)); +        } + +    } + +    g_arch_instruction_unlock_dest(instr); + +    return result; + +} + +  /* ---------------------------------------------------------------------------------- */  /*                       CONVERSIONS DU FORMAT DES INSTRUCTIONS                       */ diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 34dc59f..0c8510a 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -236,6 +236,9 @@ size_t g_arch_instruction_count_sources(const GArchInstruction *);  /* Fournit les détails d'une origine d'une instruction donnée. */  const instr_link_t *g_arch_instruction_get_source(GArchInstruction *, size_t); +/* Fournit tous les détails d'origine d'une instruction donnée. */ +instr_link_t *g_arch_instruction_get_sources(GArchInstruction *, size_t *); +  #define g_arch_instruction_lock_dest(ins) g_arch_instruction_lock_unlock_links(ins, false, true)  #define g_arch_instruction_unlock_dest(ins) g_arch_instruction_lock_unlock_links(ins, false, false) @@ -248,6 +251,9 @@ const instr_link_t *g_arch_instruction_get_destination(GArchInstruction *, size_  /* Fournit la destination d'une instruction et d'un type donné. */  GArchInstruction *g_arch_instruction_get_given_destination(GArchInstruction *, InstructionLinkType); +/* Fournit tous les détails de destination d'une instruction. */ +instr_link_t *g_arch_instruction_get_destinations(GArchInstruction *, size_t *); +  /* --------------------- CONVERSIONS DU FORMAT DES INSTRUCTIONS --------------------- */  | 
