using System.Collections.Generic;
using System.Linq;
namespace Semmle.Extraction.CIL
{
///
/// When we decode a type/method signature, we need access to
/// generic parameters.
///
public abstract class GenericContext
{
public Context Cx { get; }
protected GenericContext(Context cx)
{
this.Cx = cx;
}
///
/// The list of generic type parameters, including type parameters of
/// containing types.
///
public abstract IEnumerable TypeParameters { get; }
///
/// The list of generic method parameters.
///
public abstract IEnumerable MethodParameters { get; }
///
/// Gets the `p`th type parameter.
///
/// The index of the parameter.
///
/// For constructed types, the supplied type.
/// For unbound types, the type parameter.
///
public Entities.Type GetGenericTypeParameter(int p)
{
return TypeParameters.ElementAt(p);
}
///
/// Gets the `p`th method type parameter.
///
/// The index of the parameter.
///
/// For constructed types, the supplied type.
/// For unbound types, the type parameter.
///
public Entities.Type GetGenericMethodParameter(int p)
{
return MethodParameters.ElementAt(p);
}
}
}