You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Nicer assembly display...
Fewer extraneous quotes and remove pattrs that don't mean anything. Base more on OP poperties like varargs and NAME_OPS
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016-2018 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2019 by Rocky Bernstein
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
# Copyright (c) 1999 John Aycock
|
||||
#
|
||||
@@ -90,11 +90,11 @@ class Token():
|
||||
if not self.has_arg:
|
||||
return "%s%s" % (prefix, offset_opname)
|
||||
argstr = "%6d " % self.attr if isinstance(self.attr, int) else (' '*7)
|
||||
name = self.kind
|
||||
|
||||
if self.has_arg:
|
||||
pattr = self.pattr
|
||||
if self.opc:
|
||||
name = self.kind
|
||||
opname_base = name[:name.find('_')]
|
||||
if self.op in self.opc.JREL_OPS:
|
||||
if not self.pattr.startswith('to '):
|
||||
pattr = "to " + self.pattr
|
||||
@@ -106,14 +106,22 @@ class Token():
|
||||
elif self.op in self.opc.CONST_OPS:
|
||||
if name == 'LOAD_STR':
|
||||
pattr = self.attr
|
||||
elif self.attr is None:
|
||||
pattr = None
|
||||
elif name == 'LOAD_CODE':
|
||||
return "%s%s%s %s" % (prefix, offset_opname, argstr, pattr)
|
||||
else:
|
||||
return "%s%s %r" % (prefix, offset_opname, pattr)
|
||||
|
||||
elif self.op in self.opc.hascompare:
|
||||
if isinstance(self.attr, int):
|
||||
pattr = self.opc.cmp_op[self.attr]
|
||||
pass
|
||||
elif opname_base in ('CALL', 'BUILD', 'RAISE'):
|
||||
return "%s%s%s %s" % (prefix, offset_opname, argstr, pattr)
|
||||
elif self.op in self.opc.hasvargs:
|
||||
return "%s%s%s" % (prefix, offset_opname, argstr)
|
||||
elif self.op in self.opc.NAME_OPS:
|
||||
return "%s%s%s %s" % (prefix, offset_opname, argstr, self.attr)
|
||||
elif name == 'EXTENDED_ARG':
|
||||
return "%s%s%s 0x%x << %s = %s" % (prefix, offset_opname, argstr, self.attr,
|
||||
self.opc.EXTENDED_ARG_SHIFT, pattr)
|
||||
# And so on. See xdis/bytecode.py get_instructions_bytes
|
||||
pass
|
||||
elif re.search(r'_\d+$', self.kind):
|
||||
|
Reference in New Issue
Block a user