diff --git a/test/bytecode_3.2/add.cpython-32.pyc b/test/bytecode_3.2/add.pyc similarity index 100% rename from test/bytecode_3.2/add.cpython-32.pyc rename to test/bytecode_3.2/add.pyc diff --git a/test/bytecode_3.2/and.cpython-32.pyc b/test/bytecode_3.2/and.pyc similarity index 100% rename from test/bytecode_3.2/and.cpython-32.pyc rename to test/bytecode_3.2/and.pyc diff --git a/test/bytecode_3.2/divide_floor.pyc b/test/bytecode_3.2/divide_floor.pyc new file mode 100644 index 00000000..24899bdb Binary files /dev/null and b/test/bytecode_3.2/divide_floor.pyc differ diff --git a/test/bytecode_3.2/divide_true.pyc b/test/bytecode_3.2/divide_true.pyc new file mode 100644 index 00000000..dcaecfb5 Binary files /dev/null and b/test/bytecode_3.2/divide_true.pyc differ diff --git a/test/bytecode_3.2/for.cpython-32.pyc b/test/bytecode_3.2/for.pyc similarity index 100% rename from test/bytecode_3.2/for.cpython-32.pyc rename to test/bytecode_3.2/for.pyc diff --git a/test/bytecode_3.2/if.cpython-32.pyc b/test/bytecode_3.2/if.pyc similarity index 100% rename from test/bytecode_3.2/if.cpython-32.pyc rename to test/bytecode_3.2/if.pyc diff --git a/test/bytecode_3.2/ifelse.cpython-32.pyc b/test/bytecode_3.2/ifelse.pyc similarity index 100% rename from test/bytecode_3.2/ifelse.cpython-32.pyc rename to test/bytecode_3.2/ifelse.pyc diff --git a/test/bytecode_3.2/keyword.cpython-32.pyc b/test/bytecode_3.2/keyword.pyc similarity index 100% rename from test/bytecode_3.2/keyword.cpython-32.pyc rename to test/bytecode_3.2/keyword.pyc diff --git a/test/bytecode_3.2/modulo.pyc b/test/bytecode_3.2/modulo.pyc new file mode 100644 index 00000000..201095ca Binary files /dev/null and b/test/bytecode_3.2/modulo.pyc differ diff --git a/test/bytecode_3.2/multiply.pyc b/test/bytecode_3.2/multiply.pyc new file mode 100644 index 00000000..f18d053f Binary files /dev/null and b/test/bytecode_3.2/multiply.pyc differ diff --git a/test/bytecode_3.2/or.pyc b/test/bytecode_3.2/or.pyc new file mode 100644 index 00000000..386cc391 Binary files /dev/null and b/test/bytecode_3.2/or.pyc differ diff --git a/test/bytecode_3.2/positional.cpython-32.pyc b/test/bytecode_3.2/positional.pyc similarity index 100% rename from test/bytecode_3.2/positional.cpython-32.pyc rename to test/bytecode_3.2/positional.pyc diff --git a/test/bytecode_3.2/power.pyc b/test/bytecode_3.2/power.pyc new file mode 100644 index 00000000..86151859 Binary files /dev/null and b/test/bytecode_3.2/power.pyc differ diff --git a/test/bytecode_3.2/shift_left.pyc b/test/bytecode_3.2/shift_left.pyc new file mode 100644 index 00000000..d18c0ac3 Binary files /dev/null and b/test/bytecode_3.2/shift_left.pyc differ diff --git a/test/bytecode_3.2/shift_right.pyc b/test/bytecode_3.2/shift_right.pyc new file mode 100644 index 00000000..8643247a Binary files /dev/null and b/test/bytecode_3.2/shift_right.pyc differ diff --git a/test/bytecode_3.2/subscription.pyc b/test/bytecode_3.2/subscription.pyc new file mode 100644 index 00000000..6b974ad7 Binary files /dev/null and b/test/bytecode_3.2/subscription.pyc differ diff --git a/test/bytecode_3.2/subtract.pyc b/test/bytecode_3.2/subtract.pyc new file mode 100644 index 00000000..439dc8dd Binary files /dev/null and b/test/bytecode_3.2/subtract.pyc differ diff --git a/test/bytecode_3.2/while.cpython-32.pyc b/test/bytecode_3.2/while.pyc similarity index 100% rename from test/bytecode_3.2/while.cpython-32.pyc rename to test/bytecode_3.2/while.pyc diff --git a/test/bytecode_3.2/xor.pyc b/test/bytecode_3.2/xor.pyc new file mode 100644 index 00000000..e75f33bd Binary files /dev/null and b/test/bytecode_3.2/xor.pyc differ diff --git a/test/bytecode_3.4/add.pyc b/test/bytecode_3.4/add.pyc index b75cc3b4..e03b6825 100644 Binary files a/test/bytecode_3.4/add.pyc and b/test/bytecode_3.4/add.pyc differ diff --git a/test/bytecode_3.4/and.pyc b/test/bytecode_3.4/and.pyc index 0ba3c386..10c00e52 100644 Binary files a/test/bytecode_3.4/and.pyc and b/test/bytecode_3.4/and.pyc differ diff --git a/test/bytecode_3.4/assert.pyc b/test/bytecode_3.4/assert.pyc new file mode 100644 index 00000000..dcdc3b4d Binary files /dev/null and b/test/bytecode_3.4/assert.pyc differ diff --git a/test/bytecode_3.4/assign_none.pyc b/test/bytecode_3.4/assign_none.pyc new file mode 100644 index 00000000..ea9a1590 Binary files /dev/null and b/test/bytecode_3.4/assign_none.pyc differ diff --git a/test/bytecode_3.4/assign_none_str.pyc b/test/bytecode_3.4/assign_none_str.pyc new file mode 100644 index 00000000..82973773 Binary files /dev/null and b/test/bytecode_3.4/assign_none_str.pyc differ diff --git a/test/bytecode_3.4/complex1.pyc b/test/bytecode_3.4/complex1.pyc new file mode 100644 index 00000000..ce76eafd Binary files /dev/null and b/test/bytecode_3.4/complex1.pyc differ diff --git a/test/bytecode_3.4/complex2.pyc b/test/bytecode_3.4/complex2.pyc new file mode 100644 index 00000000..62eebcbe Binary files /dev/null and b/test/bytecode_3.4/complex2.pyc differ diff --git a/test/bytecode_3.4/complex3.pyc b/test/bytecode_3.4/complex3.pyc new file mode 100644 index 00000000..968b8256 Binary files /dev/null and b/test/bytecode_3.4/complex3.pyc differ diff --git a/test/bytecode_3.4/complex4.pyc b/test/bytecode_3.4/complex4.pyc new file mode 100644 index 00000000..74b08190 Binary files /dev/null and b/test/bytecode_3.4/complex4.pyc differ diff --git a/test/bytecode_3.4/complex5.pyc b/test/bytecode_3.4/complex5.pyc new file mode 100644 index 00000000..1e9190ab Binary files /dev/null and b/test/bytecode_3.4/complex5.pyc differ diff --git a/test/bytecode_3.4/complex6.pyc b/test/bytecode_3.4/complex6.pyc new file mode 100644 index 00000000..1324c129 Binary files /dev/null and b/test/bytecode_3.4/complex6.pyc differ diff --git a/test/bytecode_3.4/complex7.pyc b/test/bytecode_3.4/complex7.pyc new file mode 100644 index 00000000..c8b0504c Binary files /dev/null and b/test/bytecode_3.4/complex7.pyc differ diff --git a/test/bytecode_3.4/complex8.pyc b/test/bytecode_3.4/complex8.pyc new file mode 100644 index 00000000..f9c0e50b Binary files /dev/null and b/test/bytecode_3.4/complex8.pyc differ diff --git a/test/bytecode_3.4/complex9.pyc b/test/bytecode_3.4/complex9.pyc new file mode 100644 index 00000000..ec34d9d4 Binary files /dev/null and b/test/bytecode_3.4/complex9.pyc differ diff --git a/test/bytecode_3.4/complex_script1.pyc b/test/bytecode_3.4/complex_script1.pyc new file mode 100644 index 00000000..77aa3dd6 Binary files /dev/null and b/test/bytecode_3.4/complex_script1.pyc differ diff --git a/test/bytecode_3.4/complex_script2.pyc b/test/bytecode_3.4/complex_script2.pyc new file mode 100644 index 00000000..ef80c4d6 Binary files /dev/null and b/test/bytecode_3.4/complex_script2.pyc differ diff --git a/test/bytecode_3.4/divide_floor.pyc b/test/bytecode_3.4/divide_floor.pyc new file mode 100644 index 00000000..82807a47 Binary files /dev/null and b/test/bytecode_3.4/divide_floor.pyc differ diff --git a/test/bytecode_3.4/divide_true.pyc b/test/bytecode_3.4/divide_true.pyc new file mode 100644 index 00000000..c19cc74f Binary files /dev/null and b/test/bytecode_3.4/divide_true.pyc differ diff --git a/test/bytecode_3.4/equal.pyc b/test/bytecode_3.4/equal.pyc new file mode 100644 index 00000000..4a5b6d7d Binary files /dev/null and b/test/bytecode_3.4/equal.pyc differ diff --git a/test/bytecode_3.4/for.pyc b/test/bytecode_3.4/for.pyc new file mode 100644 index 00000000..bf5baeb8 Binary files /dev/null and b/test/bytecode_3.4/for.pyc differ diff --git a/test/bytecode_3.4/forelse.pyc b/test/bytecode_3.4/forelse.pyc new file mode 100644 index 00000000..2583bb88 Binary files /dev/null and b/test/bytecode_3.4/forelse.pyc differ diff --git a/test/bytecode_3.4/globals.pyc b/test/bytecode_3.4/globals.pyc new file mode 100644 index 00000000..24c1d289 Binary files /dev/null and b/test/bytecode_3.4/globals.pyc differ diff --git a/test/bytecode_3.4/globals_locals.pyc b/test/bytecode_3.4/globals_locals.pyc new file mode 100644 index 00000000..59a77b99 Binary files /dev/null and b/test/bytecode_3.4/globals_locals.pyc differ diff --git a/test/bytecode_3.4/greater.pyc b/test/bytecode_3.4/greater.pyc new file mode 100644 index 00000000..149151a3 Binary files /dev/null and b/test/bytecode_3.4/greater.pyc differ diff --git a/test/bytecode_3.4/greater_equal.pyc b/test/bytecode_3.4/greater_equal.pyc new file mode 100644 index 00000000..30271e40 Binary files /dev/null and b/test/bytecode_3.4/greater_equal.pyc differ diff --git a/test/bytecode_3.4/invert.pyc b/test/bytecode_3.4/invert.pyc new file mode 100644 index 00000000..bc9c56dc Binary files /dev/null and b/test/bytecode_3.4/invert.pyc differ diff --git a/test/bytecode_3.4/iter.pyc b/test/bytecode_3.4/iter.pyc new file mode 100644 index 00000000..066f7733 Binary files /dev/null and b/test/bytecode_3.4/iter.pyc differ diff --git a/test/bytecode_3.4/left.pyc b/test/bytecode_3.4/left.pyc new file mode 100644 index 00000000..e7661663 Binary files /dev/null and b/test/bytecode_3.4/left.pyc differ diff --git a/test/bytecode_3.4/less.pyc b/test/bytecode_3.4/less.pyc new file mode 100644 index 00000000..8044f5cd Binary files /dev/null and b/test/bytecode_3.4/less.pyc differ diff --git a/test/bytecode_3.4/less_equal.pyc b/test/bytecode_3.4/less_equal.pyc new file mode 100644 index 00000000..21e4c25f Binary files /dev/null and b/test/bytecode_3.4/less_equal.pyc differ diff --git a/test/bytecode_3.4/modulo.pyc b/test/bytecode_3.4/modulo.pyc new file mode 100644 index 00000000..e6d7efa0 Binary files /dev/null and b/test/bytecode_3.4/modulo.pyc differ diff --git a/test/bytecode_3.4/multiply.pyc b/test/bytecode_3.4/multiply.pyc new file mode 100644 index 00000000..38dd35de Binary files /dev/null and b/test/bytecode_3.4/multiply.pyc differ diff --git a/test/bytecode_3.4/negative.pyc b/test/bytecode_3.4/negative.pyc new file mode 100644 index 00000000..d186d8e3 Binary files /dev/null and b/test/bytecode_3.4/negative.pyc differ diff --git a/test/bytecode_3.4/not.pyc b/test/bytecode_3.4/not.pyc new file mode 100644 index 00000000..a93fcf2c Binary files /dev/null and b/test/bytecode_3.4/not.pyc differ diff --git a/test/bytecode_3.4/notequal.pyc b/test/bytecode_3.4/notequal.pyc new file mode 100644 index 00000000..46626f3e Binary files /dev/null and b/test/bytecode_3.4/notequal.pyc differ diff --git a/test/bytecode_3.4/or.pyc b/test/bytecode_3.4/or.pyc new file mode 100644 index 00000000..8a6494ac Binary files /dev/null and b/test/bytecode_3.4/or.pyc differ diff --git a/test/bytecode_3.4/positive.pyc b/test/bytecode_3.4/positive.pyc new file mode 100644 index 00000000..61b1e844 Binary files /dev/null and b/test/bytecode_3.4/positive.pyc differ diff --git a/test/bytecode_3.4/power.pyc b/test/bytecode_3.4/power.pyc new file mode 100644 index 00000000..4a148e20 Binary files /dev/null and b/test/bytecode_3.4/power.pyc differ diff --git a/test/bytecode_3.4/right.pyc b/test/bytecode_3.4/right.pyc new file mode 100644 index 00000000..b60072d0 Binary files /dev/null and b/test/bytecode_3.4/right.pyc differ diff --git a/test/bytecode_3.4/shift_left.pyc b/test/bytecode_3.4/shift_left.pyc new file mode 100644 index 00000000..00eba3d8 Binary files /dev/null and b/test/bytecode_3.4/shift_left.pyc differ diff --git a/test/bytecode_3.4/shift_right.pyc b/test/bytecode_3.4/shift_right.pyc new file mode 100644 index 00000000..bb00cb9b Binary files /dev/null and b/test/bytecode_3.4/shift_right.pyc differ diff --git a/test/bytecode_3.4/structure.pyc b/test/bytecode_3.4/structure.pyc new file mode 100644 index 00000000..30403737 Binary files /dev/null and b/test/bytecode_3.4/structure.pyc differ diff --git a/test/bytecode_3.4/subscription.pyc b/test/bytecode_3.4/subscription.pyc new file mode 100644 index 00000000..3451e8b5 Binary files /dev/null and b/test/bytecode_3.4/subscription.pyc differ diff --git a/test/bytecode_3.4/subtract.pyc b/test/bytecode_3.4/subtract.pyc new file mode 100644 index 00000000..8a39a1ad Binary files /dev/null and b/test/bytecode_3.4/subtract.pyc differ diff --git a/test/bytecode_3.4/while.pyc b/test/bytecode_3.4/while.pyc new file mode 100644 index 00000000..623d4f4a Binary files /dev/null and b/test/bytecode_3.4/while.pyc differ diff --git a/test/bytecode_3.4/xor.pyc b/test/bytecode_3.4/xor.pyc new file mode 100644 index 00000000..c09fc46f Binary files /dev/null and b/test/bytecode_3.4/xor.pyc differ diff --git a/test/simple-source/operation_binary/multiply.py b/test/simple-source/operation_binary/multiply.py new file mode 100644 index 00000000..dbb590ed --- /dev/null +++ b/test/simple-source/operation_binary/multiply.py @@ -0,0 +1 @@ +a = b * c diff --git a/test/simple-source/operation_binary/or.py b/test/simple-source/operation_binary/or.py new file mode 100644 index 00000000..0d0d5926 --- /dev/null +++ b/test/simple-source/operation_binary/or.py @@ -0,0 +1 @@ +a = b | c diff --git a/test/simple-source/operation_binary/power.py b/test/simple-source/operation_binary/power.py new file mode 100644 index 00000000..55af6117 --- /dev/null +++ b/test/simple-source/operation_binary/power.py @@ -0,0 +1 @@ +a = b ** c diff --git a/test/simple-source/operation_binary/shift_left.py b/test/simple-source/operation_binary/shift_left.py new file mode 100644 index 00000000..ce1e5fa2 --- /dev/null +++ b/test/simple-source/operation_binary/shift_left.py @@ -0,0 +1 @@ +a = b << c diff --git a/test/simple-source/operation_binary/shift_right.py b/test/simple-source/operation_binary/shift_right.py new file mode 100644 index 00000000..f5f12630 --- /dev/null +++ b/test/simple-source/operation_binary/shift_right.py @@ -0,0 +1 @@ +a = b >> c diff --git a/test/simple-source/operation_binary/subscription.py b/test/simple-source/operation_binary/subscription.py new file mode 100644 index 00000000..c82b29ce --- /dev/null +++ b/test/simple-source/operation_binary/subscription.py @@ -0,0 +1 @@ +a = b[c] diff --git a/test/simple-source/operation_binary/subtract.py b/test/simple-source/operation_binary/subtract.py new file mode 100644 index 00000000..5665b9a0 --- /dev/null +++ b/test/simple-source/operation_binary/subtract.py @@ -0,0 +1 @@ +a = b - c diff --git a/test/simple-source/operation_binary/xor.py b/test/simple-source/operation_binary/xor.py new file mode 100644 index 00000000..74ac990b --- /dev/null +++ b/test/simple-source/operation_binary/xor.py @@ -0,0 +1 @@ +a = b ^ c diff --git a/test/simple-source/operation_comparison/equal.py b/test/simple-source/operation_comparison/equal.py new file mode 100644 index 00000000..3868da7a --- /dev/null +++ b/test/simple-source/operation_comparison/equal.py @@ -0,0 +1 @@ +a == b diff --git a/test/simple-source/operation_comparison/greater.py b/test/simple-source/operation_comparison/greater.py new file mode 100644 index 00000000..4fb63b4b --- /dev/null +++ b/test/simple-source/operation_comparison/greater.py @@ -0,0 +1 @@ +a > b diff --git a/test/simple-source/operation_comparison/greater_equal.py b/test/simple-source/operation_comparison/greater_equal.py new file mode 100644 index 00000000..c85dc864 --- /dev/null +++ b/test/simple-source/operation_comparison/greater_equal.py @@ -0,0 +1 @@ +a >= b diff --git a/test/simple-source/operation_comparison/less.py b/test/simple-source/operation_comparison/less.py new file mode 100644 index 00000000..ec87be75 --- /dev/null +++ b/test/simple-source/operation_comparison/less.py @@ -0,0 +1 @@ +a < b diff --git a/test/simple-source/operation_comparison/less_equal.py b/test/simple-source/operation_comparison/less_equal.py new file mode 100644 index 00000000..6228539c --- /dev/null +++ b/test/simple-source/operation_comparison/less_equal.py @@ -0,0 +1 @@ +a <= b diff --git a/test/simple-source/operation_comparison/notequal.py b/test/simple-source/operation_comparison/notequal.py new file mode 100644 index 00000000..22a319fb --- /dev/null +++ b/test/simple-source/operation_comparison/notequal.py @@ -0,0 +1 @@ +a != b diff --git a/test/simple-source/operation_inplace/add.py b/test/simple-source/operation_inplace/add.py new file mode 100644 index 00000000..d1e399dd --- /dev/null +++ b/test/simple-source/operation_inplace/add.py @@ -0,0 +1 @@ +a += b diff --git a/test/simple-source/operation_inplace/and.py b/test/simple-source/operation_inplace/and.py new file mode 100644 index 00000000..59af58ce --- /dev/null +++ b/test/simple-source/operation_inplace/and.py @@ -0,0 +1 @@ +a &= b diff --git a/test/simple-source/operation_inplace/divide_floor.py b/test/simple-source/operation_inplace/divide_floor.py new file mode 100644 index 00000000..94ec2e03 --- /dev/null +++ b/test/simple-source/operation_inplace/divide_floor.py @@ -0,0 +1 @@ +a //= b diff --git a/test/simple-source/operation_inplace/divide_true.py b/test/simple-source/operation_inplace/divide_true.py new file mode 100644 index 00000000..1c9955c3 --- /dev/null +++ b/test/simple-source/operation_inplace/divide_true.py @@ -0,0 +1 @@ +a /= b diff --git a/test/simple-source/operation_inplace/modulo.py b/test/simple-source/operation_inplace/modulo.py new file mode 100644 index 00000000..0ec49076 --- /dev/null +++ b/test/simple-source/operation_inplace/modulo.py @@ -0,0 +1 @@ +a %= b diff --git a/test/simple-source/operation_inplace/multiply.py b/test/simple-source/operation_inplace/multiply.py new file mode 100644 index 00000000..14afe669 --- /dev/null +++ b/test/simple-source/operation_inplace/multiply.py @@ -0,0 +1 @@ +a *= b diff --git a/test/simple-source/operation_inplace/or.py b/test/simple-source/operation_inplace/or.py new file mode 100644 index 00000000..ab5d8855 --- /dev/null +++ b/test/simple-source/operation_inplace/or.py @@ -0,0 +1 @@ +a |= b diff --git a/test/simple-source/operation_inplace/power.py b/test/simple-source/operation_inplace/power.py new file mode 100644 index 00000000..b8a5cf99 --- /dev/null +++ b/test/simple-source/operation_inplace/power.py @@ -0,0 +1 @@ +a **= b diff --git a/test/simple-source/operation_inplace/shift_left.py b/test/simple-source/operation_inplace/shift_left.py new file mode 100644 index 00000000..13ce5cbf --- /dev/null +++ b/test/simple-source/operation_inplace/shift_left.py @@ -0,0 +1 @@ +a <<= b diff --git a/test/simple-source/operation_inplace/shift_right.py b/test/simple-source/operation_inplace/shift_right.py new file mode 100644 index 00000000..0ec678a7 --- /dev/null +++ b/test/simple-source/operation_inplace/shift_right.py @@ -0,0 +1 @@ +a >>= b diff --git a/test/simple-source/operation_inplace/subtract.py b/test/simple-source/operation_inplace/subtract.py new file mode 100644 index 00000000..19bd84cb --- /dev/null +++ b/test/simple-source/operation_inplace/subtract.py @@ -0,0 +1 @@ +a -= b diff --git a/test/simple-source/operation_inplace/xor.py b/test/simple-source/operation_inplace/xor.py new file mode 100644 index 00000000..01cce8c5 --- /dev/null +++ b/test/simple-source/operation_inplace/xor.py @@ -0,0 +1 @@ +a ^= b diff --git a/test/simple-source/operation_logic/and.py b/test/simple-source/operation_logic/and.py new file mode 100644 index 00000000..3296cb3e --- /dev/null +++ b/test/simple-source/operation_logic/and.py @@ -0,0 +1 @@ +a = b and c diff --git a/test/simple-source/operation_logic/complex1.py b/test/simple-source/operation_logic/complex1.py new file mode 100644 index 00000000..1d8d14de --- /dev/null +++ b/test/simple-source/operation_logic/complex1.py @@ -0,0 +1 @@ +a = b and c or d diff --git a/test/simple-source/operation_logic/complex2.py b/test/simple-source/operation_logic/complex2.py new file mode 100644 index 00000000..84a033e3 --- /dev/null +++ b/test/simple-source/operation_logic/complex2.py @@ -0,0 +1 @@ +a = (b or c) and d diff --git a/test/simple-source/operation_logic/complex3.py b/test/simple-source/operation_logic/complex3.py new file mode 100644 index 00000000..88625229 --- /dev/null +++ b/test/simple-source/operation_logic/complex3.py @@ -0,0 +1 @@ +a = b or c or d diff --git a/test/simple-source/precedence/left.py b/test/simple-source/precedence/left.py new file mode 100644 index 00000000..fcc8b9fb --- /dev/null +++ b/test/simple-source/precedence/left.py @@ -0,0 +1,2 @@ +a = (b + c) * d +a = b + c * d diff --git a/test/simple-source/precedence/right.py b/test/simple-source/precedence/right.py new file mode 100644 index 00000000..fa7722ca --- /dev/null +++ b/test/simple-source/precedence/right.py @@ -0,0 +1,2 @@ +a = b * (c + d) +a = b * c + d diff --git a/test/simple-source/precedence/structure.py b/test/simple-source/precedence/structure.py new file mode 100644 index 00000000..d7e170a0 --- /dev/null +++ b/test/simple-source/precedence/structure.py @@ -0,0 +1,2 @@ +a = b + c + d + e +a = b + c + (d + e) diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index eb4d4eaa..b41800fa 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -665,24 +665,23 @@ class Python3Parser(PythonParser): """ new_rules = set() for token in tokens: - if token.type not in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR', - 'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'): - continue - # Low byte indicates number of positional paramters, - # high byte number of positional parameters - args_pos = token.attr & 0xff - args_kw = (token.attr >> 8) & 0xff - nak = ( len(token.type)-len('CALL_FUNCTION') ) // 3 - token.type = 'CALL_FUNCTION_%i' % token.attr - rule = ('call_function ::= expr ' - + ('expr ' * args_pos) - + ('kwarg ' * args_kw) - + 'expr ' * nak + token.type) - # Make sure we do not add the same rule twice - if rule not in new_rules: - new_rules.add(rule) - self.addRule(rule, nop_func) - customize[token.type] = args_pos + if token.type in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR', + 'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'): + # Low byte indicates number of positional paramters, + # high byte number of positional parameters + args_pos = token.attr & 0xff + args_kw = (token.attr >> 8) & 0xff + nak = ( len(token.type)-len('CALL_FUNCTION') ) // 3 + token.type = 'CALL_FUNCTION_%i' % token.attr + rule = ('call_function ::= expr ' + + ('expr ' * args_pos) + + ('kwarg ' * args_kw) + + 'expr ' * nak + token.type) + # Make sure we do not add the same rule twice + if rule not in new_rules: + new_rules.add(rule) + self.addRule(rule, nop_func) + customize[token.type] = args_pos + pass pass - pass return diff --git a/uncompyle6/scanners/scanner34.py b/uncompyle6/scanners/scanner34.py index dd5ed7eb..cdbd0c93 100644 --- a/uncompyle6/scanners/scanner34.py +++ b/uncompyle6/scanners/scanner34.py @@ -17,6 +17,7 @@ from __future__ import print_function import dis from collections import namedtuple +from array import array from uncompyle6 import PYTHON_VERSION from uncompyle6.scanner import Token, L65536 @@ -36,21 +37,59 @@ class Scanner34(scan.Scanner): def __init__(self): scan.Scanner.__init__(self, 3.4) # check + def get_argument(self, bytecode, pos): + arg = bytecode[pos+1] + bytecode[pos+2] * 256 + return arg + def disassemble(self, co): fn = self.disassemble_built_in if PYTHON_VERSION == 3.4 \ else self.disassemble_cross_version return fn(co) - def disassemble_built_in(self, co): + def disassemble_built_in(self, co, classname=None): # Container for tokens tokens = [] - self.code = co.co_code + customize = {} + self.code = array('B', co.co_code) self.build_lines_data(co) self.build_prev_op() + # Get jump targets # Format: {target offset: [jump offsets]} jump_targets = self.find_jump_targets() bytecode = dis.Bytecode(co) + + # self.lines contains (block,addrLastInstr) + # if classname: + # classname = '_' + classname.lstrip('_') + '__' + + # def unmangle(name): + # if name.startswith(classname) and name[-2:] != '__': + # return name[len(classname) - 2:] + # return name + + # free = [ unmangle(name) for name in (co.co_cellvars + co.co_freevars) ] + # names = [ unmangle(name) for name in co.co_names ] + # varnames = [ unmangle(name) for name in co.co_varnames ] + # else: + # free = co.co_cellvars + co.co_freevars + # names = co.co_names + # varnames = co.co_varnames + + # Scan for assertions. Later we will + # turn 'LOAD_GLOBAL' to 'LOAD_ASSERT' for those + # assertions + self.load_asserts = set() + bs = list(bytecode) + n = len(bs) + for i in range(n): + inst = bs[i] + if inst.opname == 'POP_JUMP_IF_TRUE' and i+1 < n: + next_inst = bs[i+1] + if (next_inst.opname == 'LOAD_GLOBAL' and + next_inst.argval == 'AssertionError'): + self.load_asserts.add(next_inst.offset) + for inst in bytecode: if inst.offset in jump_targets: jump_idx = 0 @@ -60,14 +99,38 @@ class Scanner34(scan.Scanner): jump_idx += 1 pass pass + + pattr = inst.argrepr + opname = inst.opname + # For constants, the pattr is the same as attr. Using pattr adds # an extra level of quotes which messes other things up, like getting # keyword attribute names in a call. I suspect there will be things # other than LOAD_CONST, but we'll start out with just this for now. - pattr = inst.argval if inst.opname in ['LOAD_CONST'] else inst.argrepr + if opname in ['LOAD_CONST']: + pattr = inst.argval + elif opname in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SET', 'BUILD_SLICE', + 'UNPACK_SEQUENCE', + 'MAKE_FUNCTION', 'MAKE_CLOSURE', + 'DUP_TOPX', 'RAISE_VARARGS' + ): + # if opname == 'BUILD_TUPLE' and \ + # self.code[self.prev[offset]] == LOAD_CLOSURE: + # continue + # else: + # op_name = '%s_%d' % (op_name, oparg) + # if opname != BUILD_SLICE: + # customize[op_name] = oparg + opname = '%s_%d' % (opname, inst.argval) + if inst.opname != 'BUILD_SLICE': + customize[opname] = inst.argval + + elif inst.offset in self.load_asserts: + opname = 'LOAD_ASSERT' + tokens.append( Token( - type_ = inst.opname, + type_ = opname, attr = inst.argval, pattr = pattr, offset = inst.offset, @@ -85,7 +148,7 @@ class Scanner34(scan.Scanner): """ # Container for tokens tokens = [] - self.code = code = co.co_code + self.code = code = array('B', co.co_code) codelen = len(code) self.build_lines_data(co) self.build_prev_op()