diff options
author | Damien George <damien.p.george@gmail.com> | 2014-06-07 22:01:00 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-06-07 22:01:00 +0100 |
commit | f0778a7ccbbdd1d7bf116a6939c7eb05173e1987 (patch) | |
tree | 24a427ad51ea16deacc158a855b8c13b7c98f57c /py/compile.c | |
parent | aabd83ea204325cdf45355a5bdc6838745484060 (diff) |
py: Implement default keyword only args.
Should finish addressing issue #524.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c index 1f0d90570..946c8924b 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1035,7 +1035,10 @@ void compile_funcdef_param(compiler_t *comp, mp_parse_node_t pn) { if (comp->have_star) { comp->num_dict_params += 1; -#if !MICROPY_EMIT_CPYTHON +#if MICROPY_EMIT_CPYTHON + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id), false); + compile_node(comp, pn_equal); +#else // in Micro Python we put the default dict parameters into a dictionary using the bytecode if (comp->num_dict_params == 1) { // in Micro Python we put the default positional parameters into a tuple using the bytecode @@ -1048,11 +1051,10 @@ void compile_funcdef_param(compiler_t *comp, mp_parse_node_t pn) { // first default dict param, so make the map EMIT_ARG(build_map, 0); } -#endif - EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id), false); + + // compile value then key, then store it to the dict compile_node(comp, pn_equal); -#if !MICROPY_EMIT_CPYTHON - // in Micro Python we put the default dict parameters into a dictionary using the bytecode + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id), false); EMIT(store_map); #endif } else { |