diff options
author | Damien George <damien.p.george@gmail.com> | 2018-05-19 00:30:42 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-05-23 00:22:35 +1000 |
commit | e686c940525c5b87d02e3dd7bfcdec23cfa996dd (patch) | |
tree | 53782e9b79e3a26eb4ec2c5cd1348b0cea351e25 /py/emitbc.c | |
parent | 0a25fff9562e3051d85db9ca773f203620004742 (diff) | |
download | micropython-e686c940525c5b87d02e3dd7bfcdec23cfa996dd.tar.gz micropython-e686c940525c5b87d02e3dd7bfcdec23cfa996dd.zip |
py/emit: Combine yield value and yield-from emit funcs into one.
Reduces code size by:
bare-arm: -24
minimal x86: -72
unix x64: -200
unix nanbox: -72
stm32: -52
cc3200: -32
esp8266: -84
esp32: -24
Diffstat (limited to 'py/emitbc.c')
-rw-r--r-- | py/emitbc.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/py/emitbc.c b/py/emitbc.c index 28d32d4ea8..bff2c5a4c5 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -931,16 +931,11 @@ void mp_emit_bc_raise_varargs(emit_t *emit, mp_uint_t n_args) { emit_write_bytecode_byte_byte(emit, MP_BC_RAISE_VARARGS, n_args); } -void mp_emit_bc_yield_value(emit_t *emit) { - emit_bc_pre(emit, 0); - emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - emit_write_bytecode_byte(emit, MP_BC_YIELD_VALUE); -} - -void mp_emit_bc_yield_from(emit_t *emit) { - emit_bc_pre(emit, -1); +void mp_emit_bc_yield(emit_t *emit, int kind) { + MP_STATIC_ASSERT(MP_BC_YIELD_VALUE + 1 == MP_BC_YIELD_FROM); + emit_bc_pre(emit, -kind); emit->scope->scope_flags |= MP_SCOPE_FLAG_GENERATOR; - emit_write_bytecode_byte(emit, MP_BC_YIELD_FROM); + emit_write_bytecode_byte(emit, MP_BC_YIELD_VALUE + kind); } void mp_emit_bc_start_except_handler(emit_t *emit) { @@ -1034,8 +1029,7 @@ const emit_method_table_t emit_bc_method_table = { mp_emit_bc_call_method, mp_emit_bc_return_value, mp_emit_bc_raise_varargs, - mp_emit_bc_yield_value, - mp_emit_bc_yield_from, + mp_emit_bc_yield, mp_emit_bc_start_except_handler, mp_emit_bc_end_except_handler, |