@@ -1372,12 +1372,12 @@ let operators (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr o
13721372 | _ -> args
13731373 let modul , meth , args =
13741374 match genArg with
1375- | Char -> " Seq " , " rangeChar" , args
1376- | Builtin BclInt64 -> " Seq " , " rangeLong " , ( addStep args) @ [ makeBoolConst false ]
1377- | Builtin BclUInt64 -> " Seq " , " rangeLong " , ( addStep args) @ [ makeBoolConst true ]
1378- | Builtin BclDecimal -> " Seq " , " rangeDecimal" , addStep args
1379- | Builtin BclBigInt -> " BigInt " , " range " , addStep args
1380- | _ -> " Seq " , " rangeNumber " , addStep args
1375+ | Char -> " Range " , " rangeChar" , args
1376+ | Builtin BclInt64 -> " Range " , " rangeInt64 " , addStep args
1377+ | Builtin BclUInt64 -> " Range " , " rangeUInt64 " , addStep args
1378+ | Builtin BclDecimal -> " Range " , " rangeDecimal" , addStep args
1379+ | Builtin BclBigInt -> " Range " , " rangeBigInt " , addStep args
1380+ | _ -> " Range " , " rangeDouble " , addStep args
13811381 Helper.LibCall( com, modul, meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
13821382 // Pipes and composition
13831383 | " op_PipeRight" , [ x; f]
@@ -1542,7 +1542,7 @@ let implementedStringFunctions =
15421542 |]
15431543
15441544let getEnumerator com r t expr =
1545- Helper.LibCall( com, " Seq " , " getEnumerator" , t, [ toSeq Any expr], ?loc= r)
1545+ Helper.LibCall( com, " Util " , " getEnumerator" , t, [ toSeq Any expr], ?loc= r)
15461546
15471547let strings ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
15481548 match i.CompiledName, thisArg, args with
@@ -1660,7 +1660,7 @@ let stringModule (com: ICompiler) (ctx: Context) r t (i: CallInfo) (_: Expr opti
16601660 | meth, args ->
16611661 Helper.LibCall( com, " String" , Naming.lowerFirst meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
16621662
1663- let seqs ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
1663+ let seqModule ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
16641664 let sort r returnType descending projection args genArg =
16651665 let compareFn =
16661666 let identExpr ident =
@@ -1749,16 +1749,16 @@ let resizeArrays (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (this
17491749 | " Clear" , Some ar, _ ->
17501750 Helper.LibCall( com, " Util" , " clear" , t, [ ar], ?loc= r) |> Some
17511751 | " Find" , Some ar, [ arg] ->
1752- let opt = Helper.LibCall( com, " Seq " , " tryFind" , t, [ arg; ar; defaultof com ctx t ], ?loc= r)
1753- Helper.LibCall( com, " Option" , " value " , t, [ opt], ?loc= r) |> Some
1752+ let opt = Helper.LibCall( com, " Array " , " tryFind" , t, [ arg; ar], ?loc= r)
1753+ Helper.LibCall( com, " Option" , " defaultArg " , t, [ opt; defaultof com ctx t ], ?loc= r) |> Some
17541754 | " Exists" , Some ar, [ arg] ->
17551755 let left = Helper.InstanceCall( ar, " findIndex" , Number Int32, [ arg], ?loc= r)
17561756 makeEqOp r left ( makeIntConst - 1 ) BinaryGreater |> Some
17571757 | " FindLast" , Some ar, [ arg] ->
1758- let opt = Helper.LibCall( com, " Seq " , " tryFindBack" , t, [ arg; ar; defaultof com ctx t ], ?loc= r)
1759- Helper.LibCall( com, " Option" , " value " , t, [ opt], ?loc= r) |> Some
1758+ let opt = Helper.LibCall( com, " Array " , " tryFindBack" , t, [ arg; ar], ?loc= r)
1759+ Helper.LibCall( com, " Option" , " defaultArg " , t, [ opt; defaultof com ctx t ], ?loc= r) |> Some
17601760 | " FindAll" , Some ar, [ arg] ->
1761- Helper.LibCall( com, " Seq " , " filter" , t, [ arg; ar], ?loc= r) |> toArray r t |> Some
1761+ Helper.LibCall( com, " Array " , " filter" , t, [ arg; ar], ?loc= r) |> Some
17621762 | " AddRange" , Some ar, [ arg] ->
17631763 Helper.LibCall( com, " Array" , " addRangeInPlace" , t, [ arg; ar], ?loc= r) |> Some
17641764 | " GetRange" , Some ar, [ idx; cnt] ->
@@ -1860,16 +1860,13 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex
18601860 newArray ( makeIntConst 0 ) t |> Some
18611861 | " IsEmpty" , [ ar] ->
18621862 eq ( get r ( Number Int32) ar " length" ) ( makeIntConst 0 ) |> Some
1863- | " AllPairs" , args ->
1864- let allPairs = Helper.LibCall( com, " Seq" , " allPairs" , t, args, i.SignatureArgTypes, ?loc= r)
1865- toArray r t allPairs |> Some
18661863 | " TryExactlyOne" , args ->
18671864 tryCoreOp com r t " Array" " exactlyOne" args |> Some
1868- | " SortInPlace" , args ->
1869- let _ , thisArg = List.splitLast args
1870- let argTypes = List.take ( List.length args) i.SignatureArgTypes
1871- let compareFn = ( genArg com ctx r 0 i.GenericArgs) |> makeComparerFunction com ctx
1872- Helper.InstanceCall( thisArg, " sort" , t, [ compareFn], argTypes, ?loc= r) |> Some
1865+ // | "SortInPlace", args ->
1866+ // let _, thisArg = List.splitLast args
1867+ // let argTypes = List.take (List.length args) i.SignatureArgTypes
1868+ // let compareFn = (genArg com ctx r 0 i.GenericArgs) |> makeComparerFunction com ctx
1869+ // Helper.InstanceCall(thisArg, "sort", t, [compareFn], argTypes, ?loc=r) |> Some
18731870 | " CopyTo" , args ->
18741871 copyToArray com r t i args
18751872 | Patterns.DicContains nativeArrayFunctions meth, _ ->
@@ -1908,9 +1905,6 @@ let listModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Exp
19081905 // Use a cast to give it better chances of optimization (e.g. converting list
19091906 // literals to arrays) after the beta reduction pass
19101907 | " ToSeq" , [ x] -> toSeq t x |> Some
1911- | " AllPairs" , args ->
1912- let allPairs = Helper.LibCall( com, " Seq" , " allPairs" , t, args, i.SignatureArgTypes, ?loc= r)
1913- toList com t allPairs |> Some
19141908 | " TryExactlyOne" , args ->
19151909 tryCoreOp com r t " List" " exactlyOne" args |> Some
19161910 | meth, _ ->
@@ -1990,19 +1984,20 @@ let optionModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: E
19901984 Helper.LibCall( com, " Option" , Naming.lowerFirst meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
19911985 | " ToArray" , [ arg] ->
19921986 toArray r t arg |> Some
1987+ | " ToList" , [ arg] ->
1988+ let args = args |> List.replaceLast ( toArray None t)
1989+ Helper.LibCall( com, " List" , " ofArray" , t, args, ?loc= r) |> Some
19931990 | " FoldBack" , [ folder; opt; state] ->
19941991 Helper.LibCall( com, " Seq" , " foldBack" , t, [ folder; toArray None t opt; state], i.SignatureArgTypes, ?loc= r) |> Some
19951992 | ( " DefaultValue" | " OrElse" ), _ ->
19961993 Helper.LibCall( com, " Option" , " defaultArg" , t, List.rev args, ?loc= r) |> Some
19971994 | ( " DefaultWith" | " OrElseWith" ), _ ->
19981995 Helper.LibCall( com, " Option" , " defaultArgWith" , t, List.rev args, List.rev i.SignatureArgTypes, ?loc= r) |> Some
1999- | ( " Count" | " Contains" | " Exists" | " Fold" | " ForAll" | " Iterate" | " ToList" as meth), _ ->
1996+ | ( " Count" | " Contains" | " Exists" | " Fold" | " ForAll" | " Iterate" as meth), _ ->
1997+ let meth = Naming.lowerFirst meth
20001998 let args = args |> List.replaceLast ( toArray None t)
2001- let moduleName , meth =
2002- if meth = " ToList"
2003- then " List" , " ofArray"
2004- else " Seq" , Naming.lowerFirst meth
2005- Helper.LibCall( com, moduleName, meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1999+ let args = injectArg com ctx r " Seq" meth i.GenericArgs args
2000+ Helper.LibCall( com, " Seq" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
20062001 | _ -> None
20072002
20082003let parseBool ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
@@ -2267,18 +2262,19 @@ let intrinsicFunctions (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisAr
22672262 // Type: RangeChar : char -> char -> seq<char>
22682263 // Usage: RangeChar start stop
22692264 | " RangeChar" , None, _ ->
2270- Helper.LibCall( com, " Seq " , " rangeChar" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
2265+ Helper.LibCall( com, " Range " , " rangeChar" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
22712266 // reference: https://msdn.microsoft.com/visualfsharpdocs/conceptual/operatorintrinsics.rangedouble-function-%5bfsharp%5d
22722267 // Type: RangeDouble: float -> float -> float -> seq<float>
22732268 // Usage: RangeDouble start step stop
22742269 | ( " RangeSByte" | " RangeByte"
22752270 | " RangeInt16" | " RangeUInt16"
22762271 | " RangeInt32" | " RangeUInt32"
22772272 | " RangeSingle" | " RangeDouble" ), None, args ->
2278- Helper.LibCall( com, " Seq" , " rangeNumber" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
2279- | ( " RangeInt64" | " RangeUInt64" ), None, args ->
2280- let isUnsigned = makeBoolConst ( i.CompiledName = " RangeUInt64" )
2281- Helper.LibCall( com, " Seq" , " rangeLong" , t, args @ [ isUnsigned] , i.SignatureArgTypes, ?loc= r) |> Some
2273+ Helper.LibCall( com, " Range" , " rangeDouble" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
2274+ | " RangeInt64" , None, args ->
2275+ Helper.LibCall( com, " Range" , " rangeInt64" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
2276+ | " RangeUInt64" , None, args ->
2277+ Helper.LibCall( com, " Range" , " rangeUInt64" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
22822278 | _ -> None
22832279
22842280let runtimeHelpers ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) thisArg args =
@@ -3062,8 +3058,8 @@ let private replacedModules =
30623058 " Microsoft.FSharp.Collections.ListModule" , listModule
30633059 " Microsoft.FSharp.Collections.HashIdentity" , fsharpModule
30643060 " Microsoft.FSharp.Collections.ComparisonIdentity" , fsharpModule
3065- " Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers" , seqs
3066- " Microsoft.FSharp.Collections.SeqModule" , seqs
3061+ " Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers" , seqModule
3062+ " Microsoft.FSharp.Collections.SeqModule" , seqModule
30673063 " System.Collections.Generic.KeyValuePair`2" , keyValuePairs
30683064 " System.Collections.Generic.Comparer`1" , bclType
30693065 " System.Collections.Generic.EqualityComparer`1" , bclType
0 commit comments