summaryrefslogtreecommitdiff
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-04-05 17:13:47 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-04-07 11:42:36 -0700
commit4cf20cd37c12c6243a09d52739d3d47f030a1799 (patch)
treee05cfb94c9ba1ec36ca7ecfab07b10721c5b4f0f /ast_to_hir.cpp
parent01f8de4a87157b01e8b9fe31c6766a15bbfb2788 (diff)
Process ast_jump_statement into ir_loop_jump
Specifically, handle 'break' and 'continue' inside loops. This causes the following tests to pass: glslparsertest/shaders/break.frag glslparsertest/shaders/continue.frag
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 444cb7d54e..ae5a8d51f7 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -2021,6 +2021,32 @@ ast_jump_statement::hir(exec_list *instructions,
case ast_break:
case ast_continue:
+ /* FINISHME: Handle switch-statements. They cannot contain 'continue',
+ * FINISHME: and they use a different IR instruction for 'break'.
+ */
+ /* FINISHME: Correctly handle the nesting. If a switch-statement is
+ * FINISHME: inside a loop, a 'continue' is valid and will bind to the
+ * FINISHME: loop.
+ */
+ if (state->loop_or_switch_nesting == NULL) {
+ YYLTYPE loc = this->get_location();
+
+ _mesa_glsl_error(& loc, state,
+ "`%s' may only appear in a loop",
+ (mode == ast_break) ? "break" : "continue");
+ } else {
+ ir_loop *const loop = state->loop_or_switch_nesting->as_loop();
+
+ if (loop != NULL) {
+ ir_loop_jump *const jump =
+ new ir_loop_jump(loop,
+ (mode == ast_break)
+ ? ir_loop_jump::jump_break
+ : ir_loop_jump::jump_continue);
+ instructions->push_tail(jump);
+ }
+ }
+
break;
}