if (sig == NULL) {
sig = new ir_function_signature(return_type);
f->add_signature(sig);
- } else if (is_definition) {
- /* Destroy all of the previous parameter information. The previous
- * parameter information comes from the function prototype, and it can
- * either include invalid parameter names or may not have names at all.
- */
- foreach_iter(exec_list_iterator, iter, sig->parameters) {
- assert(((ir_instruction *) iter.get())->as_variable() != NULL);
-
- iter.remove();
- delete iter.get();
- }
}
- hir_parameters.move_nodes_to(& sig->parameters);
+ sig->replace_parameters(&hir_parameters);
signature = sig;
/* Function declarations (prototypes) do not have r-values.
}
+void
+ir_function_signature::replace_parameters(exec_list *new_params)
+{
+ /* Destroy all of the previous parameter information. If the previous
+ * parameter information comes from the function prototype, it may either
+ * specify incorrect parameter names or not have names at all.
+ */
+ foreach_iter(exec_list_iterator, iter, parameters) {
+ assert(((ir_instruction *) iter.get())->as_variable() != NULL);
+
+ iter.remove();
+ delete (ir_instruction*) iter.get();
+ }
+
+ new_params->move_nodes_to(¶meters);
+}
+
+
ir_function::ir_function(const char *name)
: name(name)
{
*/
const char *qualifiers_match(exec_list *params);
+ /**
+ * Replace the current parameter list with the given one. This is useful
+ * if the current information came from a prototype, and either has invalid
+ * or missing parameter names.
+ */
+ void replace_parameters(exec_list *new_params);
+
/**
* Function return type.
*