diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-12 15:38:15 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-12 15:38:15 +0000 |
commit | 9d68e9ccdd4d7f4ecb7a8765ca694e355753d686 (patch) | |
tree | 73926072f5555829e31dfb1a1b72abe259bacd03 /py/objint.c | |
parent | bb4a43f35ccb128aeb42e483d9937764353de49e (diff) |
py: Implement integer overflow checking for * and << ops.
If operation will overflow, a multi-precision integer is created.
Diffstat (limited to 'py/objint.c')
-rw-r--r-- | py/objint.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/objint.c b/py/objint.c index 490b4340b..7a9b0366d 100644 --- a/py/objint.c +++ b/py/objint.c @@ -71,6 +71,12 @@ mp_obj_t mp_obj_new_int_from_long_str(const char *s) { return mp_const_none; } +// This is called when an integer larger than a SMALL_INT is needed (although val might still fit in a SMALL_INT) +mp_obj_t mp_obj_new_int_from_ll(long long val) { + nlr_jump(mp_obj_new_exception_msg(&mp_type_OverflowError, "small int overflow")); + return mp_const_none; +} + mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value) { // SMALL_INT accepts only signed numbers, of one bit less size // then word size, which totals 2 bits less for unsigned numbers. |