Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit instructions ignored in decompilation #1223

Closed
angelo-wf opened this issue Mar 18, 2023 · 1 comment
Closed

Exit instructions ignored in decompilation #1223

angelo-wf opened this issue Mar 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@angelo-wf
Copy link

Describe the bug

Certain exit.i-instructions seem to be ignored when decompiling (possibly only when it is the only content of an is-else block, and possible only when the condition uses short-circuit operations?).

For example, the following disassembly:

push.v self.openingstate
pushi.e 3
cmp.i.v LT
bt [93]

:[92]
push.v self.blackalpha
pushi.e 0
cmp.i.v GT
b [94]

:[93]
push.e 1

:[94]
bf [96]

:[95]
exit.i

:[96]

Decompiled into an empty if statement:

if (openingstate < 3 || blackalpha > 0)
{
}

Making another change in the decompiled code and recompiling it will case the exit.i to then disappear from the disassembly, and the script to malfunction. Manually adding exit to the empty block and recompiling will have it immediately disappear again (due to decompiling again) but the exit.i instruction to return to the disassembly. This implies it should have probably been decompiled as:

if (openingstate < 3 || blackalpha > 0)
{
    exit
}

(or similar)

Also note that near the end of that code, return; is placed in the decompiled code (due to an exit.i instruction at the end of the disassembly), but the GML manual says that that's only valid within functions. That should probably be exit instead?

I noticed this with the game Tribal Hunter, in the code gml_Object_menu_title_Step_0. There are other places where exit.i instructions seem to be ignored in that same code as well.

Reproducing steps

  1. Open the data.win for Tribal Hunter
  2. Open gml_Object_menu_title_Step_0 under code.
  3. Observe empty if statements.
  4. Switch to the disassembly tab and look for the disassembly for those statements.
  5. Observe exit.i instructions that are ignored.

Setup Details

  1. UndertaleModTool v0.5.1.0, git d40d7a0 (latest nightly as of this report)
  2. Windows 11 (arm64)
  3. Tribal Hunter 1.0.0.8 (latest Steam release). The game has a free demo, but I don't know if it also appears there as I no longer have access to it (I remember it's title screen to be nearly identical to the full version so probably?). It is also available on GOG. Note that the game is technically SFW, but can be considered fetishy in nature.
@angelo-wf angelo-wf added the bug Something isn't working label Mar 18, 2023
@Jacky720
Copy link
Contributor

oh, you are kidding me. This issue is almost certainly caused by #1191, which I created to solve the opposite problem (removing returns during re-compilation). Specifically the change to Decompiler.cs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants