@@ -207,6 +207,8 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
207207let v_nativeptr_tcr = mk_ MFCore_ tcref fslibCcu" nativeptr`1"
208208let v_ilsigptr_tcr = mk_ MFCore_ tcref fslibCcu" ilsigptr`1"
209209let v_fastFunc_tcr = mk_ MFCore_ tcref fslibCcu" FSharpFunc`2"
210+ let v_refcell_tcr_canon = mk_ MFCore_ tcref fslibCcu" Ref`1"
211+ let v_refcell_tcr_nice = mk_ MFCore_ tcref fslibCcu" ref`1"
210212
211213let dummyAssemblyNameCarryingUsefulErrorInformation path typeName =
212214 FSComp.SR.tcGlobalsSystemTypeNotFound( String.concat" ." path+ " ." + typeName)
@@ -347,6 +349,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
347349let mk_hash_withc_sig ty = [[ v_ IEqualityComparer_ ty]; [ ty]], v_ int_ ty
348350let mkListTy ty = TType_ app( v_ list_ tcr_ nice, [ ty])
349351let mkSeqTy ty1 = TType_ app( v_ seq_ tcr, [ ty1])
352+ let mkRefCellTy ty = TType_ app( v_ refcell_ tcr_ canon, [ ty])
350353let mkQuerySourceTy ty1 ty2 = TType_ app( v_ querySource_ tcr, [ ty1; ty2])
351354let v_tcref_System_Collections_IEnumerable = findSysTyconRef sysCollections" IEnumerable" ;
352355let mkArrayType rank ( ty : TType ) : TType =
@@ -596,10 +599,11 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
596599let v_sprintf_info = makeIntrinsicValRef( fslib_ MFExtraTopLevelOperators_ nleref, " sprintf" , None, Some" PrintFormatToStringThen" , [ vara], ([[ mk_ format4_ ty varaTy v_ unit_ ty v_ string_ ty v_ string_ ty]], varaTy))
597600let v_lazy_force_info =
598601// Lazy\Value for > 4.0
599- makeIntrinsicValRef( fslib_ MFLazyExtensions_ nleref, " Force" , Some" Lazy`1" , None, [ vara], ([[ mkLazyTy varaTy]; []], varaTy))
602+ makeIntrinsicValRef( fslib_ MFLazyExtensions_ nleref, " Force" , Some" Lazy`1" , None, [ vara], ([[ mkLazyTy varaTy]; []], varaTy))
600603let v_lazy_create_info = makeIntrinsicValRef( fslib_ MFLazyExtensions_ nleref, " Create" , Some" Lazy`1" , None, [ vara], ([[ v_ unit_ ty- -> varaTy]], mkLazyTy varaTy))
601604
602605let v_seq_info = makeIntrinsicValRef( fslib_ MFOperators_ nleref, " seq" , None, Some" CreateSequence" , [ vara], ([[ mkSeqTy varaTy]], mkSeqTy varaTy))
606+ let v_refcell_info = makeIntrinsicValRef( fslib_ MFCore_ nleref, " ref" , Some" FSharpRef`1" , None, [ vara], ([[ mkRefCellTy varaTy]; []], varaTy))
603607let v_splice_expr_info = makeIntrinsicValRef( fslib_ MFExtraTopLevelOperators_ nleref, " op_Splice" , None, None, [ vara], ([[ mkQuotedExprTy varaTy]], varaTy))
604608let v_splice_raw_expr_info = makeIntrinsicValRef( fslib_ MFExtraTopLevelOperators_ nleref, " op_SpliceUntyped" , None, None, [ vara], ([[ mkRawQuotedExprTy]], varaTy))
605609let v_new_decimal_info = makeIntrinsicValRef( fslib_ MFIntrinsicFunctions_ nleref, " MakeDecimal" , None, None, [], ([[ v_ int_ ty]; [ v_ int_ ty]; [ v_ int_ ty]; [ v_ bool_ ty]; [ v_ byte_ ty]], v_ decimal_ ty))
@@ -679,47 +683,47 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
679683let betterTyconRefMap =
680684begin
681685let entries1 =
682- [ " Int32" , v_ int_ tcr
683- " IntPtr" , v_ nativeint_ tcr
684- " UIntPtr" , v_ unativeint_ tcr
685- " Int16" , v_ int16_ tcr
686- " Int64" , v_ int64_ tcr
687- " UInt16" , v_ uint16_ tcr
688- " UInt32" , v_ uint32_ tcr
689- " UInt64" , v_ uint64_ tcr
690- " SByte" , v_ sbyte_ tcr
691- " Decimal" , v_ decimal_ tcr
692- " Byte" , v_ byte_ tcr
693- " Boolean" , v_ bool_ tcr
694- " String" , v_ string_ tcr
695- " Object" , v_ obj_ tcr
696- " Exception" , v_ exn_ tcr
697- " Char" , v_ char_ tcr
698- " Double" , v_ float_ tcr
699- " Single" , v_ float32_ tcr]
700- |> List .map( fun ( nm , tcr ) ->
686+ [| " Int32" , v_ int_ tcr
687+ " IntPtr" , v_ nativeint_ tcr
688+ " UIntPtr" , v_ unativeint_ tcr
689+ " Int16" , v_ int16_ tcr
690+ " Int64" , v_ int64_ tcr
691+ " UInt16" , v_ uint16_ tcr
692+ " UInt32" , v_ uint32_ tcr
693+ " UInt64" , v_ uint64_ tcr
694+ " SByte" , v_ sbyte_ tcr
695+ " Decimal" , v_ decimal_ tcr
696+ " Byte" , v_ byte_ tcr
697+ " Boolean" , v_ bool_ tcr
698+ " String" , v_ string_ tcr
699+ " Object" , v_ obj_ tcr
700+ " Exception" , v_ exn_ tcr
701+ " Char" , v_ char_ tcr
702+ " Double" , v_ float_ tcr
703+ " Single" , v_ float32_ tcr| ]
704+ |> Array .map( fun ( nm , tcr ) ->
701705let ty = mkNonGenericTy tcr
702706 nm, findSysTyconRef sys nm, ( fun _ -> ty))
703707
704708let entries2 =
705- [ " FSharpFunc`2 " , v _ fastFunc _ tcr , ( fun tinst -> mkFunTy ( List.item 0 tinst ) ( List.item 1 tinst ))
706- " Tuple `2" , v _ ref _ tuple2 _ tcr , decodeTupleTy tupInfoRef
707- " Tuple`3 " , v _ ref _ tuple3 _ tcr , decodeTupleTy tupInfoRef
708- " Tuple`4 " , v _ ref _ tuple4 _ tcr , decodeTupleTy tupInfoRef
709- " Tuple`5 " , v _ ref _ tuple5 _ tcr , decodeTupleTy tupInfoRef
710- " Tuple`6 " , v _ ref _ tuple6 _ tcr , decodeTupleTy tupInfoRef
711- " Tuple`7 " , v _ ref _ tuple7 _ tcr , decodeTupleTy tupInfoRef
712- " Tuple`8 " , v _ ref _ tuple8 _ tcr , decodeTupleTy tupInfoRef
713- " ValueTuple`2 " , v _ struct _ tuple2 _ tcr , decodeTupleTytupInfoStruct
714- " ValueTuple`3 " , v _ struct _ tuple3 _ tcr , decodeTupleTy tupInfoStruct
715- " ValueTuple`4 " , v _ struct _ tuple4 _ tcr , decodeTupleTy tupInfoStruct
716- " ValueTuple`5 " , v _ struct _ tuple5 _ tcr , decodeTupleTy tupInfoStruct
717- " ValueTuple`6 " , v _ struct _ tuple6 _ tcr , decodeTupleTy tupInfoStruct
718- " ValueTuple`7 " , v _ struct _ tuple7 _ tcr , decodeTupleTy tupInfoStruct
719- " ValueTuple`8 " , v _ struct _ tuple8 _ tcr , decodeTupleTy tupInfoStruct]
720-
721- let entries = ( entries1 @ entries2 )
722-
709+ [|
710+ " FSharpFunc `2" , v _ fastFunc _ tcr , ( fun tinst -> mkFunTy ( List.item 0 tinst ) ( List.item 1 tinst ))
711+ " Tuple`2 " , v _ ref _ tuple2 _ tcr , decodeTupleTy tupInfoRef
712+ " Tuple`3 " , v _ ref _ tuple3 _ tcr , decodeTupleTy tupInfoRef
713+ " Tuple`4 " , v _ ref _ tuple4 _ tcr , decodeTupleTy tupInfoRef
714+ " Tuple`5 " , v _ ref _ tuple5 _ tcr , decodeTupleTy tupInfoRef
715+ " Tuple`6 " , v _ ref _ tuple6 _ tcr , decodeTupleTy tupInfoRef
716+ " Tuple`7 " , v _ ref _ tuple7 _ tcr , decodeTupleTy tupInfoRef
717+ " Tuple`8 " , v _ ref _ tuple8 _ tcr , decodeTupleTytupInfoRef
718+ " ValueTuple`2 " , v _ struct _ tuple2 _ tcr , decodeTupleTy tupInfoStruct
719+ " ValueTuple`3 " , v _ struct _ tuple3 _ tcr , decodeTupleTy tupInfoStruct
720+ " ValueTuple`4 " , v _ struct _ tuple4 _ tcr , decodeTupleTy tupInfoStruct
721+ " ValueTuple`5 " , v _ struct _ tuple5 _ tcr , decodeTupleTy tupInfoStruct
722+ " ValueTuple`6 " , v _ struct _ tuple6 _ tcr , decodeTupleTy tupInfoStruct
723+ " ValueTuple`7 " , v _ struct _ tuple7 _ tcr , decodeTupleTy tupInfoStruct
724+ " ValueTuple`8 " , v _ struct _ tuple8 _ tcr , decodeTupleTy tupInfoStruct |]
725+
726+ let entries = Array.append entries1 entries2
723727if compilingFslibthen
724728// This map is for use when building FSharp.Core.dll. The backing Tycon's may not yet exist for
725729// the TyconRef's we have in our hands, hence we can't dereference them to find their stamps.
@@ -728,10 +732,12 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
728732//
729733// Make it lazy to avoid dereferencing while setting up the base imports.
730734let dict =
731- lazy
732- entries
733- |> List.map( fun ( nm , tcref , builder ) -> nm, ( fun tcref2 tinst -> if tyconRefEq tcref tcref2then Some( builder tinst) else None))
734- |> Dictionary.ofList
735+ lazy (
736+ let dict = Dictionary.newWithSize entries.Length
737+ for nm, tcref, builderin entriesdo
738+ dict.Add( nm, fun tcref2 tinst -> if tyconRefEq tcref tcref2then Some( builder tinst) else None)
739+ dict
740+ )
735741( fun ( tcref : EntityRef ) tinst ->
736742let dict = dict.Value
737743let key = tcref.LogicalName
@@ -746,10 +752,11 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
746752// Make it lazy to avoid dereferencing while setting up the base imports.
747753let dict =
748754lazy
749- entries
750- |> List.filter( fun ( _ , tcref , _ ) -> tcref.CanDeref)
751- |> List.map( fun ( _ , tcref , builder ) -> tcref.Stamp, builder)
752- |> Dictionary.ofList
755+ let dict = Dictionary.newWithSize entries.Length
756+ for _, tcref, builderin entriesdo
757+ if tcref.CanDerefthen
758+ dict.Add( tcref.Stamp, builder)
759+ dict
753760( fun tcref2 tinst ->
754761let dict = dict.Value
755762let key = tcref2.Stamp
@@ -772,13 +779,13 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
772779member __.unionCaseRefEq x y = primUnionCaseRefEq compilingFslib fslibCcu x y
773780member __.valRefEq x y = primValRefEq compilingFslib fslibCcu x y
774781member __.fslibCcu = fslibCcu
775- member val refcell_tcr_canon = mk _ MFCore _ tcref fslibCcu " Ref`1 "
782+ member val refcell_tcr_canon = v _ refcell _ tcr _ canon
776783member val option_tcr_canon = mk_ MFCore_ tcref fslibCcu" Option`1"
777784member __.list_tcr_canon = v_ list_ tcr_ canon
778785member val set_tcr_canon = mk_ MFCollections_ tcref fslibCcu" Set`1"
779786member val map_tcr_canon = mk_ MFCollections_ tcref fslibCcu" Map`2"
780787member __.lazy_tcr_canon = lazy_ tcr
781- member val refcell_tcr_nice = mk _ MFCore _ tcref fslibCcu " ref`1 "
788+ member val refcell_tcr_nice = v _ refcell _ tcr _ nice
782789member val array_tcr_nice = v_ il_ arr_ tcr_ map.[ 0 ]
783790member __.option_tcr_nice = v_ option_ tcr_ nice
784791member __.list_tcr_nice = v_ list_ tcr_ nice
@@ -1050,6 +1057,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
10501057member __.new_decimal_info = v_ new_ decimal_ info
10511058member __.seq_info = v_ seq_ info
10521059member val seq_vref = ( ValRefForIntrinsic v_ seq_ info)
1060+ member val fsharpref_vref = ( ValRefForIntrinsic v_ refcell_ info)
10531061member val and_vref = ( ValRefForIntrinsic v_ and_ info)
10541062member val and2_vref = ( ValRefForIntrinsic v_ and2_ info)
10551063member val addrof_vref = ( ValRefForIntrinsic v_ addrof_ info)