summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/compile.c16
-rw-r--r--py/parse.c7
-rw-r--r--py/persistentcode.c2
3 files changed, 8 insertions, 17 deletions
diff --git a/py/compile.c b/py/compile.c
index f9e8de457..2e719206f 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -2790,23 +2790,7 @@ STATIC void compile_node(compiler_t *comp, mp_parse_node_t pn) {
// pass
} else if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn);
- #if MICROPY_DYNAMIC_COMPILER
- mp_uint_t sign_mask = -((mp_uint_t)1 << (mp_dynamic_compiler.small_int_bits - 1));
- if ((arg & sign_mask) == 0 || (arg & sign_mask) == sign_mask) {
- // integer fits in target runtime's small-int
- EMIT_ARG(load_const_small_int, arg);
- } else {
- // integer doesn't fit, so create a multi-precision int object
- // (but only create the actual object on the last pass)
- if (comp->pass != MP_PASS_EMIT) {
- EMIT_ARG(load_const_obj, mp_const_none);
- } else {
- EMIT_ARG(load_const_obj, mp_obj_new_int_from_ll(arg));
- }
- }
- #else
EMIT_ARG(load_const_small_int, arg);
- #endif
} else if (MP_PARSE_NODE_IS_LEAF(pn)) {
uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn);
switch (MP_PARSE_NODE_LEAF_KIND(pn)) {
diff --git a/py/parse.c b/py/parse.c
index f18f03b3f..233cba11b 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -471,6 +471,13 @@ STATIC mp_parse_node_t make_node_const_int(parser_t *parser, size_t src_line, mp
return make_node_const_object(parser, src_line, obj);
}
#endif
+ #if MICROPY_DYNAMIC_COMPILER
+ // Check that the integer value fits in target runtime's small-int
+ mp_uint_t sign_mask = -((mp_uint_t)1 << (mp_dynamic_compiler.small_int_bits - 1));
+ if (!((val & sign_mask) == 0 || (val & sign_mask) == sign_mask)) {
+ return make_node_const_object(parser, src_line, obj);
+ }
+ #endif
return mp_parse_node_new_small_int(val);
} else {
return make_node_const_object(parser, src_line, obj);
diff --git a/py/persistentcode.c b/py/persistentcode.c
index b473f1830..6110ae97f 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -536,7 +536,7 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) {
// we save numbers using a simplistic text representation
// TODO could be improved
byte obj_type;
- if (mp_obj_is_type(o, &mp_type_int)) {
+ if (mp_obj_is_int(o)) {
obj_type = 'i';
#if MICROPY_PY_BUILTINS_COMPLEX
} else if (mp_obj_is_type(o, &mp_type_complex)) {