Double -a option show asm before tokenization

This commit is contained in:
rocky
2023-07-04 07:13:54 -04:00
parent 99f054ea9d
commit 227f494fa8
5 changed files with 50 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2015-2020, 2022 by Rocky Bernstein
# Copyright (c) 2015-2020, 2022-2023 by Rocky Bernstein
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
#
@@ -219,10 +219,17 @@ class Scanner37Base(Scanner):
bytecode = self.build_instructions(co)
# show_asm = 'both'
if show_asm in ("both", "before"):
for instr in bytecode.get_instructions(co):
print(instr.disassemble(self.opc))
print("\n# ---- before tokenization:")
bytecode.disassemble_bytes(
co.co_code,
varnames=co.co_varnames,
names=co.co_names,
constants=co.co_consts,
cells=bytecode._cell_names,
linestarts=bytecode._linestarts,
asm_format="extended",
)
# "customize" is in the process of going away here
customize = {}
@@ -525,6 +532,7 @@ class Scanner37Base(Scanner):
pass
if show_asm in ("both", "after"):
print("\n# ---- after tokenization:")
for t in tokens:
print(t.format(line_prefix=""))
print()