diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-20 17:50:40 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-20 17:50:40 +0100 |
commit | 3558f62fb5c21a19a518c2ba75860f0b5963219e (patch) | |
tree | cf8626118be5d0169ec0f1cd0482563595704c4e /py/emitnative.c | |
parent | bc5f0c19775e23b4f0621d52de47fb9438a78ba2 (diff) | |
download | micropython-3558f62fb5c21a19a518c2ba75860f0b5963219e.tar.gz micropython-3558f62fb5c21a19a518c2ba75860f0b5963219e.zip |
py: Making closures now passes pointer to stack, not a tuple for vars.
Closed over variables are now passed on the stack, instead of creating a
tuple and passing that. This way memory for the closed over variables
can be allocated within the closure object itself. See issue #510 for
background.
Diffstat (limited to 'py/emitnative.c')
-rw-r--r-- | py/emitnative.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index d86456244a..dc6e37c53f 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -700,6 +700,11 @@ STATIC void emit_native_load_const_verbatim_str(emit_t *emit, const char *str) { assert(0); } +STATIC void emit_native_load_null(emit_t *emit) { + emit_native_pre(emit); + emit_post_push_imm(emit, VTYPE_PYOBJ, 0); +} + STATIC void emit_native_load_fast(emit_t *emit, qstr qstr, uint id_flags, int local_num) { vtype_kind_t vtype = emit->local_vtype[local_num]; if (vtype == VTYPE_UNBOUND) { @@ -1209,7 +1214,7 @@ STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, uint n_pos_d emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } -STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, uint n_pos_defaults, uint n_kw_defaults) { +STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, uint n_closed_over, uint n_pos_defaults, uint n_kw_defaults) { assert(0); } @@ -1335,6 +1340,7 @@ const emit_method_table_t EXPORT_FUN(method_table) = { emit_native_load_const_id, emit_native_load_const_str, emit_native_load_const_verbatim_str, + emit_native_load_null, emit_native_load_fast, emit_native_load_deref, emit_native_load_closure, |