Suppress arg in dissassembly if there is none

This commit is contained in:
rocky
2016-07-16 14:12:31 -04:00
parent cd8cbf9200
commit 942b15e3c6
4 changed files with 36 additions and 14 deletions

View File

@@ -20,8 +20,11 @@ class Token:
# linestart = starts_line
# attr = argval
# pattr = argrepr
def __init__(self, type_, attr=None, pattr=None, offset=-1, linestart=None):
def __init__(self, type_, attr=None, pattr=None, offset=-1,
linestart=None, op=None, has_arg=None):
self.type = intern(type_)
self.op = op
self.has_arg = has_arg
self.attr = attr
self.pattr = pattr
self.offset = offset
@@ -50,7 +53,10 @@ class Token:
offset_opname = '%6s %-17s' % (self.offset, self.type)
argstr = "%6d " % self.attr if isinstance(self.attr, int) else (' '*7)
pattr = self.pattr if self.pattr is not None else ''
return "%s%s%s %r" % (prefix, offset_opname, argstr, pattr)
if self.has_arg:
return "%s%s%s %r" % (prefix, offset_opname, argstr, pattr)
else:
return "%s%s" % (prefix, offset_opname)
def __hash__(self):
return hash(self.type)