@@ -1661,50 +1661,12 @@ let stringModule (com: ICompiler) (ctx: Context) r t (i: CallInfo) (_: Expr opti
16611661 Helper.LibCall( com, " String" , Naming.lowerFirst meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
16621662
16631663let seqModule ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
1664- let sort r returnType descending projection args genArg =
1665- let compareFn =
1666- let identExpr ident =
1667- match projection with
1668- | Some projection ->
1669- let info = makeCallInfo None [ IdentExpr ident] []
1670- Call( projection, info, genArg, None)
1671- | None -> IdentExpr ident
1672- let x = makeUniqueIdent ctx genArg " x"
1673- let y = makeUniqueIdent ctx genArg " y"
1674- let comparison =
1675- let comparison = compare com ctx None ( identExpr x) ( identExpr y)
1676- if descending
1677- then makeUnOp None ( Number Int32) comparison UnaryMinus
1678- else comparison
1679- Delegate([ x; y], comparison, None)
1680- Helper.LibCall( com, " Seq" , " sortWith" , returnType, compareFn:: args, ?loc= r) |> Some
1681-
16821664 match i.CompiledName, args with
16831665 | " Cast" , [ arg] -> Some arg // Erase
1684- | ( " Cache" | " ToArray" ), [ arg] -> toArray r t arg |> Some
1685- | " OfList" , [ arg] -> toSeq t arg |> Some
1686- | " ToList" , _ -> Helper.LibCall( com, " List" , " ofSeq" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
1687- | ( " ChunkBySize" | " Permute" | " SplitInto" ) as meth, [ arg1; arg2] ->
1688- let arg2 = toArray r ( Array Any) arg2
1689- let result = Helper.LibCall( com, " Array" , Naming.lowerFirst meth, Any, [ arg1; arg2])
1690- Helper.LibCall( com, " Seq" , " ofArray" , t, [ result]) |> Some
1691- // For Using we need to cast the argument to IDisposable
1692- | " EnumerateUsing" , [ arg; f] ->
1693- Helper.LibCall( com, " Seq" , " enumerateUsing" , t, [ arg; f], i.SignatureArgTypes, ?loc= r) |> Some
1694- | ( " Sort" | " SortDescending" as meth), args ->
1695- ( genArg com ctx r 0 i.GenericArgs) |> sort r t ( meth = " SortDescending" ) None args
1696- | ( " SortBy" | " SortByDescending" as meth), projection:: args ->
1697- ( genArg com ctx r 1 i.GenericArgs) |> sort r t ( meth = " SortByDescending" ) ( Some projection) args
1698- | ( " GroupBy" | " CountBy" as meth), args ->
1699- let meth = Naming.lowerFirst meth
1700- let args = injectArg com ctx r " Map" meth i.GenericArgs args
1701- Helper.LibCall( com, " Map" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1702- | ( " Distinct" | " DistinctBy" as meth), args ->
1666+ | ( " Distinct" | " DistinctBy" | " Except" | " GroupBy" | " CountBy" as meth), args ->
17031667 let meth = Naming.lowerFirst meth
1704- let args = injectArg com ctx r " Set" meth i.GenericArgs args
1705- Helper.LibCall( com, " Set" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1706- | " TryExactlyOne" , args ->
1707- tryCoreOp com r t " Seq" " exactlyOne" args |> Some
1668+ let args = injectArg com ctx r " Seq2" meth i.GenericArgs args
1669+ Helper.LibCall( com, " Seq2" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
17081670 | meth, _ ->
17091671 let meth = Naming.lowerFirst meth
17101672 let args = injectArg com ctx r " Seq" meth i.GenericArgs args
@@ -1860,19 +1822,16 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex
18601822 newArray ( makeIntConst 0 ) t |> Some
18611823 | " IsEmpty" , [ ar] ->
18621824 eq ( get r ( Number Int32) ar " length" ) ( makeIntConst 0 ) |> Some
1863- | " TryExactlyOne" , args ->
1864- tryCoreOp com r t " Array" " exactlyOne" args |> 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
18701825 | " CopyTo" , args ->
18711826 copyToArray com r t i args
18721827 | Patterns.DicContains nativeArrayFunctions meth, _ ->
18731828 let args , thisArg = List.splitLast args
18741829 let argTypes = List.take ( List.length args) i.SignatureArgTypes
18751830 Helper.InstanceCall( thisArg, meth, t, args, argTypes, ?loc= r) |> Some
1831+ | ( " Distinct" | " DistinctBy" | " Except" | " GroupBy" | " CountBy" as meth), args ->
1832+ let meth = Naming.lowerFirst meth
1833+ let args = injectArg com ctx r " Seq2" meth i.GenericArgs args
1834+ Helper.LibCall( com, " Seq2" , " Array_" + meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18761835 | meth, _ ->
18771836 let meth = Naming.lowerFirst meth
18781837 let args = injectArg com ctx r " Array" meth i.GenericArgs args
@@ -1905,8 +1864,10 @@ let listModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Exp
19051864 // Use a cast to give it better chances of optimization (e.g. converting list
19061865 // literals to arrays) after the beta reduction pass
19071866 | " ToSeq" , [ x] -> toSeq t x |> Some
1908- | " TryExactlyOne" , args ->
1909- tryCoreOp com r t " List" " exactlyOne" args |> Some
1867+ | ( " Distinct" | " DistinctBy" | " Except" | " GroupBy" | " CountBy" as meth), args ->
1868+ let meth = Naming.lowerFirst meth
1869+ let args = injectArg com ctx r " Seq2" meth i.GenericArgs args
1870+ Helper.LibCall( com, " Seq2" , " List_" + meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
19101871 | meth, _ ->
19111872 let meth = Naming.lowerFirst meth
19121873 let args = injectArg com ctx r " List" meth i.GenericArgs args
0 commit comments