using System;
using Mono.Cecil.Cil;
namespace OpenTK.Rewrite
{
///
/// Acts as a unique identifier for a generated named variable that can be passed between methods. Replaces uses of
/// variable names from Mono.Cecil.
///
internal sealed class GeneratedVariableIdentifier
{
///
/// The which the variable is in.
///
public MethodBody Body { get; }
///
/// The which the variable idetifier maps to.
///
public VariableDefinition Definition { get; }
///
/// The name of the generated variable.
///
public string Name { get; }
///
/// Initializes a new instance of the class.
///
/// The method body which the variable is in.
/// The name of the generated variable.
/// The index of the generated variable in its method.
///
public GeneratedVariableIdentifier(MethodBody body, VariableDefinition definition, string name)
{
if (body == null)
{
throw new ArgumentException("The body argument cannot be null.", nameof(body));
}
if (definition == null)
{
throw new ArgumentException("The definition argument cannot be null.", nameof(definition));
}
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("The name argument cannot be null or empty", nameof(name));
}
this.Body = body;
this.Definition = definition;
this.Name = name;
}
}
}