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

Compiler self call support #1683

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

XdotCore
Copy link
Contributor

Resolves #1133

Description

  1. Adds support for GMS2.3+ self calls in the compiler, cherrypicked from UndertaleModTool Community Edition.

  2. Fixed an issue where sub functions in an object should be stored in a self variable without the object function name suffix.
    Example: the utmt compiler would make gml_Script_act_gml_Object_menu_chapter_btn_Create_0 be stored in self.act_gml_Object_menu_chapter_btn_Create_0 when the original game code had self.act.

Caveats

None

Notes

I've tested this with Submachine Legacy (2023.8), and the one from #1133 (2022.5)

How to Reproduce:

  1. Create a function in a GlobalScript or Object code, then call that function from another function
    image

  2. In gamemaker (I've only tested this for 2023.8), make a function in an object, then call that function from another one in the same object
    image

@XdotCore XdotCore marked this pull request as draft February 19, 2024 01:40
@Jacky720
Copy link
Contributor

Jacky720 commented Mar 5, 2024

See also #564.

@colinator27
Copy link
Member

As a heads up, we'll probably be looking at merging this functionality in once the Underanalyzer decompiler is merged in. We do have a few things to make decisions about, though:

  • Do we consult the builtin function list to determine self calls, or do we make a setting on the decompiler to force self. notation?
  • Do we account for more complex chains of calls, like a.b().c().d(), or do we hold off until we (possibly) make a new compiler on the Underanalyzer side?

Curious for thoughts!

@CST1229
Copy link
Contributor

CST1229 commented Jul 1, 2024

Just a note, UTMTCE's self calls have received further improvements since this PR, that are not in the PR (XDOneDude@19a4f44 XDOneDude@aeb6624), and they now do support chains of calls and also local variables (although still using self, yeah I know it's messy):

var a = function() {
    return  {
        b: function() {
            return 123;
        }
    };
}
show_message(self.a().b()) // shows "123"

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.

Using 'self' Throws Error "Expected token kind ProcVariable, got ProcFunction"
4 participants