curiousdannii / if-decompiler

Decompile Glulx storyfiles into C code
MIT License
17 stars 0 forks source link

Relooper, Stackifier, decompiler problems #13

Open kdabwl opened 2 years ago

kdabwl commented 2 years ago

Thank you for bringing the Relooper problem class to my attention (and indirectly the Stackifier problem class). . I had previously assumed that bytecode was "always" a 100% decompilable substitute for missing source code (100% identical, except temporary names), as is the case with Smalltalk decompiler. . What might be the reason for the problems of Relooper and Stackifier that are not present in the Smalltalk system?

curiousdannii commented 2 years ago

I'm not familiar with Smalltalk.

But the main issue is a mismatch between structured code (loops and if/else) and jump/branch to address models. Some languages only support one of them, and some VM formats use the other.

Also many, probably most, bytecodes definitely aren't 100% reversible. That sounds like Python's which is really just a compressed source code. Most bytecodes for VMs are truly compiled for them, and lots of information is lost.

kdabwl commented 2 years ago

what information can be lost by Inform7 compiled bytecode; I'm sure I can find examples (going the very long way), but your experience could shortcut that for me; thanks

curiousdannii commented 2 years ago

Whether the code used loops, switch statements, arbitrary jumps, etc. That's the main difficult for which reloopers are designed to solve.