43
43
44
44
// TODO need to mangle __attr names
45
45
46
+ #define INVALID_LABEL (0xffff)
47
+
46
48
typedef enum {
47
49
// define rules with a compile function
48
50
#define DEF_RULE(rule, comp, kind, ...) PN_##rule,
@@ -959,7 +961,7 @@ STATIC void compile_del_stmt(compiler_t *comp, const byte *p, const byte *ptop)
959
961
960
962
STATIC void compile_break_stmt (compiler_t * comp , const byte * p , const byte * ptop ) {
961
963
(void )ptop ;
962
- if (comp -> break_label == 0 ) {
964
+ if (comp -> break_label == INVALID_LABEL ) {
963
965
compile_syntax_error (comp , p , "'break' outside loop" );
964
966
}
965
967
assert (comp -> cur_except_level >= comp -> break_continue_except_level );
@@ -968,7 +970,7 @@ STATIC void compile_break_stmt(compiler_t *comp, const byte *p, const byte *ptop
968
970
969
971
STATIC void compile_continue_stmt (compiler_t * comp , const byte * p , const byte * ptop ) {
970
972
(void )ptop ;
971
- if (comp -> continue_label == 0 ) {
973
+ if (comp -> continue_label == INVALID_LABEL ) {
972
974
compile_syntax_error (comp , p , "'continue' outside loop" );
973
975
}
974
976
assert (comp -> cur_except_level >= comp -> break_continue_except_level );
@@ -2840,7 +2842,7 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
2840
2842
STATIC void compile_scope (compiler_t * comp , scope_t * scope , pass_kind_t pass ) {
2841
2843
comp -> pass = pass ;
2842
2844
comp -> scope_cur = scope ;
2843
- comp -> next_label = 1 ;
2845
+ comp -> next_label = 0 ;
2844
2846
EMIT_ARG (start_pass , pass , scope );
2845
2847
2846
2848
if (comp -> pass == MP_PASS_SCOPE ) {
@@ -3019,7 +3021,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
3019
3021
STATIC void compile_scope_inline_asm (compiler_t * comp , scope_t * scope , pass_kind_t pass ) {
3020
3022
comp -> pass = pass ;
3021
3023
comp -> scope_cur = scope ;
3022
- comp -> next_label = 1 ;
3024
+ comp -> next_label = 0 ;
3023
3025
3024
3026
if (scope -> kind != SCOPE_FUNCTION ) {
3025
3027
compile_syntax_error (comp , NULL , "inline assembler must be a function" );
@@ -3273,6 +3275,8 @@ mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_f
3273
3275
comp -> source_file = source_file ;
3274
3276
comp -> is_repl = is_repl ;
3275
3277
comp -> co_data = parse_tree -> co_data ;
3278
+ comp -> break_label = INVALID_LABEL ;
3279
+ comp -> continue_label = INVALID_LABEL ;
3276
3280
3277
3281
// create the array of scopes
3278
3282
comp -> num_scopes = pt_small_int_value (pt_next (parse_tree -> root ));
0 commit comments