@@ -717,6 +717,8 @@ let identityHash r (arg: Expr) =
717717 Helper.CoreCall( " Util" , " structuralHash" , Number Int32, [ arg], ?loc= r)
718718 | DeclaredType( ent,_) when ent.IsFSharpUnion || ent.IsFSharpRecord || ent.IsValueType ->
719719 Helper.CoreCall( " Util" , " structuralHash" , Number Int32, [ arg], ?loc= r)
720+ | DeclaredType( ent,_) ->
721+ Helper.InstanceCall( arg, " GetHashCode" , Number Int32, [], ?loc= r)
720722 | _ ->
721723 Helper.CoreCall( " Util" , " identityHash" , Number Int32, [ arg], ?loc= r)
722724
@@ -1838,30 +1840,20 @@ let arrayModule (com: ICompiler) (ctx: Context) r (t: Type) (i: CallInfo) (_: Ex
18381840 Helper.CoreCall( " Array" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18391841
18401842let lists ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
1843+ let meth = Naming.removeGetSetPrefix i.CompiledName |> Naming.lowerFirst
18411844 match i.CompiledName, thisArg, args with
1842- // Use methods for Head and Tail (instead of Get(ListHead) for example) to check for empty lists
1843- | ( " get_Head" | " get_Tail" | " get_Length" | " get_IsEmpty" ), Some callee, _ ->
1844- let meth = Naming.removeGetSetPrefix i.CompiledName
1845- get r t callee meth |> Some
1846- | " get_Item" , Some callee, _ ->
1847- let meth = Naming.removeGetSetPrefix i.CompiledName
1848- Helper.InstanceCall( callee, meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1849- | " GetSlice" , Some x, _ ->
1850- let meth = Naming.lowerFirst i.CompiledName
1851- let args = match args with [ ExprType Unit] -> [ x] | args -> args @ [ x]
1845+ | ( " get_Head" | " get_Tail" | " get_Length" | " get_IsEmpty" ), Some x, _ ->
1846+ Helper.CoreCall( " List" , meth, t, [ x], i.SignatureArgTypes, ?loc= r) |> Some
1847+ | ( " get_Item" | " GetSlice" ), Some x, _ ->
1848+ Helper.CoreCall( " List" , meth, t, args @ [ x], i.SignatureArgTypes, ?loc= r) |> Some
1849+ | ( " get_Empty" | " Cons" ), None, _ ->
18521850 Helper.CoreCall( " List" , meth, t, args, i.SignatureArgTypes, ?loc= r) |> Some
1853- | " get_Empty" , None, _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1854- | " Cons" , None, [ h; t] -> NewList( Some( h, t), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
18551851 | ( " GetHashCode" | " Equals" | " CompareTo" ), Some callee, _ ->
18561852 Helper.InstanceCall( callee, i.CompiledName, t, args, i.SignatureArgTypes, ?loc= r) |> Some
18571853 | _ -> None
18581854
18591855let listModule ( com : ICompiler ) ( ctx : Context ) r ( t : Type ) ( i : CallInfo ) ( _ : Expr option ) ( args : Expr list ) =
18601856 match i.CompiledName, args with
1861- | " IsEmpty" , [ x] -> Test( x, ListTest false , r) |> Some
1862- | " Empty" , _ -> NewList( None, ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
1863- | " Singleton" , [ x] ->
1864- NewList( Some( x, Value( NewList( None, t), None)), ( genArg com ctx r 0 i.GenericArgs)) |> makeValue r |> Some
18651857 // Use a cast to give it better chances of optimization (e.g. converting list
18661858 // literals to arrays) after the beta reduction pass
18671859 | " ToSeq" , [ x] -> toSeq t x |> Some
0 commit comments