From 82d85dd2e2c923619ae9d940dcbdb09b57325b08 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 30 Jun 2024 20:58:05 -0400 Subject: [PATCH] Handle STORE_DEREF formatting like any other store --- xdis/opcodes/format/extended.py | 3 ++- xdis/opcodes/opcode_310graal.py | 1 + xdis/opcodes/opcode_311.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xdis/opcodes/format/extended.py b/xdis/opcodes/format/extended.py index 4fd6deae..693c1a8b 100644 --- a/xdis/opcodes/format/extended.py +++ b/xdis/opcodes/format/extended.py @@ -149,7 +149,7 @@ def extended_format_store_op(opc, instructions: list) -> Tuple[str, Optional[int argval = get_instruction_arg(prev_inst, argval) start_offset = prev_inst.start_offset if prev_inst.opname.startswith("INPLACE_"): - # Inplace operators show their own assign + # Inplace operators have their own assign routine. return argval, start_offset return f"{inst.argval} = {argval}", start_offset @@ -753,6 +753,7 @@ def skip_cache(instructions: list, i: int) -> int: "RAISE_VARARGS": extended_format_RAISE_VARARGS_older, "RETURN_VALUE": extended_format_RETURN_VALUE, "STORE_ATTR": extended_format_ATTR, + "STORE_DEREF": extended_format_store_op, "STORE_FAST": extended_format_store_op, "STORE_GLOBAL": extended_format_store_op, "STORE_NAME": extended_format_store_op, diff --git a/xdis/opcodes/opcode_310graal.py b/xdis/opcodes/opcode_310graal.py index 921eab1e..cae38357 100644 --- a/xdis/opcodes/opcode_310graal.py +++ b/xdis/opcodes/opcode_310graal.py @@ -201,6 +201,7 @@ def def_graal_op( # cellvars or freevars array ({@code co_cellvars}, {@code # co_freevars}). # Pops: value to be written into the cell contents +# FIXME: this should be tagged as both a "free" and as "store" op. def_graal_op(opc, "STORE_DEREF", 34, 1, 1, 0) # Deletes a local cell variable determined by the immediate operand diff --git a/xdis/opcodes/opcode_311.py b/xdis/opcodes/opcode_311.py index e0a6e7b3..e4d86413 100644 --- a/xdis/opcodes/opcode_311.py +++ b/xdis/opcodes/opcode_311.py @@ -31,6 +31,7 @@ init_opdata, jrel_op, rm_op, + store_op, update_pj3, ) from xdis.opcodes.format.extended import extended_format_binary_op @@ -160,7 +161,7 @@ def_op(loc, "GET_AWAITABLE", 131, 0, 0) def_op(loc, "LOAD_CLOSURE", 136, 0, 1) def_op(loc, "LOAD_DEREF", 137, 0, 1) -def_op(loc, "STORE_DEREF", 138, 1, 0) +store_op(loc, "STORE_DEREF", 138, 1, 0, is_type="free") def_op(loc, "DELETE_DEREF", 139, 0, 0) # These are added since 3.10...