- if (previous_label) {
- YYLTYPE loc = this->test_value->get_location();
- _mesa_glsl_error(& loc, state,
- "duplicate case value");
-
- loc = previous_label->get_location();
- _mesa_glsl_error(& loc, state,
- "this is the previous case label");
- } else {
- hash_table_insert(state->switch_state.labels_ht,
- this->test_value,
- (void *)(uintptr_t)label_const->value.u[0]);
- }
- }
-
- ir_dereference_variable *deref_test_var =
- new(ctx) ir_dereference_variable(state->switch_state.test_var);
-
- ir_rvalue *const test_cond = new(ctx) ir_expression(ir_binop_all_equal,
- glsl_type::bool_type,
- label_const,
- deref_test_var);
-
- ir_assignment *set_fallthru_on_test =
- new(ctx) ir_assignment(deref_fallthru_var,
- true_val,
- test_cond);
-
- instructions->push_tail(set_fallthru_on_test);
- } else { /* default case */
- if (state->switch_state.previous_default) {
- printf("a\n");
- YYLTYPE loc = this->get_location();
- _mesa_glsl_error(& loc, state,
- "multiple default labels in one switch");
-
- printf("b\n");
-
- loc = state->switch_state.previous_default->get_location();
- _mesa_glsl_error(& loc, state,
- "this is the first default label");
- }
- state->switch_state.previous_default = this;
-
- /* Set falltrhu state.
- */
- ir_assignment *set_fallthru =
- new(ctx) ir_assignment(deref_fallthru_var,
- true_val,
- NULL);
-
- instructions->push_tail(set_fallthru);
- }
-
- /* Case statements do not have r-values.
- */
- return NULL;
- }
-
-
- void
- ast_iteration_statement::condition_to_hir(ir_loop *stmt,
- struct _mesa_glsl_parse_state *state)
- {
- void *ctx = state;
-
- if (condition != NULL) {
- ir_rvalue *const cond =
- condition->hir(& stmt->body_instructions, state);
-
- if ((cond == NULL)
- || !cond->type->is_boolean() || !cond->type->is_scalar()) {
- YYLTYPE loc = condition->get_location();
-
- _mesa_glsl_error(& loc, state,
- "loop condition must be scalar boolean");
- } else {
- /* As the first code in the loop body, generate a block that looks
- * like 'if (!condition) break;' as the loop termination condition.
- */
- ir_rvalue *const not_cond =
- new(ctx) ir_expression(ir_unop_logic_not, glsl_type::bool_type, cond,
- NULL);
-
- ir_if *const if_stmt = new(ctx) ir_if(not_cond);
-
- ir_jump *const break_stmt =
- new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
-
- if_stmt->then_instructions.push_tail(break_stmt);
- stmt->body_instructions.push_tail(if_stmt);
- }
- }
- }
-
-
- ir_rvalue *
- ast_iteration_statement::hir(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
- {
- void *ctx = state;
-
- /* For-loops and while-loops start a new scope, but do-while loops do not.
- */
- if (mode != ast_do_while)
- state->symbols->push_scope();
-
- if (init_statement != NULL)
- init_statement->hir(instructions, state);
-
- ir_loop *const stmt = new(ctx) ir_loop();
- instructions->push_tail(stmt);
-
- /* Track the current loop nesting.
- */
- ast_iteration_statement *nesting_ast = state->loop_nesting_ast;
-
- state->loop_nesting_ast = this;
-
- /* Likewise, indicate that following code is closest to a loop,
- * NOT closest to a switch.
- */
- bool saved_is_switch_innermost = state->switch_state.is_switch_innermost;
- state->switch_state.is_switch_innermost = false;
-
- if (mode != ast_do_while)
- condition_to_hir(stmt, state);
+ _mesa_glsl_error(& loc, state,
+ "loop condition must be scalar boolean");
+ } else {
+ /* As the first code in the loop body, generate a block that looks
+ * like 'if (!condition) break;' as the loop termination condition.
+ */
+ ir_rvalue *const not_cond =
+ new(ctx) ir_expression(ir_unop_logic_not, cond);
+
+ ir_if *const if_stmt = new(ctx) ir_if(not_cond);
+
+ ir_jump *const break_stmt =
+ new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
+
+ if_stmt->then_instructions.push_tail(break_stmt);
+ stmt->body_instructions.push_tail(if_stmt);
+ }
+ }
+}
+
+
+ir_rvalue *
+ast_iteration_statement::hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ void *ctx = state;