1063 "instructions": [], |
1063 "instructions": [], |
1064 } |
1064 } |
1065 |
1065 |
1066 # 1. disassembly info |
1066 # 1. disassembly info |
1067 for instr in dis.get_instructions(co): |
1067 for instr in dis.get_instructions(co): |
1068 instrDict = { |
1068 instrDict = ( |
1069 "lineno": 0 if instr.starts_line is None else instr.starts_line, |
1069 { |
1070 "isJumpTarget": instr.is_jump_target, |
1070 "lineno": 0 if instr.starts_line is None else instr.starts_line, |
1071 "offset": instr.offset, |
1071 "starts_line": instr.starts_line is not None, |
1072 "opname": instr.opname, |
1072 "isJumpTarget": instr.is_jump_target, |
1073 "arg": instr.arg, |
1073 "offset": instr.offset, |
1074 "argrepr": instr.argrepr, |
1074 "opname": instr.opname, |
1075 } |
1075 "arg": instr.arg, |
|
1076 "argrepr": instr.argrepr, |
|
1077 "label": "dummy_label" if instr.is_jump_target else "", |
|
1078 # IDE might be 3.13.0+ |
|
1079 } |
|
1080 if sys.version_info < (3, 13, 0) |
|
1081 else { |
|
1082 "lineno": 0 if instr.line_number is None else instr.line_number, |
|
1083 "starts_line": instr.starts_line, |
|
1084 "isJumpTarget": instr.is_jump_target, |
|
1085 "offset": instr.offset, |
|
1086 "opname": instr.opname, |
|
1087 "arg": instr.arg, |
|
1088 "argrepr": instr.argrepr, |
|
1089 "label": "" if instr.label is None else instr.label, |
|
1090 } |
|
1091 ) |
1076 disDict["instructions"].append(instrDict) |
1092 disDict["instructions"].append(instrDict) |
1077 |
1093 |
1078 # 2. code info |
1094 # 2. code info |
1079 # Note: keep in sync with PythonDisViewer.__createCodeInfo() |
1095 # Note: keep in sync with PythonDisViewer.__createCodeInfo() |
1080 disDict["codeinfo"] = { |
1096 disDict["codeinfo"] = { |