diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-14 21:32:42 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-14 21:32:42 +0000 |
commit | d2d64f00fb7f1487c1fa21a456e003a801d7e711 (patch) | |
tree | 7345a9ba92baed508c4287bfca5ab09d67290821 /py/compile.c | |
parent | 65ef6b768cbba6a55f28c13433c3763c6567045e (diff) | |
download | micropython-d2d64f00fb7f1487c1fa21a456e003a801d7e711.tar.gz micropython-d2d64f00fb7f1487c1fa21a456e003a801d7e711.zip |
py: Add "default" to switches to allow better code flow analysis.
This helps compiler produce smaller code. Saves 124 bytes on stmhal and
bare-arm.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/py/compile.c b/py/compile.c index 55ab688962..f554854252 100644 --- a/py/compile.c +++ b/py/compile.c @@ -860,6 +860,7 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ EMIT_ARG(store_id, arg); break; case ASSIGN_AUG_LOAD: + default: EMIT_ARG(load_id, arg); break; } @@ -2185,8 +2186,7 @@ STATIC void compile_expr_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { case MP_TOKEN_DEL_DBL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_FLOOR_DIVIDE; break; case MP_TOKEN_DEL_SLASH_EQUAL: op = MP_BINARY_OP_INPLACE_TRUE_DIVIDE; break; case MP_TOKEN_DEL_PERCENT_EQUAL: op = MP_BINARY_OP_INPLACE_MODULO; break; - case MP_TOKEN_DEL_DBL_STAR_EQUAL: op = MP_BINARY_OP_INPLACE_POWER; break; - default: assert(0); op = MP_BINARY_OP_INPLACE_OR; // shouldn't happen + case MP_TOKEN_DEL_DBL_STAR_EQUAL: default: op = MP_BINARY_OP_INPLACE_POWER; break; } EMIT_ARG(binary_op, op); c_assign(comp, pns->nodes[0], ASSIGN_AUG_STORE); // lhs store for aug assign @@ -2350,8 +2350,7 @@ STATIC void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) { case MP_TOKEN_OP_LESS_EQUAL: op = MP_BINARY_OP_LESS_EQUAL; break; case MP_TOKEN_OP_MORE_EQUAL: op = MP_BINARY_OP_MORE_EQUAL; break; case MP_TOKEN_OP_NOT_EQUAL: op = MP_BINARY_OP_NOT_EQUAL; break; - case MP_TOKEN_KW_IN: op = MP_BINARY_OP_IN; break; - default: assert(0); op = MP_BINARY_OP_LESS; // shouldn't happen + case MP_TOKEN_KW_IN: default: op = MP_BINARY_OP_IN; break; } EMIT_ARG(binary_op, op); } else if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])) { @@ -2982,7 +2981,7 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) { case MP_PARSE_NODE_DECIMAL: EMIT_ARG(load_const_dec, arg); break; case MP_PARSE_NODE_STRING: EMIT_ARG(load_const_str, arg, false); break; case MP_PARSE_NODE_BYTES: EMIT_ARG(load_const_str, arg, true); break; - case MP_PARSE_NODE_TOKEN: + case MP_PARSE_NODE_TOKEN: default: if (arg == MP_TOKEN_NEWLINE) { // this can occur when file_input lets through a NEWLINE (eg if file starts with a newline) // or when single_input lets through a NEWLINE (user enters a blank line) @@ -2991,7 +2990,6 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) { EMIT_ARG(load_const_tok, arg); } break; - default: assert(0); } } else { mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; |