Python: CG trace: Handle LOAD_DEREF

This commit is contained in:
Rasmus Wriedt Larsen
2020-07-21 22:02:25 +02:00
parent 61b1d3eef3
commit 3752a25665
2 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
def func(func_arg):
print("func")
def func2():
print("func2")
return func_arg()
func2()
def nop():
print("nop")
pass
func(nop)
"""
Needs handling of LOAD_DEREF. Disassembled bytecode looks like:
6 8 LOAD_DEREF 0 (func_arg)
10 CALL_FUNCTION 0
12 RETURN_VALUE
"""

View File

@@ -143,7 +143,7 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
LOGGER.debug(f"expr_from_instruction: {inst} {index=}")
if inst.opname in ["LOAD_GLOBAL", "LOAD_FAST", "LOAD_NAME"]:
if inst.opname in ["LOAD_GLOBAL", "LOAD_FAST", "LOAD_NAME", "LOAD_DEREF"]:
return BytecodeVariableName(inst.argval)
elif inst.opname in ["LOAD_CONST"]: