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);
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;
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 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 {