You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
show-asm on python2.5 is optional
make scanner2 look a little more like scanner3
This commit is contained in:
@@ -742,7 +742,7 @@ class Scanner2(scan.Scanner):
|
|||||||
else:
|
else:
|
||||||
if (self.version < 2.7
|
if (self.version < 2.7
|
||||||
and parent['type'] in ('root', 'for-loop', 'if-then',
|
and parent['type'] in ('root', 'for-loop', 'if-then',
|
||||||
'if-else', 'try')):
|
'else', 'try')):
|
||||||
self.fixed_jumps[offset] = rtarget
|
self.fixed_jumps[offset] = rtarget
|
||||||
else:
|
else:
|
||||||
# note test for < 2.7 might be superflous although informative
|
# note test for < 2.7 might be superflous although informative
|
||||||
@@ -795,7 +795,20 @@ class Scanner2(scan.Scanner):
|
|||||||
else:
|
else:
|
||||||
rtarget = pre[rtarget]
|
rtarget = pre[rtarget]
|
||||||
|
|
||||||
# Does the "if" jump just beyond a jump op, then this is probably an if statement
|
# Does the "jump if" jump beyond a jump op?
|
||||||
|
# That is, we have something like:
|
||||||
|
# POP_JUMP_IF_FALSE HERE
|
||||||
|
# ...
|
||||||
|
# JUMP_FORWARD
|
||||||
|
# HERE:
|
||||||
|
#
|
||||||
|
# If so, this can be block inside an "if" statement
|
||||||
|
# or a conditional assignment like:
|
||||||
|
# x = 1 if x else 2
|
||||||
|
#
|
||||||
|
# There are other contexts we may need to consider
|
||||||
|
# like whether the target is "END_FINALLY"
|
||||||
|
# or if the condition jump is to a forward location
|
||||||
pre_rtarget = pre[rtarget]
|
pre_rtarget = pre[rtarget]
|
||||||
code_pre_rtarget = code[pre_rtarget]
|
code_pre_rtarget = code[pre_rtarget]
|
||||||
|
|
||||||
@@ -830,7 +843,7 @@ class Scanner2(scan.Scanner):
|
|||||||
self.not_continue.add(pre_rtarget)
|
self.not_continue.add(pre_rtarget)
|
||||||
|
|
||||||
if rtarget < end:
|
if rtarget < end:
|
||||||
self.structs.append({'type': 'if-else',
|
self.structs.append({'type': 'else',
|
||||||
'start': rtarget,
|
'start': rtarget,
|
||||||
'end': end})
|
'end': end})
|
||||||
elif code_pre_rtarget == self.opc.RETURN_VALUE:
|
elif code_pre_rtarget == self.opc.RETURN_VALUE:
|
||||||
|
@@ -18,7 +18,7 @@ JUMP_OPs = opcode_25.JUMP_OPs
|
|||||||
# The history is that 2.7 support is the cleanest,
|
# The history is that 2.7 support is the cleanest,
|
||||||
# then from that we got 2.6 and so on.
|
# then from that we got 2.6 and so on.
|
||||||
class Scanner25(scan.Scanner26):
|
class Scanner25(scan.Scanner26):
|
||||||
def __init__(self, show_asm):
|
def __init__(self, show_asm=False):
|
||||||
# There are no differences in initialization between
|
# There are no differences in initialization between
|
||||||
# 2.5 and 2.6
|
# 2.5 and 2.6
|
||||||
self.opc = opcode_25
|
self.opc = opcode_25
|
||||||
|
Reference in New Issue
Block a user