Replace GML decompiler with Underanalyzer#1862
Merged
colinator27 merged 98 commits intomasterfrom Mar 19, 2025
Merged
Conversation
Also updates a variable type in Deltarune's builtin JSON
Mostly missing code append operations at the moment, but replace operations are functional
Removed a LOT of legacy code with this pass, and upgraded many built-in scripts
Bugs fixed include handling -0 rotation, and properly handling nonexistent instance IDs on layers. GameSpecificResolver has also been made thread-safe with its definition loading.
Also implements MurmurHash in the library (with tests)
Underanalyzer compiler integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.