|
18 | 18 |
|
19 | 19 |
|
20 | 20 | # Get all the opcodes into globals |
21 | | -globals().update(dis.opmap) |
22 | | -from uncompyle6.opcodes.opcode_33 import * |
| 21 | +import uncompyle6.opcodes.opcode_33 as op3 |
| 22 | +globals().update(op3.opmap) |
| 23 | + |
| 24 | + |
23 | 25 | import uncompyle6.scanner as scan |
24 | 26 |
|
25 | 27 | class Code3: |
@@ -122,23 +124,23 @@ def unmangle(name): |
122 | 124 | jump_idx = 0 |
123 | 125 | for jump_offset in jump_targets[offset]: |
124 | 126 | tokens.append(Token('COME_FROM', None, repr(jump_offset), |
125 | | - offset='{}_{}'.format(offset, jump_idx))) |
| 127 | + offset='%s_%s' % (offset, jump_idx))) |
126 | 128 | jump_idx += 1 |
127 | 129 | pass |
128 | 130 | pass |
129 | 131 |
|
130 | 132 | op = code[offset] |
131 | | - op_name = opname[op] |
| 133 | + op_name = op3.opname[op] |
132 | 134 |
|
133 | 135 | oparg = None; pattr = None |
134 | 136 |
|
135 | | - if op >= HAVE_ARGUMENT: |
| 137 | + if op >= op3.HAVE_ARGUMENT: |
136 | 138 | oparg = self.get_argument(offset) + extended_arg |
137 | 139 | extended_arg = 0 |
138 | | - if op == EXTENDED_ARG: |
| 140 | + if op == op3.EXTENDED_ARG: |
139 | 141 | extended_arg = oparg * scan.L65536 |
140 | 142 | continue |
141 | | - if op in hasconst: |
| 143 | + if op in op3.hasconst: |
142 | 144 | const = co.co_consts[oparg] |
143 | 145 | if not PYTHON3 and isinstance(const, str): |
144 | 146 | if const in code_objects: |
@@ -168,17 +170,17 @@ def unmangle(name): |
168 | 170 | pattr = '<code_object ' + const.co_name + '>' |
169 | 171 | else: |
170 | 172 | pattr = const |
171 | | - elif op in hasname: |
| 173 | + elif op in op3.hasname: |
172 | 174 | pattr = names[oparg] |
173 | | - elif op in hasjrel: |
| 175 | + elif op in op3.hasjrel: |
174 | 176 | pattr = repr(offset + 3 + oparg) |
175 | | - elif op in hasjabs: |
| 177 | + elif op in op3.hasjabs: |
176 | 178 | pattr = repr(oparg) |
177 | | - elif op in haslocal: |
| 179 | + elif op in op3.haslocal: |
178 | 180 | pattr = varnames[oparg] |
179 | | - elif op in hascompare: |
180 | | - pattr = cmp_op[oparg] |
181 | | - elif op in hasfree: |
| 181 | + elif op in op3.hascompare: |
| 182 | + pattr = op3.cmp_op[oparg] |
| 183 | + elif op in op3.hasfree: |
182 | 184 | pattr = free[oparg] |
183 | 185 |
|
184 | 186 | if op in (BUILD_LIST, BUILD_TUPLE, BUILD_SET, BUILD_SLICE, |
@@ -338,23 +340,23 @@ def build_statement_indices(self): |
338 | 340 | start = 0 |
339 | 341 | end = codelen = len(code) |
340 | 342 |
|
341 | | - statement_opcodes = { |
| 343 | + statement_opcodes = set([ |
342 | 344 | SETUP_LOOP, BREAK_LOOP, CONTINUE_LOOP, |
343 | 345 | SETUP_FINALLY, END_FINALLY, SETUP_EXCEPT, SETUP_WITH, |
344 | 346 | POP_BLOCK, STORE_FAST, DELETE_FAST, STORE_DEREF, |
345 | 347 | STORE_GLOBAL, DELETE_GLOBAL, STORE_NAME, DELETE_NAME, |
346 | 348 | STORE_ATTR, DELETE_ATTR, STORE_SUBSCR, DELETE_SUBSCR, |
347 | 349 | RETURN_VALUE, RAISE_VARARGS, POP_TOP, PRINT_EXPR, |
348 | 350 | JUMP_ABSOLUTE |
349 | | - } |
| 351 | + ]) |
350 | 352 |
|
351 | 353 | statement_opcode_sequences = [(POP_JUMP_IF_FALSE, JUMP_FORWARD), (POP_JUMP_IF_FALSE, JUMP_ABSOLUTE), |
352 | 354 | (POP_JUMP_IF_TRUE, JUMP_FORWARD), (POP_JUMP_IF_TRUE, JUMP_ABSOLUTE)] |
353 | 355 |
|
354 | | - designator_ops = { |
| 356 | + designator_ops = set([ |
355 | 357 | STORE_FAST, STORE_NAME, STORE_GLOBAL, STORE_DEREF, STORE_ATTR, |
356 | 358 | STORE_SUBSCR, UNPACK_SEQUENCE, JUMP_ABSOLUTE |
357 | | - } |
| 359 | + ]) |
358 | 360 |
|
359 | 361 | # Compose preliminary list of indices with statements, |
360 | 362 | # using plain statement opcodes |
|
0 commit comments