Skip to content

Commit 126c584

Browse files
committed
changes
1 parent ef5a332 commit 126c584

5 files changed

Lines changed: 50 additions & 1 deletion

File tree

src/Compiler/Driver/ParseAndCheckInputs.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module internal FSharp.Compiler.ParseAndCheckInputs
55

66
open System
7+
open System.Diagnostics
78
open System.IO
89
open System.Collections.Generic
910

@@ -1114,11 +1115,17 @@ let GetInitialTcState (m, ccuName, tcConfig: TcConfig, tcGlobals, tcImports: TcI
11141115
let CreateEmptyDummyImplFile qualNameOfFile sigTy =
11151116
CheckedImplFile(qualNameOfFile, [], sigTy, ModuleOrNamespaceContents.TMDefs [], false, false, StampMap [], Map.empty)
11161117

1118+
let totalSw = Stopwatch()
1119+
let mutable singles = 0
1120+
11171121
let AddCheckResultsToTcState
11181122
(tcGlobals, amap, hadSig, prefixPathOpt, tcSink, tcImplEnv, qualNameOfFile, implFileSigType)
11191123
(tcState: TcState)
11201124
=
11211125

1126+
let sw = Stopwatch.StartNew()
1127+
totalSw.Start()
1128+
11221129
let rootImpls = Zset.add qualNameOfFile tcState.tcsRootImpls
11231130

11241131
// Only add it to the environment if it didn't have a signature
@@ -1159,6 +1166,11 @@ let AddCheckResultsToTcState
11591166
tcsImplicitOpenDeclarations = tcState.tcsImplicitOpenDeclarations @ openDecls
11601167
}
11611168

1169+
sw.Stop()
1170+
totalSw.Stop()
1171+
singles <- singles + 1
1172+
printfn $"[{singles}] single add took {sw.ElapsedMilliseconds}ms, total so far: {totalSw.ElapsedMilliseconds}ms"
1173+
11621174
ccuSigForFile, tcState
11631175

11641176
let AddDummyCheckResultsToTcState

tests/FSharp.Compiler.Service.Tests2/DepResolving.fs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,30 @@ module internal AutomatedDependencyResolving =
307307
)
308308
|> dict
309309

310+
let transitiveDeps = Dictionary<int, int[]>()
311+
312+
let rec calcTransitiveDeps (idx : int) =
313+
match transitiveDeps.TryGetValue idx with
314+
| true, deps -> deps
315+
| false, _ ->
316+
let directDeps = graph[idx]
317+
let deps =
318+
directDeps
319+
|> Array.collect (
320+
fun dep ->
321+
calcTransitiveDeps dep
322+
|> Array.append [|dep|]
323+
)
324+
|> Array.distinct
325+
transitiveDeps[idx] <- deps
326+
deps
327+
328+
// Calculate transitive closure of the graph
329+
let graph =
330+
graph.Keys
331+
|> Seq.map (fun idx -> idx, calcTransitiveDeps idx)
332+
|> dict
333+
310334
let res =
311335
{
312336
DepsResult.Files = nodes

tests/FSharp.Compiler.Service.Tests2/Program.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ let runCompiler () =
99
[<EntryPoint>]
1010
let main _ =
1111
//TestDepResolving.TestProject(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")
12-
runCompiler ()
12+
//runCompiler ()
13+
//TestDepResolving.TestHardcodedFiles()
14+
TestDepResolving.TestProject(@"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj")
1315
0

tests/FSharp.Compiler.Service.Tests2/RunCompiler.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ type Node =
1818

1919
[<Test>]
2020
let runCompiler () =
21+
let args =
22+
System.IO.File.ReadAllLines(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.Service.Tests2\args.txt") |> Array.skip 1
23+
FSharp.Compiler.CommandLineMain.main args |> ignore
24+
25+
[<Test>]
26+
let runGrapher () =
2127
// let args =
2228
// System.IO.File.ReadAllLines(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.Service.Tests2\args.txt") |> Array.skip 1
2329
// FSharp.Compiler.CommandLineMain.main args |> ignore

tests/FSharp.Compiler.Service.Tests2/TestDepResolving.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
open Buildalyzer
44
open FSharp.Compiler.Service.Tests
5+
open FSharp.Compiler.Service.Tests2.ASTVisit
56
open FSharp.Compiler.Service.Tests2.DepResolving
67
open NUnit.Framework
78
open Newtonsoft.Json
@@ -120,6 +121,10 @@ let TestProject (projectFile : string) =
120121
let ast = getParseResults code
121122
{Name = f; Code = code; AST = ast}
122123
)
124+
|> Array.filter (fun x ->
125+
ASTVisit.extractModuleRefs x.AST
126+
|> Array.forall (function | ReferenceOrAbbreviation.Reference _ -> true | ReferenceOrAbbreviation.Abbreviation _ -> false)
127+
)
123128
let N = files.Length
124129
log $"{N} files read and parsed"
125130

0 commit comments

Comments
 (0)