summaryrefslogtreecommitdiffstats
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-04-05 17:01:53 -0700
committerIan Romanick <[email protected]>2010-04-07 11:42:36 -0700
commite9d0f265aabb39928d4d8a527684bf3b9eebc21c (patch)
treed9d7946a8314352fe8d510f0db5ec1df3ee760ec /ast_to_hir.cpp
parentc0e76d8352fbe96efb0338e9d98b08494671e504 (diff)
Begin tracking the nesting of loops and switch-statements
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 823bab9dfa0..444cb7d54e3 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -2093,6 +2093,12 @@ ast_iteration_statement::hir(exec_list *instructions,
ir_loop *const stmt = new ir_loop();
instructions->push_tail(stmt);
+ /* Track the current loop and / or switch-statement nesting.
+ */
+ ir_instruction *const nesting = state->loop_or_switch_nesting;
+ state->loop_or_switch_nesting = stmt;
+
+
if (condition != NULL) {
ir_rvalue *const cond =
condition->hir(& stmt->body_instructions, state);
@@ -2135,6 +2141,10 @@ ast_iteration_statement::hir(exec_list *instructions,
if (mode == ast_for)
state->symbols->pop_scope();
+ /* Restore previous nesting before returning.
+ */
+ state->loop_or_switch_nesting = nesting;
+
/* Loops do not have r-values.
*/
return NULL;