@@ -54,6 +54,19 @@ def __str__(self):
5454 return f"{ self .object } [{ self .key } ]"
5555
5656
57+ @dataclasses .dataclass (frozen = True , eq = True , order = True )
58+ class BytecodeTuple (BytecodeExpr ):
59+ elements : List [BytecodeExpr ]
60+
61+ def __str__ (self ):
62+ elements_formatted = (
63+ ", " .join (str (e ) for e in self .elements )
64+ if len (self .elements ) > 1
65+ else f"{ self .elements [0 ]} ,"
66+ )
67+ return f"({ elements_formatted } )"
68+
69+
5770@dataclasses .dataclass (frozen = True , eq = True , order = True )
5871class BytecodeCall (BytecodeExpr ):
5972 function : BytecodeExpr
@@ -161,6 +174,14 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
161174 obj_expr = expr_that_added_elem_to_stack (instructions , index - 1 , 1 )
162175 return BytecodeSubscript (key = key_expr , object = obj_expr )
163176
177+ elif inst .opname in ["BUILD_TUPLE" ]:
178+ elements = []
179+ for i in range (inst .arg ):
180+ element_expr = expr_that_added_elem_to_stack (instructions , index - 1 , i )
181+ elements .append (element_expr )
182+ elements .reverse ()
183+ return BytecodeTuple (elements = elements )
184+
164185 # https://docs.python.org/3/library/dis.html#opcode-CALL_FUNCTION
165186 elif inst .opname in [
166187 "CALL_FUNCTION" ,
0 commit comments