@@ -95,7 +95,7 @@ typedef struct _compiler_t {
95
95
STATIC void compile_syntax_error (compiler_t * comp , mp_parse_node_t pn , const char * msg ) {
96
96
// TODO store the error message to a variable in compiler_t instead of printing it
97
97
if (MP_PARSE_NODE_IS_STRUCT (pn )) {
98
- printf (" File \"%s\", line " UINT_FMT "\n" , qstr_str (comp -> source_file ), (machine_uint_t )((mp_parse_node_struct_t * )pn )-> source_line );
98
+ printf (" File \"%s\", line " UINT_FMT "\n" , qstr_str (comp -> source_file ), (mp_uint_t )((mp_parse_node_struct_t * )pn )-> source_line );
99
99
} else {
100
100
printf (" File \"%s\"\n" , qstr_str (comp -> source_file ));
101
101
}
@@ -158,7 +158,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
158
158
compile_syntax_error (comp , (mp_parse_node_t )pns , "constant must be an integer" );
159
159
break ;
160
160
}
161
- machine_int_t value = MP_PARSE_NODE_LEAF_SMALL_INT (pn_value );
161
+ mp_int_t value = MP_PARSE_NODE_LEAF_SMALL_INT (pn_value );
162
162
163
163
// store the value in the table of dynamic constants
164
164
mp_map_elem_t * elem = mp_map_lookup (consts , MP_OBJ_NEW_QSTR (id_qstr ), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND );
@@ -200,25 +200,25 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
200
200
case PN_expr :
201
201
if (n == 2 && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [0 ]) && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [1 ])) {
202
202
// int | int
203
- machine_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
204
- machine_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
203
+ mp_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
204
+ mp_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
205
205
pn = mp_parse_node_new_leaf (MP_PARSE_NODE_SMALL_INT , arg0 | arg1 );
206
206
}
207
207
break ;
208
208
209
209
case PN_and_expr :
210
210
if (n == 2 && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [0 ]) && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [1 ])) {
211
211
// int & int
212
- machine_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
213
- machine_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
212
+ mp_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
213
+ mp_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
214
214
pn = mp_parse_node_new_leaf (MP_PARSE_NODE_SMALL_INT , arg0 & arg1 );
215
215
}
216
216
break ;
217
217
218
218
case PN_shift_expr :
219
219
if (n == 3 && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [0 ]) && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [2 ])) {
220
- machine_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
221
- machine_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
220
+ mp_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
221
+ mp_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
222
222
if (MP_PARSE_NODE_IS_TOKEN_KIND (pns -> nodes [1 ], MP_TOKEN_OP_DBL_LESS )) {
223
223
// int << int
224
224
if (!(arg1 >= BITS_PER_WORD || arg0 > (MP_SMALL_INT_MAX >> arg1 ) || arg0 < (MP_SMALL_INT_MIN >> arg1 ))) {
@@ -235,10 +235,10 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
235
235
break ;
236
236
237
237
case PN_arith_expr :
238
- // overflow checking here relies on SMALL_INT being strictly smaller than machine_int_t
238
+ // overflow checking here relies on SMALL_INT being strictly smaller than mp_int_t
239
239
if (n == 3 && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [0 ]) && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [2 ])) {
240
- machine_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
241
- machine_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
240
+ mp_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
241
+ mp_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
242
242
if (MP_PARSE_NODE_IS_TOKEN_KIND (pns -> nodes [1 ], MP_TOKEN_OP_PLUS )) {
243
243
// int + int
244
244
arg0 += arg1 ;
@@ -258,8 +258,8 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
258
258
259
259
case PN_term :
260
260
if (n == 3 && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [0 ]) && MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [2 ])) {
261
- machine_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
262
- machine_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
261
+ mp_int_t arg0 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [0 ]);
262
+ mp_int_t arg1 = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [2 ]);
263
263
if (MP_PARSE_NODE_IS_TOKEN_KIND (pns -> nodes [1 ], MP_TOKEN_OP_STAR )) {
264
264
// int * int
265
265
if (!mp_small_int_mul_overflow (arg0 , arg1 )) {
@@ -288,7 +288,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
288
288
289
289
case PN_factor_2 :
290
290
if (MP_PARSE_NODE_IS_SMALL_INT (pns -> nodes [1 ])) {
291
- machine_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
291
+ mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT (pns -> nodes [1 ]);
292
292
if (MP_PARSE_NODE_IS_TOKEN_KIND (pns -> nodes [0 ], MP_TOKEN_OP_PLUS )) {
293
293
// +int
294
294
pn = mp_parse_node_new_leaf (MP_PARSE_NODE_SMALL_INT , arg );
@@ -336,7 +336,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m
336
336
mp_obj_t dest [2 ];
337
337
mp_load_method_maybe (elem -> value , q_attr , dest );
338
338
if (MP_OBJ_IS_SMALL_INT (dest [0 ]) && dest [1 ] == NULL ) {
339
- machine_int_t val = MP_OBJ_SMALL_INT_VALUE (dest [0 ]);
339
+ mp_int_t val = MP_OBJ_SMALL_INT_VALUE (dest [0 ]);
340
340
if (MP_SMALL_INT_FITS (val )) {
341
341
pn = mp_parse_node_new_leaf (MP_PARSE_NODE_SMALL_INT , val );
342
342
}
@@ -482,7 +482,7 @@ STATIC void cpython_c_print_quoted_str(vstr_t *vstr, const char *str, uint len,
482
482
STATIC void cpython_c_tuple_emit_const (compiler_t * comp , mp_parse_node_t pn , vstr_t * vstr ) {
483
483
if (MP_PARSE_NODE_IS_STRUCT_KIND (pn , PN_string )) {
484
484
mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )pn ;
485
- cpython_c_print_quoted_str (vstr , (const char * )pns -> nodes [0 ], (machine_uint_t )pns -> nodes [1 ], false);
485
+ cpython_c_print_quoted_str (vstr , (const char * )pns -> nodes [0 ], (mp_uint_t )pns -> nodes [1 ], false);
486
486
return ;
487
487
}
488
488
@@ -2528,7 +2528,7 @@ void compile_atom_string(compiler_t *comp, mp_parse_node_struct_t *pns) {
2528
2528
mp_parse_node_struct_t * pns_string = (mp_parse_node_struct_t * )pns -> nodes [i ];
2529
2529
assert (MP_PARSE_NODE_STRUCT_KIND (pns_string ) == PN_string );
2530
2530
pn_kind = MP_PARSE_NODE_STRING ;
2531
- n_bytes += (machine_uint_t )pns_string -> nodes [1 ];
2531
+ n_bytes += (mp_uint_t )pns_string -> nodes [1 ];
2532
2532
}
2533
2533
if (i == 0 ) {
2534
2534
string_kind = pn_kind ;
@@ -2549,8 +2549,8 @@ void compile_atom_string(compiler_t *comp, mp_parse_node_struct_t *pns) {
2549
2549
s_dest += s_len ;
2550
2550
} else {
2551
2551
mp_parse_node_struct_t * pns_string = (mp_parse_node_struct_t * )pns -> nodes [i ];
2552
- memcpy (s_dest , (const char * )pns_string -> nodes [0 ], (machine_uint_t )pns_string -> nodes [1 ]);
2553
- s_dest += (machine_uint_t )pns_string -> nodes [1 ];
2552
+ memcpy (s_dest , (const char * )pns_string -> nodes [0 ], (mp_uint_t )pns_string -> nodes [1 ]);
2553
+ s_dest += (mp_uint_t )pns_string -> nodes [1 ];
2554
2554
}
2555
2555
}
2556
2556
qstr q = qstr_build_end (q_ptr );
@@ -2858,10 +2858,10 @@ void compile_node(compiler_t *comp, mp_parse_node_t pn) {
2858
2858
if (MP_PARSE_NODE_IS_NULL (pn )) {
2859
2859
// pass
2860
2860
} else if (MP_PARSE_NODE_IS_SMALL_INT (pn )) {
2861
- machine_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT (pn );
2861
+ mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT (pn );
2862
2862
EMIT_ARG (load_const_small_int , arg );
2863
2863
} else if (MP_PARSE_NODE_IS_LEAF (pn )) {
2864
- machine_uint_t arg = MP_PARSE_NODE_LEAF_ARG (pn );
2864
+ mp_uint_t arg = MP_PARSE_NODE_LEAF_ARG (pn );
2865
2865
switch (MP_PARSE_NODE_LEAF_KIND (pn )) {
2866
2866
case MP_PARSE_NODE_ID : EMIT_ARG (load_id , arg ); break ;
2867
2867
case MP_PARSE_NODE_INTEGER : EMIT_ARG (load_const_int , arg ); break ;
@@ -2883,7 +2883,7 @@ void compile_node(compiler_t *comp, mp_parse_node_t pn) {
2883
2883
mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )pn ;
2884
2884
EMIT_ARG (set_line_number , pns -> source_line );
2885
2885
if (MP_PARSE_NODE_STRUCT_KIND (pns ) == PN_string ) {
2886
- EMIT_ARG (load_const_str , qstr_from_strn ((const char * )pns -> nodes [0 ], (machine_uint_t )pns -> nodes [1 ]), false);
2886
+ EMIT_ARG (load_const_str , qstr_from_strn ((const char * )pns -> nodes [0 ], (mp_uint_t )pns -> nodes [1 ]), false);
2887
2887
} else {
2888
2888
compile_function_t f = compile_function [MP_PARSE_NODE_STRUCT_KIND (pns )];
2889
2889
if (f == NULL ) {
@@ -3337,7 +3337,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
3337
3337
return ;
3338
3338
}
3339
3339
if (pass > MP_PASS_SCOPE ) {
3340
- machine_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT (pn_arg [0 ]);
3340
+ mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT (pn_arg [0 ]);
3341
3341
for (uint i = 1 ; i < n_args ; i ++ ) {
3342
3342
if (!MP_PARSE_NODE_IS_SMALL_INT (pn_arg [i ])) {
3343
3343
compile_syntax_error (comp , nodes [i ], "inline assembler 'data' requires integer arguments" );
0 commit comments