mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Support method calls on instances
This commit is contained in:
@@ -8,7 +8,7 @@ internal class IrisExpression : Expression
|
||||
{
|
||||
public virtual string Decompile(DecompileContext context) => ToString();
|
||||
|
||||
public static Expression ToExpression(object p)
|
||||
public static Expression Wrap(object p)
|
||||
{
|
||||
return p switch
|
||||
{
|
||||
@@ -16,7 +16,14 @@ internal class IrisExpression : Expression
|
||||
Expression expr => expr,
|
||||
Disassembler.RawConstantInfo constantInfo => new IrisConstantExpression(constantInfo.Value, constantInfo.Type),
|
||||
|
||||
_ => throw new NotImplementedException()
|
||||
_ => throw new NotImplementedException($"Unable to wrap '{p}' in an expression")
|
||||
};
|
||||
}
|
||||
|
||||
public static string Decompile(Expression expr, DecompileContext context)
|
||||
{
|
||||
return expr is IrisExpression irisExpr
|
||||
? irisExpr.Decompile(context)
|
||||
: expr.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,22 +33,23 @@ internal class IrisMethodCallExpression : IrisExpression, IArgumentProvider, IRe
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
||||
var qfn = context.GetQualifiedName(Method.Owner);
|
||||
sb.Append(qfn);
|
||||
if (Target is null)
|
||||
{
|
||||
var qfn = context.GetQualifiedName(Method.Owner);
|
||||
sb.Append(qfn);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(Decompile(Target, context));
|
||||
}
|
||||
|
||||
sb.Append('.');
|
||||
sb.Append(Method.Name);
|
||||
|
||||
sb.Append('(');
|
||||
|
||||
sb.Append(string.Join(", ", _arguments.Select(exprToString)));
|
||||
|
||||
sb.Append(string.Join(", ", _arguments.Select(x => Decompile(x, context))));
|
||||
sb.Append(')');
|
||||
return sb.ToString();
|
||||
|
||||
string exprToString(Expression x)
|
||||
{
|
||||
return x is IrisExpression irisExpr
|
||||
? irisExpr.Decompile(context)
|
||||
: x.ToString();
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user