Commit Graph

105 Commits

Author SHA1 Message Date
rocky
9c49b5d54b Handle 3.6 BUILD_CONST_KEYMAP 2017-01-15 11:10:13 -05:00
rocky
707770049f Python 3.0 decompile bugs 2017-01-08 22:19:15 -05:00
rocky
ec0669367f Towards better 3.0 decompilation
Sync scanner2 and scanner3 better
2017-01-08 17:40:57 -05:00
rocky
3f40c16587 Fix 3.5, 3.6 while true if/break bug 2017-01-08 15:54:49 -05:00
rocky
21023fea74 Add 3.5+ async with/for ..
scanner3.py: 3.6 bytecode vs wordcode fix
2017-01-08 08:54:03 -05:00
rocky
e4c0d56947 3.5 continue check is needed on 3.6 2017-01-03 07:22:25 -05:00
rocky
4827b1e994 Towards better 3.6 support 2017-01-03 00:44:07 -05:00
rocky
2b46e71264 Python 3.5 continue detection bug 2017-01-02 10:06:52 -05:00
rocky
84c2932bc5 add come_from for setup_finally and setup_except 2017-01-01 21:11:35 -05:00
rocky
874b3c9d31 Towards fixing Python 3.5 return bugs 2017-01-01 04:56:15 -05:00
rocky
2327f0fdfa Towards fixing a Python 3.3 return/continue bug 2016-12-31 03:56:41 -05:00
rocky
6f097ff1ca dectect_structure() -> detect_control_flow() 2016-12-29 07:32:36 -05:00
rocky
8eb1a16f5b DRY code and emitted Python 3 source
* Python 3: break; continue -> break
* Use variable in detect_structure for pre[rtarget]
* Make Python 2 and Python 3 detect_structure more alie
2016-12-29 07:28:37 -05:00
rocky
ed9fb64e72 More if/then detection in Python 3.x 2016-12-29 03:56:39 -05:00
rocky
e6761e13bb Python flake8 crap
Was testing realgud's C-x!8 (goto flake8 warning/error)
2016-12-18 20:18:19 -05:00
rocky
08dcc7d820 Start to handle 3.5 build_map_unpack_with_call
3.6 also started but needs even more work
2016-12-16 20:39:24 -05:00
rocky
7755563b65 Some Python 3.6 bytecode->wordcode fixes 2016-12-15 02:54:25 -05:00
rocky
38eed14b41 Another python 3 ELSE fixes and ...
Makefile:
  - test python 3.0 bytecode
  - turn full --verify back on Python 3.x
2016-12-10 06:36:22 -05:00
rocky
2c993f8c32 Another faulty Python3 ELSE tag remove 2016-12-10 00:43:55 -05:00
rocky
813bce4697 Merge branch 'master' of github.com:rocky/python-uncompyle6 2016-12-09 21:13:31 -05:00
rocky
a5d2237435 Python 3.x else clause detection and..
- Strengthen verify check.
- weak verification on Python 3.5 for now
2016-12-09 21:10:10 -05:00
rocky
d22931cb49 Get ready for release 2.9.7
Some of the many lint things. Linting is kind of stupid though.
2016-12-04 09:36:30 -05:00
rocky
97576e473d Python 3 while/else bug 2016-11-27 07:06:20 -05:00
rocky
0f56b4f476 Add debug option on Python 3 find_jump_targets() 2016-11-20 03:21:03 -05:00
rocky
f2a3721d7d Start to improve detect_structure for 2.7 and 2.x
Add debug flag to find_jump_targets to show the structure we found.
When there are control-flow bugs, it's often reflected here.

scanner3.py: make code make more similar to 2.x code
2016-11-20 02:38:59 -05:00
rocky
76ae1592d0 verify scanner2 vs scanner3 small changes...
verify.py: allow LOAD_CONST None to make LOAD_NAME 'None'
scanner{2,3}.py: make them look more alike
2016-11-17 03:43:39 -05:00
rocky
80a4ad4f1b Python 3.0 while1 if bug...
Is a workaround. We really need more tagging in of SETUP_LOOP and COME_FROM.
2016-11-13 01:28:36 -05:00
rocky
5d10f7a0b0 Python 3.0 doesn't have POP_JUMP ops...
In some ways Python 3.0 code generation is more like Python 2.6 (and
before) than it is Python 2.7 or 3.0.
2016-11-06 08:55:03 -05:00
rocky
abb61a4d7d Fix some Python 3.1 bugs 2016-10-24 02:16:23 -04:00
rocky
d6f7ef4e17 DRY op_size
Move from scanner{2,3}.py to scanner.py
2016-10-21 07:40:35 -04:00
rocky
346d8678d2 Merge in COME_FROM disambiguation ...
from controlflowbranch. Should probably expand to Python2
parsers as well
2016-10-06 03:27:37 -04:00
rocky
649e4518fe Python 3: "and" doesn't have optional come_from 2016-10-05 03:34:29 -04:00
rocky
fe46015b78 PY3 COME_FROM_LOOP bug
There are still more in sre...
2016-09-27 04:59:06 -04:00
rocky
051efb80f5 PY3: COME_FROM -> COME_FROM_FINALLY as appropriate
We now have all WITH_ op jumps associated in the grammar

