From 9d2ff7617a08fa1dc26c7661e813b0d6cb8acc2b Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 9 Apr 2010 17:56:22 -0700 Subject: [PATCH] ir_reader: Add support for reading (return ...) --- ir_reader.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ir_reader.cpp b/ir_reader.cpp index 00fcc9475cc..2289095dfde 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 )"); + 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) { -- 2.30.2