Fix up Python 3.2, 3.3, and 3.4 cross-version scanners

Try travis 2.6 and 3.3
This commit is contained in:
rocky
2015-12-26 10:19:26 -05:00
parent e8ee3ac751
commit 008bd79719
30 changed files with 864 additions and 571 deletions

View File

@@ -1,9 +1,4 @@
# Copyright (c) 1999 John Aycock
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2015 by Rocky Bernstein
#
# See main module for license.
"""
Python 3.4 bytecode scanner/deparser
@@ -30,6 +25,7 @@ globals().update(dis.opmap)
from uncompyle6.opcodes.opcode_34 import *
import uncompyle6.scanner as scan
import uncompyle6.scanners.scanner33 as scan33
class Scanner34(scan.Scanner):
@@ -171,9 +167,11 @@ class Scanner34(scan.Scanner):
pass
return tokens, {}
# FIXME Create and move to scanner3
def disassemble_cross_version(self, co, classname=None):
return scan.scanner32().disassemble(self, co, classname)
return scan33.Scanner33().disassemble(co, classname)
# FIXME Create and move to scanner3
def build_lines_data(self, code_obj):
"""
Generate various line-related helper data.
@@ -205,6 +203,7 @@ class Scanner34(scan.Scanner):
lines.append(LineTuple(prev_line_no, codelen))
offset += 1
# FIXME Create and move to scanner3
def build_prev_op(self):
"""
Compose 'list-map' which allows to jump to previous
@@ -218,6 +217,7 @@ class Scanner34(scan.Scanner):
for _ in range(self.op_size(op)):
self.prev_op.append(offset)
# FIXME Create and move to scanner3
def op_size(self, op):
"""
Return size of operator with its arguments
@@ -377,6 +377,7 @@ class Scanner34(scan.Scanner):
# Finish filling the list for last statement
slist += [codelen] * (codelen-len(slist))
# FIXME Create and move to scanner3
def get_target(self, offset):
"""
Get target offset for op located at given <offset>.
@@ -414,6 +415,7 @@ class Scanner34(scan.Scanner):
elif op in (SETUP_EXCEPT, SETUP_WITH, SETUP_FINALLY):
count_SETUP_ += 1
# FIXME Create and move to scanner3
def detect_structure(self, offset):
"""
Detect structures and their boundaries to fix optimizied jumps
@@ -596,12 +598,6 @@ class Scanner34(scan.Scanner):
else:
self.fixed_jumps[offset] = self.restrict_to_parent(target, parent)
def restrict_to_parent(self, target, parent):
"""Restrict target to parent structure boundaries."""
if not (parent['start'] < target < parent['end']):
target = parent['end']
return target
def rem_or(self, start, end, instr, target=None, include_beyond_target=False):
"""
Find offsets of all requested <instr> between <start> and <end>,