MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_instructions

Function get_instructions

Lib/dis.py:652–680  ·  view source on GitHub ↗

Iterator for the opcodes in methods, functions or code Generates a series of Instruction named tuples giving the details of each operations in the supplied code. If *first_line* is not None, it indicates the line number that should be reported for the first source line in the disas

(x, *, first_line=None, show_caches=None, adaptive=False)

Source from the content-addressed store, hash-verified

650 return argval, argrepr
651
652def get_instructions(x, *, first_line=None, show_caches=None, adaptive=False):
653 """Iterator for the opcodes in methods, functions or code
654
655 Generates a series of Instruction named tuples giving the details of
656 each operations in the supplied code.
657
658 If *first_line* is not None, it indicates the line number that should
659 be reported for the first source line in the disassembled code.
660 Otherwise, the source line information (if any) is taken directly from
661 the disassembled code object.
662 """
663 co = _get_code_object(x)
664 linestarts = dict(findlinestarts(co))
665 if first_line is not None:
666 line_offset = first_line - co.co_firstlineno
667 else:
668 line_offset = 0
669
670 original_code = co.co_code
671 arg_resolver = ArgResolver(co_consts=co.co_consts,
672 names=co.co_names,
673 varname_from_oparg=co._varname_from_oparg,
674 labels_map=_make_labels_map(original_code))
675 return _get_instructions_bytes(_get_code_array(co, adaptive),
676 linestarts=linestarts,
677 line_offset=line_offset,
678 co_positions=co.co_positions(),
679 original_code=original_code,
680 arg_resolver=arg_resolver)
681
682def _get_const_value(op, arg, co_consts):
683 """Helper to get the value of the const in a hasconst op.

Callers

nothing calls this directly

Calls 7

_get_code_objectFunction · 0.85
findlinestartsFunction · 0.85
ArgResolverClass · 0.85
_make_labels_mapFunction · 0.85
_get_instructions_bytesFunction · 0.85
_get_code_arrayFunction · 0.85
co_positionsMethod · 0.80

Tested by

no test coverage detected