py: Fix casting and printing of small int.
This commit is contained in:
parent
b25ef4db3b
commit
0379b55ab0
@ -47,7 +47,7 @@ STATIC mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
|
|||||||
|
|
||||||
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||||
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
||||||
print(env, "%d", (int)MP_OBJ_SMALL_INT_VALUE(self_in));
|
print(env, INT_FMT, MP_OBJ_SMALL_INT_VALUE(self_in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
void int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||||
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
if (MP_OBJ_IS_SMALL_INT(self_in)) {
|
||||||
print(env, "%d", (int)MP_OBJ_SMALL_INT_VALUE(self_in));
|
print(env, INT_FMT, MP_OBJ_SMALL_INT_VALUE(self_in));
|
||||||
} else {
|
} else {
|
||||||
mp_obj_int_t *self = self_in;
|
mp_obj_int_t *self = self_in;
|
||||||
print(env, "%lld" SUFFIX, self->val);
|
print(env, "%lld" SUFFIX, self->val);
|
||||||
|
@ -68,7 +68,7 @@ void mp_byte_code_print(const byte *ip, int len) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_BC_LOAD_CONST_SMALL_INT: {
|
case MP_BC_LOAD_CONST_SMALL_INT: {
|
||||||
int num = 0;
|
machine_int_t num = 0;
|
||||||
if ((ip[0] & 0x40) != 0) {
|
if ((ip[0] & 0x40) != 0) {
|
||||||
// Number is negative
|
// Number is negative
|
||||||
num--;
|
num--;
|
||||||
@ -76,7 +76,7 @@ void mp_byte_code_print(const byte *ip, int len) {
|
|||||||
do {
|
do {
|
||||||
num = (num << 7) | (*ip & 0x7f);
|
num = (num << 7) | (*ip & 0x7f);
|
||||||
} while ((*ip++ & 0x80) != 0);
|
} while ((*ip++ & 0x80) != 0);
|
||||||
printf("LOAD_CONST_SMALL_INT %d", num);
|
printf("LOAD_CONST_SMALL_INT " INT_FMT, num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user