ir_reader: Read record_refs.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 26 May 2010 22:20:59 +0000 (15:20 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 26 May 2010 22:24:53 +0000 (15:24 -0700)
Also changes the print visitor to not emit extraneous parenthesis.

ir_print_visitor.cpp
ir_reader.cpp

index e507a0ebf99fda0066a34a76ea04f4667a9d9a39..84edad5dfac4f97c56f2abea492f547f596a4021 100644 (file)
@@ -181,7 +181,7 @@ void ir_print_visitor::visit(ir_dereference_record *ir)
 {
    printf("(record_ref ");
    ir->record->accept(this);
-   printf("(%s)) ", ir->field);
+   printf(" %s) ", ir->field);
 }
 
 
index 072842e83b7de3f2f0c91f1cbf33547ad2abb066..f4b9967d449ef8462aa9333d1d9dbaf058848bea 100644 (file)
@@ -862,6 +862,22 @@ read_array_ref(_mesa_glsl_parse_state *st, s_list *list)
 static ir_dereference *
 read_record_ref(_mesa_glsl_parse_state *st, s_list *list)
 {
-   ir_read_error(st, list, "FINISHME: record refs not yet supported.");
-   return NULL;
+   if (list->length() != 3) {
+      ir_read_error(st, list, "expected (record_ref <rvalue> <field>)");
+      return NULL;
+   }
+
+   s_expression *subj_expr = (s_expression*) list->subexpressions.head->next;
+   ir_rvalue *subject = read_rvalue(st, subj_expr);
+   if (subject == NULL) {
+      ir_read_error(st, NULL, "when reading the subject of a record_ref");
+      return NULL;
+   }
+
+   s_symbol *field = SX_AS_SYMBOL(subj_expr->next);
+   if (field == NULL) {
+      ir_read_error(st, list, "expected (record_ref ... <field name>)");
+      return NULL;
+   }
+   return new ir_dereference_record(subject, field->value());
 }