|
40 | 40 |
|
41 | 41 | // TODO need to mangle __attr names |
42 | 42 |
|
| 43 | +#define INVALID_LABEL (0xffff) |
| 44 | + |
43 | 45 | typedef enum { |
44 | 46 | // define rules with a compile function |
45 | 47 | #define DEF_RULE(rule, comp, kind, ...) PN_##rule, |
@@ -954,15 +956,15 @@ STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { |
954 | 956 | } |
955 | 957 |
|
956 | 958 | STATIC void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { |
957 | | - if (comp->break_label == 0) { |
| 959 | + if (comp->break_label == INVALID_LABEL) { |
958 | 960 | compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop"); |
959 | 961 | } |
960 | 962 | assert(comp->cur_except_level >= comp->break_continue_except_level); |
961 | 963 | EMIT_ARG(break_loop, comp->break_label, comp->cur_except_level - comp->break_continue_except_level); |
962 | 964 | } |
963 | 965 |
|
964 | 966 | STATIC void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) { |
965 | | - if (comp->continue_label == 0) { |
| 967 | + if (comp->continue_label == INVALID_LABEL) { |
966 | 968 | compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop"); |
967 | 969 | } |
968 | 970 | assert(comp->cur_except_level >= comp->break_continue_except_level); |
@@ -2960,7 +2962,7 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) { |
2960 | 2962 | STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { |
2961 | 2963 | comp->pass = pass; |
2962 | 2964 | comp->scope_cur = scope; |
2963 | | - comp->next_label = 1; |
| 2965 | + comp->next_label = 0; |
2964 | 2966 | EMIT_ARG(start_pass, pass, scope); |
2965 | 2967 |
|
2966 | 2968 | if (comp->pass == MP_PASS_SCOPE) { |
@@ -3135,7 +3137,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { |
3135 | 3137 | STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) { |
3136 | 3138 | comp->pass = pass; |
3137 | 3139 | comp->scope_cur = scope; |
3138 | | - comp->next_label = 1; |
| 3140 | + comp->next_label = 0; |
3139 | 3141 |
|
3140 | 3142 | if (scope->kind != SCOPE_FUNCTION) { |
3141 | 3143 | compile_syntax_error(comp, MP_PARSE_NODE_NULL, "inline assembler must be a function"); |
@@ -3381,6 +3383,8 @@ mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_f |
3381 | 3383 |
|
3382 | 3384 | comp->source_file = source_file; |
3383 | 3385 | comp->is_repl = is_repl; |
| 3386 | + comp->break_label = INVALID_LABEL; |
| 3387 | + comp->continue_label = INVALID_LABEL; |
3384 | 3388 |
|
3385 | 3389 | // create the module scope |
3386 | 3390 | scope_t *module_scope = scope_new_and_link(comp, SCOPE_MODULE, parse_tree->root, emit_opt); |
|
0 commit comments