diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-04-09 17:56:22 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-04-28 18:14:54 -0700 |
commit | 9d2ff7617a08fa1dc26c7661e813b0d6cb8acc2b (patch) | |
tree | 58dee5b3d8cd037877f746c59dd85a837b4e84df /ir_reader.cpp | |
parent | d1d2ada3c6bdf5a99c07147c157da75f07100847 (diff) |
ir_reader: Add support for reading (return ...)
Diffstat (limited to 'ir_reader.cpp')
-rw-r--r-- | ir_reader.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ir_reader.cpp b/ir_reader.cpp index 00fcc9475c..2289095dfd 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -33,6 +33,7 @@ static glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *); static ir_instruction *read_instruction(_mesa_glsl_parse_state *, s_expression *); static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *); +static ir_return *read_return(_mesa_glsl_parse_state *, s_list *); static ir_rvalue *read_rvalue(_mesa_glsl_parse_state *, s_expression *); static ir_assignment *read_assignment(_mesa_glsl_parse_state *, s_list *); @@ -143,6 +144,8 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr) ir_instruction *inst = NULL; if (strcmp(tag->value(), "declare") == 0) inst = read_declaration(st, list); + else if (strcmp(tag->value(), "return") == 0) + inst = read_return(st, list); else ir_read_error(expr, "unrecognized instruction tag: %s", tag->value()); @@ -220,6 +223,26 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list) } +static ir_return * +read_return(_mesa_glsl_parse_state *st, s_list *list) +{ + if (list->length() != 2) { + ir_read_error(list, "expected (return <rvalue>)"); + return NULL; + } + + s_expression *expr = (s_expression*) list->subexpressions.head->next; + + ir_rvalue *retval = read_rvalue(st, expr); + if (retval == NULL) { + ir_read_error(list, "when reading return value"); + return NULL; + } + + return new ir_return(retval); +} + + static ir_rvalue * read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) { |