Skip to content

Commit 923eac5

Browse files
committed
integrate visualfsharp master
2 parents 216a38b + 2002675 commit 923eac5

File tree

6 files changed

+173
-212
lines changed

6 files changed

+173
-212
lines changed

src/fsharp/CompileOps.fs

Lines changed: 72 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,7 +2796,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
27962796
(sourceFiles |> List.mapi (fun i _ -> (i = n-1)), tcConfig.target.IsExe)
27972797

27982798
// This call can fail if no CLR is found (this is the path to mscorlib)
2799-
member tcConfig.ClrRoot =
2799+
member tcConfig.TargetFrameworkDirectories =
28002800
use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind (BuildPhase.Parameter)
28012801
match tcConfig.clrRoot with
28022802
| Some x ->
@@ -2868,15 +2868,15 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
28682868
member tcConfig.IsSystemAssembly (filename:string) =
28692869
try
28702870
FileSystem.SafeExists filename &&
2871-
((tcConfig.ClrRoot |> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
2871+
((tcConfig.TargetFrameworkDirectories |> List.exists (fun clrRoot -> clrRoot = Path.GetDirectoryName filename)) ||
28722872
(systemAssemblies |> List.exists (fun sysFile -> sysFile = fileNameWithoutExtension filename)))
28732873
with _ ->
28742874
false
28752875

28762876
// This is not the complete set of search paths, it is just the set
28772877
// that is special to F# (as compared to MSBuild resolution)
28782878
member tcConfig.SearchPathsForLibraryFiles =
2879-
[ yield! tcConfig.ClrRoot
2879+
[ yield! tcConfig.TargetFrameworkDirectories
28802880
yield! List.map (tcConfig.MakePathAbsolute) tcConfig.includes
28812881
yield tcConfig.implicitIncludeDir
28822882
yield tcConfig.fsharpBinariesDir ]
@@ -3001,13 +3001,16 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30013001
assemblyName, highestPosition, assemblyGroup)
30023002
|> Array.ofSeq
30033003

3004-
let logmessage showMessages =
3004+
let logMessage showMessages =
30053005
if showMessages && tcConfig.showReferenceResolutions then (fun (message:string)->dprintf "%s\n" message)
30063006
else ignore
30073007

3008-
let logwarning showMessages =
3009-
(fun code message->
3008+
let logErrorOrWarning showMessages =
3009+
(fun isError code message->
30103010
if showMessages && mode = ReportErrors then
3011+
if isError then
3012+
errorR(MSBuildReferenceResolutionError(code,message,errorAndWarningRange))
3013+
else
30113014
match code with
30123015
// These are warnings that mean 'not resolved' for some assembly.
30133016
// Note that we don't get to know the name of the assembly that couldn't be resolved.
@@ -3016,15 +3019,10 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30163019
| "MSB3106"
30173020
-> ()
30183021
| _ ->
3019-
(if code = "MSB3245" then errorR else warning)
3020-
(MSBuildReferenceResolutionWarning(code,message,errorAndWarningRange)))
3021-
3022-
let logerror showMessages =
3023-
(fun code message ->
3024-
if showMessages && mode = ReportErrors then
3025-
errorR(MSBuildReferenceResolutionError(code,message,errorAndWarningRange)))
3026-
3027-
let targetFrameworkVersion = tcConfig.targetFrameworkVersion
3022+
if code = "MSB3245" then
3023+
errorR(MSBuildReferenceResolutionWarning(code,message,errorAndWarningRange))
3024+
else
3025+
warning(MSBuildReferenceResolutionWarning(code,message,errorAndWarningRange)))
30283026

30293027
let targetProcessorArchitecture =
30303028
match tcConfig.platform with
@@ -3033,13 +3031,6 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30333031
| Some(AMD64) -> "amd64"
30343032
| Some(IA64) -> "ia64"
30353033

3036-
let outputDirectory =
3037-
match tcConfig.outputFile with
3038-
| Some(outputFile) -> tcConfig.MakePathAbsolute outputFile
3039-
| None -> tcConfig.implicitIncludeDir
3040-
3041-
let targetFrameworkDirectories = tcConfig.ClrRoot
3042-
30433034
// First, try to resolve everything as a file using simple resolution
30443035
let resolvedAsFile =
30453036
groupedReferences
@@ -3055,14 +3046,13 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
30553046
tcConfig.referenceResolver.Resolve
30563047
(tcConfig.resolutionEnvironment,
30573048
references,
3058-
targetFrameworkVersion,
3059-
targetFrameworkDirectories,
3049+
tcConfig.targetFrameworkVersion,
3050+
tcConfig.TargetFrameworkDirectories,
30603051
targetProcessorArchitecture,
3061-
Path.GetDirectoryName(outputDirectory),
30623052
tcConfig.fsharpBinariesDir, // FSharp binaries directory
30633053
tcConfig.includes, // Explicit include directories
30643054
tcConfig.implicitIncludeDir, // Implicit include directory (likely the project directory)
3065-
logmessage showMessages, logwarning showMessages, logerror showMessages)
3055+
logMessage showMessages, logErrorOrWarning showMessages)
30663056
with
30673057
ReferenceResolver.ResolutionFailure -> error(Error(FSComp.SR.buildAssemblyResolutionFailed(),errorAndWarningRange))
30683058

@@ -4264,38 +4254,25 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
42644254
let invalidateCcu = new Event<_>()
42654255
#endif
42664256

4267-
// Adjust where the code for known F# libraries live relative to the installation of F#
4268-
let codeDir =
4269-
let dir = minfo.compileTimeWorkingDir
4270-
let knownLibraryLocation = @"src\fsharp\" // Help highlighting... "
4271-
let knownLibarySuffixes =
4272-
[ @"FSharp.Core"
4273-
@"FSharp.PowerPack"
4274-
@"FSharp.PowerPack.Linq"
4275-
@"FSharp.PowerPack.Metadata" ]
4276-
match knownLibarySuffixes |> List.tryFind (fun x -> dir.EndsWith(knownLibraryLocation + x,StringComparison.OrdinalIgnoreCase)) with
4277-
| None ->
4278-
dir
4279-
| Some libSuffix ->
4280-
// add "..\lib\FSharp.Core" to the F# binaries directory
4281-
Path.Combine(Path.Combine(tcConfig.fsharpBinariesDir,@"..\lib"),libSuffix)
4282-
4283-
let ccu =
4284-
CcuThunk.Create(ccuName, { ILScopeRef=ilScopeRef
4285-
Stamp = newStamp()
4286-
FileName = Some filename
4287-
QualifiedName= Some(ilScopeRef.QualifiedName)
4288-
SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4289-
IsFSharp=true
4290-
Contents = mspec
4257+
let codeDir = minfo.compileTimeWorkingDir
4258+
let ccuData : CcuData =
4259+
{ ILScopeRef=ilScopeRef
4260+
Stamp = newStamp()
4261+
FileName = Some filename
4262+
QualifiedName= Some(ilScopeRef.QualifiedName)
4263+
SourceCodeDirectory = codeDir (* note: in some cases we fix up this information later *)
4264+
IsFSharp=true
4265+
Contents = mspec
42914266
#if EXTENSIONTYPING
4292-
InvalidateEvent=invalidateCcu.Publish
4293-
IsProviderGenerated = false
4294-
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
4267+
InvalidateEvent=invalidateCcu.Publish
4268+
IsProviderGenerated = false
4269+
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
42954270
#endif
4296-
UsesFSharp20PlusQuotations = minfo.usesQuotations
4297-
MemberSignatureEquality= (fun ty1 ty2 -> Tastops.typeEquivAux EraseAll (tcImports.GetTcGlobals()) ty1 ty2)
4298-
TypeForwarders = ImportILAssemblyTypeForwarders(tcImports.GetImportMap,m, ilModule.GetRawTypeForwarders()) })
4271+
UsesFSharp20PlusQuotations = minfo.usesQuotations
4272+
MemberSignatureEquality= (fun ty1 ty2 -> Tastops.typeEquivAux EraseAll (tcImports.GetTcGlobals()) ty1 ty2)
4273+
TypeForwarders = ImportILAssemblyTypeForwarders(tcImports.GetImportMap,m, ilModule.GetRawTypeForwarders()) }
4274+
4275+
let ccu = CcuThunk.Create(ccuName, ccuData)
42994276

43004277
let optdata =
43014278
lazy
@@ -4310,15 +4287,15 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
43104287
Some res)
43114288
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
43124289
let ccuinfo =
4313-
{ FSharpViewOfMetadata=ccu
4314-
AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes(ilg)
4315-
AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes(ilg)
4316-
FSharpOptimizationData=optdata
4290+
{ FSharpViewOfMetadata=ccu
4291+
AssemblyAutoOpenAttributes = ilModule.GetAutoOpenAttributes(ilg)
4292+
AssemblyInternalsVisibleToAttributes = ilModule.GetInternalsVisibleToAttributes(ilg)
4293+
FSharpOptimizationData=optdata
43174294
#if EXTENSIONTYPING
4318-
IsProviderGenerated = false
4319-
TypeProviders = []
4295+
IsProviderGenerated = false
4296+
TypeProviders = []
43204297
#endif
4321-
ILScopeRef = ilScopeRef }
4298+
ILScopeRef = ilScopeRef }
43224299
let phase2() =
43234300
#if EXTENSIONTYPING
43244301
match ilModule.TryGetRawILModule() with
@@ -4367,15 +4344,16 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
43674344
let phase2() = [tcImports.FindCcuInfo(m,ilShortAssemName,lookupOnly=true)]
43684345
dllinfo,phase2
43694346
else
4370-
let dllinfo = {RawMetadata=assemblyData
4371-
FileName=filename
4347+
let dllinfo =
4348+
{ RawMetadata=assemblyData
4349+
FileName=filename
43724350
#if EXTENSIONTYPING
4373-
ProviderGeneratedAssembly=None
4374-
IsProviderGenerated=false
4375-
ProviderGeneratedStaticLinkMap = None
4351+
ProviderGeneratedAssembly=None
4352+
IsProviderGenerated=false
4353+
ProviderGeneratedStaticLinkMap = None
43764354
#endif
4377-
ILScopeRef = ilScopeRef
4378-
ILAssemblyRefs = assemblyData.ILAssemblyRefs }
4355+
ILScopeRef = ilScopeRef
4356+
ILAssemblyRefs = assemblyData.ILAssemblyRefs }
43794357
tcImports.RegisterDll(dllinfo)
43804358
let ilg = defaultArg ilGlobalsOpt EcmaILGlobals
43814359
let phase2 =
@@ -5177,26 +5155,31 @@ type TcState =
51775155
tcsTcImplEnv = tcEnvAtEndOfLastInput }
51785156

