Make ir_function::signatures private
[mesa.git] / ir.cpp
diff --git a/ir.cpp b/ir.cpp
index 58c459ed5db7cc72b6e6f6d3690aa0722b790b1b..90df67bbf1dcd8388d0186661b2ec790bd0bc0dd 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -57,9 +57,6 @@ ir_label::ir_label(const char *label)
 ir_constant::ir_constant(const struct glsl_type *type, const void *data)
    : ir_rvalue()
 {
-   const unsigned elements = 
-      ((type->vector_elements == 0) ? 1 : type->vector_elements)
-      * ((type->matrix_columns == 0) ? 1 : type->matrix_columns);
    unsigned size = 0;
 
    this->type = type;
@@ -74,7 +71,35 @@ ir_constant::ir_constant(const struct glsl_type *type, const void *data)
       break;
    }
 
-   memcpy(& this->value, data, size * elements);
+   memcpy(& this->value, data, size * type->components());
+}
+
+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;
 }
 
 
@@ -83,7 +108,7 @@ ir_dereference::ir_dereference(ir_instruction *var)
 {
    this->mode = ir_reference_variable;
    this->var = var;
-   this->type = (var != NULL) ? var->type : glsl_error_type;
+   this->type = (var != NULL) ? var->type : glsl_type::error_type;
 }
 
 
@@ -92,7 +117,7 @@ ir_dereference::ir_dereference(ir_instruction *var,
    : ir_rvalue(), mode(ir_reference_array),
      var(var)
 {
-   this->type = (var != NULL) ? var->type : glsl_error_type;
+   this->type = (var != NULL) ? var->type : glsl_type::error_type;
    this->selector.array_index = array_index;
 }
 
@@ -215,6 +240,9 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name)
 {
    this->type = type;
    this->name = name;
+
+   if (type && type->base_type == GLSL_TYPE_SAMPLER)
+      this->read_only = true;
 }
 
 
@@ -237,6 +265,6 @@ ir_call::get_error_instruction()
 {
    ir_call *call = new ir_call;
 
-   call->type = glsl_error_type;
+   call->type = glsl_type::error_type;
    return call;
 }