MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / findlabels

Function findlabels

tools/python-3.11.9-amd64/Lib/dis.py:618–637  ·  view source on GitHub ↗

Detect all offsets in a byte code which are jump targets. Return the list of offsets.

(code)

Source from the content-addressed store, hash-verified

616 yield (i, op, arg)
617
618def findlabels(code):
619 """Detect all offsets in a byte code which are jump targets.
620
621 Return the list of offsets.
622
623 """
624 labels = []
625 for offset, op, arg in _unpack_opargs(code):
626 if arg is not None:
627 if op in hasjrel:
628 if _is_backward_jump(op):
629 arg = -arg
630 label = offset + 2 + arg*2
631 elif op in hasjabs:
632 label = arg*2
633 else:
634 continue
635 if label not in labels:
636 labels.append(label)
637 return labels
638
639def findlinestarts(code):
640 """Find the offsets in a byte code which are start of lines in the source.

Callers 1

_get_instructions_bytesFunction · 0.85

Calls 3

_unpack_opargsFunction · 0.85
_is_backward_jumpFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected