diff options
author | Damien George <damien.p.george@gmail.com> | 2014-05-28 14:51:12 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-05-28 14:51:12 +0100 |
commit | d1e355ea8e2a5a17ee126f5c3d173b2e6f33e460 (patch) | |
tree | d5ba59452f72a9dcc31fc6cdcf0ad8c08c8713b2 /py/compile.c | |
parent | 813ed3bda6818bd8dd15ee5e3c673a24321e740b (diff) | |
download | micropython-d1e355ea8e2a5a17ee126f5c3d173b2e6f33e460.tar.gz micropython-d1e355ea8e2a5a17ee126f5c3d173b2e6f33e460.zip |
py: Fix check of small-int overflow when parsing ints.
Also unifies use of SMALL_INT_FITS macro across parser and runtime.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/compile.c b/py/compile.c index f925c8c1ff..31ecbf0b91 100644 --- a/py/compile.c +++ b/py/compile.c @@ -249,7 +249,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m // shouldn't happen assert(0); } - if (MP_PARSE_FITS_SMALL_INT(arg0)) { + if (MP_SMALL_INT_FITS(arg0)) { //printf("%ld + %ld\n", arg0, arg1); pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0); } @@ -264,7 +264,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m // int * int if (!mp_small_int_mul_overflow(arg0, arg1)) { arg0 *= arg1; - if (MP_PARSE_FITS_SMALL_INT(arg0)) { + if (MP_SMALL_INT_FITS(arg0)) { pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, arg0); } } @@ -337,7 +337,7 @@ STATIC mp_parse_node_t fold_constants(compiler_t *comp, mp_parse_node_t pn, mp_m mp_load_method_maybe(elem->value, q_attr, dest); if (MP_OBJ_IS_SMALL_INT(dest[0]) && dest[1] == NULL) { machine_int_t val = MP_OBJ_SMALL_INT_VALUE(dest[0]); - if (MP_PARSE_FITS_SMALL_INT(val)) { + if (MP_SMALL_INT_FITS(val)) { pn = mp_parse_node_new_leaf(MP_PARSE_NODE_SMALL_INT, val); } } |