py/emitbc: Remove/refactor unreachable code, to improve coverage.

This commit is contained in:
Damien George 2016-09-27 15:46:50 +10:00
parent 897129a7ff
commit 7385b018ed

View File

@ -302,15 +302,6 @@ STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint
c[2] = bytecode_offset >> 8; c[2] = bytecode_offset >> 8;
} }
#if MICROPY_EMIT_NATIVE
STATIC void mp_emit_bc_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) {
(void)emit;
(void)op;
(void)arg1;
(void)arg2;
}
#endif
void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) { void mp_emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
emit->pass = pass; emit->pass = pass;
emit->stack_size = 0; emit->stack_size = 0;
@ -408,9 +399,7 @@ void mp_emit_bc_end_pass(emit_t *emit) {
} }
// check stack is back to zero size // check stack is back to zero size
if (emit->stack_size != 0) { assert(emit->stack_size == 0);
mp_printf(&mp_plat_print, "ERROR: stack size not back to zero; got %d\n", emit->stack_size);
}
emit_write_code_info_byte(emit, 0); // end of line number info emit_write_code_info_byte(emit, 0); // end of line number info
@ -528,9 +517,10 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_FALSE); break; case MP_TOKEN_KW_FALSE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_FALSE); break;
case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break; case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break;
case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break; case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break;
no_other_choice: default:
case MP_TOKEN_ELLIPSIS: emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj)); break; assert(tok == MP_TOKEN_ELLIPSIS);
default: assert(0); goto no_other_choice; // to help flow control analysis emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj));
break;
} }
} }
@ -964,7 +954,7 @@ void mp_emit_bc_end_except_handler(emit_t *emit) {
#if MICROPY_EMIT_NATIVE #if MICROPY_EMIT_NATIVE
const emit_method_table_t emit_bc_method_table = { const emit_method_table_t emit_bc_method_table = {
mp_emit_bc_set_native_type, NULL, // set_native_type is never called when emitting bytecode
mp_emit_bc_start_pass, mp_emit_bc_start_pass,
mp_emit_bc_end_pass, mp_emit_bc_end_pass,
mp_emit_bc_last_emit_was_return_value, mp_emit_bc_last_emit_was_return_value,