@@ -1664,6 +1664,8 @@ let resizeArrays (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (this
16641664 Helper.LibCall( com, " Seq" , " filter" , t, [ arg; ar], ?loc= r) |> toArray com t |> Some
16651665 | " AddRange" , Some ar, [ arg] ->
16661666 Helper.LibCall( com, " Array" , " addRangeInPlace" , t, [ arg; ar], ?loc= r) |> Some
1667+ | " GetRange" , Some ar, [ idx; cnt] ->
1668+ Helper.LibCall( com, " Array" , " getSubArray" , t, [ ar; idx; cnt], ?loc= r) |> Some
16671669 | " Contains" , Some ( MaybeCasted( ar)), [ arg] ->
16681670 match ar.Type with
16691671 | Array _ ->
@@ -1771,29 +1773,26 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex
17711773 Helper.LibCall( com, " Array" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
17721774
17731775let lists ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
1776+ let meth = Naming.removeGetSetPrefix i.CompiledName |> Naming.lowerFirst
17741777 match i.CompiledName, thisArg, args with
1775- // Use methods for Head and Tail (instead of Get(ListHead) for example) to check for empty lists
1776- | ReplaceName
1777- [ " get_Head" , " head"
1778- " get_Tail" , " tail"
1779- " get_Item" , " item"
1780- " get_Length" , " length"
1781- " GetSlice" , " slice" ] methName, Some x, _ ->
1782- let args = match args with [ ExprType Unit] -> [ x] | args -> args @ [ x]
1783- Helper.LibCall( com, " List" , methName, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1784- | " get_IsEmpty" , Some x, _ -> Test( x, ListTest false , r) |> Some
1785- | " get_Empty" , None, _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1786- | " Cons" , None, [ h; t] -> NewList( Some( h, t), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1778+ | ( " get_Head" | " get_Tail" | " get_IsEmpty" | " get_Length" ), Some x, _ ->
1779+ Helper.LibCall( com, " List" , meth, t, [ x], i.SignatureArgTypes, ?loc= r) |> Some
1780+ // get r t x meth |> Some
1781+ | ( " get_Item" | " GetSlice" ), Some x, _ ->
1782+ Helper.LibCall( com, " List" , meth, t, args @ [ x], i.SignatureArgTypes, ?loc= r) |> Some
1783+ | ( " get_Empty" | " Cons" ), None, _ ->
1784+ Helper.LibCall( com, " List" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
17871785 | ( " GetHashCode" | " Equals" | " CompareTo" ), Some callee, _ ->
17881786 Helper.InstanceCall( callee, i.CompiledName, t, args, i.SignatureArgTypes, ?loc= r) |> Some
17891787 | _ -> None
17901788
17911789let listModule ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( _ : Expr option ) ( args : Expr list ) =
17921790 match i.CompiledName, args with
1793- | " IsEmpty" , [ x] -> Test( x, ListTest false , r) |> Some
1794- | " Empty" , _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1795- | " Singleton" , [ x] ->
1796- NewList( Some( x, Value( NewList( None, t), None)), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1791+ // | ("Head" | "Tail" | "IsEmpty") as meth, [x] -> get r t x (Naming.lowerFirst meth) |> Some
1792+ // | "IsEmpty", [x] -> Test(x, ListTest false, r) |> Some
1793+ // | "Empty", _ -> NewList(None, (genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1794+ // | "Singleton", [x] ->
1795+ // NewList(Some(x, Value(NewList(None, t), None)), (genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
17971796 // Use a cast to give it better chances of optimization (e.g. converting list
17981797 // literals to arrays) after the beta reduction pass
17991798 | " ToSeq" , [ x] -> toSeq t x |> Some
@@ -2586,8 +2585,8 @@ let enumerables (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr
25862585
25872586let enumerators ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
25882587 match i.CompiledName, thisArg with
2589- | " get_Current" , Some x -> get r t x " Current" |> Some
2590- | meth, Some x -> Helper.InstanceCall( x, meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
2588+ // | "get_Current", Some x -> get r t x "Current" |> Some
2589+ | meth, Some x -> Helper.InstanceCall( x, Naming.removeGetSetPrefix meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
25912590 | _ -> None
25922591
25932592let events ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
0 commit comments