From 17e4254488cbaa471706ba1195e9dfcf20ed3aff Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Fri, 4 May 2012 09:17:56 +0200 Subject: [PATCH] Factorise code to create local declarations. --- ast2firm.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ast2firm.c b/ast2firm.c index 7dacbbe..9d4844d 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -175,7 +175,6 @@ ir_mode *atomic_modes[ATOMIC_TYPE_LAST+1]; static ir_node *_expression_to_firm(const expression_t *expression); static ir_node *expression_to_firm(const expression_t *expression); -static void create_local_declaration(entity_t *entity); static unsigned decide_modulo_shift(unsigned type_size) { @@ -4466,15 +4465,11 @@ static ir_node *expression_statement_to_firm(expression_statement_t *statement) return expression_to_firm(statement->expression); } +static void create_local_declarations(entity_t*); + static ir_node *compound_statement_to_firm(compound_statement_t *compound) { - entity_t *entity = compound->scope.entities; - for ( ; entity != NULL; entity = entity->base.next) { - if (!is_declaration(entity)) - continue; - - create_local_declaration(entity); - } + create_local_declarations(compound->scope.entities); ir_node *result = NULL; statement_t *statement = compound->statements; @@ -4568,6 +4563,14 @@ static void create_local_declaration(entity_t *entity) panic("invalid storage class found"); } +static void create_local_declarations(entity_t *e) +{ + for (; e; e = e->base.next) { + if (is_declaration(e)) + create_local_declaration(e); + } +} + static void initialize_local_declaration(entity_t *entity) { if (entity->base.symbol == NULL) @@ -4789,17 +4792,10 @@ static ir_node *do_while_statement_to_firm(do_while_statement_t *statement) static ir_node *for_statement_to_firm(for_statement_t *statement) { - /* create declarations */ - entity_t *entity = statement->scope.entities; - for ( ; entity != NULL; entity = entity->base.next) { - if (!is_declaration(entity)) - continue; - - create_local_declaration(entity); - } + create_local_declarations(statement->scope.entities); if (currently_reachable()) { - entity = statement->scope.entities; + entity_t *entity = statement->scope.entities; for ( ; entity != NULL; entity = entity->base.next) { if (!is_declaration(entity)) continue; -- 2.20.1