Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2015-12-16 01:08:55 +0300
committerMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2015-12-16 01:08:55 +0300
commited8a19c4c4741659df0212efad2ee0b371692901 (patch)
treeef56913307ef5437613f9b812ae86d35bfae574c /src/Common
parent803146ac12ed76bdb913016f36d76e89120c9c52 (diff)
parente328a377ba6d49d1e7d89dfb43ad37efe32f5d7e (diff)
Merge pull request #536 from MichalStrehovsky/moreTSFixes
More type system tweaks
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/src/TypeSystem/Common/GenericParameterDesc.cs15
-rw-r--r--src/Common/src/TypeSystem/Common/InstantiatedType.cs8
-rw-r--r--src/Common/src/TypeSystem/Common/MetadataType.cs5
-rw-r--r--src/Common/src/TypeSystem/Common/ModuleDesc.cs2
-rw-r--r--src/Common/src/TypeSystem/Ecma/EcmaField.cs2
-rw-r--r--src/Common/src/TypeSystem/Ecma/EcmaGenericParameter.cs27
-rw-r--r--src/Common/src/TypeSystem/Ecma/EcmaMethod.cs2
-rw-r--r--src/Common/src/TypeSystem/Ecma/EcmaType.cs32
8 files changed, 77 insertions, 16 deletions
diff --git a/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs b/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs
index b52ce0b8b..e159bf692 100644
--- a/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs
+++ b/src/Common/src/TypeSystem/Common/GenericParameterDesc.cs
@@ -3,7 +3,22 @@
namespace Internal.TypeSystem
{
+ public enum GenericParameterKind
+ {
+ Type,
+ Method,
+ }
+
public abstract partial class GenericParameterDesc : TypeDesc
{
+ /// <summary>
+ /// Gets a value indicating whether this is a type or method generic parameter.
+ /// </summary>
+ public abstract GenericParameterKind Kind { get; }
+
+ /// <summary>
+ /// Gets the zero based index of the generic parameter within the declaring type or method.
+ /// </summary>
+ public abstract int Index { get; }
}
}
diff --git a/src/Common/src/TypeSystem/Common/InstantiatedType.cs b/src/Common/src/TypeSystem/Common/InstantiatedType.cs
index 72aca7ee6..5b468a1fc 100644
--- a/src/Common/src/TypeSystem/Common/InstantiatedType.cs
+++ b/src/Common/src/TypeSystem/Common/InstantiatedType.cs
@@ -285,6 +285,14 @@ namespace Internal.TypeSystem
}
}
+ public override ModuleDesc Module
+ {
+ get
+ {
+ return _typeDef.Module;
+ }
+ }
+
public override bool HasCustomAttribute(string attributeNamespace, string attributeName)
{
return _typeDef.HasCustomAttribute(attributeNamespace, attributeName);
diff --git a/src/Common/src/TypeSystem/Common/MetadataType.cs b/src/Common/src/TypeSystem/Common/MetadataType.cs
index 0acd42d7a..dbf120e7e 100644
--- a/src/Common/src/TypeSystem/Common/MetadataType.cs
+++ b/src/Common/src/TypeSystem/Common/MetadataType.cs
@@ -66,6 +66,11 @@ namespace Internal.TypeSystem
public abstract bool IsModuleType { get; }
/// <summary>
+ /// Gets the module that defines this type.
+ /// </summary>
+ public abstract ModuleDesc Module { get; }
+
+ /// <summary>
/// Same as <see cref="TypeDesc.BaseType"/>, but the result is a MetadataType (avoids casting).
/// </summary>
public abstract MetadataType MetadataBaseType { get; }
diff --git a/src/Common/src/TypeSystem/Common/ModuleDesc.cs b/src/Common/src/TypeSystem/Common/ModuleDesc.cs
index 6d60c4373..22341abb5 100644
--- a/src/Common/src/TypeSystem/Common/ModuleDesc.cs
+++ b/src/Common/src/TypeSystem/Common/ModuleDesc.cs
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using System.Reflection;
-
namespace Internal.TypeSystem
{
public abstract partial class ModuleDesc
diff --git a/src/Common/src/TypeSystem/Ecma/EcmaField.cs b/src/Common/src/TypeSystem/Ecma/EcmaField.cs
index 45e6577b6..94681aa3d 100644
--- a/src/Common/src/TypeSystem/Ecma/EcmaField.cs
+++ b/src/Common/src/TypeSystem/Ecma/EcmaField.cs
@@ -73,7 +73,7 @@ namespace Internal.TypeSystem.Ecma
{
get
{
- return _type.Module;
+ return _type.EcmaModule;
}
}
diff --git a/src/Common/src/TypeSystem/Ecma/EcmaGenericParameter.cs b/src/Common/src/TypeSystem/Ecma/EcmaGenericParameter.cs
index 389a319f6..ccd8032c2 100644
--- a/src/Common/src/TypeSystem/Ecma/EcmaGenericParameter.cs
+++ b/src/Common/src/TypeSystem/Ecma/EcmaGenericParameter.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
using System.Reflection.Metadata;
using Internal.NativeFormat;
@@ -61,6 +62,32 @@ namespace Internal.TypeSystem.Ecma
}
}
+ public override GenericParameterKind Kind
+ {
+ get
+ {
+ GenericParameter parameter = _module.MetadataReader.GetGenericParameter(_handle);
+ if (parameter.Parent.Kind == HandleKind.MethodDefinition)
+ {
+ return GenericParameterKind.Method;
+ }
+ else
+ {
+ Debug.Assert(parameter.Parent.Kind == HandleKind.TypeDefinition);
+ return GenericParameterKind.Type;
+ }
+ }
+ }
+
+ public override int Index
+ {
+ get
+ {
+ GenericParameter parameter = _module.MetadataReader.GetGenericParameter(_handle);
+ return parameter.Index;
+ }
+ }
+
#if CCIGLUE
public TypeDesc DefiningType
{
diff --git a/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs b/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs
index 6775148a0..aac228fbd 100644
--- a/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs
+++ b/src/Common/src/TypeSystem/Ecma/EcmaMethod.cs
@@ -96,7 +96,7 @@ namespace Internal.TypeSystem.Ecma
{
get
{
- return _type.Module;
+ return _type.EcmaModule;
}
}
diff --git a/src/Common/src/TypeSystem/Ecma/EcmaType.cs b/src/Common/src/TypeSystem/Ecma/EcmaType.cs
index a577ad42f..f52cc9970 100644
--- a/src/Common/src/TypeSystem/Ecma/EcmaType.cs
+++ b/src/Common/src/TypeSystem/Ecma/EcmaType.cs
@@ -96,7 +96,7 @@ namespace Internal.TypeSystem.Ecma
int i = 0;
foreach (var genericParameterHandle in genericParameterHandles)
{
- genericParameters[i++] = new EcmaGenericParameter(this.Module, genericParameterHandle);
+ genericParameters[i++] = new EcmaGenericParameter(_module, genericParameterHandle);
}
Interlocked.CompareExchange(ref _genericParameters, genericParameters, null);
}
@@ -116,7 +116,15 @@ namespace Internal.TypeSystem.Ecma
}
}
- public EcmaModule Module
+ public override ModuleDesc Module
+ {
+ get
+ {
+ return _module;
+ }
+ }
+
+ public EcmaModule EcmaModule
{
get
{
@@ -257,7 +265,7 @@ namespace Internal.TypeSystem.Ecma
{
foreach (var handle in _typeDefinition.GetMethods())
{
- yield return (MethodDesc)this.Module.GetObject(handle);
+ yield return (MethodDesc)_module.GetObject(handle);
}
}
@@ -270,7 +278,7 @@ namespace Internal.TypeSystem.Ecma
{
if (stringComparer.Equals(metadataReader.GetMethodDefinition(handle).Name, name))
{
- MethodDesc method = (MethodDesc)this.Module.GetObject(handle);
+ MethodDesc method = (MethodDesc)_module.GetObject(handle);
if (signature == null || signature.Equals(method.Signature))
return method;
}
@@ -290,7 +298,7 @@ namespace Internal.TypeSystem.Ecma
if ((methodDefinition.Attributes & MethodAttributes.SpecialName) != 0 &&
stringComparer.Equals(methodDefinition.Name, ".cctor"))
{
- MethodDesc method = (MethodDesc)this.Module.GetObject(handle);
+ MethodDesc method = (MethodDesc)_module.GetObject(handle);
return method;
}
}
@@ -328,7 +336,7 @@ namespace Internal.TypeSystem.Ecma
{
foreach (var handle in _typeDefinition.GetFields())
{
- var field = (EcmaField)this.Module.GetObject(handle);
+ var field = (EcmaField)_module.GetObject(handle);
yield return field;
}
}
@@ -342,7 +350,7 @@ namespace Internal.TypeSystem.Ecma
{
if (stringComparer.Equals(metadataReader.GetFieldDefinition(handle).Name, name))
{
- var field = (EcmaField)this.Module.GetObject(handle);
+ var field = (EcmaField)_module.GetObject(handle);
return field;
}
}
@@ -354,7 +362,7 @@ namespace Internal.TypeSystem.Ecma
{
foreach (var handle in _typeDefinition.GetNestedTypes())
{
- yield return (MetadataType)this.Module.GetObject(handle);
+ yield return (MetadataType)_module.GetObject(handle);
}
}
@@ -366,7 +374,7 @@ namespace Internal.TypeSystem.Ecma
foreach (var handle in _typeDefinition.GetNestedTypes())
{
if (stringComparer.Equals(metadataReader.GetTypeDefinition(handle).Name, name))
- return (MetadataType)this.Module.GetObject(handle);
+ return (MetadataType)_module.GetObject(handle);
}
return null;
@@ -400,7 +408,7 @@ namespace Internal.TypeSystem.Ecma
public override string ToString()
{
- return "[" + Module.GetName().Name + "]" + this.GetFullName();
+ return "[" + _module.GetName().Name + "]" + this.GetFullName();
}
public override ClassLayoutMetadata GetClassLayout()
@@ -439,7 +447,7 @@ namespace Internal.TypeSystem.Ecma
// to FieldAndOffset.InvalidOffset.
Debug.Assert(FieldAndOffset.InvalidOffset == -1);
result.Offsets[index] =
- new FieldAndOffset((FieldDesc)this.Module.GetObject(handle), fieldDefinition.GetOffset());
+ new FieldAndOffset((FieldDesc)_module.GetObject(handle), fieldDefinition.GetOffset());
index++;
}
@@ -478,7 +486,7 @@ namespace Internal.TypeSystem.Ecma
{
get
{
- return Module.GetGlobalModuleType() == this;
+ return _module.GetGlobalModuleType() == this;
}
}