diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2016-09-20 19:51:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-20 19:51:43 +0300 |
commit | f81a8add885da6492bb16306fa22230fa6cc3c99 (patch) | |
tree | f765d0ffc7fa014086b93ea453e3a9e969215f5d | |
parent | df8a73cade72e7972662da657208f25269a0758b (diff) |
Add TypeSystemEntity as a root type in the type system (#1880)
In my shared generics work there are some spots where we carry a method or a type. In those places I have to type things as `object`, which is unfortunate. Having a common root type would make things at least a bit less gross.
There's also at least one spot where I would like to ask about the type system context the object-typed thing is associated with - this makes that part clean.
-rw-r--r-- | src/Common/src/TypeSystem/Common/FieldDesc.cs | 7 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Common/MethodDesc.cs | 10 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Common/ModuleDesc.cs | 8 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Common/TypeDesc.cs | 10 | ||||
-rw-r--r-- | src/Common/src/TypeSystem/Common/TypeSystemEntity.cs | 14 | ||||
-rw-r--r-- | src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj | 3 |
6 files changed, 22 insertions, 30 deletions
diff --git a/src/Common/src/TypeSystem/Common/FieldDesc.cs b/src/Common/src/TypeSystem/Common/FieldDesc.cs index e7478d7e7..ce491302d 100644 --- a/src/Common/src/TypeSystem/Common/FieldDesc.cs +++ b/src/Common/src/TypeSystem/Common/FieldDesc.cs @@ -9,7 +9,7 @@ using Debug = System.Diagnostics.Debug; namespace Internal.TypeSystem { - public abstract partial class FieldDesc + public abstract partial class FieldDesc : TypeSystemEntity { public readonly static FieldDesc[] EmptyFields = new FieldDesc[0]; @@ -34,11 +34,6 @@ namespace Internal.TypeSystem } } - public abstract TypeSystemContext Context - { - get; - } - public abstract DefType OwningType { get; diff --git a/src/Common/src/TypeSystem/Common/MethodDesc.cs b/src/Common/src/TypeSystem/Common/MethodDesc.cs index 7dff64b57..d732de343 100644 --- a/src/Common/src/TypeSystem/Common/MethodDesc.cs +++ b/src/Common/src/TypeSystem/Common/MethodDesc.cs @@ -209,7 +209,7 @@ namespace Internal.TypeSystem /// <summary> /// Represents the fundamental base type for all methods within the type system. /// </summary> - public abstract partial class MethodDesc + public abstract partial class MethodDesc : TypeSystemEntity { public readonly static MethodDesc[] EmptyMethods = new MethodDesc[0]; @@ -261,14 +261,6 @@ namespace Internal.TypeSystem } /// <summary> - /// Gets the type system context this method belongs to. - /// </summary> - public abstract TypeSystemContext Context - { - get; - } - - /// <summary> /// Gets the type that owns this method. This will be a <see cref="DefType"/> or /// an <see cref="ArrayType"/>. /// </summary> diff --git a/src/Common/src/TypeSystem/Common/ModuleDesc.cs b/src/Common/src/TypeSystem/Common/ModuleDesc.cs index 78b9f0a32..4d06abb7a 100644 --- a/src/Common/src/TypeSystem/Common/ModuleDesc.cs +++ b/src/Common/src/TypeSystem/Common/ModuleDesc.cs @@ -6,15 +6,11 @@ using System.Collections.Generic; namespace Internal.TypeSystem { - public abstract partial class ModuleDesc + public abstract partial class ModuleDesc : TypeSystemEntity { - /// <summary> - /// Gets the type system context the module belongs to. - /// </summary> - public TypeSystemContext Context + public override TypeSystemContext Context { get; - private set; } public ModuleDesc(TypeSystemContext context) diff --git a/src/Common/src/TypeSystem/Common/TypeDesc.cs b/src/Common/src/TypeSystem/Common/TypeDesc.cs index aaafd8080..42c5e5781 100644 --- a/src/Common/src/TypeSystem/Common/TypeDesc.cs +++ b/src/Common/src/TypeSystem/Common/TypeDesc.cs @@ -12,7 +12,7 @@ namespace Internal.TypeSystem /// <summary> /// Represents the fundamental base type of all types within the type system. /// </summary> - public abstract partial class TypeDesc + public abstract partial class TypeDesc : TypeSystemEntity { public static readonly TypeDesc[] EmptyTypes = new TypeDesc[0]; @@ -47,14 +47,6 @@ namespace Internal.TypeSystem private TypeFlags _typeFlags; /// <summary> - /// Gets the type system context this type belongs to. - /// </summary> - public abstract TypeSystemContext Context - { - get; - } - - /// <summary> /// Gets the generic instantiation information of this type. /// For generic definitions, retrieves the generic parameters of the type. /// For generic instantiation, retrieves the generic arguments of the type. diff --git a/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs b/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs new file mode 100644 index 000000000..ad3d3739d --- /dev/null +++ b/src/Common/src/TypeSystem/Common/TypeSystemEntity.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Internal.TypeSystem +{ + public abstract class TypeSystemEntity + { + /// <summary> + /// Gets the type system context this entity belongs to. + /// </summary> + public abstract TypeSystemContext Context { get; } + } +} diff --git a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj index 9e4b9a66b..66d960978 100644 --- a/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj +++ b/src/ILCompiler.TypeSystem/src/ILCompiler.TypeSystem.csproj @@ -92,6 +92,9 @@ <Compile Include="..\..\Common\src\TypeSystem\Common\ModuleDesc.cs"> <Link>TypeSystem\Common\ModuleDesc.cs</Link> </Compile> + <Compile Include="..\..\Common\src\TypeSystem\Common\TypeSystemEntity.cs"> + <Link>TypeSystem\Common\TypeSystemEntity.cs</Link> + </Compile> <Compile Include="..\..\Common\src\TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs"> <Link>Utilities\CustomAttributeTypeNameParser.cs</Link> </Compile> |