diff --git a/WoofWare.PawPrint.Domain/TypeConcretisation.fs b/WoofWare.PawPrint.Domain/TypeConcretisation.fs index 757a666..5c83535 100644 --- a/WoofWare.PawPrint.Domain/TypeConcretisation.fs +++ b/WoofWare.PawPrint.Domain/TypeConcretisation.fs @@ -132,23 +132,6 @@ module ConcreteActivePatterns = | None -> None | _ -> None - let (|ConcreteBool|_|) (concreteTypes : AllConcreteTypes) (handle : ConcreteTypeHandle) : unit option = - match handle with - | ConcreteTypeHandle.Concrete id -> - match concreteTypes.Mapping |> Map.tryFind id with - | Some ct -> - if - ct.Assembly.Name = "System.Private.CoreLib" - && ct.Namespace = "System" - && ct.Name = "Boolean" - && ct.Generics.IsEmpty - then - Some () - else - None - | None -> None - | _ -> None - let (|ConcreteChar|_|) (concreteTypes : AllConcreteTypes) (handle : ConcreteTypeHandle) : unit option = match handle with | ConcreteTypeHandle.Concrete id -> @@ -166,6 +149,23 @@ module ConcreteActivePatterns = | None -> None | _ -> None + let (|ConcreteBool|_|) (concreteTypes : AllConcreteTypes) (handle : ConcreteTypeHandle) : unit option = + match handle with + | ConcreteTypeHandle.Concrete id -> + match concreteTypes.Mapping |> Map.tryFind id with + | Some ct -> + if + ct.Assembly.Name = "System.Private.CoreLib" + && ct.Namespace = "System" + && ct.Name = "Boolean" + && ct.Generics.IsEmpty + then + Some () + else + None + | None -> None + | _ -> None + let (|ConcreteString|_|) (concreteTypes : AllConcreteTypes) (handle : ConcreteTypeHandle) : unit option = match handle with | ConcreteTypeHandle.Concrete id -> diff --git a/WoofWare.PawPrint/Intrinsics.fs b/WoofWare.PawPrint/Intrinsics.fs index ce5a349..0d3438f 100644 --- a/WoofWare.PawPrint/Intrinsics.fs +++ b/WoofWare.PawPrint/Intrinsics.fs @@ -50,6 +50,11 @@ module Intrinsics = // https://github.com/dotnet/runtime/blob/108fa7856efcfd39bc991c2d849eabbf7ba5989c/src/coreclr/tools/Common/TypeSystem/IL/Stubs/UnsafeIntrinsics.cs#L192 match methodToCall.DeclaringType.Assembly.Name, methodToCall.DeclaringType.Name, methodToCall.Name with | "System.Private.CoreLib", "Type", "get_TypeHandle" -> + // TODO: check return type is RuntimeTypeHandle + match methodToCall.Signature.ParameterTypes with + | _ :: _ -> failwith "bad signature Type.get_TypeHandle" + | _ -> () + // https://github.com/dotnet/runtime/blob/ec11903827fc28847d775ba17e0cd1ff56cfbc2e/src/libraries/System.Private.CoreLib/src/System/Type.cs#L470 // TODO: check return type is RuntimeTypeHandle @@ -379,5 +384,8 @@ module Intrinsics = |> IlMachineState.pushToEvalStack (CliType.Numeric (CliNumericType.Int32 size)) currentThread |> IlMachineState.advanceProgramCounter currentThread |> Some + | "System.Private.CoreLib", "RuntimeHelpers", "CreateSpan" -> + // https://github.com/dotnet/runtime/blob/9e5e6aa7bc36aeb2a154709a9d1192030c30a2ef/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs#L153 + None | a, b, c -> failwith $"TODO: implement JIT intrinsic {a}.{b}.{c}" |> Option.map (fun s -> s.WithThreadSwitchedToAssembly callerAssy currentThread |> fst)