33module FSharp.Compiler.AbstractIL.IL
44
55open FSharp.Compiler .IO
6+ open Internal.Utilities .Library
67
78#nowarn " 49"
89#nowarn " 343" // The type 'ILAssemblyRef' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'.
@@ -29,16 +30,14 @@ let _ =
2930 if logging then
3031 dprintn " * warning: Il.logging is on"
3132
32- let notlazy v = Lazy<_>. CreateFromValue v
33-
3433/// A little ugly, but the idea is that if a data structure does not
3534/// contain lazy values then we don't add laziness. So if the thing to map
3635/// is already evaluated then immediately apply the function.
37- let lazyMap f ( x : Lazy < _ >) =
36+ let lazyMap f ( x : InterruptibleLazy < _ >) =
3837 if x.IsValueCreated then
3938 notlazy ( f ( x.Force()))
4039 else
41- lazy ( f ( x.Force()))
40+ InterruptibleLazy ( fun _ -> f ( x.Force()))
4241
4342[<RequireQualifiedAccess>]
4443type PrimaryAssembly =
@@ -165,7 +164,7 @@ let splitTypeNameRight nm =
165164// --------------------------------------------------------------------
166165
167166/// This is used to store event, property and field maps.
168- type LazyOrderedMultiMap < 'Key , 'Data when 'Key: equality >( keyf : 'Data -> 'Key , lazyItems : Lazy < 'Data list >) =
167+ type LazyOrderedMultiMap < 'Key , 'Data when 'Key: equality >( keyf : 'Data -> 'Key , lazyItems : InterruptibleLazy < 'Data list >) =
169168
170169 let quickMap =
171170 lazyItems
@@ -1822,7 +1821,7 @@ type ILMethodVirtualInfo =
18221821
18231822[<RequireQualifiedAccess>]
18241823type MethodBody =
1825- | IL of Lazy < ILMethodBody >
1824+ | IL of InterruptibleLazy < ILMethodBody >
18261825 | PInvoke of Lazy < PInvokeMethod > (* platform invoke to native *)
18271826 | Abstract
18281827 | Native
@@ -1903,7 +1902,7 @@ type ILMethodDef
19031902 callingConv: ILCallingConv,
19041903 parameters: ILParameters,
19051904 ret: ILReturn,
1906- body: Lazy < MethodBody>,
1905+ body: InterruptibleLazy < MethodBody>,
19071906 isEntryPoint: bool,
19081907 genericParams: ILGenericParameterDefs,
19091908 securityDeclsStored: ILSecurityDeclsStored,
@@ -1962,7 +1961,7 @@ type ILMethodDef
19621961 ? callingConv : ILCallingConv ,
19631962 ? parameters : ILParameters ,
19641963 ? ret : ILReturn ,
1965- ? body : Lazy < MethodBody >,
1964+ ? body : InterruptibleLazy < MethodBody >,
19661965 ? securityDecls : ILSecurityDecls ,
19671966 ? isEntryPoint : bool ,
19681967 ? genericParams : ILGenericParameterDefs ,
@@ -2468,7 +2467,7 @@ type ILMethodImplDef =
24682467
24692468// Index table by name and arity.
24702469type ILMethodImplDefs =
2471- | ILMethodImpls of Lazy < MethodImplsMap >
2470+ | ILMethodImpls of InterruptibleLazy < MethodImplsMap >
24722471
24732472 member x.AsList () =
24742473 let ( ILMethodImpls ltab ) = x in Map.foldBack ( fun _x y r -> y @ r) ( ltab.Force()) []
@@ -2919,7 +2918,7 @@ type ILNestedExportedType =
29192918 override x.ToString () = " exported type " + x.Name
29202919
29212920and ILNestedExportedTypes =
2922- | ILNestedExportedTypes of Lazy < Map < string , ILNestedExportedType >>
2921+ | ILNestedExportedTypes of InterruptibleLazy < Map < string , ILNestedExportedType >>
29232922
29242923 member x.AsList () =
29252924 let ( ILNestedExportedTypes ltab ) = x in Map.foldBack ( fun _x y r -> y :: r) ( ltab.Force()) []
@@ -2943,7 +2942,7 @@ and [<NoComparison; NoEquality>] ILExportedTypeOrForwarder =
29432942 override x.ToString () = " exported type " + x.Name
29442943
29452944and ILExportedTypesAndForwarders =
2946- | ILExportedTypesAndForwarders of Lazy < Map < string , ILExportedTypeOrForwarder >>
2945+ | ILExportedTypesAndForwarders of InterruptibleLazy < Map < string , ILExportedTypeOrForwarder >>
29472946
29482947 member x.AsList () =
29492948 let ( ILExportedTypesAndForwarders ltab ) = x in Map.foldBack ( fun _x y r -> y :: r) ( ltab.Force()) []
@@ -3784,7 +3783,7 @@ let mkILMethodBody (initlocals, locals, maxstack, code, tag, imports) : ILMethod
37843783
37853784let mkMethodBody ( zeroinit , locals , maxstack , code , tag , imports ) =
37863785 let ilCode = mkILMethodBody ( zeroinit, locals, maxstack, code, tag, imports)
3787- MethodBody.IL( lazy ilCode)
3786+ MethodBody.IL( InterruptibleLazy.FromValue ilCode)
37883787
37893788// --------------------------------------------------------------------
37903789// Make a constructor
@@ -4098,7 +4097,7 @@ let mkILExportedTypes l =
40984097 ILExportedTypesAndForwarders( notlazy ( List.foldBack addExportedTypeToTable l Map.empty))
40994098
41004099let mkILExportedTypesLazy ( l : Lazy < _ >) =
4101- ILExportedTypesAndForwarders( lazy ( List.foldBack addExportedTypeToTable ( l.Force()) Map.empty))
4100+ ILExportedTypesAndForwarders( InterruptibleLazy ( fun _ -> List.foldBack addExportedTypeToTable ( l.Force()) Map.empty))
41024101
41034102let addNestedExportedTypeToTable ( y : ILNestedExportedType ) tab = Map.add y.Name y tab
41044103
@@ -4116,7 +4115,7 @@ let mkILNestedExportedTypes l =
41164115 ILNestedExportedTypes( notlazy ( List.foldBack addNestedExportedTypeToTable l Map.empty))
41174116
41184117let mkILNestedExportedTypesLazy ( l : Lazy < _ >) =
4119- ILNestedExportedTypes( lazy ( List.foldBack addNestedExportedTypeToTable ( l.Force()) Map.empty))
4118+ ILNestedExportedTypes( InterruptibleLazy ( fun _ -> List.foldBack addNestedExportedTypeToTable ( l.Force()) Map.empty))
41204119
41214120let mkILResources l = ILResources l
41224121let emptyILResources = ILResources []
@@ -4130,7 +4129,7 @@ let mkILMethodImpls l =
41304129 ILMethodImpls( notlazy ( List.foldBack addMethodImplToTable l Map.empty))
41314130
41324131let mkILMethodImplsLazy l =
4133- ILMethodImpls( lazy ( List.foldBack addMethodImplToTable ( Lazy.force l) Map.empty))
4132+ ILMethodImpls( InterruptibleLazy ( fun _ -> List.foldBack addMethodImplToTable ( Lazy.force l) Map.empty))
41344133
41354134let emptyILMethodImpls = mkILMethodImpls []
41364135
0 commit comments