diff options
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c index f925c8c1ff..1f0d90570e 100644 --- a/py/compile.c +++ b/py/compile.c @@ -73,8 +73,8 @@ typedef struct _compiler_t { uint next_label; - uint break_label; - uint continue_label; + uint16_t break_label; // highest bit set indicates we are breaking out of a for loop + uint16_t continue_label; int break_continue_except_level; uint16_t cur_except_level; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT @@ -249,7 +249,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m // shouldn't happen assert(0); } - if (MP_PARSE_FITS_SMALL_INT(arg0)) { + if (MP_SMALL_INT_FITS(arg0)) { //printf("%ld + %ld\n", arg0, arg1); pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0); } @@ -264,7 +264,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m // int * int if (!mp_small_int_mul_overflow(arg0, arg1)) { arg0 *= arg1; - if (MP_PARSE_FITS_SMALL_INT(arg0)) { + if (MP_SMALL_INT_FITS(arg0)) { pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0); } } @@ -337,7 +337,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m mp_load_method_maybe(elem->value, q_attr, dest); if (MP_OBJ_IS_SMALL_INT(dest[0]) && dest[1] == NULL) { machine_int_t val = MP_OBJ_SMALL_INT_VALUE(dest[0]); - if (MP_PARSE_FITS_SMALL_INT(val)) { + if (MP_SMALL_INT_FITS(val)) { pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, val); } } @@ -1745,6 +1745,7 @@ void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { // And, if the loop never runs, the loop variable should never be assigned void compile_for_stmt_optimised_range(compiler_t *comp, mp_parse_node_t pn_var, mp_parse_node_t pn_start, mp_parse_node_t pn_end, mp_parse_node_t pn_step, mp_parse_node_t pn_body, mp_parse_node_t pn_else) { START_BREAK_CONTINUE_BLOCK + // note that we don't need to pop anything when breaking from an optimise for loop uint top_label = comp_next_label(comp); uint entry_label = comp_next_label(comp); @@ -1843,6 +1844,7 @@ void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { #endif START_BREAK_CONTINUE_BLOCK + comp->break_label |= MP_EMIT_BREAK_FROM_FOR; uint pop_label = comp_next_label(comp); uint end_label = comp_next_label(comp); |