diff options
Diffstat (limited to 'src/decomp/instr')
| -rw-r--r-- | src/decomp/instr/ite.c | 57 | ||||
| -rw-r--r-- | src/decomp/instr/ite.h | 9 | 
2 files changed, 57 insertions, 9 deletions
| diff --git a/src/decomp/instr/ite.c b/src/decomp/instr/ite.c index 60627a6..5cdeb87 100644 --- a/src/decomp/instr/ite.c +++ b/src/decomp/instr/ite.c @@ -33,9 +33,7 @@ struct _GITEInstruction  {      GDecInstruction parent;                 /* A laisser en premier        */ -    bool inverse;                           /* Condition inversée          */ - -    GDecExpression *cond;                   /* Condition prise en compte   */ +    GCondExpression *cond;                  /* Condition prise en compte   */      GDecInstruction *true_branch;           /* Condition vérifiée          */      GDecInstruction *false_branch;          /* Condition non vérifiée      */ @@ -144,7 +142,7 @@ static void g_ite_instruction_init(GITEInstruction *instr)  *                                                                             *  ******************************************************************************/ -GDecInstruction *g_ite_instruction_new(GDecExpression *cond, vmpa_t if_true, vmpa_t if_false) +GDecInstruction *g_ite_instruction_new(GCondExpression *cond, vmpa_t if_true, vmpa_t if_false)  {      GITEInstruction *result;              /* Expression à retourner      */ @@ -245,9 +243,6 @@ static GBufferLine *g_ite_instruction_print(const GITEInstruction *instr, GCodeB      g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "if ", 3, RTT_KEY_WORD); -    if (instr->inverse) -        g_buffer_line_insert_text(line /* FIXME */, BLC_ASSEMBLY_HEAD, "!", 1, RTT_KEY_WORD); -      result = g_dec_instruction_print(G_DEC_INSTRUCTION(instr->cond),                                       buffer, line, output); @@ -266,6 +261,25 @@ static GBufferLine *g_ite_instruction_print(const GITEInstruction *instr, GCodeB  /******************************************************************************  *                                                                             * +*  Paramètres  : instr = instruction fixant le choix de l'aiguillage.         * +*                                                                             * +*  Description : Fournit la condition régissant la suite de l'exécution.      * +*                                                                             * +*  Retour      : Condition mise en place.                                     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +GCondExpression *g_ite_instruction_get_condition(const GITEInstruction *instr) +{ +    return instr->cond; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : instr        = expression fixant le choix de l'aiguillage.   *  *                true_branch  = instructions si la condition est vérifiée.    *  *                false_branch = instructions si la cond. n'est pas vérifiée.  * @@ -280,10 +294,12 @@ static GBufferLine *g_ite_instruction_print(const GITEInstruction *instr, GCodeB  void g_ite_instruction_set_branches(GITEInstruction *instr, GDecInstruction *true_branch, GDecInstruction *false_branch)  { +    if (instr->true_branch != NULL) g_object_unref(G_OBJECT(instr->true_branch)); +    if (instr->false_branch != NULL) g_object_unref(G_OBJECT(instr->false_branch));      if (true_branch == NULL)      { -        instr->inverse = true; +        g_dec_expression_negate(G_DEC_EXPRESSION(instr->cond));          instr->true_branch = false_branch;          instr->false_branch = true_branch; @@ -296,3 +312,28 @@ void g_ite_instruction_set_branches(GITEInstruction *instr, GDecInstruction *tru      }  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : instr        = instruction fixant le choix de l'aiguillage.  * +*                true_branch  = instrs. si la condition est vérifiée. [OUT]   * +*                false_branch = instrs. si la cond. n'est pas vérifiée. [OUT] * +*                                                                             * +*  Description : Fournit le corps des différentes branches possibles.         * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_ite_instruction_get_branches(const GITEInstruction *instr, GDecInstruction **true_branch, GDecInstruction **false_branch) +{ +    if (true_branch != NULL) +        *true_branch = instr->true_branch; + +    if (false_branch != NULL) +        *false_branch = instr->false_branch; + +} diff --git a/src/decomp/instr/ite.h b/src/decomp/instr/ite.h index 7137452..91c18ae 100644 --- a/src/decomp/instr/ite.h +++ b/src/decomp/instr/ite.h @@ -30,6 +30,7 @@  #include "../expression.h"  #include "../instruction.h" +#include "../expr/cond.h" @@ -53,11 +54,17 @@ typedef struct _GITEInstructionClass GITEInstructionClass;  GType g_ite_instruction_get_type(void);  /* Exprime un aiguillage du flux en fonction d'une condition. */ -GDecInstruction *g_ite_instruction_new(GDecExpression *, vmpa_t, vmpa_t); +GDecInstruction *g_ite_instruction_new(GCondExpression *, vmpa_t, vmpa_t); + +/* Fournit la condition régissant la suite de l'exécution. */ +GCondExpression *g_ite_instruction_get_condition(const GITEInstruction *);  /* Détermine le corps des différentes branches possibles. */  void g_ite_instruction_set_branches(GITEInstruction *, GDecInstruction *, GDecInstruction *); +/* Fournit le corps des différentes branches possibles. */ +void g_ite_instruction_get_branches(const GITEInstruction *, GDecInstruction **, GDecInstruction **); +  #endif  /* _DECOMP_INSTR_ITE_H */ | 
