mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using Microsoft.CodeAnalysis.CSharp;
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
using Microsoft.Iris.Markup;
|
|
using System;
|
|
using System.Linq.Expressions;
|
|
|
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
|
|
|
namespace Microsoft.Iris.DecompXml.Mock;
|
|
|
|
internal class IrisConstantExpression : IrisExpression, IReturnValueProvider
|
|
{
|
|
public IrisConstantExpression(object value, TypeSchema typeSchema)
|
|
{
|
|
Value = value;
|
|
TypeSchema = typeSchema;
|
|
}
|
|
|
|
public sealed override ExpressionType NodeType => ExpressionType.Constant;
|
|
|
|
public object Value { get; }
|
|
|
|
public TypeSchema TypeSchema { get; }
|
|
|
|
public TypeSchema ReturnType => TypeSchema;
|
|
|
|
public override ExpressionSyntax ToSyntax(DecompileContext context)
|
|
{
|
|
return Value switch
|
|
{
|
|
Enum enumValue => MemberAccessExpression(
|
|
SyntaxKind.SimpleMemberAccessExpression,
|
|
IdentifierName(context.GetQualifiedName(TypeSchema).ToString()),
|
|
IdentifierName(Value.ToString())
|
|
),
|
|
|
|
_ => ToSyntax(Value, context)
|
|
};
|
|
}
|
|
}
|