51795157

5158+
/// Create the initial type checking state for compiling an assembly
51805159
let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports,niceNameGen,tcEnv0) =
51815160
ignore tcImports
5161+
51825162
// Create a ccu to hold all the results of compilation
51835163
let ccuType = NewCcuContents ILScopeRef.Local m ccuName (NewEmptyModuleOrNamespaceType Namespace)
5184-
let ccu =
5185-
CcuThunk.Create(ccuName,{IsFSharp=true
5186-
UsesFSharp20PlusQuotations=false
5164+
5165+
let ccuData : CcuData =
5166+
{ IsFSharp=true
5167+
UsesFSharp20PlusQuotations=false
51875168
#if EXTENSIONTYPING
5188-
InvalidateEvent=(new Event<_>()).Publish
5189-
IsProviderGenerated = false
5190-
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
5169+
InvalidateEvent=(new Event<_>()).Publish
5170+
IsProviderGenerated = false
5171+
ImportProvidedType = (fun ty -> Import.ImportProvidedType (tcImports.GetImportMap()) m ty)
51915172
#endif
5192-
FileName=None
5193-
Stamp = newStamp()
5194-
QualifiedName= None
5195-
SourceCodeDirectory = tcConfig.implicitIncludeDir
5196-
ILScopeRef=ILScopeRef.Local
5197-
Contents=ccuType
5198-
MemberSignatureEquality= (Tastops.typeEquivAux EraseAll tcGlobals)
5199-
TypeForwarders=Map.empty })
5173+
FileName=None
5174+
Stamp = newStamp()
5175+
QualifiedName= None
5176+
SourceCodeDirectory = tcConfig.implicitIncludeDir
5177+
ILScopeRef=ILScopeRef.Local
5178+
Contents=ccuType
5179+
MemberSignatureEquality= (Tastops.typeEquivAux EraseAll tcGlobals)
5180+
TypeForwarders=Map.empty }
5181+
5182+
let ccu = CcuThunk.Create(ccuName,ccuData)
52005183

