summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-04-28 12:44:24 -0700
committerIan Romanick <[email protected]>2010-04-28 15:34:52 -0700
commitbff6013d469b3d4e54cdc5731801c56994a523ec (patch)
treecfbd67f0ab174146df188d4e7563dafbe0084fc8
parent0d605cb97c9cd2f9a170e3aa15bdf4021a75fc14 (diff)
Factor out parameter list replacement for later reuse.
-rw-r--r--ast_to_hir.cpp13
-rw-r--r--ir.cpp18
-rw-r--r--ir.h7
3 files changed, 26 insertions, 12 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 52e372c7e49..1dc4ea25b21 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1973,20 +1973,9 @@ ast_function::hir(exec_list *instructions,
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.
diff --git a/ir.cpp b/ir.cpp
index 8912c00e827..e7e5dee00cb 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -364,6 +364,24 @@ ir_function_signature::qualifiers_match(exec_list *params)
}
+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(&parameters);
+}
+
+
ir_function::ir_function(const char *name)
: name(name)
{
diff --git a/ir.h b/ir.h
index 118d97ffa3c..df64e488235 100644
--- a/ir.h
+++ b/ir.h
@@ -214,6 +214,13 @@ public:
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.
*
* \note This discards the optional precision qualifier.