summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-31 17:54:26 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-31 17:54:26 -0700
commite29a5859891eb9e1587396dea0e8010f7d88f68c (patch)
tree4de5f769931784b05916d0f6d9c1ce81f640fe36
parent2d394d4877794d19756c3760d711524dca89f772 (diff)
Use ir_variable::clone to copy parameters to the function body
Several other code movements were also done. This partitions this function into two halves. The first half processes the prototype part, and the second have processes the actual function definition. The coming patch series will parition ast_function_definition::hir into (at least) two separate functions.
-rw-r--r--ast_to_hir.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 627d932182..6d78383a46 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1544,32 +1544,29 @@ ast_function_definition::hir(exec_list *instructions,
}
}
+ parameters.move_nodes_to(& signature->parameters);
+
assert(state->current_function == NULL);
state->current_function = signature;
- ast_function_parameters_to_hir(& this->prototype->parameters,
- & signature->parameters,
- state);
-
label = new ir_label(name);
if (signature->definition == NULL) {
signature->definition = label;
}
instructions->push_tail(label);
- /* Add the function parameters to the symbol table. During this step the
- * parameter declarations are also moved from the temporary "parameters" list
- * to the instruction list. There are other more efficient ways to do this,
- * but they involve ugly linked-list gymnastics.
+ /* Duplicate parameters declared in the prototype as concrete variables.
+ * Add these to the symbol table.
*/
state->symbols->push_scope();
- foreach_iter(exec_list_iterator, iter, parameters) {
- ir_variable *const var = ((ir_instruction *) iter.get())->as_variable();
+ foreach_iter(exec_list_iterator, iter, signature->parameters) {
+ ir_variable *const proto = ((ir_instruction *) iter.get())->as_variable();
+
+ assert(proto != NULL);
- assert(var != NULL);
+ ir_variable *const var = proto->clone();
- iter.remove();
instructions->push_tail(var);
/* The only way a parameter would "exist" is if two parameters have