diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-18 14:15:48 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-18 14:15:48 +0000 |
commit | 632cf5710ca49cdcc4593672650ca53092dd435c (patch) | |
tree | 3e0e9a286e0f6eadda8b3f9de91642c1c4e2d2d9 /py/objint.c | |
parent | 20006dbba9d2d84ead036fdfab7190e88b2337ce (diff) | |
parent | d26b379eec155ddd7a4aa64057c3d0507eee79f5 (diff) | |
download | micropython-632cf5710ca49cdcc4593672650ca53092dd435c.tar.gz micropython-632cf5710ca49cdcc4593672650ca53092dd435c.zip |
Merge branch 'master' of github.com:dpgeorge/micropython
Diffstat (limited to 'py/objint.c')
-rw-r--r-- | py/objint.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/py/objint.c b/py/objint.c index 477b8aa52b..49341d38a2 100644 --- a/py/objint.c +++ b/py/objint.c @@ -58,7 +58,7 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { // This is called only with strings whose value doesn't fit in SMALL_INT mp_obj_t mp_obj_new_int_from_long_str(const char *s) { - assert(0); + nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "long int not supported in this build")); return mp_const_none; } @@ -68,8 +68,7 @@ mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value) { if ((value & (WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1))) == 0) { return MP_OBJ_NEW_SMALL_INT(value); } - // TODO: Raise exception - assert(0); + nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "small int overflow")); return mp_const_none; } @@ -77,8 +76,16 @@ mp_obj_t mp_obj_new_int(machine_int_t value) { if (MP_OBJ_FITS_SMALL_INT(value)) { return MP_OBJ_NEW_SMALL_INT(value); } - // TODO: Raise exception - assert(0); + nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "small int overflow")); return mp_const_none; } + +machine_int_t mp_obj_int_get(mp_obj_t self_in) { + return MP_OBJ_SMALL_INT_VALUE(self_in); +} + +machine_int_t mp_obj_int_get_checked(mp_obj_t self_in) { + return MP_OBJ_SMALL_INT_VALUE(self_in); +} + #endif |