Also, some COME_FROM_LOOP grammar fixes
2016-09-27 03:27:41 -04:00
rocky
1fc8ac4700 Interval order COME_FROMs in Python3
This bug had possibly caused lots of grammar pollution which may need
addressing.

We want to process COME_FROMs to the same offset to be in *descending*
order so we have the larger range or biggest instruction interval
last. (I think they are sorted in increasing order, but for safety
we sort them). That way, specific COME_FROM tags will match up
properly. For example, a "loop" with an "if" nested in it should have
the "loop" tag last so the grammar rule matches that properly

Adjust Python 3 grammar for more COME_FROM -> COME_FROM_LOOP. And
remove optional COME_FROM_LOOP where possible. Previously, the
optional-ness was a result of inner nestings gobbling up the
COME_FROM.

We'll probably want to go back and fix this up in Python2.
2016-09-26 09:26:51 -04:00
rocky
c87710dd4b Python 3 COME_FROM -> COME_FROM_WITH appropriately 2016-09-26 08:09:05 -04:00
rocky
8bc76f19b9 Tidy use of SETUP_ ops
Also possibly remove a bug in decompiling Python 3.0 .. 3.2 which doesn't
have SETUP_WITH
2016-09-23 19:22:09 -04:00
rocky
760532b218 Add COME_FROM_LOOP
Note: we have regressed in --verify and some tests,
but I believe that's because we are producing more equivalant
(if uglier) programs. That's a separate problem though.
2016-09-22 08:24:02 -04:00
rocky
b6dee24289 First step towards managing control flow decoding 2016-09-21 21:30:57 -04:00
rocky
0fce4c6dc3 Another 3.5+ erroneous RETURN_END_IF misclassify 2016-09-07 04:03:21 -04:00
rocky
c44d4898cb But in Python 3.5+ erroneosly adding RETURN_END_IF 2016-09-07 03:37:48 -04:00
rocky
318311818e Python 2.6- try/except control flow detection 2016-09-05 04:02:37 -04:00
rocky
c7788e4545 disassemble -> ingest where appropriate
As part of tokenization for (de)parsing, we need to do something like a
disassembly, but is is really a little different.

Disassembly, strictly speaking, is done by the xdis module now.
What "ingestion" does is massage the instruction tokens to a form that is
more amenable for parsing.

In sum, ingestion is different than disassembly, although disassembly is
generally the first part of ingestion.
2016-09-04 11:43:02 -04:00
rocky
6189ce3c04 Bug in 3.x detecting "if" structure and ...
scanner3.py: bug in 3.x detecting "if" structure
Make scanner2.py look more like scanner3.py
verify.py: add weak-verify which tests Pytyon syntax, but not code
2016-08-31 04:07:42 -04:00
rocky
ddc5460030 Start to handle Python 3.1 bytecode 2016-08-26 20:50:08 -04:00
rocky
3a6f9d8f24 Fix 3.5 misclassifying RETURN_VALUE
We use location of SETUP_EXCEPT instructions to disambiguate.
2016-07-29 08:56:23 -04:00
rocky
5c9c0228ee PyPy 3.2 bug confusing RETURN_END_IF for except
Also fix a instruction formatting bug
2016-07-28 00:41:40 -04:00
rocky
5ffd9b2be7 2.6 and 2.7 while1 grammar rule
Fixes issue #40
2016-07-27 13:19:42 -04:00
rocky
3a78332d59 tok.format -> tok.__str__; simplify pypy code 2016-07-27 09:26:39 -04:00
rocky
6c5bd6289f More PyPy grammar rules
* assert one and two-arg form
* trystmt

Simplify adding multiple grammar rules
2016-07-26 10:21:12 -04:00