diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-05-10 11:10:26 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-05-10 11:10:26 -0700 |
commit | 4f9d72fa9e2a4ff1a2aca6de8ee4fa93639c75f1 (patch) | |
tree | 0836881617d459540235b5252669f8d15aa93fb9 | |
parent | f4e06981cc85e28a61a1d94681989fb8e45dc310 (diff) |
Loop bodies, then-statements, and else-statements are not lists
The statement making up a loop body, a then-statement, or an
else-statement are single nodes. If the statement is a block, the
single node will be an ast_compound_statement. There is no need to
loop at the top level when processing these statements.
-rw-r--r-- | ast_to_hir.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 357683f0c3..427158cf10 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -2171,21 +2171,11 @@ ast_selection_statement::hir(exec_list *instructions, ir_if *const stmt = new ir_if(condition); - if (then_statement != NULL) { - ast_node *node = (ast_node *) then_statement; - do { - node->hir(& stmt->then_instructions, state); - node = (ast_node *) node->next; - } while (node != then_statement); - } + if (then_statement != NULL) + then_statement->hir(& stmt->then_instructions, state); - if (else_statement != NULL) { - ast_node *node = (ast_node *) else_statement; - do { - node->hir(& stmt->else_instructions, state); - node = (ast_node *) node->next; - } while (node != else_statement); - } + if (else_statement != NULL) + else_statement->hir(& stmt->else_instructions, state); instructions->push_tail(stmt); @@ -2252,13 +2242,8 @@ ast_iteration_statement::hir(exec_list *instructions, if (mode != ast_do_while) condition_to_hir(stmt, state); - if (body != NULL) { - ast_node *node = (ast_node *) body; - do { - node->hir(& stmt->body_instructions, state); - node = (ast_node *) node->next; - } while (node != body); - } + if (body != NULL) + body->hir(& stmt->body_instructions, state); if (rest_expression != NULL) rest_expression->hir(& stmt->body_instructions, state); |