Added additional identifier constraints.
This commit is contained in:
parent
879da06b29
commit
dd0de0a75b
1 changed files with 25 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
namespace OpenTK.Rewrite
|
||||
{
|
||||
|
@ -8,36 +9,48 @@ namespace OpenTK.Rewrite
|
|||
/// </summary>
|
||||
public class GeneratedVariableIdentifier
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="MethodBody"/> which the variable is in.
|
||||
/// </summary>
|
||||
public MethodBody Body { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="VariableDefinition"/> which the variable idetifier maps to.
|
||||
/// </summary>
|
||||
public VariableDefinition Definition { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the generated variable.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The index of the generated variable in its method.
|
||||
/// </summary>
|
||||
public int Index { 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 (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(body));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentException("The name argument cannot be null or empty", nameof(name));
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ArgumentException("The index must be greater than zero.", nameof(index));
|
||||
}
|
||||
|
||||
this.Body = body;
|
||||
this.Definition = definition;
|
||||
this.Name = name;
|
||||
this.Index = index;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue