Files
ZuneUIXTools/libs/UIX.DecompXml/Mock/IrisMethodCallExpression.cs
T

55 lines
1.4 KiB
C#
Raw Normal View History

2025-07-17 00:46:05 -05:00
using Microsoft.Iris.Markup;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace Microsoft.Iris.DecompXml.Mock;
internal class IrisMethodCallExpression : IrisExpression, IArgumentProvider, IReturnValueProvider
{
private readonly Expression[] _arguments;
public IrisMethodCallExpression(MethodSchema method, Expression? target, IEnumerable<Expression> arguments)
{
Method = method;
Target = target;
_arguments = arguments.ToArray();
}
public MethodSchema Method { get; }
public sealed override ExpressionType NodeType => ExpressionType.Call;
public Expression? Target { get; }
public int ArgumentCount => _arguments.Length;
public TypeSchema ReturnType => Method.ReturnType;
public Expression GetArgument(int index) => _arguments[index];
2025-07-17 14:30:19 -05:00
public override string Decompile(DecompileContext context)
2025-07-17 00:46:05 -05:00
{
StringBuilder sb = new();
2025-07-17 14:30:19 -05:00
var qfn = context.GetQualifiedName(Method.Owner);
2025-07-17 00:46:05 -05:00
sb.Append(qfn);
sb.Append('.');
sb.Append(Method.Name);
sb.Append('(');
sb.Append(string.Join(", ", _arguments.Select(exprToString)));
sb.Append(')');
return sb.ToString();
string exprToString(Expression x)
{
return x is IrisExpression irisExpr
2025-07-17 14:30:19 -05:00
? irisExpr.Decompile(context)
2025-07-17 00:46:05 -05:00
: x.ToString();
}
}
}