diff options
author | Damien George <damien.p.george@gmail.com> | 2015-11-27 17:09:11 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-29 14:25:36 +0000 |
commit | b8cfb0d7b2c91ea1e17f6caeabfc9cb23166cdc1 (patch) | |
tree | d8fc58ac063c837b22b15f7a3967a09f06013054 /py/parse.c | |
parent | 999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (diff) | |
download | micropython-b8cfb0d7b2c91ea1e17f6caeabfc9cb23166cdc1.tar.gz micropython-b8cfb0d7b2c91ea1e17f6caeabfc9cb23166cdc1.zip |
py: Add support for 64-bit NaN-boxing object model, on 32-bit machine.
To use, put the following in mpconfigport.h:
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_D)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
typedef int64_t mp_int_t;
typedef uint64_t mp_uint_t;
#define UINT_FMT "%llu"
#define INT_FMT "%lld"
Currently does not work with native emitter enabled.
Diffstat (limited to 'py/parse.c')
-rw-r--r-- | py/parse.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/py/parse.c b/py/parse.c index afe8711a2d..25aeeae03b 100644 --- a/py/parse.c +++ b/py/parse.c @@ -283,7 +283,11 @@ void mp_parse_node_print(mp_parse_node_t pn, mp_uint_t indent) { } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_bytes) { printf("literal bytes(%.*s)\n", (int)pns->nodes[1], (char*)pns->nodes[0]); } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_const_object) { + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + printf("literal const(%016llx)\n", (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32)); + #else printf("literal const(%p)\n", (mp_obj_t)pns->nodes[0]); + #endif } else { mp_uint_t n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); #ifdef USE_RULE_NAME @@ -362,8 +366,15 @@ STATIC mp_parse_node_t make_node_const_object(parser_t *parser, mp_uint_t src_li return MP_PARSE_NODE_NULL; } pn->source_line = src_line; + #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D + // nodes are 32-bit pointers, but need to store 64-bit object + pn->kind_num_nodes = RULE_const_object | (2 << 8); + pn->nodes[0] = (uint64_t)obj; + pn->nodes[1] = (uint64_t)obj >> 32; + #else pn->kind_num_nodes = RULE_const_object | (1 << 8); pn->nodes[0] = (mp_uint_t)obj; + #endif return (mp_parse_node_t)pn; } |