pfalcon / ScratchABlock

Yet another crippled decompiler project
https://github.com/EiNSTeiN-/decompiler/issues/9#issuecomment-103221200
GNU General Public License v3.0
104 stars 23 forks source link

tests/switch-btree1.lst: New test. #19

Closed maximumspatium closed 6 years ago

maximumspatium commented 6 years ago

Looks simple enough to be grokkable by a human. Please submit as a PR.

Here it goes.

pfalcon commented 6 years ago

Cool, merged with a comment that it unit-like test for a future pass.

Note that I thought this would go to tests/decomp/ first, and tried to drop it there too, but got an error:

  File "/mnt/hdd/projects/ScratchABlock/decomp.py", line 196, in match_if_else_inv_ladder_recursive
    assert len(block.branches) == 2, "Must be applied before match_if_else_ladder"
AssertionError: Must be applied before match_if_else_ladder

That's an example of mis-assumptions (and/or mis-ordering) of passes.

pfalcon commented 6 years ago

So far, turned that assert into a warning in 3a10ad1f3467502889403b488aa984bf5542235c

pfalcon commented 6 years ago

Ok, trying it now leads to nondeterministic variations in if-else structuring:

         $a3 = 250;
       } else if ($a2_0 == 100) {
         $a3 = 100;
-      } else if ($a2_0 == 200) {
+      } else if ($a2_0 != 200) {
+      } else {
         $a3 = 200;
       }
-    } else if ($a2_0 != 500) {
-    } else {
+    } else if ($a2_0 == 500) {
       $a3 = 500;
     }
   } else if ($a2_0 == 750) {