Details for a bytecode operation Defined fields: opname - human readable name for operation opcode - numeric code for operation arg - numeric argument to operation (if any), otherwise None argval - resolved arg value (if known), otherwise same as arg
| 274 | _OPARG_WIDTH = 5 |
| 275 | |
| 276 | class Instruction(_Instruction): |
| 277 | """Details for a bytecode operation |
| 278 | |
| 279 | Defined fields: |
| 280 | opname - human readable name for operation |
| 281 | opcode - numeric code for operation |
| 282 | arg - numeric argument to operation (if any), otherwise None |
| 283 | argval - resolved arg value (if known), otherwise same as arg |
| 284 | argrepr - human readable description of operation argument |
| 285 | offset - start index of operation within bytecode sequence |
| 286 | starts_line - line started by this opcode (if any), otherwise None |
| 287 | is_jump_target - True if other code jumps to here, otherwise False |
| 288 | positions - Optional dis.Positions object holding the span of source code |
| 289 | covered by this instruction |
| 290 | """ |
| 291 | |
| 292 | def _disassemble(self, lineno_width=3, mark_as_current=False, offset_width=4): |
| 293 | """Format instruction details for inclusion in disassembly output |
| 294 | |
| 295 | *lineno_width* sets the width of the line number field (0 omits it) |
| 296 | *mark_as_current* inserts a '-->' marker arrow as part of the line |
| 297 | *offset_width* sets the width of the instruction offset field |
| 298 | """ |
| 299 | fields = [] |
| 300 | # Column: Source code line number |
| 301 | if lineno_width: |
| 302 | if self.starts_line is not None: |
| 303 | lineno_fmt = "%%%dd" % lineno_width |
| 304 | fields.append(lineno_fmt % self.starts_line) |
| 305 | else: |
| 306 | fields.append(' ' * lineno_width) |
| 307 | # Column: Current instruction indicator |
| 308 | if mark_as_current: |
| 309 | fields.append('-->') |
| 310 | else: |
| 311 | fields.append(' ') |
| 312 | # Column: Jump target marker |
| 313 | if self.is_jump_target: |
| 314 | fields.append('>>') |
| 315 | else: |
| 316 | fields.append(' ') |
| 317 | # Column: Instruction offset from start of code sequence |
| 318 | fields.append(repr(self.offset).rjust(offset_width)) |
| 319 | # Column: Opcode name |
| 320 | fields.append(self.opname.ljust(_OPNAME_WIDTH)) |
| 321 | # Column: Opcode argument |
| 322 | if self.arg is not None: |
| 323 | fields.append(repr(self.arg).rjust(_OPARG_WIDTH)) |
| 324 | # Column: Opcode argument details |
| 325 | if self.argrepr: |
| 326 | fields.append('(' + self.argrepr + ')') |
| 327 | return ' '.join(fields).rstrip() |
| 328 | |
| 329 | |
| 330 | def get_instructions(x, *, first_line=None, show_caches=False, adaptive=False): |
no outgoing calls
no test coverage detected