Begin tracking the nesting of loops and switch-statements
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 6 Apr 2010 00:01:53 +0000 (17:01 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 7 Apr 2010 18:42:36 +0000 (11:42 -0700)
ast_to_hir.cpp
glsl_parser_extras.cpp
glsl_parser_extras.h

index 823bab9dfa0da935e30caff6227d760b52643202..444cb7d54e30e974c8dda0921edb06c8fba30e91 100644 (file)
@@ -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;
index 538d77c663cd20dbcf2f70d102aea9354af25768..877b165ad718f4cb171d0355d4303893171110cb 100644 (file)
@@ -637,6 +637,7 @@ main(int argc, char **argv)
    state.symbols = new glsl_symbol_table;
    state.error = false;
    state.temp_index = 0;
+   state.loop_or_switch_nesting = NULL;
 
    _mesa_glsl_lexer_ctor(& state, shader, shader_len);
    _mesa_glsl_parse(& state);
index 96c975ba117495b8ad24b97998b2917717dae010..373d295bba4bc4328afaa4beba17f92aa7458a39 100644 (file)
@@ -56,6 +56,9 @@ struct _mesa_glsl_parse_state {
 
    /** Index of last generated anonymous temporary. */
    unsigned temp_index;
+
+   /** Loop or switch statement containing the current instructions. */
+   class ir_instruction *loop_or_switch_nesting;
 };
 
 typedef struct YYLTYPE {