glsl: Populate built-in types correctly for GLSL 3.00 ES.
[mesa.git] / src / glsl / ir_clone.cpp
index e8ac9fbe456074560358d6ef0e9727c65b7fb133..4314efa76d402e12ed3ed293521b126da2d894fc 100644 (file)
 #include "glsl_types.h"
 #include "program/hash_table.h"
 
+ir_rvalue *
+ir_rvalue::clone(void *mem_ctx, struct hash_table *ht) const
+{
+   /* The only possible instantiation is the generic error value. */
+   return error_value(mem_ctx);
+}
+
 /**
  * Duplicate an IR variable
  *
@@ -46,11 +53,15 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
    var->invariant = this->invariant;
    var->interpolation = this->interpolation;
    var->location = this->location;
+   var->index = this->index;
+   var->uniform_block = this->uniform_block;
    var->warn_extension = this->warn_extension;
    var->origin_upper_left = this->origin_upper_left;
    var->pixel_center_integer = this->pixel_center_integer;
    var->explicit_location = this->explicit_location;
+   var->explicit_index = this->explicit_index;
    var->has_initializer = this->has_initializer;
+   var->depth_layout = this->depth_layout;
 
    var->num_state_slots = this->num_state_slots;
    if (this->state_slots) {
@@ -63,9 +74,6 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
             sizeof(this->state_slots[0]) * var->num_state_slots);
    }
 
-   if (this->explicit_location)
-      var->location = this->location;
-
    if (this->constant_value)
       var->constant_value = this->constant_value->clone(mem_ctx, ht);
 
@@ -159,8 +167,9 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
 ir_call *
 ir_call::clone(void *mem_ctx, struct hash_table *ht) const
 {
-   if (this->type == glsl_type::error_type)
-      return ir_call::get_error_instruction(mem_ctx);
+   ir_dereference_variable *new_return_ref = NULL;
+   if (this->return_deref != NULL)
+      new_return_ref = this->return_deref->clone(mem_ctx, ht);
 
    exec_list new_parameters;
 
@@ -169,7 +178,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const
       new_parameters.push_tail(ir->clone(mem_ctx, ht));
    }
 
-   return new(mem_ctx) ir_call(this->callee, &new_parameters);
+   return new(mem_ctx) ir_call(this->callee, new_return_ref, &new_parameters);
 }
 
 ir_expression *
@@ -316,6 +325,7 @@ ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) con
 
    copy->is_defined = false;
    copy->is_builtin = this->is_builtin;
+   copy->origin = this;
 
    /* Clone the parameter list, but NOT the body.
     */
@@ -389,9 +399,9 @@ public:
        * table.  If it is found, replace it with the value from the table.
        */
       ir_function_signature *sig =
-        (ir_function_signature *) hash_table_find(this->ht, ir->get_callee());
+        (ir_function_signature *) hash_table_find(this->ht, ir->callee);
       if (sig != NULL)
-        ir->set_callee(sig);
+        ir->callee = sig;
 
       /* Since this may be used before function call parameters are flattened,
        * the children also need to be processed.