Add missing break statement
[mesa.git] / ir.cpp
diff --git a/ir.cpp b/ir.cpp
index c900a285bc7b1d3abf5aaa632f1e6ec3cb3958c3..a68d01cca9688956c7e2320a739a5041f09dde1b 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
 #include "main/imports.h"
 #include "main/simple_list.h"
 #include "ir.h"
+#include "ir_visitor.h"
 #include "glsl_types.h"
 
 ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
                             ir_rvalue *condition)
-   : ir_rvalue()
 {
    this->lhs = lhs;
    this->rhs = rhs;
@@ -38,7 +38,6 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
 
 ir_expression::ir_expression(int op, const struct glsl_type *type,
                             ir_rvalue *op0, ir_rvalue *op1)
-   : ir_rvalue()
 {
    this->type = type;
    this->operation = ir_expression_operation(op);
@@ -109,15 +108,14 @@ ir_expression::get_num_operands(void)
    return num_operands[this->operation];
 }
 
-ir_label::ir_label(const char *label)
-   : ir_instruction(), label(label)
+ir_label::ir_label(const char *label, ir_function_signature *signature)
+   : label(label), signature(signature)
 {
    /* empty */
 }
 
 
 ir_constant::ir_constant(const struct glsl_type *type, const void *data)
-   : ir_rvalue()
 {
    unsigned size = 0;
 
@@ -137,28 +135,24 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data)
 }
 
 ir_constant::ir_constant(float f)
-   : ir_rvalue()
 {
    this->type = glsl_type::float_type;
    this->value.f[0] = f;
 }
 
 ir_constant::ir_constant(unsigned int u)
-   : ir_rvalue()
 {
    this->type = glsl_type::uint_type;
    this->value.u[0] = u;
 }
 
 ir_constant::ir_constant(int i)
-   : ir_rvalue()
 {
    this->type = glsl_type::int_type;
    this->value.i[0] = i;
 }
 
 ir_constant::ir_constant(bool b)
-   : ir_rvalue()
 {
    this->type = glsl_type::bool_type;
    this->value.b[0] = b;
@@ -166,7 +160,6 @@ ir_constant::ir_constant(bool b)
 
 
 ir_dereference::ir_dereference(ir_instruction *var)
-   : ir_rvalue()
 {
    this->mode = ir_reference_variable;
    this->var = var;
@@ -176,8 +169,7 @@ ir_dereference::ir_dereference(ir_instruction *var)
 
 ir_dereference::ir_dereference(ir_instruction *var,
                               ir_rvalue *array_index)
-   : ir_rvalue(), mode(ir_reference_array),
-     var(var)
+   : mode(ir_reference_array), var(var)
 {
    type = glsl_type::error_type;
 
@@ -186,7 +178,9 @@ ir_dereference::ir_dereference(ir_instruction *var,
 
       if (vt->is_array()) {
         type = vt->element_type();
-      } else if (vt->is_matrix() || vt->is_vector()) {
+      } else if (vt->is_matrix()) {
+        type = vt->column_type();
+      } else if (vt->is_vector()) {
         type = vt->get_base_type();
       }
    }
@@ -336,6 +330,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name)
 {
    this->type = type;
    this->name = name;
+   this->constant_value = NULL;
 
    if (type && type->base_type == GLSL_TYPE_SAMPLER)
       this->read_only = true;
@@ -343,14 +338,14 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name)
 
 
 ir_function_signature::ir_function_signature(const glsl_type *return_type)
-   : ir_instruction(), return_type(return_type), definition(NULL)
+   : return_type(return_type), definition(NULL)
 {
    /* empty */
 }
 
 
 ir_function::ir_function(const char *name)
-   : ir_instruction(), name(name)
+   : name(name)
 {
    /* empty */
 }
@@ -364,3 +359,12 @@ ir_call::get_error_instruction()
    call->type = glsl_type::error_type;
    return call;
 }
+
+void
+visit_exec_list(exec_list *list, ir_visitor *visitor)
+{
+   foreach_iter(exec_list_iterator, iter, *list) {
+      ((ir_instruction *)iter.get())->accept(visitor);
+   }
+}
+