Add dereference constructor for array element dereferences
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 26 Mar 2010 00:01:15 +0000 (17:01 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 26 Mar 2010 00:01:15 +0000 (17:01 -0700)
This should have gone in before the previous commit.

ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index ad75cdad73c49cbf794853adb06ab4aa8b37b703..1b5947a4704d5a8de2f0d845ded2167135b6ec51 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -87,6 +87,16 @@ ir_dereference::ir_dereference(ir_instruction *var)
 }
 
 
+ir_dereference::ir_dereference(ir_instruction *var,
+                              ir_instruction *array_index)
+   : ir_instruction(ir_op_dereference), mode(ir_reference_array),
+     var(var)
+{
+   this->type = (var != NULL) ? var->type : glsl_error_type;
+   this->selector.array_index = array_index;
+}
+
+
 void
 ir_dereference::set_swizzle(unsigned x, unsigned y, unsigned z, unsigned w,
                            unsigned count)
diff --git a/ir.h b/ir.h
index 530c7326a35c48bd3fa23f6ca09c2a537152205f..22b46c971e84848c17e96742699ef5aae6b8fb64 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -393,6 +393,8 @@ class ir_dereference : public ir_instruction {
 public:
    ir_dereference(struct ir_instruction *);
 
+   ir_dereference(ir_instruction *variable, ir_instruction *array_index);
+
    virtual void accept(ir_visitor *v)
    {
       v->visit(this);
@@ -419,7 +421,7 @@ public:
    ir_instruction *var;
 
    union {
-      ir_expression *array_index;
+      ir_instruction *array_index;
       const char *field;
       struct ir_swizzle_mask swizzle;
    } selector;