Show binary ops from Python 3.11 in disassembly
This commit is contained in:
11
bytecode.cpp
11
bytecode.cpp
@@ -371,6 +371,12 @@ void bc_disasm(PycRef<PycCode> code, PycModule* mod, int indent, unsigned flags)
|
|||||||
};
|
};
|
||||||
static const size_t cmp_strings_len = sizeof(cmp_strings) / sizeof(cmp_strings[0]);
|
static const size_t cmp_strings_len = sizeof(cmp_strings) / sizeof(cmp_strings[0]);
|
||||||
|
|
||||||
|
static const char *binop_strings[] = {
|
||||||
|
"+", "&", "//", "<<", "@", "*", "%", "|", "**", ">>", "-", "/", "^",
|
||||||
|
"+=", "&=", "//=", "<<=", "@=", "*=", "%=", "|=", "**=", ">>=", "-=", "/=", "^=",
|
||||||
|
};
|
||||||
|
static const size_t binop_strings_len = sizeof(binop_strings) / sizeof(binop_strings[0]);
|
||||||
|
|
||||||
PycBuffer source(code->code()->value(), code->code()->length());
|
PycBuffer source(code->code()->value(), code->code()->length());
|
||||||
|
|
||||||
int opcode, operand;
|
int opcode, operand;
|
||||||
@@ -437,6 +443,11 @@ void bc_disasm(PycRef<PycCode> code, PycModule* mod, int indent, unsigned flags)
|
|||||||
fprintf(pyc_output, "%d (%s)", operand, cmp_strings[operand]);
|
fprintf(pyc_output, "%d (%s)", operand, cmp_strings[operand]);
|
||||||
else
|
else
|
||||||
fprintf(pyc_output, "%d (UNKNOWN)", operand);
|
fprintf(pyc_output, "%d (UNKNOWN)", operand);
|
||||||
|
} else if (opcode == Pyc::BINARY_OP_A) {
|
||||||
|
if (static_cast<size_t>(operand) < binop_strings_len)
|
||||||
|
fprintf(pyc_output, "%d (%s)", operand, binop_strings[operand]);
|
||||||
|
else
|
||||||
|
fprintf(pyc_output, "%d (UNKNOWN)", operand);
|
||||||
} else if (opcode == Pyc::IS_OP_A) {
|
} else if (opcode == Pyc::IS_OP_A) {
|
||||||
fprintf(pyc_output, "%d (%s)", operand, (operand == 0) ? "is"
|
fprintf(pyc_output, "%d (%s)", operand, (operand == 0) ? "is"
|
||||||
: (operand == 1) ? "is not"
|
: (operand == 1) ? "is not"
|
||||||
|
Reference in New Issue
Block a user