Skip to content

Commit 1ee1785

Browse files
committed
showbc: Print operation mnemonic in BINARY_OP.
1 parent df10346 commit 1ee1785

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

py/objtype.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) {
362362
}
363363
}
364364

365-
STATIC const qstr binary_op_method_name[] = {
365+
const qstr mp_binary_op_method_name[] = {
366366
/*
367367
MP_BINARY_OP_OR,
368368
MP_BINARY_OP_XOR,
@@ -435,7 +435,7 @@ STATIC mp_obj_t instance_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_i
435435
// Note: For ducktyping, CPython does not look in the instance members or use
436436
// __getattr__ or __getattribute__. It only looks in the class dictionary.
437437
mp_obj_instance_t *lhs = lhs_in;
438-
qstr op_name = binary_op_method_name[op];
438+
qstr op_name = mp_binary_op_method_name[op];
439439
/* Still try to lookup native slot
440440
if (op_name == 0) {
441441
return MP_OBJ_NULL;

py/showbc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "runtime.h"
3535
#include "bc0.h"
3636
#include "bc.h"
37+
extern const qstr mp_binary_op_method_name[];
3738

3839
#if MICROPY_DEBUG_PRINTERS
3940

@@ -509,7 +510,8 @@ const byte *mp_bytecode_print_str(const byte *ip) {
509510
} else if (ip[-1] < MP_BC_UNARY_OP_MULTI + 5) {
510511
printf("UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI);
511512
} else if (ip[-1] < MP_BC_BINARY_OP_MULTI + 35) {
512-
printf("BINARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_BINARY_OP_MULTI);
513+
mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI;
514+
printf("BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op]));
513515
} else {
514516
printf("code %p, byte code 0x%02x not implemented\n", ip, ip[-1]);
515517
assert(0);

0 commit comments

Comments
 (0)