mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
C#: Separate all classes to dedicated files in CIL extractor
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
@@ -116,69 +115,4 @@ namespace Semmle.Extraction.CIL
|
||||
return Pdb?.GetMethod(handle.ToDebugInformationHandle());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we decode a type/method signature, we need access to
|
||||
/// generic parameters.
|
||||
/// </summary>
|
||||
public abstract class GenericContext
|
||||
{
|
||||
public Context Cx { get; }
|
||||
|
||||
protected GenericContext(Context cx)
|
||||
{
|
||||
this.Cx = cx;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list of generic type parameters, including type parameters of
|
||||
/// containing types.
|
||||
/// </summary>
|
||||
public abstract IEnumerable<Entities.Type> TypeParameters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of generic method parameters.
|
||||
/// </summary>
|
||||
public abstract IEnumerable<Entities.Type> MethodParameters { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the `p`th type parameter.
|
||||
/// </summary>
|
||||
/// <param name="p">The index of the parameter.</param>
|
||||
/// <returns>
|
||||
/// For constructed types, the supplied type.
|
||||
/// For unbound types, the type parameter.
|
||||
/// </returns>
|
||||
public Entities.Type GetGenericTypeParameter(int p)
|
||||
{
|
||||
return TypeParameters.ElementAt(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the `p`th method type parameter.
|
||||
/// </summary>
|
||||
/// <param name="p">The index of the parameter.</param>
|
||||
/// <returns>
|
||||
/// For constructed types, the supplied type.
|
||||
/// For unbound types, the type parameter.
|
||||
/// </returns>
|
||||
public Entities.Type GetGenericMethodParameter(int p)
|
||||
{
|
||||
return MethodParameters.ElementAt(p);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A generic context which does not contain any type parameters.
|
||||
/// </summary>
|
||||
public class EmptyContext : GenericContext
|
||||
{
|
||||
public EmptyContext(Context cx) : base(cx)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEnumerable<Entities.Type> TypeParameters { get { yield break; } }
|
||||
|
||||
public override IEnumerable<Entities.Type> MethodParameters { get { yield break; } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user