2025-07-17 14:07:44 -05:00
|
|
|
using Microsoft.Iris.Asm;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq.Expressions;
|
2025-07-17 00:46:05 -05:00
|
|
|
|
|
|
|
|
namespace Microsoft.Iris.DecompXml.Mock;
|
|
|
|
|
|
|
|
|
|
internal class IrisExpression : Expression
|
|
|
|
|
{
|
2025-07-17 14:30:19 -05:00
|
|
|
public virtual string Decompile(DecompileContext context) => ToString();
|
2025-07-17 14:07:44 -05:00
|
|
|
|
2025-07-17 17:52:57 -05:00
|
|
|
public static Expression Wrap(object p)
|
2025-07-17 14:07:44 -05:00
|
|
|
{
|
|
|
|
|
return p switch
|
|
|
|
|
{
|
|
|
|
|
null => Constant(null),
|
|
|
|
|
Expression expr => expr,
|
|
|
|
|
Disassembler.RawConstantInfo constantInfo => new IrisConstantExpression(constantInfo.Value, constantInfo.Type),
|
2025-07-17 17:55:04 -05:00
|
|
|
Markup.SymbolReference symbolRef => Constant(symbolRef),
|
2025-07-17 14:07:44 -05:00
|
|
|
|
2025-07-17 17:52:57 -05:00
|
|
|
_ => throw new NotImplementedException($"Unable to wrap '{p}' in an expression")
|
2025-07-17 14:07:44 -05:00
|
|
|
};
|
|
|
|
|
}
|
2025-07-17 17:52:57 -05:00
|
|
|
|
|
|
|
|
public static string Decompile(Expression expr, DecompileContext context)
|
|
|
|
|
{
|
|
|
|
|
return expr is IrisExpression irisExpr
|
|
|
|
|
? irisExpr.Decompile(context)
|
|
|
|
|
: expr.ToString();
|
|
|
|
|
}
|
2025-07-17 00:46:05 -05:00
|
|
|
}
|