You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Instruction formatting - yet again
This commit is contained in:
2
pytest/testdata/if-2.7.right
vendored
2
pytest/testdata/if-2.7.right
vendored
@@ -9,4 +9,4 @@
|
|||||||
12 JUMP_FORWARD 0 'to 15'
|
12 JUMP_FORWARD 0 'to 15'
|
||||||
15_0 COME_FROM '12'
|
15_0 COME_FROM '12'
|
||||||
15 LOAD_CONST 0 ''
|
15 LOAD_CONST 0 ''
|
||||||
18 RETURN_VALUE ''
|
18 RETURN_VALUE
|
||||||
|
2
pytest/testdata/ifelse-2.7.right
vendored
2
pytest/testdata/ifelse-2.7.right
vendored
@@ -12,4 +12,4 @@
|
|||||||
18 STORE_NAME 2 'd'
|
18 STORE_NAME 2 'd'
|
||||||
21_0 COME_FROM '12'
|
21_0 COME_FROM '12'
|
||||||
21 LOAD_CONST 2 ''
|
21 LOAD_CONST 2 ''
|
||||||
24 RETURN_VALUE ''
|
24 RETURN_VALUE
|
||||||
|
@@ -52,6 +52,8 @@ class Token:
|
|||||||
def format(self):
|
def format(self):
|
||||||
prefix = '\n%4d ' % self.linestart if self.linestart else (' ' * 6)
|
prefix = '\n%4d ' % self.linestart if self.linestart else (' ' * 6)
|
||||||
offset_opname = '%6s %-17s' % (self.offset, self.type)
|
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)
|
argstr = "%6d " % self.attr if isinstance(self.attr, int) else (' '*7)
|
||||||
if self.pattr:
|
if self.pattr:
|
||||||
pattr = self.pattr
|
pattr = self.pattr
|
||||||
@@ -63,7 +65,9 @@ class Token:
|
|||||||
if not self.pattr.startswith('to '):
|
if not self.pattr.startswith('to '):
|
||||||
pattr = "to " + str(self.pattr)
|
pattr = "to " + str(self.pattr)
|
||||||
pass
|
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
|
pass
|
||||||
else:
|
else:
|
||||||
pattr = ''
|
pattr = ''
|
||||||
|
Reference in New Issue
Block a user