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 *);
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);
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());
}
return NULL; // should not be reached
}
+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)
{