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

Function _get_instructions_bytes

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

Iterate over the instructions in a bytecode string. Generates a sequence of Instruction namedtuples giving the details of each opcode. Additional information about the code's runtime environment (e.g. variable names, co_consts) can be specified using optional arguments.

(code, varname_from_oparg=None,
                            names=None, co_consts=None,
                            linestarts=None, line_offset=0,
                            exception_entries=(), co_positions=None,
                            show_caches=False)

Source from the content-addressed store, hash-verified

421 return 'JUMP_BACKWARD' in opname[op]
422
423def _get_instructions_bytes(code, varname_from_oparg=None,
424 names=None, co_consts=None,
425 linestarts=None, line_offset=0,
426 exception_entries=(), co_positions=None,
427 show_caches=False):
428 """Iterate over the instructions in a bytecode string.
429
430 Generates a sequence of Instruction namedtuples giving the details of each
431 opcode. Additional information about the code's runtime environment
432 (e.g. variable names, co_consts) can be specified using optional
433 arguments.
434
435 """
436 co_positions = co_positions or iter(())
437 get_name = None if names is None else names.__getitem__
438 labels = set(findlabels(code))
439 for start, end, target, _, _ in exception_entries:
440 for i in range(start, end):
441 labels.add(target)
442 starts_line = None
443 for offset, op, arg in _unpack_opargs(code):
444 if linestarts is not None:
445 starts_line = linestarts.get(offset, None)
446 if starts_line is not None:
447 starts_line += line_offset
448 is_jump_target = offset in labels
449 argval = None
450 argrepr = ''
451 positions = Positions(*next(co_positions, ()))
452 deop = _deoptop(op)
453 if arg is not None:
454 # Set argval to the dereferenced value of the argument when
455 # available, and argrepr to the string representation of argval.
456 # _disassemble_bytes needs the string repr of the
457 # raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
458 argval = arg
459 if deop in hasconst:
460 argval, argrepr = _get_const_info(deop, arg, co_consts)
461 elif deop in hasname:
462 if deop == LOAD_GLOBAL:
463 argval, argrepr = _get_name_info(arg//2, get_name)
464 if (arg & 1) and argrepr:
465 argrepr = "NULL + " + argrepr
466 else:
467 argval, argrepr = _get_name_info(arg, get_name)
468 elif deop in hasjabs:
469 argval = arg*2
470 argrepr = "to " + repr(argval)
471 elif deop in hasjrel:
472 signed_arg = -arg if _is_backward_jump(deop) else arg
473 argval = offset + 2 + signed_arg*2
474 argrepr = "to " + repr(argval)
475 elif deop in haslocal or deop in hasfree:
476 argval, argrepr = _get_name_info(arg, varname_from_oparg)
477 elif deop in hascompare:
478 argval = cmp_op[arg]
479 argrepr = argval
480 elif deop == FORMAT_VALUE:

Callers 3

get_instructionsFunction · 0.85
_disassemble_bytesFunction · 0.85
__iter__Method · 0.85

Calls 14

findlabelsFunction · 0.85
_unpack_opargsFunction · 0.85
_deoptopFunction · 0.85
_get_const_infoFunction · 0.85
_get_name_infoFunction · 0.85
_is_backward_jumpFunction · 0.85
enumerateFunction · 0.85
InstructionClass · 0.85
from_bytesMethod · 0.80
setFunction · 0.50
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected