@@ -1814,29 +1814,26 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex
18141814 Helper.LibCall( com, " Array" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18151815
18161816let lists ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
1817+ let meth = Naming.removeGetSetPrefix i.CompiledName |> Naming.lowerFirst
18171818 match i.CompiledName, thisArg, args with
1818- // Use methods for Head and Tail (instead of Get(ListHead) for example) to check for empty lists
1819- | ReplaceName
1820- [ " get_Head" , " head"
1821- " get_Tail" , " tail"
1822- " get_Item" , " item"
1823- " get_Length" , " length"
1824- " GetSlice" , " slice" ] methName, Some x, _ ->
1825- let args = match args with [ ExprType Unit] -> [ x] | args -> args @ [ x]
1826- Helper.LibCall( com, " List" , methName, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1827- | " get_IsEmpty" , Some x, _ -> Test( x, ListTest false , r) |> Some
1828- | " get_Empty" , None, _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1829- | " Cons" , None, [ h; t] -> NewList( Some( h, t), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1819+ | ( " get_Head" | " get_Tail" | " get_IsEmpty" | " get_Length" ), Some x, _ ->
1820+ Helper.LibCall( com, " List" , meth, t, [ x], i.SignatureArgTypes, ?loc= r) |> Some
1821+ // get r t x meth |> Some
1822+ | ( " get_Item" | " GetSlice" ), Some x, _ ->
1823+ Helper.LibCall( com, " List" , meth, t, args @ [ x], i.SignatureArgTypes, ?loc= r) |> Some
1824+ | ( " get_Empty" | " Cons" ), None, _ ->
1825+ Helper.LibCall( com, " List" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18301826 | ( " GetHashCode" | " Equals" | " CompareTo" ), Some callee, _ ->
18311827 Helper.InstanceCall( callee, i.CompiledName, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18321828 | _ -> None
18331829
18341830let listModule ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( _ : Expr option ) ( args : Expr list ) =
18351831 match i.CompiledName, args with
1836- | " IsEmpty" , [ x] -> Test( x, ListTest false , r) |> Some
1837- | " Empty" , _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1838- | " Singleton" , [ x] ->
1839- NewList( Some( x, Value( NewList( None, t), None)), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1832+ // | ("Head" | "Tail" | "IsEmpty") as meth, [x] -> get r t x (Naming.lowerFirst meth) |> Some
1833+ // | "IsEmpty", [x] -> Test(x, ListTest false, r) |> Some
1834+ // | "Empty", _ -> NewList(None, (genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1835+ // | "Singleton", [x] ->
1836+ // NewList(Some(x, Value(NewList(None, t), None)), (genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
18401837 // Use a cast to give it better chances of optimization (e.g. converting list
18411838 // literals to arrays) after the beta reduction pass
18421839 | " ToSeq" , [ x] -> toSeq t x |> Some
0 commit comments