Allow array dereferences to be considered as lvalues.
authorEric Anholt <eric@anholt.net>
Fri, 2 Apr 2010 06:27:35 +0000 (20:27 -1000)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 2 Apr 2010 18:22:41 +0000 (11:22 -0700)
Fixes glsl-vs-arrays.vert and glsl-vs-mov-after-deref.vert.
Regresses parser3.frag which was failing for the wrong reason.

ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index 35fecf7..d9faac0 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -190,6 +190,30 @@ ir_dereference::ir_dereference(ir_instruction *var,
    this->selector.array_index = array_index;
 }
 
+bool
+ir_dereference::is_lvalue()
+{
+   if (var == NULL)
+      return false;
+
+   if (this->type->base_type == GLSL_TYPE_ARRAY ||
+       this->type->base_type == GLSL_TYPE_STRUCT)
+      return false;
+
+   if (mode == ir_reference_variable) {
+      ir_variable *const as_var = var->as_variable();
+      if (as_var == NULL)
+        return false;
+
+      return !as_var->read_only;
+   } else if (mode == ir_reference_array) {
+      /* FINISHME: Walk up the dereference chain and figure out if
+       * FINISHME: the variable is read-only.
+       */
+   }
+
+   return true;
+}
 
 ir_swizzle::ir_swizzle(ir_rvalue *val, unsigned x, unsigned y, unsigned z,
                       unsigned w, unsigned count)
diff --git a/ir.h b/ir.h
index 381af35..64ed881 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -540,17 +540,7 @@ public:
       v->visit(this);
    }
 
-   bool is_lvalue()
-   {
-      if (var == NULL)
-        return false;
-
-      ir_variable *const as_var = var->as_variable();
-      if (as_var == NULL)
-        return false;
-
-      return !as_var->read_only;
-   }
+   bool is_lvalue();
 
    enum {
       ir_reference_variable,