Skip to content

Commit f7871e4

Browse files
Precompile inlined functions (#2634)
* Remove reference to FCS in Replacements * Precompile inline functions * Fixt Fable.Library build * Make tests compilable * Unresolved member ref * Fix standalone
1 parent bb8164c commit f7871e4

File tree

16 files changed

+660
-435
lines changed

16 files changed

+660
-435
lines changed

Fable.sln

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30114.105
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C8CB96CF-68A8-4083-A0F8-319275CF8097}"
77
EndProject
8-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Core", "src\Fable.Core\Fable.Core.fsproj", "{287FF404-A34F-4385-95BE-C892BA0E3DCE}"
8+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.Core", "src\Fable.Core\Fable.Core.fsproj", "{287FF404-A34F-4385-95BE-C892BA0E3DCE}"
99
EndProject
10-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Library", "src\fable-library\Fable.Library.fsproj", "{11C625B4-0E0E-49BD-977F-4A0FC9821B5B}"
10+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.Library", "src\fable-library\Fable.Library.fsproj", "{11C625B4-0E0E-49BD-977F-4A0FC9821B5B}"
1111
EndProject
12-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.AST", "src\Fable.AST\Fable.AST.fsproj", "{893F6BC9-81D7-4154-88D8-0F0D4601E7AE}"
12+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.AST", "src\Fable.AST\Fable.AST.fsproj", "{893F6BC9-81D7-4154-88D8-0F0D4601E7AE}"
1313
EndProject
14-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Transforms", "src\Fable.Transforms\Fable.Transforms.fsproj", "{AC4FFF83-30BB-4DBA-9600-C19FA999E088}"
14+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.Transforms", "src\Fable.Transforms\Fable.Transforms.fsproj", "{AC4FFF83-30BB-4DBA-9600-C19FA999E088}"
1515
EndProject
16-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.Cli", "src\Fable.Cli\Fable.Cli.fsproj", "{964B545D-0EB2-485A-9D74-693D75DB3EDE}"
16+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.Cli", "src\Fable.Cli\Fable.Cli.fsproj", "{964B545D-0EB2-485A-9D74-693D75DB3EDE}"
1717
EndProject
18-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "QuickTest", "src\quicktest\QuickTest.fsproj", "{11F9359C-06BA-410A-AB1B-339B89222983}"
18+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "QuickTest", "src\quicktest\QuickTest.fsproj", "{11F9359C-06BA-410A-AB1B-339B89222983}"
1919
EndProject
20-
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fable.PublishUtils", "src\Fable.PublishUtils\Fable.PublishUtils.fsproj", "{B6D5BB00-D2C2-404D-8CA2-A278784AF0CA}"
20+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fable.PublishUtils", "src\Fable.PublishUtils\Fable.PublishUtils.fsproj", "{B6D5BB00-D2C2-404D-8CA2-A278784AF0CA}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1972E8A5-9DC3-40FA-87FD-FE25FC90132B}"
23+
ProjectSection(SolutionItems) = preProject
24+
build.fsx = build.fsx
25+
EndProjectSection
2126
EndProject
2227
Global
2328
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2429
Debug|Any CPU = Debug|Any CPU
2530
Release|Any CPU = Release|Any CPU
2631
EndGlobalSection
27-
GlobalSection(SolutionProperties) = preSolution
28-
HideSolutionNode = FALSE
29-
EndGlobalSection
3032
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3133
{287FF404-A34F-4385-95BE-C892BA0E3DCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3234
{287FF404-A34F-4385-95BE-C892BA0E3DCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
@@ -57,6 +59,9 @@ Global
5759
{B6D5BB00-D2C2-404D-8CA2-A278784AF0CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
5860
{B6D5BB00-D2C2-404D-8CA2-A278784AF0CA}.Release|Any CPU.Build.0 = Release|Any CPU
5961
EndGlobalSection
62+
GlobalSection(SolutionProperties) = preSolution
63+
HideSolutionNode = FALSE
64+
EndGlobalSection
6065
GlobalSection(NestedProjects) = preSolution
6166
{287FF404-A34F-4385-95BE-C892BA0E3DCE} = {C8CB96CF-68A8-4083-A0F8-319275CF8097}
6267
{11C625B4-0E0E-49BD-977F-4A0FC9821B5B} = {C8CB96CF-68A8-4083-A0F8-319275CF8097}
@@ -66,4 +71,7 @@ Global
6671
{11F9359C-06BA-410A-AB1B-339B89222983} = {C8CB96CF-68A8-4083-A0F8-319275CF8097}
6772
{B6D5BB00-D2C2-404D-8CA2-A278784AF0CA} = {C8CB96CF-68A8-4083-A0F8-319275CF8097}
6873
EndGlobalSection
74+
GlobalSection(ExtensibilityGlobals) = postSolution
75+
SolutionGuid = {58DF9285-8523-4EAC-B598-BE5B02A76A00}
76+
EndGlobalSection
6977
EndGlobal

src/Fable.AST/Fable.fs

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ type GenericParam =
4242
abstract Name: string
4343

4444
type Parameter =
45-
abstract Name: string option
46-
abstract Type: Type
45+
{ Name: string option
46+
Type: Type }
4747

4848
type MemberInfo =
4949
abstract Attributes: Attribute seq
@@ -160,8 +160,8 @@ type Declaration =
160160
||> List.fold (fun acc m -> Set.union acc m.UsedNames)
161161

162162
type File(decls, ?usedRootNames) =
163-
member __.Declarations: Declaration list = decls
164-
member __.UsedNamesInRootScope: Set<string> = defaultArg usedRootNames Set.empty
163+
member _.Declarations: Declaration list = decls
164+
member _.UsedNamesInRootScope: Set<string> = defaultArg usedRootNames Set.empty
165165

166166
type Ident =
167167
{ Name: string
@@ -224,6 +224,7 @@ type ValueKind =
224224
type CallMemberInfo =
225225
{ CurriedParameterGroups: Parameter list list
226226
IsInstance: bool
227+
IsGetter: bool
227228
FullName: string
228229
CompiledName: string
229230
DeclaringEntity: EntityRef option }
@@ -264,8 +265,13 @@ type OperationKind =
264265
| Binary of BinaryOperator * left: Expr * right: Expr
265266
| Logical of LogicalOperator * left: Expr * right: Expr
266267

268+
type FieldKey =
269+
{ Name: string
270+
FieldType: Type
271+
IsMutable: bool }
272+
267273
type KeyKind =
268-
| FieldKey of Field
274+
| FieldKey of FieldKey
269275
| ExprKey of Expr
270276

271277
type GetKind =
@@ -283,6 +289,34 @@ type TestKind =
283289
| ListTest of isCons: bool
284290
| UnionCaseTest of tag: int
285291

292+
type MemberRefInfo =
293+
{
294+
Name: string
295+
Path: string
296+
IsMutable: bool
297+
IsPublic: bool
298+
HasOverloadSuffix: bool
299+
}
300+
301+
type UnresolvedExpr =
302+
// TODO: Add also MemberKind from the flags?
303+
| UnresolvedTraitCall of sourceTypes: Type list * traitName: string * isInstance: bool * argTypes: Type list * argExprs: Expr list * typ: Type * range: SourceLocation option
304+
| UnresolvedReplaceCall of thisArg: Expr option * args: Expr list * info: ReplaceCallInfo * attachedCall: Expr option * typ: Type * range: SourceLocation option
305+
| UnresolvedInlineCall of memberUniqueName: string * genArgs: (string * Type) list * callee: Expr option * info: CallInfo * typ: Type * range: SourceLocation option
306+
| UnresolvedMemberRef of MemberRefInfo * typ: Type * range: SourceLocation option
307+
member this.Type =
308+
match this with
309+
| UnresolvedTraitCall(_,_,_,_,_,t,_)
310+
| UnresolvedReplaceCall(_,_,_,_,t,_)
311+
| UnresolvedInlineCall(_,_,_,_,t,_)
312+
| UnresolvedMemberRef(_,t,_) -> t
313+
member this.Range =
314+
match this with
315+
| UnresolvedTraitCall(_,_,_,_,_,_,r)
316+
| UnresolvedReplaceCall(_,_,_,_,_,r)
317+
| UnresolvedInlineCall(_,_,_,_,_,r)
318+
| UnresolvedMemberRef(_,_,r) -> r
319+
286320
type Expr =
287321
// Values and Idents
288322
| Value of ValueKind * SourceLocation option
@@ -326,8 +360,11 @@ type Expr =
326360
| TryCatch of body: Expr * catch: (Ident * Expr) option * finalizer: Expr option * range: SourceLocation option
327361
| IfThenElse of guardExpr: Expr * thenExpr: Expr * elseExpr: Expr * range: SourceLocation option
328362

363+
| Unresolved of UnresolvedExpr
364+
329365
member this.Type =
330366
match this with
367+
| Unresolved e -> e.Type
331368
| Test _ -> Boolean
332369
| Value (kind, _) -> kind.Type
333370
| IdentExpr id -> id.Type
@@ -355,6 +392,7 @@ type Expr =
355392

356393
member this.Range: SourceLocation option =
357394
match this with
395+
| Unresolved e -> e.Range
358396
| ObjectExpr _
359397
| Sequential _
360398
| Let _

src/Fable.Cli/Main.fs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,11 @@ type ProjectCracked(cliArgs: CliArgs, crackerResponse: CrackerResponse, sourceFi
306306
member _.SourceFiles = sourceFiles
307307
member _.SourceFilePaths = sourceFiles |> Array.map (fun f -> f.NormalizedFullPath)
308308

309-
member _.MakeCompiler(currentFile, project, triggeredByDependency) =
310-
let opts = { cliArgs.CompilerOptions with TriggeredByDependency = triggeredByDependency }
309+
member _.MakeCompiler(currentFile, project, ?triggeredByDependency) =
310+
let opts =
311+
match triggeredByDependency with
312+
| Some t -> { cliArgs.CompilerOptions with TriggeredByDependency = t }
313+
| None -> cliArgs.CompilerOptions
311314
let fableLibDir = Path.getRelativePath currentFile crackerResponse.FableLibDir
312315
CompilerImpl(currentFile, project, opts, fableLibDir, ?outDir=cliArgs.OutDir)
313316

@@ -362,26 +365,27 @@ type ProjectChecked(checker: InteractiveChecker, errors: FSharpDiagnostic array,
362365
member _.Checker = checker
363366
member _.Errors = errors
364367

365-
static member Init(config: ProjectCracked) = async {
366-
let checker = InteractiveChecker.Create(config.ProjectOptions)
367-
let! implFiles, errors, assemblies = checkProject config checker None
368+
static member Init(projCracked: ProjectCracked) = async {
369+
let checker = InteractiveChecker.Create(projCracked.ProjectOptions)
370+
let! implFiles, errors, assemblies = checkProject projCracked checker None
368371

369372
return ProjectChecked(checker, errors, Project.From(
370-
config.ProjectFile,
373+
projCracked.ProjectFile,
371374
implFiles,
372375
assemblies.Value,
373-
getPlugin = loadType config.CliArgs,
374-
trimRootModule = config.FableOptions.RootModule))
376+
mkCompiler = (fun p f -> projCracked.MakeCompiler(f, p)),
377+
getPlugin = loadType projCracked.CliArgs,
378+
trimRootModule = projCracked.FableOptions.RootModule))
375379
}
376380

377-
member this.Update(config: ProjectCracked, filesToCompile) = async {
381+
member this.Update(projCracked: ProjectCracked, filesToCompile) = async {
378382
let! implFiles, errors, _ =
379383
Some(Array.last filesToCompile)
380-
|> checkProject config this.Checker
384+
|> checkProject projCracked this.Checker
381385

382386
let filesToCompile = set filesToCompile
383387
let implFiles = implFiles |> List.filter (fun f -> filesToCompile.Contains(f.FileName))
384-
return ProjectChecked(checker, errors, this.Project.Update(implFiles))
388+
return ProjectChecked(checker, errors, this.Project.Update(implFiles, mkCompiler = (fun p f -> projCracked.MakeCompiler(f, p))))
385389
}
386390

387391
type Watcher =
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"profiles": {
3+
"Fable.Cli": {
4+
"commandName": "Project",
5+
"commandLineArgs": "watch src/Quicktest --noCache --exclude Fable.Core",
6+
"workingDirectory": "C:\\Users\\alfon\\repos\\Fable"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)