Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
colinator27 committed Feb 2, 2025
1 parent 7d09064 commit d7b22d1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public IExpressionNode Clean(ASTCleaner cleaner)
if (cleaner.StructArguments is not null)
{
// Verify this is an argument array access
if (instType == (int)InstanceType.Argument &&
if (instType is (int)InstanceType.Argument or (int)InstanceType.Self &&
Variable is { Name.Content: "argument" } &&
ArrayIndices is [Int16Node arrayIndex])
{
Expand Down
45 changes: 45 additions & 0 deletions UnderanalyzerTest/DecompileContext.DecompileToString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2790,4 +2790,49 @@ function Test(arg0) constructor
"""
);
}

[Fact]
public void TestStructSelfArgument()
{
// Note about this test case: -1 (self) values are generally -15 (arguments), but seems like either
// different GameMaker versions or mod tooling(?) generates code that uses self...
TestUtil.VerifyDecompileResult(
"""
:[0]
call.i @@NewGMLArray@@ 0
call.i @@NewGMLArray@@ 0
b [2]
> test_struct (locals=0, args=0)
:[1]
pushi.e -1
pushi.e 0
push.v [array]self.argument
pop.v.v self.a
pushi.e -1
pushi.e 1
push.v [array]self.argument
pop.v.v self.b
exit.i
:[2]
push.i [function]test_struct
conv.i.v
call.i @@NullObject@@ 0
call.i method 2
dup.v 0
pushi.e -16
pop.v.v [stacktop]static.test_struct
call.i @@NewGMLObject@@ 3
pop.v.v self.c
""",
"""
c =
{
a: [],
b: []
};
"""
);
}
}

0 comments on commit d7b22d1

Please sign in to comment.