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>2016-09-27 00:33:00 +0300
committerGitHub <noreply@github.com>2016-09-27 00:33:00 +0300
commit653859507b55fbe1ec29f4769b3bb56c6354204d (patch)
tree1292c6ca5da37f3f87bdcb67fe76c148e180c501 /src/ILCompiler.MetadataTransform
parente05cca67d48cf8d4afb167245271157ebc3755eb (diff)
Add function pointer types to the type system (#1920)
Even though these can't be expressed in C#, we still have a bunch of test collateral that exercises them. Instead of coming up with excuses as to why we should just ignore the tests every time it shows up, I decided to just implement this. Native metadata schema update and emission will follow later.
Diffstat (limited to 'src/ILCompiler.MetadataTransform')
-rw-r--r--src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.Type.cs2
-rw-r--r--src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.cs55
2 files changed, 39 insertions, 18 deletions
diff --git a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.Type.cs b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.Type.cs
index 5c094dc67..4178a4d60 100644
--- a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.Type.cs
+++ b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.Type.cs
@@ -53,6 +53,8 @@ namespace ILCompiler.Metadata
case Cts.TypeFlags.Pointer:
rec = _types.Create((Cts.PointerType)type, _initPointer ?? (_initPointer = InitializePointer));
break;
+ case Cts.TypeFlags.FunctionPointer:
+ throw new NotImplementedException();
case Cts.TypeFlags.SignatureTypeVariable:
rec = _types.Create((Cts.SignatureTypeVariable)type, _initTypeVar ?? (_initTypeVar = InitializeTypeVariable));
break;
diff --git a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.cs b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.cs
index a120cd859..3526c2c44 100644
--- a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.cs
+++ b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.cs
@@ -2,11 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using Internal.Metadata.NativeFormat.Writer;
-
using Cts = Internal.TypeSystem;
+using Debug = System.Diagnostics.Debug;
namespace ILCompiler.Metadata
{
@@ -28,25 +25,47 @@ namespace ILCompiler.Metadata
private bool IsBlocked(Cts.TypeDesc type)
{
- if (type.IsArray || type.IsByRef || type.IsPointer)
- return IsBlocked(((Cts.ParameterizedType)type).ParameterType);
+ switch (type.Category)
+ {
+ case Cts.TypeFlags.SzArray:
+ case Cts.TypeFlags.Array:
+ case Cts.TypeFlags.Pointer:
+ case Cts.TypeFlags.ByRef:
+ return IsBlocked(((Cts.ParameterizedType)type).ParameterType);
- if (type.IsSignatureVariable)
- return false;
+ case Cts.TypeFlags.SignatureMethodVariable:
+ case Cts.TypeFlags.SignatureTypeVariable:
+ return false;
- if (!type.IsTypeDefinition)
- {
- if (IsBlocked(type.GetTypeDefinition()))
- return true;
+ case Cts.TypeFlags.FunctionPointer:
+ {
+ Cts.MethodSignature pointerSignature = ((Cts.FunctionPointerType)type).Signature;
+ if (IsBlocked(pointerSignature.ReturnType))
+ return true;
+
+ for (int i = 0; i < pointerSignature.Length; i++)
+ if (IsBlocked(pointerSignature[i]))
+ return true;
+
+ return false;
+ }
+ default:
+ Debug.Assert(type.IsDefType);
+
+ if (!type.IsTypeDefinition)
+ {
+ if (IsBlocked(type.GetTypeDefinition()))
+ return true;
- foreach (var arg in type.Instantiation)
- if (IsBlocked(arg))
- return true;
+ foreach (var arg in type.Instantiation)
+ if (IsBlocked(arg))
+ return true;
- return false;
- }
+ return false;
+ }
- return _policy.IsBlocked((Cts.MetadataType)type);
+ return _policy.IsBlocked((Cts.MetadataType)type);
+ }
}
}
}