DRY scanner code more...

Expand 2.6 testing
This commit is contained in:
rocky
2018-04-03 10:35:02 -04:00
parent e2dec73a62
commit 1cd2d1e915
9 changed files with 39 additions and 52 deletions

View File

@@ -105,6 +105,11 @@ class Scanner(object):
bytecode = Bytecode(co, self.opc)
self.build_prev_op()
self.insts = self.remove_extended_args(list(bytecode))
self.lines = self.build_lines_data(co)
self.offset2inst_index = {}
for i, inst in enumerate(self.insts):
self.offset2inst_index[inst.offset] = i
return bytecode
def build_lines_data(self, code_obj):
@@ -117,10 +122,6 @@ class Scanner(object):
linestarts = list(self.opc.findlinestarts(code_obj))
self.linestarts = dict(linestarts)
# Plain set with offsets of first ops on line.
# FIXME: we probably could do without
self.linestart_offsets = set(a for (a, _) in linestarts)
# 'List-map' which shows line number of current op and offset of
# first op on following line, given offset of op as index
lines = []
@@ -452,6 +453,9 @@ class Scanner(object):
Go through passed offsets, filtering ifs
located somewhere mid-line.
"""
# FIXME: this doesn't work for Python 3.6+
filtered = []
for i in ifs:
# For each offset, if line number of current and next op