Add debug option on Python 3 find_jump_targets()

This commit is contained in:
rocky
2016-11-20 03:21:03 -05:00
parent 94719918d4
commit 0f56b4f476

View File

@@ -199,7 +199,7 @@ class Scanner3(Scanner):
# Get jump targets # Get jump targets
# Format: {target offset: [jump offsets]} # Format: {target offset: [jump offsets]}
jump_targets = self.find_jump_targets() jump_targets = self.find_jump_targets(show_asm)
for inst in bytecode: for inst in bytecode:
@@ -401,7 +401,7 @@ class Scanner3(Scanner):
for _ in range(self.op_size(op)): for _ in range(self.op_size(op)):
self.prev_op.append(offset) self.prev_op.append(offset)
def find_jump_targets(self): def find_jump_targets(self, debug):
""" """
Detect all offsets in a byte code which are jump targets Detect all offsets in a byte code which are jump targets
where we might insert a COME_FROM instruction. where we might insert a COME_FROM instruction.
@@ -457,6 +457,13 @@ class Scanner3(Scanner):
elif op == self.opc.END_FINALLY and offset in self.fixed_jumps: elif op == self.opc.END_FINALLY and offset in self.fixed_jumps:
label = self.fixed_jumps[offset] label = self.fixed_jumps[offset]
targets[label] = targets.get(label, []) + [offset] targets[label] = targets.get(label, []) + [offset]
pass
pass
# DEBUG:
if debug in ('both', 'after'):
import pprint as pp
pp.pprint(self.structs)
return targets return targets
def build_statement_indices(self): def build_statement_indices(self):