using System;
+using Mono.Cecil.Cil;
namespace OpenTK.Rewrite
{
public class GeneratedVariableIdentifier
{
/// <summary>
- /// The name of the generated variable.
+ /// The <see cref="MethodBody"/> which the variable is in.
/// </summary>
- public string Name { get; }
+ public MethodBody Body { get; }
/// <summary>
- /// The index of the generated variable in its method.
+ /// The <see cref="VariableDefinition"/> which the variable idetifier maps to.
+ /// </summary>
+ public VariableDefinition Definition { get; }
+
+ /// <summary>
+ /// The name of the generated variable.
/// </summary>
- public int Index { get; }
+ public string Name { get; }
/// <summary>
/// Initializes a new instance of the <see cref="GeneratedVariableIdentifier"/> class.
/// </summary>
+ /// <param name="body">The method body which the variable is in.</param>
/// <param name="name">The name of the generated variable.</param>
/// <param name="index">The index of the generated variable in its method.</param>
/// <exception cref="ArgumentException"></exception>
- public GeneratedVariableIdentifier(string name, int index)
+ public GeneratedVariableIdentifier(MethodBody body, VariableDefinition definition, string name)
{
- if (string.IsNullOrEmpty(name))
+ if (body == null)
{
- throw new ArgumentException("The name argument cannot be null or empty", nameof(name));
+ throw new ArgumentException("The body argument cannot be null.", nameof(body));
}
- if (index < 0)
+ if (definition == null)
{
- throw new ArgumentException("The index must be greater than zero.", nameof(index));
+ throw new ArgumentException("The definition argument cannot be null.", nameof(body));
}
-
+
+ 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;
- this.Index = index;
}
}
}
\ No newline at end of file