Support list/dictionary bracket access

This commit is contained in:
Yoshi Askharoun
2025-07-28 19:51:25 -05:00
parent a0f6f1f66e
commit fb3b331255
2 changed files with 17 additions and 4 deletions
+16 -3
View File
@@ -16,6 +16,9 @@ namespace Microsoft.Iris.DecompXml;
partial class Decompiler
{
private static readonly TypeSchema _listType = UIXTypes.MapIDToType(UIXTypeID.List);
private static readonly TypeSchema _dictionaryType = UIXTypes.MapIDToType(UIXTypeID.Dictionary);
private SyntaxTree DecompileScript(uint startOffset, MarkupTypeSchema export)
{
var statements = DecompileMethod(startOffset, export);
@@ -313,12 +316,22 @@ partial class Decompiler
_ => stack.Pop(),
};
var methodTargetExpression = IrisExpression.ToSyntax(targetObj, _context);
ExpressionSyntax methodResult;
if ((methodSchema.Owner == _listType || methodSchema.Owner == _dictionaryType) && methodSchema.Name == "get_Item")
{
// Use brackets for list and dictionary indexing
methodResult = ElementAccessExpression(methodTargetExpression, BracketedArgumentList([.. parameters]));
}
else
{
var methodExpression = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
IrisExpression.ToSyntax(targetObj, _context),
methodTargetExpression,
IdentifierName(methodSchema.Name)
);
var methodResult = InvocationExpression(methodExpression, ArgumentList([.. parameters]));
methodResult = InvocationExpression(methodExpression, ArgumentList([.. parameters]));
}
if (methodSchema.ReturnType != VoidSchema.Type)
{
+1 -1
View File
@@ -846,7 +846,7 @@
goto UIB_0097;
source = QuickplayFrameBackground.Value;
goto UIB_00AA;
source = (zuneUI:NamedStringOption)FrameBackgrounds.get_Item(DefaultBackgroundIndex).Value;
source = (zuneUI:NamedStringOption)FrameBackgrounds[DefaultBackgroundIndex].Value;
return source;
}</Script>
</Scripts>