mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-08 15:38:41 +00:00
Recognise JIT intrinsics (#54)
This commit is contained in:
@@ -3,6 +3,7 @@ namespace WoofWare.PawPrint
|
||||
#nowarn "9"
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.Collections.Immutable
|
||||
open System.Reflection
|
||||
open System.Reflection.Metadata
|
||||
@@ -214,6 +215,28 @@ type MethodInfo<'typeGenerics, 'methodGenerics
|
||||
member this.IsPinvokeImpl : bool =
|
||||
this.MethodAttributes.HasFlag MethodAttributes.PinvokeImpl
|
||||
|
||||
member this.IsJITIntrinsic
|
||||
(getMemberRefParentType : MemberReferenceHandle -> TypeRef)
|
||||
(methodDefs : IReadOnlyDictionary<MethodDefinitionHandle, MethodInfo<FakeUnit, GenericParameter>>)
|
||||
: bool
|
||||
=
|
||||
this.CustomAttributes
|
||||
|> Seq.exists (fun attr ->
|
||||
match attr.Constructor with
|
||||
| MetadataToken.MethodDef handle ->
|
||||
let constructor = methodDefs.[handle]
|
||||
|
||||
constructor.DeclaringType.Name = "IntrinsicAttribute"
|
||||
&& constructor.DeclaringType.Assembly.FullName.StartsWith (
|
||||
"System.Private.CoreLib, ",
|
||||
StringComparison.Ordinal
|
||||
)
|
||||
| MetadataToken.MemberReference handle ->
|
||||
let ty = getMemberRefParentType handle
|
||||
ty.Namespace = "System" && ty.Name = "IntrinsicAttribute"
|
||||
| con -> failwith $"TODO: {con}"
|
||||
)
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module MethodInfo =
|
||||
let mapTypeGenerics<'a, 'b, 'methodGen
|
||||
|
Reference in New Issue
Block a user