@@ -66,10 +66,6 @@ type PrimaryAssembly =
6666 | Mscorlib -> " mscorlib"
6767 | System_ Runtime -> " System.Runtime"
6868 | NetStandard -> " netstandard"
69- static member IsSomePrimaryAssembly n =
70- n = PrimaryAssembly.Mscorlib.Name
71- || n = PrimaryAssembly.System_ Runtime.Name
72- || n = PrimaryAssembly.NetStandard.Name
7369
7470// --------------------------------------------------------------------
7571// Utilities: type names
@@ -373,6 +369,7 @@ let isMscorlib data =
373369[<Sealed>]
374370type ILAssemblyRef ( data ) =
375371 let uniqueStamp = AssemblyRefUniqueStampGenerator.Encode data
372+ let uniqueIgnoringVersionStamp = AssemblyRefUniqueStampGenerator.Encode { data with assemRefVersion = None }
376373
377374 member x.Name = data.assemRefName
378375
@@ -388,6 +385,11 @@ type ILAssemblyRef(data) =
388385
389386 member x.UniqueStamp = uniqueStamp
390387
388+ member x.UniqueIgnoringVersionStamp = uniqueIgnoringVersionStamp
389+
390+ member x.EqualsIgnoringVersion ( aref : ILAssemblyRef ) =
391+ aref.UniqueIgnoringVersionStamp = uniqueIgnoringVersionStamp
392+
391393 override x.GetHashCode () = uniqueStamp
392394
393395 override x.Equals yobj = (( yobj :?> ILAssemblyRef) .UniqueStamp = uniqueStamp)
@@ -490,6 +492,7 @@ type ILScopeRef =
490492 | Local
491493 | Module of ILModuleRef
492494 | Assembly of ILAssemblyRef
495+ | PrimaryAssembly
493496
494497 member x.IsLocalRef = match x with ILScopeRef.Local -> true | _ -> false
495498
@@ -498,6 +501,7 @@ type ILScopeRef =
498501 | ILScopeRef.Local -> " "
499502 | ILScopeRef.Module mref -> " module " + mref.Name
500503 | ILScopeRef.Assembly aref -> aref.QualifiedName
504+ | ILScopeRef.PrimaryAssembly -> " "
501505
502506type ILArrayBound = int32 option
503507
@@ -2193,6 +2197,11 @@ and ILExportedTypesAndForwarders =
21932197
21942198 member x.AsList = let ( ILExportedTypesAndForwarders ltab ) = x in Map.foldBack ( fun _x y r -> y :: r) ( ltab.Force()) []
21952199
2200+ member x.TryFindByName nm =
2201+ match x with
2202+ | ILExportedTypesAndForwarders ltab ->
2203+ ltab.Value.TryFind nm
2204+
21962205[<RequireQualifiedAccess>]
21972206type ILResourceAccess =
21982207 | Public
@@ -2593,62 +2602,55 @@ let tname_IntPtr = "System.IntPtr"
25932602[<Literal>]
25942603let tname_UIntPtr = " System.UIntPtr"
25952604
2605+ [<Literal>]
2606+ let tname_TypedReference = " System.TypedReference"
2607+
25962608[<NoEquality; NoComparison; StructuredFormatDisplay( " {DebugText}" ) >]
2597- // This data structure needs an entirely delayed implementation
2598- type ILGlobals ( primaryScopeRef ) =
2599-
2600- let m_mkSysILTypeRef nm = mkILTyRef ( primaryScopeRef, nm)
2601-
2602- let m_typ_Object = mkILBoxedType ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Object))
2603- let m_typ_String = mkILBoxedType ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ String))
2604- let m_typ_Array = mkILBoxedType ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Array))
2605- let m_typ_Type = mkILBoxedType ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Type))
2606- let m_typ_SByte = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ SByte))
2607- let m_typ_Int16 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Int16))
2608- let m_typ_Int32 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Int32))
2609- let m_typ_Int64 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Int64))
2610- let m_typ_Byte = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Byte))
2611- let m_typ_UInt16 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ UInt16))
2612- let m_typ_UInt32 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ UInt32))
2613- let m_typ_UInt64 = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ UInt64))
2614- let m_typ_Single = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Single))
2615- let m_typ_Double = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Double))
2616- let m_typ_Bool = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Bool))
2617- let m_typ_Char = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ Char))
2618- let m_typ_IntPtr = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ IntPtr))
2619- let m_typ_UIntPtr = ILType.Value ( mkILNonGenericTySpec ( m_ mkSysILTypeRef tname_ UIntPtr))
2620-
2621- member x.primaryAssemblyScopeRef = m_ typ_ Object.TypeRef.Scope
2622- member x.primaryAssemblyName =
2623- match m_ typ_ Object.TypeRef.Scope with
2624- | ILScopeRef.Assembly aref -> aref.Name
2609+ type ILGlobals ( primaryScopeRef : ILScopeRef , assembliesThatForwardToPrimaryAssembly : ILAssemblyRef list ) =
2610+
2611+ let assembliesThatForwardToPrimaryAssembly = Array.ofList assembliesThatForwardToPrimaryAssembly
2612+
2613+ let mkSysILTypeRef nm = mkILTyRef ( primaryScopeRef, nm)
2614+
2615+ member _.primaryAssemblyScopeRef = primaryScopeRef
2616+ member x.primaryAssemblyRef =
2617+ match primaryScopeRef with
2618+ | ILScopeRef.Assembly aref -> aref
26252619 | _ -> failwith " Invalid primary assembly"
2626- member x.typ_Object = m_ typ_ Object
2627- member x.typ_String = m_ typ_ String
2628- member x.typ_Array = m_ typ_ Array
2629- member x.typ_Type = m_ typ_ Type
2630- member x.typ_IntPtr = m_ typ_ IntPtr
2631- member x.typ_UIntPtr = m_ typ_ UIntPtr
2632- member x.typ_Byte = m_ typ_ Byte
2633- member x.typ_Int16 = m_ typ_ Int16
2634- member x.typ_Int32 = m_ typ_ Int32
2635- member x.typ_Int64 = m_ typ_ Int64
2636- member x.typ_SByte = m_ typ_ SByte
2637- member x.typ_UInt16 = m_ typ_ UInt16
2638- member x.typ_UInt32 = m_ typ_ UInt32
2639- member x.typ_UInt64 = m_ typ_ UInt64
2640- member x.typ_Single = m_ typ_ Single
2641- member x.typ_Double = m_ typ_ Double
2642- member x.typ_Bool = m_ typ_ Bool
2643- member x.typ_Char = m_ typ_ Char
2620+ member x.primaryAssemblyName = x.primaryAssemblyRef.Name
2621+
2622+ member val typ_Object = mkILBoxedType ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Object))
2623+ member val typ_String = mkILBoxedType ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ String))
2624+ member val typ_Array = mkILBoxedType ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Array))
2625+ member val typ_Type = mkILBoxedType ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Type))
2626+ member val typ_SByte = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ SByte))
2627+ member val typ_Int16 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Int16))
2628+ member val typ_Int32 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Int32))
2629+ member val typ_Int64 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Int64))
2630+ member val typ_Byte = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Byte))
2631+ member val typ_UInt16 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ UInt16))
2632+ member val typ_UInt32 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ UInt32))
2633+ member val typ_UInt64 = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ UInt64))
2634+ member val typ_Single = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Single))
2635+ member val typ_Double = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Double))
2636+ member val typ_Bool = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Bool))
2637+ member val typ_Char = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ Char))
2638+ member val typ_IntPtr = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ IntPtr))
2639+ member val typ_UIntPtr = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ UIntPtr))
2640+ member val typ_TypedReference = ILType.Value ( mkILNonGenericTySpec ( mkSysILTypeRef tname_ TypedReference))
2641+
2642+ member x.IsPossiblePrimaryAssemblyRef ( aref : ILAssemblyRef ) =
2643+ aref.EqualsIgnoringVersion x.primaryAssemblyRef ||
2644+ assembliesThatForwardToPrimaryAssembly
2645+ |> Array.exists aref.EqualsIgnoringVersion
26442646
26452647 /// For debugging
26462648 [<DebuggerBrowsable( DebuggerBrowsableState.Never) >]
26472649 member x.DebugText = x.ToString()
26482650
26492651 override x.ToString () = " <ILGlobals>"
26502652
2651- let mkILGlobals primaryScopeRef = ILGlobals primaryScopeRef
2653+ let mkILGlobals ( primaryScopeRef , assembliesThatForwardToPrimaryAssembly ) = ILGlobals ( primaryScopeRef, assembliesThatForwardToPrimaryAssembly )
26522654
26532655let mkNormalCall mspec = I_ call ( Normalcall, mspec, None)
26542656
@@ -2693,54 +2695,55 @@ let isILBoxedTy = function ILType.Boxed _ -> true | _ -> false
26932695
26942696let isILValueTy = function ILType.Value _ -> true | _ -> false
26952697
2696- let isPrimaryAssemblyTySpec ( tspec : ILTypeSpec ) n =
2698+ let isBuiltInTySpec ( ilg : ILGlobals ) ( tspec : ILTypeSpec ) n =
26972699 let tref = tspec.TypeRef
26982700 let scoref = tref.Scope
2699- ( tref.Name = n) &&
2700- match scoref with
2701- | ILScopeRef.Assembly n -> PrimaryAssembly.IsSomePrimaryAssembly n.Name
2702- | ILScopeRef.Module _ -> false
2703- | ILScopeRef.Local -> true
2701+ tref.Name = n &&
2702+ ( match scoref with
2703+ | ILScopeRef.Local
2704+ | ILScopeRef.Module _ -> false
2705+ | ILScopeRef.Assembly aref -> ilg.IsPossiblePrimaryAssemblyRef aref
2706+ | ILScopeRef.PrimaryAssembly -> true )
27042707
2705- let isILBoxedPrimaryAssemblyTy ( ty : ILType ) n =
2706- isILBoxedTy ty && isPrimaryAssemblyTySpec ty.TypeSpec n
2708+ let isILBoxedBuiltInTy ilg ( ty : ILType ) n =
2709+ isILBoxedTy ty && isBuiltInTySpec ilg ty.TypeSpec n
27072710
2708- let isILValuePrimaryAssemblyTy ( ty : ILType ) n =
2709- isILValueTy ty && isPrimaryAssemblyTySpec ty.TypeSpec n
2711+ let isILValueBuiltInTy ilg ( ty : ILType ) n =
2712+ isILValueTy ty && isBuiltInTySpec ilg ty.TypeSpec n
27102713
2711- let isILObjectTy ty = isILBoxedPrimaryAssemblyTy ty tname_ Object
2714+ let isILObjectTy ilg ty = isILBoxedBuiltInTy ilg ty tname_ Object
27122715
2713- let isILStringTy ty = isILBoxedPrimaryAssemblyTy ty tname_ String
2716+ let isILStringTy ilg ty = isILBoxedBuiltInTy ilg ty tname_ String
27142717
2715- let isILTypedReferenceTy ty = isILValuePrimaryAssemblyTy ty " System.TypedReference "
2718+ let isILTypedReferenceTy ilg ty = isILValueBuiltInTy ilg ty tname _ TypedReference
27162719
2717- let isILSByteTy ty = isILValuePrimaryAssemblyTy ty tname_ SByte
2720+ let isILSByteTy ilg ty = isILValueBuiltInTy ilg ty tname_ SByte
27182721
2719- let isILByteTy ty = isILValuePrimaryAssemblyTy ty tname_ Byte
2722+ let isILByteTy ilg ty = isILValueBuiltInTy ilg ty tname_ Byte
27202723
2721- let isILInt16Ty ty = isILValuePrimaryAssemblyTy ty tname_ Int16
2724+ let isILInt16Ty ilg ty = isILValueBuiltInTy ilg ty tname_ Int16
27222725
2723- let isILUInt16Ty ty = isILValuePrimaryAssemblyTy ty tname_ UInt16
2726+ let isILUInt16Ty ilg ty = isILValueBuiltInTy ilg ty tname_ UInt16
27242727
2725- let isILInt32Ty ty = isILValuePrimaryAssemblyTy ty tname_ Int32
2728+ let isILInt32Ty ilg ty = isILValueBuiltInTy ilg ty tname_ Int32
27262729
2727- let isILUInt32Ty ty = isILValuePrimaryAssemblyTy ty tname_ UInt32
2730+ let isILUInt32Ty ilg ty = isILValueBuiltInTy ilg ty tname_ UInt32
27282731
2729- let isILInt64Ty ty = isILValuePrimaryAssemblyTy ty tname_ Int64
2732+ let isILInt64Ty ilg ty = isILValueBuiltInTy ilg ty tname_ Int64
27302733
2731- let isILUInt64Ty ty = isILValuePrimaryAssemblyTy ty tname_ UInt64
2734+ let isILUInt64Ty ilg ty = isILValueBuiltInTy ilg ty tname_ UInt64
27322735
2733- let isILIntPtrTy ty = isILValuePrimaryAssemblyTy ty tname_ IntPtr
2736+ let isILIntPtrTy ilg ty = isILValueBuiltInTy ilg ty tname_ IntPtr
27342737
2735- let isILUIntPtrTy ty = isILValuePrimaryAssemblyTy ty tname_ UIntPtr
2738+ let isILUIntPtrTy ilg ty = isILValueBuiltInTy ilg ty tname_ UIntPtr
27362739
2737- let isILBoolTy ty = isILValuePrimaryAssemblyTy ty tname_ Bool
2740+ let isILBoolTy ilg ty = isILValueBuiltInTy ilg ty tname_ Bool
27382741
2739- let isILCharTy ty = isILValuePrimaryAssemblyTy ty tname_ Char
2742+ let isILCharTy ilg ty = isILValueBuiltInTy ilg ty tname_ Char
27402743
2741- let isILSingleTy ty = isILValuePrimaryAssemblyTy ty tname_ Single
2744+ let isILSingleTy ilg ty = isILValueBuiltInTy ilg ty tname_ Single
27422745
2743- let isILDoubleTy ty = isILValuePrimaryAssemblyTy ty tname_ Double
2746+ let isILDoubleTy ilg ty = isILValueBuiltInTy ilg ty tname_ Double
27442747
27452748// --------------------------------------------------------------------
27462749// Rescoping
@@ -3710,7 +3713,7 @@ let getCustomAttrData (ilg: ILGlobals) cattr =
37103713
37113714let MscorlibScopeRef = ILScopeRef.Assembly ( ILAssemblyRef.Create ( " mscorlib" , None, Some ecmaPublicKey, true , None, None))
37123715
3713- let EcmaMscorlibILGlobals = mkILGlobals MscorlibScopeRef
3716+ let EcmaMscorlibILGlobals = mkILGlobals ( MscorlibScopeRef, [])
37143717
37153718// ILSecurityDecl is a 'blob' having the following format:
37163719// - A byte containing a period (.).
@@ -4006,7 +4009,8 @@ type ILReferences =
40064009 ModuleReferences: ILModuleRef list }
40074010
40084011type ILReferencesAccumulator =
4009- { refsA: HashSet < ILAssemblyRef >
4012+ { ilg: ILGlobals
4013+ refsA: HashSet < ILAssemblyRef >
40104014 refsM: HashSet < ILModuleRef > }
40114015
40124016let emptyILRefs =
@@ -4023,6 +4027,7 @@ let refs_of_scoref s x =
40234027 | ILScopeRef.Local -> ()
40244028 | ILScopeRef.Assembly assemblyRef -> refs_ of_ assemblyRef s assemblyRef
40254029 | ILScopeRef.Module modref -> refs_ of_ modref s modref
4030+ | ILScopeRef.PrimaryAssembly -> refs_ of_ assemblyRef s s.ilg.primaryAssemblyRef
40264031
40274032let refs_of_tref s ( x : ILTypeRef ) = refs_ of_ scoref s x.Scope
40284033
@@ -4219,9 +4224,10 @@ and refs_of_manifest s (m: ILAssemblyManifest) =
42194224 refs_ of_ custom_ attrs s m.CustomAttrs
42204225 refs_ of_ exported_ types s m.ExportedTypes
42214226
4222- let computeILRefs modul =
4227+ let computeILRefs ilg modul =
42234228 let s =
4224- { refsA = HashSet<_>( HashIdentity.Structural)
4229+ { ilg = ilg
4230+ refsA = HashSet<_>( HashIdentity.Structural)
42254231 refsM = HashSet<_>( HashIdentity.Structural) }
42264232
42274233 refs_ of_ modul s modul
0 commit comments