Move common decompiler state to new class

This commit is contained in:
Yoshi Askharoun
2025-07-17 14:30:19 -05:00
parent 109c44e8eb
commit 27086b73a8
6 changed files with 212 additions and 181 deletions
@@ -19,10 +19,10 @@ internal class IrisConstantExpression : IrisExpression, IReturnValueProvider
public TypeSchema ReturnType => TypeSchema;
public override string Decompile(Decompiler decompiler)
public override string Decompile(DecompileContext context)
{
if (TypeSchema.IsEnum)
return $"{decompiler.GetQualifiedName(TypeSchema)}.{Value}";
return $"{context.GetQualifiedName(TypeSchema)}.{Value}";
return Value switch
{
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Microsoft.Iris.DecompXml.Mock;
internal class IrisExpression : Expression
{
public virtual string Decompile(Decompiler decompiler) => ToString();
public virtual string Decompile(DecompileContext context) => ToString();
public static Expression ToExpression(object p)
{
@@ -29,11 +29,11 @@ internal class IrisMethodCallExpression : IrisExpression, IArgumentProvider, IRe
public Expression GetArgument(int index) => _arguments[index];
public override string Decompile(Decompiler decompiler)
public override string Decompile(DecompileContext context)
{
StringBuilder sb = new();
var qfn = decompiler.GetQualifiedName(Method.Owner);
var qfn = context.GetQualifiedName(Method.Owner);
sb.Append(qfn);
sb.Append('.');
sb.Append(Method.Name);
@@ -47,7 +47,7 @@ internal class IrisMethodCallExpression : IrisExpression, IArgumentProvider, IRe
string exprToString(Expression x)
{
return x is IrisExpression irisExpr
? irisExpr.Decompile(decompiler)
? irisExpr.Decompile(context)
: x.ToString();
}
}
+2 -6
View File
@@ -1,15 +1,11 @@
using Microsoft.Iris.Asm;
using Microsoft.Iris.Markup;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Microsoft.Iris.DecompXml.Mock;
internal record IrisObject(object Object, TypeSchema Type)
{
public static IrisObject Create(object objIn, TypeSchema type, Decompiler decompiler)
public static IrisObject Create(object objIn, TypeSchema type, DecompileContext context)
{
object obj = objIn;
@@ -31,7 +27,7 @@ internal record IrisObject(object Object, TypeSchema Type)
type ??= hasReturnValue.ReturnType;
}
type ??= Disassembler.GuessTypeSchema(obj.GetType(), decompiler._loadResult);
type ??= Disassembler.GuessTypeSchema(obj.GetType(), context.LoadResult);
return new(obj, type);
}