Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
safesparrow committed Oct 22, 2022
1 parent ef5a332 commit 126c584
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Compiler/Driver/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module internal FSharp.Compiler.ParseAndCheckInputs

open System
open System.Diagnostics
open System.IO
open System.Collections.Generic

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

let totalSw = Stopwatch()
let mutable singles = 0

let AddCheckResultsToTcState
(tcGlobals, amap, hadSig, prefixPathOpt, tcSink, tcImplEnv, qualNameOfFile, implFileSigType)
(tcState: TcState)
=

let sw = Stopwatch.StartNew()
totalSw.Start()

let rootImpls = Zset.add qualNameOfFile tcState.tcsRootImpls

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

sw.Stop()
totalSw.Stop()
singles <- singles + 1
printfn $"[{singles}] single add took {sw.ElapsedMilliseconds}ms, total so far: {totalSw.ElapsedMilliseconds}ms"

ccuSigForFile, tcState

let AddDummyCheckResultsToTcState
Expand Down
24 changes: 24 additions & 0 deletions tests/FSharp.Compiler.Service.Tests2/DepResolving.fs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,30 @@ module internal AutomatedDependencyResolving =
)
|> dict

let transitiveDeps = Dictionary<int, int[]>()

let rec calcTransitiveDeps (idx : int) =
match transitiveDeps.TryGetValue idx with
| true, deps -> deps
| false, _ ->
let directDeps = graph[idx]
let deps =
directDeps
|> Array.collect (
fun dep ->
calcTransitiveDeps dep
|> Array.append [|dep|]
)
|> Array.distinct
transitiveDeps[idx] <- deps
deps

// Calculate transitive closure of the graph
let graph =
graph.Keys
|> Seq.map (fun idx -> idx, calcTransitiveDeps idx)
|> dict

let res =
{
DepsResult.Files = nodes
Expand Down
4 changes: 3 additions & 1 deletion tests/FSharp.Compiler.Service.Tests2/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ let runCompiler () =
[<EntryPoint>]
let main _ =
//TestDepResolving.TestProject(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")
runCompiler ()
//runCompiler ()
//TestDepResolving.TestHardcodedFiles()
TestDepResolving.TestProject(@"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj")
0
6 changes: 6 additions & 0 deletions tests/FSharp.Compiler.Service.Tests2/RunCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ type Node =

[<Test>]
let runCompiler () =
let args =
System.IO.File.ReadAllLines(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.Service.Tests2\args.txt") |> Array.skip 1
FSharp.Compiler.CommandLineMain.main args |> ignore

[<Test>]
let runGrapher () =
// let args =
// System.IO.File.ReadAllLines(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.Service.Tests2\args.txt") |> Array.skip 1
// FSharp.Compiler.CommandLineMain.main args |> ignore
Expand Down
5 changes: 5 additions & 0 deletions tests/FSharp.Compiler.Service.Tests2/TestDepResolving.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open Buildalyzer
open FSharp.Compiler.Service.Tests
open FSharp.Compiler.Service.Tests2.ASTVisit
open FSharp.Compiler.Service.Tests2.DepResolving
open NUnit.Framework
open Newtonsoft.Json
Expand Down Expand Up @@ -120,6 +121,10 @@ let TestProject (projectFile : string) =
let ast = getParseResults code
{Name = f; Code = code; AST = ast}
)
|> Array.filter (fun x ->
ASTVisit.extractModuleRefs x.AST
|> Array.forall (function | ReferenceOrAbbreviation.Reference _ -> true | ReferenceOrAbbreviation.Abbreviation _ -> false)
)
let N = files.Length
log $"{N} files read and parsed"

Expand Down

0 comments on commit 126c584

Please sign in to comment.