README.rst: note addition of pydisassemble

Remove duplicate disassembly printing from scanners and
put common code in caller(s). Show source-code line numbers in disassembly output
and fix alignment of byte offsets.
disas.py: workaround Python 2/3 different layouts before we get to
bytecodes in a code object.
This commit is contained in:
rocky
2015-12-15 01:42:07 -05:00
parent 5e5da104c5
commit 34ecd54e2c
11 changed files with 131 additions and 98 deletions

View File

@@ -38,11 +38,11 @@ def disassemble_code(version, co, out=None):
assert isinstance(co, types.CodeType)
# store final output stream for case of error
__real_out = out or sys.stdout
print('# Python %s' % version, file=__real_out)
real_out = out or sys.stdout
print('# Python %s' % version, file=real_out)
if co.co_filename:
print('# Embedded file name: %s' % co.co_filename,
file=__real_out)
file=real_out)
# Pick up appropriate scanner
if version == 2.7:
@@ -63,6 +63,11 @@ def disassemble_code(version, co, out=None):
scanner.setShowAsm(True, out)
tokens, customize = scanner.disassemble(co)
for t in tokens:
print(t, file=real_out)
print(file=out)
def disassemble_file(filename, outstream=None, showasm=False, showast=False):
"""