Skip to content

Commit 7385b01

Browse files
committed
py/emitbc: Remove/refactor unreachable code, to improve coverage.
1 parent 897129a commit 7385b01

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

py/emitbc.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,6 @@ STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint
302302
c[2] = bytecode_offset >> 8;
303303
}
304304

305-
#if MICROPY_EMIT_NATIVE
306-
STATIC void mp_emit_bc_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) {
307-
(void)emit;
308-
(void)op;
309-
(void)arg1;
310-
(void)arg2;
311-
}
312-
#endif
313-
314305
void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
315306
emit->pass = pass;
316307
emit->stack_size = 0;
@@ -408,9 +399,7 @@ void mp_emit_bc_end_pass(emit_t *emit) {
408399
}
409400

410401
// check stack is back to zero size
411-
if (emit->stack_size != 0) {
412-
mp_printf(&mp_plat_print, "ERROR: stack size not back to zero; got %d\n", emit->stack_size);
413-
}
402+
assert(emit->stack_size == 0);
414403

415404
emit_write_code_info_byte(emit, 0); // end of line number info
416405

@@ -528,9 +517,10 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
528517
case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_FALSE); break;
529518
case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break;
530519
case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break;
531-
no_other_choice:
532-
case MP_TOKEN_ELLIPSIS: emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj)); break;
533-
default: assert(0); goto no_other_choice; // to help flow control analysis
520+
default:
521+
assert(tok == MP_TOKEN_ELLIPSIS);
522+
emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj));
523+
break;
534524
}
535525
}
536526

@@ -964,7 +954,7 @@ void mp_emit_bc_end_except_handler(emit_t *emit) {
964954

965955
#if MICROPY_EMIT_NATIVE
966956
const emit_method_table_t emit_bc_method_table = {
967-
mp_emit_bc_set_native_type,
957+
NULL, // set_native_type is never called when emitting bytecode
968958
mp_emit_bc_start_pass,
969959
mp_emit_bc_end_pass,
970960
mp_emit_bc_last_emit_was_return_value,

0 commit comments

Comments
 (0)