Skip to content

Commit d7b22d1

Browse files
committed
1 parent 7d09064 commit d7b22d1

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

Underanalyzer/Decompiler/AST/Nodes/VariableNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public IExpressionNode Clean(ASTCleaner cleaner)
234234
if (cleaner.StructArguments is not null)
235235
{
236236
// Verify this is an argument array access
237-
if (instType == (int)InstanceType.Argument &&
237+
if (instType is (int)InstanceType.Argument or (int)InstanceType.Self &&
238238
Variable is { Name.Content: "argument" } &&
239239
ArrayIndices is [Int16Node arrayIndex])
240240
{

UnderanalyzerTest/DecompileContext.DecompileToString.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,4 +2790,49 @@ function Test(arg0) constructor
27902790
"""
27912791
);
27922792
}
2793+
2794+
[Fact]
2795+
public void TestStructSelfArgument()
2796+
{
2797+
// Note about this test case: -1 (self) values are generally -15 (arguments), but seems like either
2798+
// different GameMaker versions or mod tooling(?) generates code that uses self...
2799+
TestUtil.VerifyDecompileResult(
2800+
"""
2801+
:[0]
2802+
call.i @@NewGMLArray@@ 0
2803+
call.i @@NewGMLArray@@ 0
2804+
b [2]
2805+
2806+
> test_struct (locals=0, args=0)
2807+
:[1]
2808+
pushi.e -1
2809+
pushi.e 0
2810+
push.v [array]self.argument
2811+
pop.v.v self.a
2812+
pushi.e -1
2813+
pushi.e 1
2814+
push.v [array]self.argument
2815+
pop.v.v self.b
2816+
exit.i
2817+
2818+
:[2]
2819+
push.i [function]test_struct
2820+
conv.i.v
2821+
call.i @@NullObject@@ 0
2822+
call.i method 2
2823+
dup.v 0
2824+
pushi.e -16
2825+
pop.v.v [stacktop]static.test_struct
2826+
call.i @@NewGMLObject@@ 3
2827+
pop.v.v self.c
2828+
""",
2829+
"""
2830+
c =
2831+
{
2832+
a: [],
2833+
b: []
2834+
};
2835+
"""
2836+
);
2837+
}
27932838
}

0 commit comments

Comments
 (0)