diff options
Diffstat (limited to 'src/glsl/ir_clone.cpp')
-rw-r--r-- | src/glsl/ir_clone.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index a3cc8dbc970..1522af682bb 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -22,6 +22,7 @@ */ #include <string.h> +#include "main/compiler.h" #include "ir.h" #include "glsl_types.h" extern "C" { @@ -160,14 +161,15 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[2] = {NULL, NULL}; + ir_rvalue *op[Elements(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { op[i] = this->operands[i]->clone(mem_ctx, ht); } - return new(mem_ctx) ir_expression(this->operation, this->type, op[0], op[1]); + return new(mem_ctx) ir_expression(this->operation, this->type, + op[0], op[1], op[2], op[3]); } ir_dereference_variable * @@ -274,13 +276,32 @@ ir_function::clone(void *mem_ctx, struct hash_table *ht) const ir_function_signature * ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const { + ir_function_signature *copy = this->clone_prototype(mem_ctx, ht); + + copy->is_defined = this->is_defined; + + /* Clone the instruction list. + */ + foreach_list_const(node, &this->body) { + const ir_instruction *const inst = (const ir_instruction *) node; + + ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); + copy->body.push_tail(inst_copy); + } + + return copy; +} + +ir_function_signature * +ir_function_signature::clone_prototype(void *mem_ctx, struct hash_table *ht) const +{ ir_function_signature *copy = new(mem_ctx) ir_function_signature(this->return_type); - copy->is_defined = this->is_defined; + copy->is_defined = false; copy->is_builtin = this->is_builtin; - /* Clone the parameter list. + /* Clone the parameter list, but NOT the body. */ foreach_list_const(node, &this->parameters) { const ir_variable *const param = (const ir_variable *) node; @@ -291,15 +312,6 @@ ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const copy->parameters.push_tail(param_copy); } - /* Clone the instruction list. - */ - foreach_list_const(node, &this->body) { - const ir_instruction *const inst = (const ir_instruction *) node; - - ir_instruction *const inst_copy = inst->clone(mem_ctx, ht); - copy->body.push_tail(inst_copy); - } - return copy; } |