summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-06-29 15:30:40 -0700
committerPaul Berry <[email protected]>2011-07-08 09:59:29 -0700
commitf4830be938c8fa33086f73cab19a53ab3e14cb9c (patch)
tree9d612f1c89c04fef67fceae84bef60a33d332329 /src
parent5fb79fc69f56cf2d8d44e4c6c2d8b862bc631139 (diff)
glsl: Make ir_reader able to read plain (return) statements.
Previously ir_reader was only able to handle return of non-void. This patch is necessary in order to allow optimization passes to be tested in isolation. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ir_reader.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 30df257be2f..f3a621734ba 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -482,19 +482,21 @@ ir_reader::read_return(s_expression *expr)
{
s_expression *s_retval;
- s_pattern pat[] = { "return", s_retval};
- if (!MATCH(expr, pat)) {
- ir_read_error(expr, "expected (return <rvalue>)");
- return NULL;
- }
-
- ir_rvalue *retval = read_rvalue(s_retval);
- if (retval == NULL) {
- ir_read_error(NULL, "when reading return value");
+ s_pattern return_value_pat[] = { "return", s_retval};
+ s_pattern return_void_pat[] = { "return" };
+ if (MATCH(expr, return_value_pat)) {
+ ir_rvalue *retval = read_rvalue(s_retval);
+ if (retval == NULL) {
+ ir_read_error(NULL, "when reading return value");
+ return NULL;
+ }
+ return new(mem_ctx) ir_return(retval);
+ } else if (MATCH(expr, return_void_pat)) {
+ return new(mem_ctx) ir_return;
+ } else {
+ ir_read_error(expr, "expected (return <rvalue>) or (return)");
return NULL;
}
-
- return new(mem_ctx) ir_return(retval);
}