diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-02-01 17:51:47 +0000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-02-01 17:51:47 +0000 |
| commit | 87413a4d0c579ec491cf52ab8d6520430df64c7d (patch) | |
| tree | c19abcbf9275c5debd4436ed5146a4aab1ad4c7d /py/emitbc.c | |
| parent | 382b3d00ed9a2f31dcedbf65ce82cbada9b6dbdf (diff) | |
| parent | 90750029df8d7fd24600cc4fe4c98a5b80731f28 (diff) | |
Merge branch 'fun-defargs' of github.com:pfalcon/micropython into pfalcon-fun-defargs
Diffstat (limited to 'py/emitbc.c')
| -rw-r--r-- | py/emitbc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/py/emitbc.c b/py/emitbc.c index d74b06525..10a93d5b6 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -664,9 +664,15 @@ static void emit_bc_unpack_ex(emit_t *emit, int n_left, int n_right) { } static void emit_bc_make_function(emit_t *emit, scope_t *scope, int n_dict_params, int n_default_params) { - assert(n_default_params == 0 && n_dict_params == 0); - emit_pre(emit, 1); - emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION, scope->unique_code_id); + assert(n_dict_params == 0); + if (n_default_params != 0) { + emit_bc_build_tuple(emit, n_default_params); + emit_pre(emit, 0); + emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION_DEFARGS, scope->unique_code_id); + } else { + emit_pre(emit, 1); + emit_write_byte_code_byte_uint(emit, MP_BC_MAKE_FUNCTION, scope->unique_code_id); + } } static void emit_bc_make_closure(emit_t *emit, scope_t *scope, int n_dict_params, int n_default_params) { |
