summaryrefslogtreecommitdiff
path: root/ir.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-04-01 20:27:35 -1000
committerIan Romanick <ian.d.romanick@intel.com>2010-04-02 11:22:41 -0700
commitc7da28b4beb3a593f49a6c01a90b123584b421e8 (patch)
treec689e2fb6916ac0c5ab4114ae4c40180a29d10a9 /ir.cpp
parent5150c567a0bf082d93f25ba7e29d5573c9dffb8b (diff)
Allow array dereferences to be considered as lvalues.
Fixes glsl-vs-arrays.vert and glsl-vs-mov-after-deref.vert. Regresses parser3.frag which was failing for the wrong reason.
Diffstat (limited to 'ir.cpp')
-rw-r--r--ir.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/ir.cpp b/ir.cpp
index 35fecf7560..d9faac03d4 100644
--- 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)