mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 12:40:23 +01:00
glsl: Refactor out cloning of function prototypes.
This allows us to reuse some code and will be useful later.
This commit is contained in:
parent
4ce084c707
commit
01a25bb64e
3 changed files with 27 additions and 30 deletions
|
|
@ -376,6 +376,8 @@ public:
|
|||
|
||||
virtual ir_function_signature *clone(void *mem_ctx,
|
||||
struct hash_table *ht) const;
|
||||
ir_function_signature *clone_prototype(void *mem_ctx,
|
||||
struct hash_table *ht) const;
|
||||
|
||||
virtual void accept(ir_visitor *v)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -276,22 +276,9 @@ 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 =
|
||||
new(mem_ctx) ir_function_signature(this->return_type);
|
||||
ir_function_signature *copy = this->clone_prototype(mem_ctx, ht);
|
||||
|
||||
copy->is_defined = this->is_defined;
|
||||
copy->is_builtin = this->is_builtin;
|
||||
|
||||
/* Clone the parameter list.
|
||||
*/
|
||||
foreach_list_const(node, &this->parameters) {
|
||||
const ir_variable *const param = (const ir_variable *) node;
|
||||
|
||||
assert(const_cast<ir_variable *>(param)->as_variable() != NULL);
|
||||
|
||||
ir_variable *const param_copy = param->clone(mem_ctx, ht);
|
||||
copy->parameters.push_tail(param_copy);
|
||||
}
|
||||
|
||||
/* Clone the instruction list.
|
||||
*/
|
||||
|
|
@ -305,6 +292,29 @@ ir_function_signature::clone(void *mem_ctx, struct hash_table *ht) const
|
|||
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 = false;
|
||||
copy->is_builtin = this->is_builtin;
|
||||
|
||||
/* Clone the parameter list, but NOT the body.
|
||||
*/
|
||||
foreach_list_const(node, &this->parameters) {
|
||||
const ir_variable *const param = (const ir_variable *) node;
|
||||
|
||||
assert(const_cast<ir_variable *>(param)->as_variable() != NULL);
|
||||
|
||||
ir_variable *const param_copy = param->clone(mem_ctx, ht);
|
||||
copy->parameters.push_tail(param_copy);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
ir_constant *
|
||||
ir_constant::clone(void *mem_ctx, struct hash_table *ht) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,22 +82,7 @@ public:
|
|||
{
|
||||
assert(this->function != NULL);
|
||||
|
||||
ir_function_signature *copy =
|
||||
new(mem_ctx) ir_function_signature(ir->return_type);
|
||||
|
||||
copy->is_defined = false;
|
||||
copy->is_builtin = ir->is_builtin;
|
||||
|
||||
/* Clone the parameter list, but NOT the body.
|
||||
*/
|
||||
foreach_list_const(node, &ir->parameters) {
|
||||
const ir_variable *const param = (const ir_variable *) node;
|
||||
|
||||
assert(const_cast<ir_variable *>(param)->as_variable() != NULL);
|
||||
|
||||
ir_variable *const param_copy = param->clone(mem_ctx, NULL);
|
||||
copy->parameters.push_tail(param_copy);
|
||||
}
|
||||
ir_function_signature *copy = ir->clone_prototype(mem_ctx, NULL);
|
||||
|
||||
this->function->add_signature(copy);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue