py: Combine continuous block of emit steps into with_cleanup emit call.
Because different emitters need to handle with-cleanup in different ways.
This commit is contained in:
parent
2c407bcf20
commit
ce8b4e8749
@ -1640,10 +1640,7 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *n
|
||||
// compile additional pre-bits and the body
|
||||
compile_with_stmt_helper(comp, n - 1, nodes + 1, body);
|
||||
// finish this with block
|
||||
EMIT(pop_block);
|
||||
EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
|
||||
EMIT_ARG(label_assign, l_end);
|
||||
EMIT(with_cleanup);
|
||||
EMIT_ARG(with_cleanup, l_end);
|
||||
compile_decrease_except_level(comp);
|
||||
EMIT(end_finally);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ typedef struct _emit_method_table_t {
|
||||
void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
|
||||
void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
|
||||
void (*setup_with)(emit_t *emit, mp_uint_t label);
|
||||
void (*with_cleanup)(emit_t *emit);
|
||||
void (*with_cleanup)(emit_t *emit, mp_uint_t label);
|
||||
void (*setup_except)(emit_t *emit, mp_uint_t label);
|
||||
void (*setup_finally)(emit_t *emit, mp_uint_t label);
|
||||
void (*end_finally)(emit_t *emit);
|
||||
@ -227,7 +227,7 @@ void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_dept
|
||||
#define mp_emit_bc_break_loop mp_emit_bc_unwind_jump
|
||||
#define mp_emit_bc_continue_loop mp_emit_bc_unwind_jump
|
||||
void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label);
|
||||
void mp_emit_bc_with_cleanup(emit_t *emit);
|
||||
void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label);
|
||||
void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label);
|
||||
void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label);
|
||||
void mp_emit_bc_end_finally(emit_t *emit);
|
||||
|
@ -758,7 +758,10 @@ void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label) {
|
||||
emit_write_bytecode_byte_unsigned_label(emit, MP_BC_SETUP_WITH, label);
|
||||
}
|
||||
|
||||
void mp_emit_bc_with_cleanup(emit_t *emit) {
|
||||
void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label) {
|
||||
mp_emit_bc_pop_block(emit);
|
||||
mp_emit_bc_load_const_tok(emit, MP_TOKEN_KW_NONE);
|
||||
mp_emit_bc_label_assign(emit, label);
|
||||
emit_bc_pre(emit, -4);
|
||||
emit_write_bytecode_byte(emit, MP_BC_WITH_CLEANUP);
|
||||
}
|
||||
|
@ -1990,7 +1990,7 @@ STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
|
||||
assert(0);
|
||||
}
|
||||
|
||||
STATIC void emit_native_with_cleanup(emit_t *emit) {
|
||||
STATIC void emit_native_with_cleanup(emit_t *emit, mp_uint_t label) {
|
||||
(void)emit;
|
||||
assert(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user