@@ -2499,11 +2499,13 @@ let hashSets (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr op
24992499 match i.CompiledName, thisArg, args with
25002500 | " .ctor" , _, _ ->
25012501 match i.SignatureArgTypes, args with
2502- | [] , _ -> Helper.GlobalCall( " Set" , t, [], genArgs = i.GenericArgs, ?loc = r) |> Some
2502+ | ([] | [ Number _ ]) , _ -> Helper.GlobalCall( " Set" , t, [], genArgs = i.GenericArgs, ?loc = r) |> Some
25032503 | [ IEnumerable ], [ arg ] -> Helper.GlobalCall( " Set" , t, [ arg ], memb = " of" , ?loc = r) |> Some
25042504 | [ IEnumerable; IEqualityComparer ], [ arg; eqComp ] ->
25052505 Helper.LibCall( com, " Types" , " setWith" , t, [ eqComp; arg ], ?loc = r) |> Some
2506- | [ IEqualityComparer ], [ eqComp ] -> Helper.LibCall( com, " Types" , " setWith" , t, [ eqComp ], ?loc = r) |> Some
2506+ | [ IEqualityComparer ], [ eqComp ]
2507+ | [ Number _; IEqualityComparer ], [ _; eqComp ] ->
2508+ Helper.LibCall( com, " Types" , " setWith" , t, [ eqComp ], ?loc = r) |> Some
25072509 | _ -> None
25082510 // Const are read-only but I'm not sure how to detect this in runtime
25092511 // | "get_IsReadOnly", _, _ -> BoolConstant false |> makeValue r |> Some
@@ -2513,14 +2515,71 @@ let hashSets (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr op
25132515 let meth = Naming.removeGetSetPrefix meth |> Naming.lowerFirst
25142516
25152517 Helper.InstanceCall( c, meth, t, args, i.SignatureArgTypes, ?loc = r) |> Some
2516- // | ("IsProperSubsetOf" | "IsProperSupersetOf" | "IsSubsetOf" | "IsSupersetOf" as meth), Some c, args ->
2517- // let meth = Naming.lowerFirst meth
2518- // let args = injectArg com ctx r "Set" meth i.GenericArgs args
2519- // Helper.LibCall(com, "Set", meth, t, c::args, ?loc=r) |> Some
2520- // | "CopyTo" // TODO!!!
2521- // | "SetEquals"
2522- // | "Overlaps"
2523- // | "SymmetricExceptWith"
2518+ | " UnionWith" , Some c, [ other ] ->
2519+ Helper.LibCall( com, " Types" , " hashSetUnionWith" , t, [ c; other ], ?loc = r)
2520+ |> Some
2521+ | " IntersectWith" , Some c, [ other ] ->
2522+ Helper.LibCall( com, " Types" , " hashSetIntersectWith" , t, [ c; other ], ?loc = r)
2523+ |> Some
2524+ | " ExceptWith" , Some c, [ other ] ->
2525+ Helper.LibCall( com, " Types" , " hashSetExceptWith" , t, [ c; other ], ?loc = r)
2526+ |> Some
2527+ | " IsSubsetOf" , Some c, [ other ] ->
2528+ Helper.LibCall( com, " Types" , " hashSetIsSubsetOf" , t, [ c; other ], ?loc = r)
2529+ |> Some
2530+ | " IsSupersetOf" , Some c, [ other ] ->
2531+ Helper.LibCall( com, " Types" , " hashSetIsSupersetOf" , t, [ c; other ], ?loc = r)
2532+ |> Some
2533+ | " IsProperSubsetOf" , Some c, [ other ] ->
2534+ Helper.LibCall( com, " Types" , " hashSetIsProperSubsetOf" , t, [ c; other ], ?loc = r)
2535+ |> Some
2536+ | " IsProperSupersetOf" , Some c, [ other ] ->
2537+ Helper.LibCall( com, " Types" , " hashSetIsProperSupersetOf" , t, [ c; other ], ?loc = r)
2538+ |> Some
2539+ | " CopyTo" , Some c, args ->
2540+ let count = getLength c
2541+
2542+ match args with
2543+ | [ target ] ->
2544+ Helper.LibCall(
2545+ com,
2546+ " Types" ,
2547+ " hashSetCopyToArray" ,
2548+ t,
2549+ [ c; target; makeIntConst 0 ; makeIntConst 0 ; count ],
2550+ ?loc = r
2551+ )
2552+ |> Some
2553+ | [ target; targetIndex ] ->
2554+ Helper.LibCall(
2555+ com,
2556+ " Types" ,
2557+ " hashSetCopyToArray" ,
2558+ t,
2559+ [ c; target; makeIntConst 0 ; targetIndex; count ],
2560+ ?loc = r
2561+ )
2562+ |> Some
2563+ | [ target; targetIndex; copyCount ] ->
2564+ Helper.LibCall(
2565+ com,
2566+ " Types" ,
2567+ " hashSetCopyToArray" ,
2568+ t,
2569+ [ c; target; makeIntConst 0 ; targetIndex; copyCount ],
2570+ ?loc = r
2571+ )
2572+ |> Some
2573+ | _ -> None
2574+ | " SetEquals" , Some c, [ other ] ->
2575+ Helper.LibCall( com, " Types" , " hashSetSetEquals" , t, [ c; other ], ?loc = r)
2576+ |> Some
2577+ | " Overlaps" , Some c, [ other ] ->
2578+ Helper.LibCall( com, " Types" , " hashSetOverlaps" , t, [ c; other ], ?loc = r)
2579+ |> Some
2580+ | " SymmetricExceptWith" , Some c, [ other ] ->
2581+ Helper.LibCall( com, " Types" , " hashSetSymmetricExceptWith" , t, [ c; other ], ?loc = r)
2582+ |> Some
25242583 | meth, Some c, args ->
25252584 match meth with
25262585 | " Add" -> Some " add"
@@ -4069,10 +4128,12 @@ let tryBaseConstructor com ctx (ent: EntityRef) (argTypes: Lazy<Type list>) genA
40694128 | Types.hashset ->
40704129 let args =
40714130 match argTypes.Value, args with
4072- | [] , _ -> [ makeArray Any []; makeEqualityComparer com ctx ( Seq.head genArgs) ]
4131+ | ([] | [ Number _ ]) , _ -> [ makeArray Any []; makeEqualityComparer com ctx ( Seq.head genArgs) ]
40734132 | [ IEnumerable ], [ arg ] -> [ arg; makeEqualityComparer com ctx ( Seq.head genArgs) ]
40744133 | [ IEnumerable; IEqualityComparer ], [ arg; eqComp ] -> [ arg; makeComparerFromEqualityComparer eqComp ]
4075- | [ IEqualityComparer ], [ eqComp ] -> [ makeArray Any []; makeComparerFromEqualityComparer eqComp ]
4134+ | [ IEqualityComparer ], [ eqComp ]
4135+ | [ Number _; IEqualityComparer ], [ _; eqComp ] ->
4136+ [ makeArray Any []; makeComparerFromEqualityComparer eqComp ]
40764137 | _ -> FableError " Unexpected hashset constructor" |> raise
40774138
40784139 let entityName = FSharp2Fable.Helpers.cleanNameAsJsIdentifier " HashSet"
0 commit comments