diff options
| author | Damien George <damien.p.george@gmail.com> | 2018-05-22 21:31:56 +1000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2018-05-23 00:22:55 +1000 |
| commit | a4941a8ba49e3503f1a87f318b79b137a70b803b (patch) | |
| tree | c154376ee020eb2c5c95db1687a0c0cbaad86f87 /py/emitnative.c | |
| parent | d298013939b38fb05961cf05c03ac3aef6a4f00c (diff) | |
py/emit: Combine load/store/delete subscr into one emit function.
Reduces code size by:
bare-arm: -8
minimal x86: -104
unix x64: -312
unix nanbox: -120
stm32: -60
cc3200: -16
esp8266: -92
esp32: -24
Diffstat (limited to 'py/emitnative.c')
| -rw-r--r-- | py/emitnative.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/py/emitnative.c b/py/emitnative.c index 203cacff4..725ee21ed 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1447,6 +1447,16 @@ STATIC void emit_native_delete_subscr(emit_t *emit) { emit_call_with_imm_arg(emit, MP_F_OBJ_SUBSCR, (mp_uint_t)MP_OBJ_NULL, REG_ARG_3); } +STATIC void emit_native_subscr(emit_t *emit, int kind) { + if (kind == MP_EMIT_SUBSCR_LOAD) { + emit_native_load_subscr(emit); + } else if (kind == MP_EMIT_SUBSCR_STORE) { + emit_native_store_subscr(emit); + } else { + emit_native_delete_subscr(emit); + } +} + STATIC void emit_native_dup_top(emit_t *emit) { DEBUG_printf("dup_top\n"); vtype_kind_t vtype; @@ -2219,11 +2229,9 @@ const emit_method_table_t EXPORT_FUN(method_table) = { emit_native_load_attr, emit_native_load_method, emit_native_load_build_class, - emit_native_load_subscr, + emit_native_subscr, emit_native_store_attr, - emit_native_store_subscr, emit_native_delete_attr, - emit_native_delete_subscr, emit_native_dup_top, emit_native_dup_top_two, emit_native_pop_top, |
