Files
Torch/Torch/Managers/PatchManager/MSIL/MsilLocal.cs
2023-02-08 21:00:21 +07:00

67 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
namespace Torch.Managers.PatchManager.MSIL
{
/// <summary>
/// Represents metadata about a method's local
/// </summary>
public class MsilLocal
{
internal LocalBuilder Local { get; }
/// <summary>
/// The index of this local.
/// </summary>
public int Index { get; }
/// <summary>
/// The type of this local, or null if unknown.
/// </summary>
public Type Type { get; }
/// <summary>
/// The name of this local, or null if unknown.
/// </summary>
public string Name { get; }
internal MsilLocal(LocalBuilder local)
{
Local = local;
Index = local.LocalIndex;
Type = local.LocalType;
Name = null;
}
internal MsilLocal(LocalVariableInfo local)
{
Index = local.LocalIndex;
Type = local.LocalType;
Name = null;
}
/// <summary>
/// Creates an empty local reference with the given index.
/// </summary>
/// <param name="index">The local's index</param>
public MsilLocal(int index)
{
Index = index;
Type = null;
Name = null;
}
/// <inheritdoc/>
public override string ToString()
{
return $"lcl{Index:X4}({Type?.Name ?? "unknown"})";
}
}
}