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 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) private SyntaxTree DecompileScript(uint startOffset, MarkupTypeSchema export)
{ {
var statements = DecompileMethod(startOffset, export); var statements = DecompileMethod(startOffset, export);
@@ -313,12 +316,22 @@ partial class Decompiler
_ => stack.Pop(), _ => 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, var methodExpression = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
IrisExpression.ToSyntax(targetObj, _context), methodTargetExpression,
IdentifierName(methodSchema.Name) IdentifierName(methodSchema.Name)
); );
methodResult = InvocationExpression(methodExpression, ArgumentList([.. parameters]));
var methodResult = InvocationExpression(methodExpression, ArgumentList([.. parameters])); }
if (methodSchema.ReturnType != VoidSchema.Type) if (methodSchema.ReturnType != VoidSchema.Type)
{ {
+1 -1
View File
@@ -846,7 +846,7 @@
goto UIB_0097; goto UIB_0097;
source = QuickplayFrameBackground.Value; source = QuickplayFrameBackground.Value;
goto UIB_00AA; goto UIB_00AA;
source = (zuneUI:NamedStringOption)FrameBackgrounds.get_Item(DefaultBackgroundIndex).Value; source = (zuneUI:NamedStringOption)FrameBackgrounds[DefaultBackgroundIndex].Value;
return source; return source;
}</Script> }</Script>
</Scripts> </Scripts>