aboutsummaryrefslogtreecommitdiff
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-09-27 15:46:50 +1000
committerDamien George <damien.p.george@gmail.com>2016-09-27 15:46:50 +1000
commit7385b018edaca5c8cbbd1b2d8a6a10a63d93150d (patch)
treebfbca5da8ecd0ba88d79e3981e17d93a8c7d86c5 /py/emitbc.c
parent897129a7ff46ee82228369ed8fab43a7c0acb692 (diff)
py/emitbc: Remove/refactor unreachable code, to improve coverage.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 40485108d..d6f2bf333 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -302,15 +302,6 @@ STATIC void emit_write_bytecode_byte_signed_label(emit_t *emit, byte b1, mp_uint
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) {
emit->pass = pass;
emit->stack_size = 0;
@@ -408,9 +399,7 @@ void mp_emit_bc_end_pass(emit_t *emit) {
}
// check stack is back to zero size
- if (emit->stack_size != 0) {
- mp_printf(&mp_plat_print, "ERROR: stack size not back to zero; got %d\n", emit->stack_size);
- }
+ assert(emit->stack_size == 0);
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_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;
- no_other_choice:
- case MP_TOKEN_ELLIPSIS: emit_write_bytecode_byte_obj(emit, MP_BC_LOAD_CONST_OBJ, MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj)); break;
- default: assert(0); goto no_other_choice; // to help flow control analysis
+ default:
+ assert(tok == MP_TOKEN_ELLIPSIS);
+ 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
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_end_pass,
mp_emit_bc_last_emit_was_return_value,