diff options
author | Damien George <damien@micropython.org> | 2022-03-31 14:26:07 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-04-14 22:44:56 +1000 |
commit | e52f14d05772b670847c0692a635a5ec223c5e57 (patch) | |
tree | f98390653c2ef9374c076bf36168c7aa15d737f6 /py/parse.c | |
parent | 42d0bd2c17fd76860c3dc0ef5c62faa48efeb121 (diff) | |
download | micropython-e52f14d05772b670847c0692a635a5ec223c5e57.tar.gz micropython-e52f14d05772b670847c0692a635a5ec223c5e57.zip |
py/parse: Factor obj extract code to mp_parse_node_extract_const_object.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/parse.c')
-rw-r--r-- | py/parse.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/py/parse.c b/py/parse.c index 233cba11b4..f0e0a165c3 100644 --- a/py/parse.c +++ b/py/parse.c @@ -333,12 +333,7 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) { return true; } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) { mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; - #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - // nodes are 32-bit pointers, but need to extract 64-bit object - *o = (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32); - #else - *o = (mp_obj_t)pns->nodes[0]; - #endif + *o = mp_parse_node_extract_const_object(pns); return mp_obj_is_int(*o); } else { return false; @@ -397,10 +392,11 @@ void mp_parse_node_print(const mp_print_t *print, mp_parse_node_t pn, size_t ind // node must be a mp_parse_node_struct_t mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_const_object) { + mp_obj_t obj = mp_parse_node_extract_const_object(pns); #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D - mp_printf(print, "literal const(%016llx)\n", (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32)); + mp_printf(print, "literal const(%016llx)\n", obj); #else - mp_printf(print, "literal const(%p)\n", (mp_obj_t)pns->nodes[0]); + mp_printf(print, "literal const(%p)\n", obj); #endif } else { size_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); |