diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-11 13:38:30 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-11 13:38:30 +0000 |
commit | 69b89d21b2dcbe61c9abe1744cc0ec77d89422de (patch) | |
tree | bb467f417445eef1af49054d2a5363044380505b /py/emitbc.c | |
parent | 0e3329a6b82873531f63fb1358f57852723fad05 (diff) | |
download | micropython-69b89d21b2dcbe61c9abe1744cc0ec77d89422de.tar.gz micropython-69b89d21b2dcbe61c9abe1744cc0ec77d89422de.zip |
py: Change compile order for default positional and keyword args.
This simplifies the compiler a little, since now it can do 1 pass over
a function declaration, to determine default arguments. I would have
done this originally, but CPython 3.3 somehow had the default keyword
args compiled before the default position args (even though they appear
in the other order in the text of the script), and I thought it was
important to have the same order of execution when evaluating default
arguments. CPython 3.4 has changed the order to the more obvious one,
so we can also change.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r-- | py/emitbc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/emitbc.c b/py/emitbc.c index fc3e5ed622..a1179a6954 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -744,10 +744,10 @@ STATIC void emit_bc_make_function(emit_t *emit, scope_t *scope, uint n_pos_defau if (n_pos_defaults == 0) { // load dummy entry for non-existent positional default tuple emit_bc_load_null(emit); + emit_bc_rot_two(emit); } else if (n_kw_defaults == 0) { // load dummy entry for non-existent keyword default dict emit_bc_load_null(emit); - emit_bc_rot_two(emit); } emit_bc_pre(emit, -1); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION_DEFARGS, scope->unique_code_id); @@ -762,11 +762,11 @@ STATIC void emit_bc_make_closure(emit_t *emit, scope_t *scope, uint n_pos_defaul if (n_pos_defaults == 0) { // load dummy entry for non-existent positional default tuple emit_bc_load_null(emit); - emit_bc_rot_two(emit); + emit_bc_rot_three(emit); } else if (n_kw_defaults == 0) { // load dummy entry for non-existent keyword default dict emit_bc_load_null(emit); - emit_bc_rot_three(emit); + emit_bc_rot_two(emit); } emit_bc_pre(emit, -2); emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_CLOSURE_DEFARGS, scope->unique_code_id); |