diff options
author | Damien George <damien.p.george@gmail.com> | 2015-04-03 14:29:30 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-04-03 14:29:30 +0100 |
commit | 2cc5473021c221a7c5ad942c423523679452e1be (patch) | |
tree | 15a6ed9e8d60f5a1713e7a38339f8af3a7f50f1c /py | |
parent | c0dcf6e87873aaf5deaab0501750c2cfca14777a (diff) | |
download | micropython-2cc5473021c221a7c5ad942c423523679452e1be.tar.gz micropython-2cc5473021c221a7c5ad942c423523679452e1be.zip |
py: Implement (non-compliant) support for delete_fast in native emitter.
This implementation is smaller (in code size) than #1024.
Diffstat (limited to 'py')
-rw-r--r-- | py/emitnative.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index 85eb891d4a..52a05a837a 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1614,14 +1614,11 @@ STATIC void emit_native_store_subscr(emit_t *emit) { } STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) { - // TODO implement me! - // could support for Python types, just set to None (so GC can reclaim it) - // local is automatically deleted for exception block "as" var, and the message - // breaks tests. - //mp_emitter_warning(emit->pass, "Native codegeneration doesn't support deleting local"); - (void)emit; - (void)qst; - (void)local_num; + // TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL + // to mark deleted vars but then every var would need to be checked on + // each access. Very inefficient, so just set value to None to enable GC. + emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE); + emit_native_store_fast(emit, qst, local_num); } STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) { |