52015184
// OK, is this is the FSharp.Core CCU then fix it up.
52025185
if tcConfig.compilingFslib then
@@ -5214,7 +5197,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports,
52145197
tcsRootSigsAndImpls = RootSigsAndImpls (rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp) }
52155198

52165199

5217-
/// Typecheck a single file or interactive entry into F# Interactive
5200+
/// Typecheck a single file (or interactive entry into F# Interactive)
52185201
let TypeCheckOneInputEventually
52195202
(checkForErrors , tcConfig:TcConfig, tcImports:TcImports,
52205203
tcGlobals, prefixPathOpt, tcSink, tcState: TcState, inp: ParsedInput) =
@@ -5325,12 +5308,14 @@ let TypeCheckOneInputEventually
53255308
return (tcState.TcEnvFromSignatures,EmptyTopAttrs,[]),tcState
53265309
}
53275310

5311+
/// Typecheck a single file (or interactive entry into F# Interactive)
53285312
let TypeCheckOneInput (checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt) tcState inp =
53295313
// 'use' ensures that the warning handler is restored at the end
53305314
use unwindEL = PushErrorLoggerPhaseUntilUnwind(fun oldLogger -> GetErrorLoggerFilteringByScopedPragmas(false,GetScopedPragmasForInput(inp),oldLogger) )
53315315
use unwindBP = PushThreadBuildPhaseUntilUnwind (BuildPhase.TypeCheck)
53325316
TypeCheckOneInputEventually (checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, TcResultsSink.NoSink, tcState, inp) |> Eventually.force
53335317

