@@ -43,10 +43,10 @@ typedef struct _compiler_t {
4343 uint8_t had_error ; // try to keep compiler clean from nlr
4444 uint8_t func_arg_is_super ; // used to compile special case of super() function call
4545
46- int next_label ;
46+ uint next_label ;
4747
48- int break_label ;
49- int continue_label ;
48+ uint break_label ;
49+ uint continue_label ;
5050 int break_continue_except_level ;
5151 uint16_t cur_except_level ; // increased for SETUP_EXCEPT, SETUP_FINALLY; decreased for POP_BLOCK, POP_EXCEPT
5252
@@ -196,7 +196,7 @@ mp_parse_node_t fold_constants(mp_parse_node_t pn) {
196196STATIC void compile_trailer_paren_helper (compiler_t * comp , mp_parse_node_t pn_arglist , bool is_method_call , int n_positional_extra );
197197STATIC void compile_node (compiler_t * comp , mp_parse_node_t pn );
198198
199- STATIC int comp_next_label (compiler_t * comp ) {
199+ STATIC uint comp_next_label (compiler_t * comp ) {
200200 return comp -> next_label ++ ;
201201}
202202
@@ -467,7 +467,7 @@ STATIC void cpython_c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if
467467 int n = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
468468 if (MP_PARSE_NODE_STRUCT_KIND (pns ) == PN_or_test ) {
469469 if (jump_if == false) {
470- int label2 = comp_next_label (comp );
470+ uint label2 = comp_next_label (comp );
471471 for (int i = 0 ; i < n - 1 ; i ++ ) {
472472 cpython_c_if_cond (comp , pns -> nodes [i ], true, label2 , true);
473473 }
@@ -485,7 +485,7 @@ STATIC void cpython_c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if
485485 cpython_c_if_cond (comp , pns -> nodes [i ], false, label , true);
486486 }
487487 } else {
488- int label2 = comp_next_label (comp );
488+ uint label2 = comp_next_label (comp );
489489 for (int i = 0 ; i < n - 1 ; i ++ ) {
490490 cpython_c_if_cond (comp , pns -> nodes [i ], false, label2 , true);
491491 }
@@ -528,7 +528,7 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
528528 int n = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
529529 if (MP_PARSE_NODE_STRUCT_KIND (pns ) == PN_or_test ) {
530530 if (jump_if == false) {
531- int label2 = comp_next_label (comp );
531+ uint label2 = comp_next_label (comp );
532532 for (int i = 0 ; i < n - 1 ; i ++ ) {
533533 c_if_cond (comp , pns -> nodes [i ], true, label2 );
534534 }
@@ -546,7 +546,7 @@ STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int la
546546 c_if_cond (comp , pns -> nodes [i ], false, label );
547547 }
548548 } else {
549- int label2 = comp_next_label (comp );
549+ uint label2 = comp_next_label (comp );
550550 for (int i = 0 ; i < n - 1 ; i ++ ) {
551551 c_if_cond (comp , pns -> nodes [i ], false, label2 );
552552 }
@@ -1202,7 +1202,7 @@ void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
12021202 mp_parse_node_struct_t * pns_test_if_expr = (mp_parse_node_struct_t * )pns -> nodes [0 ];
12031203 mp_parse_node_struct_t * pns_test_if_else = (mp_parse_node_struct_t * )pns_test_if_expr -> nodes [1 ];
12041204
1205- int l_fail = comp_next_label (comp );
1205+ uint l_fail = comp_next_label (comp );
12061206 c_if_cond (comp , pns_test_if_else -> nodes [0 ], false, l_fail ); // condition
12071207 compile_node (comp , pns_test_if_expr -> nodes [0 ]); // success value
12081208 EMIT (return_value );
@@ -1451,7 +1451,7 @@ void compile_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
14511451}
14521452
14531453void compile_assert_stmt (compiler_t * comp , mp_parse_node_struct_t * pns ) {
1454- int l_end = comp_next_label (comp );
1454+ uint l_end = comp_next_label (comp );
14551455 c_if_cond (comp , pns -> nodes [0 ], true, l_end );
14561456 EMIT_ARG (load_global , MP_QSTR_AssertionError ); // we load_global instead of load_id, to be consistent with CPython
14571457 if (!MP_PARSE_NODE_IS_NULL (pns -> nodes [1 ])) {
@@ -1466,9 +1466,9 @@ void compile_assert_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
14661466void compile_if_stmt (compiler_t * comp , mp_parse_node_struct_t * pns ) {
14671467 // TODO proper and/or short circuiting
14681468
1469- int l_end = comp_next_label (comp );
1469+ uint l_end = comp_next_label (comp );
14701470
1471- int l_fail = comp_next_label (comp );
1471+ uint l_fail = comp_next_label (comp );
14721472 c_if_cond (comp , pns -> nodes [0 ], false, l_fail ); // if condition
14731473
14741474 compile_node (comp , pns -> nodes [1 ]); // if block
@@ -1529,10 +1529,10 @@ void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
15291529}
15301530
15311531#define START_BREAK_CONTINUE_BLOCK \
1532- int old_break_label = comp->break_label; \
1533- int old_continue_label = comp->continue_label; \
1534- int break_label = comp_next_label(comp); \
1535- int continue_label = comp_next_label(comp); \
1532+ uint old_break_label = comp->break_label; \
1533+ uint old_continue_label = comp->continue_label; \
1534+ uint break_label = comp_next_label(comp); \
1535+ uint continue_label = comp_next_label(comp); \
15361536 comp->break_label = break_label; \
15371537 comp->continue_label = continue_label; \
15381538 comp->break_continue_except_level = comp->cur_except_level;
@@ -1547,7 +1547,7 @@ void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
15471547
15481548 // compared to CPython, we have an optimised version of while loops
15491549#if MICROPY_EMIT_CPYTHON
1550- int done_label = comp_next_label (comp );
1550+ uint done_label = comp_next_label (comp );
15511551 EMIT_ARG (setup_loop , break_label );
15521552 EMIT_ARG (label_assign , continue_label );
15531553 c_if_cond (comp , pns -> nodes [0 ], false, done_label ); // condition
@@ -1562,7 +1562,7 @@ void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
15621562 EMIT (pop_block );
15631563 }
15641564#else
1565- int top_label = comp_next_label (comp );
1565+ uint top_label = comp_next_label (comp );
15661566 EMIT_ARG (jump , continue_label );
15671567 EMIT_ARG (label_assign , top_label );
15681568 compile_node (comp , pns -> nodes [1 ]); // body
@@ -1584,8 +1584,8 @@ void compile_while_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
15841584void 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 ) {
15851585 START_BREAK_CONTINUE_BLOCK
15861586
1587- int top_label = comp_next_label (comp );
1588- int entry_label = comp_next_label (comp );
1587+ uint top_label = comp_next_label (comp );
1588+ uint entry_label = comp_next_label (comp );
15891589
15901590 // compile: start, duplicated on stack
15911591 compile_node (comp , pn_start );
@@ -1682,8 +1682,8 @@ void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
16821682
16831683 START_BREAK_CONTINUE_BLOCK
16841684
1685- int pop_label = comp_next_label (comp );
1686- int end_label = comp_next_label (comp );
1685+ uint pop_label = comp_next_label (comp );
1686+ uint end_label = comp_next_label (comp );
16871687
16881688 // I don't think our implementation needs SETUP_LOOP/POP_BLOCK for for-statements
16891689#if MICROPY_EMIT_CPYTHON
@@ -1721,8 +1721,8 @@ void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except,
17211721
17221722 // setup code
17231723 int stack_size = EMIT (get_stack_size );
1724- int l1 = comp_next_label (comp );
1725- int success_label = comp_next_label (comp );
1724+ uint l1 = comp_next_label (comp );
1725+ uint success_label = comp_next_label (comp );
17261726
17271727 EMIT_ARG (setup_except , l1 );
17281728 compile_increase_except_level (comp );
@@ -1731,14 +1731,14 @@ void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except,
17311731 EMIT (pop_block );
17321732 EMIT_ARG (jump , success_label );
17331733 EMIT_ARG (label_assign , l1 );
1734- int l2 = comp_next_label (comp );
1734+ uint l2 = comp_next_label (comp );
17351735
17361736 for (int i = 0 ; i < n_except ; i ++ ) {
17371737 assert (MP_PARSE_NODE_IS_STRUCT_KIND (pn_excepts [i ], PN_try_stmt_except )); // should be
17381738 mp_parse_node_struct_t * pns_except = (mp_parse_node_struct_t * )pn_excepts [i ];
17391739
17401740 qstr qstr_exception_local = 0 ;
1741- int end_finally_label = comp_next_label (comp );
1741+ uint end_finally_label = comp_next_label (comp );
17421742
17431743 if (MP_PARSE_NODE_IS_NULL (pns_except -> nodes [0 ])) {
17441744 // this is a catch all exception handler
@@ -1773,7 +1773,7 @@ void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except,
17731773
17741774 EMIT (pop_top );
17751775
1776- int l3 = 0 ;
1776+ uint l3 = 0 ;
17771777 if (qstr_exception_local != 0 ) {
17781778 l3 = comp_next_label (comp );
17791779 EMIT_ARG (setup_finally , l3 );
@@ -1810,7 +1810,7 @@ void compile_try_except(compiler_t *comp, mp_parse_node_t pn_body, int n_except,
18101810void compile_try_finally (compiler_t * comp , mp_parse_node_t pn_body , int n_except , mp_parse_node_t * pn_except , mp_parse_node_t pn_else , mp_parse_node_t pn_finally ) {
18111811 // don't understand how the stack works with exceptions, so we force it to return to the correct value
18121812 int stack_size = EMIT (get_stack_size );
1813- int l_finally_block = comp_next_label (comp );
1813+ uint l_finally_block = comp_next_label (comp );
18141814
18151815 EMIT_ARG (setup_finally , l_finally_block );
18161816 compile_increase_except_level (comp );
@@ -1866,7 +1866,7 @@ void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *nodes, m
18661866 // no more pre-bits, compile the body of the with
18671867 compile_node (comp , body );
18681868 } else {
1869- int l_end = comp_next_label (comp );
1869+ uint l_end = comp_next_label (comp );
18701870 if (MP_PARSE_NODE_IS_STRUCT_KIND (nodes [0 ], PN_with_item )) {
18711871 // this pre-bit is of the form "a as b"
18721872 mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )nodes [0 ];
@@ -2024,8 +2024,8 @@ void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
20242024 mp_parse_node_struct_t * pns_test_if_else = (mp_parse_node_struct_t * )pns -> nodes [1 ];
20252025
20262026 int stack_size = EMIT (get_stack_size );
2027- int l_fail = comp_next_label (comp );
2028- int l_end = comp_next_label (comp );
2027+ uint l_fail = comp_next_label (comp );
2028+ uint l_end = comp_next_label (comp );
20292029 c_if_cond (comp , pns_test_if_else -> nodes [0 ], false, l_fail ); // condition
20302030 compile_node (comp , pns -> nodes [0 ]); // success value
20312031 EMIT_ARG (jump , l_end );
@@ -2055,7 +2055,7 @@ void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
20552055}
20562056
20572057void compile_or_test (compiler_t * comp , mp_parse_node_struct_t * pns ) {
2058- int l_end = comp_next_label (comp );
2058+ uint l_end = comp_next_label (comp );
20592059 int n = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
20602060 for (int i = 0 ; i < n ; i += 1 ) {
20612061 compile_node (comp , pns -> nodes [i ]);
@@ -2067,7 +2067,7 @@ void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
20672067}
20682068
20692069void compile_and_test (compiler_t * comp , mp_parse_node_struct_t * pns ) {
2070- int l_end = comp_next_label (comp );
2070+ uint l_end = comp_next_label (comp );
20712071 int n = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
20722072 for (int i = 0 ; i < n ; i += 1 ) {
20732073 compile_node (comp , pns -> nodes [i ]);
@@ -2088,7 +2088,7 @@ void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
20882088 int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
20892089 compile_node (comp , pns -> nodes [0 ]);
20902090 bool multi = (num_nodes > 3 );
2091- int l_fail = 0 ;
2091+ uint l_fail = 0 ;
20922092 if (multi ) {
20932093 l_fail = comp_next_label (comp );
20942094 }
@@ -2135,7 +2135,7 @@ void compile_comparison(compiler_t *comp, mp_parse_node_struct_t *pns) {
21352135 }
21362136 }
21372137 if (multi ) {
2138- int l_end = comp_next_label (comp );
2138+ uint l_end = comp_next_label (comp );
21392139 EMIT_ARG (jump , l_end );
21402140 EMIT_ARG (label_assign , l_fail );
21412141 EMIT (rot_two );
@@ -2835,8 +2835,8 @@ void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_t pn_iter, mp_parse
28352835 // for loop
28362836 mp_parse_node_struct_t * pns_comp_for2 = (mp_parse_node_struct_t * )pn_iter ;
28372837 compile_node (comp , pns_comp_for2 -> nodes [1 ]);
2838- int l_end2 = comp_next_label (comp );
2839- int l_top2 = comp_next_label (comp );
2838+ uint l_end2 = comp_next_label (comp );
2839+ uint l_top2 = comp_next_label (comp );
28402840 EMIT (get_iter );
28412841 EMIT_ARG (label_assign , l_top2 );
28422842 EMIT_ARG (for_iter , l_end2 );
@@ -2982,8 +2982,8 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
29822982 EMIT_ARG (build_set , 0 );
29832983 }
29842984
2985- int l_end = comp_next_label (comp );
2986- int l_top = comp_next_label (comp );
2985+ uint l_end = comp_next_label (comp );
2986+ uint l_top = comp_next_label (comp );
29872987 EMIT_ARG (load_id , qstr_arg );
29882988 EMIT_ARG (label_assign , l_top );
29892989 EMIT_ARG (for_iter , l_end );
@@ -3102,7 +3102,7 @@ void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass
31023102 compile_syntax_error (comp , nodes [i ], "inline assembler 'label' requires 1 argument" );
31033103 return ;
31043104 }
3105- int lab = comp_next_label (comp );
3105+ uint lab = comp_next_label (comp );
31063106 if (pass > PASS_1 ) {
31073107 EMIT_INLINE_ASM_ARG (label , lab , MP_PARSE_NODE_LEAF_ARG (pn_arg [0 ]));
31083108 }
0 commit comments