summaryrefslogtreecommitdiff
path: root/py/compile.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-31 11:30:17 +0100
committerDamien George <damien.p.george@gmail.com>2014-03-31 11:30:17 +0100
commit3056509e00c02e4faef44d90bf3953dcf0b0d4a0 (patch)
treef188e15e19a8ae43d777215a3e05807b1ef2c21a /py/compile.c
parente0f2979aed58499e791b01a77190d7f266cc88ea (diff)
py: Rename and reorder parameters in emit_make_function/closure.
In preparation for implementing default keyword arguments.
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/py/compile.c b/py/compile.c
index c6c6752d1..b2000d5b0 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -774,11 +774,14 @@ void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_kind) {
}
// stuff for lambda and comprehensions and generators
-void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_dict_params, int n_default_params) {
+void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_pos_defaults, int n_kw_defaults) {
+ assert(n_pos_defaults >= 0);
+ assert(n_kw_defaults >= 0);
+
#if !MICROPY_EMIT_CPYTHON
// in Micro Python we put the default params into a tuple using the bytecode
- if (n_default_params) {
- EMIT_ARG(build_tuple, n_default_params);
+ if (n_pos_defaults) {
+ EMIT_ARG(build_tuple, n_pos_defaults);
}
#endif
@@ -807,10 +810,10 @@ void close_over_variables_etc(compiler_t *comp, scope_t *this_scope, int n_dict_
// make the function/closure
if (nfree == 0) {
- EMIT_ARG(make_function, this_scope, n_dict_params, n_default_params);
+ EMIT_ARG(make_function, this_scope, n_pos_defaults, n_kw_defaults);
} else {
EMIT_ARG(build_tuple, nfree);
- EMIT_ARG(make_closure, this_scope, n_dict_params, n_default_params);
+ EMIT_ARG(make_closure, this_scope, n_pos_defaults, n_kw_defaults);
}
}
@@ -921,7 +924,7 @@ qstr compile_funcdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint
scope_t *fscope = (scope_t*)pns->nodes[4];
// make the function
- close_over_variables_etc(comp, fscope, comp->param_pass_num_dict_params, comp->param_pass_num_default_params);
+ close_over_variables_etc(comp, fscope, comp->param_pass_num_default_params, comp->param_pass_num_dict_params);
// restore variables
comp->have_bare_star = old_have_bare_star;