5318+
/// Finish checking multiple files (or one interactive entry into F# Interactive)
53345319
let TypeCheckMultipleInputsFinish(results,tcState: TcState) =
53355320
let tcEnvsAtEndFile,topAttrs,mimpls = List.unzip3 results
53365321

@@ -5341,11 +5326,12 @@ let TypeCheckMultipleInputsFinish(results,tcState: TcState) =
53415326

53425327
(tcEnvAtEndOfLastFile,topAttrs,mimpls),tcState
53435328

5329+
/// Check multiple files (or one interactive entry into F# Interactive)
53445330
let TypeCheckMultipleInputs (checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) =
53455331
let results,tcState = (tcState, inputs) ||> List.mapFold (TypeCheckOneInput (checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt))
53465332
TypeCheckMultipleInputsFinish(results,tcState)
53475333

5348-
let TypeCheckSingleInputAndFinishEventually(checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input) =
5334+
let TypeCheckOneInputAndFinishEventually(checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input) =
53495335
eventually {
53505336
let! results,tcState = TypeCheckOneInputEventually(checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcSink, tcState, input)
53515337
return TypeCheckMultipleInputsFinish([results],tcState)

src/fsharp/CompileOps.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ type TcConfig =
507507

508508

509509
member ComputeLightSyntaxInitialStatus : string -> bool
510-
member ClrRoot : string list
510+
member TargetFrameworkDirectories : string list
511511
512512
/// Get the loaded sources that exist and issue a warning for the ones that don't
513513
member GetAvailableLoadedSources : unit -> (range*string) list
@@ -728,7 +728,7 @@ val TypeCheckClosedInputSetFinish : TypedImplFile list * TcState -> TcState * Ty
728728
val TypeCheckClosedInputSet :(unit -> bool) * TcConfig * TcImports * TcGlobals * Ast.LongIdent option * TcState * Ast.ParsedInput list -> TcState * TopAttribs * TypedImplFile list * TcEnv
729729

730730
/// Check a single input and finish the checking
731-
val TypeCheckSingleInputAndFinishEventually :
731+
val TypeCheckOneInputAndFinishEventually :
732732
(unit -> bool) * TcConfig * TcImports * TcGlobals * Ast.LongIdent option * NameResolution.TcResultsSink * TcState * Ast.ParsedInput
733733
-> Eventually<(TcEnv * TopAttribs * TypedImplFile list) * TcState>
734734

0 commit comments

Comments
 (0)