diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-05-26 17:52:44 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-06-09 11:14:57 -0700 |
commit | 3c7934bfaae5dff410cddba3ac6696a8911c0c68 (patch) | |
tree | 2dfc5a104c58e2c1afc34c040ea19ca409db5748 | |
parent | 26d74cd1d140786b8f4b1ccbaf500a16e68eec3c (diff) |
ir_reader: Refactor reading of dereferences for later reuse.
-rw-r--r-- | ir_reader.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/ir_reader.cpp b/ir_reader.cpp index f4b9967d44..019631f808 100644 --- a/ir_reader.cpp +++ b/ir_reader.cpp @@ -53,6 +53,9 @@ static ir_expression *read_expression(_mesa_glsl_parse_state *, s_list *); static ir_call *read_call(_mesa_glsl_parse_state *, s_list *); static ir_swizzle *read_swizzle(_mesa_glsl_parse_state *, s_list *); static ir_constant *read_constant(_mesa_glsl_parse_state *, s_list *); + +static ir_dereference *read_dereference(_mesa_glsl_parse_state *, + s_expression *); static ir_dereference *read_var_ref(_mesa_glsl_parse_state *, s_list *); static ir_dereference *read_array_ref(_mesa_glsl_parse_state *, s_list *); static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *); @@ -528,8 +531,10 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) return NULL; } - ir_rvalue *rvalue = NULL; - if (strcmp(tag->value(), "swiz") == 0) { + ir_rvalue *rvalue = read_dereference(st, list); + if (rvalue != NULL || st->error) + return rvalue; + else if (strcmp(tag->value(), "swiz") == 0) { rvalue = read_swizzle(st, list); } else if (strcmp(tag->value(), "assign") == 0) { rvalue = read_assignment(st, list); @@ -539,12 +544,6 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr) rvalue = read_call(st, list); } else if (strcmp(tag->value(), "constant") == 0) { rvalue = read_constant(st, list); - } else if (strcmp(tag->value(), "var_ref") == 0) { - rvalue = read_var_ref(st, list); - } else if (strcmp(tag->value(), "array_ref") == 0) { - rvalue = read_array_ref(st, list); - } else if (strcmp(tag->value(), "record_ref") == 0) { - rvalue = read_record_ref(st, list); } else { ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value()); } @@ -818,6 +817,25 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) } static ir_dereference * +read_dereference(_mesa_glsl_parse_state *st, s_expression *expr) +{ + s_list *list = SX_AS_LIST(expr); + if (list == NULL || list->subexpressions.is_empty()) + return NULL; + + s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head); + assert(tag != NULL); + + if (strcmp(tag->value(), "var_ref") == 0) + return read_var_ref(st, list); + if (strcmp(tag->value(), "array_ref") == 0) + return read_array_ref(st, list); + if (strcmp(tag->value(), "record_ref") == 0) + return read_record_ref(st, list); + return NULL; +} + +static ir_dereference * read_var_ref(_mesa_glsl_parse_state *st, s_list *list) { if (list->length() != 2) { |