mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
@@ -198,7 +198,7 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
case MP_BINARY_OP_RSHIFT:
|
||||
case MP_BINARY_OP_INPLACE_RSHIFT: {
|
||||
// TODO check conversion overflow
|
||||
machine_int_t irhs = mpz_as_int(zrhs);
|
||||
mp_int_t irhs = mpz_as_int(zrhs);
|
||||
if (irhs < 0) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "negative shift count"));
|
||||
}
|
||||
@@ -241,7 +241,7 @@ mp_obj_t mp_obj_int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_new_int(machine_int_t value) {
|
||||
mp_obj_t mp_obj_new_int(mp_int_t value) {
|
||||
if (MP_SMALL_INT_FITS(value)) {
|
||||
return MP_OBJ_NEW_SMALL_INT(value);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) {
|
||||
return o;
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value) {
|
||||
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) {
|
||||
// SMALL_INT accepts only signed numbers, of one bit less size
|
||||
// than word size, which totals 2 bits less for unsigned numbers.
|
||||
if ((value & (WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1))) == 0) {
|
||||
@@ -270,7 +270,7 @@ mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint
|
||||
return o;
|
||||
}
|
||||
|
||||
machine_int_t mp_obj_int_get(mp_const_obj_t self_in) {
|
||||
mp_int_t mp_obj_int_get(mp_const_obj_t self_in) {
|
||||
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
||||
return MP_OBJ_SMALL_INT_VALUE(self_in);
|
||||
} else {
|
||||
@@ -279,12 +279,12 @@ machine_int_t mp_obj_int_get(mp_const_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
machine_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) {
|
||||
mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in) {
|
||||
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
||||
return MP_OBJ_SMALL_INT_VALUE(self_in);
|
||||
} else {
|
||||
const mp_obj_int_t *self = self_in;
|
||||
machine_int_t value;
|
||||
mp_int_t value;
|
||||
if (mpz_as_int_checked(&self->mpz, &value)) {
|
||||
return value;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user