diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2013-02-03 00:47:09 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2013-02-03 00:47:09 (GMT) | 
| commit | 48e663f21a6429787fec2c426f46024dad9cde08 (patch) | |
| tree | 8ba7878c82de5f95aecef6148a88b3bda2cd84d7 /src/decomp | |
| parent | 5b89c8369d2a26089f22be7c482e8254244ebc8c (diff) | |
Added more options to render braces (or not) around decompiled blocks.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@337 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp')
| -rw-r--r-- | src/decomp/expr/block.c | 61 | ||||
| -rw-r--r-- | src/decomp/expr/block.h | 16 | 
2 files changed, 75 insertions, 2 deletions
| diff --git a/src/decomp/expr/block.c b/src/decomp/expr/block.c index b58972d..7c2387a 100644 --- a/src/decomp/expr/block.c +++ b/src/decomp/expr/block.c @@ -37,6 +37,8 @@ struct _GExprBlock  {      GDecExpression parent;                  /* A laisser en premier        */ +    BlockBordeBehavior behavior;            /* Type de Rendu des bordures  */ +      GDecInstruction **list;                 /* Instructions contenues      */      size_t count;                           /* Taille de cette liste       */ @@ -113,6 +115,8 @@ static void g_expr_block_init(GExprBlock *block)      instr->replace = (dec_instr_replace_fc)g_expr_block_replace;      instr->print = (dec_instr_print_fc)g_expr_block_print; +    block->behavior = BBB_AUTO; +  } @@ -143,6 +147,45 @@ GDecInstruction *g_expr_block_new(GDecInstruction *item)  /******************************************************************************  *                                                                             * +*  Paramètres  : block = première instruction à venir visiter.                * +*                                                                             * +*  Description : Fournit le comportement du bloc pour le rendu de ses bords.  * +*                                                                             * +*  Retour      : Comportement pour le rendu des bordures.                     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +BlockBordeBehavior g_expr_block_get_border_behavior(const GExprBlock *block) +{ +    return block->behavior; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : block    = première instruction à venir visiter.             * +*                behavior = comportement pour le rendu des bordures.          * +*                                                                             * +*  Description : Définit le comportement du bloc pour le rendu de ses bords.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_expr_block_set_border_behavior(GExprBlock *block, BlockBordeBehavior behavior) +{ +    block->behavior = behavior; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : block    = première instruction à venir visiter.             *  *                callback = procédure à appeler à chaque instruction visitée. *  *                flags    = moments des appels à réaliser en retour.          * @@ -232,9 +275,23 @@ static bool g_expr_block_replace(GExprBlock *block, GDecInstruction *old, GDecIn  static GBufferLine *g_expr_block_print(const GExprBlock *block, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)  {      GBufferLine *result;                    /* Ligne à retourner           */ +    size_t expr_count;                      /* Taille officielle           */      size_t i;                               /* Boucle de parcours          */ -    result = g_lang_output_start_code_block(output, buffer, line, block->count); +    switch (block->behavior) +    { +        case BBB_AUTO: +            expr_count = block->count; +            break; +        case BBB_FORCE_OFF: +            expr_count = 1; +            break; +        case BBB_FORCE_ON: +            expr_count = 2; +            break; +    } + +    result = g_lang_output_start_code_block(output, buffer, line, expr_count);      for (i = 0; i < block->count; i++)      { @@ -245,7 +302,7 @@ static GBufferLine *g_expr_block_print(const GExprBlock *block, GCodeBuffer *buf      } -    result = g_lang_output_end_code_block(output, buffer, result, block->count); +    result = g_lang_output_end_code_block(output, buffer, result, expr_count);      return result; diff --git a/src/decomp/expr/block.h b/src/decomp/expr/block.h index b0c2baa..b0788dd 100644 --- a/src/decomp/expr/block.h +++ b/src/decomp/expr/block.h @@ -48,12 +48,28 @@ typedef struct _GExprBlock GExprBlock;  typedef struct _GExprBlockClass GExprBlockClass; +/* Rendu des bordures */ +typedef enum _BlockBordeBehavior +{ +    BBB_AUTO, +    BBB_FORCE_OFF, +    BBB_FORCE_ON + +} BlockBordeBehavior; + +  /* Indique le type défini pour un ensemble d'instructions décompilées. */  GType g_expr_block_get_type(void);  /* Constuit un conteneur pour diverses instructions décompilées. */  GDecInstruction *g_expr_block_new(GDecInstruction *); +/* Fournit le comportement du bloc pour le rendu de ses bords. */ +BlockBordeBehavior g_expr_block_get_border_behavior(const GExprBlock *); + +/* Définit le comportement du bloc pour le rendu de ses bords. */ +void g_expr_block_set_border_behavior(GExprBlock *, BlockBordeBehavior); +  /* Ajoute une instruction décompilée au conteneur existant. */  void g_expr_block_add_item(GExprBlock *, GDecInstruction *); | 
