Skip to content

Commit ae722fe

Browse files
committed
changes - works end-to-end for .fs files and the diamond example
1 parent b2c265b commit ae722fe

File tree

14 files changed

+221
-52
lines changed

14 files changed

+221
-52
lines changed

src/Compiler/Driver/ParseAndCheckInputs.fs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ let ParseOneInputFile (tcConfig: TcConfig, lexResourceManager, fileName, isLastC
740740
/// NOTE: this needs to be improved to commit diagnotics as soon as possible
741741
///
742742
/// NOTE: If StopProcessing is raised by any piece of work then the overall function raises StopProcessing.
743-
let UseMultipleDiagnosticLoggers (inputs, diagnosticsLogger, eagerFormat) f =
743+
let UseMultipleDiagnosticLoggers ((inputs, diagnosticsLogger, eagerFormat): 'a list * DiagnosticsLogger * (PhasedDiagnostic -> PhasedDiagnostic) option) (f: ('a * CapturingDiagnosticsLogger) list -> 'b): 'b =
744744

745745
// Check input files and create delayed error loggers before we try to parallel parse.
746746
let delayLoggers =
@@ -1060,11 +1060,18 @@ type TcState =
10601060
// a.fsi + b.fsi + c.fsi (after checking implementation file for c.fs)
10611061
member x.CcuSig = x.tcsCcuSig
10621062

1063+
member x.TcsImplicitOpenDeclarations = x.tcsImplicitOpenDeclarations
1064+
10631065
member x.NextStateAfterIncrementalFragment tcEnvAtEndOfLastInput =
10641066
{ x with
10651067
tcsTcSigEnv = tcEnvAtEndOfLastInput
10661068
tcsTcImplEnv = tcEnvAtEndOfLastInput
10671069
}
1070+
1071+
member x.WithCreatesGeneratedProvidedTypes (y : bool) : TcState =
1072+
{ x with
1073+
tcsCreatesGeneratedProvidedTypes = y
1074+
}
10681075

10691076
/// Create the initial type checking state for compiling an assembly
10701077
let GetInitialTcState (m, ccuName, tcConfig: TcConfig, tcGlobals, tcImports: TcImports, tcEnv0, openDecls0) =
@@ -1194,6 +1201,14 @@ let AddDummyCheckResultsToTcState
11941201

11951202
(tcEnvAtEnd, EmptyTopAttrs, Some emptyImplFile, ccuSigForFile), tcState
11961203

1204+
type PartialResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
1205+
1206+
type CheckArgs = CompilationThreadToken * (unit -> bool) * TcConfig * TcImports * TcGlobals * LongIdent option * TcState * (PhasedDiagnostic -> PhasedDiagnostic) * ParsedInput list
1207+
/// Use parallel checking of implementation files that have signature files
1208+
let mutable CheckMultipleInputsInParallel2 : CheckArgs -> (PartialResult list * TcState)
1209+
=
1210+
fun _ -> failwith "Dummy implementation"
1211+
11971212
/// Typecheck a single file (or interactive entry into F# Interactive)
11981213
let CheckOneInputAux
11991214
(
@@ -1433,9 +1448,6 @@ let CheckMultipleInputsSequential (ctok, checkForErrors, tcConfig, tcImports, tc
14331448
(tcState, inputs)
14341449
||> List.mapFold (CheckOneInputEntry args)
14351450

1436-
1437-
type PartialResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
1438-
14391451
/// Use parallel checking of implementation files that have signature files
14401452
let CheckMultipleInputsInParallel
14411453
((ctok,
@@ -1558,16 +1570,16 @@ type WorkInput =
15581570
}
15591571

15601572
/// Use parallel checking of implementation files that have signature files
1561-
let CheckMultipleInputsInParallel2
1562-
((ctok : CancellationToken,
1573+
let CheckMultipleInputsInParallel3
1574+
((ctok : CompilationThreadToken,
15631575
checkForErrors: unit -> bool,
15641576
tcConfig: TcConfig,
15651577
tcImports: TcImports,
15661578
tcGlobals: TcGlobals,
15671579
prefixPathOpt,
15681580
tcState,
15691581
eagerFormat,
1570-
inputs): CancellationToken * (unit -> bool) * TcConfig * TcImports * TcGlobals * LongIdent option * TcState * (PhasedDiagnostic -> PhasedDiagnostic) * ParsedInput list)
1582+
inputs): CompilationThreadToken * (unit -> bool) * TcConfig * TcImports * TcGlobals * LongIdent option * TcState * (PhasedDiagnostic -> PhasedDiagnostic) * ParsedInput list)
15711583
: PartialResult list * TcState =
15721584

15731585
let _ = ctok // TODO Use
@@ -1758,6 +1770,7 @@ let CheckMultipleInputsInParallel2
17581770
partialResults, tcState
17591771
)
17601772

1773+
17611774
let CheckClosedInputSet (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, eagerFormat, inputs) =
17621775
// tcEnvAtEndOfLastFile is the environment required by fsi.exe when incrementally adding definitions
17631776
let results, tcState =

src/Compiler/Driver/ParseAndCheckInputs.fsi

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type ModuleNamesDict = Map<string, Map<string, QualifiedNameOfFile>>
3131
/// Checks if a ParsedInput is using a module name that was already given and deduplicates the name if needed.
3232
val DeduplicateParsedInputModuleName: ModuleNamesDict -> ParsedInput -> ParsedInput * ModuleNamesDict
3333

34+
val UseMultipleDiagnosticLoggers<'a, 'b> :
35+
('a list * DiagnosticsLogger * (PhasedDiagnostic -> PhasedDiagnostic) option) ->
36+
(('a * CapturingDiagnosticsLogger) list -> 'b) ->
37+
'b
38+
3439
/// Parse a single input (A signature file or implementation file)
3540
val ParseInput:
3641
lexer: (Lexbuf -> Parser.token) *
@@ -112,7 +117,6 @@ val GetInitialTcEnv: assemblyName: string * range * TcConfig * TcImports * TcGlo
112117
/// Represents the incremental type checking state for a set of inputs
113118
[<Sealed>]
114119
type TcState =
115-
116120
/// The CcuThunk for the current assembly being checked
117121
member Ccu: CcuThunk
118122

@@ -129,6 +133,22 @@ type TcState =
129133
member NextStateAfterIncrementalFragment: TcEnv -> TcState
130134

131135
member CreatesGeneratedProvidedTypes: bool
136+
137+
member TcsImplicitOpenDeclarations: OpenDeclaration list
138+
139+
member WithCreatesGeneratedProvidedTypes : bool -> TcState
140+
141+
val AddCheckResultsToTcState :
142+
(TcGlobals * Import.ImportMap * bool * LongIdent option * NameResolution.TcResultsSink * TcEnv * QualifiedNameOfFile * ModuleOrNamespaceType)
143+
-> TcState
144+
-> (ModuleOrNamespaceType * TcState)
145+
146+
type PartialResult = TcEnv * TopAttribs * CheckedImplFile option * ModuleOrNamespaceType
147+
148+
type CheckArgs = CompilationThreadToken * (unit -> bool) * TcConfig * TcImports * TcGlobals * LongIdent option * TcState * (PhasedDiagnostic -> PhasedDiagnostic) * ParsedInput list
149+
150+
/// Use parallel checking of implementation files that have signature files
151+
val mutable CheckMultipleInputsInParallel2 : (CheckArgs -> PartialResult list * TcState)
132152

133153
/// Get the initial type checking state for a set of inputs
134154
val GetInitialTcState: range * string * TcConfig * TcGlobals * TcImports * TcEnv * OpenDeclaration list -> TcState

src/Compiler/Utilities/illib.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -924,12 +924,12 @@ module Cancellable =
924924

925925
type CancellableBuilder() =
926926

927-
member inline _.Delay([<InlineIfLambda>] f) =
927+
member _.Delay(f) =
928928
Cancellable(fun ct ->
929929
let (Cancellable g) = f ()
930930
g ct)
931931

932-
member inline _.Bind(comp, [<InlineIfLambda>] k) =
932+
member _.Bind(comp, k) =
933933
Cancellable(fun ct ->
934934
#if !FSHARPCORE_USE_PACKAGE
935935
__debugPoint ""
@@ -939,7 +939,7 @@ type CancellableBuilder() =
939939
| ValueOrCancelled.Value v1 -> Cancellable.run ct (k v1)
940940
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
941941

942-
member inline _.BindReturn(comp, [<InlineIfLambda>] k) =
942+
member _.BindReturn(comp, k) =
943943
Cancellable(fun ct ->
944944
#if !FSHARPCORE_USE_PACKAGE
945945
__debugPoint ""
@@ -949,7 +949,7 @@ type CancellableBuilder() =
949949
| ValueOrCancelled.Value v1 -> ValueOrCancelled.Value(k v1)
950950
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
951951

952-
member inline _.Combine(comp1, comp2) =
952+
member _.Combine(comp1, comp2) =
953953
Cancellable(fun ct ->
954954
#if !FSHARPCORE_USE_PACKAGE
955955
__debugPoint ""
@@ -959,7 +959,7 @@ type CancellableBuilder() =
959959
| ValueOrCancelled.Value () -> Cancellable.run ct comp2
960960
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
961961

962-
member inline _.TryWith(comp, [<InlineIfLambda>] handler) =
962+
member _.TryWith(comp, handler) =
963963
Cancellable(fun ct ->
964964
#if !FSHARPCORE_USE_PACKAGE
965965
__debugPoint ""
@@ -980,7 +980,7 @@ type CancellableBuilder() =
980980
| Choice2Of2 err -> Cancellable.run ct (handler err)
981981
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
982982

983-
member inline _.Using(resource, [<InlineIfLambda>] comp) =
983+
member _.Using(resource, comp) =
984984
Cancellable(fun ct ->
985985
#if !FSHARPCORE_USE_PACKAGE
986986
__debugPoint ""
@@ -1004,7 +1004,7 @@ type CancellableBuilder() =
10041004
| Choice2Of2 err -> raise err
10051005
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
10061006

1007-
member inline _.TryFinally(comp, [<InlineIfLambda>] compensation) =
1007+
member _.TryFinally(comp, compensation) =
10081008
Cancellable(fun ct ->
10091009
#if !FSHARPCORE_USE_PACKAGE
10101010
__debugPoint ""
@@ -1027,12 +1027,12 @@ type CancellableBuilder() =
10271027
| Choice2Of2 err -> raise err
10281028
| ValueOrCancelled.Cancelled err1 -> ValueOrCancelled.Cancelled err1)
10291029

1030-
member inline _.Return v =
1030+
member _.Return v =
10311031
Cancellable(fun _ -> ValueOrCancelled.Value v)
10321032

1033-
member inline _.ReturnFrom(v: Cancellable<'T>) = v
1033+
member _.ReturnFrom(v: Cancellable<'T>) = v
10341034

1035-
member inline _.Zero() =
1035+
member _.Zero() =
10361036
Cancellable(fun _ -> ValueOrCancelled.Value())
10371037

10381038
[<AutoOpen>]

src/Compiler/Utilities/illib.fsi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -394,28 +394,28 @@ type internal CancellableBuilder =
394394

395395
new: unit -> CancellableBuilder
396396

397-
member inline BindReturn: comp: Cancellable<'T> * [<InlineIfLambda>] k: ('T -> 'U) -> Cancellable<'U>
397+
member BindReturn: comp: Cancellable<'T> * k: ('T -> 'U) -> Cancellable<'U>
398398

399-
member inline Bind: comp: Cancellable<'T> * [<InlineIfLambda>] k: ('T -> Cancellable<'U>) -> Cancellable<'U>
399+
member Bind: comp: Cancellable<'T> * k: ('T -> Cancellable<'U>) -> Cancellable<'U>
400400

401-
member inline Combine: comp1: Cancellable<unit> * comp2: Cancellable<'T> -> Cancellable<'T>
401+
member Combine: comp1: Cancellable<unit> * comp2: Cancellable<'T> -> Cancellable<'T>
402402

403-
member inline Delay: [<InlineIfLambda>] f: (unit -> Cancellable<'T>) -> Cancellable<'T>
403+
member Delay: f: (unit -> Cancellable<'T>) -> Cancellable<'T>
404404

405-
member inline Return: v: 'T -> Cancellable<'T>
405+
member Return: v: 'T -> Cancellable<'T>
406406

407-
member inline ReturnFrom: v: Cancellable<'T> -> Cancellable<'T>
407+
member ReturnFrom: v: Cancellable<'T> -> Cancellable<'T>
408408

409-
member inline TryFinally: comp: Cancellable<'T> * [<InlineIfLambda>] compensation: (unit -> unit) -> Cancellable<'T>
409+
member TryFinally: comp: Cancellable<'T> * compensation: (unit -> unit) -> Cancellable<'T>
410410

411-
member inline TryWith:
412-
comp: Cancellable<'T> * [<InlineIfLambda>] handler: (exn -> Cancellable<'T>) -> Cancellable<'T>
411+
member TryWith:
412+
comp: Cancellable<'T> * handler: (exn -> Cancellable<'T>) -> Cancellable<'T>
413413

414-
member inline Using:
415-
resource: 'Resource * [<InlineIfLambda>] comp: ('Resource -> Cancellable<'T>) -> Cancellable<'T>
414+
member Using:
415+
resource: 'Resource * comp: ('Resource -> Cancellable<'T>) -> Cancellable<'T>
416416
when 'Resource :> IDisposable
417417

418-
member inline Zero: unit -> Cancellable<unit>
418+
member Zero: unit -> Cancellable<unit>
419419

420420
[<AutoOpen>]
421421
module internal CancellableAutoOpens =

tests/DiamondTest/B1.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module DiamondTest.B1
2-
2+
open DiamondTest
33
let b1 = A.a + 10

tests/DiamondTest/B2.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module DiamondTest.B2
2-
2+
open DiamondTest
33
let b2 = B1.b1 + 100

tests/DiamondTest/C1.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module DiamondTest.C1
2-
2+
open DiamondTest
33
let c1 = A.a + 30

tests/DiamondTest/C2.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module DiamondTest.C2
2-
2+
open DiamondTest
33
let c2 = C1.c1 + 300

tests/DiamondTest/D.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module DiamondTest.D
2-
2+
open DiamondTest
33
let d = C2.c2 + B2.b2

0 commit comments

Comments
 (0)