mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
C#: Remove marker interfaces from CIL extraction
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An array type.
|
||||
/// </summary>
|
||||
internal sealed class ArrayType : Type, IArrayType
|
||||
internal sealed class ArrayType : Type
|
||||
{
|
||||
private readonly Type elementType;
|
||||
private readonly int rank;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An assembly to extract.
|
||||
/// </summary>
|
||||
public class Assembly : LabelledEntity, IAssembly
|
||||
public class Assembly : LabelledEntity, ILocation
|
||||
{
|
||||
private readonly File file;
|
||||
private readonly AssemblyName assemblyName;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// Entity representing a CIL attribute.
|
||||
/// </summary>
|
||||
internal sealed class Attribute : UnlabelledEntity, IAttribute
|
||||
internal sealed class Attribute : UnlabelledEntity
|
||||
{
|
||||
private readonly CustomAttributeHandle handle;
|
||||
private readonly CustomAttribute attrib;
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A definition method - a method defined in the current assembly.
|
||||
/// </summary>
|
||||
internal sealed class DefinitionMethod : Method, IMember
|
||||
internal sealed class DefinitionMethod : Method
|
||||
{
|
||||
private readonly Handle handle;
|
||||
private readonly MethodDefinition md;
|
||||
private readonly PDB.IMethod? methodDebugInformation;
|
||||
private readonly PDB.Method? methodDebugInformation;
|
||||
private readonly Type declaringType;
|
||||
|
||||
private readonly string name;
|
||||
@@ -120,7 +120,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
var jump_table = new Dictionary<int, IInstruction>();
|
||||
var jump_table = new Dictionary<int, Instruction>();
|
||||
|
||||
foreach (var c in Decode(body.GetILBytes(), jump_table))
|
||||
yield return c;
|
||||
@@ -178,7 +178,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IExtractionProduct> Decode(byte[] ilbytes, Dictionary<int, IInstruction> jump_table)
|
||||
private IEnumerable<IExtractionProduct> Decode(byte[] ilbytes, Dictionary<int, Instruction> jump_table)
|
||||
{
|
||||
// Sequence points are stored in order of offset.
|
||||
// We use an enumerator to locate the correct sequence point for each instruction.
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An event entity.
|
||||
/// </summary>
|
||||
internal sealed class Event : LabelledEntity, IEvent
|
||||
internal sealed class Event : LabelledEntity
|
||||
{
|
||||
private readonly EventDefinitionHandle handle;
|
||||
private readonly Type parent;
|
||||
|
||||
@@ -5,15 +5,15 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An exception region entity.
|
||||
/// </summary>
|
||||
internal class ExceptionRegion : UnlabelledEntity, IExceptionRegion
|
||||
internal class ExceptionRegion : UnlabelledEntity
|
||||
{
|
||||
private readonly GenericContext gc;
|
||||
private readonly MethodImplementation method;
|
||||
private readonly int index;
|
||||
private readonly System.Reflection.Metadata.ExceptionRegion r;
|
||||
private readonly Dictionary<int, IInstruction> jump_table;
|
||||
private readonly Dictionary<int, Instruction> jump_table;
|
||||
|
||||
public ExceptionRegion(GenericContext gc, MethodImplementation method, int index, System.Reflection.Metadata.ExceptionRegion r, Dictionary<int, IInstruction> jump_table) : base(gc.Cx)
|
||||
public ExceptionRegion(GenericContext gc, MethodImplementation method, int index, System.Reflection.Metadata.ExceptionRegion r, Dictionary<int, Instruction> jump_table) : base(gc.Cx)
|
||||
{
|
||||
this.gc = gc;
|
||||
this.method = method;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// An entity representing a field.
|
||||
/// </summary>
|
||||
internal abstract class Field : GenericContext, IField
|
||||
internal abstract class Field : GenericContext, IMember
|
||||
{
|
||||
protected Field(Context cx) : base(cx)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
public class File : LabelledEntity, IFile
|
||||
public class File : LabelledEntity, IFileOrFolder
|
||||
{
|
||||
protected string OriginalPath { get; }
|
||||
protected PathTransformer.ITransformedPath TransformedPath { get; }
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
public sealed class Folder : LabelledEntity, IFolder
|
||||
public sealed class Folder : LabelledEntity, IFileOrFolder
|
||||
{
|
||||
private readonly PathTransformer.ITransformedPath transformedPath;
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// An array type.
|
||||
/// </summary>
|
||||
internal interface IArrayType : IType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface IAssembly : ILocation
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A CIL attribute.
|
||||
/// </summary>
|
||||
internal interface IAttribute : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// An event.
|
||||
/// </summary>
|
||||
internal interface IEvent : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface IExceptionRegion : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// An entity representing a field.
|
||||
/// </summary>
|
||||
internal interface IField : IMember
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface IFile : IFileOrFolder
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface IFolder : IFileOrFolder
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A CIL instruction.
|
||||
/// </summary>
|
||||
internal interface IInstruction : IExtractedEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the extraction products for branches.
|
||||
/// </summary>
|
||||
/// <param name="jump_table">The map from offset to instruction.</param>
|
||||
/// <returns>The extraction products.</returns>
|
||||
IEnumerable<IExtractionProduct> JumpContents(Dictionary<int, IInstruction> jump_table);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface ILocal : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A method entity.
|
||||
/// </summary>
|
||||
internal interface IMethod : IMember
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A method implementation entity.
|
||||
/// </summary>
|
||||
internal interface IMethodImplementation : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A namespace.
|
||||
/// </summary>
|
||||
internal interface INamespace : ITypeContainer
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A parameter entity.
|
||||
/// </summary>
|
||||
internal interface IParameter : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface IPointerType : IType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A property.
|
||||
/// </summary>
|
||||
internal interface IProperty : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
public interface ISourceLocation : ILocation
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A type.
|
||||
/// </summary>
|
||||
internal interface IType : IEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// A type container (namespace/types/method).
|
||||
/// </summary>
|
||||
internal interface ITypeContainer : IExtractedEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal interface ITypeParameter : IType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A CIL instruction.
|
||||
/// </summary>
|
||||
internal class Instruction : UnlabelledEntity, IInstruction
|
||||
internal class Instruction : UnlabelledEntity, IEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// The additional data following the opcode, if any.
|
||||
@@ -433,10 +433,10 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
}
|
||||
|
||||
// Called to populate the jumps in each instruction.
|
||||
public IEnumerable<IExtractionProduct> JumpContents(Dictionary<int, IInstruction> jump_table)
|
||||
public IEnumerable<IExtractionProduct> JumpContents(Dictionary<int, Instruction> jump_table)
|
||||
{
|
||||
int target;
|
||||
IInstruction? inst;
|
||||
Instruction? inst;
|
||||
|
||||
switch (PayloadType)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal class LocalVariable : LabelledEntity, ILocal
|
||||
internal class LocalVariable : LabelledEntity
|
||||
{
|
||||
private readonly MethodImplementation method;
|
||||
private readonly int index;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A method entity.
|
||||
/// </summary>
|
||||
internal abstract class Method : TypeContainer, IMethod
|
||||
internal abstract class Method : TypeContainer, IMember
|
||||
{
|
||||
protected MethodTypeParameter[]? genericParams;
|
||||
protected GenericContext gc;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// A method implementation entity.
|
||||
/// In the database, the same method could in principle have multiple implementations.
|
||||
/// </summary>
|
||||
internal class MethodImplementation : UnlabelledEntity, IMethodImplementation
|
||||
internal class MethodImplementation : UnlabelledEntity
|
||||
{
|
||||
private readonly Method m;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A namespace.
|
||||
/// </summary>
|
||||
public sealed class Namespace : TypeContainer, INamespace
|
||||
public sealed class Namespace : TypeContainer
|
||||
{
|
||||
public Namespace? ParentNamespace { get; }
|
||||
public string Name { get; }
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A parameter entity.
|
||||
/// </summary>
|
||||
internal sealed class Parameter : LabelledEntity, IParameter
|
||||
internal sealed class Parameter : LabelledEntity
|
||||
{
|
||||
private readonly Method method;
|
||||
private readonly int index;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal sealed class PointerType : Type, IPointerType
|
||||
internal sealed class PointerType : Type
|
||||
{
|
||||
private readonly Type pointee;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A property.
|
||||
/// </summary>
|
||||
internal sealed class Property : LabelledEntity, IProperty
|
||||
internal sealed class Property : LabelledEntity
|
||||
{
|
||||
private readonly Handle handle;
|
||||
private readonly Type type;
|
||||
|
||||
@@ -4,7 +4,7 @@ using Semmle.Extraction.PDB;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
public sealed class PdbSourceLocation : LabelledEntity, ISourceLocation
|
||||
public sealed class PdbSourceLocation : LabelledEntity, ILocation
|
||||
{
|
||||
private readonly Location location;
|
||||
private readonly PdbSourceFile file;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// A type.
|
||||
/// </summary>
|
||||
public abstract class Type : TypeContainer, IMember, IType
|
||||
public abstract class Type : TypeContainer, IMember
|
||||
{
|
||||
public override string IdSuffix => ";cil-type";
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// <summary>
|
||||
/// Base class for all type containers (namespaces, types, methods).
|
||||
/// </summary>
|
||||
public abstract class TypeContainer : GenericContext, ITypeContainer
|
||||
public abstract class TypeContainer : GenericContext, IExtractedEntity
|
||||
{
|
||||
protected TypeContainer(Context cx) : base(cx)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.IO;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
internal abstract class TypeParameter : Type, ITypeParameter
|
||||
internal abstract class TypeParameter : Type
|
||||
{
|
||||
protected readonly GenericContext gc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user