ir_constant: Add storage for multiple constants for arrays and records
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 10 Jun 2010 00:11:50 +0000 (17:11 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 11 Jun 2010 20:51:42 +0000 (13:51 -0700)
ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index 759bf9f804a29bc4df098f37c628acd027c116d0..b60d1b468aa6ff1f83a1687b3e43366081436c49 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -244,8 +244,24 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
 {
    this->type = type;
 
-   /* FINISHME: Support structure and array types. */
-   assert(type->is_scalar() || type->is_vector() || type->is_matrix());
+   /* FINISHME: Support array types. */
+   assert(type->is_scalar() || type->is_vector() || type->is_matrix()
+         || type->is_record());
+
+   /* If the constant is a record, the types of each of the entries in
+    * value_list must be a 1-for-1 match with the structure components.  Each
+    * entry must also be a constant.  Just move the nodes from the value_list
+    * to the list in the ir_constant.
+    */
+   /* FINISHME: Should there be some type checking and / or assertions here? */
+   /* FINISHME: Should the new constant take ownership of the nodes from
+    * FINISHME: value_list, or should it make copies?
+    */
+   if (type->is_record()) {
+      value_list->move_nodes_to(& this->components);
+      return;
+   }
+
 
    ir_constant *value = (ir_constant *) (value_list->head);
 
diff --git a/ir.h b/ir.h
index 60164a5ab1c388ed98cb285325f4f1edea37d2d4..8fd823db09c0b4bd3b020ac4d16dce8e92d22bf1 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -1087,6 +1087,8 @@ public:
       float f[16];
       bool b[16];
    } value;
+
+   exec_list components;
 };
 
 void