Instruction formatting - yet again

This commit is contained in:
rocky
2016-07-25 23:09:34 -04:00
parent f0a8505887
commit 9f0b0809b1
3 changed files with 7 additions and 3 deletions

View File

@@ -9,4 +9,4 @@
12 JUMP_FORWARD 0 'to 15'
15_0 COME_FROM '12'
15 LOAD_CONST 0 ''
18 RETURN_VALUE ''
18 RETURN_VALUE

View File

@@ -12,4 +12,4 @@
18 STORE_NAME 2 'd'
21_0 COME_FROM '12'
21 LOAD_CONST 2 ''
24 RETURN_VALUE ''
24 RETURN_VALUE

View File

@@ -52,6 +52,8 @@ class Token:
def format(self):
prefix = '\n%4d ' % self.linestart if self.linestart else (' ' * 6)
offset_opname = '%6s %-17s' % (self.offset, self.type)
if not self.has_arg:
return "%s%s" % (prefix, offset_opname)
argstr = "%6d " % self.attr if isinstance(self.attr, int) else (' '*7)
if self.pattr:
pattr = self.pattr
@@ -63,7 +65,9 @@ class Token:
if not self.pattr.startswith('to '):
pattr = "to " + str(self.pattr)
pass
# And so on. See xdis/bytecode.py
elif self.op in self.opc.hascompare:
pattr = self.opc.cmp_op[self.attr]
# And so on. See xdis/bytecode.py get_instructions_bytes
pass
else:
pattr = ''