@@ -822,7 +822,7 @@ STATIC qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pn
822
822
}
823
823
824
824
// returns true if it was a built-in decorator (even if the built-in had an error)
825
- STATIC bool compile_built_in_decorator (compiler_t * comp , int name_len , mp_parse_node_t * name_nodes , uint * emit_options ) {
825
+ STATIC bool compile_built_in_decorator (compiler_t * comp , size_t name_len , mp_parse_node_t * name_nodes , uint * emit_options ) {
826
826
if (MP_PARSE_NODE_LEAF_ARG (name_nodes [0 ]) != MP_QSTR_micropython ) {
827
827
return false;
828
828
}
@@ -874,20 +874,20 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
874
874
STATIC void compile_decorated (compiler_t * comp , mp_parse_node_struct_t * pns ) {
875
875
// get the list of decorators
876
876
mp_parse_node_t * nodes ;
877
- int n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_decorators , & nodes );
877
+ size_t n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_decorators , & nodes );
878
878
879
879
// inherit emit options for this function/class definition
880
880
uint emit_options = comp -> scope_cur -> emit_options ;
881
881
882
882
// compile each decorator
883
- int num_built_in_decorators = 0 ;
884
- for (int i = 0 ; i < n ; i ++ ) {
883
+ size_t num_built_in_decorators = 0 ;
884
+ for (size_t i = 0 ; i < n ; i ++ ) {
885
885
assert (MP_PARSE_NODE_IS_STRUCT_KIND (nodes [i ], PN_decorator )); // should be
886
886
mp_parse_node_struct_t * pns_decorator = (mp_parse_node_struct_t * )nodes [i ];
887
887
888
888
// nodes[0] contains the decorator function, which is a dotted name
889
889
mp_parse_node_t * name_nodes ;
890
- int name_len = mp_parse_node_extract_list (& pns_decorator -> nodes [0 ], PN_dotted_name , & name_nodes );
890
+ size_t name_len = mp_parse_node_extract_list (& pns_decorator -> nodes [0 ], PN_dotted_name , & name_nodes );
891
891
892
892
// check for built-in decorators
893
893
if (compile_built_in_decorator (comp , name_len , name_nodes , & emit_options )) {
@@ -899,7 +899,7 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
899
899
900
900
// compile the decorator function
901
901
compile_node (comp , name_nodes [0 ]);
902
- for (int j = 1 ; j < name_len ; j ++ ) {
902
+ for (size_t j = 1 ; j < name_len ; j ++ ) {
903
903
assert (MP_PARSE_NODE_IS_ID (name_nodes [j ])); // should be
904
904
EMIT_ARG (attr , MP_PARSE_NODE_LEAF_ARG (name_nodes [j ]), MP_EMIT_ATTR_LOAD );
905
905
}
@@ -931,7 +931,7 @@ STATIC void compile_decorated(compiler_t *comp, mp_parse_node_struct_t *pns) {
931
931
}
932
932
933
933
// call each decorator
934
- for (int i = 0 ; i < n - num_built_in_decorators ; i ++ ) {
934
+ for (size_t i = 0 ; i < n - num_built_in_decorators ; i ++ ) {
935
935
EMIT_ARG (call_function , 1 , 0 , 0 );
936
936
}
937
937
@@ -1185,10 +1185,10 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
1185
1185
1186
1186
// get the list of . and/or ...'s
1187
1187
mp_parse_node_t * nodes ;
1188
- int n = mp_parse_node_extract_list (& pn_rel , PN_one_or_more_period_or_ellipsis , & nodes );
1188
+ size_t n = mp_parse_node_extract_list (& pn_rel , PN_one_or_more_period_or_ellipsis , & nodes );
1189
1189
1190
1190
// count the total number of .'s
1191
- for (int i = 0 ; i < n ; i ++ ) {
1191
+ for (size_t i = 0 ; i < n ; i ++ ) {
1192
1192
if (MP_PARSE_NODE_IS_TOKEN_KIND (nodes [i ], MP_TOKEN_DEL_PERIOD )) {
1193
1193
import_level ++ ;
1194
1194
} else {
@@ -1222,8 +1222,8 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
1222
1222
1223
1223
// build the "fromlist" tuple
1224
1224
mp_parse_node_t * pn_nodes ;
1225
- int n = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_import_as_names , & pn_nodes );
1226
- for (int i = 0 ; i < n ; i ++ ) {
1225
+ size_t n = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_import_as_names , & pn_nodes );
1226
+ for (size_t i = 0 ; i < n ; i ++ ) {
1227
1227
assert (MP_PARSE_NODE_IS_STRUCT_KIND (pn_nodes [i ], PN_import_as_name ));
1228
1228
mp_parse_node_struct_t * pns3 = (mp_parse_node_struct_t * )pn_nodes [i ];
1229
1229
qstr id2 = MP_PARSE_NODE_LEAF_ARG (pns3 -> nodes [0 ]); // should be id
@@ -1234,7 +1234,7 @@ STATIC void compile_import_from(compiler_t *comp, mp_parse_node_struct_t *pns) {
1234
1234
// do the import
1235
1235
qstr dummy_q ;
1236
1236
do_import_name (comp , pn_import_source , & dummy_q );
1237
- for (int i = 0 ; i < n ; i ++ ) {
1237
+ for (size_t i = 0 ; i < n ; i ++ ) {
1238
1238
assert (MP_PARSE_NODE_IS_STRUCT_KIND (pn_nodes [i ], PN_import_as_name ));
1239
1239
mp_parse_node_struct_t * pns3 = (mp_parse_node_struct_t * )pn_nodes [i ];
1240
1240
qstr id2 = MP_PARSE_NODE_LEAF_ARG (pns3 -> nodes [0 ]); // should be id
@@ -1285,8 +1285,8 @@ STATIC void compile_global_nonlocal_stmt(compiler_t *comp, mp_parse_node_struct_
1285
1285
}
1286
1286
1287
1287
mp_parse_node_t * nodes ;
1288
- int n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_name_list , & nodes );
1289
- for (int i = 0 ; i < n ; i ++ ) {
1288
+ size_t n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_name_list , & nodes );
1289
+ for (size_t i = 0 ; i < n ; i ++ ) {
1290
1290
qstr qst = MP_PARSE_NODE_LEAF_ARG (nodes [i ]);
1291
1291
id_info_t * id_info = scope_find_or_add_id (comp -> scope_cur , qst , ID_INFO_KIND_UNDECIDED );
1292
1292
if (is_global ) {
@@ -1346,8 +1346,8 @@ STATIC void compile_if_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
1346
1346
1347
1347
// compile elif blocks (if any)
1348
1348
mp_parse_node_t * pn_elif ;
1349
- int n_elif = mp_parse_node_extract_list (& pns -> nodes [2 ], PN_if_stmt_elif_list , & pn_elif );
1350
- for (int i = 0 ; i < n_elif ; i ++ ) {
1349
+ size_t n_elif = mp_parse_node_extract_list (& pns -> nodes [2 ], PN_if_stmt_elif_list , & pn_elif );
1350
+ for (size_t i = 0 ; i < n_elif ; i ++ ) {
1351
1351
assert (MP_PARSE_NODE_IS_STRUCT_KIND (pn_elif [i ], PN_if_stmt_elif )); // should be
1352
1352
mp_parse_node_struct_t * pns_elif = (mp_parse_node_struct_t * )pn_elif [i ];
1353
1353
@@ -1524,7 +1524,7 @@ STATIC void compile_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
1524
1524
&& MP_PARSE_NODE_STRUCT_KIND ((mp_parse_node_struct_t * )pns_it -> nodes [1 ]) == PN_trailer_paren ) {
1525
1525
mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t * )pns_it -> nodes [1 ])-> nodes [0 ];
1526
1526
mp_parse_node_t * args ;
1527
- int n_args = mp_parse_node_extract_list (& pn_range_args , PN_arglist , & args );
1527
+ size_t n_args = mp_parse_node_extract_list (& pn_range_args , PN_arglist , & args );
1528
1528
mp_parse_node_t pn_range_start ;
1529
1529
mp_parse_node_t pn_range_end ;
1530
1530
mp_parse_node_t pn_range_step ;
@@ -1720,7 +1720,7 @@ STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
1720
1720
} else if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) == PN_try_stmt_except_and_more ) {
1721
1721
// try-except and possibly else and/or finally
1722
1722
mp_parse_node_t * pn_excepts ;
1723
- int n_except = mp_parse_node_extract_list (& pns2 -> nodes [0 ], PN_try_stmt_except_list , & pn_excepts );
1723
+ size_t n_except = mp_parse_node_extract_list (& pns2 -> nodes [0 ], PN_try_stmt_except_list , & pn_excepts );
1724
1724
if (MP_PARSE_NODE_IS_NULL (pns2 -> nodes [2 ])) {
1725
1725
// no finally
1726
1726
compile_try_except (comp , pns -> nodes [0 ], n_except , pn_excepts , pns2 -> nodes [1 ]);
@@ -1731,13 +1731,13 @@ STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
1731
1731
} else {
1732
1732
// just try-except
1733
1733
mp_parse_node_t * pn_excepts ;
1734
- int n_except = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_try_stmt_except_list , & pn_excepts );
1734
+ size_t n_except = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_try_stmt_except_list , & pn_excepts );
1735
1735
compile_try_except (comp , pns -> nodes [0 ], n_except , pn_excepts , MP_PARSE_NODE_NULL );
1736
1736
}
1737
1737
}
1738
1738
}
1739
1739
1740
- STATIC void compile_with_stmt_helper (compiler_t * comp , int n , mp_parse_node_t * nodes , mp_parse_node_t body ) {
1740
+ STATIC void compile_with_stmt_helper (compiler_t * comp , size_t n , mp_parse_node_t * nodes , mp_parse_node_t body ) {
1741
1741
if (n == 0 ) {
1742
1742
// no more pre-bits, compile the body of the with
1743
1743
compile_node (comp , body );
@@ -1767,7 +1767,7 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, int n, mp_parse_node_t *n
1767
1767
STATIC void compile_with_stmt (compiler_t * comp , mp_parse_node_struct_t * pns ) {
1768
1768
// get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
1769
1769
mp_parse_node_t * nodes ;
1770
- int n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_with_stmt_list , & nodes );
1770
+ size_t n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_with_stmt_list , & nodes );
1771
1771
assert (n > 0 );
1772
1772
1773
1773
// compile in a nested fashion
@@ -1839,7 +1839,7 @@ STATIC void compile_async_for_stmt(compiler_t *comp, mp_parse_node_struct_t *pns
1839
1839
EMIT_ARG (label_assign , break_label );
1840
1840
}
1841
1841
1842
- STATIC void compile_async_with_stmt_helper (compiler_t * comp , int n , mp_parse_node_t * nodes , mp_parse_node_t body ) {
1842
+ STATIC void compile_async_with_stmt_helper (compiler_t * comp , size_t n , mp_parse_node_t * nodes , mp_parse_node_t body ) {
1843
1843
if (n == 0 ) {
1844
1844
// no more pre-bits, compile the body of the with
1845
1845
compile_node (comp , body );
@@ -1954,7 +1954,7 @@ STATIC void compile_async_with_stmt_helper(compiler_t *comp, int n, mp_parse_nod
1954
1954
STATIC void compile_async_with_stmt (compiler_t * comp , mp_parse_node_struct_t * pns ) {
1955
1955
// get the nodes for the pre-bit of the with (the a as b, c as d, ... bit)
1956
1956
mp_parse_node_t * nodes ;
1957
- int n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_with_stmt_list , & nodes );
1957
+ size_t n = mp_parse_node_extract_list (& pns -> nodes [0 ], PN_with_stmt_list , & nodes );
1958
1958
assert (n > 0 );
1959
1959
1960
1960
// compile in a nested fashion
@@ -2325,7 +2325,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
2325
2325
2326
2326
// get the list of arguments
2327
2327
mp_parse_node_t * args ;
2328
- int n_args = mp_parse_node_extract_list (& pn_arglist , PN_arglist , & args );
2328
+ size_t n_args = mp_parse_node_extract_list (& pn_arglist , PN_arglist , & args );
2329
2329
2330
2330
// compile the arguments
2331
2331
// Rather than calling compile_node on the list, we go through the list of args
@@ -2335,7 +2335,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar
2335
2335
uint n_keyword = 0 ;
2336
2336
uint star_flags = 0 ;
2337
2337
mp_parse_node_struct_t * star_args_node = NULL , * dblstar_args_node = NULL ;
2338
- for (int i = 0 ; i < n_args ; i ++ ) {
2338
+ for (size_t i = 0 ; i < n_args ; i ++ ) {
2339
2339
if (MP_PARSE_NODE_IS_STRUCT (args [i ])) {
2340
2340
mp_parse_node_struct_t * pns_arg = (mp_parse_node_struct_t * )args [i ];
2341
2341
if (MP_PARSE_NODE_STRUCT_KIND (pns_arg ) == PN_arglist_star ) {
@@ -2527,7 +2527,7 @@ STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *
2527
2527
2528
2528
// get tail elements (2nd, 3rd, ...)
2529
2529
mp_parse_node_t * nodes ;
2530
- int n = mp_parse_node_extract_list (& pns1 -> nodes [0 ], PN_dictorsetmaker_list2 , & nodes );
2530
+ size_t n = mp_parse_node_extract_list (& pns1 -> nodes [0 ], PN_dictorsetmaker_list2 , & nodes );
2531
2531
2532
2532
// first element sets whether it's a dict or set
2533
2533
bool is_dict ;
@@ -2546,7 +2546,7 @@ STATIC void compile_atom_brace_helper(compiler_t *comp, mp_parse_node_struct_t *
2546
2546
}
2547
2547
2548
2548
// process rest of elements
2549
- for (int i = 0 ; i < n ; i ++ ) {
2549
+ for (size_t i = 0 ; i < n ; i ++ ) {
2550
2550
mp_parse_node_t pn_i = nodes [i ];
2551
2551
bool is_key_value = MP_PARSE_NODE_IS_STRUCT_KIND (pn_i , PN_dictorsetmaker_item );
2552
2552
compile_node (comp , pn_i );
@@ -3197,7 +3197,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
3197
3197
// parameters are in pns->nodes[1]
3198
3198
if (comp -> pass == MP_PASS_CODE_SIZE ) {
3199
3199
mp_parse_node_t * pn_params ;
3200
- int n_params = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_typedargslist , & pn_params );
3200
+ size_t n_params = mp_parse_node_extract_list (& pns -> nodes [1 ], PN_typedargslist , & pn_params );
3201
3201
scope -> num_pos_args = EMIT_INLINE_ASM_ARG (count_params , n_params , pn_params );
3202
3202
if (comp -> compile_error != MP_OBJ_NULL ) {
3203
3203
goto inline_asm_error ;
@@ -3235,9 +3235,9 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
3235
3235
3236
3236
mp_parse_node_t pn_body = pns -> nodes [3 ]; // body
3237
3237
mp_parse_node_t * nodes ;
3238
- int num = mp_parse_node_extract_list (& pn_body , PN_suite_block_stmts , & nodes );
3238
+ size_t num = mp_parse_node_extract_list (& pn_body , PN_suite_block_stmts , & nodes );
3239
3239
3240
- for (int i = 0 ; i < num ; i ++ ) {
3240
+ for (size_t i = 0 ; i < num ; i ++ ) {
3241
3241
assert (MP_PARSE_NODE_IS_STRUCT (nodes [i ]));
3242
3242
mp_parse_node_struct_t * pns2 = (mp_parse_node_struct_t * )nodes [i ];
3243
3243
if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) == PN_pass_stmt ) {
@@ -3271,7 +3271,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
3271
3271
qstr op = MP_PARSE_NODE_LEAF_ARG (pns2 -> nodes [0 ]);
3272
3272
pns2 = (mp_parse_node_struct_t * )pns2 -> nodes [1 ]; // PN_trailer_paren
3273
3273
mp_parse_node_t * pn_arg ;
3274
- int n_args = mp_parse_node_extract_list (& pns2 -> nodes [0 ], PN_arglist , & pn_arg );
3274
+ size_t n_args = mp_parse_node_extract_list (& pns2 -> nodes [0 ], PN_arglist , & pn_arg );
3275
3275
3276
3276
// emit instructions
3277
3277
if (op == MP_QSTR_label ) {
0 commit comments