@@ -333,12 +333,7 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
333
333
return true;
334
334
} else if (MP_PARSE_NODE_IS_STRUCT_KIND (pn , RULE_const_object )) {
335
335
mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )pn ;
336
- #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
337
- // nodes are 32-bit pointers, but need to extract 64-bit object
338
- * o = (uint64_t )pns -> nodes [0 ] | ((uint64_t )pns -> nodes [1 ] << 32 );
339
- #else
340
- * o = (mp_obj_t )pns -> nodes [0 ];
341
- #endif
336
+ * o = mp_parse_node_extract_const_object (pns );
342
337
return mp_obj_is_int (* o );
343
338
} else {
344
339
return false;
@@ -397,10 +392,11 @@ void mp_parse_node_print(const mp_print_t *print, mp_parse_node_t pn, size_t ind
397
392
// node must be a mp_parse_node_struct_t
398
393
mp_parse_node_struct_t * pns = (mp_parse_node_struct_t * )pn ;
399
394
if (MP_PARSE_NODE_STRUCT_KIND (pns ) == RULE_const_object ) {
395
+ mp_obj_t obj = mp_parse_node_extract_const_object (pns );
400
396
#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
401
- mp_printf (print , "literal const(%016llx)\n" , ( uint64_t ) pns -> nodes [ 0 ] | (( uint64_t ) pns -> nodes [ 1 ] << 32 ) );
397
+ mp_printf (print , "literal const(%016llx)\n" , obj );
402
398
#else
403
- mp_printf (print , "literal const(%p)\n" , ( mp_obj_t ) pns -> nodes [ 0 ] );
399
+ mp_printf (print , "literal const(%p)\n" , obj );
404
400
#endif
405
401
} else {
406
402
size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES (pns );
0 commit comments