Skip to content

Commit 2cc5473

Browse files
committed
py: Implement (non-compliant) support for delete_fast in native emitter.
This implementation is smaller (in code size) than adafruit#1024.
1 parent c0dcf6e commit 2cc5473

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

py/emitnative.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,14 +1614,11 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
16141614
}
16151615

16161616
STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
1617-
// TODO implement me!
1618-
// could support for Python types, just set to None (so GC can reclaim it)
1619-
// local is automatically deleted for exception block "as" var, and the message
1620-
// breaks tests.
1621-
//mp_emitter_warning(emit->pass, "Native codegeneration doesn't support deleting local");
1622-
(void)emit;
1623-
(void)qst;
1624-
(void)local_num;
1617+
// TODO: This is not compliant implementation. We could use MP_OBJ_SENTINEL
1618+
// to mark deleted vars but then every var would need to be checked on
1619+
// each access. Very inefficient, so just set value to None to enable GC.
1620+
emit_native_load_const_tok(emit, MP_TOKEN_KW_NONE);
1621+
emit_native_store_fast(emit, qst, local_num);
16251622
}
16261623

16271624
STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {

0 commit comments

Comments
 (0)