@@ -27,11 +27,11 @@ type Helper =
2727 Call( callee, info, returnType, loc)
2828
2929 static member LibValue ( com , coreModule : string , coreMember : string , returnType : Type ) =
30- makeLibRef com returnType coreMember coreModule
30+ makeImportLib com returnType coreMember coreModule
3131
3232 static member LibCall ( com , coreModule : string , coreMember : string , returnType : Type , args : Expr list ,
3333 ? argTypes : Type list , ? thisArg : Expr , ? hasSpread : bool , ? isJsConstructor : bool , ? loc : SourceLocation ) =
34- let callee = makeLibRef com Any coreMember coreModule
34+ let callee = makeImportLib com Any coreMember coreModule
3535 let info = makeCallInfo thisArg args ( defaultArg argTypes [])
3636 Call( callee, { info with HasSpread = defaultArg hasSpread false
3737 IsJsConstructor = defaultArg isJsConstructor false }, returnType, loc)
@@ -789,7 +789,7 @@ let makeEqualityComparer (com: ICompiler) ctx typArg =
789789 let body = equals com ctx None true ( IdentExpr x) ( IdentExpr y)
790790 let f = Delegate([ x; y], body, None)
791791 objExpr [ " Equals" , f
792- " GetHashCode" , makeLibRef com Any " structuralHash" " Util" ]
792+ " GetHashCode" , makeImportLib com Any " structuralHash" " Util" ]
793793
794794// TODO: Try to detect at compile-time if the object already implements `Compare`?
795795let inline makeComparerFromEqualityComparer e =
@@ -927,29 +927,29 @@ let tryEntityRef (com: Fable.ICompiler) (ent: Entity) =
927927 match ent.FullName with
928928 | BuiltinDefinition BclDateTime
929929 | BuiltinDefinition BclDateTimeOffset -> makeIdentExpr " Date" |> Some
930- | BuiltinDefinition BclTimer -> makeLibRef com Any " default" " Timer" |> Some
930+ | BuiltinDefinition BclTimer -> makeImportLib com Any " default" " Timer" |> Some
931931 | BuiltinDefinition BclInt64
932- | BuiltinDefinition BclUInt64 -> makeLibRef com Any " default" " Long" |> Some
933- | BuiltinDefinition BclDecimal -> makeLibRef com Any " default" " Decimal" |> Some
934- | BuiltinDefinition BclBigInt -> makeLibRef com Any " BigInteger" " BigInt/z" |> Some
935- | BuiltinDefinition( FSharpReference _) -> makeLibRef com Any " FSharpRef" " Types" |> Some
936- | BuiltinDefinition( FSharpResult _) -> makeLibRef com Any " Result" " Option" |> Some
937- | BuiltinDefinition( FSharpChoice _) -> makeLibRef com Any " Choice" " Option" |> Some
932+ | BuiltinDefinition BclUInt64 -> makeImportLib com Any " default" " Long" |> Some
933+ | BuiltinDefinition BclDecimal -> makeImportLib com Any " default" " Decimal" |> Some
934+ | BuiltinDefinition BclBigInt -> makeImportLib com Any " BigInteger" " BigInt/z" |> Some
935+ | BuiltinDefinition( FSharpReference _) -> makeImportLib com Any " FSharpRef" " Types" |> Some
936+ | BuiltinDefinition( FSharpResult _) -> makeImportLib com Any " Result" " Option" |> Some
937+ | BuiltinDefinition( FSharpChoice _) -> makeImportLib com Any " Choice" " Option" |> Some
938938 // | BuiltinDefinition BclGuid -> jsTypeof "string" expr
939939 // | BuiltinDefinition BclTimeSpan -> jsTypeof "number" expr
940940 // | BuiltinDefinition BclHashSet _ -> fail "MutableSet" // TODO:
941941 // | BuiltinDefinition BclDictionary _ -> fail "MutableMap" // TODO:
942942 // | BuiltinDefinition BclKeyValuePair _ -> fail "KeyValuePair" // TODO:
943943 // | BuiltinDefinition FSharpSet _ -> fail "Set" // TODO:
944944 // | BuiltinDefinition FSharpMap _ -> fail "Map" // TODO:
945- | Types.matchFail -> makeLibRef com Any " MatchFailureException" " Types" |> Some
945+ | Types.matchFail -> makeImportLib com Any " MatchFailureException" " Types" |> Some
946946 | Types.exception_ -> makeIdentExpr " Error" |> Some
947947 | entFullName ->
948948 com.Options.precompiledLib
949949 |> Option.bind ( fun tryLib -> tryLib entFullName)
950950 |> Option.map ( fun ( entityName , importPath ) ->
951951 let entityName = Naming.sanitizeIdentForbiddenChars entityName |> Naming.checkJsKeywords
952- makeCustomImport Any entityName importPath)
952+ makeImportCompilerGenerated Any entityName importPath)
953953
954954let tryJsConstructor com ent =
955955 if FSharp2Fable.Util.isReplacementCandidate ent then tryEntityRef com ent
@@ -1063,21 +1063,21 @@ let fableCoreLib (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Exp
10631063 | arg -> arg
10641064 match arg with
10651065 // TODO: Check this is not a fable-library import?
1066- | Import( selector , path ,_,_) ->
1067- dynamicImport selector path |> Some
1068- | NestedLambda( args, Call( Import( selector , path , _,_),info ,_,_), None)
1069- when argEquals args info .Args ->
1070- dynamicImport selector path |> Some
1066+ | Import( info ,_,_) ->
1067+ dynamicImport info.Selector info.Path |> Some
1068+ | NestedLambda( args, Call( Import( importInfo , _,_),callInfo ,_,_), None)
1069+ when argEquals args callInfo .Args ->
1070+ dynamicImport importInfo.Selector importInfo.Path |> Some
10711071 | _ ->
10721072 " The imported value is not coming from a different file"
10731073 |> addErrorAndReturnNull com ctx.InlinePath r |> Some
10741074 | Naming.StartsWith " import" suffix, _ ->
10751075 match suffix, args with
1076- | " Member" , [ path] -> Import ( makeStrConst Naming.placeholder, path, t , r ) |> Some
1077- | " Default" , [ path] -> Import ( makeStrConst " default" , path, t , r ) |> Some
1078- | " SideEffects" , [ path] -> Import ( makeStrConst " " , path, t , r ) |> Some
1079- | " All" , [ path] -> Import ( makeStrConst " *" , path, t , r ) |> Some
1080- | _, [ selector; path] -> Import ( selector , path , t , r ) |> Some
1076+ | " Member" , [ path] -> makeImportUserGenerated r t ( makeStrConst Naming.placeholder) path |> Some
1077+ | " Default" , [ path] -> makeImportUserGenerated r t ( makeStrConst " default" ) path |> Some
1078+ | " SideEffects" , [ path] -> makeImportUserGenerated r t ( makeStrConst " " ) path |> Some
1079+ | " All" , [ path] -> makeImportUserGenerated r t ( makeStrConst " *" ) path |> Some
1080+ | _, [ selector; path] -> makeImportUserGenerated r t ( selector ) path |> Some
10811081 | _ -> None
10821082 // Dynamic casting, erase
10831083 | " op_BangHat" , [ arg] -> Some arg
@@ -1142,7 +1142,7 @@ let fableCoreLib (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Exp
11421142
11431143let getReference r t expr = get r t expr " contents"
11441144let setReference r expr value = Set( expr, Some( ExprKey( makeStrConst " contents" )), value, r)
1145- let newReference com r t value = Helper.JsConstructorCall( makeLibRef com t " FSharpRef" " Types" , t, [ value], ?loc= r)
1145+ let newReference com r t value = Helper.JsConstructorCall( makeImportLib com t " FSharpRef" " Types" , t, [ value], ?loc= r)
11461146
11471147let references ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
11481148 match i.CompiledName, thisArg, args with
@@ -1182,10 +1182,10 @@ let getPrecompiledLibMangledName entityName memberName overloadSuffix isStatic =
11821182let precompiledLib r ( t : Type ) ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) ( entityName , importPath ) =
11831183 let mangledName = getPrecompiledLibMangledName entityName i.CompiledName i.OverloadSuffix.Value ( Option.isNone thisArg)
11841184 if i.IsModuleValue
1185- then makeCustomImport t mangledName importPath
1185+ then makeImportCompilerGenerated t mangledName importPath
11861186 else
11871187 let argInfo = { makeCallInfo thisArg args i.SignatureArgTypes with HasSpread = i.HasSpread }
1188- makeCustomImport Any mangledName importPath |> makeCall r t argInfo
1188+ makeImportCompilerGenerated Any mangledName importPath |> makeCall r t argInfo
11891189
11901190let fsFormat ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
11911191 match i.CompiledName, thisArg, args with
@@ -1250,7 +1250,7 @@ let operators (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr o
12501250 | " DefaultArg" , _ ->
12511251 Helper.LibCall( com, " Option" , " defaultArg" , t, args, i.SignatureArgTypes, ?loc= r) |> Some
12521252 | " DefaultAsyncBuilder" , _ ->
1253- makeLibRef com t " singleton" " AsyncBuilder" |> Some
1253+ makeImportLib com t " singleton" " AsyncBuilder" |> Some
12541254 // Erased operators.
12551255 // KeyValuePair is already compiled as a tuple
12561256 | ( " KeyValuePattern" | " Identity" | " Box" | " Unbox" | " ToEnum" ), [ arg] -> TypeCast( arg, t) |> Some
@@ -2616,7 +2616,7 @@ let mailbox (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr opt
26162616
26172617let asyncBuilder ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
26182618 match thisArg, i.CompiledName, args with
2619- | _, " Singleton" , _ -> makeLibRef com t " singleton" " AsyncBuilder" |> Some
2619+ | _, " Singleton" , _ -> makeImportLib com t " singleton" " AsyncBuilder" |> Some
26202620 // For Using we need to cast the argument to IDisposable
26212621 | Some x, " Using" , [ arg; f] ->
26222622 Helper.InstanceCall( x, " Using" , t, [ arg; f], i.SignatureArgTypes, ?loc= r) |> Some
@@ -2974,8 +2974,8 @@ let tryCall (com: ICompiler) (ctx: Context) r t (info: CallInfo) (thisArg: Expr
29742974
29752975let tryBaseConstructor com ctx ( ent : Entity ) ( argTypes : Lazy < Type list >) genArgs args =
29762976 match ent.FullName with
2977- | Types.exception_ -> Some( makeLibRef com Any " Exception" " Types" , args)
2978- | Types.attribute -> Some( makeLibRef com Any " Attribute" " Types" , args)
2977+ | Types.exception_ -> Some( makeImportLib com Any " Exception" " Types" , args)
2978+ | Types.attribute -> Some( makeImportLib com Any " Attribute" " Types" , args)
29792979 | Types.dictionary ->
29802980 let args =
29812981 match argTypes.Value, args with
@@ -2990,7 +2990,7 @@ let tryBaseConstructor com ctx (ent: Entity) (argTypes: Lazy<Type list>) genArgs
29902990 [ makeArray Any []; makeComparerFromEqualityComparer eqComp]
29912991 | _ -> failwith " Unexpected dictionary constructor"
29922992 let entityName = FSharp2Fable.Helpers.cleanNameAsJsIdentifier " MutableMap`2"
2993- Some( makeLibRef com Any entityName " MutableMap" , args)
2993+ Some( makeImportLib com Any entityName " MutableMap" , args)
29942994 | Types.hashset ->
29952995 let args =
29962996 match argTypes.Value, args with
@@ -3004,5 +3004,5 @@ let tryBaseConstructor com ctx (ent: Entity) (argTypes: Lazy<Type list>) genArgs
30043004 [ makeArray Any []; makeComparerFromEqualityComparer eqComp]
30053005 | _ -> failwith " Unexpected hashset constructor"
30063006 let entityName = FSharp2Fable.Helpers.cleanNameAsJsIdentifier " MutableSet`1"
3007- Some( makeLibRef com Any entityName " MutableSet" , args)
3007+ Some( makeImportLib com Any entityName " MutableSet" , args)
30083008 | _ -> None
0 commit comments