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

Replace GML decompiler with Underanalyzer #1862

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

Conversation

colinator27
Copy link
Member

Description

Removes the current GML decompiler included with UndertaleModTool, replacing it with calls to the Underanalyzer library. This is intended to drastically improve accuracy and stability on valid GML bytecode. This also provides decompiler settings, which can be tailored per user, and in theory, be used to prevent C# scripts that depend on exact decompiler output from breaking in the future.

C# scripts have been updated to account for the change in decompiler. Most should be fully functional, but could use some additional stability testing.

The built-in GML code corrections have all been removed, as the decompiler is accurate enough to supersede them. Support for code corrections has not been removed, so they will still function as normal if re-added.

Some small GML compiler upgrades have been made to complement the decompiler improvements, including function constructor support, default argument values, enum support, CSS hex color literals, named instance IDs, throw, new, amongst some other control flow fixes. Syntax highlighting in the code editor has been adjusted as well.

External JSON game-specific data is now supported through this PR, which currently is only used for Underanalyzer type definition files. Features related to these can be expanded on in the future, after this PR.

This PR also completes support for bytecode changes observed in GameMaker 2024.6, which also updates the assembly syntax, adding [function] and [variable].

A few other miscellaneous fixes and changes were made, such as some optimization/cleanup in assembly parsing, and removing extra arguments to EventHandlerFor (simplifying its usage).

Caveats

Automatic type inference support is not present in the Underanalyzer decompiler as of right now, but it's probably something we can live without, as external JSON type definitions are now supported through this PR.

Some partially corrupt code may no longer decompile properly, but this should not be an issue, as we are not going to target any obfuscation techniques, and any other cases (e.g. manual assembly editing) are rare.

Currently, Underanalyzer is included as a submodule. We may want to switch to a different method in the future (e.g. using NuGet).

Notes

This code will be under review alongside Underanalyzer's library itself.

This branch has been under active testing by multiple users for a number of weeks, and stability seems good right now.

Also updates a variable type in Deltarune's builtin JSON
@colinator27 colinator27 requested a review from Miepee August 12, 2024 02:23
Copy link

github-actions bot commented Aug 12, 2024

Including this as part of the Underanalyzer branch, as it includes many other compiler changes/fixes
@hallo1126
Copy link

Requesting this to be included asap as many games fail with main, which this branch solves

@Miepee
Copy link
Contributor

Miepee commented Sep 7, 2024

Requesting this to be included asap as many games fail with main, which this branch solves

Unfortunately, that's not how reviewing works.

@Voidymite

This comment has been minimized.

@colinator27 colinator27 marked this pull request as ready for review November 23, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants