def init_opdata(l, from_mod, version=None, is_pypy=False):
"""Sets up a number of the structures found in Python's
opcode.py. Python opcode.py routines assign attributes to modules.
In order to do this in a modular way here, the local dictionary
for the module is passed.
"""
if version:
l['python_version'] = version
l['is_pypy'] = is_pypy
l['cmp_op'] = cmp_op
l['HAVE_ARGUMENT'] = HAVE_ARGUMENT
if version <= 3.5:
l['findlinestarts'] = findlinestarts
l['findlabels'] = findlabels
l['get_jump_targets'] = get_jump_targets
l['get_jump_target_maps'] = get_jump_target_maps
else:
l['findlinestarts'] = wordcode.findlinestarts
l['findlabels'] = wordcode.findlabels
l['get_jump_targets'] = wordcode.get_jump_targets
l['get_jump_target_maps'] = wordcode.get_jump_target_maps
l['opmap'] = deepcopy(from_mod.opmap)
l['opname'] = deepcopy(from_mod.opname)
for field in fields2copy:
l[field] = list(getattr(from_mod, field))
评论列表
文章目录