diff --git a/.vsts-pr.yaml b/.vsts-pr.yaml index 44c277a394..c9f88e2296 100644 --- a/.vsts-pr.yaml +++ b/.vsts-pr.yaml @@ -4,12 +4,11 @@ jobs: vmImage: ubuntu-16.04 timeoutInMinutes: 90 strategy: - maxParallel: 2 + maxParallel: 3 matrix: dotnet_sdk: _command: make _args: Configuration=release - # disabled until it can be properly fixed release_fcs: _command: ./fcs/build.sh _args: Build @@ -23,6 +22,29 @@ jobs: continueOnError: true condition: failed() +- job: MacOS + pool: + vmImage: macOS-10.13 + timeoutInMinutes: 90 + strategy: + maxParallel: 3 + matrix: + dotnet_sdk: + _command: make + _args: Configuration=release + release_fcs: + _command: ./fcs/build.sh + _args: Build + steps: + - script: $(_command) $(_args) + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/artifacts/TestResults' + ArtifactName: 'MacOS $(_command) $(_args)' + publishLocation: Container + continueOnError: true + condition: failed() + - job: Windows pool: vmImage: vs2017-win2016 diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index c5e4108181..f64b9fc88b 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -25,22 +25,38 @@ + + $(RestoreAdditionalProjectSources);$(ArtifactsPackagesDir) + $(ArtifactsPackagesDir) + $(NUGET_PACKAGES) $(UserProfile)\.nuget\packages\ $(HOME)/.nuget/packages/ + $(NuGetPackageRoot)\ $(NuGetPackageRoot)/ + true + /usr + /Library/Frameworks/Mono.framework/Versions/Current + $(MonoRoot)/lib/mono true - /usr/lib/mono/4.5-api - /usr/lib/mono/4.6-api + $(MonoLibFolder)/4.5-api + $(MonoLibFolder)/4.5.1-api + $(MonoLibFolder)/4.5.2-api + $(MonoLibFolder)/4.6-api + $(MonoLibFolder)/4.6.1-api + $(MonoLibFolder)/4.6.2-api + $(MonoLibFolder)/4.7-api + $(MonoLibFolder)/4.7.1-api + $(MonoLibFolder)/4.7.2-api @@ -51,6 +67,7 @@ true true + $(FSharpSourcesRoot)\fsharp\test.snk false diff --git a/benchmarks/CompilerServiceBenchmarks/Program.fs b/benchmarks/CompilerServiceBenchmarks/Program.fs index d5e4527577..95485c5c14 100644 --- a/benchmarks/CompilerServiceBenchmarks/Program.fs +++ b/benchmarks/CompilerServiceBenchmarks/Program.fs @@ -2,8 +2,8 @@ open System.IO open BenchmarkDotNet.Attributes open BenchmarkDotNet.Running -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.SourceCodeServices open System.Text [] diff --git a/build/targets/AssemblyVersions.props b/build/targets/AssemblyVersions.props index b17f940a93..4ef9868ac1 100644 --- a/build/targets/AssemblyVersions.props +++ b/build/targets/AssemblyVersions.props @@ -21,7 +21,8 @@ <_Build_Number>$(BUILD_BUILDNUMBER.Substring(9)) $(_Build_Year).$(_Build_Month).$(_Build_Day).$(_Build_Number) - 4.5 + 4.5 + $(FSLanguageVersion) $(FSCoreMajorVersion).5 $(FSCoreMajorVersion).0.0 diff --git a/build/targets/ConvertPortablePdbs.targets b/build/targets/ConvertPortablePdbs.targets index c43042a499..8b1de2982b 100644 --- a/build/targets/ConvertPortablePdbs.targets +++ b/build/targets/ConvertPortablePdbs.targets @@ -7,16 +7,18 @@ + $(SymStoreDirectory)\$(TargetFramework) $(NuGetPackageRoot)Pdb2Pdb\$(Pdb2PdbPackageVersion)\tools\Pdb2Pdb.exe - "$(TargetPath)" /out "$(SymStoreDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public + "$(TargetPath)" /out "$(ConvertedPdbsDirectory)\$(TargetName).pdb" /srcsvrvar SRC_INDEX=public - + diff --git a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs index 72e3449967..eff81a3d24 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs @@ -1,4 +1,4 @@ -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices #if !NETSTANDARD1_6 open System.Runtime.Serialization.Json @@ -69,7 +69,7 @@ type ProjectCracker = yield v |] - let ret, opts = Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectCrackerTool.crackOpen arguments + let ret, opts = FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectCrackerTool.crackOpen arguments ignore ret #else let arguments = new StringBuilder() diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs index e3de75d0d1..8379737c93 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs @@ -1,4 +1,4 @@ -namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool +namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool open System open System.Reflection diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs index 71cb966fb1..a48bdc25aa 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs @@ -1,4 +1,4 @@ -namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool +namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool [] type ProjectOptions = diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs index daa5c3c9e0..7cf970f7a7 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs @@ -1,4 +1,4 @@ -namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool +namespace FSharp.Compiler.SourceCodeServices.ProjectCrackerTool open System open System.IO diff --git a/fcs/FSharp.Compiler.Service.Tests/app.runsettings b/fcs/FSharp.Compiler.Service.Tests/app.runsettings new file mode 100644 index 0000000000..009d9b6977 --- /dev/null +++ b/fcs/FSharp.Compiler.Service.Tests/app.runsettings @@ -0,0 +1,8 @@ + + + + + 1 + + + diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj index bfd4295003..a2077ba080 100644 --- a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -57,11 +57,11 @@ FSStrings.resources - --module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser --open Microsoft.FSharp.Compiler.AbstractIL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + --module FSharp.Compiler.AbstractIL.Internal.AsciiParser --open FSharp.Compiler.AbstractIL --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing ilpars.fsy - --module Microsoft.FSharp.Compiler.Parser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + --module FSharp.Compiler.Parser --open FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing pars.fsy @@ -294,7 +294,7 @@ ParserAndUntypedAST/pplex.fsl - --module Microsoft.FSharp.Compiler.PPParser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + --module FSharp.Compiler.PPParser --open FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing ParserAndUntypedAST/pppars.fsy diff --git a/fcs/docsrc/content/caches.fsx b/fcs/docsrc/content/caches.fsx index e63857c5da..b2cd931775 100644 --- a/fcs/docsrc/content/caches.fsx +++ b/fcs/docsrc/content/caches.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Notes on the FSharpChecker caches ================================================= diff --git a/fcs/docsrc/content/compiler.fsx b/fcs/docsrc/content/compiler.fsx index 534e65d5ad..a934bc8209 100644 --- a/fcs/docsrc/content/compiler.fsx +++ b/fcs/docsrc/content/compiler.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Hosted Compiler =============== @@ -29,7 +29,7 @@ First, we need to reference the libraries that contain F# interactive service: #r "FSharp.Compiler.Service.dll" open System.IO -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // Create an interactive checker instance let checker = FSharpChecker.Create() @@ -55,7 +55,9 @@ let x = 3 + 4 Now invoke the compiler: *) -let errors1, exitCode1 = checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) +let errors1, exitCode1 = + checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) + |> Async.RunSynchronously (** @@ -68,7 +70,9 @@ module M let x = 1.0 + "" // a type error """) -let errors1b, exitCode1b = checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) +let errors1b, exitCode1b = + checker.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) + |> Async.RunSynchronously (** @@ -85,10 +89,12 @@ The 'None' option indicates that the initiatlization code for the assembly is no *) let errors2, exitCode2, dynAssembly2 = checker.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None) + |> Async.RunSynchronously (* Passing 'Some' for the 'execute' parameter executes the initiatlization code for the assembly. *) let errors3, exitCode3, dynAssembly3 = checker.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr)) + |> Async.RunSynchronously diff --git a/fcs/docsrc/content/corelib.fsx b/fcs/docsrc/content/corelib.fsx index e7959385f8..61c249d2ac 100644 --- a/fcs/docsrc/content/corelib.fsx +++ b/fcs/docsrc/content/corelib.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Notes on FSharp.Core.dll ================================================= @@ -13,14 +13,11 @@ include a copy of FSharp.Core.dll as part of your application. For example, if you build a ``HostedCompiler.exe``, you will normally place an FSharp.Core.dll (say 4.3.1.0) alongside your ``HostedCompiler.exe``. -If doing dynamic compilation and execution you may also need to include -an FSharp.Core.optdata and FSharp.Core.sigdata, see below for guidance. - Binding redirects for your application -------------------------------------- The FSharp.Compiler.Service.dll component depends on FSharp.Core 4.4.0.0. Normally your application will target -a later version of FSharp.Core, and you will need a [binding redirect](http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) to ensure +a later version of FSharp.Core, and you may need a [binding redirect](http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx) to ensure that other versions of FSharp.Core forward to the final version of FSharp.Core.dll your application uses. Binding redirect files are normally generated automatically by build tools. If not, you can use one like this (if your tool is called ``HostedCompiler.exe``, the binding redirect file is called ``HostedCompiler.exe.config``) @@ -80,27 +77,12 @@ by the following choice: 2. If there is no static reference to FSharp.Core in the host assembly, then - - For FSharp.Compiler.Service 0.x series, a reference to FSharp.Core version 4.3.0.0 is added - - - For FSharp.Compiler.Service 1.3.1.x (F# 3.1 series), a reference to FSharp.Core version 4.3.1.0 is added - - - For FSharp.Compiler.Service 1.4.0.x (F# 4.0 series), a reference to FSharp.Core version 4.4.0.0 is added + - For FSharp.Compiler.Service 1.4.0.x above (F# 4.0 series), a reference to FSharp.Core version 4.4.0.0 is added Do I need to include FSharp.Core.optdata and FSharp.Core.sigdata? -------------------------------------- -If your compilation arguments explicitly reference an FSharp.Core.dll from an SDK location, then FSharp.Core.sigdata and FSharp.Core.optdata should be alongside the DLL -(if these files are not installed, then that's a bug in the F# SDK installation). If your compilation -arguments are always making an explicit reference, then you should _not_ include FSharp.Core.optdata and FSharp.Core.sigdata as part of your application. - -If you are relying on an implicit reference (e.g. for script processing, see above), this means your tool may reference the FSharp.Core.dll -that is part of your application. In this case, you may either get an error that FSharp.Core.optdata and FSharp.Core.sigdata are not -found alongside FSharp.Core.dll. **If you want to implicitly reference the FSharp.Core.dll you are including in your application, -then also add FSharp.Core.sigdata and FSharp.Core.optdata as two additional files to your application**. When using ``CompileToDynamicAssembly``, this problem -can also manifest itself as [a stack overflow during assembly resolution](https://github.com/fsharp/FSharp.Compiler.Service/issues/258). - -Tools that dynamically compile and execute code (e.g. a ``HostedExecution.exe``) often make an implicit -reference to FSharp.Core.dll, which means they normally also include FSharp.Core.optdata and FSharp.Core.sigdata. +No, unless you are doing something with very old FSharp.Core.dll. Summary ------- diff --git a/fcs/docsrc/content/editor.fsx b/fcs/docsrc/content/editor.fsx index d6b19fd0e6..70b6abff45 100644 --- a/fcs/docsrc/content/editor.fsx +++ b/fcs/docsrc/content/editor.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Editor services ================================== @@ -26,7 +26,7 @@ of `InteractiveChecker`: #r "FSharp.Compiler.Service.dll" open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // Create an interactive checker instance let checker = FSharpChecker.Create() @@ -52,7 +52,7 @@ let input = let inputLines = input.Split('\n') let file = "/home/user/Test.fsx" -let projOptions = +let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -127,11 +127,11 @@ identifier (the other option lets you get tooltip with full assembly location wh *) // Get tag of the IDENT token to be used as the last argument -open Microsoft.FSharp.Compiler +open FSharp.Compiler let identToken = FSharpTokenTag.Identifier // Get tool tip at the specified location -let tip = checkFileResults.GetToolTipTextAlternate(4, 7, inputLines.[1], ["foo"], identToken) +let tip = checkFileResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken) printfn "%A" tip (** @@ -165,7 +165,7 @@ where we need to perform the completion. // Get declarations (autocomplete) for a location let decls = checkFileResults.GetDeclarationListInfo - (Some parseFileResults, 7, 23, inputLines.[6], [], "msg", fun _ -> false) + (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun () -> []), fun _ -> false) |> Async.RunSynchronously // Print the names of available items @@ -197,7 +197,7 @@ changes): *) // Get overloads of the String.Concat method let methods = - checkFileResults.GetMethodsAlternate(5, 27, inputLines.[4], Some ["String"; "Concat"]) + checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously // Print concatenated parameter lists diff --git a/fcs/docsrc/content/filesystem.fsx b/fcs/docsrc/content/filesystem.fsx index 1461d024fb..6c968803bb 100644 --- a/fcs/docsrc/content/filesystem.fsx +++ b/fcs/docsrc/content/filesystem.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Virtualized File System ========================================== @@ -21,7 +21,7 @@ open System open System.IO open System.Collections.Generic open System.Text -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library let defaultFileSystem = Shim.FileSystem @@ -59,18 +59,26 @@ let B = File1.A + File1.A""" // Implement the service related to temporary paths and file time stamps member __.GetTempPathShim() = defaultFileSystem.GetTempPathShim() + member __.GetLastWriteTimeShim(fileName) = defaultFileSystem.GetLastWriteTimeShim(fileName) + member __.GetFullPathShim(fileName) = defaultFileSystem.GetFullPathShim(fileName) + member __.IsInvalidPathShim(fileName) = defaultFileSystem.IsInvalidPathShim(fileName) + member __.IsPathRootedShim(fileName) = defaultFileSystem.IsPathRootedShim(fileName) + member __.IsStableFileHeuristic(fileName) = + defaultFileSystem.IsStableFileHeuristic(fileName) + // Implement the service related to file existence and deletion member __.SafeExists(fileName) = files.ContainsKey(fileName) || defaultFileSystem.SafeExists(fileName) + member __.FileDelete(fileName) = defaultFileSystem.FileDelete(fileName) @@ -78,6 +86,7 @@ let B = File1.A + File1.A""" // and for F# interactive. member __.AssemblyLoadFrom(fileName) = defaultFileSystem.AssemblyLoadFrom fileName + member __.AssemblyLoad(assemblyName) = defaultFileSystem.AssemblyLoad assemblyName @@ -90,7 +99,7 @@ Doing a compilation with the FileSystem --------------------------------------- *) -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices let checker = FSharpChecker.Create() @@ -131,7 +140,11 @@ let projectOptions = yield "-r:" + r |] { ProjectFileName = @"c:\mycode\compilation.fsproj" // Make a name that is unique in this directory. - ProjectFileNames = [| fileName1; fileName2 |] + ProjectId = None + SourceFiles = [| fileName1; fileName2 |] + OriginalLoadReferences = [] + ExtraProjectInfo=None + Stamp = None OtherOptions = allFlags ReferencedProjects = [| |] IsIncompleteTypeCheckEnvironment = false diff --git a/fcs/docsrc/content/interactive.fsx b/fcs/docsrc/content/interactive.fsx index 6e09cfd13e..94a004b36f 100644 --- a/fcs/docsrc/content/interactive.fsx +++ b/fcs/docsrc/content/interactive.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Interactive Service: Embedding F# Interactive ============================================= @@ -31,8 +31,8 @@ First, we need to reference the libraries that contain F# interactive service: *) #r "FSharp.Compiler.Service.dll" -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Interactive.Shell (** To communicate with F# interactive, we need to create streams that represent input and @@ -211,7 +211,9 @@ fsiSession.EvalInteraction "let xxx = 1 + 1" Now you want to typecheck the partially complete code `xxx + xx` *) -let parseResults, checkResults, checkProjectResults = fsiSession.ParseAndCheckInteraction("xxx + xx") +let parseResults, checkResults, checkProjectResults = + fsiSession.ParseAndCheckInteraction("xxx + xx") + |> Async.RunSynchronously (** The `parseResults` and `checkResults` have types `ParseFileResults` and `CheckFileResults` @@ -225,10 +227,10 @@ based on the declarations executed so far. You can also request declaration list information, tooltip text and symbol resolution: *) -open Microsoft.FSharp.Compiler +open FSharp.Compiler // get a tooltip -checkResults.GetToolTipTextAlternate(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT) +checkResults.GetToolTipText(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT) checkResults.GetSymbolUseAtLocation(1, 2, "xxx + xx", ["xxx"]) // symbol xxx diff --git a/fcs/docsrc/content/ja/compiler.fsx b/fcs/docsrc/content/ja/compiler.fsx index 393f837cb5..db49ab825d 100644 --- a/fcs/docsrc/content/ja/compiler.fsx +++ b/fcs/docsrc/content/ja/compiler.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラの組み込み ==================== @@ -18,10 +18,10 @@ *) #r "FSharp.Compiler.Service.dll" -open Microsoft.FSharp.Compiler.SimpleSourceCodeServices +open FSharp.Compiler.SourceCodeServices open System.IO -let scs = SimpleSourceCodeServices() +let scs = FSharpChecker.Create() (** 次に、一時ファイルへコンテンツを書き込みます: @@ -44,7 +44,7 @@ let x = 3 + 4 そしてコンパイラを呼び出します: *) -let errors1, exitCode1 = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) +let errors1, exitCode1 = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) |> Async.RunSynchronously (** @@ -57,7 +57,7 @@ module M let x = 1.0 + "" // a type error """) -let errors1b, exitCode1b = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) +let errors1b, exitCode1b = scs.Compile([| "fsc.exe"; "-o"; fn3; "-a"; fn2 |]) |> Async.RunSynchronously if exitCode1b <> 0 then errors1b @@ -79,11 +79,11 @@ if exitCode1b <> 0 then 'execute' 引数に 'None' を指定するとアセンブリ用の初期化コードが実行されません。 *) let errors2, exitCode2, dynAssembly2 = - scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None) + scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], execute=None) |> Async.RunSynchronously (** 'Some' を指定するとアセンブリ用の初期化コードが実行されます。 *) let errors3, exitCode3, dynAssembly3 = - scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr)) + scs.CompileToDynamicAssembly([| "-o"; fn3; "-a"; fn2 |], Some(stdout,stderr)) |> Async.RunSynchronously diff --git a/fcs/docsrc/content/ja/corelib.fsx b/fcs/docsrc/content/ja/corelib.fsx index e2189faaea..fc47377cfa 100644 --- a/fcs/docsrc/content/ja/corelib.fsx +++ b/fcs/docsrc/content/ja/corelib.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス: FSharp.Core.dll についてのメモ ================================================== diff --git a/fcs/docsrc/content/ja/editor.fsx b/fcs/docsrc/content/ja/editor.fsx index 7bd61da518..439791d3c5 100644 --- a/fcs/docsrc/content/ja/editor.fsx +++ b/fcs/docsrc/content/ja/editor.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス: エディタサービス ==================================== @@ -28,7 +28,7 @@ #r "FSharp.Compiler.Service.dll" open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() @@ -44,7 +44,7 @@ let checker = FSharpChecker.Create() *) // サンプルの入力となる複数行文字列 let input = -""" + """ open System let foo() = @@ -56,9 +56,9 @@ printfn "%s" msg. let inputLines = input.Split('\n') let file = "/home/user/Test.fsx" -let projOptions = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously +let projOptions, _errors1 = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously -let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(projOptions) +let parsingOptions, _errors2 = checker.GetParsingOptionsFromProjectOptions(projOptions) (** @@ -73,8 +73,8 @@ let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(projOp *) // パースを実行 let parseFileResults = -checker.ParseFile(file, input, parsingOptions) -|> Async.RunSynchronously + checker.ParseFile(file, input, parsingOptions) + |> Async.RunSynchronously (** `TypeCheckResults` に備えられた興味深い機能の紹介に入る前に、 サンプル入力に対して型チェッカーを実行する必要があります。 @@ -84,25 +84,25 @@ F#コードにエラーがあった場合も何らかの型チェックの結果 // 型チェックを実行 let checkFileAnswer = -checker.CheckFileInProject(parseFileResults, file, 0, input, projOptions) -|> Async.RunSynchronously + checker.CheckFileInProject(parseFileResults, file, 0, input, projOptions) + |> Async.RunSynchronously (** あるいは `ParseAndCheckFileInProject` を使用すれば1つの操作で両方のチェックを行うことができます: *) let parseResults2, checkFileAnswer2 = -checker.ParseAndCheckFileInProject(file, 0, input, projOptions) -|> Async.RunSynchronously + checker.ParseAndCheckFileInProject(file, 0, input, projOptions) + |> Async.RunSynchronously (** この返り値は `CheckFileAnswer` 型で、この型に機能的に興味深いものが揃えられています... *) let checkFileResults = -match checkFileAnswer with -| FSharpCheckFileAnswer.Succeeded(res) -> res -| res -> failwithf "パースが完了していません... (%A)" res + match checkFileAnswer with + | FSharpCheckFileAnswer.Succeeded(res) -> res + | res -> failwithf "パースが完了していません... (%A)" res (** @@ -137,11 +137,10 @@ match checkFileAnswer with *) // 最後の引数に指定する、IDENTトークンのタグを取得 -open Microsoft.FSharp.Compiler -let identToken = Parser.tagOfToken(Parser.token.IDENT("")) +open FSharp.Compiler // 特定の位置におけるツールチップを取得 -let tip = checkFileResults.GetToolTipTextAlternate(4, 7, inputLines.[1], ["foo"], identToken) +let tip = checkFileResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], FSharpTokenTag.Identifier) printfn "%A" tip (** @@ -178,13 +177,13 @@ printfn "%A" tip *) // 特定の位置における宣言(自動補完)を取得する let decls = -checkFileResults.GetDeclarationListInfo -(Some parseFileResults, 7, 23, inputLines.[6], [], "msg", fun _ -> false) -|> Async.RunSynchronously + checkFileResults.GetDeclarationListInfo + (Some parseFileResults, 7, inputLines.[6], PartialLongName.Empty 23, (fun _ -> []), fun _ -> false) + |> Async.RunSynchronously // 利用可能な項目を表示 for item in decls.Items do -printfn " - %s" item.Name + printfn " - %s" item.Name (** > **注意:** `GetDeclarationListInfo` は古い関数 `GetDeclarations` に代わるものです。 @@ -214,13 +213,13 @@ printfn " - %s" item.Name *) //String.Concatメソッドのオーバーロードを取得する let methods = -checkFileResults.GetMethodsAlternate(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously + checkFileResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously // 連結された引数リストを表示 for mi in methods.Methods do -[ for p in mi.Parameters -> p.Display ] -|> String.concat ", " -|> printfn "%s(%s)" methods.MethodName + [ for p in mi.Parameters -> p.Display ] + |> String.concat ", " + |> printfn "%s(%s)" methods.MethodName (** ここでは `Display` プロパティを使用することで各引数に対する アノテーションを取得しています。 diff --git a/fcs/docsrc/content/ja/filesystem.fsx b/fcs/docsrc/content/ja/filesystem.fsx index 1646b49ccf..453a145eba 100644 --- a/fcs/docsrc/content/ja/filesystem.fsx +++ b/fcs/docsrc/content/ja/filesystem.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス: ファイルシステム仮想化 ========================================== @@ -21,7 +21,7 @@ open System open System.IO open System.Collections.Generic open System.Text -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library let defaultFileSystem = Shim.FileSystem @@ -48,6 +48,9 @@ let B = File1.A + File1.A""" member __.FileStreamCreateShim(fileName) = defaultFileSystem.FileStreamCreateShim(fileName) + member __.IsStableFileHeuristic(fileName) = + defaultFileSystem.IsStableFileHeuristic(fileName) + member __.FileStreamWriteExistingShim(fileName) = defaultFileSystem.FileStreamWriteExistingShim(fileName) @@ -59,18 +62,23 @@ let B = File1.A + File1.A""" // 一時パスおよびファイルのタイムスタンプに関連する機能を実装 member __.GetTempPathShim() = defaultFileSystem.GetTempPathShim() + member __.GetLastWriteTimeShim(fileName) = defaultFileSystem.GetLastWriteTimeShim(fileName) + member __.GetFullPathShim(fileName) = defaultFileSystem.GetFullPathShim(fileName) + member __.IsInvalidPathShim(fileName) = defaultFileSystem.IsInvalidPathShim(fileName) + member __.IsPathRootedShim(fileName) = defaultFileSystem.IsPathRootedShim(fileName) // ファイルの存在確認および削除に関連する機能を実装 member __.SafeExists(fileName) = files.ContainsKey(fileName) || defaultFileSystem.SafeExists(fileName) + member __.FileDelete(fileName) = defaultFileSystem.FileDelete(fileName) @@ -78,6 +86,7 @@ let B = File1.A + File1.A""" // 型プロバイダやF# Interactiveで使用される。 member __.AssemblyLoadFrom(fileName) = defaultFileSystem.AssemblyLoadFrom fileName + member __.AssemblyLoad(assemblyName) = defaultFileSystem.AssemblyLoad assemblyName @@ -90,7 +99,7 @@ FileSystemによるコンパイルの実行 -------------------------------- *) -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices let checker = FSharpChecker.Create() let projectOptions = @@ -114,7 +123,11 @@ let projectOptions = yield "-r:" + r |] { ProjectFileName = @"c:\mycode\compilation.fsproj" // 現在のディレクトリで一意な名前を指定 - ProjectFileNames = [| fileName1; fileName2 |] + ProjectId = None + SourceFiles = [| fileName1; fileName2 |] + OriginalLoadReferences = [] + ExtraProjectInfo=None + Stamp = None OtherOptions = allFlags ReferencedProjects=[| |] IsIncompleteTypeCheckEnvironment = false diff --git a/fcs/docsrc/content/ja/interactive.fsx b/fcs/docsrc/content/ja/interactive.fsx index 63240cd98f..c67b5f2746 100644 --- a/fcs/docsrc/content/ja/interactive.fsx +++ b/fcs/docsrc/content/ja/interactive.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** インタラクティブサービス: F# Interactiveの組み込み ================================================== @@ -42,8 +42,8 @@ F# Interactiveの開始 *) #r "FSharp.Compiler.Service.dll" -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Interactive.Shell (** F# Interactiveとやりとりするには、入出力を表すストリームを作成する必要があります。 @@ -226,7 +226,8 @@ fsiSession.EvalInteraction "let xxx = 1 + 1" 次に部分的に完全な `xxx + xx` というコードの型チェックを実行したいとします: *) -let parseResults, checkResults, checkProjectResults = fsiSession.ParseAndCheckInteraction("xxx + xx") +let parseResults, checkResults, checkProjectResults = + fsiSession.ParseAndCheckInteraction("xxx + xx") |> Async.RunSynchronously (** `parseResults` と `checkResults` はそれぞれ [エディタ](editor.html) @@ -243,10 +244,10 @@ checkResults.Errors.Length // 1 要求することもできます: *) -open Microsoft.FSharp.Compiler +open FSharp.Compiler // ツールチップを取得する -checkResults.GetToolTipTextAlternate(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT) +checkResults.GetToolTipText(1, 2, "xxx + xx", ["xxx"], FSharpTokenTag.IDENT) checkResults.GetSymbolUseAtLocation(1, 2, "xxx + xx", ["xxx"]) // シンボル xxx diff --git a/fcs/docsrc/content/ja/project.fsx b/fcs/docsrc/content/ja/project.fsx index 3e2895b9f3..0249107d9c 100644 --- a/fcs/docsrc/content/ja/project.fsx +++ b/fcs/docsrc/content/ja/project.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス: プロジェクトの分析 ====================================== @@ -24,7 +24,7 @@ open System open System.Collections.Generic -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() diff --git a/fcs/docsrc/content/ja/symbols.fsx b/fcs/docsrc/content/ja/symbols.fsx index d6abee1233..c4a5097394 100644 --- a/fcs/docsrc/content/ja/symbols.fsx +++ b/fcs/docsrc/content/ja/symbols.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス: シンボルの処理 ================================== @@ -21,7 +21,7 @@ open System open System.IO -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // インタラクティブチェッカーのインスタンスを作成 let checker = FSharpChecker.Create() @@ -34,7 +34,7 @@ let checker = FSharpChecker.Create() let parseAndTypeCheckSingleFile (file, input) = // スタンドアロンの(スクリプト)ファイルを表すコンテキストを取得 - let projOptions = + let projOptions, _errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -113,8 +113,8 @@ fnVal.CurriedParameterGroups.[0].[0].Name // "x" fnVal.CurriedParameterGroups.[0].[1].Name // "y" fnVal.DeclarationLocation.StartLine // 3 fnVal.DisplayName // "foo" -fnVal.DeclaringEntity.DisplayName // "Test" -fnVal.DeclaringEntity.DeclarationLocation.StartLine // 1 +fnVal.DeclaringEntity.Value.DisplayName // "Test" +fnVal.DeclaringEntity.Value.DeclarationLocation.StartLine // 1 fnVal.GenericParameters.Count // 0 fnVal.InlineAnnotation // FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern // false @@ -203,7 +203,7 @@ for assembly in projectContext.GetReferencedAssemblies() do 構成することもできます。 *) let parseAndCheckScript (file, input) = - let projOptions = + let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously diff --git a/fcs/docsrc/content/ja/tokenizer.fsx b/fcs/docsrc/content/ja/tokenizer.fsx index cf5117bfbd..405bdef14a 100644 --- a/fcs/docsrc/content/ja/tokenizer.fsx +++ b/fcs/docsrc/content/ja/tokenizer.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス:F#トークナイザを使用する ============================================ @@ -21,7 +21,7 @@ F#のソースコードに対して、トークナイザは `SourceCodeServices` 名前空間をオープンします: *) #r "FSharp.Compiler.Service.dll" -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices (** すると `FSharpSourceTokenizer` のインスタンスを作成できるようになります。 このクラスには2つの引数を指定します。 @@ -124,7 +124,7 @@ let rec tokenizeLines state count lines = *) lines |> List.ofSeq -|> tokenizeLines 0L 1 +|> tokenizeLines FSharpTokenizerLexState.Initial 1 (** 重要ではない部分(各行の先頭にある空白文字や、1行目のように空白文字しかない行) を除けば、このコードを実行すると以下のような出力になります: diff --git a/fcs/docsrc/content/ja/untypedtree.fsx b/fcs/docsrc/content/ja/untypedtree.fsx index 5c414de0b6..c398929b80 100644 --- a/fcs/docsrc/content/ja/untypedtree.fsx +++ b/fcs/docsrc/content/ja/untypedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../../../debug/bin/net45/" +#I "../../../../artifacts/bin/fcs/net45" (** コンパイラサービス:型無し構文木の処理 ====================================== @@ -41,7 +41,7 @@ *) #r "FSharp.Compiler.Service.dll" open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices (** ### 型無しパースの実行 @@ -69,7 +69,7 @@ ASTを取得するために、ファイル名とソースコードを受け取 let getUntypedTree (file, input) = // 1つのスクリプトファイルから推測される「プロジェクト」用の // コンパイラオプションを取得する - let projectOptions, _errors = + let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -101,7 +101,7 @@ ASTを理解するには ASTに関連する要素は以下の名前空間に含まれています: *) -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Ast (** ASTを処理する場合、異なる文法的要素に対するパターンマッチを行うような diff --git a/fcs/docsrc/content/project.fsx b/fcs/docsrc/content/project.fsx index abf6ff227f..fc9439e6ad 100644 --- a/fcs/docsrc/content/project.fsx +++ b/fcs/docsrc/content/project.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Project Analysis ================================== @@ -27,7 +27,7 @@ of `InteractiveChecker`: open System open System.Collections.Generic -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // Create an interactive checker instance let checker = FSharpChecker.Create() @@ -306,22 +306,27 @@ correctly and then analyze each project in turn. *) (** -Cracking a project file +Cracking a legacy project file ----------------------------- F# projects normally use the '.fsproj' project file format. -A project cracking facility is provided as a separate NuGet package: -FSharp.Compiler.Service.ProjectCracker. This NuGet package contains a -library FSharp.Compiler.Service.ProjectCracker.dll, which should be +A project cracking facility for legacy old-style .fsproj is provided as a separate NuGet package: +FSharp.Compiler.Service.ProjectCracker. + +Projecet cracking for modern project files should be done using a library such as DotNetProjInfo. +See FsAutoComplete for example code. + +The legacy NuGet package `FSharp.Compiler.Service.ProjectCracker` contains a +library `FSharp.Compiler.Service.ProjectCracker.dll`, which should be referenced by your application directly, and an executable -FSharp.Compiler.Service.ProjectCrackerTool.exe, which should be copied +`FSharp.Compiler.Service.ProjectCrackerTool.exe`, which should be copied into the output folder of your application by the build process. If you install using Paket or NuGet, then this will be configured for you automatically. If not, you should reference the provided `.targets` file manually in your application. This can be found in the NuGet package at `build/net45/FSharp.Compiler.Service.ProjectCrackerTool.targets`. -The reason for this split is so that the analysis of an F# project +The reason for this split was so the analysis of an F# project file is performed out of process, in order that the necessary assembly binding redirects can be applied without requiring the caller to arrange this. In this way MSBuild versions from 4 up to 14 can be diff --git a/fcs/docsrc/content/queue.fsx b/fcs/docsrc/content/queue.fsx index f3d61f19bb..31ac1526d6 100644 --- a/fcs/docsrc/content/queue.fsx +++ b/fcs/docsrc/content/queue.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Notes on the FSharpChecker operations queue ================================================= diff --git a/fcs/docsrc/content/react.fsx b/fcs/docsrc/content/react.fsx index 0ff4a13726..2dfa557238 100644 --- a/fcs/docsrc/content/react.fsx +++ b/fcs/docsrc/content/react.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Reacting to Changes ============================================ diff --git a/fcs/docsrc/content/symbols.fsx b/fcs/docsrc/content/symbols.fsx index ac38053a1b..60eb199f99 100644 --- a/fcs/docsrc/content/symbols.fsx +++ b/fcs/docsrc/content/symbols.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Working with symbols ============================================ @@ -18,7 +18,7 @@ of `FSharpChecker`: open System open System.IO -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // Create an interactive checker instance let checker = FSharpChecker.Create() @@ -31,7 +31,7 @@ We now perform type checking on the specified input: let parseAndTypeCheckSingleFile (file, input) = // Get context representing a stand-alone (script) file - let projOptions = + let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -109,8 +109,8 @@ fnVal.CurriedParameterGroups.[0].[0].Name // "x" fnVal.CurriedParameterGroups.[0].[1].Name // "y" fnVal.DeclarationLocation.StartLine // 3 fnVal.DisplayName // "foo" -fnVal.DeclaringEntity.DisplayName // "Test" -fnVal.DeclaringEntity.DeclarationLocation.StartLine // 1 +fnVal.DeclaringEntity.Value.DisplayName // "Test" +fnVal.DeclaringEntity.Value.DeclarationLocation.StartLine // 1 fnVal.GenericParameters.Count // 0 fnVal.InlineAnnotation // FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern // false @@ -193,7 +193,7 @@ the project for a single script. By specifying a different "projOptions" you can a specification of a larger project. *) let parseAndCheckScript (file, input) = - let projOptions = + let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously diff --git a/fcs/docsrc/content/tokenizer.fsx b/fcs/docsrc/content/tokenizer.fsx index 9ac3d6f34d..f562c8b057 100644 --- a/fcs/docsrc/content/tokenizer.fsx +++ b/fcs/docsrc/content/tokenizer.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Using the F# tokenizer ========================================= @@ -20,7 +20,7 @@ To use the tokenizer, reference `FSharp.Compiler.Service.dll` and open the `SourceCodeServices` namespace: *) #r "FSharp.Compiler.Service.dll" -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices (** Now you can create an instance of `FSharpSourceTokenizer`. The class takes two arguments - the first is the list of defined symbols and the second is the @@ -111,7 +111,7 @@ state and `1` as the number of the first line: *) lines |> List.ofSeq -|> tokenizeLines 0L 1 +|> tokenizeLines FSharpTokenizerLexState.Initial 1 (** Ignoring some unimportant details (like whitespace at the beginning of each line and the first line which is just whitespace), the code generates the following output: diff --git a/fcs/docsrc/content/typedtree.fsx b/fcs/docsrc/content/typedtree.fsx index c963760644..27dc6a2f33 100644 --- a/fcs/docsrc/content/typedtree.fsx +++ b/fcs/docsrc/content/typedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Processing typed expression tree ================================================= @@ -25,7 +25,7 @@ To use the interactive checker, reference `FSharp.Compiler.Service.dll` and open #r "FSharp.Compiler.Service.dll" open System open System.IO -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices (** ### Checking code @@ -41,7 +41,7 @@ let parseAndCheckSingleFile (input) = let file = Path.ChangeExtension(System.IO.Path.GetTempFileName(), "fsx") File.WriteAllText(file, input) // Get context representing a stand-alone (script) file - let projOptions = + let projOptions, _errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -205,6 +205,8 @@ let rec visitExpr f (e:FSharpExpr) = visitExprs f argExprs | BasicPatterns.NewRecord(recordType, argExprs) -> visitExprs f argExprs + | BasicPatterns.NewAnonRecord(recordType, argExprs) -> + visitExprs f argExprs | BasicPatterns.NewTuple(tupleType, argExprs) -> visitExprs f argExprs | BasicPatterns.NewUnionCase(unionType, unionCase, argExprs) -> @@ -213,6 +215,8 @@ let rec visitExpr f (e:FSharpExpr) = visitExpr f quotedExpr | BasicPatterns.FSharpFieldGet(objExprOpt, recordOrClassType, fieldInfo) -> visitObjArg f objExprOpt + | BasicPatterns.AnonRecordGet(objExpr, recordOrClassType, fieldInfo) -> + visitExpr f objExpr | BasicPatterns.FSharpFieldSet(objExprOpt, recordOrClassType, fieldInfo, argExpr) -> visitObjArg f objExprOpt; visitExpr f argExpr | BasicPatterns.Sequential(firstExpr, secondExpr) -> diff --git a/fcs/docsrc/content/untypedtree.fsx b/fcs/docsrc/content/untypedtree.fsx index dc3cabb0a0..4dd89a8d8a 100644 --- a/fcs/docsrc/content/untypedtree.fsx +++ b/fcs/docsrc/content/untypedtree.fsx @@ -1,5 +1,5 @@ (*** hide ***) -#I "../../bin/v4.5/" +#I "../../../artifacts/bin/fcs/net45" (** Compiler Services: Processing untyped syntax tree ================================================= @@ -30,7 +30,7 @@ To use the interactive checker, reference `FSharp.Compiler.Service.dll` and open *) #r "FSharp.Compiler.Service.dll" open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices (** ### Performing untyped parse @@ -56,7 +56,7 @@ return the `ParseTree` property: /// Get untyped tree for a specified input let getUntypedTree (file, input) = // Get compiler options for the 'project' implied by a single script file - let projOptions, _errors = + let projOptions, errors = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously @@ -83,7 +83,7 @@ code](https://github.com/fsharp/fsharp/blob/master/src/fsharp/ast.fs#L464). The relevant parts are in the following namespace: *) -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Ast (** When processing the AST, you will typically write a number of mutually recursive functions diff --git a/fcs/samples/EditorService/Program.fs b/fcs/samples/EditorService/Program.fs index 5a2cb624f0..91c50b36a9 100644 --- a/fcs/samples/EditorService/Program.fs +++ b/fcs/samples/EditorService/Program.fs @@ -1,8 +1,8 @@ // Open the namespace with InteractiveChecker type open System -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.QuickParse +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.QuickParse // Create an interactive checker instance (ignore notifications) let checker = FSharpChecker.Create() diff --git a/fcs/samples/FscExe/FscMain.fs b/fcs/samples/FscExe/FscMain.fs index af8f290df7..94e0a42ceb 100644 --- a/fcs/samples/FscExe/FscMain.fs +++ b/fcs/samples/FscExe/FscMain.fs @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.CommandLineMain +module internal FSharp.Compiler.CommandLineMain open System open System.Diagnostics open System.IO open System.Reflection open System.Runtime.CompilerServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.IL // runningOnMono -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.IL // runningOnMono +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range #if RESIDENT_COMPILER type TypeInThisAssembly() = member x.Dummy = 1 @@ -307,5 +307,5 @@ let main(argv) = try Driver.main(Array.append [| "fsc.exe" |] argv); with e -> - errorRecovery e Microsoft.FSharp.Compiler.Range.range0; + errorRecovery e FSharp.Compiler.Range.range0; 1 diff --git a/fcs/samples/FsiExe/console.fs b/fcs/samples/FsiExe/console.fs index 5f24fe4fd1..efde3707c2 100644 --- a/fcs/samples/FsiExe/console.fs +++ b/fcs/samples/FsiExe/console.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.Interactive +namespace FSharp.Compiler.Interactive open System open System.Text diff --git a/fcs/samples/FsiExe/fsimain.fs b/fcs/samples/FsiExe/fsimain.fs index ead26ca026..c59ef2fe50 100644 --- a/fcs/samples/FsiExe/fsimain.fs +++ b/fcs/samples/FsiExe/fsimain.fs @@ -13,7 +13,7 @@ //---------------------------------------------------------------------------- -module internal Sample.Microsoft.FSharp.Compiler.Interactive.Main +module internal Sample.FSharp.Compiler.Interactive.Main open System open System.Globalization @@ -22,9 +22,9 @@ open System.Reflection open System.Threading open System.Windows.Forms -open Microsoft.FSharp.Compiler.Interactive.Shell -open Microsoft.FSharp.Compiler.Interactive -open Microsoft.FSharp.Compiler +open FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.Interactive +open FSharp.Compiler #nowarn "55" @@ -53,7 +53,7 @@ let WinFormsEventLoop(lcid : int option) = do mainForm.DoCreateHandle(); // Set the default thread exception handler let restart = ref false - { new Microsoft.FSharp.Compiler.Interactive.IEventLoop with + { new FSharp.Compiler.Interactive.IEventLoop with member x.Run() = restart := false Application.Run() @@ -151,7 +151,7 @@ let MainMain argv = #endif try - let console = new Microsoft.FSharp.Compiler.Interactive.ReadLineConsole() + let console = new FSharp.Compiler.Interactive.ReadLineConsole() let getConsoleReadLine (probeToSeeIfConsoleWorks) = let consoleIsOperational = if probeToSeeIfConsoleWorks then diff --git a/fcs/samples/FsiExe/fsiserver.fs b/fcs/samples/FsiExe/fsiserver.fs index 77b9083237..838c259304 100644 --- a/fcs/samples/FsiExe/fsiserver.fs +++ b/fcs/samples/FsiExe/fsiserver.fs @@ -7,7 +7,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. //[] // avoid calling the type "Shared" which is keyword in some languages -namespace Microsoft.FSharp.Compiler.Server.Shared +namespace FSharp.Compiler.Server.Shared // For FSI VS plugin, require FSI to provide services: // e.g. diff --git a/fcs/samples/InteractiveService/Program.fs b/fcs/samples/InteractiveService/Program.fs index 2e2c8b2da4..4b8d968864 100644 --- a/fcs/samples/InteractiveService/Program.fs +++ b/fcs/samples/InteractiveService/Program.fs @@ -1,6 +1,6 @@ open System open System.IO -open Microsoft.FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.Interactive.Shell let sbOut = new Text.StringBuilder() let sbErr = new Text.StringBuilder() diff --git a/fcs/samples/Tokenizer/Program.fs b/fcs/samples/Tokenizer/Program.fs index 9cc79e699f..5a35373673 100644 --- a/fcs/samples/Tokenizer/Program.fs +++ b/fcs/samples/Tokenizer/Program.fs @@ -1,4 +1,4 @@ -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices let sourceTok = FSharpSourceTokenizer([], Some "C:\\test.fsx") diff --git a/fcs/samples/UntypedTree/Program.fs b/fcs/samples/UntypedTree/Program.fs index 3334b093ba..c2a0caee13 100644 --- a/fcs/samples/UntypedTree/Program.fs +++ b/fcs/samples/UntypedTree/Program.fs @@ -1,6 +1,6 @@ // Open the namespace with InteractiveChecker type open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // Create a checker instance (ignore notifications) @@ -18,7 +18,7 @@ let getUntypedTree (file, input) = // ------------------------------------------------------------------ -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Ast /// Walk over all module or namespace declarations /// (basically 'module Foo =' or 'namespace Foo.Bar') diff --git a/fsharp.proj b/fsharp.proj index 92b37d547e..75887c46db 100644 --- a/fsharp.proj +++ b/fsharp.proj @@ -90,7 +90,12 @@ - + + + + + + @@ -106,7 +111,7 @@ - + @@ -135,7 +140,6 @@ - @@ -151,20 +155,25 @@ - + + + - + + + + - + - + diff --git a/src/absil/bytes.fs b/src/absil/bytes.fs index c385e987ab..a272b99a45 100755 --- a/src/absil/bytes.fs +++ b/src/absil/bytes.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Byte arrays -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal open System.IO open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal module internal Bytes = let b0 n = (n &&& 0xFF) diff --git a/src/absil/bytes.fsi b/src/absil/bytes.fsi index 796eb16187..c611e80c77 100755 --- a/src/absil/bytes.fsi +++ b/src/absil/bytes.fsi @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Blobs of bytes, cross-compiling -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal module internal Bytes = diff --git a/src/absil/il.fs b/src/absil/il.fs index 61c5a33a84..19c6fc05e8 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module Microsoft.FSharp.Compiler.AbstractIL.IL +module FSharp.Compiler.AbstractIL.IL #nowarn "49" #nowarn "343" // The type 'ILAssemblyRef' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'. @@ -16,10 +16,10 @@ open System.Collections.Concurrent open System.Runtime.CompilerServices open System.Reflection -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library open Internal.Utilities @@ -1614,7 +1614,11 @@ type ILMethodDef (name: string, attributes: MethodAttributes, implAttributes: Me member __.MetadataIndex = metadataIndex - member x.With (?name: string, ?attributes: MethodAttributes, ?implAttributes: MethodImplAttributes, ?callingConv: ILCallingConv, ?parameters: ILParameters, ?ret: ILReturn, ?body: ILLazyMethodBody, ?securityDecls: ILSecurityDecls, ?isEntryPoint:bool, ?genericParams: ILGenericParameterDefs, ?customAttrs: ILAttributes) = + member x.With (?name: string, ?attributes: MethodAttributes, ?implAttributes: MethodImplAttributes, + ?callingConv: ILCallingConv, ?parameters: ILParameters, ?ret: ILReturn, + ?body: ILLazyMethodBody, ?securityDecls: ILSecurityDecls, ?isEntryPoint:bool, + ?genericParams: ILGenericParameterDefs, ?customAttrs: ILAttributes) = + ILMethodDef (name = defaultArg name x.Name, attributes = defaultArg attributes x.Attributes, implAttributes = defaultArg implAttributes x.ImplAttributes, @@ -1732,7 +1736,9 @@ type ILMethodDefs(f : (unit -> ILMethodDef[])) = member x.FindByNameAndArity (nm, arity) = x.FindByName nm |> List.filter (fun x -> List.length x.Parameters = arity) [] -type ILEventDef(eventType: ILType option, name: string, attributes: EventAttributes, addMethod: ILMethodRef, removeMethod: ILMethodRef, fireMethod: ILMethodRef option, otherMethods: ILMethodRef list, customAttrsStored: ILAttributesStored, metadataIndex: int32) = +type ILEventDef(eventType: ILType option, name: string, attributes: EventAttributes, + addMethod: ILMethodRef, removeMethod: ILMethodRef, fireMethod: ILMethodRef option, + otherMethods: ILMethodRef list, customAttrsStored: ILAttributesStored, metadataIndex: int32) = new (eventType, name, attributes, addMethod, removeMethod, fireMethod, otherMethods, customAttrs) = ILEventDef(eventType, name, attributes, addMethod, removeMethod, fireMethod, otherMethods, storeILCustomAttrs customAttrs, NoMetadataIdx) @@ -1776,7 +1782,9 @@ type ILEventDefs = member x.LookupByName s = let (ILEvents t) = x in t.[s] [] -type ILPropertyDef(name: string, attributes: PropertyAttributes, setMethod: ILMethodRef option, getMethod: ILMethodRef option, callingConv: ILThisConvention, propertyType: ILType, init: ILFieldInit option, args: ILTypes, customAttrsStored: ILAttributesStored, metadataIndex: int32) = +type ILPropertyDef(name: string, attributes: PropertyAttributes, setMethod: ILMethodRef option, + getMethod: ILMethodRef option, callingConv: ILThisConvention, propertyType: ILType, + init: ILFieldInit option, args: ILTypes, customAttrsStored: ILAttributesStored, metadataIndex: int32) = new (name, attributes, setMethod, getMethod, callingConv, propertyType, init, args, customAttrs) = ILPropertyDef(name, attributes, setMethod, getMethod, callingConv, propertyType, init, args, storeILCustomAttrs customAttrs, NoMetadataIdx) @@ -1832,7 +1840,9 @@ let convertFieldAccess (ilMemberAccess:ILMemberAccess) = | ILMemberAccess.Public -> FieldAttributes.Public [] -type ILFieldDef(name: string, fieldType: ILType, attributes: FieldAttributes, data: byte[] option, literalValue: ILFieldInit option, offset: int32 option, marshal: ILNativeType option, customAttrsStored: ILAttributesStored, metadataIndex: int32) = +type ILFieldDef(name: string, fieldType: ILType, attributes: FieldAttributes, data: byte[] option, + literalValue: ILFieldInit option, offset: int32 option, marshal: ILNativeType option, + customAttrsStored: ILAttributesStored, metadataIndex: int32) = new (name, fieldType, attributes, data, literalValue, offset, marshal, customAttrs) = ILFieldDef(name, fieldType, attributes, data, literalValue, offset, marshal, storeILCustomAttrs customAttrs, NoMetadataIdx) @@ -2283,7 +2293,7 @@ type ILModuleDef = member x.ManifestOfAssembly = match x.Manifest with | Some m -> m - | None -> failwith "no manifest. It is possible you are using an auxiliary module of an assembly in a context where the main module of an assembly is expected. Typically the main module of an assembly must be specified first within a list of the modules in an assembly." + | None -> failwith "no manifest" member m.HasManifest = match m.Manifest with None -> false | _ -> true @@ -2512,8 +2522,11 @@ let defaultImageBase = 0x034f0000 (* this is what comes out of ILDASM on 30/04/2 // -------------------------------------------------------------------- let mkILArrTy (ty, shape) = ILType.Array(shape, ty) + let mkILArr1DTy ty = mkILArrTy (ty, ILArrayShape.SingleDimensional) + let isILArrTy ty = match ty with ILType.Array _ -> true| _ -> false + let destILArrTy ty = match ty with ILType.Array(shape, ty) -> (shape, ty) | _ -> failwith "destILArrTy" // -------------------------------------------------------------------- @@ -2522,38 +2535,55 @@ let destILArrTy ty = match ty with ILType.Array(shape, ty) -> (shape, ty) | _ -> [] let tname_Object = "System.Object" + [] let tname_String = "System.String" + [] let tname_Array = "System.Array" + [] let tname_Type = "System.Type" + [] let tname_Int64 = "System.Int64" + [] let tname_UInt64 = "System.UInt64" + [] let tname_Int32 = "System.Int32" + [] let tname_UInt32 = "System.UInt32" + [] let tname_Int16 = "System.Int16" + [] let tname_UInt16 = "System.UInt16" + [] let tname_SByte = "System.SByte" + [] let tname_Byte = "System.Byte" + [] let tname_Single = "System.Single" + [] let tname_Double = "System.Double" + [] let tname_Bool = "System.Boolean" + [] let tname_Char = "System.Char" + [] let tname_IntPtr = "System.IntPtr" + [] let tname_UIntPtr = "System.UIntPtr" @@ -2612,8 +2642,11 @@ type ILGlobals(primaryScopeRef) = let mkILGlobals primaryScopeRef = ILGlobals primaryScopeRef let mkNormalCall mspec = I_call (Normalcall, mspec, None) + let mkNormalCallvirt mspec = I_callvirt (Normalcall, mspec, None) + let mkNormalCallconstraint (ty, mspec) = I_callconstraint (Normalcall, ty, mspec, None) + let mkNormalNewobj mspec = I_newobj (mspec, None) /// Comment on common object cache sizes: @@ -2623,39 +2656,42 @@ let mkNormalNewobj mspec = I_newobj (mspec, None) /// mkLdcInt32 - just a guess let ldargs = [| for i in 0 .. 128 -> I_ldarg (uint16 i) |] + let mkLdarg i = if 0us < i && i < uint16 ldargs.Length then ldargs.[int i] else I_ldarg i + let mkLdarg0 = mkLdarg 0us let ldlocs = [| for i in 0 .. 512 -> I_ldloc (uint16 i) |] + let mkLdloc i = if 0us < i && i < uint16 ldlocs.Length then ldlocs.[int i] else I_ldloc i let stlocs = [| for i in 0 .. 512 -> I_stloc (uint16 i) |] + let mkStloc i = if 0us < i && i < uint16 stlocs.Length then stlocs.[int i] else I_stloc i let ldi32s = [| for i in 0 .. 256 -> AI_ldc (DT_I4, ILConst.I4 i) |] + let mkLdcInt32 i = if 0 < i && i < ldi32s.Length then ldi32s.[i] else AI_ldc (DT_I4, ILConst.I4 i) let tname_CompilerGeneratedAttribute = "System.Runtime.CompilerServices.CompilerGeneratedAttribute" -let tname_DebuggableAttribute = "System.Diagnostics.DebuggableAttribute" - +let tname_DebuggableAttribute = "System.Diagnostics.DebuggableAttribute" - (* NOTE: ecma_ prefix refers to the standard "mscorlib" *) let ecmaPublicKey = PublicKeyToken (Bytes.ofInt32Array [|0xde; 0xad; 0xbe; 0xef; 0xca; 0xfe; 0xfa; 0xce |]) let isILBoxedTy = function ILType.Boxed _ -> true | _ -> false -let isILValueTy = function ILType.Value _ -> true | _ -> false +let isILValueTy = function ILType.Value _ -> true | _ -> false let isPrimaryAssemblyTySpec (tspec:ILTypeSpec) n = - let tref = tspec.TypeRef - let scoref = tref.Scope - (tref.Name = n) && - match scoref with - | ILScopeRef.Assembly n -> PrimaryAssembly.IsSomePrimaryAssembly n.Name - | ILScopeRef.Module _ -> false - | ILScopeRef.Local -> true + let tref = tspec.TypeRef + let scoref = tref.Scope + (tref.Name = n) && + match scoref with + | ILScopeRef.Assembly n -> PrimaryAssembly.IsSomePrimaryAssembly n.Name + | ILScopeRef.Module _ -> false + | ILScopeRef.Local -> true let isILBoxedPrimaryAssemblyTy (ty:ILType) n = isILBoxedTy ty && isPrimaryAssemblyTySpec ty.TypeSpec n @@ -2664,21 +2700,37 @@ let isILValuePrimaryAssemblyTy (ty:ILType) n = isILValueTy ty && isPrimaryAssemblyTySpec ty.TypeSpec n let isILObjectTy ty = isILBoxedPrimaryAssemblyTy ty tname_Object + let isILStringTy ty = isILBoxedPrimaryAssemblyTy ty tname_String + let isILTypedReferenceTy ty = isILValuePrimaryAssemblyTy ty "System.TypedReference" + let isILSByteTy ty = isILValuePrimaryAssemblyTy ty tname_SByte + let isILByteTy ty = isILValuePrimaryAssemblyTy ty tname_Byte + let isILInt16Ty ty = isILValuePrimaryAssemblyTy ty tname_Int16 + let isILUInt16Ty ty = isILValuePrimaryAssemblyTy ty tname_UInt16 + let isILInt32Ty ty = isILValuePrimaryAssemblyTy ty tname_Int32 + let isILUInt32Ty ty = isILValuePrimaryAssemblyTy ty tname_UInt32 + let isILInt64Ty ty = isILValuePrimaryAssemblyTy ty tname_Int64 + let isILUInt64Ty ty = isILValuePrimaryAssemblyTy ty tname_UInt64 + let isILIntPtrTy ty = isILValuePrimaryAssemblyTy ty tname_IntPtr + let isILUIntPtrTy ty = isILValuePrimaryAssemblyTy ty tname_UIntPtr + let isILBoolTy ty = isILValuePrimaryAssemblyTy ty tname_Bool + let isILCharTy ty = isILValuePrimaryAssemblyTy ty tname_Char + let isILSingleTy ty = isILValuePrimaryAssemblyTy ty tname_Single + let isILDoubleTy ty = isILValuePrimaryAssemblyTy ty tname_Double // -------------------------------------------------------------------- @@ -2803,7 +2855,9 @@ let mkILParam (name, ty) : ILParameter = Type=ty CustomAttrsStored=storeILCustomAttrs emptyILCustomAttrs MetadataIndex = NoMetadataIdx } + let mkILParamNamed (s, ty) = mkILParam (Some s, ty) + let mkILParamAnon ty = mkILParam (None, ty) let mkILReturn ty : ILReturn = @@ -2818,22 +2872,22 @@ let mkILLocal ty dbgInfo : ILLocal = DebugInfo=dbgInfo } type ILFieldSpec with - member fr.ActualType = - let env = fr.DeclaringType.GenericArgs - instILType env fr.FormalType + member fr.ActualType = + let env = fr.DeclaringType.GenericArgs + instILType env fr.FormalType // -------------------------------------------------------------------- // Make a method mbody // -------------------------------------------------------------------- let mkILMethodBody (zeroinit, locals, maxstack, code, tag) : ILMethodBody = - { IsZeroInit=zeroinit - MaxStack=maxstack - NoInlining=false - AggressiveInlining=false - Locals= locals - Code= code - SourceMarker=tag } + { IsZeroInit=zeroinit + MaxStack=maxstack + NoInlining=false + AggressiveInlining=false + Locals= locals + Code= code + SourceMarker=tag } let mkMethodBody (zeroinit, locals, maxstack, code, tag) = MethodBody.IL (mkILMethodBody (zeroinit, locals, maxstack, code, tag)) @@ -2844,7 +2898,9 @@ let mkMethodBody (zeroinit, locals, maxstack, code, tag) = MethodBody.IL (mkILMe let mkILVoidReturn = mkILReturn ILType.Void let methBodyNotAvailable = mkMethBodyAux MethodBody.NotAvailable + let methBodyAbstract = mkMethBodyAux MethodBody.Abstract + let methBodyNative = mkMethBodyAux MethodBody.Native let mkILCtor (access, args, impl) = @@ -2870,11 +2926,17 @@ let mkCallBaseConstructor (ty, args: ILType list) = [ mkNormalCall (mkILCtorMethSpecForTy (ty, [])) ] let mkNormalStfld fspec = I_stfld (Aligned, Nonvolatile, fspec) + let mkNormalStsfld fspec = I_stsfld (Nonvolatile, fspec) + let mkNormalLdsfld fspec = I_ldsfld (Nonvolatile, fspec) + let mkNormalLdfld fspec = I_ldfld (Aligned, Nonvolatile, fspec) + let mkNormalLdflda fspec = I_ldflda fspec + let mkNormalLdobj dt = I_ldobj(Aligned, Nonvolatile, dt) + let mkNormalStobj dt = I_stobj(Aligned, Nonvolatile, dt) let mkILNonGenericEmptyCtor tag superTy = @@ -3022,13 +3084,12 @@ let mkRefToILMethod (tref, md: ILMethodDef) = let mkRefToILField (tref, fdef:ILFieldDef) = mkILFieldRef (tref, fdef.Name, fdef.FieldType) let mkRefForILMethod scope (tdefs, tdef) mdef = mkRefToILMethod (mkRefForNestedILTypeDef scope (tdefs, tdef), mdef) -let mkRefForILField scope (tdefs, tdef) (fdef:ILFieldDef) = mkILFieldRef (mkRefForNestedILTypeDef scope (tdefs, tdef), fdef.Name, fdef.FieldType) +let mkRefForILField scope (tdefs, tdef) (fdef:ILFieldDef) = mkILFieldRef (mkRefForNestedILTypeDef scope (tdefs, tdef), fdef.Name, fdef.FieldType) -(* Creates cctor if needed *) +// Creates cctor if needed let prependInstrsToClassCtor instrs tag cd = - cdef_cctorCode2CodeOrCreate tag (prependInstrsToMethod instrs) cd - + cdef_cctorCode2CodeOrCreate tag (prependInstrsToMethod instrs) cd let mkILField (isStatic, nm, ty, (init:ILFieldInit option), (at: byte [] option), access, isLiteral) = ILFieldDef(name=nm, @@ -3046,7 +3107,9 @@ let mkILField (isStatic, nm, ty, (init:ILFieldInit option), (at: byte [] option) customAttrs=emptyILCustomAttrs) let mkILInstanceField (nm, ty, init, access) = mkILField (false, nm, ty, init, None, access, false) + let mkILStaticField (nm, ty, init, at, access) = mkILField (true, nm, ty, init, at, access, false) + let mkILLiteralField (nm, ty, init, at, access) = mkILField (true, nm, ty, Some init, at, access, true) // -------------------------------------------------------------------- @@ -3064,19 +3127,27 @@ type ILLocalsAllocator(numPrealloc:int) = let mkILFieldsLazy l = ILFields (LazyOrderedMultiMap((fun (f:ILFieldDef) -> f.Name), l)) + let mkILFields l = mkILFieldsLazy (notlazy l) + let emptyILFields = mkILFields [] let mkILEventsLazy l = ILEvents (LazyOrderedMultiMap((fun (e: ILEventDef) -> e.Name), l)) + let mkILEvents l = mkILEventsLazy (notlazy l) + let emptyILEvents = mkILEvents [] let mkILPropertiesLazy l = ILProperties (LazyOrderedMultiMap((fun (p: ILPropertyDef) -> p.Name), l) ) + let mkILProperties l = mkILPropertiesLazy (notlazy l) + let emptyILProperties = mkILProperties [] let addExportedTypeToTable (y: ILExportedTypeOrForwarder) tab = Map.add y.Name y tab + let mkILExportedTypes l = ILExportedTypesAndForwarders (notlazy (List.foldBack addExportedTypeToTable l Map.empty)) + let mkILExportedTypesLazy (l:Lazy<_>) = ILExportedTypesAndForwarders (lazy (List.foldBack addExportedTypeToTable (l.Force()) Map.empty)) let addNestedExportedTypeToTable (y: ILNestedExportedType) tab = @@ -3104,15 +3175,13 @@ let addMethodImplToTable y tab = Map.add key (y::prev) tab let mkILMethodImpls l = ILMethodImpls (notlazy (List.foldBack addMethodImplToTable l Map.empty)) -let mkILMethodImplsLazy l = ILMethodImpls (lazy (List.foldBack addMethodImplToTable (Lazy.force l) Map.empty)) -let emptyILMethodImpls = mkILMethodImpls [] +let mkILMethodImplsLazy l = ILMethodImpls (lazy (List.foldBack addMethodImplToTable (Lazy.force l) Map.empty)) -// -------------------------------------------------------------------- -// Make a constructor that simply takes its arguments and stuffs -// them in fields. preblock is how to call the superclass constructor.... -// -------------------------------------------------------------------- +let emptyILMethodImpls = mkILMethodImpls [] +/// Make a constructor that simply takes its arguments and stuffs +/// them in fields. preblock is how to call the superclass constructor.... let mkILStorageCtorWithParamNames(tag, preblock, ty, extraParams, flds, access) = mkILCtor(access, (flds |> List.map (fun (pnm, _, ty) -> mkILParamNamed (pnm, ty))) @ extraParams, @@ -3146,10 +3215,10 @@ let mkILSimpleStorageCtor(tag, baseTySpec, ty, extraParams, flds, access) = let mkILStorageCtor(tag, preblock, ty, flds, access) = mkILStorageCtorWithParamNames(tag, preblock, ty, [], addParamNames flds, access) - let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nestedTypes, props, events, attrs, init) = ILTypeDef(name=nm, - attributes=(convertTypeAccessFlags access ||| TypeAttributes.AutoLayout ||| TypeAttributes.Class ||| (match init with | ILTypeInit.BeforeField -> TypeAttributes.BeforeFieldInit | _ -> enum 0) ||| TypeAttributes.AnsiClass), + attributes=(convertTypeAccessFlags access ||| TypeAttributes.AutoLayout ||| TypeAttributes.Class ||| + (match init with | ILTypeInit.BeforeField -> TypeAttributes.BeforeFieldInit | _ -> enum 0) ||| TypeAttributes.AnsiClass), genericParams= genparams, implements = impl, layout=ILTypeDefLayout.Auto, @@ -3166,7 +3235,8 @@ let mkILGenericClass (nm, access, genparams, extends, impl, methods, fields, nes let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) = ILTypeDef(name = nm, genericParams= [], - attributes = (TypeAttributes.NotPublic ||| TypeAttributes.Sealed ||| TypeAttributes.ExplicitLayout ||| TypeAttributes.BeforeFieldInit ||| TypeAttributes.AnsiClass), + attributes = (TypeAttributes.NotPublic ||| TypeAttributes.Sealed ||| TypeAttributes.ExplicitLayout ||| + TypeAttributes.BeforeFieldInit ||| TypeAttributes.AnsiClass), implements = [], extends = Some iltyp_ValueType, layout=ILTypeDefLayout.Explicit { Size=Some size; Pack=Some pack }, @@ -3183,7 +3253,8 @@ let mkRawDataValueTypeDef (iltyp_ValueType: ILType) (nm, size, pack) = let mkILSimpleClass (ilg: ILGlobals) (nm, access, methods, fields, nestedTypes, props, events, attrs, init) = mkILGenericClass (nm, access, mkILEmptyGenericParams, ilg.typ_Object, [], methods, fields, nestedTypes, props, events, attrs, init) -let mkILTypeDefForGlobalFunctions ilg (methods, fields) = mkILSimpleClass ilg (typeNameForGlobalFunctions, ILTypeDefAccess.Public, methods, fields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.BeforeField) +let mkILTypeDefForGlobalFunctions ilg (methods, fields) = + mkILSimpleClass ilg (typeNameForGlobalFunctions, ILTypeDefAccess.Public, methods, fields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.BeforeField) let destTypeDefsWithGlobalFunctionsFirst ilg (tdefs: ILTypeDefs) = let l = tdefs.AsList @@ -3270,7 +3341,9 @@ let mkILDelegateMethods (access) (ilg: ILGlobals) (iltyp_AsyncCallback, iltyp_IA let mkCtorMethSpecForDelegate (ilg: ILGlobals) (ty:ILType, useUIntPtr) = let scoref = ty.TypeRef.Scope - mkILInstanceMethSpecInTy (ty, ".ctor", [rescopeILType scoref ilg.typ_Object; rescopeILType scoref (if useUIntPtr then ilg.typ_UIntPtr else ilg.typ_IntPtr)], ILType.Void, emptyILGenericArgsList) + mkILInstanceMethSpecInTy (ty, ".ctor", [rescopeILType scoref ilg.typ_Object; + rescopeILType scoref (if useUIntPtr then ilg.typ_UIntPtr else ilg.typ_IntPtr)], + ILType.Void, emptyILGenericArgsList) type ILEnumInfo = { enumValues: (string * ILFieldInit) list @@ -3286,8 +3359,6 @@ let computeILEnumInfo (mdName, mdFields: ILFieldDefs) = | _, [] -> failwith ("info_of_enum_tdef: badly formed enum "+mdName+": no non-static field found") | _, _ -> failwith ("info_of_enum_tdef: badly formed enum "+mdName+": more than one non-static field found") - - //--------------------------------------------------------------------- // Primitives to help read signatures. These do not use the file cursor, but // pass around an int index @@ -3346,6 +3417,7 @@ let sigptr_get_u64 bytes sigptr = uint64 u, sigptr let float32_of_bits (x:int32) = System.BitConverter.ToSingle(System.BitConverter.GetBytes(x), 0) + let float_of_bits (x:int64) = System.BitConverter.Int64BitsToDouble(x) let sigptr_get_ieee32 bytes sigptr = @@ -3417,28 +3489,43 @@ let string_as_utf8_bytes (s:string) = System.Text.Encoding.UTF8.GetBytes s (* Little-endian encoding of int64 *) let dw7 n = byte ((n >>> 56) &&& 0xFFL) + let dw6 n = byte ((n >>> 48) &&& 0xFFL) + let dw5 n = byte ((n >>> 40) &&& 0xFFL) + let dw4 n = byte ((n >>> 32) &&& 0xFFL) + let dw3 n = byte ((n >>> 24) &&& 0xFFL) + let dw2 n = byte ((n >>> 16) &&& 0xFFL) + let dw1 n = byte ((n >>> 8) &&& 0xFFL) + let dw0 n = byte (n &&& 0xFFL) let u8AsBytes (i:byte) = [| i |] + let u16AsBytes x = let n = (int x) in [| byte (b0 n); byte (b1 n) |] + let i32AsBytes i = [| byte (b0 i); byte (b1 i); byte (b2 i); byte (b3 i) |] + let i64AsBytes i = [| dw0 i; dw1 i; dw2 i; dw3 i; dw4 i; dw5 i; dw6 i; dw7 i |] let i8AsBytes (i:sbyte) = u8AsBytes (byte i) + let i16AsBytes (i:int16) = u16AsBytes (uint16 i) + let u32AsBytes (i:uint32) = i32AsBytes (int32 i) + let u64AsBytes (i:uint64) = i64AsBytes (int64 i) let bits_of_float32 (x:float32) = System.BitConverter.ToInt32(System.BitConverter.GetBytes(x), 0) + let bits_of_float (x:float) = System.BitConverter.DoubleToInt64Bits(x) let ieee32AsBytes i = i32AsBytes (bits_of_float32 i) + let ieee64AsBytes i = i64AsBytes (bits_of_float i) let et_END = 0x00uy @@ -3522,7 +3609,6 @@ let rec encodeCustomAttrElemTypeForObject x = | ILAttribElem.Double _ -> [| et_R8 |] | ILAttribElem.Array (elemTy, _) -> [| yield et_SZARRAY; yield! encodeCustomAttrElemType elemTy |] - let rec decodeCustomAttrElemType (ilg: ILGlobals) bytes sigptr x = match x with | x when x = et_I1 -> ilg.typ_SByte, sigptr @@ -3615,8 +3701,8 @@ let getCustomAttrData (ilg: ILGlobals) cattr = encodeCustomAttrArgs ilg mspec fixedArgs namedArgs let MscorlibScopeRef = ILScopeRef.Assembly (ILAssemblyRef.Create("mscorlib", None, Some ecmaPublicKey, true, None, None)) -let EcmaMscorlibILGlobals = mkILGlobals MscorlibScopeRef +let EcmaMscorlibILGlobals = mkILGlobals MscorlibScopeRef // ILSecurityDecl is a 'blob' having the following format: // - A byte containing a period (.). @@ -3641,7 +3727,6 @@ let mkPermissionSet (ilg: ILGlobals) (action, attributes: list<(ILTypeRef * (str ILSecurityDecl.ILSecurityDecl(action, bytes) - // Parse an IL type signature argument within a custom attribute blob type ILTypeSigParser(tstring : string) = @@ -3917,8 +4002,8 @@ type ILReferencesAccumulator = refsM: HashSet } let emptyILRefs = - { AssemblyReferences=[] - ModuleReferences = [] } + { AssemblyReferences=[] + ModuleReferences = [] } (* Now find references. *) let refs_of_assemblyRef (s:ILReferencesAccumulator) x = s.refsA.Add x |> ignore @@ -4009,7 +4094,6 @@ and refs_of_instr s x = | AI_shl | AI_shr | AI_shr_un | AI_sub | AI_sub_ovf | AI_sub_ovf_un | AI_xor | AI_or | AI_neg | AI_not | AI_ldnull | AI_dup | AI_pop | AI_ckfinite | AI_nop | AI_ldc _ | I_seqpoint _ | EI_ldlen_multi _ -> () - and refs_of_il_code s (c: ILCode) = c.Instrs |> Array.iter (refs_of_instr s) @@ -4037,7 +4121,9 @@ and refs_of_mdef s (md: ILMethodDef) = refs_of_genparams s md.GenericParams and refs_of_param s p = refs_of_typ s p.Type + and refs_of_return s (rt:ILReturn) = refs_of_typ s rt.Type + and refs_of_mdefs s x = Seq.iter (refs_of_mdef s) x and refs_of_event_def s (ed: ILEventDef) = @@ -4087,6 +4173,7 @@ and refs_of_tdef s (td : ILTypeDef) = refs_of_properties s td.Properties and refs_of_string _s _ = () + and refs_of_types s (types: ILTypeDefs) = Seq.iter (refs_of_tdef s) types and refs_of_exported_type s (c: ILExportedTypeOrForwarder) = @@ -4216,16 +4303,24 @@ let resolveILMethodRefWithRescope r (td: ILTypeDef) (mref:ILMethodRef) = let resolveILMethodRef td mref = resolveILMethodRefWithRescope id td mref let mkRefToILModule m = - ILModuleRef.Create(m.Name, true, None) + ILModuleRef.Create(m.Name, true, None) type ILEventRef = - { erA: ILTypeRef; erB: string } + { erA: ILTypeRef + erB: string } + static member Create(a, b) = {erA=a;erB=b} + member x.DeclaringTypeRef = x.erA + member x.Name = x.erB type ILPropertyRef = - { prA: ILTypeRef; prB: string } + { prA: ILTypeRef + prB: string } + static member Create (a, b) = {prA=a;prB=b} + member x.DeclaringTypeRef = x.prA + member x.Name = x.prB diff --git a/src/absil/il.fsi b/src/absil/il.fsi index 668459088f..81ea562251 100755 --- a/src/absil/il.fsi +++ b/src/absil/il.fsi @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// The "unlinked" view of .NET metadata and code. Central to the Abstract IL library -module public Microsoft.FSharp.Compiler.AbstractIL.IL +module public FSharp.Compiler.AbstractIL.IL open System.Collections.Generic open System.Reflection diff --git a/src/absil/ilascii.fs b/src/absil/ilascii.fs index 763235afa1..41196df57a 100755 --- a/src/absil/ilascii.fs +++ b/src/absil/ilascii.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants +module internal FSharp.Compiler.AbstractIL.Internal.AsciiConstants open Internal.Utilities open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.IL // set to the proper value at CompileOps.fs (BuildFrameworkTcImports) let parseILGlobals = ref EcmaMscorlibILGlobals diff --git a/src/absil/ilascii.fsi b/src/absil/ilascii.fsi index d142d2f620..1b94bbed22 100755 --- a/src/absil/ilascii.fsi +++ b/src/absil/ilascii.fsi @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Various constants and utilities used when parsing the ILASM format for IL -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants +module internal FSharp.Compiler.AbstractIL.Internal.AsciiConstants open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.IL // -------------------------------------------------------------------- // IL Parser state - must be initialized before parsing a module diff --git a/src/absil/ilbinary.fs b/src/absil/ilbinary.fs index 46dfef12be..41297d117e 100755 --- a/src/absil/ilbinary.fs +++ b/src/absil/ilbinary.fs @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.BinaryConstants +module internal FSharp.Compiler.AbstractIL.Internal.BinaryConstants open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library [] type TableName(idx: int) = diff --git a/src/absil/ilbinary.fsi b/src/absil/ilbinary.fsi index 1f95028cb7..200ee8b027 100755 --- a/src/absil/ilbinary.fsi +++ b/src/absil/ilbinary.fsi @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Compiler use only. Code and constants shared between binary reader/writer. -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.BinaryConstants +module internal FSharp.Compiler.AbstractIL.Internal.BinaryConstants open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal [] diff --git a/src/absil/ildiag.fs b/src/absil/ildiag.fs index 8b58001bd8..de7411fbf9 100755 --- a/src/absil/ildiag.fs +++ b/src/absil/ildiag.fs @@ -2,7 +2,7 @@ /// Configurable Diagnostics channel for the Abstract IL library -module internal Microsoft.FSharp.Compiler.AbstractIL.Diagnostics +module internal FSharp.Compiler.AbstractIL.Diagnostics open Internal.Utilities diff --git a/src/absil/ildiag.fsi b/src/absil/ildiag.fsi index d0b8ab9557..4be1d87bc4 100755 --- a/src/absil/ildiag.fsi +++ b/src/absil/ildiag.fsi @@ -6,7 +6,7 @@ /// points to stderr. All functions call flush() automatically. /// /// REVIEW: review if we should just switch to System.Diagnostics -module internal Microsoft.FSharp.Compiler.AbstractIL.Diagnostics +module internal FSharp.Compiler.AbstractIL.Diagnostics open System.IO open Microsoft.FSharp.Core.Printf diff --git a/src/absil/illex.fsl b/src/absil/illex.fsl index 481f7b28f6..849ebd17b8 100755 --- a/src/absil/illex.fsl +++ b/src/absil/illex.fsl @@ -2,18 +2,18 @@ { -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiLexer +module internal FSharp.Compiler.AbstractIL.Internal.AsciiLexer open Internal.Utilities open Internal.Utilities.Collections open Internal.Utilities.Text open Internal.Utilities.Text.Lexing -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser -open Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants +open FSharp.Compiler.AbstractIL.Internal.AsciiParser +open FSharp.Compiler.AbstractIL.Internal.AsciiConstants let lexeme (lexbuf : LexBuffer) = new System.String(lexbuf.Lexeme) diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 4426160638..159975b440 100755 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +module public FSharp.Compiler.AbstractIL.Internal.Library #nowarn "1178" // The struct, record or union type 'internal_instr_extension' is not structurally comparable because the type diff --git a/src/absil/ilmorph.fs b/src/absil/ilmorph.fs index d5398099e0..e0fe4cc749 100755 --- a/src/absil/ilmorph.fs +++ b/src/absil/ilmorph.fs @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Morphs +module internal FSharp.Compiler.AbstractIL.Morphs open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.IL let mutable morphCustomAttributeData = false diff --git a/src/absil/ilmorph.fsi b/src/absil/ilmorph.fsi index 3a12eeb521..1b5fc1499d 100755 --- a/src/absil/ilmorph.fsi +++ b/src/absil/ilmorph.fsi @@ -6,10 +6,10 @@ /// morphed occurs, e.g. the module being morphed itself, the /// ILTypeDef (possibly nested) where the item occurs, /// the ILMethodDef (if any) where the item occurs. etc. -module internal Microsoft.FSharp.Compiler.AbstractIL.Morphs +module internal FSharp.Compiler.AbstractIL.Morphs -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL /// Morph each scope reference inside a type signature. val morphILScopeRefsInILTypeRef: (ILScopeRef -> ILScopeRef) -> ILTypeRef -> ILTypeRef diff --git a/src/absil/ilpars.fsy b/src/absil/ilpars.fsy index 40ad9fd127..b685201546 100755 --- a/src/absil/ilpars.fsy +++ b/src/absil/ilpars.fsy @@ -7,13 +7,13 @@ open Internal.Utilities open Internal.Utilities.Text -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.AsciiConstants +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library let pfailwith s = diff --git a/src/absil/ilprint.fs b/src/absil/ilprint.fs index 58c13ba148..c2d4e1d45d 100755 --- a/src/absil/ilprint.fs +++ b/src/absil/ilprint.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.ILAsciiWriter +module internal FSharp.Compiler.AbstractIL.ILAsciiWriter open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.Internal.AsciiConstants +open FSharp.Compiler.AbstractIL.IL open System.Text open System.IO diff --git a/src/absil/ilprint.fsi b/src/absil/ilprint.fsi index 5f7ebe4f11..9ba4ccb1bf 100755 --- a/src/absil/ilprint.fsi +++ b/src/absil/ilprint.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Printer for the abstract syntax. -module internal Microsoft.FSharp.Compiler.AbstractIL.ILAsciiWriter +module internal FSharp.Compiler.AbstractIL.ILAsciiWriter -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal open System.IO #if DEBUG diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index c2c10e9479..9d14d0858d 100755 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -5,7 +5,7 @@ // //--------------------------------------------------------------------- -module Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader +module FSharp.Compiler.AbstractIL.ILBinaryReader #nowarn "42" // This construct is deprecated: it is only for use in the F# library @@ -17,17 +17,17 @@ open System.Runtime.InteropServices open System.Text open Internal.Utilities open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal #if !FX_NO_PDB_READER -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Support +open FSharp.Compiler.AbstractIL.Internal.Support #endif -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal.BinaryConstants -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Internal.BinaryConstants +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range open Microsoft.FSharp.NativeInterop open System.Reflection @@ -3751,20 +3751,20 @@ let openPEFileReader (fileName, pefile: BinaryFile, pdbDirPath, noFileOnDisk) = let dataSegmentAddr = seekReadInt32 pev (peOptionalHeaderPhysLoc + 24) (* e.g. 0x0000c000 *) (* REVIEW: For now, we'll use the DWORD at offset 24 for x64. This currently ok since fsc doesn't support true 64-bit image bases, but we'll have to fix this up when such support is added. *) - let imageBaseReal = if only64 then dataSegmentAddr else seekReadInt32 pev (peOptionalHeaderPhysLoc + 28) (* Image Base Always 0x400000 (see Section 23.1). - QUERY : no it's not always 0x400000, e.g. 0x034f0000 *) - let alignVirt = seekReadInt32 pev (peOptionalHeaderPhysLoc + 32) (* Section Alignment Always 0x2000 (see Section 23.1). *) - let alignPhys = seekReadInt32 pev (peOptionalHeaderPhysLoc + 36) (* File Alignment Either 0x200 or 0x1000. *) + let imageBaseReal = if only64 then dataSegmentAddr else seekReadInt32 pev (peOptionalHeaderPhysLoc + 28) // Image Base Always 0x400000 (see Section 23.1). + let alignVirt = seekReadInt32 pev (peOptionalHeaderPhysLoc + 32) // Section Alignment Always 0x2000 (see Section 23.1). + let alignPhys = seekReadInt32 pev (peOptionalHeaderPhysLoc + 36) // File Alignment Either 0x200 or 0x1000. (* x86: 000000c0 *) - let _osMajor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 40) (* OS Major Always 4 (see Section 23.1). *) - let _osMinor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 42) (* OS Minor Always 0 (see Section 23.1). *) - let _userMajor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 44) (* User Major Always 0 (see Section 23.1). *) - let _userMinor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 46) (* User Minor Always 0 (see Section 23.1). *) - let subsysMajor = seekReadUInt16AsInt32 pev (peOptionalHeaderPhysLoc + 48) (* SubSys Major Always 4 (see Section 23.1). *) - let subsysMinor = seekReadUInt16AsInt32 pev (peOptionalHeaderPhysLoc + 50) (* SubSys Minor Always 0 (see Section 23.1). *) + let _osMajor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 40) // OS Major Always 4 (see Section 23.1). + let _osMinor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 42) // OS Minor Always 0 (see Section 23.1). + let _userMajor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 44) // User Major Always 0 (see Section 23.1). + let _userMinor = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 46) // User Minor Always 0 (see Section 23.1). + let subsysMajor = seekReadUInt16AsInt32 pev (peOptionalHeaderPhysLoc + 48) // SubSys Major Always 4 (see Section 23.1). + let subsysMinor = seekReadUInt16AsInt32 pev (peOptionalHeaderPhysLoc + 50) // SubSys Minor Always 0 (see Section 23.1). (* x86: 000000d0 *) - let _imageEndAddr = seekReadInt32 pev (peOptionalHeaderPhysLoc + 56) (* Image Size: Size, in bytes, of image, including all headers and padding; shall be a multiple of Section Alignment. e.g. 0x0000e000 *) - let _headerPhysSize = seekReadInt32 pev (peOptionalHeaderPhysLoc + 60) (* Header Size Combined size of MS-DOS Header, PE Header, PE Optional Header and padding; shall be a multiple of the file alignment. *) - let subsys = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 68) (* SubSystem Subsystem required to run this image. Shall be either IMAGE_SUBSYSTEM_WINDOWS_CE_GUI (!0x3) or IMAGE_SUBSYSTEM_WINDOWS_GUI (!0x2). QUERY: Why is this 3 on the images ILASM produces??? *) + let _imageEndAddr = seekReadInt32 pev (peOptionalHeaderPhysLoc + 56) // Image Size: Size, in bytes, of image, including all headers and padding; + let _headerPhysSize = seekReadInt32 pev (peOptionalHeaderPhysLoc + 60) // Header Size Combined size of MS-DOS Header, PE Header, PE Optional Header and padding; + let subsys = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 68) // SubSystem Subsystem required to run this image. let useHighEnthropyVA = let n = seekReadUInt16 pev (peOptionalHeaderPhysLoc + 70) let highEnthropyVA = 0x20us @@ -4099,7 +4099,7 @@ let OpenILModuleReader fileName opts = [] module Shim = - open Microsoft.FSharp.Compiler.Lib + open FSharp.Compiler.Lib type IAssemblyReader = abstract GetILModuleReader: filename: string * readerOptions: ILReaderOptions -> ILModuleReader diff --git a/src/absil/ilread.fsi b/src/absil/ilread.fsi index c548447444..8fa43982fe 100755 --- a/src/absil/ilread.fsi +++ b/src/absil/ilread.fsi @@ -24,13 +24,13 @@ /// class. That is not particularly satisfactory, and it may be /// a good idea to build a small library which extracts the information /// you need. -module Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader +module FSharp.Compiler.AbstractIL.ILBinaryReader open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.ErrorLogger open System.IO /// Used to implement a Binary file over native memory, used by Roslyn integration diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index 5e15cbbd37..2b6dd3d06d 100755 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -5,7 +5,7 @@ //---------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter +module internal FSharp.Compiler.AbstractIL.ILRuntimeWriter open System open System.Reflection @@ -13,13 +13,13 @@ open System.Reflection.Emit open System.Runtime.InteropServices open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range open Microsoft.FSharp.Core.Printf @@ -30,7 +30,7 @@ open Microsoft.FSharp.Core.ReflectionAdapters let codeLabelOrder = ComparisonIdentity.Structural // Convert the output of convCustomAttr -open Microsoft.FSharp.Compiler.AbstractIL.ILAsciiWriter +open FSharp.Compiler.AbstractIL.ILAsciiWriter let wrapCustomAttr setCustomAttr (cinfo, bytes) = setCustomAttr(cinfo, bytes) diff --git a/src/absil/ilsign.fs b/src/absil/ilsign.fs index becf5aee92..4608a9f9d5 100644 --- a/src/absil/ilsign.fs +++ b/src/absil/ilsign.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.StrongNameSign +module internal FSharp.Compiler.AbstractIL.Internal.StrongNameSign #nowarn "9" diff --git a/src/absil/ilsupp.fs b/src/absil/ilsupp.fs index fb4e3a58fd..6fbdc5bb72 100755 --- a/src/absil/ilsupp.fs +++ b/src/absil/ilsupp.fs @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.Support +module internal FSharp.Compiler.AbstractIL.Internal.Support let DateTime1970Jan01 = new System.DateTime(1970,1,1,0,0,0,System.DateTimeKind.Utc) (* ECMA Spec (Oct2002), Part II, 24.2.2 PE File Header. *) let absilWriteGetTimeStamp () = (System.DateTime.UtcNow - DateTime1970Jan01).TotalSeconds |> int open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Bytes -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Bytes +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Internal.Library #if FX_NO_CORHOST_SIGNER -open Microsoft.FSharp.Compiler.AbstractIL.Internal.StrongNameSign +open FSharp.Compiler.AbstractIL.Internal.StrongNameSign #endif open System open System.IO @@ -1036,7 +1036,7 @@ let pdbInitialize (binaryName:string) (pdbName:string) = { symWriter = writer } -[] +[] do() let pdbCloseDocument(documentWriter : PdbDocumentWriter) = diff --git a/src/absil/ilsupp.fsi b/src/absil/ilsupp.fsi index 3a3748c6d2..48e7de602b 100755 --- a/src/absil/ilsupp.fsi +++ b/src/absil/ilsupp.fsi @@ -5,7 +5,7 @@ /// Runtime, e.g. between the SSCLI, Mono and the Microsoft CLR. /// /// The implementation of the functions can be found in ilsupp-*.fs -module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.Support +module internal FSharp.Compiler.AbstractIL.Internal.Support #if !FX_NO_PDB_WRITER type PdbWriter @@ -25,9 +25,9 @@ open System.Runtime.InteropServices open System.Diagnostics.SymbolStore #endif open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.IL #if !FX_NO_LINKEDRESOURCES type IStream = System.Runtime.InteropServices.ComTypes.IStream diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index 12541d5089..ccc40c69d7 100755 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -1,26 +1,26 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter +module internal FSharp.Compiler.AbstractIL.ILBinaryWriter open System.Collections.Generic open System.IO open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.ILAsciiWriter -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.BinaryConstants -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Support -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter -open Microsoft.FSharp.Compiler.DiagnosticMessage -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.ILAsciiWriter +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.BinaryConstants +open FSharp.Compiler.AbstractIL.Internal.Support +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.ILPdbWriter +open FSharp.Compiler.DiagnosticMessage +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range #if FX_NO_CORHOST_SIGNER -open Microsoft.FSharp.Compiler.AbstractIL.Internal.StrongNameSign +open FSharp.Compiler.AbstractIL.Internal.StrongNameSign #endif @@ -3441,7 +3441,8 @@ let writeILMetadataAndCode (generatePdb, desiredMetadataVersion, ilg, emitTailca // uses of strings in the code for (codeStartAddr, l) in requiredStringFixups do for (codeOffset, userStringIndex) in l do - if codeStartAddr < codep.addr || codeStartAddr >= codep.addr + codep.size then failwith "strings-in-code fixup: a group of fixups is located outside the code array"; + if codeStartAddr < codep.addr || codeStartAddr >= codep.addr + codep.size then + failwith "strings-in-code fixup: a group of fixups is located outside the code array"; let locInCode = ((codeStartAddr + codeOffset) - codep.addr) checkFixup32 code locInCode 0xdeadbeef; let token = getUncodedToken TableNames.UserStrings (userStringAddress userStringIndex) @@ -3665,10 +3666,14 @@ let writeBinaryAndReportMappings (outfile, let pdbOpt = match portablePDB with | true -> - let (uncompressedLength, contentId, stream) as pdbStream = generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic + let (uncompressedLength, contentId, stream) as pdbStream = + generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic + if embeddedPDB then Some (compressPortablePdbStream uncompressedLength contentId stream) else Some (pdbStream) + | _ -> None + let debugDirectoryChunk, next = chunk (if pdbfile = None then 0x0 @@ -3773,7 +3778,9 @@ let writeBinaryAndReportMappings (outfile, else let res = rawdataChunk.addr + dataOffset if res < rawdataChunk.addr then dprintn ("data rva before data section"); - if res >= rawdataChunk.addr + rawdataChunk.size then dprintn ("data rva after end of data section, dataRva = "+string res+", rawdataChunk.addr = "+string rawdataChunk.addr+", rawdataChunk.size = "+string rawdataChunk.size); + if res >= rawdataChunk.addr + rawdataChunk.size then + dprintn ("data rva after end of data section, dataRva = "+string res+", rawdataChunk.addr = "+string rawdataChunk.addr + + ", rawdataChunk.size = "+string rawdataChunk.size); res applyFixup32 metadata metadataOffset dataRva); end; @@ -3868,9 +3875,9 @@ let writeBinaryAndReportMappings (outfile, writeInt32AsUInt16 os peOptionalHeaderByte; // ECMA spec says 6, some binaries, e.g. fscmanaged.exe say 7, Whidbey binaries say 8 writeInt32 os textSectionPhysSize; // Size of the code (text) section, or the sum of all code sections if there are multiple sections. // 000000a0 - writeInt32 os dataSectionPhysSize; // Size of the initialized data section, or the sum of all such sections if there are multiple data sections. - writeInt32 os 0x00; // Size of the uninitialized data section, or the sum of all such sections if there are multiple uninitialized data sections. - writeInt32 os entrypointCodeChunk.addr; // RVA of entry point , needs to point to bytes 0xFF 0x25 followed by the RVA+!0x4000000 in a section marked execute/read for EXEs or 0 for DLLs e.g. 0x0000b57e + writeInt32 os dataSectionPhysSize; // Size of the initialized data section + writeInt32 os 0x00; // Size of the uninitialized data section + writeInt32 os entrypointCodeChunk.addr; // RVA of entry point , needs to point to bytes 0xFF 0x25 followed by the RVA+!0x4000000 writeInt32 os textSectionAddr; // e.g. 0x0002000 // 000000b0 if modul.Is64Bit then @@ -3892,10 +3899,10 @@ let writeBinaryAndReportMappings (outfile, writeInt32AsUInt16 os minor; writeInt32 os 0x00; // Reserved Always 0 (see Section 23.1). // 000000d0 - writeInt32 os imageEndAddr; // Image Size: Size, in bytes, of image, including all headers and padding; shall be a multiple of Section Alignment. e.g. 0x0000e000 - writeInt32 os headerSectionPhysSize; // Header Size Combined size of MS-DOS Header, PE Header, PE Optional Header and padding; shall be a multiple of the file alignment. + writeInt32 os imageEndAddr; // Image Size: Size, in bytes, of image, including all headers and padding; + writeInt32 os headerSectionPhysSize; // Header Size Combined size of MS-DOS Header, PE Header, PE Optional Header and padding; writeInt32 os 0x00; // File Checksum Always 0 (see Section 23.1). QUERY: NOT ALWAYS ZERO - writeInt32AsUInt16 os modul.SubSystemFlags; // SubSystem Subsystem required to run this image. Shall be either IMAGE_SUBSYSTEM_WINDOWS_CE_GUI (0x3) or IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2). QUERY: Why is this 3 on the images ILASM produces + writeInt32AsUInt16 os modul.SubSystemFlags; // SubSystem Subsystem required to run this image. // DLL Flags Always 0x400 (no unmanaged windows exception handling - see Section 23.1). // Itanium: see notes at end of file // IMAGE_DLLCHARACTERISTICS_NX_COMPAT: See FSharp 1.0 bug 5019 and http://blogs.msdn.com/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx @@ -3930,7 +3937,7 @@ let writeBinaryAndReportMappings (outfile, writeInt32 os 0x00 // Export Table Always 0 (see Section 23.1). // 00000100 writeDirectory os importTableChunk // Import Table RVA of Import Table, (see clause 24.3.1). e.g. 0000b530 - // Native Resource Table: ECMA says Always 0 (see Section 23.1), but mscorlib and other files with resources bound into executable do not. For the moment assume the resources table is always the first resource in the file. + // Native Resource Table: ECMA says Always 0 (see Section 23.1), but mscorlib and other files with resources bound into executable do not. writeDirectory os nativeResourcesChunk // 00000110 @@ -3968,28 +3975,28 @@ let writeBinaryAndReportMappings (outfile, // 00000178 writeBytes os [| 0x2euy; 0x74uy; 0x65uy; 0x78uy; 0x74uy; 0x00uy; 0x00uy; 0x00uy; |] // ".text\000\000\000" // 00000180 - writeInt32 os textSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x00009584 - writeInt32 os textSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x00020000 - writeInt32 os textSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. 0x00009600 - writeInt32 os textSectionPhysLoc // PointerToRawData RVA to section's first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 00000200 + writeInt32 os textSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. + writeInt32 os textSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section + writeInt32 os textSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes + writeInt32 os textSectionPhysLoc // PointerToRawData RVA to section's first page within the PE file. // 00000190 writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section. writeInt32 os 0x00 // PointerToLineNumbers Always 0 (see Section 23.1). // 00000198 writeInt32AsUInt16 os 0x00// NumberOfRelocations Number of relocations, set to 0 if unused. writeInt32AsUInt16 os 0x00 // NumberOfLinenumbers Always 0 (see Section 23.1). - writeBytes os [| 0x20uy; 0x00uy; 0x00uy; 0x60uy |] // Characteristics Flags describing section's characteristics, see below. IMAGE_SCN_CNT_CODE || IMAGE_SCN_MEM_EXECUTE || IMAGE_SCN_MEM_READ + writeBytes os [| 0x20uy; 0x00uy; 0x00uy; 0x60uy |] // Characteristics Flags IMAGE_SCN_CNT_CODE || IMAGE_SCN_MEM_EXECUTE || IMAGE_SCN_MEM_READ write (Some dataSectionHeaderChunk.addr) os "data section header" [| |] // 000001a0 writeBytes os [| 0x2euy; 0x72uy; 0x73uy; 0x72uy; 0x63uy; 0x00uy; 0x00uy; 0x00uy; |] // ".rsrc\000\000\000" // writeBytes os [| 0x2e; 0x73; 0x64; 0x61; 0x74; 0x61; 0x00; 0x00; |] // ".sdata\000\000" - writeInt32 os dataSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c - writeInt32 os dataSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000 + writeInt32 os dataSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. + writeInt32 os dataSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section. // 000001b0 - writeInt32 os dataSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. e.g. 0x00000200 - writeInt32 os dataSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to section's first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 0x00009800 + writeInt32 os dataSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes, + writeInt32 os dataSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to section's first page within the PE file. // 000001b8 writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section. writeInt32 os 0x00 // PointerToLineNumbers Always 0 (see Section 23.1). @@ -4001,11 +4008,11 @@ let writeBinaryAndReportMappings (outfile, write (Some relocSectionHeaderChunk.addr) os "reloc section header" [| |] // 000001a0 writeBytes os [| 0x2euy; 0x72uy; 0x65uy; 0x6cuy; 0x6fuy; 0x63uy; 0x00uy; 0x00uy; |] // ".reloc\000\000" - writeInt32 os relocSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c - writeInt32 os relocSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000 + writeInt32 os relocSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. + writeInt32 os relocSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section. // 000001b0 - writeInt32 os relocSectionPhysSize // SizeOfRawData Size of the initialized reloc on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00000200 - writeInt32 os relocSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to section's first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00009800 + writeInt32 os relocSectionPhysSize // SizeOfRawData Size of the initialized reloc on disk in bytes + writeInt32 os relocSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to section's first page within the PE file. // 000001b8 writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section. writeInt32 os 0x00 // PointerToLineNumbers Always 0 (see Section 23.1). diff --git a/src/absil/ilwrite.fsi b/src/absil/ilwrite.fsi index fc23d028bd..e7b2aaf3f4 100755 --- a/src/absil/ilwrite.fsi +++ b/src/absil/ilwrite.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// The IL Binary writer. -module internal Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter +module internal FSharp.Compiler.AbstractIL.ILBinaryWriter -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.IL [] type ILStrongNameSigner = diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index 61771a9b2d..58dd9c241b 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter +module internal FSharp.Compiler.AbstractIL.ILPdbWriter open System open System.Collections.Generic @@ -12,12 +12,12 @@ open System.Reflection.Metadata open System.Reflection.Metadata.Ecma335 open System.Reflection.PortableExecutable open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Support -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Internal.Support +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range type BlobBuildingStream () = diff --git a/src/absil/ilwritepdb.fsi b/src/absil/ilwritepdb.fsi index af9f16be9e..a291ce4667 100644 --- a/src/absil/ilwritepdb.fsi +++ b/src/absil/ilwritepdb.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// The ILPdbWriter -module internal Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter +module internal FSharp.Compiler.AbstractIL.ILPdbWriter -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range open System.Collections.Generic open System.IO open System.Reflection.Metadata diff --git a/src/absil/ilx.fs b/src/absil/ilx.fs index 1914ace9b0..56d264a6dc 100755 --- a/src/absil/ilx.fs +++ b/src/absil/ilx.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Defines an extension of the IL algebra -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.Types open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library // -------------------------------------------------------------------- // Define an extension of the IL instruction algebra diff --git a/src/absil/ilx.fsi b/src/absil/ilx.fsi index 39792635fe..657e8353f6 100755 --- a/src/absil/ilx.fsi +++ b/src/absil/ilx.fsi @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// ILX extensions to Abstract IL types and instructions F# -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.Types open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.IL // -------------------------------------------------------------------- // Union references diff --git a/src/absil/zmap.fs b/src/absil/zmap.fs index c08767e274..4702eec5c7 100755 --- a/src/absil/zmap.fs +++ b/src/absil/zmap.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal open Internal.Utilities.Collections.Tagged open System.Collections.Generic diff --git a/src/absil/zmap.fsi b/src/absil/zmap.fsi index 12a1740002..733d11870f 100755 --- a/src/absil/zmap.fsi +++ b/src/absil/zmap.fsi @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal open Internal.Utilities open Internal.Utilities.Collections.Tagged -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library open System.Collections.Generic /// Maps with a specific comparison function diff --git a/src/absil/zset.fs b/src/absil/zset.fs index 960caa06e3..2f626674c8 100755 --- a/src/absil/zset.fs +++ b/src/absil/zset.fs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library open Internal.Utilities open Internal.Utilities.Collections.Tagged open System.Collections.Generic diff --git a/src/absil/zset.fsi b/src/absil/zset.fsi index 094e028812..5d1d341974 100755 --- a/src/absil/zset.fsi +++ b/src/absil/zset.fsi @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.AbstractIL.Internal +namespace FSharp.Compiler.AbstractIL.Internal open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal.Library open System.Collections.Generic /// Sets with a specific comparison function diff --git a/src/buildtools/fslex/fslex.fs b/src/buildtools/fslex/fslex.fs index d2f1af826b..e35f955914 100644 --- a/src/buildtools/fslex/fslex.fs +++ b/src/buildtools/fslex/fslex.fs @@ -13,7 +13,7 @@ open System.Collections.Generic open System.IO //------------------------------------------------------------------ -// This code is duplicated from Microsoft.FSharp.Compiler.UnicodeLexing +// This code is duplicated from FSharp.Compiler.UnicodeLexing type Lexbuf = LexBuffer diff --git a/src/buildtools/fsyacc/fsyacc.fs b/src/buildtools/fsyacc/fsyacc.fs index 185ff33232..b4d0a39093 100644 --- a/src/buildtools/fsyacc/fsyacc.fs +++ b/src/buildtools/fsyacc/fsyacc.fs @@ -12,7 +12,7 @@ open FsLexYacc.FsYacc open FsLexYacc.FsYacc.AST //------------------------------------------------------------------ -// This code is duplicated from Microsoft.FSharp.Compiler.UnicodeLexing +// This code is duplicated from FSharp.Compiler.UnicodeLexing type Lexbuf = LexBuffer diff --git a/src/fsharp/AccessibilityLogic.fs b/src/fsharp/AccessibilityLogic.fs index dcd8d5d801..009846bf4f 100644 --- a/src/fsharp/AccessibilityLogic.fs +++ b/src/fsharp/AccessibilityLogic.fs @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// The basic logic of private/internal/protected/InternalsVisibleTo/public accessibility -module internal Microsoft.FSharp.Compiler.AccessibilityLogic +module internal FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif /// Represents the 'keys' a particular piece of code can use to access other constructs?. diff --git a/src/fsharp/AttributeChecking.fs b/src/fsharp/AttributeChecking.fs index a28598d970..17e01bdaba 100644 --- a/src/fsharp/AttributeChecking.fs +++ b/src/fsharp/AttributeChecking.fs @@ -2,22 +2,22 @@ /// Logic associated with checking "ObsoleteAttribute" and other attributes /// on items from name resolution -module internal Microsoft.FSharp.Compiler.AttributeChecking +module internal FSharp.Compiler.AttributeChecking open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping open Microsoft.FSharp.Core.CompilerServices #endif diff --git a/src/fsharp/AugmentWithHashCompare.fs b/src/fsharp/AugmentWithHashCompare.fs index 6d9abf0dc1..70fc0df123 100755 --- a/src/fsharp/AugmentWithHashCompare.fs +++ b/src/fsharp/AugmentWithHashCompare.fs @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Generate the hash/compare functions we add to user-defined types by default. -module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare +module internal FSharp.Compiler.AugmentWithHashCompare -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos let mkIComparableCompareToSlotSig (g: TcGlobals) = TSlotSig("CompareTo",g.mk_IComparable_ty, [],[], [[TSlotParam(Some("obj"),g.obj_ty,false,false,false,[])]],Some g.int_ty) diff --git a/src/fsharp/AugmentWithHashCompare.fsi b/src/fsharp/AugmentWithHashCompare.fsi index 089966c8b1..13d3f18f0e 100755 --- a/src/fsharp/AugmentWithHashCompare.fsi +++ b/src/fsharp/AugmentWithHashCompare.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Generate the hash/compare functions we add to user-defined types by default. -module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare +module internal FSharp.Compiler.AugmentWithHashCompare -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals val CheckAugmentationAttribs : bool -> TcGlobals -> Import.ImportMap -> Tycon -> unit val TyconIsCandidateForAugmentationWithCompare : TcGlobals -> Tycon -> bool diff --git a/src/fsharp/CheckFormatStrings.fs b/src/fsharp/CheckFormatStrings.fs index 9d7fd72d7a..bf1f6bbcb3 100755 --- a/src/fsharp/CheckFormatStrings.fs +++ b/src/fsharp/CheckFormatStrings.fs @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.CheckFormatStrings - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.ConstraintSolver -open Microsoft.FSharp.Compiler.NameResolution +module internal FSharp.Compiler.CheckFormatStrings + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.ConstraintSolver +open FSharp.Compiler.NameResolution type FormatItem = Simple of TType | FuncAndVal diff --git a/src/fsharp/CheckFormatStrings.fsi b/src/fsharp/CheckFormatStrings.fsi index 2b6d8d4f02..10768a9424 100755 --- a/src/fsharp/CheckFormatStrings.fsi +++ b/src/fsharp/CheckFormatStrings.fsi @@ -5,12 +5,12 @@ /// /// Must be updated if the Printf runtime component is updated. -module internal Microsoft.FSharp.Compiler.CheckFormatStrings +module internal FSharp.Compiler.CheckFormatStrings -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.NameResolution +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals val ParseFormatString : Range.range -> TcGlobals -> formatStringCheckContext: FormatStringCheckContext option -> fmt: string -> bty: TType -> cty: TType -> dty: TType -> (TType * TType) * (Range.range * int) list diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 830a08bf2f..47ba63034d 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Coordinating compiler operations - configuration, loading initial context, reporting errors etc. -module internal Microsoft.FSharp.Compiler.CompileOps +module internal FSharp.Compiler.CompileOps open System open System.Collections.Generic @@ -14,39 +14,39 @@ open Internal.Utilities.Collections open Internal.Utilities.Filename open Internal.Utilities.Text -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.ConstraintSolver -open Microsoft.FSharp.Compiler.DiagnosticMessage -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.MethodCalls -open Microsoft.FSharp.Compiler.MethodOverrides -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.ReferenceResolver -open Microsoft.FSharp.Compiler.SignatureConformance -open Microsoft.FSharp.Compiler.TastPickle -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Diagnostics + +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.ConstraintSolver +open FSharp.Compiler.DiagnosticMessage +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Import +open FSharp.Compiler.Infos +open FSharp.Compiler.Lexhelp +open FSharp.Compiler.Lib +open FSharp.Compiler.MethodCalls +open FSharp.Compiler.MethodOverrides +open FSharp.Compiler.NameResolution +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range +open FSharp.Compiler.ReferenceResolver +open FSharp.Compiler.SignatureConformance +open FSharp.Compiler.TastPickle +open FSharp.Compiler.TypeChecker +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping open Microsoft.FSharp.Core.CompilerServices #endif @@ -384,10 +384,10 @@ let GetWarningLevel err = | NumberedError((n, _), _) | ErrorWithSuggestions((n, _), _, _, _) | Error((n, _), _) -> - // 1178, tcNoComparisonNeeded1, "The struct, record or union type '%s' is not structurally comparable because the type parameter %s does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to this type to clarify that the type is not comparable" - // 1178, tcNoComparisonNeeded2, "The struct, record or union type '%s' is not structurally comparable because the type '%s' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to this type to clarify that the type is not comparable" - // 1178, tcNoEqualityNeeded1, "The struct, record or union type '%s' does not support structural equality because the type parameter %s does not satisfy the 'equality' constraint. Consider adding the 'NoEquality' attribute to this type to clarify that the type does not support structural equality" - // 1178, tcNoEqualityNeeded2, "The struct, record or union type '%s' does not support structural equality because the type '%s' does not satisfy the 'equality' constraint. Consider adding the 'NoEquality' attribute to this type to clarify that the type does not support structural equality" + // 1178, tcNoComparisonNeeded1, "The struct, record or union type '%s' is not structurally comparable because the type parameter %s does not satisfy the 'comparison' constraint..." + // 1178, tcNoComparisonNeeded2, "The struct, record or union type '%s' is not structurally comparable because the type '%s' does not satisfy the 'comparison' constraint...." + // 1178, tcNoEqualityNeeded1, "The struct, record or union type '%s' does not support structural equality because the type parameter %s does not satisfy the 'equality' constraint..." + // 1178, tcNoEqualityNeeded2, "The struct, record or union type '%s' does not support structural equality because the type '%s' does not satisfy the 'equality' constraint...." if (n = 1178) then 5 else 2 // Level 2 | _ -> 2 @@ -434,7 +434,7 @@ let SplitRelatedDiagnostics(err:PhasedDiagnostic) = SplitRelatedException(err.Exception) -let DeclareMesssage = Microsoft.FSharp.Compiler.DiagnosticMessage.DeclareResourceString +let DeclareMesssage = FSharp.Compiler.DiagnosticMessage.DeclareResourceString do FSComp.SR.RunStartupValidation() let SeeAlsoE() = DeclareResourceString("SeeAlso", "%s") @@ -2542,12 +2542,12 @@ type TcConfigBuilder = let pdbfile = if tcConfigB.debuginfo then Some (match tcConfigB.debugSymbolFile with - | None -> Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter.getDebugFileName outfile tcConfigB.portablePDB + | None -> FSharp.Compiler.AbstractIL.ILPdbWriter.getDebugFileName outfile tcConfigB.portablePDB #if ENABLE_MONO_SUPPORT | Some _ when runningOnMono -> // On Mono, the name of the debug file has to be ".mdb" so specifying it explicitly is an error warning(Error(FSComp.SR.ilwriteMDBFileNameCannotBeChangedWarning(), rangeCmdArgs)) - Microsoft.FSharp.Compiler.AbstractIL.ILPdbWriter.getDebugFileName outfile tcConfigB.portablePDB + FSharp.Compiler.AbstractIL.ILPdbWriter.getDebugFileName outfile tcConfigB.portablePDB #endif | Some f -> f) elif (tcConfigB.debugSymbolFile <> None) && (not (tcConfigB.debuginfo)) then @@ -2790,22 +2790,26 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) = error(Error(FSComp.SR.buildExplicitCoreLibRequiresNoFramework("--noframework"), rangeStartup)) let ilGlobals = mkILGlobals ILScopeRef.Local + + // clrRoot: the location of the primary assembly (mscorlib.dll or netstandard.dll or System.Runtime.dll) + // + // targetFrameworkVersionValue: Normally just HighestInstalledNetFrameworkVersion() + // + // Note, when mscorlib.dll has been given explicitly the actual value of + // targetFrameworkVersion shouldn't matter since resolution has already happened. + // In those cases where it does matter (e.g. --noframework is not being used or we are processing further + // resolutions for a script) then it is correct to just use HighestInstalledNetFrameworkVersion(). let clrRootValue, targetFrameworkVersionValue = match primaryAssemblyExplicitFilenameOpt with - | Some(primaryAssemblyFilename) -> + | Some primaryAssemblyFilename -> let filename = ComputeMakePathAbsolute data.implicitIncludeDir primaryAssemblyFilename try - use ilReader = OpenILBinary(filename, data.reduceMemoryUsage, ilGlobals, None, data.shadowCopyReferences, data.tryGetMetadataSnapshot) - let ilModule = ilReader.ILModuleDef - match ilModule.ManifestOfAssembly.Version with - | Some(v1, v2, _, _) -> - let clrRoot = Some(Path.GetDirectoryName(FileSystem.GetFullPathShim(filename))) - clrRoot, (sprintf "v%d.%d" v1 v2) - | _ -> - failwith (FSComp.SR.buildCouldNotReadVersionInfoFromMscorlib()) + let clrRoot = Some(Path.GetDirectoryName(FileSystem.GetFullPathShim(filename))) + clrRoot, data.legacyReferenceResolver.HighestInstalledNetFrameworkVersion() with e -> + // We no longer expect the above to fail but leaving this just in case error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup)) - | _ -> + | None -> #if !ENABLE_MONO_SUPPORT // TODO: we have to get msbuild out of this if data.useSimpleResolution then @@ -2821,6 +2825,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) = let fsharpBinariesDirValue = // NOTE: It's not clear why this behaviour has been changed for the NETSTANDARD compilations of the F# compiler #if NETSTANDARD1_6 || NETSTANDARD2_0 + ignore ilGlobals data.defaultFSharpBinariesDir #else match fslibExplicitFilenameOpt with @@ -4799,7 +4804,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti #endif // do this prior to parsing, since parsing IL assembly code may refer to mscorlib #if !NO_INLINE_IL_PARSER - Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiConstants.parseILGlobals := tcGlobals.ilg + FSharp.Compiler.AbstractIL.Internal.AsciiConstants.parseILGlobals := tcGlobals.ilg #endif frameworkTcImports.SetTcGlobals(tcGlobals) return tcGlobals, frameworkTcImports @@ -5065,7 +5070,9 @@ module private ScriptPreprocessClosure = seen.ContainsKey(check) /// Parse a script from source. - let ParseScriptText(filename:string, source:string, tcConfig:TcConfig, codeContext, lexResourceManager:Lexhelp.LexResourceManager, errorLogger:ErrorLogger) = + let ParseScriptText + (filename:string, source:string, tcConfig:TcConfig, codeContext, + lexResourceManager:Lexhelp.LexResourceManager, errorLogger:ErrorLogger) = // fsc.exe -- COMPILED\!INTERACTIVE // fsi.exe -- !COMPILED\INTERACTIVE @@ -5083,12 +5090,26 @@ module private ScriptPreprocessClosure = ParseOneInputLexbuf (tcConfig, lexResourceManager, defines, lexbuf, filename, isLastCompiland, errorLogger) /// Create a TcConfig for load closure starting from a single .fsx file - let CreateScriptTextTcConfig (legacyReferenceResolver, defaultFSharpBinariesDir, filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = + let CreateScriptTextTcConfig + (legacyReferenceResolver, defaultFSharpBinariesDir, + filename:string, codeContext, + useSimpleResolution, useFsiAuxLib, + basicReferences, applyCommandLineArgs, + assumeDotNetFramework, tryGetMetadataSnapshot, + reduceMemoryUsage) = + let projectDir = Path.GetDirectoryName(filename) let isInteractive = (codeContext = CodeContext.CompilationAndEvaluation) let isInvalidationSupported = (codeContext = CodeContext.Editing) - let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, reduceMemoryUsage, projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore=CopyFSharpCoreFlag.No, tryGetMetadataSnapshot=tryGetMetadataSnapshot) + + let tcConfigB = + TcConfigBuilder.CreateNew + (legacyReferenceResolver, defaultFSharpBinariesDir, reduceMemoryUsage, projectDir, + isInteractive, isInvalidationSupported, defaultCopyFSharpCore=CopyFSharpCoreFlag.No, + tryGetMetadataSnapshot=tryGetMetadataSnapshot) + applyCommandLineArgs tcConfigB + match basicReferences with | None -> BasicReferencesForScriptLoadClosure(useFsiAuxLib, assumeDotNetFramework) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0, f)) // Add script references | Some rs -> for m, r in rs do tcConfigB.AddReferencedAssemblyByPath(m, r) @@ -5119,7 +5140,9 @@ module private ScriptPreprocessClosure = errorRecovery e m [] - let ApplyMetaCommandsFromInputToTcConfigAndGatherNoWarn (tcConfig:TcConfig, inp:ParsedInput, pathOfMetaCommandSource) = + let ApplyMetaCommandsFromInputToTcConfigAndGatherNoWarn + (tcConfig:TcConfig, inp:ParsedInput, pathOfMetaCommandSource) = + let tcConfigB = tcConfig.CloneOfOriginalBuilder let nowarns = ref [] let getWarningNumber = fun () (m, s) -> nowarns := (s, m) :: !nowarns @@ -5138,7 +5161,10 @@ module private ScriptPreprocessClosure = let tcConfigB = tcConfig.CloneOfOriginalBuilder TcConfig.Create(tcConfigB, validate=false), nowarns - let FindClosureFiles(closureSources, tcConfig:TcConfig, codeContext, lexResourceManager:Lexhelp.LexResourceManager) = + let FindClosureFiles + (closureSources, tcConfig:TcConfig, codeContext, + lexResourceManager:Lexhelp.LexResourceManager) = + let tcConfig = ref tcConfig let observedSources = Observed() @@ -5198,13 +5224,29 @@ module private ScriptPreprocessClosure = closureFiles else match List.frontAndBack closureFiles with - | rest, ClosureFile(filename, m, Some(ParsedInput.ImplFile(ParsedImplFileInput(name, isScript, qualNameOfFile, scopedPragmas, hashDirectives, implFileFlags, _))), parseDiagnostics, metaDiagnostics, nowarns) -> - rest @ [ClosureFile(filename, m, Some(ParsedInput.ImplFile(ParsedImplFileInput(name, isScript, qualNameOfFile, scopedPragmas, hashDirectives, implFileFlags, (true, tcConfig.target.IsExe)))), parseDiagnostics, metaDiagnostics, nowarns)] + | rest, ClosureFile + (filename, m, + Some(ParsedInput.ImplFile(ParsedImplFileInput(name, isScript, qualNameOfFile, scopedPragmas, hashDirectives, implFileFlags, _))), + parseDiagnostics, metaDiagnostics, nowarns) -> + + let isLastCompiland = (true, tcConfig.target.IsExe) + rest @ [ClosureFile + (filename, m, + Some(ParsedInput.ImplFile(ParsedImplFileInput(name, isScript, qualNameOfFile, scopedPragmas, hashDirectives, implFileFlags, isLastCompiland))), + parseDiagnostics, metaDiagnostics, nowarns)] + | _ -> closureFiles // Get all source files. let sourceFiles = [ for (ClosureFile(filename, m, _, _, _, _)) in closureFiles -> (filename, m) ] - let sourceInputs = [ for (ClosureFile(filename, _, input, parseDiagnostics, metaDiagnostics, _nowarns)) in closureFiles -> ({ FileName=filename; SyntaxTree=input; ParseDiagnostics=parseDiagnostics; MetaCommandDiagnostics=metaDiagnostics }: LoadClosureInput) ] + + let sourceInputs = + [ for (ClosureFile(filename, _, input, parseDiagnostics, metaDiagnostics, _nowarns)) in closureFiles -> + ({ FileName=filename + SyntaxTree=input + ParseDiagnostics=parseDiagnostics + MetaCommandDiagnostics=metaDiagnostics } : LoadClosureInput) ] + let globalNoWarns = closureFiles |> List.collect (fun (ClosureFile(_, _, _, _, _, noWarns)) -> noWarns) // Resolve all references. @@ -5250,18 +5292,33 @@ module private ScriptPreprocessClosure = result /// Given source text, find the full load closure. Used from service.fs, when editing a script file - let GetFullClosureOfScriptText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = + let GetFullClosureOfScriptText + (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, + filename, source, + codeContext, useSimpleResolution, useFsiAuxLib, + lexResourceManager:Lexhelp.LexResourceManager, + applyCommmandLineArgs, assumeDotNetFramework, + tryGetMetadataSnapshot, reduceMemoryUsage) = + // Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script // // This is tries to mimic the action of running the script in F# Interactive - the initial context for scripting is created // first, then #I and other directives are processed. let references0 = - let tcConfig = CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) + let tcConfig = + CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, + filename, codeContext, useSimpleResolution, + useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework, + tryGetMetadataSnapshot, reduceMemoryUsage) + let resolutions0, _unresolvedReferences = GetAssemblyResolutionInformation(ctok, tcConfig) let references0 = resolutions0 |> List.map (fun r->r.originalReference.Range, r.resolvedPath) |> Seq.distinct |> List.ofSeq references0 - let tcConfig = CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) + let tcConfig = + CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, + codeContext, useSimpleResolution, useFsiAuxLib, Some references0, + applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) let closureSources = [ClosureSource(filename, range0, source, true)] let closureFiles, tcConfig = FindClosureFiles(closureSources, tcConfig, codeContext, lexResourceManager) @@ -5269,7 +5326,12 @@ module private ScriptPreprocessClosure = /// Given source filename, find the full load closure /// Used from fsi.fs and fsc.fs, for #load and command line - let GetFullClosureOfScriptFiles(ctok, tcConfig:TcConfig, files:(string*range) list, codeContext, lexResourceManager:Lexhelp.LexResourceManager) = + let GetFullClosureOfScriptFiles + (ctok, tcConfig:TcConfig, + files:(string*range) list, + codeContext, + lexResourceManager:Lexhelp.LexResourceManager) = + let mainFile = fst (List.last files) let closureSources = files |> List.collect (fun (filename, m) -> ClosureSourceOfFilename(filename, m, tcConfig.inputCodePage, true)) let closureFiles, tcConfig = FindClosureFiles(closureSources, tcConfig, codeContext, lexResourceManager) @@ -5277,17 +5339,23 @@ module private ScriptPreprocessClosure = type LoadClosure with /// Analyze a script text and find the closure of its references. - /// Used from FCS, when editing a script file. - // - /// A temporary TcConfig is created along the way, is why this routine takes so many arguments. We want to be sure to use exactly the - /// same arguments as the rest of the application. - static member ComputeClosureOfScriptText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) : LoadClosure = + static member ComputeClosureOfScriptText + (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, + filename:string, source:string, codeContext, useSimpleResolution:bool, + useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, + applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = + use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse - ScriptPreprocessClosure.GetFullClosureOfScriptText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) + ScriptPreprocessClosure.GetFullClosureOfScriptText + (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, + codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, + applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) + + /// Analyze a set of script files and find the closure of their references. + static member ComputeClosureOfScriptFiles + (ctok, tcConfig:TcConfig, files:(string*range) list, codeContext, + lexResourceManager:Lexhelp.LexResourceManager) = - /// Analyze a set of script files and find the closure of their references. The resulting references are then added to the given TcConfig. - /// Used from fsi.fs and fsc.fs, for #load and command line. - static member ComputeClosureOfScriptFiles (ctok, tcConfig:TcConfig, files:(string*range) list, codeContext, lexResourceManager:Lexhelp.LexResourceManager) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse ScriptPreprocessClosure.GetFullClosureOfScriptFiles (ctok, tcConfig, files, codeContext, lexResourceManager) diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index 9ee74ee993..912bcf137c 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -1,25 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Coordinating compiler operations - configuration, loading initial context, reporting errors etc. -module internal Microsoft.FSharp.Compiler.CompileOps +module internal FSharp.Compiler.CompileOps open System open System.Text open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.TypeChecker +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals open Microsoft.FSharp.Core.CompilerServices #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index 344c0e1412..6e9152d598 100755 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -2,31 +2,24 @@ // # FSComp.SR.opts -module internal Microsoft.FSharp.Compiler.CompileOptions +module internal FSharp.Compiler.CompileOptions open Internal.Utilities open System -open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.IlxGen +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.CompileOps +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lib +open FSharp.Compiler.Range +open FSharp.Compiler.IlxGen #if FX_RESHAPED_REFLECTION open Microsoft.FSharp.Core.ReflectionAdapters @@ -102,7 +95,7 @@ let compilerOptionUsage (CompilerOption(s,tag,spec,_,_)) = | OptionGeneral _ -> if tag="" then sprintf "%s" s else sprintf "%s:%s" s tag (* still being decided *) let PrintCompilerOption (CompilerOption(_s,_tag,_spec,_,help) as compilerOption) = - let flagWidth = 30 // fixed width for printing of flags, e.g. --warnaserror: + let flagWidth = 42 // fixed width for printing of flags, e.g. --debug:{full|pdbonly|portable|embedded} let defaultLineWidth = 80 // the fallback width let lineWidth = try @@ -113,7 +106,6 @@ let PrintCompilerOption (CompilerOption(_s,_tag,_spec,_,help) as compilerOption) // flagWidth chars - for flags description or padding on continuation lines. // single space - space. // description - words upto but excluding the final character of the line. - assert(flagWidth = 30) printf "%-40s" (compilerOptionUsage compilerOption) let printWord column (word:string) = // Have printed upto column. @@ -121,7 +113,6 @@ let PrintCompilerOption (CompilerOption(_s,_tag,_spec,_,help) as compilerOption) // Returns the column printed to (suited to folding). if column + 1 (*space*) + word.Length >= lineWidth then // NOTE: "equality" ensures final character of the line is never printed printfn "" (* newline *) - assert(flagWidth = 30) printf "%-40s %s" ""(*<--flags*) word flagWidth + 1 + word.Length else @@ -444,14 +435,18 @@ let subSystemVersionSwitch (tcConfigB : TcConfigBuilder) (text : string) = let fail() = error(Error(FSComp.SR.optsInvalidSubSystemVersion(text), rangeCmdArgs)) // per spec for 357994: Validate input string, should be two positive integers x.y when x>=4 and y>=0 and both <= 65535 - if System.String.IsNullOrEmpty(text) then fail() + if System.String.IsNullOrEmpty(text) then + fail() else - match text.Split('.') with - | [| majorStr; minorStr|] -> - match (Int32.TryParse majorStr), (Int32.TryParse minorStr) with - | (true, major), (true, minor) when major >= 4 && major <=65535 && minor >=0 && minor <= 65535 -> tcConfigB.subsystemVersion <- (major, minor) + match text.Split('.') with + | [| majorStr; minorStr|] -> + match (Int32.TryParse majorStr), (Int32.TryParse minorStr) with + | (true, major), (true, minor) + when major >= 4 && major <= 65535 + && minor >=0 && minor <= 65535 -> + tcConfigB.subsystemVersion <- (major, minor) + | _ -> fail() | _ -> fail() - | _ -> fail() let (++) x s = x @ [s] @@ -467,14 +462,31 @@ let SetDebugSwitch (tcConfigB : TcConfigBuilder) (dtype : string option) (s : Op match dtype with | Some(s) -> match s with - | "portable" -> tcConfigB.portablePDB <- true; tcConfigB.embeddedPDB <- false; tcConfigB.jitTracking <- true; tcConfigB.ignoreSymbolStoreSequencePoints <- true - | "pdbonly" -> tcConfigB.portablePDB <- false; tcConfigB.embeddedPDB <- false; tcConfigB.jitTracking <- false - | "embedded" -> tcConfigB.portablePDB <- true; tcConfigB.embeddedPDB <- true; tcConfigB.jitTracking <- true; tcConfigB.ignoreSymbolStoreSequencePoints <- true + | "portable" -> + tcConfigB.portablePDB <- true + tcConfigB.embeddedPDB <- false + tcConfigB.jitTracking <- true + tcConfigB.ignoreSymbolStoreSequencePoints <- true + | "pdbonly" -> + tcConfigB.portablePDB <- false + tcConfigB.embeddedPDB <- false + tcConfigB.jitTracking <- false + | "embedded" -> + tcConfigB.portablePDB <- true + tcConfigB.embeddedPDB <- true + tcConfigB.jitTracking <- true + tcConfigB.ignoreSymbolStoreSequencePoints <- true #if FX_NO_PDB_WRITER // When building on the coreclr, full means portable - | "full" -> tcConfigB.portablePDB <- true; tcConfigB.embeddedPDB <- false; tcConfigB.jitTracking <- true + | "full" -> + tcConfigB.portablePDB <- true + tcConfigB.embeddedPDB <- false + tcConfigB.jitTracking <- true #else - | "full" -> tcConfigB.portablePDB <- false; tcConfigB.embeddedPDB <- false; tcConfigB.jitTracking <- true + | "full" -> + tcConfigB.portablePDB <- false + tcConfigB.embeddedPDB <- false + tcConfigB.jitTracking <- true #endif | _ -> error(Error(FSComp.SR.optsUnrecognizedDebugType(s), rangeCmdArgs)) @@ -604,51 +616,93 @@ let errorsAndWarningsFlags (tcConfigB: TcConfigBuilder) = //-------------------------- let outputFileFlagsFsi (_tcConfigB : TcConfigBuilder) = [] + let outputFileFlagsFsc (tcConfigB : TcConfigBuilder) = [ - CompilerOption("out", tagFile, OptionString (setOutFileName tcConfigB), None, - Some (FSComp.SR.optsNameOfOutputFile()) ); - - CompilerOption("target", tagExe, OptionString (SetTarget tcConfigB), None, - Some (FSComp.SR.optsBuildConsole())) - - CompilerOption("target", tagWinExe, OptionString (SetTarget tcConfigB), None, - Some (FSComp.SR.optsBuildWindows())) - - CompilerOption("target", tagLibrary, OptionString (SetTarget tcConfigB), None, - Some (FSComp.SR.optsBuildLibrary())) - - CompilerOption("target", tagModule, OptionString (SetTarget tcConfigB), None, - Some (FSComp.SR.optsBuildModule())) - - CompilerOption("delaysign", tagNone, OptionSwitch (fun s -> tcConfigB.delaysign <- (s = OptionSwitch.On)), None, - Some (FSComp.SR.optsDelaySign())) - - CompilerOption("publicsign", tagNone, OptionSwitch (fun s -> tcConfigB.publicsign <- (s = OptionSwitch.On)), None, - Some (FSComp.SR.optsPublicSign())) - - CompilerOption("doc", tagFile, OptionString (fun s -> tcConfigB.xmlDocOutputFile <- Some s), None, - Some (FSComp.SR.optsWriteXml())) - - CompilerOption("keyfile", tagFile, OptionString (fun s -> tcConfigB.signer <- Some(s)), None, - Some (FSComp.SR.optsStrongKeyFile())) - - CompilerOption("keycontainer", tagString, OptionString(fun s -> tcConfigB.container <- Some(s)),None, - Some(FSComp.SR.optsStrongKeyContainer())) - - CompilerOption("platform", tagString, OptionString (fun s -> tcConfigB.platform <- match s with | "x86" -> Some X86 | "x64" -> Some AMD64 | "Itanium" -> Some IA64 | "anycpu32bitpreferred" -> (tcConfigB.prefer32Bit <- true; None) | "anycpu" -> None | _ -> error(Error(FSComp.SR.optsUnknownPlatform(s),rangeCmdArgs))), None, - Some(FSComp.SR.optsPlatform())) - - CompilerOption("nooptimizationdata", tagNone, OptionUnit (fun () -> tcConfigB.onlyEssentialOptimizationData <- true), None, - Some (FSComp.SR.optsNoOpt())) - - CompilerOption("nointerfacedata", tagNone, OptionUnit (fun () -> tcConfigB.noSignatureData <- true), None, - Some (FSComp.SR.optsNoInterface())) - - CompilerOption("sig", tagFile, OptionString (setSignatureFile tcConfigB), None, - Some (FSComp.SR.optsSig())) + CompilerOption + ("out", tagFile, + OptionString (setOutFileName tcConfigB), None, + Some (FSComp.SR.optsNameOfOutputFile()) ); + + CompilerOption + ("target", tagExe, + OptionString (SetTarget tcConfigB), None, + Some (FSComp.SR.optsBuildConsole())) + + CompilerOption + ("target", tagWinExe, + OptionString (SetTarget tcConfigB), None, + Some (FSComp.SR.optsBuildWindows())) + + CompilerOption + ("target", tagLibrary, + OptionString (SetTarget tcConfigB), None, + Some (FSComp.SR.optsBuildLibrary())) + + CompilerOption + ("target", tagModule, + OptionString (SetTarget tcConfigB), None, + Some (FSComp.SR.optsBuildModule())) + + CompilerOption + ("delaysign", tagNone, + OptionSwitch (fun s -> tcConfigB.delaysign <- (s = OptionSwitch.On)), None, + Some (FSComp.SR.optsDelaySign())) + + CompilerOption + ("publicsign", tagNone, + OptionSwitch (fun s -> tcConfigB.publicsign <- (s = OptionSwitch.On)), None, + Some (FSComp.SR.optsPublicSign())) + + CompilerOption + ("doc", tagFile, + OptionString (fun s -> tcConfigB.xmlDocOutputFile <- Some s), None, + Some (FSComp.SR.optsWriteXml())) + + CompilerOption + ("keyfile", tagFile, + OptionString (fun s -> tcConfigB.signer <- Some(s)), None, + Some (FSComp.SR.optsStrongKeyFile())) + + CompilerOption + ("keycontainer", tagString, + OptionString(fun s -> tcConfigB.container <- Some(s)),None, + Some(FSComp.SR.optsStrongKeyContainer())) + + CompilerOption + ("platform", tagString, + OptionString (fun s -> + tcConfigB.platform <- + match s with + | "x86" -> Some X86 + | "x64" -> Some AMD64 + | "Itanium" -> Some IA64 + | "anycpu32bitpreferred" -> + tcConfigB.prefer32Bit <- true + None + | "anycpu" -> None + | _ -> error(Error(FSComp.SR.optsUnknownPlatform(s),rangeCmdArgs))), None, + Some(FSComp.SR.optsPlatform())) + + CompilerOption + ("nooptimizationdata", tagNone, + OptionUnit (fun () -> tcConfigB.onlyEssentialOptimizationData <- true), None, + Some (FSComp.SR.optsNoOpt())) + + CompilerOption + ("nointerfacedata", tagNone, + OptionUnit (fun () -> tcConfigB.noSignatureData <- true), None, + Some (FSComp.SR.optsNoInterface())) + + CompilerOption + ("sig", tagFile, + OptionString (setSignatureFile tcConfigB), None, + Some (FSComp.SR.optsSig())) - CompilerOption("nocopyfsharpcore", tagNone, OptionUnit (fun () -> tcConfigB.copyFSharpCore <- CopyFSharpCoreFlag.No), None, Some (FSComp.SR.optsNoCopyFsharpCore())) + CompilerOption + ("nocopyfsharpcore", tagNone, + OptionUnit (fun () -> tcConfigB.copyFSharpCore <- CopyFSharpCoreFlag.No), None, + Some (FSComp.SR.optsNoCopyFsharpCore())) ] @@ -658,20 +712,30 @@ let outputFileFlagsFsc (tcConfigB : TcConfigBuilder) = let resourcesFlagsFsi (_tcConfigB : TcConfigBuilder) = [] let resourcesFlagsFsc (tcConfigB : TcConfigBuilder) = [ - CompilerOption("win32res", tagFile, OptionString (fun s -> tcConfigB.win32res <- s), None, - Some (FSComp.SR.optsWin32res())) + CompilerOption + ("win32res", tagFile, + OptionString (fun s -> tcConfigB.win32res <- s), None, + Some (FSComp.SR.optsWin32res())) - CompilerOption("win32manifest", tagFile, OptionString (fun s -> tcConfigB.win32manifest <- s), None, - Some (FSComp.SR.optsWin32manifest())) + CompilerOption + ("win32manifest", tagFile, + OptionString (fun s -> tcConfigB.win32manifest <- s), None, + Some (FSComp.SR.optsWin32manifest())) - CompilerOption("nowin32manifest", tagNone, OptionUnit (fun () -> tcConfigB.includewin32manifest <- false), None, - Some (FSComp.SR.optsNowin32manifest())) - - CompilerOption("resource", tagResInfo, OptionString (fun s -> tcConfigB.AddEmbeddedResource s), None, - Some (FSComp.SR.optsResource())) - - CompilerOption("linkresource", tagResInfo, OptionString (fun s -> tcConfigB.linkResources <- tcConfigB.linkResources ++ s), None, - Some (FSComp.SR.optsLinkresource())) + CompilerOption + ("nowin32manifest", tagNone, + OptionUnit (fun () -> tcConfigB.includewin32manifest <- false), None, + Some (FSComp.SR.optsNowin32manifest())) + + CompilerOption + ("resource", tagResInfo, + OptionString (fun s -> tcConfigB.AddEmbeddedResource s), None, + Some (FSComp.SR.optsResource())) + + CompilerOption + ("linkresource", tagResInfo, + OptionString (fun s -> tcConfigB.linkResources <- tcConfigB.linkResources ++ s), None, + Some (FSComp.SR.optsLinkresource())) ] @@ -680,28 +744,53 @@ let resourcesFlagsFsc (tcConfigB : TcConfigBuilder) = let codeGenerationFlags isFsi (tcConfigB : TcConfigBuilder) = let debug = - [CompilerOption("debug", tagNone, OptionSwitch (SetDebugSwitch tcConfigB None), None, - Some (FSComp.SR.optsDebugPM())) - CompilerOption("debug", tagFullPDBOnlyPortable, OptionString (fun s -> SetDebugSwitch tcConfigB (Some(s)) OptionSwitch.On), None, - Some (FSComp.SR.optsDebug(if isFsi then "pdbonly" else "full"))) + [ CompilerOption + ("debug", tagNone, + OptionSwitch (SetDebugSwitch tcConfigB None), None, + Some (FSComp.SR.optsDebugPM())) + + CompilerOption + ("debug", tagFullPDBOnlyPortable, + OptionString (fun s -> SetDebugSwitch tcConfigB (Some(s)) OptionSwitch.On), None, + Some (FSComp.SR.optsDebug(if isFsi then "pdbonly" else "full"))) ] let embed = - [CompilerOption("embed", tagNone, OptionSwitch (SetEmbedAllSourceSwitch tcConfigB) , None, - Some (FSComp.SR.optsEmbedAllSource())) - CompilerOption("embed", tagFileList, OptionStringList (fun f -> tcConfigB.AddEmbeddedSourceFile f), None, - Some ( FSComp.SR.optsEmbedSource())); - CompilerOption("sourcelink", tagFile, OptionString (fun f -> tcConfigB.sourceLink <- f), None, - Some ( FSComp.SR.optsSourceLink())); + [ CompilerOption + ("embed", tagNone, + OptionSwitch (SetEmbedAllSourceSwitch tcConfigB) , None, + Some (FSComp.SR.optsEmbedAllSource())) + + CompilerOption + ("embed", tagFileList, + OptionStringList (fun f -> tcConfigB.AddEmbeddedSourceFile f), None, + Some ( FSComp.SR.optsEmbedSource())) + + CompilerOption + ("sourcelink", tagFile, + OptionString (fun f -> tcConfigB.sourceLink <- f), None, + Some ( FSComp.SR.optsSourceLink())) ] + let codegen = - [CompilerOption("optimize", tagNone, OptionSwitch (SetOptimizeSwitch tcConfigB) , None, - Some (FSComp.SR.optsOptimize())) - CompilerOption("tailcalls", tagNone, OptionSwitch (SetTailcallSwitch tcConfigB), None, - Some (FSComp.SR.optsTailcalls())) - CompilerOption("deterministic", tagNone, OptionSwitch (SetDeterministicSwitch tcConfigB), None, - Some (FSComp.SR.optsDeterministic())) - CompilerOption("crossoptimize", tagNone, OptionSwitch (crossOptimizeSwitch tcConfigB), None, - Some (FSComp.SR.optsCrossoptimize())) + [ CompilerOption + ("optimize", tagNone, + OptionSwitch (SetOptimizeSwitch tcConfigB) , None, + Some (FSComp.SR.optsOptimize())) + + CompilerOption + ("tailcalls", tagNone, + OptionSwitch (SetTailcallSwitch tcConfigB), None, + Some (FSComp.SR.optsTailcalls())) + + CompilerOption + ("deterministic", tagNone, + OptionSwitch (SetDeterministicSwitch tcConfigB), None, + Some (FSComp.SR.optsDeterministic())) + + CompilerOption + ("crossoptimize", tagNone, + OptionSwitch (crossOptimizeSwitch tcConfigB), None, + Some (FSComp.SR.optsCrossoptimize())) ] if isFsi then debug @ codegen else debug @ embed @ codegen @@ -712,14 +801,23 @@ let codeGenerationFlags isFsi (tcConfigB : TcConfigBuilder) = let defineSymbol tcConfigB s = tcConfigB.conditionalCompilationDefines <- s :: tcConfigB.conditionalCompilationDefines let mlCompatibilityFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("mlcompatibility", tagNone, OptionUnit (fun () -> tcConfigB.mlCompatibility<-true; tcConfigB.TurnWarningOff(rangeCmdArgs,"62")), None, - Some (FSComp.SR.optsMlcompatibility())) + CompilerOption + ("mlcompatibility", tagNone, + OptionUnit (fun () -> tcConfigB.mlCompatibility<-true; tcConfigB.TurnWarningOff(rangeCmdArgs,"62")), None, + Some (FSComp.SR.optsMlcompatibility())) + let languageFlags tcConfigB = [ - CompilerOption("checked", tagNone, OptionSwitch (fun switch -> tcConfigB.checkOverflow <- (switch = OptionSwitch.On)), None, - Some (FSComp.SR.optsChecked())) - CompilerOption("define", tagString, OptionString (defineSymbol tcConfigB), None, - Some (FSComp.SR.optsDefine())) + CompilerOption + ("checked", tagNone, + OptionSwitch (fun switch -> tcConfigB.checkOverflow <- (switch = OptionSwitch.On)), None, + Some (FSComp.SR.optsChecked())) + + CompilerOption + ("define", tagString, + OptionString (defineSymbol tcConfigB), None, + Some (FSComp.SR.optsDefine())) + mlCompatibilityFlag tcConfigB ] @@ -728,37 +826,52 @@ let languageFlags tcConfigB = //----------------------------------- let libFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("lib", tagDirList, OptionStringList (fun s -> tcConfigB.AddIncludePath (rangeStartup,s,tcConfigB.implicitIncludeDir)), None, - Some (FSComp.SR.optsLib())) + CompilerOption + ("lib", tagDirList, + OptionStringList (fun s -> tcConfigB.AddIncludePath (rangeStartup,s,tcConfigB.implicitIncludeDir)), None, + Some (FSComp.SR.optsLib())) let libFlagAbbrev (tcConfigB : TcConfigBuilder) = - CompilerOption("I", tagDirList, OptionStringList (fun s -> tcConfigB.AddIncludePath (rangeStartup,s,tcConfigB.implicitIncludeDir)), None, - Some (FSComp.SR.optsShortFormOf("--lib"))) + CompilerOption + ("I", tagDirList, + OptionStringList (fun s -> tcConfigB.AddIncludePath (rangeStartup,s,tcConfigB.implicitIncludeDir)), None, + Some (FSComp.SR.optsShortFormOf("--lib"))) let codePageFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("codepage", tagInt, OptionInt (fun n -> - try - System.Text.Encoding.GetEncoding(n) |> ignore - with :? System.ArgumentException as err -> - error(Error(FSComp.SR.optsProblemWithCodepage(n,err.Message),rangeCmdArgs)) + CompilerOption + ("codepage", tagInt, + OptionInt (fun n -> + try + System.Text.Encoding.GetEncoding(n) |> ignore + with :? System.ArgumentException as err -> + error(Error(FSComp.SR.optsProblemWithCodepage(n,err.Message),rangeCmdArgs)) - tcConfigB.inputCodePage <- Some(n)), None, - Some (FSComp.SR.optsCodepage())) + tcConfigB.inputCodePage <- Some(n)), None, + Some (FSComp.SR.optsCodepage())) let preferredUiLang (tcConfigB: TcConfigBuilder) = - CompilerOption("preferreduilang", tagString, OptionString (fun s -> tcConfigB.preferredUiLang <- Some(s)), None, Some(FSComp.SR.optsPreferredUiLang())) + CompilerOption + ("preferreduilang", tagString, + OptionString (fun s -> tcConfigB.preferredUiLang <- Some(s)), None, + Some(FSComp.SR.optsPreferredUiLang())) let utf8OutputFlag (tcConfigB: TcConfigBuilder) = - CompilerOption("utf8output", tagNone, OptionUnit (fun () -> tcConfigB.utf8output <- true), None, - Some (FSComp.SR.optsUtf8output())) + CompilerOption + ("utf8output", tagNone, + OptionUnit (fun () -> tcConfigB.utf8output <- true), None, + Some (FSComp.SR.optsUtf8output())) let fullPathsFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("fullpaths", tagNone, OptionUnit (fun () -> tcConfigB.showFullPaths <- true), None, - Some (FSComp.SR.optsFullpaths())) + CompilerOption + ("fullpaths", tagNone, + OptionUnit (fun () -> tcConfigB.showFullPaths <- true), None, + Some (FSComp.SR.optsFullpaths())) let cliRootFlag (_tcConfigB : TcConfigBuilder) = - CompilerOption("cliroot", tagString, OptionString (fun _ -> ()), Some(DeprecatedCommandLineOptionFull(FSComp.SR.optsClirootDeprecatedMsg(), rangeCmdArgs)), - Some(FSComp.SR.optsClirootDescription())) + CompilerOption + ("cliroot", tagString, + OptionString (fun _ -> ()), Some(DeprecatedCommandLineOptionFull(FSComp.SR.optsClirootDeprecatedMsg(), rangeCmdArgs)), + Some(FSComp.SR.optsClirootDescription())) let SetTargetProfile tcConfigB v = tcConfigB.primaryAssembly <- @@ -778,20 +891,26 @@ let advancedFlagsBoth tcConfigB = yield preferredUiLang tcConfigB yield fullPathsFlag tcConfigB yield libFlag tcConfigB - yield CompilerOption("simpleresolution", - tagNone, - OptionUnit (fun () -> tcConfigB.useSimpleResolution<-true), - None, - Some (FSComp.SR.optsSimpleresolution())) - yield CompilerOption("targetprofile", tagString, OptionString (SetTargetProfile tcConfigB), None, Some(FSComp.SR.optsTargetProfile())) + yield CompilerOption + ("simpleresolution", + tagNone, + OptionUnit (fun () -> tcConfigB.useSimpleResolution<-true), None, + Some (FSComp.SR.optsSimpleresolution())) + + yield CompilerOption + ("targetprofile", tagString, + OptionString (SetTargetProfile tcConfigB), None, + Some(FSComp.SR.optsTargetProfile())) ] let noFrameworkFlag isFsc tcConfigB = - CompilerOption("noframework", tagNone, OptionUnit (fun () -> - tcConfigB.framework <- false - if isFsc then - tcConfigB.implicitlyResolveAssemblies <- false), None, - Some (FSComp.SR.optsNoframework())) + CompilerOption + ("noframework", tagNone, + OptionUnit (fun () -> + tcConfigB.framework <- false + if isFsc then + tcConfigB.implicitlyResolveAssemblies <- false), None, + Some (FSComp.SR.optsNoframework())) let advancedFlagsFsi tcConfigB = advancedFlagsBoth tcConfigB @ @@ -802,51 +921,79 @@ let advancedFlagsFsi tcConfigB = let advancedFlagsFsc tcConfigB = advancedFlagsBoth tcConfigB @ [ - yield CompilerOption("baseaddress", tagAddress, OptionString (fun s -> tcConfigB.baseAddress <- Some(int32 s)), None, Some (FSComp.SR.optsBaseaddress())) + yield CompilerOption + ("baseaddress", tagAddress, + OptionString (fun s -> tcConfigB.baseAddress <- Some(int32 s)), None, + Some (FSComp.SR.optsBaseaddress())) + yield noFrameworkFlag true tcConfigB - yield CompilerOption("standalone", tagNone, OptionUnit (fun _ -> - tcConfigB.openDebugInformationForLaterStaticLinking <- true - tcConfigB.standalone <- true - tcConfigB.implicitlyResolveAssemblies <- true), None, - Some (FSComp.SR.optsStandalone())) + yield CompilerOption + ("standalone", tagNone, + OptionUnit (fun _ -> + tcConfigB.openDebugInformationForLaterStaticLinking <- true + tcConfigB.standalone <- true + tcConfigB.implicitlyResolveAssemblies <- true), None, + Some (FSComp.SR.optsStandalone())) - yield CompilerOption("staticlink", tagFile, OptionString (fun s -> tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [s]), None, - Some (FSComp.SR.optsStaticlink())) + yield CompilerOption + ("staticlink", tagFile, + OptionString (fun s -> tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [s]), None, + Some (FSComp.SR.optsStaticlink())) #if ENABLE_MONO_SUPPORT if runningOnMono then - yield CompilerOption("resident", tagFile, OptionUnit (fun () -> ()), None, - Some (FSComp.SR.optsResident())) + yield CompilerOption + ("resident", tagFile, + OptionUnit (fun () -> ()), None, + Some (FSComp.SR.optsResident())) #endif - yield CompilerOption("pdb", tagString, OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), None, - Some (FSComp.SR.optsPdb())) - yield CompilerOption("highentropyva", tagNone, OptionSwitch (useHighEntropyVASwitch tcConfigB), None, Some (FSComp.SR.optsUseHighEntropyVA())) - yield CompilerOption("subsystemversion", tagString, OptionString (subSystemVersionSwitch tcConfigB), None, Some (FSComp.SR.optsSubSystemVersion())) - yield CompilerOption("quotations-debug", tagNone, OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On), None, Some(FSComp.SR.optsEmitDebugInfoInQuotations())) + + yield CompilerOption + ("pdb", tagString, + OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), None, + Some (FSComp.SR.optsPdb())) + + yield CompilerOption + ("highentropyva", tagNone, + OptionSwitch (useHighEntropyVASwitch tcConfigB), None, + Some (FSComp.SR.optsUseHighEntropyVA())) + + yield CompilerOption + ("subsystemversion", tagString, + OptionString (subSystemVersionSwitch tcConfigB), None, + Some (FSComp.SR.optsSubSystemVersion())) + + yield CompilerOption + ("quotations-debug", tagNone, + OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On), None, + Some(FSComp.SR.optsEmitDebugInfoInQuotations())) + ] // OptionBlock: Internal options (test use only) //-------------------------------------------------- let testFlag tcConfigB = - CompilerOption("test", tagString, OptionString (fun s -> - match s with - | "StackSpan" -> tcConfigB.internalTestSpanStackReferring <- true - | "ErrorRanges" -> tcConfigB.errorStyle <- ErrorStyle.TestErrors - | "MemberBodyRanges" -> PostTypeCheckSemanticChecks.testFlagMemberBody := true - | "Tracking" -> Lib.tracking := true (* general purpose on/off diagnostics flag *) - | "NoNeedToTailcall" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportNoNeedToTailcall = true } - | "FunctionSizes" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportFunctionSizes = true } - | "TotalSizes" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportTotalSizes = true } - | "HasEffect" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportHasEffect = true } - | "NoErrorText" -> FSComp.SR.SwallowResourceText <- true - | "EmitFeeFeeAs100001" -> tcConfigB.testFlagEmitFeeFeeAs100001 <- true - | "DumpDebugInfo" -> tcConfigB.dumpDebugInfo <- true - | "ShowLoadedAssemblies" -> tcConfigB.showLoadedAssemblies <- true - | "ContinueAfterParseFailure" -> tcConfigB.continueAfterParseFailure <- true - | str -> warning(Error(FSComp.SR.optsUnknownArgumentToTheTestSwitch(str),rangeCmdArgs))), None, - None) + CompilerOption + ("test", tagString, + OptionString (fun s -> + match s with + | "StackSpan" -> tcConfigB.internalTestSpanStackReferring <- true + | "ErrorRanges" -> tcConfigB.errorStyle <- ErrorStyle.TestErrors + | "MemberBodyRanges" -> PostTypeCheckSemanticChecks.testFlagMemberBody := true + | "Tracking" -> Lib.tracking := true (* general purpose on/off diagnostics flag *) + | "NoNeedToTailcall" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportNoNeedToTailcall = true } + | "FunctionSizes" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportFunctionSizes = true } + | "TotalSizes" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportTotalSizes = true } + | "HasEffect" -> tcConfigB.optSettings <- { tcConfigB.optSettings with reportHasEffect = true } + | "NoErrorText" -> FSComp.SR.SwallowResourceText <- true + | "EmitFeeFeeAs100001" -> tcConfigB.testFlagEmitFeeFeeAs100001 <- true + | "DumpDebugInfo" -> tcConfigB.dumpDebugInfo <- true + | "ShowLoadedAssemblies" -> tcConfigB.showLoadedAssemblies <- true + | "ContinueAfterParseFailure" -> tcConfigB.continueAfterParseFailure <- true + | str -> warning(Error(FSComp.SR.optsUnknownArgumentToTheTestSwitch(str),rangeCmdArgs))), None, + None) // Not shown in fsc.exe help, no warning on use, motivation is for use from tooling. let editorSpecificFlags (tcConfigB: TcConfigBuilder) = @@ -862,53 +1009,194 @@ let editorSpecificFlags (tcConfigB: TcConfigBuilder) = let internalFlags (tcConfigB:TcConfigBuilder) = [ - CompilerOption("stamps", tagNone, OptionUnit ignore, Some(InternalCommandLineOption("--stamps", rangeCmdArgs)), None) - CompilerOption("ranges", tagNone, OptionSet Tastops.DebugPrint.layoutRanges, Some(InternalCommandLineOption("--ranges", rangeCmdArgs)), None) - CompilerOption("terms" , tagNone, OptionUnit (fun () -> tcConfigB.showTerms <- true), Some(InternalCommandLineOption("--terms", rangeCmdArgs)), None) - CompilerOption("termsfile" , tagNone, OptionUnit (fun () -> tcConfigB.writeTermsToFiles <- true), Some(InternalCommandLineOption("--termsfile", rangeCmdArgs)), None) + CompilerOption + ("stamps", tagNone, + OptionUnit ignore, + Some(InternalCommandLineOption("--stamps", rangeCmdArgs)), None) + + CompilerOption + ("ranges", tagNone, + OptionSet Tastops.DebugPrint.layoutRanges, + Some(InternalCommandLineOption("--ranges", rangeCmdArgs)), None) + + CompilerOption + ("terms" , tagNone, + OptionUnit (fun () -> tcConfigB.showTerms <- true), + Some(InternalCommandLineOption("--terms", rangeCmdArgs)), None) + + CompilerOption + ("termsfile" , tagNone, + OptionUnit (fun () -> tcConfigB.writeTermsToFiles <- true), + Some(InternalCommandLineOption("--termsfile", rangeCmdArgs)), None) + #if DEBUG - CompilerOption("debug-parse", tagNone, OptionUnit (fun () -> Internal.Utilities.Text.Parsing.Flags.debug <- true), Some(InternalCommandLineOption("--debug-parse", rangeCmdArgs)), None) -#endif - CompilerOption("pause", tagNone, OptionUnit (fun () -> tcConfigB.pause <- true), Some(InternalCommandLineOption("--pause", rangeCmdArgs)), None) - CompilerOption("detuple", tagNone, OptionInt (setFlag (fun v -> tcConfigB.doDetuple <- v)), Some(InternalCommandLineOption("--detuple", rangeCmdArgs)), None) - CompilerOption("simulateException", tagNone, OptionString (fun s -> tcConfigB.simulateException <- Some(s)), Some(InternalCommandLineOption("--simulateException", rangeCmdArgs)), Some "Simulate an exception from some part of the compiler") - CompilerOption("stackReserveSize", tagNone, OptionString (fun s -> tcConfigB.stackReserveSize <- Some(int32 s)), Some(InternalCommandLineOption("--stackReserveSize", rangeCmdArgs)), Some ("for an exe, set stack reserve size")) - CompilerOption("tlr", tagInt, OptionInt (setFlag (fun v -> tcConfigB.doTLR <- v)), Some(InternalCommandLineOption("--tlr", rangeCmdArgs)), None) - CompilerOption("finalSimplify", tagInt, OptionInt (setFlag (fun v -> tcConfigB.doFinalSimplify <- v)), Some(InternalCommandLineOption("--finalSimplify", rangeCmdArgs)), None) -#if TLR_LIFT - CompilerOption("tlrlift", tagNone, OptionInt (setFlag (fun v -> InnerLambdasToTopLevelFuncs.liftTLR := v)), Some(InternalCommandLineOption("--tlrlift", rangeCmdArgs)), None) + CompilerOption + ("debug-parse", tagNone, + OptionUnit (fun () -> Internal.Utilities.Text.Parsing.Flags.debug <- true), + Some(InternalCommandLineOption("--debug-parse", rangeCmdArgs)), None) #endif - CompilerOption("parseonly", tagNone, OptionUnit (fun () -> tcConfigB.parseOnly <- true), Some(InternalCommandLineOption("--parseonly", rangeCmdArgs)), None) - CompilerOption("typecheckonly", tagNone, OptionUnit (fun () -> tcConfigB.typeCheckOnly <- true), Some(InternalCommandLineOption("--typecheckonly", rangeCmdArgs)), None) - CompilerOption("ast", tagNone, OptionUnit (fun () -> tcConfigB.printAst <- true), Some(InternalCommandLineOption("--ast", rangeCmdArgs)), None) - CompilerOption("tokenize", tagNone, OptionUnit (fun () -> tcConfigB.tokenizeOnly <- true), Some(InternalCommandLineOption("--tokenize", rangeCmdArgs)), None) - CompilerOption("testInteractionParser", tagNone, OptionUnit (fun () -> tcConfigB.testInteractionParser <- true), Some(InternalCommandLineOption("--testInteractionParser", rangeCmdArgs)), None) - CompilerOption("testparsererrorrecovery", tagNone, OptionUnit (fun () -> tcConfigB.reportNumDecls <- true), Some(InternalCommandLineOption("--testparsererrorrecovery", rangeCmdArgs)), None) - CompilerOption("inlinethreshold", tagInt, OptionInt (fun n -> tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = n }), Some(InternalCommandLineOption("--inlinethreshold", rangeCmdArgs)), None) - CompilerOption("extraoptimizationloops", tagNone, OptionInt (fun n -> tcConfigB.extraOptimizationIterations <- n), Some(InternalCommandLineOption("--extraoptimizationloops", rangeCmdArgs)), None) - CompilerOption("abortonerror", tagNone, OptionUnit (fun () -> tcConfigB.abortOnError <- true), Some(InternalCommandLineOption("--abortonerror", rangeCmdArgs)), None) - CompilerOption("implicitresolution", tagNone, OptionUnit (fun _ -> tcConfigB.implicitlyResolveAssemblies <- true), Some(InternalCommandLineOption("--implicitresolution", rangeCmdArgs)), None) - - CompilerOption("resolutions", tagNone, OptionUnit (fun () -> tcConfigB.showReferenceResolutions <- true), Some(InternalCommandLineOption("", rangeCmdArgs)), None) // "Display assembly reference resolution information") - CompilerOption("resolutionframeworkregistrybase", tagString, OptionString (fun _ -> ()), Some(InternalCommandLineOption("", rangeCmdArgs)), None) // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\[SOFTWARE\Microsoft\.NETFramework]\v2.0.50727\AssemblyFoldersEx") - CompilerOption("resolutionassemblyfoldersuffix", tagString, OptionString (fun _ -> ()), Some(InternalCommandLineOption("resolutionassemblyfoldersuffix", rangeCmdArgs)), None) // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\[AssemblyFoldersEx]") - CompilerOption("resolutionassemblyfoldersconditions", tagString, OptionString (fun _ -> ()), Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None) // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id") - CompilerOption("msbuildresolution", tagNone, OptionUnit (fun () -> tcConfigB.useSimpleResolution<-false), Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None) // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)") - CompilerOption("alwayscallvirt",tagNone,OptionSwitch(callVirtSwitch tcConfigB),Some(InternalCommandLineOption("alwayscallvirt",rangeCmdArgs)), None) - CompilerOption("nodebugdata",tagNone, OptionUnit (fun () -> tcConfigB.noDebugData<-true),Some(InternalCommandLineOption("--nodebugdata",rangeCmdArgs)), None) + + CompilerOption + ("pause", tagNone, + OptionUnit (fun () -> tcConfigB.pause <- true), + Some(InternalCommandLineOption("--pause", rangeCmdArgs)), None) + + CompilerOption + ("detuple", tagNone, + OptionInt (setFlag (fun v -> tcConfigB.doDetuple <- v)), + Some(InternalCommandLineOption("--detuple", rangeCmdArgs)), None) + + CompilerOption + ("simulateException", tagNone, + OptionString (fun s -> tcConfigB.simulateException <- Some(s)), + Some(InternalCommandLineOption("--simulateException", rangeCmdArgs)), Some "Simulate an exception from some part of the compiler") + + CompilerOption + ("stackReserveSize", tagNone, + OptionString (fun s -> tcConfigB.stackReserveSize <- Some(int32 s)), + Some(InternalCommandLineOption("--stackReserveSize", rangeCmdArgs)), Some ("for an exe, set stack reserve size")) + + CompilerOption + ("tlr", tagInt, + OptionInt (setFlag (fun v -> tcConfigB.doTLR <- v)), + Some(InternalCommandLineOption("--tlr", rangeCmdArgs)), None) + + CompilerOption + ("finalSimplify", tagInt, + OptionInt (setFlag (fun v -> tcConfigB.doFinalSimplify <- v)), + Some(InternalCommandLineOption("--finalSimplify", rangeCmdArgs)), None) + + CompilerOption + ("parseonly", tagNone, + OptionUnit (fun () -> tcConfigB.parseOnly <- true), + Some(InternalCommandLineOption("--parseonly", rangeCmdArgs)), None) + + CompilerOption + ("typecheckonly", tagNone, + OptionUnit (fun () -> tcConfigB.typeCheckOnly <- true), + Some(InternalCommandLineOption("--typecheckonly", rangeCmdArgs)), None) + + CompilerOption + ("ast", tagNone, + OptionUnit (fun () -> tcConfigB.printAst <- true), + Some(InternalCommandLineOption("--ast", rangeCmdArgs)), None) + + CompilerOption + ("tokenize", tagNone, + OptionUnit (fun () -> tcConfigB.tokenizeOnly <- true), + Some(InternalCommandLineOption("--tokenize", rangeCmdArgs)), None) + + CompilerOption + ("testInteractionParser", tagNone, + OptionUnit (fun () -> tcConfigB.testInteractionParser <- true), + Some(InternalCommandLineOption("--testInteractionParser", rangeCmdArgs)), None) + + CompilerOption + ("testparsererrorrecovery", tagNone, + OptionUnit (fun () -> tcConfigB.reportNumDecls <- true), + Some(InternalCommandLineOption("--testparsererrorrecovery", rangeCmdArgs)), None) + + CompilerOption + ("inlinethreshold", tagInt, + OptionInt (fun n -> tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = n }), + Some(InternalCommandLineOption("--inlinethreshold", rangeCmdArgs)), None) + + CompilerOption + ("extraoptimizationloops", tagNone, + OptionInt (fun n -> tcConfigB.extraOptimizationIterations <- n), + Some(InternalCommandLineOption("--extraoptimizationloops", rangeCmdArgs)), None) + + CompilerOption + ("abortonerror", tagNone, + OptionUnit (fun () -> tcConfigB.abortOnError <- true), + Some(InternalCommandLineOption("--abortonerror", rangeCmdArgs)), None) + + CompilerOption + ("implicitresolution", tagNone, + OptionUnit (fun _ -> tcConfigB.implicitlyResolveAssemblies <- true), + Some(InternalCommandLineOption("--implicitresolution", rangeCmdArgs)), None) + + // "Display assembly reference resolution information") + CompilerOption + ("resolutions", tagNone, + OptionUnit (fun () -> tcConfigB.showReferenceResolutions <- true), + Some(InternalCommandLineOption("", rangeCmdArgs)), None) + + // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\[SOFTWARE\Microsoft\.NETFramework]\v2.0.50727\AssemblyFoldersEx") + CompilerOption + ("resolutionframeworkregistrybase", tagString, + OptionString (fun _ -> ()), + Some(InternalCommandLineOption("", rangeCmdArgs)), None) + + // "The base registry key to use for assembly resolution. This part in brackets here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\[AssemblyFoldersEx]") + CompilerOption + ("resolutionassemblyfoldersuffix", tagString, + OptionString (fun _ -> ()), + Some(InternalCommandLineOption("resolutionassemblyfoldersuffix", rangeCmdArgs)), None) + + // "Additional reference resolution conditions. For example \"OSVersion=5.1.2600.0,PlatformID=id") + CompilerOption + ("resolutionassemblyfoldersconditions", tagString, + OptionString (fun _ -> ()), + Some(InternalCommandLineOption("resolutionassemblyfoldersconditions", rangeCmdArgs)), None) + + // "Resolve assembly references using MSBuild resolution rules rather than directory based (Default=true except when running fsc.exe under mono)") + CompilerOption + ("msbuildresolution", tagNone, + OptionUnit (fun () -> tcConfigB.useSimpleResolution<-false), + Some(InternalCommandLineOption("msbuildresolution", rangeCmdArgs)), None) + + CompilerOption + ("alwayscallvirt",tagNone, + OptionSwitch(callVirtSwitch tcConfigB), + Some(InternalCommandLineOption("alwayscallvirt",rangeCmdArgs)), None) + + CompilerOption + ("nodebugdata",tagNone, + OptionUnit (fun () -> tcConfigB.noDebugData<-true), + Some(InternalCommandLineOption("--nodebugdata",rangeCmdArgs)), None) + testFlag tcConfigB ] @ + editorSpecificFlags tcConfigB @ - [ CompilerOption("jit", tagNone, OptionSwitch (jitoptimizeSwitch tcConfigB), Some(InternalCommandLineOption("jit", rangeCmdArgs)), None) - CompilerOption("localoptimize", tagNone, OptionSwitch(localoptimizeSwitch tcConfigB),Some(InternalCommandLineOption("localoptimize", rangeCmdArgs)), None) - CompilerOption("splitting", tagNone, OptionSwitch(splittingSwitch tcConfigB),Some(InternalCommandLineOption("splitting", rangeCmdArgs)), None) - CompilerOption("versionfile", tagString, OptionString (fun s -> tcConfigB.version <- VersionFile s), Some(InternalCommandLineOption("versionfile", rangeCmdArgs)), None) - CompilerOption("times" , tagNone, OptionUnit (fun () -> tcConfigB.showTimes <- true), Some(InternalCommandLineOption("times", rangeCmdArgs)), None) // "Display timing profiles for compilation") + [ CompilerOption + ("jit", tagNone, + OptionSwitch (jitoptimizeSwitch tcConfigB), + Some(InternalCommandLineOption("jit", rangeCmdArgs)), None) + + CompilerOption + ("localoptimize", tagNone, + OptionSwitch(localoptimizeSwitch tcConfigB), + Some(InternalCommandLineOption("localoptimize", rangeCmdArgs)), None) + + CompilerOption + ("splitting", tagNone, + OptionSwitch(splittingSwitch tcConfigB), + Some(InternalCommandLineOption("splitting", rangeCmdArgs)), None) + + CompilerOption + ("versionfile", tagString, + OptionString (fun s -> tcConfigB.version <- VersionFile s), + Some(InternalCommandLineOption("versionfile", rangeCmdArgs)), None) + + // "Display timing profiles for compilation" + CompilerOption + ("times" , tagNone, + OptionUnit (fun () -> tcConfigB.showTimes <- true), + Some(InternalCommandLineOption("times", rangeCmdArgs)), None) + #if !NO_EXTENSIONTYPING - CompilerOption("showextensionresolution" , tagNone, OptionUnit (fun () -> tcConfigB.showExtensionTypeMessages <- true), Some(InternalCommandLineOption("showextensionresolution", rangeCmdArgs)), None) // "Display information about extension type resolution") + // "Display information about extension type resolution") + CompilerOption + ("showextensionresolution" , tagNone, + OptionUnit (fun () -> tcConfigB.showExtensionTypeMessages <- true), + Some(InternalCommandLineOption("showextensionresolution", rangeCmdArgs)), None) #endif - (* BEGIN: Consider as public Retail option? *) - // Some System.Console do not have operational colors, make this available in Retail? - CompilerOption("metadataversion", tagString, OptionString (fun s -> tcConfigB.metadataVersion <- Some(s)), Some(InternalCommandLineOption("metadataversion", rangeCmdArgs)), None) + + CompilerOption + ("metadataversion", tagString, + OptionString (fun s -> tcConfigB.metadataVersion <- Some(s)), + Some(InternalCommandLineOption("metadataversion", rangeCmdArgs)), None) ] @@ -916,61 +1204,166 @@ let internalFlags (tcConfigB:TcConfigBuilder) = //-------------------------------------------------- let compilingFsLibFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("compiling-fslib", tagNone, OptionUnit (fun () -> tcConfigB.compilingFslib <- true - tcConfigB.TurnWarningOff(rangeStartup,"42") - ErrorLogger.reportLibraryOnlyFeatures <- false - IlxSettings.ilxCompilingFSharpCoreLib := true), Some(InternalCommandLineOption("--compiling-fslib", rangeCmdArgs)), None) + CompilerOption + ("compiling-fslib", tagNone, + OptionUnit (fun () -> + tcConfigB.compilingFslib <- true + tcConfigB.TurnWarningOff(rangeStartup,"42") + ErrorLogger.reportLibraryOnlyFeatures <- false + IlxSettings.ilxCompilingFSharpCoreLib := true), + Some(InternalCommandLineOption("--compiling-fslib", rangeCmdArgs)), None) + let compilingFsLib20Flag (tcConfigB : TcConfigBuilder) = - CompilerOption("compiling-fslib-20", tagNone, OptionString (fun s -> tcConfigB.compilingFslib20 <- Some s ), Some(InternalCommandLineOption("--compiling-fslib-20", rangeCmdArgs)), None) + CompilerOption + ("compiling-fslib-20", tagNone, + OptionString (fun s -> tcConfigB.compilingFslib20 <- Some s ), + Some(InternalCommandLineOption("--compiling-fslib-20", rangeCmdArgs)), None) + let compilingFsLib40Flag (tcConfigB : TcConfigBuilder) = - CompilerOption("compiling-fslib-40", tagNone, OptionUnit (fun () -> tcConfigB.compilingFslib40 <- true ), Some(InternalCommandLineOption("--compiling-fslib-40", rangeCmdArgs)), None) + CompilerOption + ("compiling-fslib-40", tagNone, + OptionUnit (fun () -> tcConfigB.compilingFslib40 <- true ), + Some(InternalCommandLineOption("--compiling-fslib-40", rangeCmdArgs)), None) + let compilingFsLibNoBigIntFlag (tcConfigB : TcConfigBuilder) = - CompilerOption("compiling-fslib-nobigint", tagNone, OptionUnit (fun () -> tcConfigB.compilingFslibNoBigInt <- true ), Some(InternalCommandLineOption("--compiling-fslib-nobigint", rangeCmdArgs)), None) + CompilerOption + ("compiling-fslib-nobigint", tagNone, + OptionUnit (fun () -> tcConfigB.compilingFslibNoBigInt <- true ), + Some(InternalCommandLineOption("--compiling-fslib-nobigint", rangeCmdArgs)), None) let mlKeywordsFlag = - CompilerOption("ml-keywords", tagNone, OptionUnit (fun () -> ()), Some(DeprecatedCommandLineOptionNoDescription("--ml-keywords", rangeCmdArgs)), None) + CompilerOption + ("ml-keywords", tagNone, + OptionUnit (fun () -> ()), + Some(DeprecatedCommandLineOptionNoDescription("--ml-keywords", rangeCmdArgs)), None) let gnuStyleErrorsFlag tcConfigB = - CompilerOption("gnu-style-errors", tagNone, OptionUnit (fun () -> tcConfigB.errorStyle <- ErrorStyle.EmacsErrors), Some(DeprecatedCommandLineOptionNoDescription("--gnu-style-errors", rangeCmdArgs)), None) + CompilerOption + ("gnu-style-errors", tagNone, + OptionUnit (fun () -> tcConfigB.errorStyle <- ErrorStyle.EmacsErrors), + Some(DeprecatedCommandLineOptionNoDescription("--gnu-style-errors", rangeCmdArgs)), None) let deprecatedFlagsBoth tcConfigB = [ - CompilerOption("light", tagNone, OptionUnit (fun () -> tcConfigB.light <- Some(true)), Some(DeprecatedCommandLineOptionNoDescription("--light", rangeCmdArgs)), None) - CompilerOption("indentation-syntax", tagNone, OptionUnit (fun () -> tcConfigB.light <- Some(true)), Some(DeprecatedCommandLineOptionNoDescription("--indentation-syntax", rangeCmdArgs)), None) - CompilerOption("no-indentation-syntax", tagNone, OptionUnit (fun () -> tcConfigB.light <- Some(false)), Some(DeprecatedCommandLineOptionNoDescription("--no-indentation-syntax", rangeCmdArgs)), None) + CompilerOption + ("light", tagNone, + OptionUnit (fun () -> tcConfigB.light <- Some(true)), + Some(DeprecatedCommandLineOptionNoDescription("--light", rangeCmdArgs)), None) + + CompilerOption + ("indentation-syntax", tagNone, + OptionUnit (fun () -> tcConfigB.light <- Some(true)), + Some(DeprecatedCommandLineOptionNoDescription("--indentation-syntax", rangeCmdArgs)), None) + + CompilerOption + ("no-indentation-syntax", tagNone, + OptionUnit (fun () -> tcConfigB.light <- Some(false)), + Some(DeprecatedCommandLineOptionNoDescription("--no-indentation-syntax", rangeCmdArgs)), None) ] let deprecatedFlagsFsi tcConfigB = deprecatedFlagsBoth tcConfigB + let deprecatedFlagsFsc tcConfigB = deprecatedFlagsBoth tcConfigB @ [ cliRootFlag tcConfigB - CompilerOption("jit-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some true }), Some(DeprecatedCommandLineOptionNoDescription("--jit-optimize", rangeCmdArgs)), None) - CompilerOption("no-jit-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some false }), Some(DeprecatedCommandLineOptionNoDescription("--no-jit-optimize", rangeCmdArgs)), None) - CompilerOption("jit-tracking", tagNone, OptionUnit (fun _ -> (tcConfigB.jitTracking <- true) ), Some(DeprecatedCommandLineOptionNoDescription("--jit-tracking", rangeCmdArgs)), None) - CompilerOption("no-jit-tracking", tagNone, OptionUnit (fun _ -> (tcConfigB.jitTracking <- false) ), Some(DeprecatedCommandLineOptionNoDescription("--no-jit-tracking", rangeCmdArgs)), None) - CompilerOption("progress", tagNone, OptionUnit (fun () -> progress := true), Some(DeprecatedCommandLineOptionNoDescription("--progress", rangeCmdArgs)), None) - (compilingFsLibFlag tcConfigB) - (compilingFsLib20Flag tcConfigB) - (compilingFsLib40Flag tcConfigB) - (compilingFsLibNoBigIntFlag tcConfigB) - CompilerOption("version", tagString, OptionString (fun s -> tcConfigB.version <- VersionString s), Some(DeprecatedCommandLineOptionNoDescription("--version", rangeCmdArgs)), None) -// "--clr-mscorlib", OptionString (fun s -> warning(Some(DeprecatedCommandLineOptionNoDescription("--clr-mscorlib", rangeCmdArgs))) tcConfigB.Build.mscorlib_assembly_name <- s), "\n\tThe name of mscorlib on the target CLR" - CompilerOption("local-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true }), Some(DeprecatedCommandLineOptionNoDescription("--local-optimize", rangeCmdArgs)), None) - CompilerOption("no-local-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some false }), Some(DeprecatedCommandLineOptionNoDescription("--no-local-optimize", rangeCmdArgs)), None) - CompilerOption("cross-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some true }), Some(DeprecatedCommandLineOptionNoDescription("--cross-optimize", rangeCmdArgs)), None) - CompilerOption("no-cross-optimize", tagNone, OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some false }), Some(DeprecatedCommandLineOptionNoDescription("--no-cross-optimize", rangeCmdArgs)), None) - CompilerOption("no-string-interning", tagNone, OptionUnit (fun () -> tcConfigB.internConstantStrings <- false), Some(DeprecatedCommandLineOptionNoDescription("--no-string-interning", rangeCmdArgs)), None) - CompilerOption("statistics", tagNone, OptionUnit (fun () -> tcConfigB.stats <- true), Some(DeprecatedCommandLineOptionNoDescription("--statistics", rangeCmdArgs)), None) - CompilerOption("generate-filter-blocks", tagNone, OptionUnit (fun () -> tcConfigB.generateFilterBlocks <- true), Some(DeprecatedCommandLineOptionNoDescription("--generate-filter-blocks", rangeCmdArgs)), None) - //CompilerOption("no-generate-filter-blocks", tagNone, OptionUnit (fun () -> tcConfigB.generateFilterBlocks <- false), Some(DeprecatedCommandLineOptionNoDescription("--generate-filter-blocks", rangeCmdArgs)), None) - CompilerOption("max-errors", tagInt, OptionInt (fun n -> tcConfigB.maxErrors <- n), Some(DeprecatedCommandLineOptionSuggestAlternative("--max-errors", "--maxerrors", rangeCmdArgs)),None) - CompilerOption("debug-file", tagNone, OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), Some(DeprecatedCommandLineOptionSuggestAlternative("--debug-file", "--pdb", rangeCmdArgs)), None) - CompilerOption("no-debug-file", tagNone, OptionUnit (fun () -> tcConfigB.debuginfo <- false), Some(DeprecatedCommandLineOptionSuggestAlternative("--no-debug-file", "--debug-", rangeCmdArgs)), None) - CompilerOption("Ooff", tagNone, OptionUnit (fun () -> SetOptimizeOff(tcConfigB)), Some(DeprecatedCommandLineOptionSuggestAlternative("-Ooff", "--optimize-", rangeCmdArgs)), None) + CompilerOption + ("jit-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some true }), + Some(DeprecatedCommandLineOptionNoDescription("--jit-optimize", rangeCmdArgs)), None) + + CompilerOption + ("no-jit-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some false }), + Some(DeprecatedCommandLineOptionNoDescription("--no-jit-optimize", rangeCmdArgs)), None) + + CompilerOption + ("jit-tracking", tagNone, + OptionUnit (fun _ -> (tcConfigB.jitTracking <- true) ), + Some(DeprecatedCommandLineOptionNoDescription("--jit-tracking", rangeCmdArgs)), None) + + CompilerOption + ("no-jit-tracking", tagNone, + OptionUnit (fun _ -> (tcConfigB.jitTracking <- false) ), + Some(DeprecatedCommandLineOptionNoDescription("--no-jit-tracking", rangeCmdArgs)), None) + + CompilerOption + ("progress", tagNone, + OptionUnit (fun () -> progress := true), + Some(DeprecatedCommandLineOptionNoDescription("--progress", rangeCmdArgs)), None) + + compilingFsLibFlag tcConfigB + compilingFsLib20Flag tcConfigB + compilingFsLib40Flag tcConfigB + compilingFsLibNoBigIntFlag tcConfigB + + CompilerOption + ("version", tagString, + OptionString (fun s -> tcConfigB.version <- VersionString s), + Some(DeprecatedCommandLineOptionNoDescription("--version", rangeCmdArgs)), None) + + CompilerOption + ("local-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true }), + Some(DeprecatedCommandLineOptionNoDescription("--local-optimize", rangeCmdArgs)), None) + + CompilerOption + ("no-local-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some false }), + Some(DeprecatedCommandLineOptionNoDescription("--no-local-optimize", rangeCmdArgs)), None) + + CompilerOption + ("cross-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some true }), + Some(DeprecatedCommandLineOptionNoDescription("--cross-optimize", rangeCmdArgs)), None) + + CompilerOption + ("no-cross-optimize", tagNone, + OptionUnit (fun _ -> tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some false }), + Some(DeprecatedCommandLineOptionNoDescription("--no-cross-optimize", rangeCmdArgs)), None) + + CompilerOption + ("no-string-interning", tagNone, + OptionUnit (fun () -> tcConfigB.internConstantStrings <- false), + Some(DeprecatedCommandLineOptionNoDescription("--no-string-interning", rangeCmdArgs)), None) + + CompilerOption + ("statistics", tagNone, + OptionUnit (fun () -> tcConfigB.stats <- true), + Some(DeprecatedCommandLineOptionNoDescription("--statistics", rangeCmdArgs)), None) + + CompilerOption + ("generate-filter-blocks", tagNone, + OptionUnit (fun () -> tcConfigB.generateFilterBlocks <- true), + Some(DeprecatedCommandLineOptionNoDescription("--generate-filter-blocks", rangeCmdArgs)), None) + + //CompilerOption + // ("no-generate-filter-blocks", tagNone, + // OptionUnit (fun () -> tcConfigB.generateFilterBlocks <- false), + // Some(DeprecatedCommandLineOptionNoDescription("--generate-filter-blocks", rangeCmdArgs)), None) + + CompilerOption + ("max-errors", tagInt, + OptionInt (fun n -> tcConfigB.maxErrors <- n), + Some(DeprecatedCommandLineOptionSuggestAlternative("--max-errors", "--maxerrors", rangeCmdArgs)),None) + + CompilerOption + ("debug-file", tagNone, + OptionString (fun s -> tcConfigB.debugSymbolFile <- Some s), + Some(DeprecatedCommandLineOptionSuggestAlternative("--debug-file", "--pdb", rangeCmdArgs)), None) + + CompilerOption + ("no-debug-file", tagNone, + OptionUnit (fun () -> tcConfigB.debuginfo <- false), + Some(DeprecatedCommandLineOptionSuggestAlternative("--no-debug-file", "--debug-", rangeCmdArgs)), None) + + CompilerOption + ("Ooff", tagNone, + OptionUnit (fun () -> SetOptimizeOff(tcConfigB)), + Some(DeprecatedCommandLineOptionSuggestAlternative("-Ooff", "--optimize-", rangeCmdArgs)), None) + mlKeywordsFlag - gnuStyleErrorsFlag tcConfigB - ] + gnuStyleErrorsFlag tcConfigB ] // OptionBlock: Miscellaneous options @@ -1014,15 +1407,35 @@ let abbreviatedFlagsBoth tcConfigB = ] let abbreviatedFlagsFsi tcConfigB = abbreviatedFlagsBoth tcConfigB + let abbreviatedFlagsFsc tcConfigB = abbreviatedFlagsBoth tcConfigB @ - [ (* FSC only abbreviated options *) - CompilerOption("o", tagString, OptionString (setOutFileName tcConfigB), None, Some(FSComp.SR.optsShortFormOf("--out"))) - CompilerOption("a", tagString, OptionUnit (fun () -> tcConfigB.target <- CompilerTarget.Dll), None, Some(FSComp.SR.optsShortFormOf("--target library"))) - (* FSC help abbreviations. FSI has it's own help options... *) - CompilerOption("?" , tagNone, OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, Some(FSComp.SR.optsShortFormOf("--help"))) - CompilerOption("help" , tagNone, OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, Some(FSComp.SR.optsShortFormOf("--help"))) - CompilerOption("full-help", tagNone, OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, Some(FSComp.SR.optsShortFormOf("--help"))) + [ // FSC only abbreviated options + CompilerOption + ("o", tagString, + OptionString (setOutFileName tcConfigB), None, + Some(FSComp.SR.optsShortFormOf("--out"))) + + CompilerOption + ("a", tagString, + OptionUnit (fun () -> tcConfigB.target <- CompilerTarget.Dll), None, + Some(FSComp.SR.optsShortFormOf("--target library"))) + + // FSC help abbreviations. FSI has it's own help options... + CompilerOption + ("?" , tagNone, + OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, + Some(FSComp.SR.optsShortFormOf("--help"))) + + CompilerOption + ("help" , tagNone, + OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, + Some(FSComp.SR.optsShortFormOf("--help"))) + + CompilerOption + ("full-help", tagNone, + OptionHelp (fun blocks -> displayHelpFsc tcConfigB blocks), None, + Some(FSComp.SR.optsShortFormOf("--help"))) ] let GetAbbrevFlagSet tcConfigB isFsc = @@ -1057,7 +1470,10 @@ let PostProcessCompilerArgs (abbrevArgs : string Set) (args : string []) = let testingAndQAFlags _tcConfigB = [ - CompilerOption("dumpAllCommandLineOptions", tagNone, OptionHelp(fun blocks -> DumpCompilerOptionBlocks blocks), None, None) // "Command line options") + CompilerOption + ("dumpAllCommandLineOptions", tagNone, + OptionHelp(fun blocks -> DumpCompilerOptionBlocks blocks), + None, None) // "Command line options") ] @@ -1258,8 +1674,11 @@ let ApplyAllOptimizations (tcConfig:TcConfig, tcGlobals, tcVal, outfile, importM // want to save in the x-module info (i.e. x-module info is currently "high level"). PrintWholeAssemblyImplementation tcConfig outfile "pass-start" implFiles #if DEBUG - if tcConfig.showOptimizationData then dprintf "Expression prior to optimization:\n%s\n" (Layout.showL (Layout.squashTo 192 (DebugPrint.implFilesL implFiles))) - if tcConfig.showOptimizationData then dprintf "CCU prior to optimization:\n%s\n" (Layout.showL (Layout.squashTo 192 (DebugPrint.entityL ccu.Contents))) + if tcConfig.showOptimizationData then + dprintf "Expression prior to optimization:\n%s\n" (Layout.showL (Layout.squashTo 192 (DebugPrint.implFilesL implFiles))) + + if tcConfig.showOptimizationData then + dprintf "CCU prior to optimization:\n%s\n" (Layout.showL (Layout.squashTo 192 (DebugPrint.entityL ccu.Contents))) #endif let optEnv0 = optEnv @@ -1271,24 +1690,36 @@ let ApplyAllOptimizations (tcConfig:TcConfig, tcGlobals, tcVal, outfile, importM let optSettings = { optSettings with reportingPhase = true } let results,(optEnvFirstLoop,_,_,_) = - ((optEnv0,optEnv0,optEnv0,SignatureHidingInfo.Empty),implFiles) ||> List.mapFold (fun (optEnvFirstLoop,optEnvExtraLoop,optEnvFinalSimplify,hidden) implFile -> + ((optEnv0,optEnv0,optEnv0,SignatureHidingInfo.Empty),implFiles) + + ||> List.mapFold (fun (optEnvFirstLoop,optEnvExtraLoop,optEnvFinalSimplify,hidden) implFile -> //ReportTime tcConfig ("Initial simplify") let (optEnvFirstLoop,implFile,implFileOptData,hidden), optimizeDuringCodeGen = - Optimizer.OptimizeImplFile(optSettings,ccu,tcGlobals,tcVal,importMap,optEnvFirstLoop,isIncrementalFragment,tcConfig.emitTailcalls,hidden,implFile) + Optimizer.OptimizeImplFile + (optSettings,ccu,tcGlobals,tcVal,importMap, + optEnvFirstLoop,isIncrementalFragment, + tcConfig.emitTailcalls,hidden,implFile) let implFile = AutoBox.TransformImplFile tcGlobals importMap implFile // Only do this on the first pass! let optSettings = { optSettings with abstractBigTargets = false; reportingPhase = false } #if DEBUG - if tcConfig.showOptimizationData then dprintf "Optimization implFileOptData:\n%s\n" (Layout.showL (Layout.squashTo 192 (Optimizer.moduleInfoL tcGlobals implFileOptData))) + if tcConfig.showOptimizationData then + dprintf "Optimization implFileOptData:\n%s\n" (Layout.showL (Layout.squashTo 192 (Optimizer.moduleInfoL tcGlobals implFileOptData))) #endif let implFile,optEnvExtraLoop = if tcConfig.extraOptimizationIterations > 0 then + //ReportTime tcConfig ("Extra simplification loop") - let (optEnvExtraLoop,implFile, _, _), _ = Optimizer.OptimizeImplFile(optSettings,ccu,tcGlobals,tcVal, importMap,optEnvExtraLoop,isIncrementalFragment,tcConfig.emitTailcalls,hidden,implFile) + let (optEnvExtraLoop,implFile, _, _), _ = + Optimizer.OptimizeImplFile + (optSettings,ccu,tcGlobals,tcVal, importMap, + optEnvExtraLoop,isIncrementalFragment, + tcConfig.emitTailcalls,hidden,implFile) + //PrintWholeAssemblyImplementation tcConfig outfile (sprintf "extra-loop-%d" n) implFile implFile,optEnvExtraLoop else @@ -1312,8 +1743,13 @@ let ApplyAllOptimizations (tcConfig:TcConfig, tcGlobals, tcVal, outfile, importM let implFile,optEnvFinalSimplify = if tcConfig.doFinalSimplify then + //ReportTime tcConfig ("Final simplify pass") - let (optEnvFinalSimplify,implFile, _, _),_ = Optimizer.OptimizeImplFile(optSettings,ccu,tcGlobals,tcVal, importMap,optEnvFinalSimplify,isIncrementalFragment,tcConfig.emitTailcalls,hidden,implFile) + let (optEnvFinalSimplify,implFile, _, _),_ = + Optimizer.OptimizeImplFile + (optSettings,ccu,tcGlobals,tcVal, importMap,optEnvFinalSimplify, + isIncrementalFragment,tcConfig.emitTailcalls,hidden,implFile) + //PrintWholeAssemblyImplementation tcConfig outfile "post-rec-opt" implFile implFile,optEnvFinalSimplify else @@ -1340,8 +1776,16 @@ let CreateIlxAssemblyGenerator (_tcConfig:TcConfig,tcImports:TcImports,tcGlobals ilxGenerator.AddExternalCcus ccus ilxGenerator -let GenerateIlxCode (ilxBackend, isInteractiveItExpr, isInteractiveOnMono, tcConfig:TcConfig, topAttrs, optimizedImpls, fragName, ilxGenerator : IlxAssemblyGenerator) = - if !progress then dprintf "Generating ILX code...\n" +let GenerateIlxCode + (ilxBackend, isInteractiveItExpr, isInteractiveOnMono, + tcConfig:TcConfig, topAttrs: TypeChecker.TopAttribs, optimizedImpls, + fragName, ilxGenerator: IlxAssemblyGenerator) = + + let mainMethodInfo = + if (tcConfig.target = CompilerTarget.Dll) || (tcConfig.target = CompilerTarget.Module) then + None + else Some topAttrs.mainMethodAttrs + let ilxGenOpts : IlxGenOptions = { generateFilterBlocks = tcConfig.generateFilterBlocks emitConstantArraysUsingStaticDataBlobs = not isInteractiveOnMono @@ -1350,7 +1794,7 @@ let GenerateIlxCode (ilxBackend, isInteractiveItExpr, isInteractiveOnMono, tcCon fragName = fragName localOptimizationsAreOn= tcConfig.optSettings.localOpt () testFlagEmitFeeFeeAs100001 = tcConfig.testFlagEmitFeeFeeAs100001 - mainMethodInfo= (if (tcConfig.target = CompilerTarget.Dll || tcConfig.target = CompilerTarget.Module) then None else Some topAttrs.mainMethodAttrs) + mainMethodInfo= mainMethodInfo ilxBackend = ilxBackend isInteractive = tcConfig.isInteractive isInteractiveItExpr = isInteractiveItExpr diff --git a/src/fsharp/CompileOptions.fsi b/src/fsharp/CompileOptions.fsi index 50e7a3acef..e6e010bff2 100644 --- a/src/fsharp/CompileOptions.fsi +++ b/src/fsharp/CompileOptions.fsi @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.CompileOptions - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Optimizer -open Microsoft.FSharp.Compiler.TcGlobals +module internal FSharp.Compiler.CompileOptions + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.CompileOps +open FSharp.Compiler.Tast +open FSharp.Compiler.Import +open FSharp.Compiler.Optimizer +open FSharp.Compiler.TcGlobals //---------------------------------------------------------------------------- // Compiler Option Parser diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 230474a2e8..0234e608fd 100755 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -30,28 +30,28 @@ //------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.ConstraintSolver +module internal FSharp.Compiler.ConstraintSolver open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.MethodCalls -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.Lib +open FSharp.Compiler.MethodCalls +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range +open FSharp.Compiler.Rational +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations //------------------------------------------------------------------------- // Generate type variables and record them in within the scope of the @@ -75,9 +75,13 @@ let NewNamedInferenceMeasureVar (_m, rigid, var, id) = let NewInferenceMeasurePar () = NewCompGenTypar (TyparKind.Measure, TyparRigidity.Flexible, NoStaticReq, TyparDynamicReq.No, false) let NewErrorTypar () = NewCompGenTypar (TyparKind.Type, TyparRigidity.Flexible, NoStaticReq, TyparDynamicReq.No, true) + let NewErrorMeasureVar () = NewCompGenTypar (TyparKind.Measure, TyparRigidity.Flexible, NoStaticReq, TyparDynamicReq.No, true) + let NewInferenceType () = mkTyparTy (NewTypar (TyparKind.Type, TyparRigidity.Flexible, Typar(compgenId, NoStaticReq, true), false, TyparDynamicReq.No, [], false, false)) + let NewErrorType () = mkTyparTy (NewErrorTypar ()) + let NewErrorMeasure () = Measure.Var (NewErrorMeasureVar ()) let NewByRefKindInferenceType (g: TcGlobals) m = @@ -787,8 +791,12 @@ and SolveAnonInfoEqualsAnonInfo (csenv:ConstraintSolverEnv) m2 (anonInfo1: AnonR (match anonInfo1.Assembly, anonInfo2.Assembly with | ccu1, ccu2 -> if not (ccuEq ccu1 ccu2) then ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdCcuMismatch(ccu1.AssemblyName, ccu2.AssemblyName), csenv.m,m2)) else ResultD () ) ++ (fun () -> - if not (anonInfo1.SortedNames = anonInfo2.SortedNames) then ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdFieldNameMismatch(sprintf "%A" (Array.toList anonInfo1.SortedNames), sprintf "%A" (Array.toList anonInfo2.SortedNames)), csenv.m,m2)) else - ResultD ()) + if not (anonInfo1.SortedNames = anonInfo2.SortedNames) then + let namesText1 = sprintf "%A" (Array.toList anonInfo1.SortedNames) + let namesText2 = sprintf "%A" (Array.toList anonInfo2.SortedNames) + ErrorD (ConstraintSolverError(FSComp.SR.tcAnonRecdFieldNameMismatch(namesText1, namesText2), csenv.m,m2)) + else + ResultD ()) /// Add the constraint "ty1 = ty2" to the constraint problem. /// Propagate all effects of adding this constraint, e.g. to solve type variables @@ -1004,10 +1012,22 @@ and SolveDimensionlessNumericType (csenv:ConstraintSolverEnv) ndeep m2 trace ty | None -> CompleteD -/// We do a bunch of fakery to pretend that primitive types have certain members. -/// We pretend int and other types support a number of operators. In the actual IL for mscorlib they -/// don't, however the type-directed static optimization rules in the library code that makes use of this -/// will deal with the problem. +/// Attempt to solve a statically resolved member constraint. +/// +/// 1. We do a bunch of fakery to pretend that primitive types have certain members. +/// We pretend int and other types support a number of operators. In the actual IL for mscorlib they +/// don't. The type-directed static optimization rules in the library code that makes use of this +/// will deal with the problem. +/// +/// 2. Some additional solutions are forced prior to generalization (permitWeakResolution=true). These are, roughly speaking, rules +/// for binary-operand constraints arising from constructs such as "1.0 + x" where "x" is an unknown type. THe constraint here +/// involves two type parameters - one for the left, and one for the right. The left is already known to be Double. +/// In this situation (and in the absence of other evidence prior to generalization), constraint solving forces an assumption that +/// the right is also Double - this is "weak" because there is only weak evidence for it. +/// +/// permitWeakResolution also applies to resolutions of multi-type-variable constraints via method overloads. Method overloading gets applied even if +/// only one of the two type variables is known +/// and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload permitWeakResolution ndeep m2 trace (TTrait(tys, nm, memFlags, argtys, rty, sln)): OperationResult = trackErrors { // Do not re-solve if already solved if sln.Value.IsSome then return true else @@ -1065,7 +1085,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload p // The rule is triggered by these sorts of inputs when permitWeakResolution=true // float * 'a // 'a * float - // decimal<'u> * 'a <--- + // decimal<'u> * 'a (let checkRuleAppliesInPreferenceToMethods argty1 argty2 = // Check that at least one of the argument types is numeric (IsNumericOrIntegralEnumType g argty1) && @@ -1314,7 +1334,7 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload p // Now check if there are no feasible solutions at all match minfos, recdPropSearch, anonRecdPropSearch with - | [], None, None when not (tys |> List.exists (isAnyParTy g)) -> + | [], None, None when MemberConstraintIsReadyForStrongResolution csenv traitInfo -> if tys |> List.exists (isFunTy g) then return! ErrorD (ConstraintSolverError(FSComp.SR.csExpectTypeWithOperatorButGivenFunction(DecompileOpName nm), m, m2)) elif tys |> List.exists (isAnyTupleTy g) then @@ -1387,14 +1407,21 @@ and SolveMemberConstraint (csenv:ConstraintSolverEnv) ignoreUnresolvedOverload p | _ -> let support = GetSupportOfMemberConstraint csenv traitInfo let frees = GetFreeTyparsOfMemberConstraint csenv traitInfo - // If there's nothing left to learn then raise the errors - if (permitWeakResolution && isNil support) || isNil frees then do! errors + + // If there's nothing left to learn then raise the errors. + // Note: we should likely call MemberConstraintIsReadyForResolution here when permitWeakResolution=false but for stability + // reasons we use the more restrictive isNil frees. + if (permitWeakResolution && MemberConstraintIsReadyForWeakResolution csenv traitInfo) || isNil frees then + do! errors // Otherwise re-record the trait waiting for canonicalization - else do! AddMemberConstraint csenv ndeep m2 trace traitInfo support frees - return! - match errors with - | ErrorResult (_, UnresolvedOverloading _) when not ignoreUnresolvedOverload && (not (nm = "op_Explicit" || nm = "op_Implicit")) -> ErrorD LocallyAbortOperationThatFailsToResolveOverload - | _ -> ResultD TTraitUnsolved + else + do! AddMemberConstraint csenv ndeep m2 trace traitInfo support frees + + match errors with + | ErrorResult (_, UnresolvedOverloading _) when not ignoreUnresolvedOverload && (not (nm = "op_Explicit" || nm = "op_Implicit")) -> + return! ErrorD LocallyAbortOperationThatFailsToResolveOverload + | _ -> + return TTraitUnsolved } return! RecordMemberConstraintSolution csenv.SolverState m trace traitInfo res } @@ -1475,7 +1502,7 @@ and TransactMemberConstraintSolution traitInfo (trace:OptionalTrace) sln = /// That is, don't perform resolution if more nominal information may influence the set of available overloads and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution nm (TTrait(tys, _, memFlags, argtys, rty, soln) as traitInfo): MethInfo list = let results = - if permitWeakResolution || isNil (GetSupportOfMemberConstraint csenv traitInfo) then + if permitWeakResolution || MemberConstraintSupportIsReadyForDeterminingOverloads csenv traitInfo then let m = csenv.m let minfos = match memFlags.MemberKind with @@ -1483,13 +1510,9 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution tys |> List.map (GetIntrinsicConstructorInfosOfType csenv.SolverState.InfoReader m) | _ -> tys |> List.map (GetIntrinsicMethInfosOfType csenv.SolverState.InfoReader (Some nm, AccessibleFromSomeFSharpCode, AllowMultiIntfInstantiations.Yes) IgnoreOverrides m) - /// Merge the sets so we don't get the same minfo from each side - /// We merge based on whether minfos use identical metadata or not. - /// REVIEW: Consider the pathological cases where this may cause a loss of distinction - /// between potential overloads because a generic instantiation derived from the left hand type differs - /// to a generic instantiation for an operator based on the right hand type. - + // Merge the sets so we don't get the same minfo from each side + // We merge based on whether minfos use identical metadata or not. let minfos = List.reduce (ListSet.unionFavourLeft MethInfo.MethInfosUseIdenticalDefinitions) minfos /// Check that the available members aren't hiding a member from the parent (depth 1 only) @@ -1503,7 +1526,7 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution [] // The trait name "op_Explicit" also covers "op_Implicit", so look for that one too. if nm = "op_Explicit" then - results @ GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution "op_Implicit" (TTrait(tys, "op_Implicit", memFlags, argtys, rty, soln)) + results @ GetRelevantMethodsForTrait csenv permitWeakResolution "op_Implicit" (TTrait(tys, "op_Implicit", memFlags, argtys, rty, soln)) else results @@ -1512,10 +1535,28 @@ and GetRelevantMethodsForTrait (csenv:ConstraintSolverEnv) permitWeakResolution and GetSupportOfMemberConstraint (csenv:ConstraintSolverEnv) (TTrait(tys, _, _, _, _, _)) = tys |> List.choose (tryAnyParTyOption csenv.g) -/// All the typars relevant to the member constraint *) +/// Check if the support is fully solved. +and SupportOfMemberConstraintIsFullySolved (csenv:ConstraintSolverEnv) (TTrait(tys, _, _, _, _, _)) = + tys |> List.forall (isAnyParTy csenv.g >> not) + +// This may be relevant to future bug fixes, see https://github.com/Microsoft/visualfsharp/issues/3814 +// /// Check if some part of the support is solved. +// and SupportOfMemberConstraintIsPartiallySolved (csenv:ConstraintSolverEnv) (TTrait(tys, _, _, _, _, _)) = +// tys |> List.exists (isAnyParTy csenv.g >> not) + +/// Get all the unsolved typars (statically resolved or not) relevant to the member constraint and GetFreeTyparsOfMemberConstraint (csenv:ConstraintSolverEnv) (TTrait(tys, _, _, argtys, rty, _)) = freeInTypesLeftToRightSkippingConstraints csenv.g (tys@argtys@ Option.toList rty) +and MemberConstraintIsReadyForWeakResolution csenv traitInfo = + SupportOfMemberConstraintIsFullySolved csenv traitInfo + +and MemberConstraintIsReadyForStrongResolution csenv traitInfo = + SupportOfMemberConstraintIsFullySolved csenv traitInfo + +and MemberConstraintSupportIsReadyForDeterminingOverloads csenv traitInfo = + SupportOfMemberConstraintIsFullySolved csenv traitInfo + /// Re-solve the global constraints involving any of the given type variables. /// Trait constraints can't always be solved using the pessimistic rules. We only canonicalize /// them forcefully (permitWeakResolution=true) prior to generalization. diff --git a/src/fsharp/ConstraintSolver.fsi b/src/fsharp/ConstraintSolver.fsi index e943d7be69..4626c736bd 100755 --- a/src/fsharp/ConstraintSolver.fsi +++ b/src/fsharp/ConstraintSolver.fsi @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Solves constraints using a mutable constraint-solver state -module internal Microsoft.FSharp.Compiler.ConstraintSolver - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.MethodCalls -open Microsoft.FSharp.Compiler.InfoReader +module internal FSharp.Compiler.ConstraintSolver + +open FSharp.Compiler +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Range +open FSharp.Compiler.Import +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos +open FSharp.Compiler.MethodCalls +open FSharp.Compiler.InfoReader /// Create a type variable representing the use of a "_" in F# code val NewAnonTypar : TyparKind * range * TyparRigidity * TyparStaticReq * TyparDynamicReq -> Typar diff --git a/src/fsharp/DetupleArgs.fs b/src/fsharp/DetupleArgs.fs index 9a7f99e63a..9973e45276 100755 --- a/src/fsharp/DetupleArgs.fs +++ b/src/fsharp/DetupleArgs.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Detuple - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib +module internal FSharp.Compiler.Detuple + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Ast +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib // // This pass has one aim. diff --git a/src/fsharp/DetupleArgs.fsi b/src/fsharp/DetupleArgs.fsi index 5841231582..c76c02b1c4 100755 --- a/src/fsharp/DetupleArgs.fsi +++ b/src/fsharp/DetupleArgs.fsi @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Detuple +module internal FSharp.Compiler.Detuple -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals val DetupleImplFile : CcuThunk -> TcGlobals -> TypedImplFile -> TypedImplFile diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs index 41be3768ed..8c5aa94fc6 100755 --- a/src/fsharp/ErrorLogger.fs +++ b/src/fsharp/ErrorLogger.fs @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.ErrorLogger +module public FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler +open FSharp.Compiler.Range open System //------------------------------------------------------------------------ diff --git a/src/fsharp/ErrorResolutionHints.fs b/src/fsharp/ErrorResolutionHints.fs index 20bcb13fd2..f40dd8f914 100644 --- a/src/fsharp/ErrorResolutionHints.fs +++ b/src/fsharp/ErrorResolutionHints.fs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Functions to format error message details -module internal Microsoft.FSharp.Compiler.ErrorResolutionHints +module internal FSharp.Compiler.ErrorResolutionHints open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library let maxSuggestions = 5 let minThresholdForSuggestions = 0.7 diff --git a/src/fsharp/ExtensionTyping.fs b/src/fsharp/ExtensionTyping.fs index 0d86ca58a0..eda980f5e2 100755 --- a/src/fsharp/ExtensionTyping.fs +++ b/src/fsharp/ExtensionTyping.fs @@ -2,7 +2,7 @@ // Type providers, validation of provided types, etc. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler #if !NO_EXTENSIONTYPING @@ -12,11 +12,11 @@ module internal ExtensionTyping = open System.Collections.Generic open System.Reflection open Microsoft.FSharp.Core.CompilerServices - open Microsoft.FSharp.Compiler.ErrorLogger - open Microsoft.FSharp.Compiler.Range - open Microsoft.FSharp.Compiler.AbstractIL.IL - open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics // dprintfn - open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack + open FSharp.Compiler.ErrorLogger + open FSharp.Compiler.Range + open FSharp.Compiler.AbstractIL.IL + open FSharp.Compiler.AbstractIL.Diagnostics // dprintfn + open FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack #if FX_RESHAPED_REFLECTION open Microsoft.FSharp.Core.ReflectionAdapters diff --git a/src/fsharp/ExtensionTyping.fsi b/src/fsharp/ExtensionTyping.fsi index a16788e2bb..f062717fec 100755 --- a/src/fsharp/ExtensionTyping.fsi +++ b/src/fsharp/ExtensionTyping.fsi @@ -2,7 +2,7 @@ // Extension typing, validation of extension types, etc. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler #if !NO_EXTENSIONTYPING @@ -12,9 +12,9 @@ module internal ExtensionTyping = open System.IO open System.Collections.Generic open Microsoft.FSharp.Core.CompilerServices - open Microsoft.FSharp.Compiler.AbstractIL.IL - open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - open Microsoft.FSharp.Compiler.Range + open FSharp.Compiler.AbstractIL.IL + open FSharp.Compiler.AbstractIL.Internal.Library + open FSharp.Compiler.Range type TypeProviderDesignation = TypeProviderDesignation of string @@ -351,11 +351,11 @@ module internal ExtensionTyping = /// Get the ILTypeRef for the provided type (including for nested types). Take into account /// any type relocations or static linking for generated types. - val GetILTypeRefOfProvidedType : Tainted * range:range -> Microsoft.FSharp.Compiler.AbstractIL.IL.ILTypeRef + val GetILTypeRefOfProvidedType : Tainted * range:range -> FSharp.Compiler.AbstractIL.IL.ILTypeRef /// Get the ILTypeRef for the provided type (including for nested types). Do not take into account /// any type relocations or static linking for generated types. - val GetOriginalILTypeRefOfProvidedType : Tainted * range:range -> Microsoft.FSharp.Compiler.AbstractIL.IL.ILTypeRef + val GetOriginalILTypeRefOfProvidedType : Tainted * range:range -> FSharp.Compiler.AbstractIL.IL.ILTypeRef /// Represents the remapping information for a generated provided type and its nested types. diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index cb5747f3c5..ae91c46ed3 100755 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -44,7 +44,6 @@ buildProductNameCommunity,"F# Compiler for F# %s" 213,buildInvalidAssemblyName,"'%s' is not a valid assembly name" 214,buildInvalidPrivacy,"Unrecognized privacy setting '%s' for managed resource, valid options are 'public' and 'private'" 215,buildMultipleReferencesNotAllowed,"Multiple references to '%s.dll' are not permitted" -buildCouldNotReadVersionInfoFromMscorlib,"Could not read version from mscorlib.dll" 218,buildCannotReadAssembly,"Unable to read assembly '%s'" 220,buildAssemblyResolutionFailed,"Assembly resolution failure at or near this location" 221,buildImplicitModuleIsNotLegalIdentifier,"The declarations in this file will be placed in an implicit module '%s' based on the file name '%s'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file." @@ -1404,7 +1403,7 @@ keywordDescriptionTo,"Used in for loops to indicate a range." keywordDescriptionTry,"Used to introduce a block of code that might generate an exception. Used together with with or finally." keywordDescriptionType,"Used to declare a class, record, structure, discriminated union, enumeration type, unit of measure, or type abbreviation." keywordDescriptionUpcast,"Used to convert to a type that is higher in the inheritance chain." -keywordDescriptionUse,"Used instead of let for values that implement IDisposable"" +keywordDescriptionUse,"Used instead of let for values that implement IDisposable" keywordDescriptionUseBang,"Used instead of let! in computation expressions for computation expression results that implement IDisposable." keywordDescriptionVal,"Used in a signature to indicate a value, or in a type to declare a member, in limited situations." keywordDescriptionVoid,"Indicates the .NET void type. Used when interoperating with other .NET languages." diff --git a/src/fsharp/FindUnsolved.fs b/src/fsharp/FindUnsolved.fs index 9c38f26a2a..386545c7e2 100755 --- a/src/fsharp/FindUnsolved.fs +++ b/src/fsharp/FindUnsolved.fs @@ -2,15 +2,15 @@ /// Find unsolved, uninstantiated type variables -module internal Microsoft.FSharp.Compiler.FindUnsolved - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations +module internal FSharp.Compiler.FindUnsolved + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations type env = Nix diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index d027afabeb..9703dd76b9 100755 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4,7 +4,7 @@ // The ILX generator. //-------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.IlxGen +module internal FSharp.Compiler.IlxGen open System.IO open System.Reflection @@ -13,29 +13,29 @@ open System.Collections.Generic open Internal.Utilities open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.Internal.BinaryConstants - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.Internal.BinaryConstants + +open FSharp.Compiler +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.Import +open FSharp.Compiler.Layout +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations let IsNonErasedTypar (tp:Typar) = not tp.IsErased let DropErasedTypars (tps:Typar list) = tps |> List.filter IsNonErasedTypar @@ -755,9 +755,9 @@ let AddStorageForLocalVals g vals eenv = List.foldBack (fun (v,s) acc -> AddStor // Lookup eenv //-------------------------------------------------------------------------- -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library let StorageForVal m v eenv = let v = @@ -816,12 +816,14 @@ let GetMethodSpecForMemberVal amap g (memberInfo:ValMemberInfo) (vref:ValRef) = let thisTy = if isByrefTy g thisTy then destByrefTy g thisTy else thisTy let thisArgTys = argsOfAppTy g thisTy if numParentTypars <> thisArgTys.Length then - warning(InternalError(sprintf "CodeGen check: type checking did not quantify the correct number of type variables for this method, #parentTypars = %d, #mtps = %d, #thisArgTys = %d" numParentTypars mtps.Length thisArgTys.Length,m)) + let msg = sprintf "CodeGen check: type checking did not quantify the correct number of type variables for this method, #parentTypars = %d, #mtps = %d, #thisArgTys = %d" numParentTypars mtps.Length thisArgTys.Length + warning(InternalError(msg,m)) else List.iter2 (fun gtp ty2 -> if not (typeEquiv g (mkTyparTy gtp) ty2) then - warning(InternalError("CodeGen check: type checking did not quantify the correct type variables for this method: generalization list contained " + gtp.Name + "#" + string gtp.Stamp + " and list from 'this' pointer contained " + (showL(typeL ty2)), m))) + warning(InternalError("CodeGen check: type checking did not quantify the correct type variables for this method: generalization list contained " + + gtp.Name + "#" + string gtp.Stamp + " and list from 'this' pointer contained " + (showL(typeL ty2)), m))) ctps thisArgTys let methodArgTys,paramInfos = List.unzip flatArgInfos @@ -1066,7 +1068,10 @@ let MergeOptions m o1 o2 = | Some x, Some _ -> #if DEBUG // This warning fires on some code that also triggers this warning: - // warning(Error("The implementation of a specified generic interface required a method implementation not fully supported by F# Interactive. In the unlikely event that the resulting class fails to load then compile the interface type into a statically-compiled DLL and reference it using '#r'",m)) + // The implementation of a specified generic interface + // required a method implementation not fully supported by F# Interactive. In + // the unlikely event that the resulting class fails to load then compile + // the interface type into a statically-compiled DLL and reference it using '#r' // The code is OK so we don't print this. errorR(InternalError("MergeOptions: two values given",m)) #else @@ -1497,7 +1502,9 @@ type CodeGenBuffer(m:range, member cgbuf.GetCurrentStack() = stack member cgbuf.AssertEmptyStack() = if not (isNil stack) then - let msg = sprintf "stack flush didn't work, or extraneous expressions left on stack before stack restore, methodName = %s, stack = %+A, m = %s" methodName stack (stringOfRange m) + let msg = + sprintf "stack flush didn't work, or extraneous expressions left on stack before stack restore, methodName = %s, stack = %+A, m = %s" + methodName stack (stringOfRange m) System.Diagnostics.Debug.Assert(false, msg) warning(InternalError(msg,m)) () @@ -2416,16 +2423,36 @@ and GenNewArray cenv cgbuf eenv (elems: Expr list,elemTy,m) sequel = let elems' = Array.ofList elems let test,write = match elems'.[0] with - | Expr.Const(Const.Bool _,_,_) -> (function Const.Bool _ -> true | _ -> false), (fun (buf: ByteBuffer) -> function Const.Bool b -> buf.EmitBoolAsByte b | _ -> failwith "unreachable") - | Expr.Const(Const.Char _,_,_) -> (function Const.Char _ -> true | _ -> false), (fun buf -> function Const.Char b -> buf.EmitInt32AsUInt16 (int b) | _ -> failwith "unreachable") - | Expr.Const(Const.Byte _,_,_) -> (function Const.Byte _ -> true | _ -> false), (fun buf -> function Const.Byte b -> buf.EmitByte b | _ -> failwith "unreachable") - | Expr.Const(Const.UInt16 _,_,_) -> (function Const.UInt16 _ -> true | _ -> false), (fun buf -> function Const.UInt16 b -> buf.EmitUInt16 b | _ -> failwith "unreachable") - | Expr.Const(Const.UInt32 _,_,_) -> (function Const.UInt32 _ -> true | _ -> false), (fun buf -> function Const.UInt32 b -> buf.EmitInt32 (int32 b) | _ -> failwith "unreachable") - | Expr.Const(Const.UInt64 _,_,_) -> (function Const.UInt64 _ -> true | _ -> false), (fun buf -> function Const.UInt64 b -> buf.EmitInt64 (int64 b) | _ -> failwith "unreachable") - | Expr.Const(Const.SByte _,_,_) -> (function Const.SByte _ -> true | _ -> false), (fun buf -> function Const.SByte b -> buf.EmitByte (byte b) | _ -> failwith "unreachable") - | Expr.Const(Const.Int16 _,_,_) -> (function Const.Int16 _ -> true | _ -> false), (fun buf -> function Const.Int16 b -> buf.EmitUInt16 (uint16 b) | _ -> failwith "unreachable") - | Expr.Const(Const.Int32 _,_,_) -> (function Const.Int32 _ -> true | _ -> false), (fun buf -> function Const.Int32 b -> buf.EmitInt32 b | _ -> failwith "unreachable") - | Expr.Const(Const.Int64 _,_,_) -> (function Const.Int64 _ -> true | _ -> false), (fun buf -> function Const.Int64 b -> buf.EmitInt64 b | _ -> failwith "unreachable") + | Expr.Const(Const.Bool _,_,_) -> + (function Const.Bool _ -> true | _ -> false), + (fun (buf: ByteBuffer) -> function Const.Bool b -> buf.EmitBoolAsByte b | _ -> failwith "unreachable") + | Expr.Const(Const.Char _,_,_) -> + (function Const.Char _ -> true | _ -> false), + (fun buf -> function Const.Char b -> buf.EmitInt32AsUInt16 (int b) | _ -> failwith "unreachable") + | Expr.Const(Const.Byte _,_,_) -> + (function Const.Byte _ -> true | _ -> false), + (fun buf -> function Const.Byte b -> buf.EmitByte b | _ -> failwith "unreachable") + | Expr.Const(Const.UInt16 _,_,_) -> + (function Const.UInt16 _ -> true | _ -> false), + (fun buf -> function Const.UInt16 b -> buf.EmitUInt16 b | _ -> failwith "unreachable") + | Expr.Const(Const.UInt32 _,_,_) -> + (function Const.UInt32 _ -> true | _ -> false), + (fun buf -> function Const.UInt32 b -> buf.EmitInt32 (int32 b) | _ -> failwith "unreachable") + | Expr.Const(Const.UInt64 _,_,_) -> + (function Const.UInt64 _ -> true | _ -> false), + (fun buf -> function Const.UInt64 b -> buf.EmitInt64 (int64 b) | _ -> failwith "unreachable") + | Expr.Const(Const.SByte _,_,_) -> + (function Const.SByte _ -> true | _ -> false), + (fun buf -> function Const.SByte b -> buf.EmitByte (byte b) | _ -> failwith "unreachable") + | Expr.Const(Const.Int16 _,_,_) -> + (function Const.Int16 _ -> true | _ -> false), + (fun buf -> function Const.Int16 b -> buf.EmitUInt16 (uint16 b) | _ -> failwith "unreachable") + | Expr.Const(Const.Int32 _,_,_) -> + (function Const.Int32 _ -> true | _ -> false), + (fun buf -> function Const.Int32 b -> buf.EmitInt32 b | _ -> failwith "unreachable") + | Expr.Const(Const.Int64 _,_,_) -> + (function Const.Int64 _ -> true | _ -> false), + (fun buf -> function Const.Int64 b -> buf.EmitInt64 b | _ -> failwith "unreachable") | _ -> (function _ -> false), (fun _ _ -> failwith "unreachable") if elems' |> Array.forall (function Expr.Const(c,_,_) -> test c | _ -> false) then @@ -2817,8 +2844,9 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = let isDllImport = IsValRefIsDllImport cenv.g vref let hasByrefArg = mspec.FormalArgTypes |> List.exists (function ILType.Byref _ -> true | _ -> false) let makesNoCriticalTailcalls = vref.MakesNoCriticalTailcalls - CanTailcall((boxity=AsValue),ccallInfo,eenv.withinSEH,hasByrefArg,mustGenerateUnitAfterCall,isDllImport,isSelfInit,makesNoCriticalTailcalls,sequel) - else Normalcall + CanTailcall((boxity=AsValue), ccallInfo, eenv.withinSEH, hasByrefArg,mustGenerateUnitAfterCall, isDllImport, isSelfInit, makesNoCriticalTailcalls, sequel) + else + Normalcall let useICallVirt = virtualCall || useCallVirt cenv boxity mspec isBaseCall @@ -2845,7 +2873,8 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = // Only save arguments that have effects if Optimizer.ExprHasEffect cenv.g laterArg then let ilTy = laterArg |> tyOfExpr cenv.g |> GenType cenv.amap m eenv.tyenv - let loc, _realloc, eenv = AllocLocal cenv cgbuf eenv true (ilxgenGlobalNng.FreshCompilerGeneratedName ("arg",m), ilTy, false) scopeMarks + let locName = ilxgenGlobalNng.FreshCompilerGeneratedName ("arg",m), ilTy, false + let loc, _realloc, eenv = AllocLocal cenv cgbuf eenv true locName scopeMarks GenExpr cenv cgbuf eenv SPSuppress laterArg Continue EmitSetLocal cgbuf loc Choice1Of2 (ilTy,loc),eenv @@ -2853,8 +2882,8 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = Choice2Of2 laterArg, eenv) let nargs = mspec.FormalArgTypes.Length - CG.EmitInstr cgbuf (pop (nargs + (if mspec.CallingConv.IsStatic || newobj then 0 else 1))) - (if mustGenerateUnitAfterCall || isSuperInit || isSelfInit then Push0 else (Push [(GenType cenv.amap m eenv.tyenv actualRetTy)])) callInstr + let pushes = if mustGenerateUnitAfterCall || isSuperInit || isSelfInit then Push0 else (Push [(GenType cenv.amap m eenv.tyenv actualRetTy)]) + CG.EmitInstr cgbuf (pop (nargs + (if mspec.CallingConv.IsStatic || newobj then 0 else 1))) pushes callInstr // For isSuperInit, load the 'this' pointer as the pretend 'result' of the operation. It will be popped again in most cases if isSuperInit then CG.EmitInstrs cgbuf (pop 0) (Push [mspec.DeclaringType]) [ mkLdarg0 ] @@ -2890,9 +2919,12 @@ and GenApp cenv cgbuf eenv (f,fty,tyargs,args,m) sequel = GenArgsAndIndirectCall cenv cgbuf eenv (fty,tyargs,args,m) sequel and CanTailcall (hasStructObjArg, ccallInfo, withinSEH, hasByrefArg, mustGenerateUnitAfterCall, isDllImport, isSelfInit, makesNoCriticalTailcalls, sequel) = + // Can't tailcall with a struct object arg since it involves a byref // Can't tailcall with a .NET 2.0 generic constrained call since it involves a byref - if not hasStructObjArg && Option.isNone ccallInfo && not withinSEH && not hasByrefArg && not isDllImport && not isSelfInit && not makesNoCriticalTailcalls && + if not hasStructObjArg && Option.isNone ccallInfo && not withinSEH && not hasByrefArg && + not isDllImport && not isSelfInit && not makesNoCriticalTailcalls && + // We can tailcall even if we need to generate "unit", as long as we're about to throw the value away anyway as par of the return. // We can tailcall if we don't need to generate "unit", as long as we're about to return. (match sequelIgnoreEndScopes sequel with @@ -3001,7 +3033,9 @@ and GenTry cenv cgbuf eenv scopeMarks (e1,m,resty,spTry) = let afterHandler = CG.GenerateDelayMark cgbuf "afterHandler" let eenvinner = {eenvinner with withinSEH = true} let ilResultTy = GenType cenv.amap m eenvinner.tyenv resty - let whereToSave, _realloc, eenvinner = AllocLocal cenv cgbuf eenvinner true (ilxgenGlobalNng.FreshCompilerGeneratedName ("tryres",m),ilResultTy, false) (startTryMark,endTryMark) + + let whereToSave, _realloc, eenvinner = + AllocLocal cenv cgbuf eenvinner true (ilxgenGlobalNng.FreshCompilerGeneratedName ("tryres",m),ilResultTy, false) (startTryMark,endTryMark) // Generate the body of the try. In the normal case (SequencePointAtTry) we generate a sequence point // both on the 'try' keyword and on the start of the expression in the 'try'. For inlined code and @@ -3304,8 +3338,9 @@ and GenAsmCode cenv cgbuf eenv (il,tyargs,args,returnTys,m) sequel = | I_stobj (a,b,ILType.TypeVar _) ,[tyarg] -> I_stobj (a,b,tyarg) | I_ldtoken (ILToken.ILType (ILType.TypeVar _)),[tyarg] -> I_ldtoken (ILToken.ILType (tyarg)) | I_sizeof (ILType.TypeVar _) ,[tyarg] -> I_sizeof (tyarg) - | I_cpobj (ILType.TypeVar _) ,[tyarg] -> I_cpobj (tyarg) // currently unused, added for forward compat, see https://visualfsharp.codeplex.com/SourceControl/network/forks/jackpappas/fsharpcontrib/contribution/7134 - | I_initobj (ILType.TypeVar _) ,[tyarg] -> I_initobj (tyarg) // currently unused, added for forward compat, see https://visualfsharp.codeplex.com/SourceControl/network/forks/jackpappas/fsharpcontrib/contribution/7134 + // currently unused, added for forward compat, see https://visualfsharp.codeplex.com/SourceControl/network/forks/jackpappas/fsharpcontrib/contribution/7134 + | I_cpobj (ILType.TypeVar _) ,[tyarg] -> I_cpobj (tyarg) + | I_initobj (ILType.TypeVar _) ,[tyarg] -> I_initobj (tyarg) | I_ldfld (al,vol,fspec) ,_ -> I_ldfld (al,vol,modFieldSpec fspec) | I_ldflda (fspec) ,_ -> I_ldflda (modFieldSpec fspec) | I_stfld (al,vol,fspec) ,_ -> I_stfld (al,vol,modFieldSpec fspec) @@ -3553,17 +3588,22 @@ and GenGetValAddr cenv cgbuf eenv (v: ValRef, m) sequel = let vspec = v.Deref let ilTy = GenTypeOfVal cenv eenv vspec let storage = StorageForValRef m v eenv + match storage with | Local (idx, _, None) -> CG.EmitInstrs cgbuf (pop 0) (Push [ILType.Byref ilTy]) [ I_ldloca (uint16 idx) ] + | Arg idx -> CG.EmitInstrs cgbuf (pop 0) (Push [ILType.Byref ilTy]) [ I_ldarga (uint16 idx) ] + | StaticField (fspec, _vref, hasLiteralAttr, _ilTyForProperty, _, ilTy, _, _, _) -> if hasLiteralAttr then errorR(Error(FSComp.SR.ilAddressOfLiteralFieldIsInvalid(),m)) let ilTy = if ilTy.IsNominal && ilTy.Boxity = ILBoxity.AsValue then ILType.Byref ilTy else ilTy EmitGetStaticFieldAddr cgbuf ilTy fspec + | Env (_,_,ilField,_) -> CG.EmitInstrs cgbuf (pop 0) (Push [ILType.Byref ilTy]) [ mkLdarg0; mkNormalLdflda ilField ] + | Local (_, _, Some _) | StaticProperty _ | Method _ | Env _ | Null -> errorR(Error(FSComp.SR.ilAddressOfValueHereIsInvalid(v.DisplayName),m)) CG.EmitInstrs cgbuf (pop 1) (Push [ILType.Byref ilTy]) [ I_ldarga (uint16 669 (* random value for post-hoc diagnostic analysis on generated tree *) ) ] ; @@ -3624,10 +3664,21 @@ and GenDefaultValue cenv cgbuf eenv (ty,m) = //-------------------------------------------------------------------------- and GenGenericParam cenv eenv (tp:Typar) = - let subTypeConstraints = tp.Constraints |> List.choose (function | TyparConstraint.CoercesTo(ty,_) -> Some(ty) | _ -> None) |> List.map (GenTypeAux cenv.amap tp.Range eenv.tyenv VoidNotOK PtrTypesNotOK) - let refTypeConstraint = tp.Constraints |> List.exists (function TyparConstraint.IsReferenceType _ -> true | TyparConstraint.SupportsNull _ -> true | _ -> false) - let notNullableValueTypeConstraint = tp.Constraints |> List.exists (function TyparConstraint.IsNonNullableStruct _ -> true | _ -> false) - let defaultConstructorConstraint = tp.Constraints |> List.exists (function TyparConstraint.RequiresDefaultConstructor _ -> true | _ -> false) + let subTypeConstraints = + tp.Constraints + |> List.choose (function | TyparConstraint.CoercesTo(ty,_) -> Some(ty) | _ -> None) + |> List.map (GenTypeAux cenv.amap tp.Range eenv.tyenv VoidNotOK PtrTypesNotOK) + + let refTypeConstraint = + tp.Constraints + |> List.exists (function TyparConstraint.IsReferenceType _ -> true | TyparConstraint.SupportsNull _ -> true | _ -> false) + + let notNullableValueTypeConstraint = + tp.Constraints |> List.exists (function TyparConstraint.IsNonNullableStruct _ -> true | _ -> false) + + let defaultConstructorConstraint = + tp.Constraints |> List.exists (function TyparConstraint.RequiresDefaultConstructor _ -> true | _ -> false) + { Name= // use the CompiledName if given @@ -3705,8 +3756,13 @@ and GenActualSlotsig m cenv eenv (TSlotSig(_,ty,ctps,mtps,ilSlotParams,ilSlotRet let ilSlotParams = List.concat ilSlotParams let instForSlotSig = mkTyparInst (ctps@mtps) (argsOfAppTy cenv.g ty @ generalizeTypars methTyparsOfOverridingMethod) let ilParams = ilSlotParams |> List.map (instSlotParam instForSlotSig >> GenSlotParam m cenv eenv) + // Use the better names if available - let ilParams = if ilParams.Length = methodParams.Length then (ilParams, methodParams) ||> List.map2 (fun p pv -> { p with Name = Some (nameOfVal pv) }) else ilParams + let ilParams = + if ilParams.Length = methodParams.Length then + (ilParams, methodParams) ||> List.map2 (fun p pv -> { p with Name = Some (nameOfVal pv) }) + else ilParams + let ilRetTy = GenReturnType cenv.amap m eenv.tyenv (Option.map (instType instForSlotSig) ilSlotRetTy) let iLRet = mkILReturn ilRetTy ilParams,iLRet @@ -3721,7 +3777,7 @@ and GenMethodImpl cenv eenv (useMethodImpl,(TSlotSig(nameOfOverridenMethod,_,_,_ nameOfOverridingMethod, (fun (ilTyForOverriding,methTyparsOfOverridingMethod) -> let ilOverrideTyRef = ilOverrideTy.TypeRef - let ilOverrideMethRef = mkILMethRef(ilOverrideTyRef, ILCallingConv.Instance, nameOfOverridenMethod, List.length (DropErasedTypars methTyparsOfOverridingMethod), (typesOfILParams ilOverrideParams), ilOverrideRet.Type) + let ilOverrideMethRef = mkILMethRef(ilOverrideTyRef, ILCallingConv.Instance, nameOfOverridenMethod, List.length (DropErasedTypars methTyparsOfOverridingMethod), typesOfILParams ilOverrideParams, ilOverrideRet.Type) let eenvForOverrideBy = AddTyparsToEnv methTyparsOfOverridingMethod eenv let ilParamsOfOverridingMethod,ilReturnOfOverridingMethod = GenActualSlotsig m cenv eenvForOverrideBy slotsig methTyparsOfOverridingMethod [] let ilOverrideMethGenericParams = GenGenericParams cenv eenvForOverrideBy methTyparsOfOverridingMethod @@ -3755,12 +3811,15 @@ and GenObjectMethod cenv eenvinner (cgbuf:CodeGenBuffer) useMethodImpl tmethod = let eenvUnderTypars = AddTyparsToEnv methTyparsOfOverridingMethod eenvinner let methodParams = List.concat methodParams let methodParamsNonSelf = match methodParams with [] -> [] | _::t -> t // drop the 'this' arg when computing better argument names for IL parameters - let ilParamsOfOverridingMethod,ilReturnOfOverridingMethod = GenActualSlotsig m cenv eenvUnderTypars slotsig methTyparsOfOverridingMethod methodParamsNonSelf + let ilParamsOfOverridingMethod,ilReturnOfOverridingMethod = + GenActualSlotsig m cenv eenvUnderTypars slotsig methTyparsOfOverridingMethod methodParamsNonSelf + let ilAttribs = GenAttrs cenv eenvinner attribs // Args are stored starting at #1 let eenvForMeth = AddStorageForLocalVals cenv.g (methodParams |> List.mapi (fun i v -> (v,Arg i))) eenvUnderTypars - let ilMethodBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways,[],nameOfOverridenMethod,eenvForMeth,0,methodBodyExpr,(if slotSigHasVoidReturnTy slotsig then discardAndReturnVoid else Return)) + let sequel = (if slotSigHasVoidReturnTy slotsig then discardAndReturnVoid else Return) + let ilMethodBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways,[],nameOfOverridenMethod,eenvForMeth,0,methodBodyExpr,sequel) let nameOfOverridingMethod,methodImplGenerator = GenMethodImpl cenv eenvinner (useMethodImpl,slotsig) methodBodyExpr.Range @@ -3827,7 +3886,12 @@ and GenObjectExpr cenv cgbuf eenvouter expr (baseType,baseValOpt,basecall,overri CG.EmitInstr cgbuf (pop ilCloFreeVars.Length) (Push [ EraseClosures.mkTyOfLambdas cenv.g.ilxPubCloEnv ilCloLambdas]) (I_newobj (ilxCloSpec.Constructor,None)) GenSequel cenv eenvouter.cloc cgbuf sequel -and GenSequenceExpr cenv (cgbuf:CodeGenBuffer) eenvouter (nextEnumeratorValRef:ValRef,pcvref:ValRef,currvref:ValRef,stateVars,generateNextExpr,closeExpr,checkCloseExpr:Expr,seqElemTy, m) sequel = +and GenSequenceExpr + cenv + (cgbuf:CodeGenBuffer) + eenvouter + (nextEnumeratorValRef:ValRef, pcvref:ValRef, currvref:ValRef, stateVars, generateNextExpr, closeExpr, checkCloseExpr:Expr, seqElemTy, m) sequel = + let stateVars = [ pcvref; currvref ] @ stateVars let stateVarsSet = stateVars |> List.map (fun vref -> vref.Deref) |> Zset.ofList valOrder @@ -3857,48 +3921,57 @@ and GenSequenceExpr cenv (cgbuf:CodeGenBuffer) eenvouter (nextEnumeratorValRef:V let getFreshMethod = let _,mbody = - CodeGenMethod cenv cgbuf.mgbuf ([],"GetFreshEnumerator",eenvinner,1, - (fun cgbuf eenv -> - for fv in cloFreeVars do - /// State variables always get zero-initialized - if stateVarsSet.Contains fv then - GenDefaultValue cenv cgbuf eenv (fv.Type,m) - else - GenGetLocalVal cenv cgbuf eenv m fv None - CG.EmitInstr cgbuf (pop ilCloFreeVars.Length) (Push [ilCloRetTyInner]) (I_newobj (formalClospec.Constructor,None)) - GenSequel cenv eenv.cloc cgbuf Return), - m) + CodeGenMethod cenv cgbuf.mgbuf + ([],"GetFreshEnumerator",eenvinner,1, + (fun cgbuf eenv -> + for fv in cloFreeVars do + /// State variables always get zero-initialized + if stateVarsSet.Contains fv then + GenDefaultValue cenv cgbuf eenv (fv.Type,m) + else + GenGetLocalVal cenv cgbuf eenv m fv None + CG.EmitInstr cgbuf (pop ilCloFreeVars.Length) (Push [ilCloRetTyInner]) (I_newobj (formalClospec.Constructor,None)) + GenSequel cenv eenv.cloc cgbuf Return), + m) mkILNonGenericVirtualMethod("GetFreshEnumerator",ILMemberAccess.Public, [], mkILReturn ilCloEnumeratorTy, MethodBody.IL mbody) |> AddNonUserCompilerGeneratedAttribs cenv.g let closeMethod = // Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump let spReq = SPSuppress - mkILNonGenericVirtualMethod("Close",ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"Close",eenvinner,1,closeExpr,discardAndReturnVoid))) + let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"Close",eenvinner,1,closeExpr,discardAndReturnVoid) + mkILNonGenericVirtualMethod("Close",ILMemberAccess.Public, [], mkILReturn ILType.Void, MethodBody.IL ilCode) let checkCloseMethod = // Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump let spReq = SPSuppress - mkILNonGenericVirtualMethod("get_CheckClose",ILMemberAccess.Public, [], mkILReturn cenv.g.ilg.typ_Bool, MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"get_CheckClose",eenvinner,1,checkCloseExpr,Return))) + let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"get_CheckClose",eenvinner,1,checkCloseExpr,Return) + mkILNonGenericVirtualMethod("get_CheckClose",ILMemberAccess.Public, [], mkILReturn cenv.g.ilg.typ_Bool, MethodBody.IL ilCode) let generateNextMethod = // Note: We suppress the first sequence point in the body of this method since it is the initial state machine jump let spReq = SPSuppress // the 'next enumerator' byref arg is at arg position 1 let eenvinner = eenvinner |> AddStorageForLocalVals cenv.g [ (nextEnumeratorValRef.Deref, Arg 1) ] - mkILNonGenericVirtualMethod("GenerateNext",ILMemberAccess.Public, [mkILParamNamed("next",ILType.Byref ilCloEnumerableTy)], mkILReturn cenv.g.ilg.typ_Int32, MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"GenerateNext",eenvinner,2,generateNextExpr,Return))) + let ilParams = [mkILParamNamed("next",ILType.Byref ilCloEnumerableTy)] + let ilReturn = mkILReturn cenv.g.ilg.typ_Int32 + let ilCode = MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (spReq,[],"GenerateNext",eenvinner,2,generateNextExpr,Return)) + mkILNonGenericVirtualMethod("GenerateNext",ILMemberAccess.Public, ilParams, ilReturn, ilCode) let lastGeneratedMethod = - mkILNonGenericVirtualMethod("get_LastGenerated",ILMemberAccess.Public, [], mkILReturn ilCloSeqElemTy, MethodBody.IL (CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress,[],"get_LastGenerated",eenvinner,1,exprForValRef m currvref,Return))) + let ilCode = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPSuppress,[],"get_LastGenerated",eenvinner,1,exprForValRef m currvref,Return) + mkILNonGenericVirtualMethod("get_LastGenerated",ILMemberAccess.Public, [], mkILReturn ilCloSeqElemTy, MethodBody.IL ilCode) |> AddNonUserCompilerGeneratedAttribs cenv.g let ilCtorBody = mkILSimpleStorageCtor(None, Some ilCloBaseTy.TypeSpec, ilCloTyInner, [], [], ILMemberAccess.Assembly).MethodBody let attrs = GenAttrs cenv eenvinner cloAttribs - let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef,ilCloGenericParams,attrs,ilCloFreeVars,ilCloLambdas,ilCtorBody,[generateNextMethod;closeMethod;checkCloseMethod;lastGeneratedMethod;getFreshMethod],[],ilCloBaseTy,[]) + let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, ilCloGenericParams, attrs, ilCloFreeVars, ilCloLambdas, ilCtorBody, [generateNextMethod;closeMethod;checkCloseMethod;lastGeneratedMethod;getFreshMethod],[],ilCloBaseTy,[]) + for cloTypeDef in cloTypeDefs do cgbuf.mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None) + CountClosure() for fv in cloFreeVars do @@ -3990,7 +4063,18 @@ and GenLambdaClosure cenv (cgbuf:CodeGenBuffer) eenv isLocalTypeFunc selfv expr implements = [], extends= Some cenv.g.ilg.typ_Object, securityDecls= emptyILSecurityDecls) - let ilContractTypeDef = ilContractTypeDef.WithAbstract(true).WithAccess(ComputeTypeAccess ilContractTypeRef true).WithSerializable(true).WithSpecialName(true).WithLayout(ILTypeDefLayout.Auto).WithInitSemantics(ILTypeInit.BeforeField).WithEncoding(ILDefaultPInvokeEncoding.Auto) // the contract type is an abstract type and not sealed + + // the contract type is an abstract type and not sealed + let ilContractTypeDef = + ilContractTypeDef + .WithAbstract(true) + .WithAccess(ComputeTypeAccess ilContractTypeRef true) + .WithSerializable(true) + .WithSpecialName(true) + .WithLayout(ILTypeDefLayout.Auto) + .WithInitSemantics(ILTypeInit.BeforeField) + .WithEncoding(ILDefaultPInvokeEncoding.Auto) + cgbuf.mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None) let ilCtorBody = mkILMethodBody (true,[],8,nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy,[])), None ) diff --git a/src/fsharp/IlxGen.fsi b/src/fsharp/IlxGen.fsi index 6d50da1bfd..5e2823f8e3 100755 --- a/src/fsharp/IlxGen.fsi +++ b/src/fsharp/IlxGen.fsi @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.IlxGen +module internal FSharp.Compiler.IlxGen open System open System.IO open System.Reflection -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals /// Indicates how the generated IL code is ultimately emitted type IlxGenBackend = diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index e04485887e..23544c6120 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -2,23 +2,23 @@ /// Select members from a type by name, searching the type hierarchy if needed -module internal Microsoft.FSharp.Compiler.InfoReader +module internal FSharp.Compiler.InfoReader open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals /// Use the given function to select some of the member values from the members of an F# type let private SelectImmediateMemberVals g optFilter f (tcref:TyconRef) = @@ -624,11 +624,25 @@ let private FilterOverrides findFlag (isVirt:'a->bool,isNewSlot,isDefiniteOverri /// Filter the overrides of methods, either keeping the overrides or keeping the dispatch slots. let private FilterOverridesOfMethInfos findFlag g amap m minfos = - FilterOverrides findFlag ((fun (minfo:MethInfo) -> minfo.IsVirtual),(fun minfo -> minfo.IsNewSlot),(fun minfo -> minfo.IsDefiniteFSharpOverride),(fun minfo -> minfo.IsFinal),MethInfosEquivByNameAndSig EraseNone true g amap m,(fun minfo -> minfo.LogicalName)) minfos + minfos + |> FilterOverrides findFlag + ((fun (minfo:MethInfo) -> minfo.IsVirtual), + (fun minfo -> minfo.IsNewSlot), + (fun minfo -> minfo.IsDefiniteFSharpOverride), + (fun minfo -> minfo.IsFinal), + MethInfosEquivByNameAndSig EraseNone true g amap m, + (fun minfo -> minfo.LogicalName)) /// Filter the overrides of properties, either keeping the overrides or keeping the dispatch slots. let private FilterOverridesOfPropInfos findFlag g amap m props = - FilterOverrides findFlag ((fun (pinfo:PropInfo) -> pinfo.IsVirtualProperty),(fun pinfo -> pinfo.IsNewSlot),(fun pinfo -> pinfo.IsDefiniteFSharpOverride),(fun _ -> false),PropInfosEquivByNameAndSig EraseNone g amap m, (fun pinfo -> pinfo.PropertyName)) props + props + |> FilterOverrides findFlag + ((fun (pinfo:PropInfo) -> pinfo.IsVirtualProperty), + (fun pinfo -> pinfo.IsNewSlot), + (fun pinfo -> pinfo.IsDefiniteFSharpOverride), + (fun _ -> false), + PropInfosEquivByNameAndSig EraseNone g amap m, + (fun pinfo -> pinfo.PropertyName)) /// Exclude methods from super types which have the same signature as a method in a more specific type. let ExcludeHiddenOfMethInfos g amap m (minfos:MethInfo list list) = diff --git a/src/fsharp/InnerLambdasToTopLevelFuncs.fs b/src/fsharp/InnerLambdasToTopLevelFuncs.fs index c783c1efe1..c03ac2ace3 100755 --- a/src/fsharp/InnerLambdasToTopLevelFuncs.fs +++ b/src/fsharp/InnerLambdasToTopLevelFuncs.fs @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.InnerLambdasToTopLevelFuncs - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Detuple.GlobalUsageAnalysis -open Microsoft.FSharp.Compiler.Lib +module internal FSharp.Compiler.InnerLambdasToTopLevelFuncs + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Layout +open FSharp.Compiler.Detuple.GlobalUsageAnalysis +open FSharp.Compiler.Lib let verboseTLR = false diff --git a/src/fsharp/InnerLambdasToTopLevelFuncs.fsi b/src/fsharp/InnerLambdasToTopLevelFuncs.fsi index 916d563438..5a25c27ac5 100755 --- a/src/fsharp/InnerLambdasToTopLevelFuncs.fsi +++ b/src/fsharp/InnerLambdasToTopLevelFuncs.fsi @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.InnerLambdasToTopLevelFuncs +module internal FSharp.Compiler.InnerLambdasToTopLevelFuncs -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.TcGlobals val MakeTLRDecisions : Tast.CcuThunk -> TcGlobals -> Tast.TypedImplFile -> Tast.TypedImplFile diff --git a/src/fsharp/LegacyHostedCompilerForTesting.fs b/src/fsharp/LegacyHostedCompilerForTesting.fs index 1f8e258e07..b793915b5c 100644 --- a/src/fsharp/LegacyHostedCompilerForTesting.fs +++ b/src/fsharp/LegacyHostedCompilerForTesting.fs @@ -9,12 +9,12 @@ open System open System.IO open System.Text open System.Text.RegularExpressions -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Driver -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Driver +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.CompileOps +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal.Library /// build issue location type internal Location = diff --git a/src/fsharp/LexFilter.fs b/src/fsharp/LexFilter.fs index c67aa06cb4..94c4634abe 100755 --- a/src/fsharp/LexFilter.fs +++ b/src/fsharp/LexFilter.fs @@ -2,18 +2,18 @@ /// LexFilter - process the token stream prior to parsing. /// Implements the offside rule and a copule of other lexical transformations. -module internal Microsoft.FSharp.Compiler.LexFilter +module internal FSharp.Compiler.LexFilter open Internal.Utilities.Text.Lexing -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Parser -open Microsoft.FSharp.Compiler.Lexhelp +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Parser +open FSharp.Compiler.Lexhelp let debug = false @@ -806,8 +806,11 @@ type LexFilterImpl (lightSyntaxStatus:LightSyntaxStatus, compilingFsLib, lexer, let c2 = newCtxt.StartCol if c2 < p1.Column then warn tokenTup - (if debug then (sprintf "possible incorrect indentation: this token is offside of context at position %s, newCtxt = %A, stack = %A, newCtxtPos = %s, c1 = %d, c2 = %d" (warningStringOfPos p1.Position) newCtxt offsideStack (stringOfPos (newCtxt.StartPos)) p1.Column c2) - else (FSComp.SR.lexfltTokenIsOffsideOfContextStartedEarlier(warningStringOfPos p1.Position)) ) + (if debug then + sprintf "possible incorrect indentation: this token is offside of context at position %s, newCtxt = %A, stack = %A, newCtxtPos = %s, c1 = %d, c2 = %d" + (warningStringOfPos p1.Position) newCtxt offsideStack (stringOfPos (newCtxt.StartPos)) p1.Column c2 + else + FSComp.SR.lexfltTokenIsOffsideOfContextStartedEarlier(warningStringOfPos p1.Position)) let newOffsideStack = newCtxt :: offsideStack if debug then dprintf "--> pushing, stack = %A\n" newOffsideStack offsideStack <- newOffsideStack diff --git a/src/fsharp/Logger.fs b/src/fsharp/Logger.fs index 7ecfe842f2..b1968240d2 100644 --- a/src/fsharp/Logger.fs +++ b/src/fsharp/Logger.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System.Diagnostics.Tracing open System diff --git a/src/fsharp/Logger.fsi b/src/fsharp/Logger.fsi index 324a0d0936..cb84dde5f5 100644 --- a/src/fsharp/Logger.fsi +++ b/src/fsharp/Logger.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs index 15904bfabd..bec0d2afe8 100755 --- a/src/fsharp/LowerCallsAndSeqs.fs +++ b/src/fsharp/LowerCallsAndSeqs.fs @@ -1,22 +1,22 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.LowerCallsAndSeqs - -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.MethodCalls +module internal FSharp.Compiler.LowerCallsAndSeqs + +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library + +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.Infos +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.InfoReader +open FSharp.Compiler.MethodCalls //---------------------------------------------------------------------------- // Eta-expansion of calls to top-level-methods diff --git a/src/fsharp/MSBuildReferenceResolver.fs b/src/fsharp/MSBuildReferenceResolver.fs index c2a9d2133b..2e25ebf95a 100644 --- a/src/fsharp/MSBuildReferenceResolver.fs +++ b/src/fsharp/MSBuildReferenceResolver.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver +module internal FSharp.Compiler.MSBuildReferenceResolver open System open System.IO @@ -10,12 +10,12 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver open Microsoft.FSharp.Core.ReflectionAdapters #endif #if FX_RESHAPED_MSBUILD - open Microsoft.FSharp.Compiler.MsBuildAdapters - open Microsoft.FSharp.Compiler.ToolLocationHelper + open FSharp.Compiler.MsBuildAdapters + open FSharp.Compiler.ToolLocationHelper #endif - open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - open Microsoft.FSharp.Compiler.ReferenceResolver + open FSharp.Compiler.AbstractIL.Internal.Library + open FSharp.Compiler.ReferenceResolver open Microsoft.Build.Tasks open Microsoft.Build.Utilities open Microsoft.Build.Framework @@ -344,7 +344,7 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver #if ENABLE_MONO_SUPPORT // The properties TargetedRuntimeVersion and CopyLocalDependenciesWhenParentReferenceInGac // are not available on Mono. So we only set them if available (to avoid a compile-time dependency). - if not Microsoft.FSharp.Compiler.AbstractIL.IL.runningOnMono then + if not FSharp.Compiler.AbstractIL.IL.runningOnMono then typeof.InvokeMember("TargetedRuntimeVersion",(BindingFlags.Instance ||| BindingFlags.SetProperty ||| BindingFlags.Public),null,rar,[| box targetedRuntimeVersionValue |]) |> ignore typeof.InvokeMember("CopyLocalDependenciesWhenParentReferenceInGac",(BindingFlags.Instance ||| BindingFlags.SetProperty ||| BindingFlags.Public),null,rar,[| box true |]) |> ignore #else @@ -398,9 +398,19 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver let rooted, unrooted = references |> Array.partition (fst >> FileSystem.IsPathRootedShim) - let rootedResults = ResolveCore(resolutionEnvironment, rooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, true, logMessage, logDiagnostic) - - let unrootedResults = ResolveCore(resolutionEnvironment, unrooted, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, false, logMessage, logDiagnostic) + let rootedResults = + ResolveCore + (resolutionEnvironment, rooted, targetFrameworkVersion, + targetFrameworkDirectories, targetProcessorArchitecture, + fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, + true, logMessage, logDiagnostic) + + let unrootedResults = + ResolveCore + (resolutionEnvironment, unrooted, targetFrameworkVersion, + targetFrameworkDirectories, targetProcessorArchitecture, + fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, + false, logMessage, logDiagnostic) // now unify the two sets of results Array.concat [| rootedResults; unrootedResults |] diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index de5271eb67..e7737b3f25 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -1,28 +1,28 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Logic associated with resolving method calls. -module internal Microsoft.FSharp.Compiler.MethodCalls - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations -open Microsoft.FSharp.Compiler.AttributeChecking +module internal FSharp.Compiler.MethodCalls + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.NameResolution +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations +open FSharp.Compiler.AttributeChecking #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index 77b98010d3..6866910286 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -1,22 +1,22 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Primary logic related to method overrides. -module internal Microsoft.FSharp.Compiler.MethodOverrides - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations +module internal FSharp.Compiler.MethodOverrides + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.NameResolution +open FSharp.Compiler.Range +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations //------------------------------------------------------------------------- // Completeness of classes diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 9434740d31..9ba23ab08e 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -2,31 +2,31 @@ /// Name environment and name resolution -module internal Microsoft.FSharp.Compiler.NameResolution +module internal FSharp.Compiler.NameResolution open Internal.Utilities -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.ResultOrException -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library.ResultOrException +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Infos +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.InfoReader +open FSharp.Compiler.PrettyNaming open System.Collections.Generic #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif /// An object that captures the logical context for name resolution. @@ -2322,10 +2322,16 @@ let rec ResolveExprLongIdentInModuleOrNamespace (ncenv:NameResolver) nenv (typeN let tcrefs = LookupTypeNameInEntityMaybeHaveArity (ncenv.amap, id.idRange, ad, id.idText, (if isNil rest then typeNameResInfo.StaticArgsInfo else TypeNameResolutionStaticArgsInfo.Indefinite), modref) if isNil tcrefs then NoResultsOrUsefulErrors else let tcrefs = tcrefs |> List.map (fun tcref -> (resInfo,tcref)) + match rest with | id2::rest2 -> - let tcrefs = CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities (tcrefs, TypeNameResolutionInfo (ResolveTypeNamesToTypeRefs,TypeNameResolutionStaticArgsInfo.Indefinite), PermitDirectReferenceToGeneratedType.No, unionRanges m id.idRange) + + let tcrefs = + let typeNameResInfo = TypeNameResolutionInfo (ResolveTypeNamesToTypeRefs,TypeNameResolutionStaticArgsInfo.Indefinite) + CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities (tcrefs, typeNameResInfo, PermitDirectReferenceToGeneratedType.No, unionRanges m id.idRange) + ResolveLongIdentInTyconRefs ResultCollectionSettings.AtMostOneResult ncenv nenv LookupKind.Expr (depth+1) m ad id2 rest2 typeNameResInfo id.idRange tcrefs + // Check if we've got some explicit type arguments | _ -> let tcrefs = CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities (tcrefs, typeNameResInfo, PermitDirectReferenceToGeneratedType.No, unionRanges m id.idRange) @@ -2557,7 +2563,9 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) first fullyQualified match rest with | id2::rest2 -> let tcrefs = tcrefs |> List.map (fun tcref -> (resInfo,tcref)) - let tcrefs = CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities (tcrefs, TypeNameResolutionInfo.ResolveToTypeRefs (TypeNameResolutionStaticArgsInfo.Indefinite), PermitDirectReferenceToGeneratedType.No, unionRanges m id.idRange) + let tcrefs = + let typeNameResInfo = TypeNameResolutionInfo.ResolveToTypeRefs (TypeNameResolutionStaticArgsInfo.Indefinite) + CheckForTypeLegitimacyAndMultipleGenericTypeAmbiguities (tcrefs, typeNameResInfo, PermitDirectReferenceToGeneratedType.No, unionRanges m id.idRange) ResolveLongIdentInTyconRefs ResultCollectionSettings.AtMostOneResult ncenv nenv LookupKind.Expr 1 m ad id2 rest2 typeNameResInfo id.idRange tcrefs | _ -> NoResultsOrUsefulErrors diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index a302e22ef1..c887aad2fd 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.NameResolution - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.PrettyNaming +module internal FSharp.Compiler.NameResolution + +open FSharp.Compiler +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.Infos +open FSharp.Compiler.Range +open FSharp.Compiler.Import +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.PrettyNaming /// A NameResolver is a context for name resolution. It primarily holds an InfoReader. type NameResolver = @@ -240,7 +240,7 @@ type TypeNameResolutionInfo = static member ResolveToTypeRefs : TypeNameResolutionStaticArgsInfo -> TypeNameResolutionInfo /// Represents the kind of the occurrence when reporting a name in name resolution -[] +[] type internal ItemOccurence = | Binding | Use @@ -319,7 +319,7 @@ type internal TcSymbolUses = member GetUsesOfSymbol : Item -> TcSymbolUseData[] /// All the uses of all items within the file - member AllUsesOfSymbols : TcSymbolUseData[][] + member AllUsesOfSymbols : TcSymbolUseData[][] /// Get the locations of all the printf format specifiers in the file member GetFormatSpecifierLocationsAndArity : unit -> (range * int)[] diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 142ccbae07..d201758b73 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -4,26 +4,26 @@ // Print Signatures/Types, for signatures, intellisense, quick info, FSI responses //-------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.NicePrint - -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -open Microsoft.FSharp.Compiler.PrettyNaming +module internal FSharp.Compiler.NicePrint + +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Rational +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.InfoReader +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.Layout +open FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.PrettyNaming open Microsoft.FSharp.Core.Printf @@ -100,7 +100,7 @@ module internal PrintUtilities = module private PrintIL = - open Microsoft.FSharp.Compiler.AbstractIL.IL + open FSharp.Compiler.AbstractIL.IL let fullySplitILTypeRef (tref:ILTypeRef) = (List.collect IL.splitNamespace (tref.Enclosing @ [PrettyNaming.DemangleGenericTypeName tref.Name])) @@ -194,8 +194,13 @@ module private PrintIL = let args = signatur.ArgTypes |> List.map (layoutILType denv ilTyparSubst) let res = match cons with - | Some className -> layoutILTypeRefName denv (SplitNamesForILPath (PrettyNaming.DemangleGenericTypeName className)) ^^ (pruneParms className ilTyparSubst |> paramsL) // special case for constructor return-type (viz., the class itself) - | None -> signatur.ReturnType |> layoutILType denv ilTyparSubst + | Some className -> + let names = SplitNamesForILPath (PrettyNaming.DemangleGenericTypeName className) + // special case for constructor return-type (viz., the class itself) + layoutILTypeRefName denv names ^^ (pruneParms className ilTyparSubst |> paramsL) + | None -> + signatur.ReturnType |> layoutILType denv ilTyparSubst + match args with | [] -> WordL.structUnit ^^ WordL.arrow ^^ res | [x] -> x ^^ WordL.arrow ^^ res @@ -221,14 +226,16 @@ module private PrintIL = /// Layout a function pointer signature using type-only-F#-style. No argument names are printed. and private layoutILParameters denv ilTyparSubst cons (parameters: ILParameters, retType: ILType) = - // We need a special case for - // constructors (Their return types are reported as `void`, but this is + // We need a special case for constructors (Their return types are reported as `void`, but this is // incorrect; so if we're dealing with a constructor we require that the // return type be passed along as the `cons` parameter.) let res = match cons with - | Some className -> layoutILTypeRefName denv (SplitNamesForILPath (PrettyNaming.DemangleGenericTypeName className)) ^^ (pruneParms className ilTyparSubst |> paramsL) // special case for constructor return-type (viz., the class itself) - | None -> retType |> layoutILType denv ilTyparSubst + | Some className -> + let names = SplitNamesForILPath (PrettyNaming.DemangleGenericTypeName className) + layoutILTypeRefName denv names ^^ (pruneParms className ilTyparSubst |> paramsL) + | None -> retType |> layoutILType denv ilTyparSubst + match parameters with | [] -> WordL.structUnit ^^ WordL.arrow ^^ res | [x] -> layoutILParameter denv ilTyparSubst x ^^ WordL.arrow ^^ res @@ -1860,16 +1867,40 @@ module private InferredSigPrinting = and imdefL denv x = let filterVal (v:Val) = not v.IsCompilerGenerated && Option.isNone v.MemberInfo let filterExtMem (v:Val) = v.IsExtensionMember + match x with | TMDefRec(_,tycons,mbinds,_) -> - TastDefinitionPrinting.layoutTyconDefns denv infoReader ad m tycons @@ - (mbinds |> List.choose (function ModuleOrNamespaceBinding.Binding bind -> Some bind | _ -> None) |> valsOfBinds |> List.filter filterExtMem |> TastDefinitionPrinting.layoutExtensionMembers denv) @@ - (mbinds |> List.choose (function ModuleOrNamespaceBinding.Binding bind -> Some bind | _ -> None) |> valsOfBinds |> List.filter filterVal |> List.map (PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv) |> aboveListL) @@ - (mbinds |> List.choose (function ModuleOrNamespaceBinding.Module (mspec,def) -> Some (mspec,def) | _ -> None) |> List.map (imbindL denv) |> aboveListL) - | TMDefLet(bind,_) -> ([bind.Var] |> List.filter filterVal |> List.map (PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv) |> aboveListL) + TastDefinitionPrinting.layoutTyconDefns denv infoReader ad m tycons @@ + (mbinds + |> List.choose (function ModuleOrNamespaceBinding.Binding bind -> Some bind | _ -> None) + |> valsOfBinds + |> List.filter filterExtMem + |> TastDefinitionPrinting.layoutExtensionMembers denv) @@ + + (mbinds + |> List.choose (function ModuleOrNamespaceBinding.Binding bind -> Some bind | _ -> None) + |> valsOfBinds + |> List.filter filterVal + |> List.map (PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv) + |> aboveListL) @@ + + (mbinds + |> List.choose (function ModuleOrNamespaceBinding.Module (mspec,def) -> Some (mspec,def) | _ -> None) + |> List.map (imbindL denv) + |> aboveListL) + + | TMDefLet(bind,_) -> + ([bind.Var] + |> List.filter filterVal + |> List.map (PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv) + |> aboveListL) + | TMDefs defs -> imdefsL denv defs + | TMDefDo _ -> emptyL + | TMAbstract mexpr -> imexprLP denv mexpr + and imbindL denv (mspec, def) = let nm = mspec.DemangledModuleOrNamespaceName let innerPath = (fullCompPathOfModuleOrNamespace mspec).AccessPath diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 5e34582267..4225ec7422 100755 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -7,29 +7,29 @@ //------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.Optimizer +module internal FSharp.Compiler.Optimizer open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TastPickle -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -open Microsoft.FSharp.Compiler.TypeRelations +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library + +open FSharp.Compiler +open FSharp.Compiler.Lib +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.Tast +open FSharp.Compiler.TastPickle +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Layout +open FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.TypeRelations open System.Collections.Generic diff --git a/src/fsharp/Optimizer.fsi b/src/fsharp/Optimizer.fsi index d99d370358..e156a26d3e 100755 --- a/src/fsharp/Optimizer.fsi +++ b/src/fsharp/Optimizer.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Optimizer +module internal FSharp.Compiler.Optimizer -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals type OptimizationSettings = { abstractBigTargets : bool diff --git a/src/fsharp/PatternMatchCompilation.fs b/src/fsharp/PatternMatchCompilation.fs index 625b23a70d..7120da3a13 100755 --- a/src/fsharp/PatternMatchCompilation.fs +++ b/src/fsharp/PatternMatchCompilation.fs @@ -1,22 +1,22 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.PatternMatchCompilation +module internal FSharp.Compiler.PatternMatchCompilation open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.TypeRelations -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.TypeRelations +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib exception MatchIncomplete of bool * (string * bool) option * range exception RuleNeverMatched of range @@ -523,6 +523,25 @@ let (|ListEmptyDiscrim|_|) g = function | _ -> None #endif +let (|ConstNeedsDefaultCase|_|) c = + match c with + | Const.Decimal _ + | Const.String _ + | Const.Single _ + | Const.Double _ + | Const.SByte _ + | Const.Byte _ + | Const.Int16 _ + | Const.UInt16 _ + | Const.Int32 _ + | Const.UInt32 _ + | Const.Int64 _ + | Const.UInt64 _ + | Const.IntPtr _ + | Const.UIntPtr _ + | Const.Char _ -> Some () + | _ -> None + /// Build a dtree, equivalent to: TDSwitch("expr",edges,default,m) /// /// Once we've chosen a particular active to investigate, we compile the @@ -568,7 +587,7 @@ let rec BuildSwitch inpExprOpt g expr edges dflt m = #endif // All these should also always have default cases - | TCase(DecisionTreeTest.Const (Const.Decimal _ | Const.String _ | Const.Single _ | Const.Double _ | Const.SByte _ | Const.Byte _| Const.Int16 _ | Const.UInt16 _ | Const.Int32 _ | Const.UInt32 _ | Const.Int64 _ | Const.UInt64 _ | Const.IntPtr _ | Const.UIntPtr _ | Const.Char _ ),_) :: _, None -> + | (TCase(DecisionTreeTest.Const ConstNeedsDefaultCase,_) :: _), None -> error(InternalError("inexhaustive match - need a default cases!",m)) // Split string, float, uint64, int64, unativeint, nativeint matches into serial equality tests diff --git a/src/fsharp/PatternMatchCompilation.fsi b/src/fsharp/PatternMatchCompilation.fsi index d4fbba2588..8394611a16 100755 --- a/src/fsharp/PatternMatchCompilation.fsi +++ b/src/fsharp/PatternMatchCompilation.fsi @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.PatternMatchCompilation +module internal FSharp.Compiler.PatternMatchCompilation -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Range /// What should the decision tree contain for any incomplete match? diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index acc3c0c03a..f2c8f370da 100755 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -2,28 +2,28 @@ /// Implements a set of checks on the TAST for a file that can only be performed after type inference /// is complete. -module internal Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks +module internal FSharp.Compiler.PostTypeCheckSemanticChecks open System open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.TypeRelations +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library + +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.InfoReader +open FSharp.Compiler.TypeRelations //-------------------------------------------------------------------------- // TestHooks - for dumping range to support source transforms @@ -2103,8 +2103,7 @@ let CheckEntityDefn cenv env (tycon:Entity) = let m = (match minfo.ArbitraryValRef with None -> m | Some vref -> vref.DefinitionRange) let parentMethsOfSameName = getHash hashOfAllVirtualMethsInParent nm let checkForDup erasureFlag minfo2 = MethInfosEquivByNameAndSig erasureFlag true g cenv.amap m minfo minfo2 - //if minfo.NumArgs.Length > 1 then - // warning(Error(sprintf "Abstract methods taking curried arguments Duplicate method. The method '%s' has curried arguments but has the same name as another method in this type. Methods with curried arguments may not be overloaded" nm,(match minfo.ArbitraryValRef with None -> m | Some vref -> vref.DefinitionRange))) + if parentMethsOfSameName |> List.exists (checkForDup EraseAll) then if parentMethsOfSameName |> List.exists (checkForDup EraseNone) then errorR(Error(FSComp.SR.chkDuplicateMethodInheritedType(nm),m)) diff --git a/src/fsharp/PostInferenceChecks.fsi b/src/fsharp/PostInferenceChecks.fsi index 62ad52d449..54f4ba7db1 100644 --- a/src/fsharp/PostInferenceChecks.fsi +++ b/src/fsharp/PostInferenceChecks.fsi @@ -2,13 +2,13 @@ /// Implements a set of checks on the TAST for a file that can only be performed after type inference /// is complete. -module internal Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks +module internal FSharp.Compiler.PostTypeCheckSemanticChecks -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.Import +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals val testFlagMemberBody : bool ref diff --git a/src/fsharp/PrettyNaming.fs b/src/fsharp/PrettyNaming.fs index 923be2ccea..6f5222b7d4 100755 --- a/src/fsharp/PrettyNaming.fs +++ b/src/fsharp/PrettyNaming.fs @@ -5,15 +5,15 @@ //-------------------------------------------------------------------------- /// Anything to do with special names of identifiers and other lexical rules -module public Microsoft.FSharp.Compiler.PrettyNaming +module public FSharp.Compiler.PrettyNaming open System open System.Collections.Generic open System.Collections.Concurrent open System.Globalization open System.Text - open Microsoft.FSharp.Compiler - open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library + open FSharp.Compiler + open FSharp.Compiler.AbstractIL.Internal.Library open Internal.Utilities open Internal.Utilities.StructuredFormat diff --git a/src/fsharp/QuotationPickler.fs b/src/fsharp/QuotationPickler.fs index 79c2ac2796..7cd8cb9918 100755 --- a/src/fsharp/QuotationPickler.fs +++ b/src/fsharp/QuotationPickler.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.QuotationPickler +module internal FSharp.Compiler.QuotationPickler open System.Text open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler +open FSharp.Compiler.Lib let mkRLinear mk (vs,body) = List.foldBack (fun v acc -> mk (v,acc)) vs body diff --git a/src/fsharp/QuotationPickler.fsi b/src/fsharp/QuotationPickler.fsi index da37b63de2..ffe2321588 100755 --- a/src/fsharp/QuotationPickler.fsi +++ b/src/fsharp/QuotationPickler.fsi @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Code to pickle out quotations in the quotation binary format. -module internal Microsoft.FSharp.Compiler.QuotationPickler +module internal FSharp.Compiler.QuotationPickler #nowarn "1178" // The struct, record or union type 'internal_instr_extension' is not structurally comparable because the type open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Bytes -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Bytes +open FSharp.Compiler +open FSharp.Compiler.Lib type TypeData type TypeVarData = { tvName: string } diff --git a/src/fsharp/QuotationTranslator.fs b/src/fsharp/QuotationTranslator.fs index b0f1e7ce4c..ab7d63348d 100755 --- a/src/fsharp/QuotationTranslator.fs +++ b/src/fsharp/QuotationTranslator.fs @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.QuotationTranslator +module internal FSharp.Compiler.QuotationTranslator open Internal.Utilities -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.Ast +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Range open System.Collections.Generic -module QP = Microsoft.FSharp.Compiler.QuotationPickler +module QP = FSharp.Compiler.QuotationPickler let verboseCReflect = condition "VERBOSE_CREFLECT" diff --git a/src/fsharp/QuotationTranslator.fsi b/src/fsharp/QuotationTranslator.fsi index 2558b6f768..184f1d3da4 100755 --- a/src/fsharp/QuotationTranslator.fsi +++ b/src/fsharp/QuotationTranslator.fsi @@ -2,14 +2,14 @@ // Convert quoted TAST data structures to structures ready for pickling -module internal Microsoft.FSharp.Compiler.QuotationTranslator - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.AbstractIL.IL +module internal FSharp.Compiler.QuotationTranslator + +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Import +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.AbstractIL.IL [] type QuotationTranslationEnv = diff --git a/src/fsharp/ReferenceResolver.fs b/src/fsharp/ReferenceResolver.fs index 62fe8c22f6..d9a23ecb2a 100644 --- a/src/fsharp/ReferenceResolver.fs +++ b/src/fsharp/ReferenceResolver.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler module public ReferenceResolver = diff --git a/src/fsharp/SignatureConformance.fs b/src/fsharp/SignatureConformance.fs index ac0c23e970..a9db8a883a 100644 --- a/src/fsharp/SignatureConformance.fs +++ b/src/fsharp/SignatureConformance.fs @@ -2,23 +2,23 @@ /// Primary relations on types and signatures, with the exception of /// constraint solving and method overload resolution. -module internal Microsoft.FSharp.Compiler.SignatureConformance +module internal FSharp.Compiler.SignatureConformance open System.Text -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif @@ -151,14 +151,26 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = and checkTypeDef (aenv: TypeEquivEnv) (implTycon:Tycon) (sigTycon:Tycon) = let m = implTycon.Range + // Propagate defn location information from implementation to signature . sigTycon.SetOtherRange (implTycon.Range, true) implTycon.SetOtherRange (sigTycon.Range, false) - if implTycon.LogicalName <> sigTycon.LogicalName then (errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleNamesDiffer(implTycon.TypeOrMeasureKind.ToString(),sigTycon.LogicalName,implTycon.LogicalName),m)); false) else - if implTycon.CompiledName <> sigTycon.CompiledName then (errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleNamesDiffer(implTycon.TypeOrMeasureKind.ToString(),sigTycon.CompiledName,implTycon.CompiledName),m)); false) else + + if implTycon.LogicalName <> sigTycon.LogicalName then + errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleNamesDiffer(implTycon.TypeOrMeasureKind.ToString(),sigTycon.LogicalName,implTycon.LogicalName),m)) + false + else + + if implTycon.CompiledName <> sigTycon.CompiledName then + errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleNamesDiffer(implTycon.TypeOrMeasureKind.ToString(),sigTycon.CompiledName,implTycon.CompiledName),m)) + false + else + checkExnInfo (fun f -> ExnconstrNotContained(denv,implTycon,sigTycon,f)) aenv implTycon.ExceptionInfo sigTycon.ExceptionInfo && + let implTypars = implTycon.Typars m let sigTypars = sigTycon.Typars m + if implTypars.Length <> sigTypars.Length then errorR (Error(FSComp.SR.DefinitionsInSigAndImplNotCompatibleParameterCountsDiffer(implTycon.TypeOrMeasureKind.ToString(),implTycon.DisplayName),m)) false @@ -430,8 +442,15 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = and checkVirtualSlots denv m (implTycon:Tycon) implAbstractSlots sigAbstractSlots = let m1 = NameMap.ofKeyedList (fun (v:ValRef) -> v.DisplayName) implAbstractSlots let m2 = NameMap.ofKeyedList (fun (v:ValRef) -> v.DisplayName) sigAbstractSlots - (m1,m2) ||> NameMap.suball2 (fun _s vref -> errorR(Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInImpl(implTycon.TypeOrMeasureKind.ToString(), implTycon.DisplayName, NicePrint.stringValOrMember denv vref.Deref),m)); false) (fun _x _y -> true) && - (m2,m1) ||> NameMap.suball2 (fun _s vref -> errorR(Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInSig(implTycon.TypeOrMeasureKind.ToString(), implTycon.DisplayName, NicePrint.stringValOrMember denv vref.Deref),m)); false) (fun _x _y -> true) + (m1,m2) ||> NameMap.suball2 (fun _s vref -> + let kindText = implTycon.TypeOrMeasureKind.ToString() + let valText = NicePrint.stringValOrMember denv vref.Deref + errorR(Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInImpl(kindText, implTycon.DisplayName, valText),m)); false) (fun _x _y -> true) && + + (m2,m1) ||> NameMap.suball2 (fun _s vref -> + let kindText = implTycon.TypeOrMeasureKind.ToString() + let valText = NicePrint.stringValOrMember denv vref.Deref + errorR(Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInSig(kindText, implTycon.DisplayName, valText),m)); false) (fun _x _y -> true) and checkClassFields isStruct m aenv (implTycon:Tycon) (implFields:TyconRecdFields) (sigFields:TyconRecdFields) = let implFields = implFields.TrueFieldsAsList @@ -590,11 +609,7 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) = // for each formal requirement, try to find a precisely matching actual requirement let matchingPairs = fvs |> List.choose (fun fv -> - match avs |> List.tryFind (fun av -> - let res = valLinkageAEquiv g aenv av fv - //if res then printfn "%s" (bufs (fun buf -> Printf.bprintf buf "YES MATCH: fv '%a', av '%a'" (NicePrint.outputQualifiedValOrMember denv) fv (NicePrint.outputQualifiedValOrMember denv) av)) - //else printfn "%s" (bufs (fun buf -> Printf.bprintf buf "NO MATCH: fv '%a', av '%a'" (NicePrint.outputQualifiedValOrMember denv) fv (NicePrint.outputQualifiedValOrMember denv) av)) - res) with + match avs |> List.tryFind (fun av -> valLinkageAEquiv g aenv av fv) with | None -> None | Some av -> Some(fv,av)) diff --git a/src/fsharp/SimulatedMSBuildReferenceResolver.fs b/src/fsharp/SimulatedMSBuildReferenceResolver.fs index 6fd5fc5312..387611b6c3 100644 --- a/src/fsharp/SimulatedMSBuildReferenceResolver.fs +++ b/src/fsharp/SimulatedMSBuildReferenceResolver.fs @@ -3,16 +3,16 @@ #if INTERACTIVE #load "../utils/ResizeArray.fs" "../absil/illib.fs" "../fsharp/ReferenceResolver.fs" #else -module internal Microsoft.FSharp.Compiler.SimulatedMSBuildReferenceResolver +module internal FSharp.Compiler.SimulatedMSBuildReferenceResolver #endif open System open System.IO open System.Reflection open Microsoft.Win32 -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.ReferenceResolver -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.ReferenceResolver +open FSharp.Compiler.AbstractIL.Internal.Library let internal SimulatedMSBuildResolver = let supportedFrameworks = [| @@ -147,13 +147,14 @@ let internal SimulatedMSBuildResolver = match n.Version, n.GetPublicKeyToken() with | null, _ | _,null -> let options = - [ for gacdir in Directory.EnumerateDirectories(gac) do - let assdir = Path.Combine(gacdir,n.Name) - if Directory.Exists(assdir) then - for tdir in Directory.EnumerateDirectories(assdir) do - let trialPath = Path.Combine(tdir,qual) - if FileSystem.SafeExists(trialPath) then - yield trialPath ] + [ if Directory.Exists(gac) then + for gacdir in Directory.EnumerateDirectories(gac) do + let assemblyDir = Path.Combine(gacdir,n.Name) + if Directory.Exists(assemblyDir) then + for tdir in Directory.EnumerateDirectories(assemblyDir) do + let trialPath = Path.Combine(tdir,qual) + if FileSystem.SafeExists(trialPath) then + yield trialPath ] //printfn "sorting GAC paths: %A" options options |> List.sort // puts latest version last @@ -161,21 +162,22 @@ let internal SimulatedMSBuildResolver = |> function None -> () | Some p -> success p | v,tok -> - for gacdir in Directory.EnumerateDirectories(gac) do - //printfn "searching GAC directory: %s" gacdir - let assdir = Path.Combine(gacdir,n.Name) - if Directory.Exists(assdir) then - //printfn "searching GAC directory: %s" assdir - - let tokText = String.concat "" [| for b in tok -> sprintf "%02x" b |] - let verdir = Path.Combine(assdir,"v4.0_"+v.ToString()+"__"+tokText) - //printfn "searching GAC directory: %s" verdir - - if Directory.Exists(verdir) then - let trialPath = Path.Combine(verdir,qual) - //printfn "searching GAC: %s" trialPath - if FileSystem.SafeExists(trialPath) then - success trialPath + if Directory.Exists(gac) then + for gacdir in Directory.EnumerateDirectories(gac) do + //printfn "searching GAC directory: %s" gacdir + let assemblyDir = Path.Combine(gacdir,n.Name) + if Directory.Exists(assemblyDir) then + //printfn "searching GAC directory: %s" assemblyDir + + let tokText = String.concat "" [| for b in tok -> sprintf "%02x" b |] + let verdir = Path.Combine(assemblyDir,"v4.0_"+v.ToString()+"__"+tokText) + //printfn "searching GAC directory: %s" verdir + + if Directory.Exists(verdir) then + let trialPath = Path.Combine(verdir,qual) + //printfn "searching GAC: %s" trialPath + if FileSystem.SafeExists(trialPath) then + success trialPath with e -> logWarningOrError false "SR001" (e.ToString()) #endif @@ -187,7 +189,7 @@ let internal GetBestAvailableResolver() = // Detect if MSBuild is on the machine, if so use the resolver from there let mb = try Assembly.Load(sprintf "Microsoft.Build.Framework, Version=%s.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" v) |> Option.ofObj with _ -> None let assembly = mb |> Option.bind (fun _ -> try Assembly.Load(sprintf "FSharp.Compiler.Service.MSBuild.v%s" v) |> Option.ofObj with _ -> None) - let ty = assembly |> Option.bind (fun a -> a.GetType("Microsoft.FSharp.Compiler.MSBuildReferenceResolver") |> Option.ofObj) + let ty = assembly |> Option.bind (fun a -> a.GetType("FSharp.Compiler.MSBuildReferenceResolver") |> Option.ofObj) let obj = ty |> Option.bind (fun ty -> ty.InvokeMember("get_Resolver",BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.InvokeMethod ||| BindingFlags.NonPublic, null, null, [| |]) |> Option.ofObj) let resolver = obj |> Option.bind (fun obj -> match obj with :? Resolver as r -> Some r | _ -> None) resolver @@ -214,7 +216,10 @@ let fscoreDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() let resolve s = - SimulatedMSBuildResolver.Resolve(ResolutionEnvironment.EditingOrCompilation,[| for a in s -> (a, "") |],"v4.5.1", [SimulatedMSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectory + @"\v4.5.1" ],"", "", fscoreDir,[],__SOURCE_DIRECTORY__,ignore, (fun _ _ -> ()), (fun _ _-> ())) + SimulatedMSBuildResolver.Resolve + (ResolutionEnvironment.EditingOrCompilation,[| for a in s -> (a, "") |],"v4.5.1", + [SimulatedMSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectory + @"\v4.5.1" ],"", "", + fscoreDir,[],__SOURCE_DIRECTORY__,ignore, (fun _ _ -> ()), (fun _ _-> ())) // Resolve partial name to something on search path resolve ["FSharp.Core" ] diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 23242b1aff..3fb3e816e0 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -1,29 +1,29 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Defines derived expression manipulation and construction functions. -module internal Microsoft.FSharp.Compiler.Tastops +module internal FSharp.Compiler.Tastops open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Rational +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Lib +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Layout +open FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.PrettyNaming #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif //--------------------------------------------------------------------------- @@ -3174,7 +3174,7 @@ let (|TypeDefOfExpr|_|) g expr = //--------------------------------------------------------------------------- module DebugPrint = begin - open Microsoft.FSharp.Compiler.Layout + open FSharp.Compiler.Layout open PrettyTypes let layoutRanges = ref false @@ -3418,10 +3418,13 @@ module DebugPrint = begin ^^ (if v.IsMutable then wordL(tagText "mutable ") else emptyL) ^^ wordL (tagText ":")) -- typeL v.Type - let tslotparamL(TSlotParam(nmOpt, ty, inFlag, outFlag, _, _)) = - (optionL (tagText >> wordL) nmOpt) ^^ wordL(tagText ":") ^^ typeL ty ^^ (if inFlag then wordL(tagText "[in]") else emptyL) ^^ (if outFlag then wordL(tagText "[out]") else emptyL) ^^ (if inFlag then wordL(tagText "[opt]") else emptyL) - + (optionL (tagText >> wordL) nmOpt) ^^ + wordL(tagText ":") ^^ + typeL ty ^^ + (if inFlag then wordL(tagText "[in]") else emptyL) ^^ + (if outFlag then wordL(tagText "[out]") else emptyL) ^^ + (if inFlag then wordL(tagText "[opt]") else emptyL) let slotSigL (slotsig:SlotSig) = #if DEBUG @@ -3452,10 +3455,6 @@ module DebugPrint = begin let unionCaseRefL (ucr:UnionCaseRef) = wordL (tagText ucr.CaseName) let recdFieldRefL (rfref:RecdFieldRef) = wordL (tagText rfref.FieldName) - //-------------------------------------------------------------------------- - // DEBUG layout - bind, expr, dtree etc. - //-------------------------------------------------------------------------- - let identL (id:Ident) = wordL (tagText id.idText) // Note: We need nice printing of constants in order to print literals and attributes diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index badacfda0e..c719406d5a 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Defines derived expression manipulation and construction functions. -module internal Microsoft.FSharp.Compiler.Tastops +module internal FSharp.Compiler.Tastops open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Layout +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Rational +open FSharp.Compiler.Ast +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Layout //------------------------------------------------------------------------- // Type equivalence diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index 14998cc882..d0504a5982 100755 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -1,25 +1,25 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.TastPickle +module internal FSharp.Compiler.TastPickle open System.Collections.Generic open System.Text open Internal.Utilities -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Lib.Bits -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.Lib.Bits +open FSharp.Compiler.Range +open FSharp.Compiler.Rational +open FSharp.Compiler.Ast +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.ErrorLogger let verbose = false @@ -227,22 +227,36 @@ let p_single i st = p_int32 (bits_of_float32 i) st let p_double i st = p_int64 (bits_of_float i) st let p_ieee64 i st = p_int64 (bits_of_float i) st let p_char i st = p_uint16 (uint16 (int32 i)) st -let inline p_tup2 p1 p2 (a,b) (st:WriterState) = (p1 a st : unit); (p2 b st : unit) -let inline p_tup3 p1 p2 p3 (a,b,c) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit) -let inline p_tup4 p1 p2 p3 p4 (a,b,c,d) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit) -let inline p_tup5 p1 p2 p3 p4 p5 (a,b,c,d,e) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit) -let inline p_tup6 p1 p2 p3 p4 p5 p6 (a,b,c,d,e,f) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit) -let inline p_tup7 p1 p2 p3 p4 p5 p6 p7 (a,b,c,d,e,f,x7) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit) -let inline p_tup8 p1 p2 p3 p4 p5 p6 p7 p8 (a,b,c,d,e,f,x7,x8) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit) -let inline p_tup9 p1 p2 p3 p4 p5 p6 p7 p8 p9 (a,b,c,d,e,f,x7,x8,x9) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit) -let inline p_tup10 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 (a,b,c,d,e,f,x7,x8,x9,x10) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit) -let inline p_tup11 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 (a,b,c,d,e,f,x7,x8,x9,x10,x11) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit) -let inline p_tup12 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit) -let inline p_tup13 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12,x13) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit); (p13 x13 st : unit) -let inline p_tup14 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12,x13,x14) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit); (p13 x13 st : unit) ; (p14 x14 st : unit) -let inline p_tup15 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12,x13,x14,x15) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit); (p13 x13 st : unit) ; (p14 x14 st : unit); (p15 x15 st : unit) -let inline p_tup16 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit); (p13 x13 st : unit) ; (p14 x14 st : unit); (p15 x15 st : unit); (p16 x16 st : unit) -let inline p_tup17 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 (a,b,c,d,e,f,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17) (st:WriterState) = (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit); (p12 x12 st : unit); (p13 x13 st : unit) ; (p14 x14 st : unit); (p15 x15 st : unit); (p16 x16 st : unit); (p17 x17 st : unit) + +let inline p_tup2 p1 p2 (a,b) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit) + +let inline p_tup3 p1 p2 p3 (a,b,c) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit) + +let inline p_tup4 p1 p2 p3 p4 (a,b,c,d) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit) + +let inline p_tup5 p1 p2 p3 p4 p5 (a,b,c,d,e) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit) + +let inline p_tup6 p1 p2 p3 p4 p5 p6 (a,b,c,d,e,f) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit) + +let inline p_tup7 p1 p2 p3 p4 p5 p6 p7 (a,b,c,d,e,f,x7) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit) + +let inline p_tup8 p1 p2 p3 p4 p5 p6 p7 p8 (a,b,c,d,e,f,x7,x8) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit) + +let inline p_tup9 p1 p2 p3 p4 p5 p6 p7 p8 p9 (a,b,c,d,e,f,x7,x8,x9) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit) + +let inline p_tup10 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 (a,b,c,d,e,f,x7,x8,x9,x10) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit) + +let inline p_tup11 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 (a,b,c,d,e,f,x7,x8,x9,x10,x11) (st:WriterState) = + (p1 a st : unit); (p2 b st : unit); (p3 c st : unit); (p4 d st : unit); (p5 e st : unit); (p6 f st : unit); (p7 x7 st : unit); (p8 x8 st : unit); (p9 x9 st : unit); (p10 x10 st : unit); (p11 x11 st : unit) let u_byte st = int (st.is.ReadByte()) @@ -406,7 +420,13 @@ let inline u_tup17 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 (s let p_osgn_ref (_ctxt:string) (outMap : NodeOutTable<_,_>) x st = let idx = outMap.Table.FindOrAdd (outMap.NodeStamp x) //if ((idx = 0) && outMap.Name = "oentities") then - // System.Diagnostics.Debug.Assert(false, sprintf "idx %d#%d in table %s has name '%s', was defined at '%s' and is referenced from context %s\n" idx (outMap.NodeStamp x) outMap.Name (outMap.NodeName x) (stringOfRange (outMap.GetRange x)) _ctxt) + // let msg = + // sprintf "idx %d#%d in table %s has name '%s', was defined at '%s' and is referenced from context %s\n" + // idx (outMap.NodeStamp x) + // outMap.Name (outMap.NodeName x) + // (stringOfRange (outMap.GetRange x)) + // _ctxt + // System.Diagnostics.Debug.Assert(false, msg ) p_int idx st let p_osgn_decl (outMap : NodeOutTable<_,_>) p x st = @@ -806,7 +826,10 @@ let check (ilscope:ILScopeRef) (inMap : NodeInTable<_,_>) = let n = inMap.Get i if not (inMap.IsLinked n) then warning(Error(FSComp.SR.pickleMissingDefinition (i, inMap.Name, ilscope.QualifiedName), range0)) - // Note for compiler developers: to get information about which item this index relates to, enable the conditional in Pickle.p_osgn_ref to refer to the given index number and recompile an identical copy of the source for the DLL containing the data being unpickled. A message will then be printed indicating the name of the item.\n" + // Note for compiler developers: to get information about which item this index relates to, + // enable the conditional in Pickle.p_osgn_ref to refer to the given index number and recompile + // an identical copy of the source for the DLL containing the data being unpickled. A message will + // then be printed indicating the name of the item. let unpickleObjWithDanglingCcus file ilscope (iILModule:ILModuleDef option) u (phase2bytes:byte[]) = let st2 = @@ -2122,7 +2145,16 @@ and u_entity_spec_data st : Entity = entity_opt_data= match x2b, x10b, x15, x8, x4a, x4b, x14 with | None, TyparKind.Type, None, None, TAccess [], TAccess [], TExnNone -> None - | _ -> Some { Entity.EmptyEntityOptData with entity_compiled_name = x2b; entity_kind = x10b; entity_xmldoc= defaultArg x15 XmlDoc.Empty; entity_xmldocsig = System.String.Empty; entity_tycon_abbrev = x8; entity_accessiblity = x4a; entity_tycon_repr_accessibility = x4b; entity_exn_info = x14 } + | _ -> + Some { Entity.NewEmptyEntityOptData() with + entity_compiled_name = x2b + entity_kind = x10b + entity_xmldoc= defaultArg x15 XmlDoc.Empty + entity_xmldocsig = System.String.Empty + entity_tycon_abbrev = x8 + entity_accessiblity = x4a + entity_tycon_repr_accessibility = x4b + entity_exn_info = x14 } } and u_tcaug st = diff --git a/src/fsharp/TastPickle.fsi b/src/fsharp/TastPickle.fsi index 97eab4b30b..9f1000580a 100644 --- a/src/fsharp/TastPickle.fsi +++ b/src/fsharp/TastPickle.fsi @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Defines the framework for serializing and de-serializing TAST data structures as binary blobs for the F# metadata format. -module internal Microsoft.FSharp.Compiler.TastPickle +module internal FSharp.Compiler.TastPickle open Internal.Utilities -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals /// Represents deserialized data with a dangling set of CCU fixup thunks indexed by name [] diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index 85f12f8b3f..86cea705ba 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -6,22 +6,22 @@ /// into the compiler. This lets the compiler perform particular optimizations /// for these types and values, for example emitting optimized calls for /// comparison and hashing functions. -module internal Microsoft.FSharp.Compiler.TcGlobals +module internal FSharp.Compiler.TcGlobals open System.Collections.Generic open System.Diagnostics -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Internal.Library + +open FSharp.Compiler.Tast +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming open Internal.Utilities diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index a20b3743ca..b5391bde5a 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -2,43 +2,43 @@ /// The typechecker. Left-to-right constrained type checking /// with generalization at appropriate points. -module internal Microsoft.FSharp.Compiler.TypeChecker +module internal FSharp.Compiler.TypeChecker open System open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.ResultOrException -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Rational -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.PatternMatchCompilation -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.TypeRelations -open Microsoft.FSharp.Compiler.MethodCalls -open Microsoft.FSharp.Compiler.MethodOverrides -open Microsoft.FSharp.Compiler.ConstraintSolver -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.InfoReader +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library.ResultOrException +open FSharp.Compiler.AbstractIL.Diagnostics + +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Rational +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.PatternMatchCompilation +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.TypeRelations +open FSharp.Compiler.MethodCalls +open FSharp.Compiler.MethodOverrides +open FSharp.Compiler.ConstraintSolver +open FSharp.Compiler.NameResolution +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.InfoReader #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif //------------------------------------------------------------------------- @@ -1401,8 +1401,12 @@ let CheckForAbnormalOperatorNames cenv (idRange:range) coreDisplayName (memberIn warning(StandardOperatorRedefinitionWarning(FSComp.SR.tcInvalidMemberNameFixedTypes opName, idRange)) | PrettyNaming.Other -> () -let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValScheme(id, typeScheme, topValData, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, compgen, isIncrClass, isTyFunc, hasDeclaredTypars)), attrs, doc, konst, isGeneratedEventVal) = +let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, vscheme, attrs, doc, konst, isGeneratedEventVal) = + + let (ValScheme(id, typeScheme, topValData, memberInfoOpt, isMutable, inlineFlag, baseOrThis, vis, compgen, isIncrClass, isTyFunc, hasDeclaredTypars)) = vscheme + let ty = GeneralizedTypeForTypeScheme typeScheme + let m = id.idRange let isTopBinding = @@ -1413,6 +1417,7 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche | _ -> false let isExtrinsic = (declKind = ExtrinsicExtensionBinding) + let actualParent, overrideVis = // Use the parent of the member if it's available // If it's an extrinsic extension member or not a member then use the containing module. @@ -1509,21 +1514,26 @@ let MakeAndPublishVal cenv env (altActualParent, inSig, declKind, vrec, (ValSche PublishValueDefn cenv env declKind vspec + let shouldNotifySink (vspec: Val) = + match vspec.MemberInfo with + // `this` reference named `__`. It's either: + // * generated by compiler for auto properties or + // * provided by source code (i.e. `member __.Method = ...`) + // We don't notify sink about it to prevent generating `FSharpSymbol` for it and appearing in completion list. + | None when + let baseOrThisInfo = vspec.BaseOrThisInfo + baseOrThisInfo = ValBaseOrThisInfo.BaseVal || // visualfsharp#3699 + baseOrThisInfo = ValBaseOrThisInfo.MemberThisVal && vspec.LogicalName = "__" -> false + | _ -> true + match cenv.tcSink.CurrentSink with - | None -> () - | Some _ -> - if not vspec.IsCompilerGenerated then - match vspec.MemberInfo with - // `this` reference named `__`. It's either: - // * generated by compiler for auto properties or - // * provided by source code (i.e. `member __.Method = ...`) - // We don't notify sink about it to prevent generating `FSharpSymbol` for it and appearing in completion list. - | None when vspec.BaseOrThisInfo = ValBaseOrThisInfo.MemberThisVal && vspec.LogicalName = "__" -> () - | _ -> - let nenv = AddFakeNamedValRefToNameEnv vspec.DisplayName env.NameEnv (mkLocalValRef vspec) - CallEnvSink cenv.tcSink (vspec.Range, nenv, env.eAccessRights) - let item = Item.Value(mkLocalValRef vspec) - CallNameResolutionSink cenv.tcSink (vspec.Range, nenv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights) + | Some _ when not vspec.IsCompilerGenerated && shouldNotifySink vspec -> + let nenv = AddFakeNamedValRefToNameEnv vspec.DisplayName env.NameEnv (mkLocalValRef vspec) + CallEnvSink cenv.tcSink (vspec.Range, nenv, env.eAccessRights) + let item = Item.Value(mkLocalValRef vspec) + CallNameResolutionSink cenv.tcSink (vspec.Range, nenv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights) + | _ -> () + vspec let MakeAndPublishVals cenv env (altActualParent, inSig, declKind, vrec, valSchemes, attrs, doc, konst) = @@ -4569,6 +4579,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv:SyntacticUnscoped | SynType.LongIdent(LongIdentWithDots([], _)) -> // special case when type name is absent - i.e. empty inherit part in type declaration cenv.g.obj_ty, tpenv + | SynType.LongIdent(LongIdentWithDots(tc, _) as lidwd) -> let m = lidwd.Range let ad = env.eAccessRights @@ -4587,14 +4598,21 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv:SyntacticUnscoped | SynType.App (SynType.LongIdent(LongIdentWithDots(tc, _)), _, args, _commas, _, postfix, m) -> let ad = env.eAccessRights - let tcref = ForceRaise(ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInType OpenQualified env.eNameResEnv ad tc (TypeNameResolutionStaticArgsInfo.FromTyArgs args.Length) PermitDirectReferenceToGeneratedType.No) + + let tcref = + let tyResInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs args.Length + ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.UseInType OpenQualified env.eNameResEnv ad tc tyResInfo PermitDirectReferenceToGeneratedType.No + |> ForceRaise + match optKind, tcref.TypeOrMeasureKind with | Some TyparKind.Type, TyparKind.Measure -> error(Error(FSComp.SR.tcExpectedTypeNotUnitOfMeasure(), m)) NewErrorType (), tpenv + | Some TyparKind.Measure, TyparKind.Type -> error(Error(FSComp.SR.tcExpectedUnitOfMeasureNotType(), m)) TType_measure (NewErrorMeasure ()), tpenv + | _, TyparKind.Type -> if postfix && tcref.Typars(m) |> List.exists (fun tp -> match tp.Kind with TyparKind.Measure -> true | _ -> false) then error(Error(FSComp.SR.tcInvalidUnitsOfMeasurePrefix(), m)) @@ -4688,12 +4706,13 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv:SyntacticUnscoped | _ -> errorR(Error(FSComp.SR.parsInvalidLiteralInType(), m)) NewErrorType (), tpenv + | SynType.StaticConstantNamed (_, _, m) + | SynType.StaticConstantExpr (_, m) -> errorR(Error(FSComp.SR.parsInvalidLiteralInType(), m)) NewErrorType (), tpenv - | SynType.MeasurePower(ty, exponent, m) -> match optKind with | Some TyparKind.Type -> @@ -4720,7 +4739,7 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv:SyntacticUnscoped let ms2, tpenv = TcMeasure cenv newOk checkCxs occ env tpenv arg2 m TType_measure (Measure.Prod(ms1, ms2)), tpenv - | _, _, _ -> + | _ -> errorR(Error(FSComp.SR.tcTypeParameterInvalidAsTypeConstructor(), m)) NewErrorType (), tpenv @@ -4739,11 +4758,10 @@ and TcMeasure cenv newOk checkCxs occ env (tpenv:SyntacticUnscopedTyparEnv) ty m | _ -> match TcTypeOrMeasure (Some TyparKind.Measure) cenv newOk checkCxs occ env tpenv ty with | TType_measure ms, tpenv -> ms, tpenv - | _, _ -> + | _ -> error(Error(FSComp.SR.tcExpectedUnitOfMeasureNotType(), m)) NewErrorMeasure (), tpenv - and TcAnonTypeOrMeasure optKind _cenv rigid dyn newOk m = if newOk = NoNewTypars then errorR (Error(FSComp.SR.tcAnonymousTypeInvalidInDeclaration(), m)) let rigid = (if rigid = TyparRigidity.Anon && newOk = NewTyparsOKButWarnIfNotRigid then TyparRigidity.WarnIfNotRigid else rigid) @@ -4773,7 +4791,6 @@ and TcMeasuresAsTuple cenv newOk checkCxs occ env (tpenv:SyntacticUnscopedTyparE gather args tpenv nextisquot (if isquot then Measure.Prod(acc, Measure.Inv ms1) else Measure.Prod(acc, ms1)) gather args tpenv false Measure.One - and TcTypesOrMeasures optKinds cenv newOk checkCxs occ env tpenv args m = match optKinds with | None -> @@ -7878,7 +7895,9 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv let _, _, vspecs, envinner, _ = TcMatchPattern cenv (NewInferenceType()) env tpenv (pat, None) vspecs, envinner) - Some (trans true q varSpace innerComp (fun holeFill -> translatedCtxt (mkSynCall "For" mFor [wrappedSourceExpr; SynExpr.MatchLambda(false, sourceExpr.Range, [Clause(pat, None, holeFill, mPat, SequencePointAtTarget)], spBind, mFor) ])) ) + Some (trans true q varSpace innerComp + (fun holeFill -> + translatedCtxt (mkSynCall "For" mFor [wrappedSourceExpr; SynExpr.MatchLambda(false, sourceExpr.Range, [Clause(pat, None, holeFill, mPat, SequencePointAtTarget)], spBind, mFor) ])) ) | SynExpr.For (spBind, id, start, dir, finish, innerComp, m) -> let mFor = match spBind with SequencePointAtForLoop m -> m | _ -> m @@ -11024,7 +11043,9 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (synBinds, synBinds [] else let freeInEnv = lazyFreeInEnv.Force() - GeneralizationHelpers.ComputeAndGeneralizeGenericTypars(cenv, denv, m, freeInEnv, canInferTypars, GeneralizationHelpers.CanGeneralizeConstrainedTyparsForDecl(declKind), inlineFlag, Some rhsExpr, allDeclaredTypars, maxInferredTypars, tauTy, false) + let canConstrain = GeneralizationHelpers.CanGeneralizeConstrainedTyparsForDecl(declKind) + GeneralizationHelpers.ComputeAndGeneralizeGenericTypars + (cenv, denv, m, freeInEnv, canInferTypars, canConstrain, inlineFlag, Some rhsExpr, allDeclaredTypars, maxInferredTypars, tauTy, false) let prelimValSchemes2 = GeneralizeVals cenv denv enclosingDeclaredTypars generalizedTypars nameToPrelimValSchemeMap @@ -11086,7 +11107,8 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (synBinds, synBinds // Add the compilation of the pattern to the bodyExpr we get from mkCleanup let mkPatBind (bodyExpr, bodyExprTy) = let valsDefinedByMatching = ListSet.remove valEq patternInputTmp allValsDefinedByPattern - let matchx = CompilePatternForMatch cenv env m m true ThrowIncompleteMatchException (patternInputTmp, generalizedTypars, Some rhsExpr) [TClause(checkedPat2, None, TTarget(valsDefinedByMatching, bodyExpr, SuppressSequencePointAtTarget), m)] tauTy bodyExprTy + let clauses = [TClause(checkedPat2, None, TTarget(valsDefinedByMatching, bodyExpr, SuppressSequencePointAtTarget), m)] + let matchx = CompilePatternForMatch cenv env m m true ThrowIncompleteMatchException (patternInputTmp, generalizedTypars, Some rhsExpr) clauses tauTy bodyExprTy let matchx = if (DeclKind.ConvertToLinearBindings declKind) then LinearizeTopMatch cenv.g altActualParent matchx else matchx matchx, bodyExprTy @@ -11339,7 +11361,16 @@ and CheckForNonAbstractInterface declKind tcref memberFlags m = // TcLetrec - AnalyzeAndMakeAndPublishRecursiveValue(s) //------------------------------------------------------------------------ -and AnalyzeRecursiveStaticMemberOrValDecl (cenv, envinner: TcEnv, tpenv, declKind, newslotsOK, overridesOK, tcrefContainerInfo, vis1, id:Ident, vis2, declaredTypars, memberFlagsOpt, thisIdOpt, bindingAttribs, valSynInfo, ty, bindingRhs, mBinding, flex) = +and AnalyzeRecursiveStaticMemberOrValDecl + (cenv, envinner: TcEnv, + tpenv, declKind, + newslotsOK, overridesOK, + tcrefContainerInfo, vis1, + id:Ident, vis2, declaredTypars, + memberFlagsOpt, thisIdOpt, + bindingAttribs, valSynInfo, ty, + bindingRhs, mBinding, flex) = + let vis = CombineVisibilityAttribs vis1 vis2 mBinding // Check if we're defining a member, in which case generate the internal unique @@ -11404,7 +11435,12 @@ and AnalyzeRecursiveStaticMemberOrValDecl (cenv, envinner: TcEnv, tpenv, declKin envinner, tpenv, id, None, None, vis, vis2, None, [], None, flex, bindingRhs, declaredTypars -and AnalyzeRecursiveInstanceMemberDecl (cenv, envinner: TcEnv, tpenv, declKind, synTyparDecls, valSynInfo, flex:ExplicitTyparInfo, newslotsOK, overridesOK, vis1, thisId, memberId:Ident, toolId:Ident option, bindingAttribs, vis2, tcrefContainerInfo, memberFlagsOpt, ty, bindingRhs, mBinding) = +and AnalyzeRecursiveInstanceMemberDecl + (cenv, envinner: TcEnv, tpenv, declKind, synTyparDecls, valSynInfo, + flex:ExplicitTyparInfo, newslotsOK, overridesOK, vis1, thisId, + memberId:Ident, toolId:Ident option, bindingAttribs, vis2, + tcrefContainerInfo, memberFlagsOpt, ty, bindingRhs, mBinding) = + let vis = CombineVisibilityAttribs vis1 vis2 mBinding let (ExplicitTyparInfo(_, declaredTypars, infer)) = flex match tcrefContainerInfo, memberFlagsOpt with @@ -11489,10 +11525,20 @@ and AnalyzeRecursiveDecl (cenv, envinner, tpenv, declKind, synTyparDecls, declar analyzeRecursiveDeclPat tpenv (SynPat.Named (SynPat.Wild m, id, false, None, m)) | SynPat.Named (SynPat.Wild _, id, _, vis2, _) -> - AnalyzeRecursiveStaticMemberOrValDecl (cenv, envinner, tpenv, declKind, newslotsOK, overridesOK, tcrefContainerInfo, vis1, id, vis2, declaredTypars, memberFlagsOpt, thisIdOpt, bindingAttribs, valSynInfo, ty, bindingRhs, mBinding, flex) + AnalyzeRecursiveStaticMemberOrValDecl + (cenv, envinner, tpenv, declKind, + newslotsOK, overridesOK, tcrefContainerInfo, + vis1, id, vis2, declaredTypars, + memberFlagsOpt, thisIdOpt, bindingAttribs, + valSynInfo, ty, bindingRhs, mBinding, flex) | SynPat.InstanceMember(thisId, memberId, toolId, vis2, _) -> - AnalyzeRecursiveInstanceMemberDecl (cenv, envinner, tpenv, declKind, synTyparDecls, valSynInfo, flex, newslotsOK, overridesOK, vis1, thisId, memberId, toolId, bindingAttribs, vis2, tcrefContainerInfo, memberFlagsOpt, ty, bindingRhs, mBinding) + AnalyzeRecursiveInstanceMemberDecl + (cenv, envinner, tpenv, declKind, + synTyparDecls, valSynInfo, flex, newslotsOK, + overridesOK, vis1, thisId, memberId, toolId, + bindingAttribs, vis2, tcrefContainerInfo, + memberFlagsOpt, ty, bindingRhs, mBinding) | _ -> error(Error(FSComp.SR.tcOnlySimplePatternsInLetRec(), mBinding)) @@ -13365,7 +13411,9 @@ module MutRecBindingChecking = // ideally we'd have the 'm' of the type declaration stored here, to avoid needing to trim to line to approx error(Error(FSComp.SR.tcTypeAbbreviationsMayNotHaveMembers(), (trimRangeToLine m))) - if tcref.IsEnumTycon && (declKind <> ExtrinsicExtensionBinding) then error(Error(FSComp.SR.tcEnumerationsMayNotHaveMembers(), (trimRangeToLine m))) // ideally we'd have the 'm' of the type declaration stored here, to avoid needing to trim to line to approx + if tcref.IsEnumTycon && (declKind <> ExtrinsicExtensionBinding) then + // ideally we'd have the 'm' of the type declaration stored here, to avoid needing to trim to line to approx + error(Error(FSComp.SR.tcEnumerationsMayNotHaveMembers(), (trimRangeToLine m))) match classMemberDef, containerInfo with | SynMemberDefn.ImplicitCtor (vis, attrs, spats, thisIdOpt, m), ContainerInfo(_, Some(MemberOrValContainerInfo(tcref, _, baseValOpt, safeInitInfo, _))) -> @@ -13526,7 +13574,8 @@ module MutRecBindingChecking = let (tpenv, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) = innerState - let (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, _, uncheckedRecBindsTable) = TcLetrecBinding (cenv, envStatic, scopem, [], None) (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, tpenv, uncheckedRecBindsTable) rbind + let (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, _, uncheckedRecBindsTable) = + TcLetrecBinding (cenv, envStatic, scopem, [], None) (envNonRec, generalizedRecBinds, preGeneralizationRecBinds, tpenv, uncheckedRecBindsTable) rbind let innerState = (tpenv, envStatic, envNonRec, generalizedRecBinds, preGeneralizationRecBinds, uncheckedRecBindsTable) rbind.RecBindingInfo.Index, innerState) @@ -14397,7 +14446,11 @@ module TyconConstraintInference = let newSet = assumedTycons |> Set.filter (fun tyconStamp -> let (tycon, structuralTypes) = tab.[tyconStamp] - if cenv.g.compilingFslib && AugmentWithHashCompare.TyconIsCandidateForAugmentationWithCompare cenv.g tycon && not (HasFSharpAttribute g g.attrib_StructuralComparisonAttribute tycon.Attribs) && not (HasFSharpAttribute g g.attrib_NoComparisonAttribute tycon.Attribs) then + + if cenv.g.compilingFslib && + AugmentWithHashCompare.TyconIsCandidateForAugmentationWithCompare cenv.g tycon && + not (HasFSharpAttribute g g.attrib_StructuralComparisonAttribute tycon.Attribs) && + not (HasFSharpAttribute g g.attrib_NoComparisonAttribute tycon.Attribs) then errorR(Error(FSComp.SR.tcFSharpCoreRequiresExplicit(), tycon.Range)) let res = (structuralTypes |> List.forall (fst >> checkIfFieldTypeSupportsComparison tycon)) @@ -14519,8 +14572,13 @@ module TyconConstraintInference = let newSet = assumedTycons |> Set.filter (fun tyconStamp -> + let (tycon, structuralTypes) = tab.[tyconStamp] - if cenv.g.compilingFslib && AugmentWithHashCompare.TyconIsCandidateForAugmentationWithEquals cenv.g tycon && not (HasFSharpAttribute g g.attrib_StructuralEqualityAttribute tycon.Attribs) && not (HasFSharpAttribute g g.attrib_NoEqualityAttribute tycon.Attribs) then + + if cenv.g.compilingFslib && + AugmentWithHashCompare.TyconIsCandidateForAugmentationWithEquals cenv.g tycon && + not (HasFSharpAttribute g g.attrib_StructuralEqualityAttribute tycon.Attribs) && + not (HasFSharpAttribute g g.attrib_NoEqualityAttribute tycon.Attribs) then errorR(Error(FSComp.SR.tcFSharpCoreRequiresExplicit(), tycon.Range)) // Remove structural types with incomparable elements from the assumedTycons @@ -15730,7 +15788,8 @@ module EstablishTypeDefinitionCores = noAllowNullLiteralAttributeCheck() let vfld = NewRecdField false None (ident("value__", m)) false fieldTy false false [] [] XmlDoc.Empty taccessPublic true - if not (ListSet.contains (typeEquiv cenv.g) fieldTy [ cenv.g.int32_ty; cenv.g.int16_ty; cenv.g.sbyte_ty; cenv.g.int64_ty; cenv.g.char_ty; cenv.g.bool_ty; cenv.g.uint32_ty; cenv.g.uint16_ty; cenv.g.byte_ty; cenv.g.uint64_ty ]) then + let legitEnumTypes = [ cenv.g.int32_ty; cenv.g.int16_ty; cenv.g.sbyte_ty; cenv.g.int64_ty; cenv.g.char_ty; cenv.g.bool_ty; cenv.g.uint32_ty; cenv.g.uint16_ty; cenv.g.byte_ty; cenv.g.uint64_ty ] + if not (ListSet.contains (typeEquiv cenv.g) fieldTy legitEnumTypes) then errorR(Error(FSComp.SR.tcInvalidTypeForLiteralEnumeration(), m)) writeFakeRecordFieldsToSink fields' @@ -17305,7 +17364,7 @@ let rec IterTyconsOfModuleOrNamespaceType f (mty:ModuleOrNamespaceType) = // Defaults get applied in priority order. Defaults listed last get priority 0 (lowest), 2nd last priority 1 etc. let ApplyDefaults cenv g denvAtEnd m mexpr extraAttribs = try - let unsolved = Microsoft.FSharp.Compiler.FindUnsolved.UnsolvedTyparsOfModuleDef g cenv.amap denvAtEnd (mexpr, extraAttribs) + let unsolved = FSharp.Compiler.FindUnsolved.UnsolvedTyparsOfModuleDef g cenv.amap denvAtEnd (mexpr, extraAttribs) GeneralizationHelpers.CanonicalizePartialInferenceProblem (cenv, denvAtEnd, m) unsolved @@ -17357,7 +17416,7 @@ let CheckValueRestriction denvAtEnd rootSigOpt implFileTypePriorToSig m = let SolveInternalUnknowns g cenv denvAtEnd mexpr extraAttribs = - let unsolved = Microsoft.FSharp.Compiler.FindUnsolved.UnsolvedTyparsOfModuleDef g cenv.amap denvAtEnd (mexpr, extraAttribs) + let unsolved = FSharp.Compiler.FindUnsolved.UnsolvedTyparsOfModuleDef g cenv.amap denvAtEnd (mexpr, extraAttribs) unsolved |> List.iter (fun tp -> if (tp.Rigidity <> TyparRigidity.Rigid) && not tp.IsSolved then @@ -17470,10 +17529,18 @@ let TypeCheckOneImplFile // errors we turn off error reporting. This is because it performs various fixups over the TAST, e.g. // assigning nice names for inference variables. let hasExplicitEntryPoint, anonRecdTypes = + conditionallySuppressErrorReporting (checkForErrors()) (fun () -> + try let reportErrors = not (checkForErrors()) - PostTypeCheckSemanticChecks.CheckTopImpl (g, cenv.amap, reportErrors, cenv.infoReader, env.eInternalsVisibleCompPaths, cenv.topCcu, envAtEnd.DisplayEnv, implFileExprAfterSig, extraAttribs, isLastCompiland, isInternalTestSpanStackReferring) + + PostTypeCheckSemanticChecks.CheckTopImpl + (g, cenv.amap, reportErrors, cenv.infoReader, + env.eInternalsVisibleCompPaths, cenv.topCcu, envAtEnd.DisplayEnv, + implFileExprAfterSig, extraAttribs, isLastCompiland, + isInternalTestSpanStackReferring) + with e -> errorRecovery e m false, StampMap.Empty) diff --git a/src/fsharp/TypeChecker.fsi b/src/fsharp/TypeChecker.fsi index aae0954499..09856e0489 100644 --- a/src/fsharp/TypeChecker.fsi +++ b/src/fsharp/TypeChecker.fsi @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.TypeChecker +module internal FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Infos +open FSharp.Compiler.Import +open FSharp.Compiler.TcGlobals open System.Collections.Generic diff --git a/src/fsharp/TypeRelations.fs b/src/fsharp/TypeRelations.fs index 43944d7a92..5b633acb50 100755 --- a/src/fsharp/TypeRelations.fs +++ b/src/fsharp/TypeRelations.fs @@ -2,16 +2,16 @@ /// Primary relations on types and signatures, with the exception of /// constraint solving and method overload resolution. -module internal Microsoft.FSharp.Compiler.TypeRelations +module internal FSharp.Compiler.TypeRelations -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos +open FSharp.Compiler.PrettyNaming //------------------------------------------------------------------------- // a :> b without coercion based on finalized (no type variable) types diff --git a/src/fsharp/UnicodeLexing.fs b/src/fsharp/UnicodeLexing.fs index b6013c0342..f484a5f1a8 100755 --- a/src/fsharp/UnicodeLexing.fs +++ b/src/fsharp/UnicodeLexing.fs @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.UnicodeLexing +module internal FSharp.Compiler.UnicodeLexing //------------------------------------------------------------------ // Functions for Unicode char-based lexing (new code). // -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library open Internal.Utilities open System.IO diff --git a/src/fsharp/UnicodeLexing.fsi b/src/fsharp/UnicodeLexing.fsi index 58f6828c95..9f02c3e197 100755 --- a/src/fsharp/UnicodeLexing.fsi +++ b/src/fsharp/UnicodeLexing.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.UnicodeLexing +module internal FSharp.Compiler.UnicodeLexing open Microsoft.FSharp.Text open Internal.Utilities.Text.Lexing diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index 22b960d18c..dec2779856 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.Ast +module public FSharp.Compiler.Ast open System.Collections.Generic open Internal.Utilities.Text.Lexing open Internal.Utilities.Text.Parsing -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.UnicodeLexing -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.UnicodeLexing +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range /// The prefix of the names used for the fake namespace path added to all dynamic code entries in FSI.EXE let FsiDynamicModulePrefix = "FSI_" @@ -143,7 +143,6 @@ type ParserDetail = // AST: identifiers and long identifiers //----------------------------------------------------------------------- - // PERFORMANCE: consider making this a struct. [] [] @@ -154,6 +153,7 @@ type Ident (text: string, range: range) = override x.ToString() = text type LongIdent = Ident list + type LongIdentWithDots = /// LongIdentWithDots(lid, dotms) /// Typically dotms.Length = lid.Length-1, but they may be same if (incomplete) code ends in a dot, e.g. "Foo.Bar." @@ -194,6 +194,7 @@ type TyparStaticReq = [] type SynTypar = | Typar of ident:Ident * staticReq:TyparStaticReq * isCompGen:bool + with member this.Range = match this with | Typar(id,_,_) -> @@ -207,54 +208,76 @@ type [] /// The unchecked abstract syntax tree of constants in F# types and expressions. SynConst = + /// F# syntax: () | Unit + /// F# syntax: true, false | Bool of bool + /// F# syntax: 13y, 0xFFy, 0o077y, 0b0111101y | SByte of sbyte + /// F# syntax: 13uy, 0x40uy, 0oFFuy, 0b0111101uy | Byte of byte + /// F# syntax: 13s, 0x4000s, 0o0777s, 0b0111101s | Int16 of int16 + /// F# syntax: 13us, 0x4000us, 0o0777us, 0b0111101us | UInt16 of uint16 + /// F# syntax: 13, 0x4000, 0o0777 | Int32 of int32 + /// F# syntax: 13u, 0x4000u, 0o0777u | UInt32 of uint32 + /// F# syntax: 13L | Int64 of int64 + /// F# syntax: 13UL | UInt64 of uint64 + /// F# syntax: 13n | IntPtr of int64 + /// F# syntax: 13un | UIntPtr of uint64 + /// F# syntax: 1.30f, 1.40e10f etc. | Single of single + /// F# syntax: 1.30, 1.40e10 etc. | Double of double + /// F# syntax: 'a' | Char of char + /// F# syntax: 23.4M | Decimal of System.Decimal + /// UserNum(value, suffix) /// /// F# syntax: 1Q, 1Z, 1R, 1N, 1G | UserNum of value:string * suffix:string + /// F# syntax: verbatim or regular string, e.g. "abc" | String of text:string * range:range + /// F# syntax: verbatim or regular byte string, e.g. "abc"B. /// /// Also used internally in the typechecker once an array of unit16 constants /// is detected, to allow more efficient processing of large arrays of uint16 constants. | Bytes of bytes:byte[] * range:range + /// Used internally in the typechecker once an array of unit16 constants /// is detected, to allow more efficient processing of large arrays of uint16 constants. | UInt16s of uint16[] + /// Old comment: "we never iterate, so the const here is not another SynConst.Measure" | Measure of constant:SynConst * SynMeasure + member c.Range dflt = match c with | SynConst.String (_,m0) | SynConst.Bytes (_,m0) -> m0 @@ -266,12 +289,19 @@ and /// This should probably be merged with the representation of SynType. SynMeasure = | Named of longId:LongIdent * range:range + | Product of SynMeasure * SynMeasure * range:range + | Seq of SynMeasure list * range:range + | Divide of SynMeasure * SynMeasure * range:range + | Power of SynMeasure * SynRationalConst * range:range + | One + | Anon of range:range + | Var of SynTypar * range:range and @@ -279,7 +309,9 @@ and /// The unchecked abstract syntax tree of F# unit of measure exponents. SynRationalConst = | Integer of int32 + | Rational of int32 * int32 * range:range + | Negate of SynRationalConst @@ -293,15 +325,16 @@ type SynAccess = | Internal | Private - type SequencePointInfoForTarget = | SequencePointAtTarget | SuppressSequencePointAtTarget type SequencePointInfoForSeq = | SequencePointsAtSeq + // This means "suppress a in 'a;b'" and "suppress b in 'a before b'" | SuppressSequencePointOnExprOfSequential + // This means "suppress b in 'a;b'" and "suppress a in 'a before b'" | SuppressSequencePointOnStmtOfSequential @@ -329,16 +362,21 @@ type SequencePointInfoForWhileLoop = type SequencePointInfoForBinding = | SequencePointAtBinding of range:range + // Indicates the omission of a sequence point for a binding for a 'do expr' | NoSequencePointAtDoBinding - // Indicates the omission of a sequence point for a binding for a 'let e = expr' where 'expr' has immediate control flow + + // Indicates the omission of a sequence point for a binding for a 'let e = expr' where + // 'expr' has immediate control flow | NoSequencePointAtLetBinding + // Indicates the omission of a sequence point for a compiler generated binding // where we've done a local expansion of some construct into something that involves // a 'let'. e.g. we've inlined a function and bound its arguments using 'let' // The let bindings are 'sticky' in that the inversion of the inlining would involve // replacing the entire expression with the original and not just the let bindings alone. | NoSequencePointAtStickyBinding + // Given 'let v = e1 in e2', where this is a compiler generated binding, // we are sometimes forced to generate a sequence point for the expression anyway based on its // overall range. If the let binding is given the flag below then it is asserting that @@ -360,22 +398,28 @@ type SeqExprOnly = /// denotes location of the separator block + optional position of the semicolon (used for tooling support) type BlockSeparator = range * pos option + /// stores pair: record field name + (true if given record field name is syntactically correct and can be used in name resolution) type RecordFieldName = LongIdentWithDots * bool type ExprAtomicFlag = + /// Says that the expression is an atomic expression, i.e. is of a form that has no whitespace unless /// enclosed in parentheses, e.g. 1, "3", ident, ident.[expr] and (expr). If an atomic expression has /// type T, then the largest expression ending at the same range as the atomic expression also has type T. | Atomic = 0 + | NonAtomic = 1 /// The kind associated with a binding - "let", "do" or a standalone expression type SynBindingKind = + /// A standalone expression in a module | StandaloneExpression + /// A normal 'let' binding in a module | NormalBinding + /// A 'do' binding in a module. Must have type 'unit' | DoBinding @@ -385,31 +429,41 @@ type SynTyparDecl = | TyparDecl of attributes:SynAttributes * SynTypar - and [] /// The unchecked abstract syntax tree of F# type constraints SynTypeConstraint = + /// F# syntax : is 'typar : struct | WhereTyparIsValueType of genericName:SynTypar * range:range + /// F# syntax : is 'typar : not struct | WhereTyparIsReferenceType of genericName:SynTypar * range:range + /// F# syntax is 'typar : unmanaged | WhereTyparIsUnmanaged of genericName:SynTypar * range:range + /// F# syntax is 'typar : null | WhereTyparSupportsNull of genericName:SynTypar * range:range + /// F# syntax is 'typar : comparison | WhereTyparIsComparable of genericName:SynTypar * range:range + /// F# syntax is 'typar : equality | WhereTyparIsEquatable of genericName:SynTypar * range:range + /// F# syntax is default ^T : type | WhereTyparDefaultsToType of genericName:SynTypar * typeName:SynType * range:range + /// F# syntax is 'typar :> type | WhereTyparSubtypeOfType of genericName:SynTypar * typeName:SynType * range:range + /// F# syntax is ^T : (static member MemberName : ^T * int -> ^T) | WhereTyparSupportsMember of genericNames:SynType list * memberSig:SynMemberSig * range:range + /// F# syntax is 'typar : enum<'UnderlyingType> | WhereTyparIsEnum of genericName:SynTypar * SynType list * range:range + /// F# syntax is 'typar : delegate<'Args,unit> | WhereTyparIsDelegate of genericName:SynTypar * SynType list * range:range @@ -494,8 +548,6 @@ and | SynType.MeasurePower (range=m) -> m | SynType.LongIdent(lidwd) -> lidwd.Range - - and [] SynExpr = @@ -944,14 +996,18 @@ and | SynExpr.Ident id -> id.idRange | SynExpr.Fixed (_,m) -> m - and [] SynIndexerArg = + | Two of SynExpr * SynExpr + | One of SynExpr + member x.Range = match x with Two (e1,e2) -> unionRanges e1.Range e2.Range | One e -> e.Range + member x.Exprs = match x with Two (e1,e2) -> [e1;e2] | One e -> [e] + and [] SynSimplePat = @@ -972,19 +1028,23 @@ and | Id of ident:Ident * altNameRefCell:SynSimplePatAlternativeIdInfo ref option * isCompilerGenerated:bool * isThisVar:bool * isOptArg:bool * range:range | Typed of SynSimplePat * SynType * range:range - | Attrib of SynSimplePat * SynAttributes * range:range + | Attrib of SynSimplePat * SynAttributes * range:range and SynSimplePatAlternativeIdInfo = + /// We have not decided to use an alternative name in tha pattern and related expression | Undecided of Ident + /// We have decided to use an alternative name in tha pattern and related expression | Decided of Ident and [] SynStaticOptimizationConstraint = + | WhenTyparTyconEqualsTycon of SynTypar * SynType * range:range + | WhenTyparIsStruct of SynTypar * range:range and @@ -994,7 +1054,9 @@ and /// from the construct, e.g. after changing a "function pat1 -> rule1 | ..." to a /// "fun v -> match v with ..." SynSimplePats = + | SimplePats of SynSimplePat list * range:range + | Typed of SynSimplePats * SynType * range:range and SynConstructorArgs = @@ -1003,29 +1065,52 @@ and SynConstructorArgs = and [] SynPat = + | Const of SynConst * range:range + | Wild of range:range + | Named of SynPat * Ident * isSelfIdentifier:bool (* true if 'this' variable *) * accessibility:SynAccess option * range:range + | Typed of SynPat * SynType * range:range + | Attrib of SynPat * SynAttributes * range:range + | Or of SynPat * SynPat * range:range + | Ands of SynPat list * range:range - | LongIdent of longDotId:LongIdentWithDots * (* holds additional ident for tooling *) Ident option * SynValTyparDecls option (* usually None: temporary used to parse "f<'a> x = x"*) * SynConstructorArgs * accessibility:SynAccess option * range:range + + | LongIdent of + longDotId:LongIdentWithDots * + Ident option * // holds additional ident for tooling + SynValTyparDecls option * // usually None: temporary used to parse "f<'a> x = x"*) + SynConstructorArgs * + accessibility:SynAccess option * + range:range + | Tuple of isStruct: bool * SynPat list * range:range + | Paren of SynPat * range:range + | ArrayOrList of bool * SynPat list * range:range + | Record of ((LongIdent * Ident) * SynPat) list * range:range + /// 'null' | Null of range:range + /// '?id' -- for optional argument names | OptionalVal of Ident * range:range + /// ':? type ' | IsInst of SynType * range:range + /// <@ expr @>, used for active pattern arguments | QuoteExpr of SynExpr * range:range /// Deprecated character range:ranges | DeprecatedCharRange of char * char * range:range + /// Used internally in the type checker | InstanceMember of Ident * Ident * (* holds additional ident for tooling *) Ident option * accessibility:SynAccess option * range:range (* adhoc overloaded method/property *) @@ -1063,12 +1148,14 @@ and [] SynMatchClause = | Clause of SynPat * SynExpr option * SynExpr * range:range * SequencePointInfoForTarget + member this.RangeOfGuardAndRhs = match this with | Clause(_,eo,e,_,_) -> match eo with | None -> e.Range | Some x -> unionRanges e.Range x.Range + member this.Range = match this with | Clause(_,eo,e,m,_) -> @@ -1082,11 +1169,15 @@ and [] SynAttribute = { TypeName: LongIdentWithDots + ArgExpr: SynExpr + /// Target specifier, e.g. "assembly","module",etc. Target: Ident option + /// Is this attribute being applied to a property getter or setter? AppliesToGetterAndSetter: bool + Range: range } and @@ -1110,12 +1201,15 @@ and expr:SynExpr * range:range * seqPoint:SequencePointInfoForBinding + // no member just named "Range", as that would be confusing: // - for everything else, the 'range' member that appears last/second-to-last is the 'full range' of the whole tree construct // - but for Binding, the 'range' is only the range of the left-hand-side, the right-hand-side range is in the SynExpr // - so we use explicit names to avoid confusion member x.RangeOfBindingSansRhs = let (Binding(range=m)) = x in m + member x.RangeOfBindingAndRhs = let (Binding(expr=e; range=m)) = x in unionRanges e.Range m + member x.RangeOfHeadPat = let (Binding(headPat=headPat)) = x in headPat.Range and @@ -1137,11 +1231,17 @@ and and [] MemberKind = + | ClassConstructor + | Constructor + | Member + | PropertyGet + | PropertySet + /// An artificial member kind used prior to the point where a get/set property is split into two distinct members. | PropertyGetSet @@ -1150,10 +1250,15 @@ and /// The untyped, unchecked syntax tree for a member signature, used in signature files, abstract member declarations /// and member constraints. SynMemberSig = + | Member of SynValSig * MemberFlags * range:range + | Interface of typeName:SynType * range:range + | Inherit of typeName:SynType * range:range + | ValField of SynField * range:range + | NestedType of SynTypeDefnSig * range:range and SynMemberSigs = SynMemberSig list @@ -1173,7 +1278,6 @@ and | TyconILAssemblyCode | TyconDelegate of SynType * SynValInfo - and [] /// The untyped, unchecked syntax tree for the core of a simple type definition, in either signature @@ -1182,21 +1286,28 @@ and /// A union type definition, type X = A | B | Union of accessibility:SynAccess option * unionCases:SynUnionCases * range:range + /// An enum type definition, type X = A = 1 | B = 2 | Enum of SynEnumCases * range:range + /// A record type definition, type X = { A : int; B : int } | Record of accessibility:SynAccess option * recordFields:SynFields * range:range + /// An object oriented type definition. This is not a parse-tree form, but represents the core /// type representation which the type checker splits out from the "ObjectModel" cases of type definitions. | General of SynTypeDefnKind * (SynType * range * Ident option) list * (SynValSig * MemberFlags) list * SynField list * bool * bool * SynSimplePat list option * range:range + /// A type defined by using an IL assembly representation. Only used in FSharp.Core. /// /// F# syntax: "type X = (# "..."#) | LibraryOnlyILAssembly of ILType * range:range + /// A type abbreviation, "type X = A.B.C" | TypeAbbrev of ParserDetail * SynType * range:range + /// An abstract definition , "type X" | None of range:range + /// An exception definition , "exception E = ..." | Exception of SynExceptionDefnRepr @@ -1216,8 +1327,10 @@ and SynEnumCases = SynEnumCase list and [] SynEnumCase = + /// The untyped, unchecked syntax tree for one case in an enum definition. | EnumCase of attrs:SynAttributes * ident:Ident * SynConst * PreXmlDoc * range:range + member this.Range = match this with | EnumCase (range=m) -> m @@ -1227,8 +1340,10 @@ and SynUnionCases = SynUnionCase list and [] SynUnionCase = + /// The untyped, unchecked syntax tree for one case in a union definition. | UnionCase of SynAttributes * ident:Ident * SynUnionCaseType * PreXmlDoc * accessibility:SynAccess option * range:range + member this.Range = match this with | UnionCase (range=m) -> m @@ -1238,8 +1353,10 @@ and /// The untyped, unchecked syntax tree for the right-hand-side of union definition, excluding members, /// in either a signature or implementation. SynUnionCaseType = + /// Normal style declaration | UnionCaseFields of cases:SynField list + /// Full type spec given by 'UnionCase : ty1 * tyN -> rty'. Only used in FSharp.Core, otherwise a warning. | UnionCaseFullType of (SynType * SynValInfo) @@ -1249,11 +1366,15 @@ and /// Note: in practice, using a discriminated union to make a distinction between /// "simple" types and "object oriented" types is not particularly useful. SynTypeDefnSigRepr = + /// Indicates the right right-hand-side is a class, struct, interface or other object-model type | ObjectModel of SynTypeDefnKind * memberSigs:SynMemberSigs * range:range + /// Indicates the right right-hand-side is a record, union or other simple type. | Simple of SynTypeDefnSimpleRepr * range:range + | Exception of SynExceptionDefnRepr + member this.Range = match this with | ObjectModel (range=m) @@ -1264,6 +1385,7 @@ and [] /// The untyped, unchecked syntax tree for a type definition in a signature SynTypeDefnSig = + /// The information for a type definition in a signature | TypeDefnSig of SynComponentInfo * SynTypeDefnSigRepr * SynMemberSigs * range:range @@ -1275,7 +1397,6 @@ and SynField = | Field of attrs:SynAttributes * isStatic:bool * Ident option * SynType * bool * xmlDoc:PreXmlDoc * accessibility:SynAccess option * range:range - and [] /// The untyped, unchecked syntax tree associated with the name of a type definition or module @@ -1286,6 +1407,7 @@ and /// always empty. SynComponentInfo = | ComponentInfo of attribs:SynAttributes * typeParams:SynTyparDecl list * constraints:SynTypeConstraint list * longId:LongIdent * xmlDoc:PreXmlDoc * preferPostfix:bool * accessibility:SynAccess option * range:range + member this.Range = match this with | ComponentInfo (range=m) -> m @@ -1307,40 +1429,50 @@ and range:range member x.RangeOfId = let (ValSpfn(ident=id)) = x in id.idRange + member x.SynInfo = let (ValSpfn(arity=v)) = x in v + member x.SynType = let (ValSpfn(synType=ty)) = x in ty /// The argument names and other metadata for a member or function and [] SynValInfo = + /// SynValInfo(curriedArgInfos, returnInfo) | SynValInfo of SynArgInfo list list * SynArgInfo + member x.ArgInfos = (let (SynValInfo(args,_)) = x in args) /// The argument names and other metadata for a parameter for a member or function and [] SynArgInfo = + | SynArgInfo of SynAttributes * optional:bool * Ident option /// The names and other metadata for the type parameters for a member or function and [] SynValTyparDecls = + | SynValTyparDecls of SynTyparDecl list * bool * constraints:SynTypeConstraint list /// 'exception E = ... ' and [] SynExceptionDefnRepr = + | SynExceptionDefnRepr of SynAttributes * SynUnionCase * longId:LongIdent option * xmlDoc:PreXmlDoc * accessiblity:SynAccess option * range:range + member this.Range = match this with SynExceptionDefnRepr (range=m) -> m /// 'exception E = ... with ...' and [] SynExceptionDefn = + | SynExceptionDefn of SynExceptionDefnRepr * SynMemberDefns * range:range + member this.Range = match this with | SynExceptionDefn (range=m) -> m @@ -1348,9 +1480,13 @@ and and [] SynTypeDefnRepr = + | ObjectModel of SynTypeDefnKind * SynMemberDefns * range:range + | Simple of SynTypeDefnSimpleRepr * range:range + | Exception of SynExceptionDefnRepr + member this.Range = match this with | ObjectModel (range=m) @@ -1368,26 +1504,49 @@ and and [] SynMemberDefn = + | Open of longId:LongIdent * range:range + | Member of memberDefn:SynBinding * range:range + /// implicit ctor args as a defn line, 'as' specification | ImplicitCtor of accessiblity:SynAccess option * attributes:SynAttributes * ctorArgs:SynSimplePat list * selfIdentifier:Ident option * range:range + /// inherit (args...) as base | ImplicitInherit of inheritType:SynType * inheritArgs:SynExpr * inheritAlias:Ident option * range:range + /// LetBindings(bindingList, isStatic, isRecursive, wholeRange) /// /// localDefns | LetBindings of SynBinding list * isStatic:bool * isRecursive:bool * range:range + | AbstractSlot of SynValSig * MemberFlags * range:range + | Interface of SynType * SynMemberDefns option * range:range + | Inherit of SynType * Ident option * range:range + | ValField of SynField * range:range + /// A feature that is not implemented | NestedType of typeDefn:SynTypeDefn * accessibility:SynAccess option * range:range + /// SynMemberDefn.AutoProperty (attribs,isStatic,id,tyOpt,propKind,memberFlags,xmlDoc,access,synExpr,mGetSet,mWholeAutoProp). /// /// F# syntax: 'member val X = expr' - | AutoProperty of attribs:SynAttributes * isStatic:bool * ident:Ident * typeOpt:SynType option * propKind:MemberKind * memberFlags:(MemberKind -> MemberFlags) * xmlDoc:PreXmlDoc * accessiblity:SynAccess option * synExpr:SynExpr * getSetRange:range option * range:range + | AutoProperty of + attribs:SynAttributes * + isStatic:bool * + ident:Ident * + typeOpt:SynType option * + propKind:MemberKind * + memberFlags:(MemberKind -> MemberFlags) * + xmlDoc:PreXmlDoc * + accessiblity:SynAccess option * + synExpr:SynExpr * + getSetRange:range option * + range:range + member d.Range = match d with | SynMemberDefn.Member (range=m) @@ -1563,7 +1722,7 @@ type ParsedImplFileInput = scopedPragmas : ScopedPragma list * hashDirectives : ParsedHashDirective list * modules : SynModuleOrNamespace list * - ((* isLastCompiland *) bool * (* isExe *) bool) + isLastCompiland: (bool * bool) [] type ParsedSigFileInput = @@ -1805,8 +1964,8 @@ let ParseAssemblyCodeInstructions _s m = [| |] #else let ParseAssemblyCodeInstructions s m = - try Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser.ilInstrs - Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiLexer.token + try FSharp.Compiler.AbstractIL.Internal.AsciiParser.ilInstrs + FSharp.Compiler.AbstractIL.Internal.AsciiLexer.token (UnicodeLexing.StringAsLexbuf s) with RecoverableParseError -> errorR(Error(FSComp.SR.astParseEmbeddedILError(), m)); [| |] @@ -1820,8 +1979,8 @@ let ParseAssemblyCodeType _s m = IL.EcmaMscorlibILGlobals.typ_Object #else let ParseAssemblyCodeType s m = - try Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser.ilType - Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiLexer.token + try FSharp.Compiler.AbstractIL.Internal.AsciiParser.ilType + FSharp.Compiler.AbstractIL.Internal.AsciiLexer.token (UnicodeLexing.StringAsLexbuf s) with RecoverableParseError -> errorR(Error(FSComp.SR.astParseEmbeddedILTypeError(),m)); @@ -1841,10 +2000,11 @@ let mkSynInfix opm (l:SynExpr) oper (r:SynExpr) = let wholeRange = unionRanges l.Range r.Range SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator opm oper, l, firstTwoRange), r, wholeRange) -let mkSynBifix m oper x1 x2 = SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m) -let mkSynTrifix m oper x1 x2 x3 = SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m), x3,m) -let mkSynQuadfix m oper x1 x2 x3 x4 = SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m), x3,m),x4,m) -let mkSynQuinfix m oper x1 x2 x3 x4 x5 = SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m), x3,m),x4,m),x5,m) +let mkSynBifix m oper x1 x2 = + SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m) + +let mkSynTrifix m oper x1 x2 x3 = + SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, false, SynExpr.App (ExprAtomicFlag.NonAtomic, true, mkSynOperator m oper,x1,m), x2,m), x3,m) let mkSynPrefixPrim opm m oper x = SynExpr.App (ExprAtomicFlag.NonAtomic, false, mkSynOperator opm oper, x,m) diff --git a/src/fsharp/autobox.fs b/src/fsharp/autobox.fs index 4c929e006c..22e9409a69 100644 --- a/src/fsharp/autobox.fs +++ b/src/fsharp/autobox.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AutoBox - -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeRelations +module internal FSharp.Compiler.AutoBox + +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeRelations //---------------------------------------------------------------------------- // Decide the set of mutable locals to promote to heap-allocated reference cells diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index f3117e16e8..22b050388d 100755 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -10,7 +10,7 @@ // - Linking (including ILX-IL transformation) -module internal Microsoft.FSharp.Compiler.Driver +module internal FSharp.Compiler.Driver open System open System.Collections.Concurrent @@ -27,31 +27,31 @@ open Internal.Utilities open Internal.Utilities.Collections open Internal.Utilities.Filename -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.IlxGen - -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.CompileOptions -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeChecker +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.IlxGen + +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.Ast +open FSharp.Compiler.CompileOps +open FSharp.Compiler.CompileOptions +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Lib +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeChecker #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif #nowarn "45" // This method will be made public in the underlying IL because it may implement an interface or override a method @@ -69,10 +69,12 @@ type ErrorLoggerUpToMaxErrors(tcConfigB: TcConfigBuilder, exiter: Exiter, nameFo /// Called when an error or warning occurs abstract HandleIssue: tcConfigB: TcConfigBuilder * error: PhasedDiagnostic * isError: bool -> unit + /// Called when 'too many errors' has occurred abstract HandleTooManyErrors: text: string -> unit override x.ErrorCount = errors + override x.DiagnosticSink(err, isError) = if isError || ReportWarningAsError tcConfigB.errorSeverityOptions err then if errors >= tcConfigB.maxErrors then @@ -94,17 +96,18 @@ type ErrorLoggerUpToMaxErrors(tcConfigB: TcConfigBuilder, exiter: Exiter, nameFo /// Create an error logger that counts and prints errors -let ConsoleErrorLoggerUpToMaxErrors (tcConfigB:TcConfigBuilder, exiter : Exiter) : ErrorLogger = +let ConsoleErrorLoggerUpToMaxErrors (tcConfigB:TcConfigBuilder, exiter : Exiter) = { new ErrorLoggerUpToMaxErrors(tcConfigB, exiter, "ConsoleErrorLoggerUpToMaxErrors") with - member this.HandleTooManyErrors(text : string) = + member __.HandleTooManyErrors(text : string) = DoWithErrorColor false (fun () -> Printf.eprintfn "%s" text) - member this.HandleIssue(tcConfigB, err, isError) = + member __.HandleIssue(tcConfigB, err, isError) = DoWithErrorColor isError (fun () -> - (writeViaBufferWithEnvironmentNewLines stderr (OutputDiagnostic (tcConfigB.implicitIncludeDir, tcConfigB.showFullPaths, tcConfigB.flatErrors, tcConfigB.errorStyle, isError)) err - stderr.WriteLine())) - } :> _ + let diag = OutputDiagnostic (tcConfigB.implicitIncludeDir, tcConfigB.showFullPaths, tcConfigB.flatErrors, tcConfigB.errorStyle, isError) + writeViaBufferWithEnvironmentNewLines stderr diag err + stderr.WriteLine()) + } :> ErrorLogger /// This error logger delays the messages it receives. At the end, call ForwardDelayedDiagnostics /// to send the held messages. @@ -117,7 +120,9 @@ type DelayAndForwardErrorLogger(exiter: Exiter, errorLoggerProvider: ErrorLogger and [] ErrorLoggerProvider() = + member this.CreateDelayAndForwardLogger(exiter) = DelayAndForwardErrorLogger(exiter, this) + abstract CreateErrorLoggerUpToMaxErrors : tcConfigBuilder : TcConfigBuilder * exiter : Exiter -> ErrorLogger @@ -127,24 +132,35 @@ and [] type InProcErrorLoggerProvider() = let errors = ResizeArray() let warnings = ResizeArray() + member __.Provider = { new ErrorLoggerProvider() with - member log.CreateErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) = - { new ErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter, "InProcCompilerErrorLoggerUpToMaxErrors") with + + member log.CreateErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) = + + { new ErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter, "InProcCompilerErrorLoggerUpToMaxErrors") with + member this.HandleTooManyErrors(text) = warnings.Add(Diagnostic.Short(false, text)) + member this.HandleIssue(tcConfigBuilder, err, isError) = - let errs = CollectDiagnostic(tcConfigBuilder.implicitIncludeDir, tcConfigBuilder.showFullPaths, tcConfigBuilder.flatErrors, tcConfigBuilder.errorStyle, isError, err) + let errs = + CollectDiagnostic + (tcConfigBuilder.implicitIncludeDir, tcConfigBuilder.showFullPaths, + tcConfigBuilder.flatErrors, tcConfigBuilder.errorStyle, isError, err) let container = if isError then errors else warnings container.AddRange(errs) } - :> ErrorLogger } + :> ErrorLogger } + member __.CapturedErrors = errors.ToArray() + member __.CapturedWarnings = warnings.ToArray() /// The default ErrorLogger implementation, reporting messages to the Console up to the maxerrors maximum type ConsoleLoggerProvider() = + inherit ErrorLoggerProvider() - override this.CreateErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) = ConsoleErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) + override this.CreateErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) = ConsoleErrorLoggerUpToMaxErrors(tcConfigBuilder, exiter) /// Notify the exiter if any error has occurred let AbortOnError (errorLogger:ErrorLogger, exiter : Exiter) = @@ -157,9 +173,13 @@ let AbortOnError (errorLogger:ErrorLogger, exiter : Exiter) = /// Track a set of resources to cleanup type DisposablesTracker() = + let items = Stack() + member this.Register(i) = items.Push i + interface IDisposable with + member this.Dispose() = let l = List.ofSeq items items.Clear() @@ -177,7 +197,6 @@ let TypeCheck (ctok, tcConfig, tcImports, tcGlobals, errorLogger:ErrorLogger, as errorRecovery e rangeStartup exiter.Exit 1 - /// Check for .fsx and, if present, compute the load closure for of #loaded files. let AdjustForScriptCompile(ctok, tcConfigB:TcConfigBuilder, commandLineSourceFiles, lexResourceManager) = @@ -202,11 +221,18 @@ let AdjustForScriptCompile(ctok, tcConfigB:TcConfigBuilder, commandLineSourceFil let AppendClosureInformation(filename) = if IsScript filename then - let closure = LoadClosure.ComputeClosureOfScriptFiles(ctok, tcConfig, [filename, rangeStartup], CodeContext.Compilation, lexResourceManager=lexResourceManager) + let closure = + LoadClosure.ComputeClosureOfScriptFiles + (ctok, tcConfig, [filename, rangeStartup], CodeContext.Compilation, lexResourceManager=lexResourceManager) + // Record the references from the analysis of the script. The full resolutions are recorded as the corresponding #I paths used to resolve them // are local to the scripts and not added to the tcConfigB (they are added to localized clones of the tcConfigB). - let references = closure.References |> List.collect snd |> List.filter (fun r->r.originalReference.Range<>range0 && r.originalReference.Range<>rangeStartup) - references |> List.iter (fun r-> tcConfigB.AddReferencedAssemblyByPath(r.originalReference.Range, r.resolvedPath)) + let references = + closure.References + |> List.collect snd + |> List.filter (fun r -> r.originalReference.Range<>range0 && r.originalReference.Range<>rangeStartup) + + references |> List.iter (fun r -> tcConfigB.AddReferencedAssemblyByPath(r.originalReference.Range, r.resolvedPath)) closure.NoWarns |> List.collect (fun (n, ms) -> ms|>List.map(fun m->m, n)) |> List.iter (fun (x,m) -> tcConfigB.TurnWarningOff(x, m)) closure.SourceFiles |> List.map fst |> List.iter AddIfNotPresent closure.AllRootFileDiagnostics |> List.iter diagnosticSink @@ -218,11 +244,6 @@ let AdjustForScriptCompile(ctok, tcConfigB:TcConfigBuilder, commandLineSourceFil List.rev !allSources -//---------------------------------------------------------------------------- -// ProcessCommandLineFlags -//---------------------------------------------------------------------------- - - let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder, setProcessThreadLocals, lcidFromCodePage, argv) = let inputFilesRef = ref ([] : string list) let collect name = @@ -263,11 +284,6 @@ let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder, setProcessThreadLocals, dllFiles |> List.iter (fun f->tcConfigB.AddReferencedAssemblyByPath(rangeStartup, f)) sourceFiles - -//---------------------------------------------------------------------------- -// InterfaceFileWriter -//---------------------------------------------------------------------------- - module InterfaceFileWriter = let BuildInitialDisplayEnvForSigFileGeneration tcGlobals = @@ -303,11 +319,6 @@ module InterfaceFileWriter = if tcConfig.printSignatureFile <> "" then os.Dispose() -//---------------------------------------------------------------------------- -// XmlDocWriter -//---------------------------------------------------------------------------- - - module XmlDocWriter = let getDoc xmlDoc = @@ -419,10 +430,6 @@ module XmlDocWriter = let DefaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(FSharpEnvironment.tryCurrentDomain()).Value -//---------------------------------------------------------------------------- -// GenerateInterfaceData, EncodeInterfaceData -//---------------------------------------------------------------------------- - let GenerateInterfaceData(tcConfig:TcConfig) = not tcConfig.standalone && not tcConfig.noSignatureData @@ -441,11 +448,6 @@ let EncodeInterfaceData(tcConfig: TcConfig, tcGlobals, exportRemapping, generate else [], [] - -//---------------------------------------------------------------------------- -// GenerateOptimizationData, EncodeOptimizationData -//---------------------------------------------------------------------------- - let GenerateOptimizationData(tcConfig) = GenerateInterfaceData(tcConfig) @@ -515,15 +517,15 @@ module VersionResourceFormat = open BinaryGenerationUtilities let VersionInfoNode(data:byte[]) = - [| yield! i16 (data.Length + 2) // wLength : int16 // Specifies the length, in bytes, of the VS_VERSION_INFO structure. This length does not include any padding that aligns any subsequent version resource data on a 32-bit boundary. + [| yield! i16 (data.Length + 2) // wLength : int16 // Specifies the length, in bytes, of the VS_VERSION_INFO structure. yield! data |] let VersionInfoElement(wType, szKey, valueOpt: byte[] option, children:byte[][], isString) = // for String structs, wValueLength represents the word count, not the byte count let wValueLength = (match valueOpt with None -> 0 | Some value -> (if isString then value.Length / 2 else value.Length)) VersionInfoNode - [| yield! i16 wValueLength // wValueLength: int16. Specifies the length, in words, of the Value member. This value is zero if there is no Value member associated with the current version structure. - yield! i16 wType // wType : int16 Specifies the type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data. + [| yield! i16 wValueLength // wValueLength: int16. Specifies the length, in words, of the Value member. + yield! i16 wType // wType : int16 Specifies the type of data in the version resource. yield! Padded 2 szKey match valueOpt with | None -> yield! [] @@ -532,20 +534,28 @@ module VersionResourceFormat = yield! child |] let Version((v1, v2, v3, v4):ILVersionInfo) = - [| yield! i32 (int32 v1 <<< 16 ||| int32 v2) // DWORD dwFileVersionMS // Specifies the most significant 32 bits of the file's binary version number. This member is used with dwFileVersionLS to form a 64-bit value used for numeric comparisons. - yield! i32 (int32 v3 <<< 16 ||| int32 v4) // DWORD dwFileVersionLS // Specifies the least significant 32 bits of the file's binary version number. This member is used with dwFileVersionMS to form a 64-bit value used for numeric comparisons. + [| // DWORD dwFileVersionMS + // Specifies the most significant 32 bits of the file's binary + // version number. This member is used with dwFileVersionLS to form a 64-bit value used + // for numeric comparisons. + yield! i32 (int32 v1 <<< 16 ||| int32 v2) + + // DWORD dwFileVersionLS + // Specifies the least significant 32 bits of the file's binary + // version number. This member is used with dwFileVersionMS to form a 64-bit value used + // for numeric comparisons. + yield! i32 (int32 v3 <<< 16 ||| int32 v4) |] let String(string, value) = - let wType = 0x1 // Specifies the type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data. + let wType = 0x1 // Specifies the type of data in the version resource. let szKey = Bytes.stringAsUnicodeNullTerminated string VersionInfoElement(wType, szKey, Some (Bytes.stringAsUnicodeNullTerminated value), [| |], true) let StringTable(language, strings) = - let wType = 0x1 // Specifies the type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data. + let wType = 0x1 // Specifies the type of data in the version resource. let szKey = Bytes.stringAsUnicodeNullTerminated language - // Specifies an 8-digit hexadecimal number stored as a Unicode string. The four most significant digits represent the language identifier. The four least significant digits represent the code page for which the data is formatted. - // Each Microsoft Standard Language identifier contains two parts: the low-order 10 bits specify the major language, and the high-order 6 bits specify the sublanguage. For a table of valid identifiers see Language Identifiers. + // Specifies an 8-digit hexadecimal number stored as a Unicode string. let children = [| for string in strings do @@ -553,18 +563,18 @@ module VersionResourceFormat = VersionInfoElement(wType, szKey, None, children, false) let StringFileInfo(stringTables: #seq >) = - let wType = 0x1 // Specifies the type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data. + let wType = 0x1 // Specifies the type of data in the version resource. let szKey = Bytes.stringAsUnicodeNullTerminated "StringFileInfo" // Contains the Unicode string StringFileInfo - // Contains an array of one or more StringTable structures. Each StringTable structures szKey member indicates the appropriate language and code page for displaying the text in that StringTable structure. + // Contains an array of one or more StringTable structures. let children = [| for stringTable in stringTables do yield StringTable(stringTable) |] VersionInfoElement(wType, szKey, None, children, false) let VarFileInfo(vars: #seq) = - let wType = 0x1 // Specifies the type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data. + let wType = 0x1 // Specifies the type of data in the version resource. let szKey = Bytes.stringAsUnicodeNullTerminated "VarFileInfo" // Contains the Unicode string StringFileInfo - // Contains an array of one or more StringTable structures. Each StringTable structures szKey member indicates the appropriate language and code page for displaying the text in that StringTable structure. + // Contains an array of one or more StringTable structures. let children = [| for (lang, codePage) in vars do let szKey = Bytes.stringAsUnicodeNullTerminated "Translation" @@ -579,19 +589,38 @@ module VersionResourceFormat = dwFileType, dwFileSubtype, lwFileDate:int64) = let dwStrucVersion = 0x00010000 - [| yield! i32 0xFEEF04BD // DWORD dwSignature // Contains the value 0xFEEFO4BD. This is used with the szKey member of the VS_VERSION_INFO structure when searching a file for the VS_FIXEDFILEINFO structure. - yield! i32 dwStrucVersion // DWORD dwStrucVersion // Specifies the binary version number of this structure. The high-order word of this member contains the major version number, and the low-order word contains the minor version number. - yield! Version fileVersion // DWORD dwFileVersionMS, dwFileVersionLS // Specifies the most/least significant 32 bits of the file's binary version number. This member is used with dwFileVersionLS to form a 64-bit value used for numeric comparisons. - yield! Version productVersion // DWORD dwProductVersionMS, dwProductVersionLS // Specifies the most/least significant 32 bits of the file's binary version number. This member is used with dwFileVersionLS to form a 64-bit value used for numeric comparisons. - yield! i32 dwFileFlagsMask // DWORD dwFileFlagsMask // Contains a bitmask that specifies the valid bits in dwFileFlags. A bit is valid only if it was defined when the file was created. - yield! i32 dwFileFlags // DWORD dwFileFlags // Contains a bitmask that specifies the Boolean attributes of the file. This member can include one or more of the following values: - // VS_FF_DEBUG 0x1L The file contains debugging information or is compiled with debugging features enabled. - // VS_FF_INFOINFERRED The file's version structure was created dynamically; therefore, some of the members in this structure may be empty or incorrect. This flag should never be set in a file's VS_VERSION_INFO data. - // VS_FF_PATCHED The file has been modified and is not identical to the original shipping file of the same version number. - // VS_FF_PRERELEASE The file is a development version, not a commercially released product. - // VS_FF_PRIVATEBUILD The file was not built using standard release procedures. If this flag is set, the StringFileInfo structure should contain a PrivateBuild entry. - // VS_FF_SPECIALBUILD The file was built by the original company using standard release procedures but is a variation of the normal file of the same version number. If this flag is set, the StringFileInfo structure should contain a SpecialBuild entry. - yield! i32 dwFileOS //Specifies the operating system for which this file was designed. This member can be one of the following values: Flag + [| // DWORD dwSignature // Contains the value 0xFEEFO4BD. + yield! i32 0xFEEF04BD + + // DWORD dwStrucVersion // Specifies the binary version number of this structure. + yield! i32 dwStrucVersion + + // DWORD dwFileVersionMS, dwFileVersionLS // Specifies the most/least significant 32 bits of the file's binary version number. + yield! Version fileVersion + + // DWORD dwProductVersionMS, dwProductVersionLS // Specifies the most/least significant 32 bits of the file's binary version number. + yield! Version productVersion + + // DWORD dwFileFlagsMask // Contains a bitmask that specifies the valid bits in dwFileFlags. + yield! i32 dwFileFlagsMask + + // DWORD dwFileFlags // Contains a bitmask that specifies the Boolean attributes of the file. + yield! i32 dwFileFlags + // VS_FF_DEBUG 0x1L The file contains debugging information or is compiled with debugging features enabled. + // VS_FF_INFOINFERRED The file's version structure was created dynamically; therefore, some of the members + // in this structure may be empty or incorrect. This flag should never be set in a file's + // VS_VERSION_INFO data. + // VS_FF_PATCHED The file has been modified and is not identical to the original shipping file of + // the same version number. + // VS_FF_PRERELEASE The file is a development version, not a commercially released product. + // VS_FF_PRIVATEBUILD The file was not built using standard release procedures. If this flag is + // set, the StringFileInfo structure should contain a PrivateBuild entry. + // VS_FF_SPECIALBUILD The file was built by the original company using standard release procedures + // but is a variation of the normal file of the same version number. If this + // flag is set, the StringFileInfo structure should contain a SpecialBuild entry. + + //Specifies the operating system for which this file was designed. This member can be one of the following values: Flag + yield! i32 dwFileOS //VOS_DOS 0x0001L The file was designed for MS-DOS. //VOS_NT 0x0004L The file was designed for Windows NT. //VOS__WINDOWS16 The file was designed for 16-bit Windows. @@ -601,8 +630,10 @@ module VersionResourceFormat = //VOS__PM16 The file was designed for 16-bit Presentation Manager. //VOS__PM32 The file was designed for 32-bit Presentation Manager. //VOS_UNKNOWN The operating system for which the file was designed is unknown to Windows. - yield! i32 dwFileType // Specifies the general type of file. This member can be one of the following values: - + + // Specifies the general type of file. This member can be one of the following values: + yield! i32 dwFileType + //VFT_UNKNOWN The file type is unknown to Windows. //VFT_APP The file contains an application. //VFT_DLL The file contains a dynamic-link library (DLL). @@ -611,29 +642,36 @@ module VersionResourceFormat = //VFT_VXD The file contains a virtual device. //VFT_STATIC_LIB The file contains a static-link library. - yield! i32 dwFileSubtype // Specifies the function of the file. The possible values depend on the value of dwFileType. For all values of dwFileType not described in the following list, dwFileSubtype is zero. If dwFileType is VFT_DRV, dwFileSubtype can be one of the following values: - //VFT2_UNKNOWN The driver type is unknown by Windows. - //VFT2_DRV_COMM The file contains a communications driver. - //VFT2_DRV_PRINTER The file contains a printer driver. - //VFT2_DRV_KEYBOARD The file contains a keyboard driver. - //VFT2_DRV_LANGUAGE The file contains a language driver. - //VFT2_DRV_DISPLAY The file contains a display driver. - //VFT2_DRV_MOUSE The file contains a mouse driver. - //VFT2_DRV_NETWORK The file contains a network driver. - //VFT2_DRV_SYSTEM The file contains a system driver. - //VFT2_DRV_INSTALLABLE The file contains an installable driver. - //VFT2_DRV_SOUND The file contains a sound driver. - // - //If dwFileType is VFT_FONT, dwFileSubtype can be one of the following values: - // - //VFT2_UNKNOWN The font type is unknown by Windows. - //VFT2_FONT_RASTER The file contains a raster font. - //VFT2_FONT_VECTOR The file contains a vector font. - //VFT2_FONT_TRUETYPE The file contains a TrueType font. - // - //If dwFileType is VFT_VXD, dwFileSubtype contains the virtual device identifier included in the virtual device control block. - yield! i32 (int32 (lwFileDate >>> 32)) // Specifies the most significant 32 bits of the file's 64-bit binary creation date and time stamp. - yield! i32 (int32 lwFileDate) //Specifies the least significant 32 bits of the file's 64-bit binary creation date and time stamp. + // Specifies the function of the file. The possible values depend on the value of + // dwFileType. For all values of dwFileType not described in the following list, + // dwFileSubtype is zero. If dwFileType is VFT_DRV, dwFileSubtype can be one of the following values: + yield! i32 dwFileSubtype + //VFT2_UNKNOWN The driver type is unknown by Windows. + //VFT2_DRV_COMM The file contains a communications driver. + //VFT2_DRV_PRINTER The file contains a printer driver. + //VFT2_DRV_KEYBOARD The file contains a keyboard driver. + //VFT2_DRV_LANGUAGE The file contains a language driver. + //VFT2_DRV_DISPLAY The file contains a display driver. + //VFT2_DRV_MOUSE The file contains a mouse driver. + //VFT2_DRV_NETWORK The file contains a network driver. + //VFT2_DRV_SYSTEM The file contains a system driver. + //VFT2_DRV_INSTALLABLE The file contains an installable driver. + //VFT2_DRV_SOUND The file contains a sound driver. + // + //If dwFileType is VFT_FONT, dwFileSubtype can be one of the following values: + // + //VFT2_UNKNOWN The font type is unknown by Windows. + //VFT2_FONT_RASTER The file contains a raster font. + //VFT2_FONT_VECTOR The file contains a vector font. + //VFT2_FONT_TRUETYPE The file contains a TrueType font. + // + //If dwFileType is VFT_VXD, dwFileSubtype contains the virtual device identifier included in the virtual device control block. + + // Specifies the most significant 32 bits of the file's 64-bit binary creation date and time stamp. + yield! i32 (int32 (lwFileDate >>> 32)) + + //Specifies the least significant 32 bits of the file's 64-bit binary creation date and time stamp. + yield! i32 (int32 lwFileDate) |] @@ -835,7 +873,9 @@ module MainModuleBuilder = else [] - mkILSimpleModule assemblyName (GetGeneratedILModuleName tcConfig.target assemblyName) (tcConfig.target = CompilerTarget.Dll || tcConfig.target = CompilerTarget.Module) tcConfig.subsystemVersion tcConfig.useHighEntropyVA ilTypeDefs hashAlg locale flags (mkILExportedTypes exportedTypesList) metadataVersion + let ilModuleName = GetGeneratedILModuleName tcConfig.target assemblyName + let isDLL = (tcConfig.target = CompilerTarget.Dll || tcConfig.target = CompilerTarget.Module) + mkILSimpleModule assemblyName ilModuleName isDLL tcConfig.subsystemVersion tcConfig.useHighEntropyVA ilTypeDefs hashAlg locale flags (mkILExportedTypes exportedTypesList) metadataVersion let disableJitOptimizations = not (tcConfig.optSettings.jitOpt()) @@ -939,8 +979,12 @@ module MainModuleBuilder = let stringFileInfo = // 000004b0: - // Specifies an 8-digit hexadecimal number stored as a Unicode string. The four most significant digits represent the language identifier. The four least significant digits represent the code page for which the data is formatted. - // Each Microsoft Standard Language identifier contains two parts: the low-order 10 bits specify the major language, and the high-order 6 bits specify the sublanguage. For a table of valid identifiers see Language Identifiers. // + // Specifies an 8-digit hexadecimal number stored as a Unicode string. The + // four most significant digits represent the language identifier. The four least + // significant digits represent the code page for which the data is formatted. + // Each Microsoft Standard Language identifier contains two parts: the low-order 10 bits + // specify the major language, and the high-order 6 bits specify the sublanguage. + // For a table of valid identifiers see Language Identifiers. // // see e.g. http://msdn.microsoft.com/en-us/library/aa912040.aspx 0000 is neutral and 04b0(hex)=1252(dec) is the code page. [ ("000004b0", [ yield ("Assembly Version", (let v1, v2, v3, v4 = assemblyVersion in sprintf "%d.%d.%d.%d" v1 v2 v3 v4)) yield ("FileVersion", (let v1, v2, v3, v4 = fileVersionInfo in sprintf "%d.%d.%d.%d" v1 v2 v3 v4)) @@ -957,10 +1001,24 @@ module MainModuleBuilder = // These entries listed in the MSDN documentation as "standard" string entries are not yet settable - // InternalName: The Value member identifies the file's internal name, if one exists. For example, this string could contain the module name for Windows dynamic-link libraries (DLLs), a virtual device name for Windows virtual devices, or a device name for MS-DOS device drivers. - // OriginalFilename: The Value member identifies the original name of the file, not including a path. This enables an application to determine whether a file has been renamed by a user. This name may not be MS-DOS 8.3-format if the file is specific to a non-FAT file system. - // PrivateBuild: The Value member describes by whom, where, and why this private version of the file was built. This string should only be present if the VS_FF_PRIVATEBUILD flag is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure. For example, Value could be 'Built by OSCAR on \OSCAR2'. - // SpecialBuild: The Value member describes how this version of the file differs from the normal version. This entry should only be present if the VS_FF_SPECIALBUILD flag is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure. For example, Value could be 'Private build for Olivetti solving mouse problems on M250 and M250E computers'. + // InternalName: + // The Value member identifies the file's internal name, if one exists. For example, this + // string could contain the module name for Windows dynamic-link libraries (DLLs), a virtual + // device name for Windows virtual devices, or a device name for MS-DOS device drivers. + // OriginalFilename: + // The Value member identifies the original name of the file, not including a path. This + // enables an application to determine whether a file has been renamed by a user. This name + // may not be MS-DOS 8.3-format if the file is specific to a non-FAT file system. + // PrivateBuild: + // The Value member describes by whom, where, and why this private version of the + // file was built. This string should only be present if the VS_FF_PRIVATEBUILD flag + // is set in the dwFileFlags member of the VS_FIXEDFILEINFO structure. For example, + // Value could be 'Built by OSCAR on \OSCAR2'. + // SpecialBuild: + // The Value member describes how this version of the file differs from the normal version. + // This entry should only be present if the VS_FF_SPECIALBUILD flag is set in the dwFileFlags + // member of the VS_FIXEDFILEINFO structure. For example, Value could be 'Private build + // for Olivetti solving mouse problems on M250 and M250E computers'. // "If you use the Var structure to list the languages your application // or DLL supports instead of using multiple version resources, @@ -1446,8 +1504,13 @@ module StaticLinker = nestedTypes = mkILTypeDefs (List.map buildRelocatedGeneratedType ch)) | _ -> // If there is no matching IL type definition, then make a simple container class - if debugStaticLinking then printfn "Generating simple class '%s' because we didn't find an original type '%s' in a provider generated assembly" ilTgtTyRef.QualifiedName ilOrigTyRef.QualifiedName - mkILSimpleClass ilGlobals (ilTgtTyRef.Name, (if isNested then ILTypeDefAccess.Nested ILMemberAccess.Public else ILTypeDefAccess.Public), emptyILMethods, emptyILFields, mkILTypeDefs (List.map buildRelocatedGeneratedType ch) , emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.OnAny) + if debugStaticLinking then + printfn "Generating simple class '%s' because we didn't find an original type '%s' in a provider generated assembly" + ilTgtTyRef.QualifiedName ilOrigTyRef.QualifiedName + + let access = (if isNested then ILTypeDefAccess.Nested ILMemberAccess.Public else ILTypeDefAccess.Public) + let tdefs = mkILTypeDefs (List.map buildRelocatedGeneratedType ch) + mkILSimpleClass ilGlobals (ilTgtTyRef.Name, access, emptyILMethods, emptyILFields, tdefs , emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.OnAny) [ for (ProviderGeneratedType(_, ilTgtTyRef, _) as node) in tcImports.ProviderGeneratedTypeRoots do yield (ilTgtTyRef, buildRelocatedGeneratedType node) ] @@ -1473,7 +1536,8 @@ module StaticLinker = let (ltdefs, htd, rtdefs) = match tdefs |> trySplitFind (fun td -> td.Name = h) with | (ltdefs, None, rtdefs) -> - let fresh = mkILSimpleClass ilGlobals (h, (if isNested then ILTypeDefAccess.Nested ILMemberAccess.Public else ILTypeDefAccess.Public), emptyILMethods, emptyILFields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.OnAny) + let access = if isNested then ILTypeDefAccess.Nested ILMemberAccess.Public else ILTypeDefAccess.Public + let fresh = mkILSimpleClass ilGlobals (h, access, emptyILMethods, emptyILFields, emptyILTypeDefs, emptyILProperties, emptyILEvents, emptyILCustomAttrs, ILTypeInit.OnAny) (ltdefs, fresh, rtdefs) | (ltdefs, Some htd, rtdefs) -> (ltdefs, htd, rtdefs) @@ -1640,7 +1704,9 @@ let CopyFSharpCore(outFile: string, referencedDlls: AssemblyReference list) = [] type Args<'T> = Args of 'T -let main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage:ReduceMemoryFlag, defaultCopyFSharpCore: CopyFSharpCoreFlag, exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) = +let main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, + reduceMemoryUsage:ReduceMemoryFlag, defaultCopyFSharpCore: CopyFSharpCoreFlag, + exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) = // See Bug 735819 let lcidFromCodePage = @@ -1940,11 +2006,15 @@ let main1OfAst (ctok, legacyReferenceResolver, reduceMemoryUsage, assemblyName, // Pass on only the minimum information required for the next phase to ensure GC kicks in. // In principle the JIT should be able to do good liveness analysis to clean things up, but the // data structures involved here are so large we can't take the risk. - Args(ctok, tcConfig, tcImports, frameworkTcImports, tcGlobals, errorLogger, generatedCcu, outfile, typedAssembly, topAttrs, pdbFile, assemblyName, assemVerFromAttrib, signingInfo ,exiter) + Args(ctok, tcConfig, tcImports, frameworkTcImports, tcGlobals, errorLogger, + generatedCcu, outfile, typedAssembly, topAttrs, pdbFile, assemblyName, + assemVerFromAttrib, signingInfo ,exiter) /// Phase 2a: encode signature data, optimize, encode optimization data -let main2a(Args (ctok, tcConfig, tcImports, frameworkTcImports: TcImports, tcGlobals, errorLogger: ErrorLogger, generatedCcu: CcuThunk, outfile, typedImplFiles, topAttrs, pdbfile, assemblyName, assemVerFromAttrib, signingInfo, exiter: Exiter)) = +let main2a(Args (ctok, tcConfig, tcImports, frameworkTcImports: TcImports, tcGlobals, + errorLogger: ErrorLogger, generatedCcu: CcuThunk, outfile, typedImplFiles, + topAttrs, pdbfile, assemblyName, assemVerFromAttrib, signingInfo, exiter: Exiter)) = // Encode the signature data ReportTime tcConfig ("Encode Interface Data") @@ -1966,8 +2036,15 @@ let main2a(Args (ctok, tcConfig, tcImports, frameworkTcImports: TcImports, tcGlo let metadataVersion = match tcConfig.metadataVersion with | Some v -> v - | _ -> match (frameworkTcImports.DllTable.TryFind tcConfig.primaryAssembly.Name) with | Some ib -> ib.RawMetadata.TryGetILModuleDef().Value.MetadataVersion | _ -> "" - let optimizedImpls, optimizationData, _ = ApplyAllOptimizations (tcConfig, tcGlobals, (LightweightTcValForUsingInBuildMethodCall tcGlobals), outfile, importMap, false, optEnv0, generatedCcu, typedImplFiles) + | _ -> + match frameworkTcImports.DllTable.TryFind tcConfig.primaryAssembly.Name with + | Some ib -> ib.RawMetadata.TryGetILModuleDef().Value.MetadataVersion + | _ -> "" + + let optimizedImpls, optimizationData, _ = + ApplyAllOptimizations + (tcConfig, tcGlobals, (LightweightTcValForUsingInBuildMethodCall tcGlobals), outfile, + importMap, false, optEnv0, generatedCcu, typedImplFiles) AbortOnError(errorLogger, exiter) @@ -1976,10 +2053,16 @@ let main2a(Args (ctok, tcConfig, tcImports, frameworkTcImports: TcImports, tcGlo let optDataResources = EncodeOptimizationData(tcGlobals, tcConfig, outfile, exportRemapping, (generatedCcu, optimizationData), false) // Pass on only the minimum information required for the next phase - Args (ctok, tcConfig, tcImports, tcGlobals, errorLogger, generatedCcu, outfile, optimizedImpls, topAttrs, pdbfile, assemblyName, (sigDataAttributes, sigDataResources), optDataResources, assemVerFromAttrib, signingInfo, metadataVersion, exiter) + Args (ctok, tcConfig, tcImports, tcGlobals, errorLogger, + generatedCcu, outfile, optimizedImpls, topAttrs, pdbfile, assemblyName, + (sigDataAttributes, sigDataResources), optDataResources, assemVerFromAttrib, signingInfo, metadataVersion, exiter) /// Phase 2b: IL code generation -let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcConfig, tcImports, tcGlobals: TcGlobals, errorLogger, generatedCcu: CcuThunk, outfile, optimizedImpls, topAttrs, pdbfile, assemblyName, idata, optDataResources, assemVerFromAttrib, signingInfo, metadataVersion, exiter: Exiter)) = +let main2b + (tcImportsCapture,dynamicAssemblyCreator) + (Args (ctok, tcConfig: TcConfig, tcImports, tcGlobals: TcGlobals, errorLogger, + generatedCcu: CcuThunk, outfile, optimizedImpls, topAttrs, pdbfile, assemblyName, + idata, optDataResources, assemVerFromAttrib, signingInfo, metadataVersion, exiter: Exiter)) = match tcImportsCapture with | None -> () @@ -1996,7 +2079,8 @@ let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcCo use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.IlxGen let ilxGenerator = CreateIlxAssemblyGenerator (tcConfig, tcImports, tcGlobals, (LightweightTcValForUsingInBuildMethodCall tcGlobals), generatedCcu) - let codegenResults = GenerateIlxCode ((if Option.isSome dynamicAssemblyCreator then IlReflectBackend else IlWriteBackend), Option.isSome dynamicAssemblyCreator, false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator) + let codegenBackend = (if Option.isSome dynamicAssemblyCreator then IlReflectBackend else IlWriteBackend) + let codegenResults = GenerateIlxCode (codegenBackend, Option.isSome dynamicAssemblyCreator, false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator) let topAssemblyAttrs = codegenResults.topAssemblyAttrs let topAttrs = {topAttrs with assemblyAttrs=topAssemblyAttrs} let permissionSets = codegenResults.permissionSets @@ -2027,8 +2111,12 @@ let main3(Args (ctok, tcConfig, tcImports, tcGlobals, errorLogger: ErrorLogger, Args (ctok, tcConfig, tcImports, tcGlobals, errorLogger, ilxMainModule, outfile, pdbfile, signingInfo, exiter) /// Phase 4: write the binaries -let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, tcImports: TcImports, tcGlobals: TcGlobals, errorLogger: ErrorLogger, ilxMainModule, outfile, pdbfile, signingInfo, exiter: Exiter)) = +let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, tcImports: TcImports, tcGlobals: TcGlobals, + errorLogger: ErrorLogger, ilxMainModule, outfile, pdbfile, + signingInfo, exiter: Exiter)) = + ReportTime tcConfig "Write .NET Binary" + use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Output let outfile = tcConfig.MakePathAbsolute outfile @@ -2085,7 +2173,9 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, tcImports: TcImports, t //----------------------------------------------------------------------------- /// Entry point typecheckAndCompile -let typecheckAndCompile (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, defaultCopyFSharpCore, exiter:Exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = +let typecheckAndCompile + (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, + defaultCopyFSharpCore, exiter:Exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = use d = new DisposablesTracker() use e = new SaveAndRestoreConsoleEncoding() @@ -2098,15 +2188,23 @@ let typecheckAndCompile (ctok, argv, legacyReferenceResolver, bannerAlreadyPrint |> main4 dynamicAssemblyCreator -let compileOfAst (ctok, legacyReferenceResolver, reduceMemoryUsage, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs, tcImportsCapture, dynamicAssemblyCreator) = - main1OfAst (ctok, legacyReferenceResolver, reduceMemoryUsage, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs) +let compileOfAst + (ctok, legacyReferenceResolver, reduceMemoryUsage, assemblyName, target, + outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs, tcImportsCapture, dynamicAssemblyCreator) = + + main1OfAst (ctok, legacyReferenceResolver, reduceMemoryUsage, assemblyName, target, outFile, pdbFile, + dllReferences, noframework, exiter, errorLoggerProvider, inputs) |> main2a |> main2b (tcImportsCapture, dynamicAssemblyCreator) |> main3 |> main4 dynamicAssemblyCreator -let mainCompile (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = - //System.Runtime.GCSettings.LatencyMode <- System.Runtime.GCLatencyMode.Batch - typecheckAndCompile(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) +let mainCompile + (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, + defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = + + typecheckAndCompile + (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, reduceMemoryUsage, + defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) diff --git a/src/fsharp/fsc.fsi b/src/fsharp/fsc.fsi index 2e20a700cd..b07c6fd120 100755 --- a/src/fsharp/fsc.fsi +++ b/src/fsharp/fsc.fsi @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Driver +module internal FSharp.Compiler.Driver -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.TcGlobals +open FSharp.Compiler.Ast +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.CompileOps +open FSharp.Compiler.TcGlobals [] type ErrorLoggerProvider = diff --git a/src/fsharp/fscmain.fs b/src/fsharp/fscmain.fs index 1d50e0c68d..2a19cd0d6c 100644 --- a/src/fsharp/fscmain.fs +++ b/src/fsharp/fscmain.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.CommandLineMain +module internal FSharp.Compiler.CommandLineMain open System open System.Diagnostics @@ -8,16 +8,16 @@ open System.IO open System.Reflection open System.Runtime.CompilerServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Driver -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Driver +open FSharp.Compiler.Lib +open FSharp.Compiler.Range +open FSharp.Compiler.CompileOps +open FSharp.Compiler.AbstractIL.Internal.Library open Internal.Utilities #if FX_RESHAPED_REFLECTION @@ -45,7 +45,13 @@ module Driver = let timesFlag = argv |> Array.exists (fun x -> x = "/times" || x = "--times") if timesFlag then let stats = ILBinaryReader.GetStatistics() - AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> printfn "STATS: #ByteArrayFile = %d, #MemoryMappedFileOpen = %d, #MemoryMappedFileClosed = %d, #RawMemoryFile = %d, #WeakByteArrayFile = %d" stats.byteFileCount stats.memoryMapFileOpenedCount stats.memoryMapFileClosedCount stats.rawMemoryFileCount stats.weakByteFileCount) + AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> + printfn "STATS: #ByteArrayFile = %d, #MemoryMappedFileOpen = %d, #MemoryMappedFileClosed = %d, #RawMemoryFile = %d, #WeakByteArrayFile = %d" + stats.byteFileCount + stats.memoryMapFileOpenedCount + stats.memoryMapFileClosedCount + stats.rawMemoryFileCount + stats.weakByteFileCount) #endif let quitProcessExiter = @@ -85,5 +91,5 @@ let main(argv) = try Driver.main(Array.append [| "fsc.exe" |] argv) with e -> - errorRecovery e Microsoft.FSharp.Compiler.Range.range0 + errorRecovery e FSharp.Compiler.Range.range0 1 diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 8190be4078..f45889eff3 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module Microsoft.FSharp.Compiler.Interactive.Shell +module FSharp.Compiler.Interactive.Shell #nowarn "55" @@ -19,37 +19,37 @@ open System.Text open System.Threading open System.Reflection open System.Runtime.CompilerServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.ILRuntimeWriter -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.CompileOptions -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.IlxGen -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Optimizer -open Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.ReferenceResolver +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.ILRuntimeWriter +open FSharp.Compiler.Lib +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.CompileOptions +open FSharp.Compiler.CompileOps +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Infos +open FSharp.Compiler.InfoReader +open FSharp.Compiler.NameResolution +open FSharp.Compiler.IlxGen +open FSharp.Compiler.Lexhelp +open FSharp.Compiler.Layout +open FSharp.Compiler.Lib +open FSharp.Compiler.Optimizer +open FSharp.Compiler.PostTypeCheckSemanticChecks +open FSharp.Compiler.Range +open FSharp.Compiler.TypeChecker +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.ReferenceResolver open Internal.Utilities open Internal.Utilities.Collections @@ -2641,8 +2641,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i try errorLogger.AbortOnError(fsiConsoleOutput) with StopProcessing -> - // BUG 664864: Watson Clr20r3 across buckets with: Application fsiAnyCpu.exe from Dev11 RTM; Exception AE251Y0L0P2WC0QSWDZ0E2IDRYQTDSVB; FSIANYCPU.NI.EXE!Microsoft.FSharp.Compiler.Interactive.Shell+threadException - // reason: some window that use System.Windows.Forms.DataVisualization types (possible FSCharts) was created in FSI. + // BUG 664864 some window that use System.Windows.Forms.DataVisualization types (possible FSCharts) was created in FSI. // at some moment one chart has raised InvalidArgumentException from OnPaint, this exception was intercepted by the code in higher layer and // passed to Application.OnThreadException. FSI has already attached its own ThreadException handler, inside it will log the original error // and then raise StopProcessing exception to unwind the stack (and possibly shut down current Application) and get to DriveFsiEventLoop. diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index 894635e338..49c307b6cb 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.Interactive.Shell +module public FSharp.Compiler.Interactive.Shell open System.IO -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices [] /// Represents an evaluated F# value diff --git a/src/fsharp/fsi/fsimain.fs b/src/fsharp/fsi/fsimain.fs index 92a2f72270..90bf78b650 100644 --- a/src/fsharp/fsi/fsimain.fs +++ b/src/fsharp/fsi/fsimain.fs @@ -9,7 +9,7 @@ // 3. connect the configuration to the global state programmer-settable settings in FSharp.Compiler.Interactive.Settings.dll // 4. implement shadow copy of references -module internal Sample.Microsoft.FSharp.Compiler.Interactive.Main +module internal Sample.FSharp.Compiler.Interactive.Main open System open System.Globalization @@ -21,12 +21,12 @@ open System.Runtime.CompilerServices open System.Windows.Forms #endif -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Interactive.Shell -open Microsoft.FSharp.Compiler.Interactive -open Microsoft.FSharp.Compiler.Interactive.Shell.Settings +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.Lib +open FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.Interactive +open FSharp.Compiler.Interactive.Shell.Settings #if FX_RESHAPED_REFLECTION open Microsoft.FSharp.Core.ReflectionAdapters @@ -177,7 +177,7 @@ let evaluateSession(argv: string[]) = try // Create the console reader - let console = new Microsoft.FSharp.Compiler.Interactive.ReadLineConsole() + let console = new FSharp.Compiler.Interactive.ReadLineConsole() // Define the function we pass to the FsiEvaluationSession let getConsoleReadLine (probeToSeeIfConsoleWorks) = @@ -213,8 +213,8 @@ let evaluateSession(argv: string[]) = if isNull fsiAssembly then None else - let fsiTy = fsiAssembly.GetType("Microsoft.FSharp.Compiler.Interactive.Settings") - if isNull fsiAssembly then failwith "failed to find type Microsoft.FSharp.Compiler.Interactive.Settings in FSharp.Compiler.Interactive.Settings.dll" + let fsiTy = fsiAssembly.GetType("FSharp.Compiler.Interactive.Settings") + if isNull fsiAssembly then failwith "failed to find type FSharp.Compiler.Interactive.Settings in FSharp.Compiler.Interactive.Settings.dll" Some (callStaticMethod fsiTy "get_fsi" [ ]) let fsiConfig0 = @@ -317,8 +317,8 @@ let evaluateSession(argv: string[]) = fsiSession.Run() 0 with - | Microsoft.FSharp.Compiler.ErrorLogger.StopProcessingExn _ -> 1 - | Microsoft.FSharp.Compiler.ErrorLogger.ReportedError _ -> 1 + | FSharp.Compiler.ErrorLogger.StopProcessingExn _ -> 1 + | FSharp.Compiler.ErrorLogger.ReportedError _ -> 1 | e -> eprintf "Exception by fsi.exe:\n%+A\n" e; 1 // Mark the main thread as STAThread since it is a GUI thread diff --git a/src/fsharp/fsiattrs.fs b/src/fsharp/fsiattrs.fs index 58de98b4fc..8e279c43dd 100755 --- a/src/fsharp/fsiattrs.fs +++ b/src/fsharp/fsiattrs.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module Microsoft.FSharp.Compiler.Interactive.Attributes -[] +module FSharp.Compiler.Interactive.Attributes +[] do() diff --git a/src/fsharp/fsiaux.fs b/src/fsharp/fsiaux.fs index 7fd5d0f146..f4c5ed9cd5 100755 --- a/src/fsharp/fsiaux.fs +++ b/src/fsharp/fsiaux.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.Interactive +namespace FSharp.Compiler.Interactive #nowarn "51" #nowarn "9" @@ -115,13 +115,25 @@ type InteractiveSession() = member __.Invoke(f) = invoke((fun () -> f() |> box)) |> unbox member __.ScheduleRestart() = restart() } -[] +[] do() module Settings = let fsi = new InteractiveSession() - [] + [] do() +// For legacy compatibility with old naming +namespace Microsoft.FSharp.Compiler.Interactive + + type IEventLoop = FSharp.Compiler.Interactive.IEventLoop + + type InteractiveSession = FSharp.Compiler.Interactive.InteractiveSession + + module Settings = + + let fsi = FSharp.Compiler.Interactive.Settings.fsi + + diff --git a/src/fsharp/fsiaux.fsi b/src/fsharp/fsiaux.fsi index 1c86c3d21c..d557c17331 100755 --- a/src/fsharp/fsiaux.fsi +++ b/src/fsharp/fsiaux.fsi @@ -1,64 +1,90 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.Interactive +namespace FSharp.Compiler.Interactive + + /// An event loop used by the currently executing F# Interactive session to execute code + /// in the context of a GUI or another event-based system. + type IEventLoop = + + /// Run the event loop. + /// True if the event loop was restarted; false otherwise. + abstract Run : unit -> bool + + /// Request that the given operation be run synchronously on the event loop. + /// The result of the operation. + abstract Invoke : (unit -> 'T) -> 'T -/// An event loop used by the currently executing F# Interactive session to execute code -/// in the context of a GUI or another event-based system. -type IEventLoop = - /// Run the event loop. - /// True if the event loop was restarted; false otherwise. - abstract Run : unit -> bool - /// Request that the given operation be run synchronously on the event loop. - /// The result of the operation. - abstract Invoke : (unit -> 'T) -> 'T - /// Schedule a restart for the event loop. - abstract ScheduleRestart : unit -> unit + /// Schedule a restart for the event loop. + abstract ScheduleRestart : unit -> unit -[] -/// Operations supported by the currently executing F# Interactive session. -type InteractiveSession = - /// Get or set the floating point format used in the output of the interactive session. - member FloatingPointFormat: string with get,set - /// Get or set the format provider used in the output of the interactive session. - member FormatProvider: System.IFormatProvider with get,set - /// Get or set the print width of the interactive session. - member PrintWidth : int with get,set - /// Get or set the print depth of the interactive session. - member PrintDepth : int with get,set - /// Get or set the total print length of the interactive session. - member PrintLength : int with get,set - /// Get or set the total print size of the interactive session. - member PrintSize : int with get,set - /// When set to 'false', disables the display of properties of evaluated objects in the output of the interactive session. - member ShowProperties : bool with get,set - /// When set to 'false', disables the display of sequences in the output of the interactive session. - member ShowIEnumerable: bool with get,set - /// When set to 'false', disables the display of declaration values in the output of the interactive session. - member ShowDeclarationValues: bool with get,set - /// Register a printer that controls the output of the interactive session. - member AddPrinter: ('T -> string) -> unit - /// Register a print transformer that controls the output of the interactive session. - member AddPrintTransformer: ('T -> obj) -> unit - - member internal AddedPrinters : Choice<(System.Type * (obj -> string)), - (System.Type * (obj -> obj))> list - - /// The command line arguments after ignoring the arguments relevant to the interactive - /// environment and replacing the first argument with the name of the last script file, - /// if any. Thus 'fsi.exe test1.fs test2.fs -- hello goodbye' will give arguments - /// 'test2.fs', 'hello', 'goodbye'. This value will normally be different to those - /// returned by System.Environment.GetCommandLineArgs. - member CommandLineArgs : string [] with get,set - - /// Gets or sets a the current event loop being used to process interactions. - member EventLoop: IEventLoop with get,set + [] + /// Operations supported by the currently executing F# Interactive session. + type InteractiveSession = + + /// Get or set the floating point format used in the output of the interactive session. + member FloatingPointFormat: string with get,set + + /// Get or set the format provider used in the output of the interactive session. + member FormatProvider: System.IFormatProvider with get,set + + /// Get or set the print width of the interactive session. + member PrintWidth : int with get,set + + /// Get or set the print depth of the interactive session. + member PrintDepth : int with get,set + + /// Get or set the total print length of the interactive session. + member PrintLength : int with get,set + + /// Get or set the total print size of the interactive session. + member PrintSize : int with get,set + + /// When set to 'false', disables the display of properties of evaluated objects in the output of the interactive session. + member ShowProperties : bool with get,set + + /// When set to 'false', disables the display of sequences in the output of the interactive session. + member ShowIEnumerable: bool with get,set + + /// When set to 'false', disables the display of declaration values in the output of the interactive session. + member ShowDeclarationValues: bool with get,set + + /// Register a printer that controls the output of the interactive session. + member AddPrinter: ('T -> string) -> unit + + /// Register a print transformer that controls the output of the interactive session. + member AddPrintTransformer: ('T -> obj) -> unit + + member internal AddedPrinters : Choice<(System.Type * (obj -> string)), + (System.Type * (obj -> obj))> list + + /// The command line arguments after ignoring the arguments relevant to the interactive + /// environment and replacing the first argument with the name of the last script file, + /// if any. Thus 'fsi.exe test1.fs test2.fs -- hello goodbye' will give arguments + /// 'test2.fs', 'hello', 'goodbye'. This value will normally be different to those + /// returned by System.Environment.GetCommandLineArgs. + member CommandLineArgs : string [] with get,set + + /// Gets or sets a the current event loop being used to process interactions. + member EventLoop: IEventLoop with get,set - /// Sets the current event loop being used to process interactions. - member internal SetEventLoop: (unit -> bool) * ((unit -> obj) -> obj) * (unit -> unit) -> unit + /// Sets the current event loop being used to process interactions. + member internal SetEventLoop: (unit -> bool) * ((unit -> obj) -> obj) * (unit -> unit) -> unit -module Settings = + module Settings = + + /// The settings associated with the interactive session. + val fsi : InteractiveSession + +// For legacy compatibility with old naming +namespace Microsoft.FSharp.Compiler.Interactive + + type IEventLoop = FSharp.Compiler.Interactive.IEventLoop + + type InteractiveSession = FSharp.Compiler.Interactive.InteractiveSession + + module Settings = + + val fsi : InteractiveSession - /// The settings associated with the interactive session. - val fsi : InteractiveSession diff --git a/src/fsharp/import.fs b/src/fsharp/import.fs index e06ee756da..c8cb751cca 100755 --- a/src/fsharp/import.fs +++ b/src/fsharp/import.fs @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Functions to import .NET binary metadata as TAST objects -module internal Microsoft.FSharp.Compiler.Import +module internal FSharp.Compiler.Import open System.Reflection open System.Collections.Concurrent open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif /// Represents an interface to some of the functionality of TcImports, for loading assemblies diff --git a/src/fsharp/import.fsi b/src/fsharp/import.fsi index 02415e922f..1070bd302a 100755 --- a/src/fsharp/import.fsi +++ b/src/fsharp/import.fsi @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Functions to import .NET binary metadata as TAST objects -module internal Microsoft.FSharp.Compiler.Import +module internal FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 6ee5a6b53c..d8b2cc37f4 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -4,24 +4,24 @@ /// to .NET and F# constructs. -module internal Microsoft.FSharp.Compiler.Infos - -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Tastops.DebugPrint -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib +module internal FSharp.Compiler.Infos + +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Tastops.DebugPrint +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib open Microsoft.FSharp.Core.Printf #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping #endif #if FX_RESHAPED_REFLECTION diff --git a/src/fsharp/layout.fs b/src/fsharp/layout.fs index 2ee543d9b1..1664b9c713 100755 --- a/src/fsharp/layout.fs +++ b/src/fsharp/layout.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module Microsoft.FSharp.Compiler.Layout +module FSharp.Compiler.Layout open System open System.Collections.Generic diff --git a/src/fsharp/layout.fsi b/src/fsharp/layout.fsi index a9ced6d9f2..00831d49ca 100755 --- a/src/fsharp/layout.fsi +++ b/src/fsharp/layout.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.Layout +module public FSharp.Compiler.Layout open System.Text open System.Collections.Generic diff --git a/src/fsharp/lex.fsl b/src/fsharp/lex.fsl index 62fea65c29..0af96d71c9 100755 --- a/src/fsharp/lex.fsl +++ b/src/fsharp/lex.fsl @@ -2,7 +2,7 @@ { -module internal Microsoft.FSharp.Compiler.Lexer +module internal FSharp.Compiler.Lexer //------------------------------------------------------------------------ // The Lexer. Some of the complication arises from the fact it is @@ -15,17 +15,17 @@ open System.Globalization open System.Text open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler - -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Parser -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler + +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Parser +open FSharp.Compiler.Lexhelp +open FSharp.Compiler.Lib open Internal.Utilities.Text.Lexing let lexeme (lexbuf : UnicodeLexing.Lexbuf) = UnicodeLexing.Lexbuf.LexemeString lexbuf @@ -155,9 +155,9 @@ let evalIfDefExpression startPos args (lookup:string->bool) (lexed:string) = let lexbuf = LexBuffer.FromChars (lexed.ToCharArray ()) lexbuf.StartPos <- startPos lexbuf.EndPos <- startPos - let tokenStream = Microsoft.FSharp.Compiler.PPLexer.tokenstream args + let tokenStream = FSharp.Compiler.PPLexer.tokenstream args - let expr = Microsoft.FSharp.Compiler.PPParser.start tokenStream lexbuf + let expr = FSharp.Compiler.PPParser.start tokenStream lexbuf LexerIfdefEval lookup expr diff --git a/src/fsharp/lexhelp.fs b/src/fsharp/lexhelp.fs index b7603baf15..212d7f6c7b 100755 --- a/src/fsharp/lexhelp.fs +++ b/src/fsharp/lexhelp.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Lexhelp +module internal FSharp.Compiler.Lexhelp open System open System.Text @@ -10,17 +10,17 @@ open Internal.Utilities.Collections open Internal.Utilities.Text open Internal.Utilities.Text.Lexing -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Parser +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Lib +open FSharp.Compiler.Ast +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.Range +open FSharp.Compiler.Parser diff --git a/src/fsharp/lexhelp.fsi b/src/fsharp/lexhelp.fsi index 5c534fd7b3..9518b97d0c 100755 --- a/src/fsharp/lexhelp.fsi +++ b/src/fsharp/lexhelp.fsi @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Lexhelp +module internal FSharp.Compiler.Lexhelp open Internal.Utilities open Internal.Utilities.Text -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Ast +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index 18404ba377..ca6d129a6f 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.Lib +module internal FSharp.Compiler.Lib open System.IO open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library /// is this the developer-debug build? diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 25c8ce10a8..aef3d2d8d0 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -6,18 +6,18 @@ open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler open Internal.Utilities.Text.Parsing open System -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.ErrorLogger #if DEBUG let debugPrint(s) = diff --git a/src/fsharp/pplex.fsl b/src/fsharp/pplex.fsl index efcb7faac7..35d1c7fc3b 100644 --- a/src/fsharp/pplex.fsl +++ b/src/fsharp/pplex.fsl @@ -2,13 +2,13 @@ { -module internal Microsoft.FSharp.Compiler.PPLexer +module internal FSharp.Compiler.PPLexer open System -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lexhelp +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lexhelp open Internal.Utilities.Text.Lexing diff --git a/src/fsharp/pppars.fsy b/src/fsharp/pppars.fsy index 756eae8bf5..354fd0ac38 100644 --- a/src/fsharp/pppars.fsy +++ b/src/fsharp/pppars.fsy @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. %{ -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger let dummy = IfdefId("DUMMY") diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 4e97edc2b3..84419892a7 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Anything to do with special names of identifiers and other lexical rules -module Microsoft.FSharp.Compiler.Range +module FSharp.Compiler.Range open System open System.IO open System.Collections.Concurrent open Microsoft.FSharp.Core.Printf -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Lib.Bits +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Lib +open FSharp.Compiler.Lib.Bits type FileIndex = int32 diff --git a/src/fsharp/range.fsi b/src/fsharp/range.fsi index d4ef8be800..5da9bee549 100755 --- a/src/fsharp/range.fsi +++ b/src/fsharp/range.fsi @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module public Microsoft.FSharp.Compiler.Range +module public FSharp.Compiler.Range open System.Text open System.Collections.Generic open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler /// An index into a global tables of filenames diff --git a/src/fsharp/rational.fs b/src/fsharp/rational.fs index 4d72c2b5ad..b6c3588cdb 100644 --- a/src/fsharp/rational.fs +++ b/src/fsharp/rational.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Rational arithmetic, used for exponents on units-of-measure -module internal Microsoft.FSharp.Compiler.Rational +module internal FSharp.Compiler.Rational open System.Numerics diff --git a/src/fsharp/rational.fsi b/src/fsharp/rational.fsi index 21115b8880..30b5d6b8e7 100644 --- a/src/fsharp/rational.fsi +++ b/src/fsharp/rational.fsi @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Rational arithmetic, used for exponents on units-of-measure -module internal Microsoft.FSharp.Compiler.Rational +module internal FSharp.Compiler.Rational type Rational diff --git a/src/fsharp/service/ExternalSymbol.fs b/src/fsharp/service/ExternalSymbol.fs index ba22af9412..c0b4352c47 100644 --- a/src/fsharp/service/ExternalSymbol.fs +++ b/src/fsharp/service/ExternalSymbol.fs @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open FSharp.Reflection -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.IL open System.Diagnostics module private Option = diff --git a/src/fsharp/service/ExternalSymbol.fsi b/src/fsharp/service/ExternalSymbol.fsi index bd4cf75739..36d290db4d 100644 --- a/src/fsharp/service/ExternalSymbol.fsi +++ b/src/fsharp/service/ExternalSymbol.fsi @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open FSharp.Reflection -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.IL /// Represents a type in an external (non F#) assembly. [] diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index f5d0141b32..0c4ed00657 100755 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System @@ -8,23 +8,23 @@ open System.Collections.Concurrent open System.Collections.Generic open System.IO open System.Threading -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.CompileOptions -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.NameResolution +open FSharp.Compiler.Tastops +open FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.CompileOps +open FSharp.Compiler.CompileOptions +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypeChecker +open FSharp.Compiler.Tast +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices open Internal.Utilities.Collections [] @@ -714,7 +714,6 @@ module internal IncrementalBuild = | None -> acc | _ -> failwith "expected a VectorStamp" - /// Given the result of a single action, apply that action to the Build let ApplyResult(actionResult:ActionResult, bt:PartialBuild) = @@ -1015,7 +1014,7 @@ module IncrementalBuilderEventTesting = let GetMostRecentIncrementalBuildEvents(n) = MRU.MostRecentList(n) let GetCurrentIncrementalBuildEventNum() = MRU.CurrentEventNum -module Tc = Microsoft.FSharp.Compiler.TypeChecker +module Tc = FSharp.Compiler.TypeChecker /// Accumulated results of type checking. @@ -1493,10 +1492,14 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput let tcAssemblyDataOpt = try + // Assemblies containing type provider components can not successfully be used via cross-assembly references. // We return 'None' for the assembly portion of the cross-assembly reference let hasTypeProviderAssemblyAttrib = - topAttrs.assemblyAttrs |> List.exists (fun (Attrib(tcref, _, _, _, _, _, _)) -> tcref.CompiledRepresentationForNamedType.BasicQualifiedName = typeof.FullName) + topAttrs.assemblyAttrs |> List.exists (fun (Attrib(tcref, _, _, _, _, _, _)) -> + let nm = tcref.CompiledRepresentationForNamedType.BasicQualifiedName + nm = typeof.FullName) + if tcState.CreatesGeneratedProvidedTypes || hasTypeProviderAssemblyAttrib then None else @@ -1534,12 +1537,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput let stampedFileNamesNode = Vector.Stamp "SourceFileTimeStamps" StampFileNameTask fileNamesNode let stampedReferencedAssembliesNode = Vector.Stamp "StampReferencedAssembly" StampReferencedAssemblyTask referencedAssembliesNode let initialTcAccNode = Vector.Demultiplex "CombineImportedAssemblies" CombineImportedAssembliesTask stampedReferencedAssembliesNode -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - let parseTreesNode = Vector.Map "ParseTrees" ParseTask stampedFileNamesNode - let tcStatesNode = Vector.ScanLeft "TypeCheckingStates" TypeCheckTask initialTcAccNode stampedFileNamesNode -#else let tcStatesNode = Vector.ScanLeft "TypeCheckingStates" (fun ctok tcAcc n -> TypeCheckTask ctok tcAcc (ParseTask ctok n)) initialTcAccNode stampedFileNamesNode -#endif let finalizedTypeCheckNode = Vector.Demultiplex "FinalizeTypeCheck" FinalizeTypeCheckTask tcStatesNode // Outputs @@ -1547,9 +1545,6 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput do buildDescription.DeclareVectorOutput stampedFileNamesNode do buildDescription.DeclareVectorOutput stampedReferencedAssembliesNode -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - do buildDescription.DeclareVectorOutput parseTreesNode -#endif do buildDescription.DeclareVectorOutput tcStatesNode do buildDescription.DeclareScalarOutput initialTcAccNode do buildDescription.DeclareScalarOutput finalizedTypeCheckNode @@ -1682,7 +1677,11 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput | None -> // helpers to diagnose https://github.com/Microsoft/visualfsharp/pull/2460/ let brname = match GetTopLevelExprByName(build, finalizedTypeCheckNode.Name) with ScalarBuildRule se ->se.Id | _ -> Id 0xdeadbeef - let data = (finalizedTypeCheckNode.Name, ((build.Results :> IDictionary<_, _>).Keys |> Seq.toArray), brname, build.Results.ContainsKey brname, build.Results.TryFind brname |> Option.map (function ScalarResult(sr) -> Some(sr.TryGetAvailable().IsSome) | _ -> None)) + let data = (finalizedTypeCheckNode.Name, + ((build.Results :> IDictionary<_, _>).Keys |> Seq.toArray), + brname, + build.Results.ContainsKey brname, + build.Results.TryFind brname |> Option.map (function ScalarResult(sr) -> Some(sr.TryGetAvailable().IsSome) | _ -> None)) let msg = sprintf "Build was not evaluated, expected the results to be ready after 'Eval' (GetCheckResultsAndImplementationsForProject, data = %A)." data return! failwith msg } @@ -1712,15 +1711,6 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput member builder.GetParseResultsForFile (ctok: CompilationThreadToken, filename) = cancellable { let slotOfFile = builder.GetSlotOfFileName filename -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - match GetVectorResultBySlot(parseTreesNode, slotOfFile, partialBuild) with - | Some (results, _) -> return results - | None -> - let! build = IncrementalBuild.EvalUpTo ctok SavePartialBuild (parseTreesNode, slotOfFile) partialBuild - match GetVectorResultBySlot(parseTreesNode, slotOfFile, build) with - | Some (results, _) -> return results - | None -> return! failwith "Build was not evaluated, expected the results to be ready after 'Eval' (GetParseResultsForFile)." -#else let! results = cancellable { match GetVectorResultBySlot(stampedFileNamesNode, slotOfFile, partialBuild) with @@ -1734,14 +1724,23 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput } // re-parse on demand instead of retaining return ParseTask ctok results -#endif } member __.SourceFiles = sourceFiles |> List.map (fun (_, f, _) -> f) /// CreateIncrementalBuilder (for background type checking). Note that fsc.fs also /// creates an incremental builder used by the command line compiler. - static member TryCreateBackgroundBuilderForProjectOptions (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, frameworkTcImportsCache: FrameworkImportsCache, loadClosureOpt:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, keepAssemblyContents, keepAllBackgroundResolutions, maxTimeShareMilliseconds, tryGetMetadataSnapshot) = + static member TryCreateBackgroundBuilderForProjectOptions + (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, + frameworkTcImportsCache: FrameworkImportsCache, + loadClosureOpt:LoadClosure option, + sourceFiles:string list, + commandLineArgs:string list, + projectReferences, projectDirectory, + useScriptResolutionRules, keepAssemblyContents, + keepAllBackgroundResolutions, maxTimeShareMilliseconds, + tryGetMetadataSnapshot) = + let useSimpleResolutionSwitch = "--simpleresolution" cancellable { diff --git a/src/fsharp/service/IncrementalBuild.fsi b/src/fsharp/service/IncrementalBuild.fsi index 29c7a03a45..ff117a0a5c 100755 --- a/src/fsharp/service/IncrementalBuild.fsi +++ b/src/fsharp/service/IncrementalBuild.fsi @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.CompileOps +open FSharp.Compiler.NameResolution +open FSharp.Compiler.Tast +open FSharp.Compiler.SourceCodeServices /// Lookup the global static cache for building the FrameworkTcImports type internal FrameworkImportsCache = diff --git a/src/fsharp/service/QuickParse.fs b/src/fsharp/service/QuickParse.fs index 9e851fef05..9e962ac302 100644 --- a/src/fsharp/service/QuickParse.fs +++ b/src/fsharp/service/QuickParse.fs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.SourceCodeServices /// Qualified long name. type PartialLongName = @@ -48,7 +48,7 @@ module QuickParse = // - if we're inside active pattern name (at the bar), correct the token TAG to be an identifier let CorrectIdentifierToken (tokenText: string) (tokenTag: int) = if tokenText.EndsWithOrdinal("|") then - Microsoft.FSharp.Compiler.Parser.tagOfToken (Microsoft.FSharp.Compiler.Parser.token.IDENT tokenText) + FSharp.Compiler.Parser.tagOfToken (FSharp.Compiler.Parser.token.IDENT tokenText) else tokenTag let rec isValidStrippedName (name:string) idx = diff --git a/src/fsharp/service/QuickParse.fsi b/src/fsharp/service/QuickParse.fsi index 7857f94d4c..5f78dbefd2 100644 --- a/src/fsharp/service/QuickParse.fsi +++ b/src/fsharp/service/QuickParse.fsi @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices /// Qualified long name. type public PartialLongName = diff --git a/src/fsharp/service/Reactor.fs b/src/fsharp/service/Reactor.fs index d2b8bda7ea..bae570d0c5 100755 --- a/src/fsharp/service/Reactor.fs +++ b/src/fsharp/service/Reactor.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Diagnostics open System.Globalization open System.Threading open Microsoft.FSharp.Control -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL.Internal.Library /// Represents the capability to schedule work in the compiler service operations queue for the compilation thread type internal IReactorOperations = diff --git a/src/fsharp/service/Reactor.fsi b/src/fsharp/service/Reactor.fsi index b4bd46d167..5ea9572f48 100755 --- a/src/fsharp/service/Reactor.fsi +++ b/src/fsharp/service/Reactor.fsi @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System.Threading -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library /// Represents the capability to schedule work in the compiler service operations queue for the compilation thread type internal IReactorOperations = diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index 69049bc28f..f66d372bc2 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.PrettyNaming open System.Collections.Generic open System.Runtime.CompilerServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library module UnusedOpens = diff --git a/src/fsharp/service/ServiceAnalysis.fsi b/src/fsharp/service/ServiceAnalysis.fsi index cafaab2955..8d97644389 100644 --- a/src/fsharp/service/ServiceAnalysis.fsi +++ b/src/fsharp/service/ServiceAnalysis.fsi @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.NameResolution +open FSharp.Compiler.Range module public UnusedOpens = /// Get all unused open declarations in a file diff --git a/src/fsharp/service/ServiceAssemblyContent.fs b/src/fsharp/service/ServiceAssemblyContent.fs index 663ed82a94..9c131e4bd0 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fs +++ b/src/fsharp/service/ServiceAssemblyContent.fs @@ -5,15 +5,15 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.Internal.Library type ShortIdent = string type Idents = ShortIdent[] @@ -491,8 +491,8 @@ type OpenStatementInsertionPoint = | Nearest module ParsedInput = - open Microsoft.FSharp.Compiler - open Microsoft.FSharp.Compiler.Ast + open FSharp.Compiler + open FSharp.Compiler.Ast /// An recursive pattern that collect all sequential expressions to avoid StackOverflowException let rec (|Sequentials|_|) = function diff --git a/src/fsharp/service/ServiceAssemblyContent.fsi b/src/fsharp/service/ServiceAssemblyContent.fsi index 10c9dc4baa..0fe14c1144 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fsi +++ b/src/fsharp/service/ServiceAssemblyContent.fsi @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler +open FSharp.Compiler.Range /// Assembly content type. type public AssemblyContentType = diff --git a/src/fsharp/service/ServiceConstants.fs b/src/fsharp/service/ServiceConstants.fs index c2f298c4db..1628a277a3 100755 --- a/src/fsharp/service/ServiceConstants.fs +++ b/src/fsharp/service/ServiceConstants.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices [] type FSharpGlyph = diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index 22b851a5b8..8faf0c41c4 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -5,24 +5,24 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.InfoReader +namespace FSharp.Compiler.SourceCodeServices + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Layout +open FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.Infos +open FSharp.Compiler.NameResolution +open FSharp.Compiler.InfoReader [] module EnvMisc3 = @@ -715,7 +715,9 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForT /// a single, non-overloaded item such as union case or a named function value. // Note: instances of this type do not hold any references to any compiler resources. [] -type FSharpMethodGroupItem(description: FSharpToolTipText, xmlDoc: FSharpXmlDoc, returnType: layout, parameters: FSharpMethodGroupItemParameter[], hasParameters: bool, hasParamArrayArg: bool, staticParameters: FSharpMethodGroupItemParameter[]) = +type FSharpMethodGroupItem(description: FSharpToolTipText, xmlDoc: FSharpXmlDoc, + returnType: layout, parameters: FSharpMethodGroupItemParameter[], + hasParameters: bool, hasParamArrayArg: bool, staticParameters: FSharpMethodGroupItemParameter[]) = /// The structured description representation for the method (or other item) member __.StructuredDescription = description diff --git a/src/fsharp/service/ServiceDeclarationLists.fsi b/src/fsharp/service/ServiceDeclarationLists.fsi index 2beee7024f..4dc7905251 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fsi +++ b/src/fsharp/service/ServiceDeclarationLists.fsi @@ -3,12 +3,12 @@ //---------------------------------------------------------------------------- // API for declaration lists and method overload lists -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tastops +open FSharp.Compiler.Range +open FSharp.Compiler.NameResolution +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tastops [] diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fs b/src/fsharp/service/ServiceInterfaceStubGenerator.fs index 90a8ae4d7b..d2ec593838 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fs +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Diagnostics open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal.Library #if !FX_NO_INDENTED_TEXT_WRITER [] diff --git a/src/fsharp/service/ServiceInterfaceStubGenerator.fsi b/src/fsharp/service/ServiceInterfaceStubGenerator.fsi index 428b73f830..49a0da63d3 100644 --- a/src/fsharp/service/ServiceInterfaceStubGenerator.fsi +++ b/src/fsharp/service/ServiceInterfaceStubGenerator.fsi @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Diagnostics open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal.Library #if !FX_NO_INDENTED_TEXT_WRITER /// Capture information about an interface in ASTs diff --git a/src/fsharp/service/ServiceLexing.fs b/src/fsharp/service/ServiceLexing.fs index 5eda7cb31d..6954e70fb7 100755 --- a/src/fsharp/service/ServiceLexing.fs +++ b/src/fsharp/service/ServiceLexing.fs @@ -4,19 +4,19 @@ // Open up the compiler as an incremental service for lexing. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Parser -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Parser +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lexhelp +open FSharp.Compiler.Lib type Position = int * int type Range = Position * Position @@ -257,7 +257,10 @@ module internal TokenClassifications = | PUBLIC | PRIVATE | INTERNAL | BASE | GLOBAL | CONSTRAINT | INSTANCE | DELEGATE | INHERIT|CONSTRUCTOR|DEFAULT|OVERRIDE|ABSTRACT|CLASS | MEMBER | STATIC | NAMESPACE - | OASSERT | OLAZY | ODECLEND | OBLOCKSEP | OEND | OBLOCKBEGIN | ORIGHT_BLOCK_END | OBLOCKEND | OBLOCKEND_COMING_SOON | OBLOCKEND_IS_HERE | OTHEN | OELSE | OLET(_) | OBINDER _ | BINDER _ | ODO | OWITH | OFUNCTION | OFUN | ORESET | ODUMMY _ | DO_BANG | ODO_BANG | YIELD _ | YIELD_BANG _ | OINTERFACE_MEMBER + | OASSERT | OLAZY | ODECLEND | OBLOCKSEP | OEND | OBLOCKBEGIN | ORIGHT_BLOCK_END + | OBLOCKEND | OBLOCKEND_COMING_SOON | OBLOCKEND_IS_HERE | OTHEN | OELSE | OLET(_) + | OBINDER _ | BINDER _ | ODO | OWITH | OFUNCTION | OFUN | ORESET | ODUMMY _ | DO_BANG + | ODO_BANG | YIELD _ | YIELD_BANG _ | OINTERFACE_MEMBER | ELIF | RARROW | LARROW | SIG | STRUCT | UPCAST | DOWNCAST | NULL | RESERVED | MODULE | AND | AS | ASSERT | ASR | DOWNTO | EXCEPTION | FALSE | FOR | FUN | FUNCTION @@ -772,7 +775,7 @@ type FSharpSourceTokenizer(defineConstants : string list, filename : string opti FSharpLineTokenizer(lexbuf, None, filename, lexArgsLightOn, lexArgsLightOff) module Keywords = - open Microsoft.FSharp.Compiler.Lexhelp.Keywords + open FSharp.Compiler.Lexhelp.Keywords let QuoteIdentifierIfNeeded s = QuoteIdentifierIfNeeded s let NormalizeIdentifierBackticks s = NormalizeIdentifierBackticks s diff --git a/src/fsharp/service/ServiceLexing.fsi b/src/fsharp/service/ServiceLexing.fsi index d354e452e1..84fa2e571a 100755 --- a/src/fsharp/service/ServiceLexing.fsi +++ b/src/fsharp/service/ServiceLexing.fsi @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler +open FSharp.Compiler type Position = int * int type Range = Position * Position diff --git a/src/fsharp/service/ServiceNavigation.fs b/src/fsharp/service/ServiceNavigation.fs index e0e1feb1b3..a853805182 100755 --- a/src/fsharp/service/ServiceNavigation.fs +++ b/src/fsharp/service/ServiceNavigation.fs @@ -5,10 +5,10 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.Ast /// Represents the different kinds of items that can appear in the navigation bar type FSharpNavigationDeclarationItemKind = diff --git a/src/fsharp/service/ServiceNavigation.fsi b/src/fsharp/service/ServiceNavigation.fsi index 2f7464ba21..be15736601 100755 --- a/src/fsharp/service/ServiceNavigation.fsi +++ b/src/fsharp/service/ServiceNavigation.fsi @@ -5,9 +5,9 @@ // type checking and intellisense-like environment-reporting. //---------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler +open FSharp.Compiler /// Indicates a kind of item to show in an F# navigation bar type public FSharpNavigationDeclarationItemKind = diff --git a/src/fsharp/service/ServiceParamInfoLocations.fs b/src/fsharp/service/ServiceParamInfoLocations.fs index e0e9affd2d..f527e493ba 100755 --- a/src/fsharp/service/ServiceParamInfoLocations.fs +++ b/src/fsharp/service/ServiceParamInfoLocations.fs @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.Ast [] type FSharpNoteworthyParamInfoLocations(longId: string list, longIdRange: range, openParenLocation: pos, tupleEndLocations: pos list, isThereACloseParen: bool, namedParamNames: string option list) = diff --git a/src/fsharp/service/ServiceParamInfoLocations.fsi b/src/fsharp/service/ServiceParamInfoLocations.fsi index 6f9282c520..6961c892b0 100755 --- a/src/fsharp/service/ServiceParamInfoLocations.fsi +++ b/src/fsharp/service/ServiceParamInfoLocations.fsi @@ -5,10 +5,10 @@ // type checking and intellisense-like environment-reporting. //---------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler +open FSharp.Compiler.Range /// Represents the locations relevant to activating parameter info in an IDE [] diff --git a/src/fsharp/service/ServiceParseTreeWalk.fs b/src/fsharp/service/ServiceParseTreeWalk.fs index 14e08c9b2d..40e6580cc8 100755 --- a/src/fsharp/service/ServiceParseTreeWalk.fs +++ b/src/fsharp/service/ServiceParseTreeWalk.fs @@ -5,10 +5,10 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.Ast /// A range of utility functions to assist with traversing an AST diff --git a/src/fsharp/service/ServiceStructure.fs b/src/fsharp/service/ServiceStructure.fs index a89afd44c5..8c25bee2a1 100644 --- a/src/fsharp/service/ServiceStructure.fs +++ b/src/fsharp/service/ServiceStructure.fs @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.Ast +open FSharp.Compiler +open FSharp.Compiler.Range module Structure = /// Set of visitor utilities, designed for the express purpose of fetching ranges diff --git a/src/fsharp/service/ServiceStructure.fsi b/src/fsharp/service/ServiceStructure.fsi index a7a054a411..ef90f4627e 100644 --- a/src/fsharp/service/ServiceStructure.fsi +++ b/src/fsharp/service/ServiceStructure.fsi @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.Range module public Structure = diff --git a/src/fsharp/service/ServiceUntypedParse.fs b/src/fsharp/service/ServiceUntypedParse.fs index 62c8892331..42036bec58 100755 --- a/src/fsharp/service/ServiceUntypedParse.fs +++ b/src/fsharp/service/ServiceUntypedParse.fs @@ -5,20 +5,20 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.IO open System.Collections.Generic open System.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.Lib +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.CompileOps +open FSharp.Compiler.Lib /// Methods for dealing with F# sources files. module SourceFile = @@ -445,7 +445,7 @@ type EntityKind = module UntypedParseImpl = open System.Text.RegularExpressions - open Microsoft.FSharp.Compiler.PrettyNaming + open FSharp.Compiler.PrettyNaming let emptyStringSet = HashSet() @@ -791,7 +791,7 @@ module UntypedParseImpl = and walkType = function | SynType.LongIdent ident -> // we protect it with try..with because System.Exception : rangeOfLidwd may raise - // at Microsoft.FSharp.Compiler.Ast.LongIdentWithDots.get_Range() in D:\j\workspace\release_ci_pa---3f142ccc\src\fsharp\ast.fs:line 156 + // at FSharp.Compiler.Ast.LongIdentWithDots.get_Range() in D:\j\workspace\release_ci_pa---3f142ccc\src\fsharp\ast.fs:line 156 try ifPosInRange ident.Range (fun _ -> Some EntityKind.Type) with _ -> None | SynType.App(ty, _, types, _, _, _, _) -> walkType ty |> Option.orElse (List.tryPick walkType types) diff --git a/src/fsharp/service/ServiceUntypedParse.fsi b/src/fsharp/service/ServiceUntypedParse.fsi index 40339e85f9..8a88f766c8 100755 --- a/src/fsharp/service/ServiceUntypedParse.fsi +++ b/src/fsharp/service/ServiceUntypedParse.fsi @@ -5,13 +5,13 @@ // type checking and intellisense-like environment-reporting. //---------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Range +open FSharp.Compiler.ErrorLogger [] /// Represents the results of parsing an F# file diff --git a/src/fsharp/service/ServiceXmlDocParser.fs b/src/fsharp/service/ServiceXmlDocParser.fs index 0cfd5ec6b7..7cf4f3fb31 100644 --- a/src/fsharp/service/ServiceXmlDocParser.fs +++ b/src/fsharp/service/ServiceXmlDocParser.fs @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library /// Represent an Xml documentation block in source code type XmlDocable = | XmlDocable of line:int * indent:int * paramNames:string list module XmlDocParsing = - open Microsoft.FSharp.Compiler.Range - open Microsoft.FSharp.Compiler.Ast + open FSharp.Compiler.Range + open FSharp.Compiler.Ast let (|ConstructorPats|) = function | Pats ps -> ps diff --git a/src/fsharp/service/ServiceXmlDocParser.fsi b/src/fsharp/service/ServiceXmlDocParser.fsi index 7ba0ae6e7b..128f351e29 100644 --- a/src/fsharp/service/ServiceXmlDocParser.fsi +++ b/src/fsharp/service/ServiceXmlDocParser.fsi @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Ast /// Represent an Xml documentation block in source code type public XmlDocable = diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 7fbc49c1f3..3c624fd7d5 100755 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -3,7 +3,7 @@ // Open up the compiler as an incremental service for parsing, // type checking and intellisense-like environment-reporting. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Collections.Generic @@ -14,38 +14,38 @@ open System.Reflection open System.Text open Microsoft.FSharp.Core.Printf -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library - -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.CompileOptions -open Microsoft.FSharp.Compiler.Driver -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Parser -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Lexhelp -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.TypeChecker -open Microsoft.FSharp.Compiler.SourceCodeServices.SymbolHelpers +open FSharp.Compiler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.Diagnostics +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library + +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.CompileOps +open FSharp.Compiler.CompileOptions +open FSharp.Compiler.Driver +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Parser +open FSharp.Compiler.Range +open FSharp.Compiler.Lexhelp +open FSharp.Compiler.Layout +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos +open FSharp.Compiler.InfoReader +open FSharp.Compiler.NameResolution +open FSharp.Compiler.TypeChecker +open FSharp.Compiler.SourceCodeServices.SymbolHelpers open Internal.Utilities open Internal.Utilities.Collections -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.Layout.TaggedTextOps #if FX_RESHAPED_REFLECTION open Microsoft.FSharp.Core.ReflectionAdapters @@ -317,7 +317,7 @@ type TypeCheckInfo // check that type of value is the same or subtype of tcref // yes - allow access to protected members // no - strip ability to access protected members - if Microsoft.FSharp.Compiler.TypeRelations.TypeFeasiblySubsumesType 0 g amap m tcref Microsoft.FSharp.Compiler.TypeRelations.CanCoerce ty then + if FSharp.Compiler.TypeRelations.TypeFeasiblySubsumesType 0 g amap m tcref FSharp.Compiler.TypeRelations.CanCoerce ty then ad else AccessibleFrom(paths, None) @@ -3384,10 +3384,10 @@ module DebuggerEnvironment = System.Guid(0xAB4F38C9u, 0xB6E6us, 0x43baus, 0xBEuy, 0x3Buy, 0x58uy, 0x08uy, 0x0Buy, 0x2Cuy, 0xCCuy, 0xE3uy) module PrettyNaming = - let IsIdentifierPartCharacter x = Microsoft.FSharp.Compiler.PrettyNaming.IsIdentifierPartCharacter x - let IsLongIdentifierPartCharacter x = Microsoft.FSharp.Compiler.PrettyNaming.IsLongIdentifierPartCharacter x - let IsOperatorName x = Microsoft.FSharp.Compiler.PrettyNaming.IsOperatorName x - let GetLongNameFromString x = Microsoft.FSharp.Compiler.PrettyNaming.SplitNamesForILPath x + let IsIdentifierPartCharacter x = FSharp.Compiler.PrettyNaming.IsIdentifierPartCharacter x + let IsLongIdentifierPartCharacter x = FSharp.Compiler.PrettyNaming.IsLongIdentifierPartCharacter x + let IsOperatorName x = FSharp.Compiler.PrettyNaming.IsOperatorName x + let GetLongNameFromString x = FSharp.Compiler.PrettyNaming.SplitNamesForILPath x let FormatAndOtherOverloadsString remainingOverloads = FSComp.SR.typeInfoOtherOverloads(remainingOverloads) let QuoteIdentifierIfNeeded id = Lexhelp.Keywords.QuoteIdentifierIfNeeded id let KeywordNames = Lexhelp.Keywords.keywordNames diff --git a/src/fsharp/service/service.fsi b/src/fsharp/service/service.fsi index 2d07c23561..5952587d8f 100755 --- a/src/fsharp/service/service.fsi +++ b/src/fsharp/service/service.fsi @@ -5,27 +5,27 @@ // type checking and intellisense-like environment-reporting. //---------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Driver -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.Driver +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Range +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.NameResolution +open FSharp.Compiler.CompileOps +open FSharp.Compiler.Infos +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops /// Represents the reason why the GetDeclarationLocation operation failed. [] diff --git a/src/fsharp/sr.fs b/src/fsharp/sr.fs index 03e390c597..7eab19223f 100755 --- a/src/fsharp/sr.fs +++ b/src/fsharp/sr.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open Microsoft.FSharp.Core open Microsoft.FSharp.Core.Operators open Microsoft.FSharp.Collections diff --git a/src/fsharp/sr.fsi b/src/fsharp/sr.fsi index 00fed3bf25..72ead23feb 100755 --- a/src/fsharp/sr.fsi +++ b/src/fsharp/sr.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler module internal SR = val GetString : string -> string diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs index 4da520daed..ba9925616c 100644 --- a/src/fsharp/symbols/Exprs.fs +++ b/src/fsharp/symbols/Exprs.fs @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.QuotationTranslator -open Microsoft.FSharp.Compiler.TypeRelations +namespace FSharp.Compiler.SourceCodeServices + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Lib +open FSharp.Compiler.Infos +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.QuotationTranslator +open FSharp.Compiler.TypeRelations [] module ExprTranslationImpl = @@ -51,8 +51,11 @@ module ExprTranslationImpl = member env.BindSubstVal v e = { env with substVals = env.substVals.Add v e } - member env.BindVals vs = (env, vs) ||> List.fold (fun env v -> env.BindVal v) - member env.BindCurriedVals vsl = (env, vsl) ||> List.fold (fun env vs -> env.BindVals vs) + member env.BindVals vs = + (env, vs) ||> List.fold (fun env v -> env.BindVal v) + + member env.BindCurriedVals vsl = + (env, vsl) ||> List.fold (fun env vs -> env.BindVals vs) exception IgnoringPartOfQuotedTermWarning of string * Range.range @@ -81,6 +84,8 @@ type E = | FSharpFieldGet of FSharpExpr option * FSharpType * FSharpField | FSharpFieldSet of FSharpExpr option * FSharpType * FSharpField * FSharpExpr | NewUnionCase of FSharpType * FSharpUnionCase * FSharpExpr list + | NewAnonRecord of FSharpType * FSharpExpr list + | AnonRecordGet of FSharpExpr * FSharpType * int | UnionCaseGet of FSharpExpr * FSharpType * FSharpUnionCase * FSharpField | UnionCaseSet of FSharpExpr * FSharpType * FSharpUnionCase * FSharpField * FSharpExpr | UnionCaseTag of FSharpExpr * FSharpType @@ -134,6 +139,8 @@ and [] FSharpExpr (cenv, f: (unit -> FSharpExpr) option, e: E, m:range, | E.Let ((_bindingVar, bindingExpr), b) -> [bindingExpr;b] | E.LetRec (ves, b) -> (List.map snd ves) @ [b] | E.NewRecord (_recordType, es) -> es + | E.NewAnonRecord (_recordType, es) -> es + | E.AnonRecordGet (e, _recordType, _n) -> [e] | E.NewUnionCase (_unionType, _unionCase, es) -> es | E.NewTuple (_tupleType, es) -> es | E.TupleGet (_tupleType, _itemIndex, tupleExpr) -> [tupleExpr] @@ -559,6 +566,11 @@ module FSharpExprConvert = let argsR = ConvExprs cenv env args E.NewUnionCase(typR, mkR, argsR) + | TOp.AnonRecd anonInfo, _, _ -> + let typR = ConvType cenv (mkAnyAnonRecdTy cenv.g anonInfo tyargs) + let argsR = ConvExprs cenv env args + E.NewAnonRecord(typR, argsR) + | TOp.Tuple tupInfo, tyargs, _ -> let tyR = ConvType cenv (mkAnyTupledTy cenv.g tupInfo tyargs) let argsR = ConvExprs cenv env args @@ -575,6 +587,10 @@ module FSharpExprConvert = let projR = FSharpField(cenv, ucref, n) E.UnionCaseGet(ConvExpr cenv env e1, typR, mkR, projR) + | TOp.AnonRecdGet (anonInfo, n), tyargs, [e1] -> + let typR = ConvType cenv (mkAnyAnonRecdTy cenv.g anonInfo tyargs) + E.AnonRecordGet(ConvExpr cenv env e1, typR, n) + | TOp.UnionCaseFieldSet (ucref, n), tyargs, [e1;e2] -> let mkR = ConvUnionCaseRef cenv ucref let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) @@ -1277,12 +1293,14 @@ module BasicPatterns = let (|Let|_|) (e:FSharpExpr) = match e.E with E.Let ((v, e), b) -> Some ((v, e), b) | _ -> None let (|LetRec|_|) (e:FSharpExpr) = match e.E with E.LetRec (ves, b) -> Some (ves, b) | _ -> None let (|NewRecord|_|) (e:FSharpExpr) = match e.E with E.NewRecord (ty, es) -> Some (ty, es) | _ -> None + let (|NewAnonRecord|_|) (e:FSharpExpr) = match e.E with E.NewAnonRecord (ty, es) -> Some (ty, es) | _ -> None let (|NewUnionCase|_|) (e:FSharpExpr) = match e.E with E.NewUnionCase (e, tys, es) -> Some (e, tys, es) | _ -> None let (|NewTuple|_|) (e:FSharpExpr) = match e.E with E.NewTuple (ty, es) -> Some (ty, es) | _ -> None let (|TupleGet|_|) (e:FSharpExpr) = match e.E with E.TupleGet (ty, n, es) -> Some (ty, n, es) | _ -> None let (|Call|_|) (e:FSharpExpr) = match e.E with E.Call (a, b, c, d, e) -> Some (a, b, c, d, e) | _ -> None let (|NewObject|_|) (e:FSharpExpr) = match e.E with E.NewObject (a, b, c) -> Some (a, b, c) | _ -> None let (|FSharpFieldGet|_|) (e:FSharpExpr) = match e.E with E.FSharpFieldGet (a, b, c) -> Some (a, b, c) | _ -> None + let (|AnonRecordGet|_|) (e:FSharpExpr) = match e.E with E.AnonRecordGet (a, b, c) -> Some (a, b, c) | _ -> None let (|FSharpFieldSet|_|) (e:FSharpExpr) = match e.E with E.FSharpFieldSet (a, b, c, d) -> Some (a, b, c, d) | _ -> None let (|UnionCaseGet|_|) (e:FSharpExpr) = match e.E with E.UnionCaseGet (a, b, c, d) -> Some (a, b, c, d) | _ -> None let (|UnionCaseTag|_|) (e:FSharpExpr) = match e.E with E.UnionCaseTag (a, b) -> Some (a, b) | _ -> None diff --git a/src/fsharp/symbols/Exprs.fsi b/src/fsharp/symbols/Exprs.fsi index c9049b33c1..fd5d88c022 100644 --- a/src/fsharp/symbols/Exprs.fsi +++ b/src/fsharp/symbols/Exprs.fsi @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.CompileOps +open FSharp.Compiler +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Tast +open FSharp.Compiler.Range +open FSharp.Compiler.CompileOps /// Represents the definitional contents of an assembly, as seen by the F# language @@ -127,6 +127,13 @@ module public BasicPatterns = /// Matches record expressions val (|NewRecord|_|) : FSharpExpr -> (FSharpType * FSharpExpr list) option + /// Matches anonymous record expressions + val (|NewAnonRecord|_|) : FSharpExpr -> (FSharpType * FSharpExpr list) option + + /// Matches expressions getting a field from an anonymous record. The integer represents the + /// index into the sorted fields of the anonymous record. + val (|AnonRecordGet|_|) : FSharpExpr -> (FSharpExpr * FSharpType * int) option + /// Matches expressions which get a field from a record or class val (|FSharpFieldGet|_|) : FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField) option diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index f4fb7c0238..95d968b070 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -5,32 +5,32 @@ // type checking and intellisense-like environment-reporting. //-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System open System.Collections.Generic open System.IO open Microsoft.FSharp.Core.Printf -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics - -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Layout -open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.CompileOps +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Diagnostics + +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Layout +open FSharp.Compiler.Layout.TaggedTextOps +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.Range +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos +open FSharp.Compiler.NameResolution +open FSharp.Compiler.InfoReader +open FSharp.Compiler.CompileOps module EnvMisc2 = let maxMembers = GetEnvInteger "FCS_MaxMembersInQuickInfo" 10 @@ -547,7 +547,9 @@ module internal SymbolHelpers = | false -> filminfo.GetParamTypes(amap, m, minfo.FormalMethodInst) // http://msdn.microsoft.com/en-us/library/fsbx0t7x.aspx - // If the name of the item itself has periods, they are replaced by the hash-sign ('#'). It is assumed that no item has a hash-sign directly in its name. For example, the fully qualified name of the String constructor would be "System.String.#ctor". + // If the name of the item itself has periods, they are replaced by the hash-sign ('#'). + // It is assumed that no item has a hash-sign directly in its name. For example, the fully + // qualified name of the String constructor would be "System.String.#ctor". let normalizedName = ilminfo.ILName.Replace(".", "#") Some (ccuFileName, "M:"+actualTypeName+"."+normalizedName+genArity+XmlDocArgsEnc g (formalTypars, fmtps) args) diff --git a/src/fsharp/symbols/SymbolHelpers.fsi b/src/fsharp/symbols/SymbolHelpers.fsi index cbc351baf5..205d573961 100755 --- a/src/fsharp/symbols/SymbolHelpers.fsi +++ b/src/fsharp/symbols/SymbolHelpers.fsi @@ -4,18 +4,18 @@ // Helpers for quick info and information about items //---------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.ErrorLogger +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Infos +open FSharp.Compiler.NameResolution +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Tast +open FSharp.Compiler.Tastops +open FSharp.Compiler.ErrorLogger //---------------------------------------------------------------------------- // Object model for diagnostics diff --git a/src/fsharp/symbols/SymbolPatterns.fs b/src/fsharp/symbols/SymbolPatterns.fs index eb12229f7c..2265682692 100644 --- a/src/fsharp/symbols/SymbolPatterns.fs +++ b/src/fsharp/symbols/SymbolPatterns.fs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices /// Patterns over FSharpSymbol and derivatives. [] module Symbol = open System open System.Text.RegularExpressions - open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library + open FSharp.Compiler.AbstractIL.Internal.Library let isAttribute<'T> (attribute: FSharpAttribute) = // CompiledName throws exception on DataContractAttribute generated by SQLProvider diff --git a/src/fsharp/symbols/SymbolPatterns.fsi b/src/fsharp/symbols/SymbolPatterns.fsi index 9b86aa3a54..c4c242270c 100644 --- a/src/fsharp/symbols/SymbolPatterns.fsi +++ b/src/fsharp/symbols/SymbolPatterns.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices [] /// Patterns over FSharpSymbol and derivatives. diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index fa3fcccfc8..43622f44e5 100755 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.AttributeChecking -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Tastops +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Infos +open FSharp.Compiler.AttributeChecking +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.CompileOps +open FSharp.Compiler.Tast +open FSharp.Compiler.NameResolution +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.Lib +open FSharp.Compiler.Tastops open Internal.Utilities type FSharpAccessibility(a:Accessibility, ?isProtected) = diff --git a/src/fsharp/symbols/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi index 3f3a3f0e0e..bd5e0b188d 100644 --- a/src/fsharp/symbols/Symbols.fsi +++ b/src/fsharp/symbols/Symbols.fsi @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.CompileOps -open Microsoft.FSharp.Compiler.Import -open Microsoft.FSharp.Compiler.InfoReader -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.Tast -open Microsoft.FSharp.Compiler.TcGlobals -open Microsoft.FSharp.Compiler.NameResolution +open FSharp.Compiler +open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.CompileOps +open FSharp.Compiler.Import +open FSharp.Compiler.InfoReader +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.Tast +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.NameResolution // Implementation details used by other code in the compiler type internal SymbolEnv = diff --git a/src/fsharp/tainted.fs b/src/fsharp/tainted.fs index 5d43f46390..ebdc96c746 100755 --- a/src/fsharp/tainted.fs +++ b/src/fsharp/tainted.fs @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler #if !NO_EXTENSIONTYPING open System -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.Range open Microsoft.FSharp.Core.CompilerServices -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library open System.Reflection open System.Collections.Generic open ErrorLogger @@ -17,7 +17,7 @@ type internal TypeProviderError ( errNum : int, tpDesignation : string, - m:Microsoft.FSharp.Compiler.Range.range, + m:FSharp.Compiler.Range.range, errors : string list, typeNameContext : string option, methodNameContext : string option diff --git a/src/fsharp/tainted.fsi b/src/fsharp/tainted.fsi index 228efbf606..c5220feb6c 100755 --- a/src/fsharp/tainted.fsi +++ b/src/fsharp/tainted.fsi @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler #if !NO_EXTENSIONTYPING @@ -8,8 +8,8 @@ namespace Microsoft.FSharp.Compiler open System open System.Reflection open Microsoft.FSharp.Core.CompilerServices -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.Range +open FSharp.Compiler.AbstractIL.IL /// Stores and transports aggregated list of errors reported by the type provider type internal TypeProviderError = diff --git a/src/fsharp/tast.fs b/src/fsharp/tast.fs index 63e7412d90..4a9cdb0173 100644 --- a/src/fsharp/tast.fs +++ b/src/fsharp/tast.fs @@ -4,31 +4,31 @@ // Defines the typed abstract syntax trees used throughout the F# compiler. //------------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.Tast +module internal FSharp.Compiler.Tast open System open System.Collections.Generic open System.Diagnostics open System.Reflection open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types - -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.QuotationPickler +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types + +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.Ast +open FSharp.Compiler.ErrorLogger +open FSharp.Compiler.Lib +open FSharp.Compiler.PrettyNaming +open FSharp.Compiler.QuotationPickler open Microsoft.FSharp.Core.Printf -open Microsoft.FSharp.Compiler.Rational +open FSharp.Compiler.Rational #if !NO_EXTENSIONTYPING -open Microsoft.FSharp.Compiler.ExtensionTyping +open FSharp.Compiler.ExtensionTyping open Microsoft.FSharp.Core.CompilerServices #endif @@ -658,7 +658,16 @@ and /// Represents a type definition, exception definition, module definition or mutable entity_opt_data : EntityOptionalData option } - static member EmptyEntityOptData = { entity_compiled_name = None; entity_other_range = None; entity_kind = TyparKind.Type; entity_xmldoc = XmlDoc.Empty; entity_xmldocsig = ""; entity_tycon_abbrev = None; entity_tycon_repr_accessibility = TAccess []; entity_accessiblity = TAccess []; entity_exn_info = TExnNone } + static member NewEmptyEntityOptData() = + { entity_compiled_name = None + entity_other_range = None + entity_kind = TyparKind.Type + entity_xmldoc = XmlDoc.Empty + entity_xmldocsig = "" + entity_tycon_abbrev = None + entity_tycon_repr_accessibility = TAccess [] + entity_accessiblity = TAccess [] + entity_exn_info = TExnNone } /// The name of the namespace, module or type, possibly with mangling, e.g. List`1, List or FailureException member x.LogicalName = x.entity_logical_name @@ -677,7 +686,7 @@ and /// Represents a type definition, exception definition, module definition or member x.SetCompiledName(name) = match x.entity_opt_data with | Some optData -> optData.entity_compiled_name <- name - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_compiled_name = name } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_compiled_name = name } /// The display name of the namespace, module or type, e.g. List instead of List`1, and no static parameters member x.DisplayName = x.GetDisplayName(false, false) @@ -748,7 +757,7 @@ and /// Represents a type definition, exception definition, module definition or member x.SetOtherRange m = match x.entity_opt_data with | Some optData -> optData.entity_other_range <- Some m - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_other_range = Some m } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_other_range = Some m } /// A unique stamp for this module, namespace or type definition within the context of this compilation. /// Note that because of signatures, there are situations where in a single compilation the "same" @@ -783,7 +792,7 @@ and /// Represents a type definition, exception definition, module definition or and set v = match x.entity_opt_data with | Some optData -> optData.entity_xmldocsig <- v - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_xmldocsig = v } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_xmldocsig = v } /// The logical contents of the entity when it is a module or namespace fragment. member x.ModuleOrNamespaceType = x.entity_modul_contents.Force() @@ -800,7 +809,7 @@ and /// Represents a type definition, exception definition, module definition or member x.SetTypeOrMeasureKind kind = match x.entity_opt_data with | Some optData -> optData.entity_kind <- kind - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_kind = kind } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_kind = kind } /// The identifier at the point of declaration of the type definition. member x.Id = ident(x.LogicalName, x.Range) @@ -817,7 +826,7 @@ and /// Represents a type definition, exception definition, module definition or member x.SetExceptionInfo exn_info = match x.entity_opt_data with | Some optData -> optData.entity_exn_info <- exn_info - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_exn_info = exn_info } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_exn_info = exn_info } /// Indicates if the entity represents an F# exception declaration. member x.IsExceptionDecl = match x.ExceptionInfo with TExnNone -> false | _ -> true @@ -843,7 +852,7 @@ and /// Represents a type definition, exception definition, module definition or member x.SetTypeAbbrev tycon_abbrev = match x.entity_opt_data with | Some optData -> optData.entity_tycon_abbrev <- tycon_abbrev - | _ -> x.entity_opt_data <- Some { Entity.EmptyEntityOptData with entity_tycon_abbrev = tycon_abbrev } + | _ -> x.entity_opt_data <- Some { Entity.NewEmptyEntityOptData() with entity_tycon_abbrev = tycon_abbrev } /// Indicates if this entity is an F# type abbreviation definition member x.IsTypeAbbrev = x.TypeAbbrev.IsSome @@ -1020,7 +1029,16 @@ and /// Represents a type definition, exception definition, module definition or x.entity_il_repr_cache <- tg.entity_il_repr_cache match tg.entity_opt_data with | Some tg -> - x.entity_opt_data <- Some { entity_compiled_name = tg.entity_compiled_name; entity_other_range = tg.entity_other_range; entity_kind = tg.entity_kind; entity_xmldoc = tg.entity_xmldoc; entity_xmldocsig = tg.entity_xmldocsig; entity_tycon_abbrev = tg.entity_tycon_abbrev; entity_tycon_repr_accessibility = tg.entity_tycon_repr_accessibility; entity_accessiblity = tg.entity_accessiblity; entity_exn_info = tg.entity_exn_info } + x.entity_opt_data <- + Some { entity_compiled_name = tg.entity_compiled_name + entity_other_range = tg.entity_other_range + entity_kind = tg.entity_kind + entity_xmldoc = tg.entity_xmldoc + entity_xmldocsig = tg.entity_xmldocsig + entity_tycon_abbrev = tg.entity_tycon_abbrev + entity_tycon_repr_accessibility = tg.entity_tycon_repr_accessibility + entity_accessiblity = tg.entity_accessiblity + entity_exn_info = tg.entity_exn_info } | None -> () @@ -2045,7 +2063,7 @@ and Construct = entity_opt_data = match kind, access with | TyparKind.Type, TAccess [] -> None - | _ -> Some { Entity.EmptyEntityOptData with entity_kind = kind; entity_accessiblity = access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_accessiblity = access } } #endif static member NewModuleOrNamespace cpath access (id:Ident) xml attribs mtype = @@ -2067,7 +2085,7 @@ and Construct = entity_opt_data = match xml, access with | XmlDoc [||], TAccess [] -> None - | _ -> Some { Entity.EmptyEntityOptData with entity_xmldoc = xml; entity_tycon_repr_accessibility = access; entity_accessiblity = access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = xml; entity_tycon_repr_accessibility = access; entity_accessiblity = access } } and [] @@ -2537,7 +2555,18 @@ and [] mutable val_opt_data : ValOptionalData option } - static member EmptyValOptData = { val_compiled_name = None; val_other_range = None; val_const = None; val_defn = None; val_repr_info = None; val_access = TAccess []; val_xmldoc = XmlDoc.Empty; val_member_info = None; val_declaring_entity = ParentNone; val_xmldocsig = String.Empty; val_attribs = [] } + static member NewEmptyValOptData() = + { val_compiled_name = None + val_other_range = None + val_const = None + val_defn = None + val_repr_info = None + val_access = TAccess [] + val_xmldoc = XmlDoc.Empty + val_member_info = None + val_declaring_entity = ParentNone + val_xmldocsig = String.Empty + val_attribs = [] } /// Range of the definition (implementation) of the value, used by Visual Studio member x.DefinitionRange = @@ -2747,7 +2776,7 @@ and [] and set(v) = match x.val_opt_data with | Some optData -> optData.val_xmldocsig <- v - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_xmldocsig = v } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_xmldocsig = v } /// The parent type or module, if any (None for expression bindings and parameters) member x.DeclaringEntity = @@ -2922,34 +2951,34 @@ and [] member x.SetValReprInfo info = match x.val_opt_data with | Some optData -> optData.val_repr_info <- info - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_repr_info = info } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_repr_info = info } member x.SetType ty = x.val_type <- ty member x.SetOtherRange m = match x.val_opt_data with | Some optData -> optData.val_other_range <- Some m - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_other_range = Some m } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_other_range = Some m } member x.SetDeclaringEntity parent = match x.val_opt_data with | Some optData -> optData.val_declaring_entity <- parent - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_declaring_entity = parent } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_declaring_entity = parent } member x.SetAttribs attribs = match x.val_opt_data with | Some optData -> optData.val_attribs <- attribs - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_attribs = attribs } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_attribs = attribs } member x.SetMemberInfo member_info = match x.val_opt_data with | Some optData -> optData.val_member_info <- Some member_info - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_member_info = Some member_info } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_member_info = Some member_info } member x.SetValDefn val_defn = match x.val_opt_data with | Some optData -> optData.val_defn <- Some val_defn - | _ -> x.val_opt_data <- Some { Val.EmptyValOptData with val_defn = Some val_defn } + | _ -> x.val_opt_data <- Some { Val.NewEmptyValOptData() with val_defn = Some val_defn } /// Create a new value with empty, unlinked data. Only used during unpickling of F# metadata. static member NewUnlinked() : Val = @@ -2975,7 +3004,19 @@ and [] x.val_stamp <- tg.val_stamp x.val_flags <- tg.val_flags match tg.val_opt_data with - | Some tg -> x.val_opt_data <- Some { val_compiled_name = tg.val_compiled_name; val_other_range = tg.val_other_range; val_const = tg.val_const; val_defn = tg.val_defn; val_repr_info = tg.val_repr_info; val_access = tg.val_access; val_xmldoc = tg.val_xmldoc; val_member_info = tg.val_member_info; val_declaring_entity = tg.val_declaring_entity; val_xmldocsig = tg.val_xmldocsig; val_attribs = tg.val_attribs } + | Some tg -> + x.val_opt_data <- + Some { val_compiled_name = tg.val_compiled_name + val_other_range = tg.val_other_range + val_const = tg.val_const + val_defn = tg.val_defn + val_repr_info = tg.val_repr_info + val_access = tg.val_access + val_xmldoc = tg.val_xmldoc + val_member_info = tg.val_member_info + val_declaring_entity = tg.val_declaring_entity + val_xmldocsig = tg.val_xmldocsig + val_attribs = tg.val_attribs } | None -> () /// Indicates if a value is linked to backing data yet. Only used during unpickling of F# metadata. @@ -5652,7 +5693,7 @@ let NewExn cpath (id:Ident) access repr attribs doc = entity_opt_data = match doc, access, repr with | XmlDoc [||], TAccess [], TExnNone -> None - | _ -> Some { Entity.EmptyEntityOptData with entity_xmldoc = doc; entity_accessiblity = access; entity_tycon_repr_accessibility = access; entity_exn_info = repr } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = doc; entity_accessiblity = access; entity_tycon_repr_accessibility = access; entity_exn_info = repr } } /// Create a new TAST RecdField node for an F# class, struct or record field let NewRecdField stat konst id nameGenerated ty isMutable isVolatile pattribs fattribs docOption access secret = @@ -5690,7 +5731,7 @@ let NewTycon (cpath, nm, m, access, reprAccess, kind, typars, docOption, usesPre entity_opt_data = match kind, docOption, reprAccess, access with | TyparKind.Type, XmlDoc [||], TAccess [], TAccess [] -> None - | _ -> Some { Entity.EmptyEntityOptData with entity_kind = kind; entity_xmldoc = docOption; entity_tycon_repr_accessibility = reprAccess; entity_accessiblity=access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_xmldoc = docOption; entity_tycon_repr_accessibility = reprAccess; entity_accessiblity=access } } let NewILTycon nlpath (nm,m) tps (scoref:ILScopeRef, enc, tdef:ILTypeDef) mtyp = @@ -5707,9 +5748,16 @@ exception Duplicate of string * string * range exception NameClash of string * string * string * range * string * string * range exception FullAbstraction of string * range -let NewModuleOrNamespace cpath access (id:Ident) xml attribs mtype = Construct.NewModuleOrNamespace cpath access id xml attribs mtype +let NewModuleOrNamespace cpath access (id:Ident) xml attribs mtype = + Construct.NewModuleOrNamespace cpath access id xml attribs mtype + +/// Create a new Val object +let NewVal + (logicalName:string, m:range, compiledName, ty, isMutable, isCompGen, arity, access, + recValInfo, specialRepr, baseOrThis, attribs, inlineInfo, doc, isModuleOrMemberBinding, + isExtensionMember, isIncrClassSpecialMember, isTyFunc, allowTypeInst, isGeneratedEventVal, + konst, actualParent) : Val = -let NewVal (logicalName:string,m:range,compiledName,ty,isMutable,isCompGen,arity,access,recValInfo,specialRepr,baseOrThis,attribs,inlineInfo,doc,isModuleOrMemberBinding,isExtensionMember,isIncrClassSpecialMember,isTyFunc,allowTypeInst,isGeneratedEventVal,konst,actualParent) : Val = let stamp = newStamp() Val.New { val_stamp = stamp @@ -5721,7 +5769,7 @@ let NewVal (logicalName:string,m:range,compiledName,ty,isMutable,isCompGen,arity match compiledName, arity, konst, access, doc, specialRepr, actualParent, attribs with | None, None, None, TAccess [], XmlDoc [||], None, ParentNone, [] -> None | _ -> - Some { Val.EmptyValOptData with + Some { Val.NewEmptyValOptData() with val_compiled_name = (match compiledName with Some v when v <> logicalName -> compiledName | _ -> None) val_repr_info = arity val_const = konst @@ -5733,6 +5781,7 @@ let NewVal (logicalName:string,m:range,compiledName,ty,isMutable,isCompGen,arity } +/// Create the new contents of an overall assembly let NewCcuContents sref m nm mty = NewModuleOrNamespace (Some(CompPath(sref,[]))) taccessPublic (ident(nm,m)) XmlDoc.Empty [] (MaybeLazy.Strict mty) @@ -5813,7 +5862,7 @@ let CombineCcuContentFragments m l = entity_opt_data = match data1.entity_opt_data with | Some optData -> Some { optData with entity_xmldoc = xml } - | _ -> Some { Entity.EmptyEntityOptData with entity_xmldoc = xml } }) + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = xml } }) | false,false -> error(Error(FSComp.SR.tastDuplicateTypeDefinitionInAssembly(entity2.LogicalName, textOfPath path),entity2.Range)) | _,_ -> diff --git a/src/ilx/EraseClosures.fs b/src/ilx/EraseClosures.fs index 92476961fe..2a94fb3240 100755 --- a/src/ilx/EraseClosures.fs +++ b/src/ilx/EraseClosures.fs @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.EraseClosures +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseClosures open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings -open Microsoft.FSharp.Compiler.AbstractIL.Morphs -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.PrettyNaming +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings +open FSharp.Compiler.AbstractIL.Morphs +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.PrettyNaming open System.Reflection // -------------------------------------------------------------------- diff --git a/src/ilx/EraseClosures.fsi b/src/ilx/EraseClosures.fsi index 2c4156779a..9a0d886ca5 100755 --- a/src/ilx/EraseClosures.fsi +++ b/src/ilx/EraseClosures.fsi @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// Compiler use only. Erase closures -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.EraseClosures +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseClosures -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types type cenv val mkCallFunc : cenv -> allocLocal:(ILType -> uint16) -> numThisGenParams:int -> ILTailcall -> IlxClosureApps -> ILInstr list diff --git a/src/ilx/EraseUnions.fs b/src/ilx/EraseUnions.fs index b6fb95c4bd..4675625501 100755 --- a/src/ilx/EraseUnions.fs +++ b/src/ilx/EraseUnions.fs @@ -5,15 +5,15 @@ // -------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.EraseUnions +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseUnions open System.Collections.Generic -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types open System.Reflection diff --git a/src/ilx/EraseUnions.fsi b/src/ilx/EraseUnions.fsi index 7044d2d938..b263a9bf33 100755 --- a/src/ilx/EraseUnions.fsi +++ b/src/ilx/EraseUnions.fsi @@ -4,10 +4,10 @@ // Compiler use only. Erase discriminated unions. // -------------------------------------------------------------------- -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.EraseUnions +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseUnions -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Extensions.ILX.Types /// Make the instruction sequence for a "newdata" operation val mkNewData : ILGlobals -> IlxUnionSpec * int -> ILInstr list diff --git a/src/ilx/ilxsettings.fs b/src/ilx/ilxsettings.fs index 520da651c1..868a29d94e 100755 --- a/src/ilx/ilxsettings.fs +++ b/src/ilx/ilxsettings.fs @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -module internal Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings +module internal FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings open Internal.Utilities -open Microsoft.FSharp.Compiler.AbstractIL -open Microsoft.FSharp.Compiler.AbstractIL.IL -open Microsoft.FSharp.Compiler.AbstractIL.Internal -open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX +open FSharp.Compiler.AbstractIL +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.AbstractIL.Internal +open FSharp.Compiler.AbstractIL.Extensions.ILX type IlxCallImplementation = | VirtEntriesVirtCode diff --git a/src/scripts/scriptlib.fsx b/src/scripts/scriptlib.fsx index df3c548cbc..f5f9276c49 100644 --- a/src/scripts/scriptlib.fsx +++ b/src/scripts/scriptlib.fsx @@ -35,7 +35,7 @@ module Scripting = 0 #if INTERACTIVE - let argv = Microsoft.FSharp.Compiler.Interactive.Settings.fsi.CommandLineArgs |> Seq.skip 1 |> Seq.toArray + let argv = FSharp.Compiler.Interactive.Settings.fsi.CommandLineArgs |> Seq.skip 1 |> Seq.toArray let getCmdLineArgOptional (switchName: string) = argv |> Array.filter(fun t -> t.StartsWith(switchName)) |> Array.map(fun t -> t.Remove(0, switchName.Length).Trim()) |> Array.tryHead diff --git a/src/utils/filename.fs b/src/utils/filename.fs index 35d6d5a769..9dd20134da 100755 --- a/src/utils/filename.fs +++ b/src/utils/filename.fs @@ -3,7 +3,7 @@ module internal Internal.Utilities.Filename open System.IO -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library exception IllegalFileNameChar of string * char diff --git a/src/utils/reshapedmsbuild.fs b/src/utils/reshapedmsbuild.fs index f84e8a5d31..571edd3ae4 100644 --- a/src/utils/reshapedmsbuild.fs +++ b/src/utils/reshapedmsbuild.fs @@ -57,7 +57,7 @@ type TaskItem (itemSpec:string) = let m = buildUtilitiesTaskType.GetMethod("SetMetadata", [|typeof;typeof|]) (m.Invoke(instance,[|metadataName; metadataValue|])) |>ignore -namespace Microsoft.FSharp.Compiler +namespace FSharp.Compiler open System open System.Collections open System.Collections.Concurrent diff --git a/src/utils/sformat.fsi b/src/utils/sformat.fsi index afdd931f90..f7c053e51f 100755 --- a/src/utils/sformat.fsi +++ b/src/utils/sformat.fsi @@ -285,7 +285,7 @@ namespace Microsoft.FSharp.Text.StructuredPrintfImpl /// /// From F# Interactive the default settings can be adjusted using, for example, ///
-    ///   open Microsoft.FSharp.Compiler.Interactive.Settings;;
+    ///   open FSharp.Compiler.Interactive.Settings;;
     ///   setPrintWidth 120;;
     /// 
///
diff --git a/tests/FSharp.Compiler.UnitTests/Directory.Build.props b/tests/FSharp.Compiler.UnitTests/Directory.Build.props deleted file mode 100644 index bb8eac309b..0000000000 --- a/tests/FSharp.Compiler.UnitTests/Directory.Build.props +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/tests/FSharp.Compiler.UnitTests/Directory.Build.targets b/tests/FSharp.Compiler.UnitTests/Directory.Build.targets deleted file mode 100644 index ccd47cc0a9..0000000000 --- a/tests/FSharp.Compiler.UnitTests/Directory.Build.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj b/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj deleted file mode 100644 index 4b9f4d21a3..0000000000 --- a/tests/FSharp.Compiler.UnitTests/FSharp.Compiler.UnitTests.fsproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - net46;netcoreapp2.0 - Library - true - nunit - - - - - - - - - - - - - - - - - - - diff --git a/tests/FSharp.Compiler.UnitTests/ILHelpers.fs b/tests/FSharp.Compiler.UnitTests/ILHelpers.fs deleted file mode 100644 index 372e11d070..0000000000 --- a/tests/FSharp.Compiler.UnitTests/ILHelpers.fs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -namespace FSharp.Compiler.UnitTests - -open System -open System.IO -open System.Diagnostics - -open NUnit.Framework - -open Microsoft.FSharp.Compiler.SourceCodeServices - -module ILChecker = - - let checker = FSharpChecker.Create() - - let private (++) a b = Path.Combine(a,b) - - let private getfullpath workDir path = - let rooted = - if Path.IsPathRooted(path) then path - else Path.Combine(workDir, path) - rooted |> Path.GetFullPath - - let private fileExists workDir path = - if path |> getfullpath workDir |> File.Exists then Some path else None - - let private requireFile nm = - if fileExists __SOURCE_DIRECTORY__ nm |> Option.isSome then nm else failwith (sprintf "couldn't find %s. Running 'build test' once might solve this issue" nm) - - let private exec exe args = - let startInfo = ProcessStartInfo(exe, String.concat " " args) - startInfo.RedirectStandardError <- true - startInfo.UseShellExecute <- false - use p = Process.Start(startInfo) - p.WaitForExit() - p.StandardError.ReadToEnd(), p.ExitCode - - /// Compile the source and check to see if the expected IL exists. - /// The first line of each expected IL string is found first. - let check source expectedIL = - let packagesDir = Environment.GetEnvironmentVariable("USERPROFILE") ++ ".nuget" ++ "packages" - let Is64BitOperatingSystem = sizeof = 8 - let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86" - let ildasmExe = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ "2.0.3" ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe") - let coreclrDll = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.Runtime.CoreCLR") ++ "2.0.3" ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "coreclr.dll") - - let tmp = Path.GetTempFileName() - let tmpFs = Path.ChangeExtension(tmp, ".fs") - let tmpDll = Path.ChangeExtension(tmp, ".dll") - let tmpIL = Path.ChangeExtension(tmp, ".il") - - let mutable errorMsgOpt = None - try - // ildasm requires coreclr.dll to run which has already been restored to the packages directory - File.Copy(coreclrDll, Path.GetDirectoryName(ildasmExe) ++ "coreclr.dll", overwrite=true) - - File.WriteAllText(tmpFs, source) - - let errors, exitCode = checker.Compile([| "fsc.exe"; "--optimize+"; "-o"; tmpDll; "-a"; tmpFs |]) |> Async.RunSynchronously - let errors = - String.concat "\n" (errors |> Array.map (fun x -> x.Message)) - - if exitCode = 0 then - exec ildasmExe [ sprintf "%s /out=%s" tmpDll tmpIL ] |> ignore - - let text = File.ReadAllText(tmpIL) - let blockComments = @"/\*(.*?)\*/" - let lineComments = @"//(.*?)\r?\n" - let strings = @"""((\\[^\n]|[^""\n])*)""" - let verbatimStrings = @"@(""[^""]*"")+" - let textNoComments = - System.Text.RegularExpressions.Regex.Replace(text, - blockComments + "|" + lineComments + "|" + strings + "|" + verbatimStrings, - (fun me -> - if (me.Value.StartsWith("/*") || me.Value.StartsWith("//")) then - if me.Value.StartsWith("//") then Environment.NewLine else String.Empty - else - me.Value), System.Text.RegularExpressions.RegexOptions.Singleline) - - expectedIL - |> List.iter (fun (ilCode: string) -> - let expectedLines = ilCode.Split('\n') - let startIndex = textNoComments.IndexOf(expectedLines.[0]) - if startIndex = -1 || textNoComments.Length < startIndex + ilCode.Length then - errorMsgOpt <- Some("==EXPECTED CONTAINS==\n" + ilCode + "\n") - else - let errors = ResizeArray() - let actualLines = textNoComments.Substring(startIndex, textNoComments.Length - startIndex).Split('\n') - for i = 0 to expectedLines.Length - 1 do - let expected = expectedLines.[i].Trim() - let actual = actualLines.[i].Trim() - if expected <> actual then - errors.Add(sprintf "\n==\nName: %s\n\nExpected:\t %s\nActual:\t\t %s\n==" actualLines.[0] expected actual) - - if errors.Count > 0 then - let msg = String.concat "\n" errors + "\n\n\n==EXPECTED==\n" + ilCode + "\n" - errorMsgOpt <- Some(msg + "\n\n\n==ACTUAL==\n" + String.Join("\n", actualLines, 0, expectedLines.Length)) - ) - - match errorMsgOpt with - | Some(msg) -> errorMsgOpt <- Some(msg + "\n\n\n==ENTIRE ACTUAL==\n" + textNoComments) - | _ -> () - else - errorMsgOpt <- Some(errors) - finally - try File.Delete(tmp) with | _ -> () - try File.Delete(tmpFs) with | _ -> () - try File.Delete(tmpDll) with | _ -> () - try File.Delete(tmpIL) with | _ -> () - - match errorMsgOpt with - | Some(errorMsg) -> - Assert.Fail(errorMsg) - | _ -> () - diff --git a/tests/FSharp.Compiler.UnitTests/Language/StringConcat.fs b/tests/FSharp.Compiler.UnitTests/Language/StringConcat.fs deleted file mode 100644 index fa18e7bb42..0000000000 --- a/tests/FSharp.Compiler.UnitTests/Language/StringConcat.fs +++ /dev/null @@ -1,845 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -namespace FSharp.Compiler.UnitTests - -open System -open NUnit.Framework - -[] -module StringConcat = - - [] - let Optimizations () = - let baseSource = """ -module Test - -open System - -let arr = ResizeArray() - -let inline ss (x: int) = - arr.Add(x) - "_" + x.ToString() + "_" -""" - - let test1Source = """ -let test1 () = - ss 1 + ss 2 + ss 3 -""" - let test1IL = """.method public static string test1() cil managed - { - - .maxstack 7 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0007: ldc.i4.1 - IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_000d: ldstr "_" - IL_0012: ldloca.s V_0 - IL_0014: constrained. [mscorlib]System.Int32 - IL_001a: callvirt instance string [mscorlib]System.Object::ToString() - IL_001f: ldstr "_" - IL_0024: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0029: ldc.i4.2 - IL_002a: stloc.0 - IL_002b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0030: ldc.i4.2 - IL_0031: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0036: ldstr "_" - IL_003b: ldloca.s V_0 - IL_003d: constrained. [mscorlib]System.Int32 - IL_0043: callvirt instance string [mscorlib]System.Object::ToString() - IL_0048: ldstr "_" - IL_004d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0052: ldc.i4.3 - IL_0053: stloc.0 - IL_0054: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0059: ldc.i4.3 - IL_005a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_005f: ldstr "_" - IL_0064: ldloca.s V_0 - IL_0066: constrained. [mscorlib]System.Int32 - IL_006c: callvirt instance string [mscorlib]System.Object::ToString() - IL_0071: ldstr "_" - IL_0076: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_007b: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0080: ret - }""" - - let test2Source = """ -let test2 () = - ss 1 + ss 2 + ss 3 + ss 4 -""" - let test2IL = """.method public static string test2() cil managed - { - - .maxstack 8 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0007: ldc.i4.1 - IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_000d: ldstr "_" - IL_0012: ldloca.s V_0 - IL_0014: constrained. [mscorlib]System.Int32 - IL_001a: callvirt instance string [mscorlib]System.Object::ToString() - IL_001f: ldstr "_" - IL_0024: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0029: ldc.i4.2 - IL_002a: stloc.0 - IL_002b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0030: ldc.i4.2 - IL_0031: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0036: ldstr "_" - IL_003b: ldloca.s V_0 - IL_003d: constrained. [mscorlib]System.Int32 - IL_0043: callvirt instance string [mscorlib]System.Object::ToString() - IL_0048: ldstr "_" - IL_004d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0052: ldc.i4.3 - IL_0053: stloc.0 - IL_0054: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0059: ldc.i4.3 - IL_005a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_005f: ldstr "_" - IL_0064: ldloca.s V_0 - IL_0066: constrained. [mscorlib]System.Int32 - IL_006c: callvirt instance string [mscorlib]System.Object::ToString() - IL_0071: ldstr "_" - IL_0076: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_007b: ldc.i4.4 - IL_007c: stloc.0 - IL_007d: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0082: ldc.i4.4 - IL_0083: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0088: ldstr "_" - IL_008d: ldloca.s V_0 - IL_008f: constrained. [mscorlib]System.Int32 - IL_0095: callvirt instance string [mscorlib]System.Object::ToString() - IL_009a: ldstr "_" - IL_009f: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00a4: call string [mscorlib]System.String::Concat(string, - string, - string, - string) - IL_00a9: ret - }""" - - let test3Source = """ -let test3 () = - ss 1 + ss 2 + ss 3 + ss 4 + ss 5 -""" - let test3IL = """.method public static string test3() cil managed - { - - .maxstack 8 - .locals init (int32 V_0) - IL_0000: ldc.i4.5 - IL_0001: newarr [mscorlib]System.String - IL_0006: dup - IL_0007: ldc.i4.0 - IL_0008: ldc.i4.1 - IL_0009: stloc.0 - IL_000a: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_000f: ldc.i4.1 - IL_0010: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0015: ldstr "_" - IL_001a: ldloca.s V_0 - IL_001c: constrained. [mscorlib]System.Int32 - IL_0022: callvirt instance string [mscorlib]System.Object::ToString() - IL_0027: ldstr "_" - IL_002c: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0031: stelem [mscorlib]System.String - IL_0036: dup - IL_0037: ldc.i4.1 - IL_0038: ldc.i4.2 - IL_0039: stloc.0 - IL_003a: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_003f: ldc.i4.2 - IL_0040: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0045: ldstr "_" - IL_004a: ldloca.s V_0 - IL_004c: constrained. [mscorlib]System.Int32 - IL_0052: callvirt instance string [mscorlib]System.Object::ToString() - IL_0057: ldstr "_" - IL_005c: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0061: stelem [mscorlib]System.String - IL_0066: dup - IL_0067: ldc.i4.2 - IL_0068: ldc.i4.3 - IL_0069: stloc.0 - IL_006a: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_006f: ldc.i4.3 - IL_0070: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0075: ldstr "_" - IL_007a: ldloca.s V_0 - IL_007c: constrained. [mscorlib]System.Int32 - IL_0082: callvirt instance string [mscorlib]System.Object::ToString() - IL_0087: ldstr "_" - IL_008c: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0091: stelem [mscorlib]System.String - IL_0096: dup - IL_0097: ldc.i4.3 - IL_0098: ldc.i4.4 - IL_0099: stloc.0 - IL_009a: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_009f: ldc.i4.4 - IL_00a0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00a5: ldstr "_" - IL_00aa: ldloca.s V_0 - IL_00ac: constrained. [mscorlib]System.Int32 - IL_00b2: callvirt instance string [mscorlib]System.Object::ToString() - IL_00b7: ldstr "_" - IL_00bc: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00c1: stelem [mscorlib]System.String - IL_00c6: dup - IL_00c7: ldc.i4.4 - IL_00c8: ldc.i4.5 - IL_00c9: stloc.0 - IL_00ca: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_00cf: ldc.i4.5 - IL_00d0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00d5: ldstr "_" - IL_00da: ldloca.s V_0 - IL_00dc: constrained. [mscorlib]System.Int32 - IL_00e2: callvirt instance string [mscorlib]System.Object::ToString() - IL_00e7: ldstr "_" - IL_00ec: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00f1: stelem [mscorlib]System.String - IL_00f6: call string [mscorlib]System.String::Concat(string[]) - IL_00fb: ret - }""" - - let test4Source = """ -let test4 () = - ss 5 + ss 6 + ss 7 + String.Concat(ss 8, ss 9) + ss 10 + "_50_" + "_60_" + String.Concat(ss 100, String.Concat(ss 101, ss 102), ss 103) + String.Concat([|"_104_";"_105_"|]) + ss 106 -""" - let test4IL = """.method public static string test4() cil managed - { - - .maxstack 8 - .locals init (int32 V_0) - IL_0000: ldc.i4.s 13 - IL_0002: newarr [mscorlib]System.String - IL_0007: dup - IL_0008: ldc.i4.0 - IL_0009: ldc.i4.5 - IL_000a: stloc.0 - IL_000b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0010: ldc.i4.5 - IL_0011: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0016: ldstr "_" - IL_001b: ldloca.s V_0 - IL_001d: constrained. [mscorlib]System.Int32 - IL_0023: callvirt instance string [mscorlib]System.Object::ToString() - IL_0028: ldstr "_" - IL_002d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0032: stelem [mscorlib]System.String - IL_0037: dup - IL_0038: ldc.i4.1 - IL_0039: ldc.i4.6 - IL_003a: stloc.0 - IL_003b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0040: ldc.i4.6 - IL_0041: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0046: ldstr "_" - IL_004b: ldloca.s V_0 - IL_004d: constrained. [mscorlib]System.Int32 - IL_0053: callvirt instance string [mscorlib]System.Object::ToString() - IL_0058: ldstr "_" - IL_005d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0062: stelem [mscorlib]System.String - IL_0067: dup - IL_0068: ldc.i4.2 - IL_0069: ldc.i4.7 - IL_006a: stloc.0 - IL_006b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0070: ldc.i4.7 - IL_0071: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0076: ldstr "_" - IL_007b: ldloca.s V_0 - IL_007d: constrained. [mscorlib]System.Int32 - IL_0083: callvirt instance string [mscorlib]System.Object::ToString() - IL_0088: ldstr "_" - IL_008d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0092: stelem [mscorlib]System.String - IL_0097: dup - IL_0098: ldc.i4.3 - IL_0099: ldc.i4.8 - IL_009a: stloc.0 - IL_009b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_00a0: ldc.i4.8 - IL_00a1: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00a6: ldstr "_" - IL_00ab: ldloca.s V_0 - IL_00ad: constrained. [mscorlib]System.Int32 - IL_00b3: callvirt instance string [mscorlib]System.Object::ToString() - IL_00b8: ldstr "_" - IL_00bd: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00c2: stelem [mscorlib]System.String - IL_00c7: dup - IL_00c8: ldc.i4.4 - IL_00c9: ldc.i4.s 9 - IL_00cb: stloc.0 - IL_00cc: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_00d1: ldc.i4.s 9 - IL_00d3: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00d8: ldstr "_" - IL_00dd: ldloca.s V_0 - IL_00df: constrained. [mscorlib]System.Int32 - IL_00e5: callvirt instance string [mscorlib]System.Object::ToString() - IL_00ea: ldstr "_" - IL_00ef: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00f4: stelem [mscorlib]System.String - IL_00f9: dup - IL_00fa: ldc.i4.5 - IL_00fb: ldc.i4.s 10 - IL_00fd: stloc.0 - IL_00fe: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0103: ldc.i4.s 10 - IL_0105: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_010a: ldstr "_" - IL_010f: ldloca.s V_0 - IL_0111: constrained. [mscorlib]System.Int32 - IL_0117: callvirt instance string [mscorlib]System.Object::ToString() - IL_011c: ldstr "_" - IL_0121: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0126: stelem [mscorlib]System.String - IL_012b: dup - IL_012c: ldc.i4.6 - IL_012d: ldstr "_50__60_" - IL_0132: stelem [mscorlib]System.String - IL_0137: dup - IL_0138: ldc.i4.7 - IL_0139: ldc.i4.s 100 - IL_013b: stloc.0 - IL_013c: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0141: ldc.i4.s 100 - IL_0143: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0148: ldstr "_" - IL_014d: ldloca.s V_0 - IL_014f: constrained. [mscorlib]System.Int32 - IL_0155: callvirt instance string [mscorlib]System.Object::ToString() - IL_015a: ldstr "_" - IL_015f: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0164: stelem [mscorlib]System.String - IL_0169: dup - IL_016a: ldc.i4.8 - IL_016b: ldc.i4.s 101 - IL_016d: stloc.0 - IL_016e: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0173: ldc.i4.s 101 - IL_0175: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_017a: ldstr "_" - IL_017f: ldloca.s V_0 - IL_0181: constrained. [mscorlib]System.Int32 - IL_0187: callvirt instance string [mscorlib]System.Object::ToString() - IL_018c: ldstr "_" - IL_0191: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0196: stelem [mscorlib]System.String - IL_019b: dup - IL_019c: ldc.i4.s 9 - IL_019e: ldc.i4.s 102 - IL_01a0: stloc.0 - IL_01a1: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_01a6: ldc.i4.s 102 - IL_01a8: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_01ad: ldstr "_" - IL_01b2: ldloca.s V_0 - IL_01b4: constrained. [mscorlib]System.Int32 - IL_01ba: callvirt instance string [mscorlib]System.Object::ToString() - IL_01bf: ldstr "_" - IL_01c4: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_01c9: stelem [mscorlib]System.String - IL_01ce: dup - IL_01cf: ldc.i4.s 10 - IL_01d1: ldc.i4.s 103 - IL_01d3: stloc.0 - IL_01d4: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_01d9: ldc.i4.s 103 - IL_01db: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_01e0: ldstr "_" - IL_01e5: ldloca.s V_0 - IL_01e7: constrained. [mscorlib]System.Int32 - IL_01ed: callvirt instance string [mscorlib]System.Object::ToString() - IL_01f2: ldstr "_" - IL_01f7: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_01fc: stelem [mscorlib]System.String - IL_0201: dup - IL_0202: ldc.i4.s 11 - IL_0204: ldstr "_104__105_" - IL_0209: stelem [mscorlib]System.String - IL_020e: dup - IL_020f: ldc.i4.s 12 - IL_0211: ldc.i4.s 106 - IL_0213: stloc.0 - IL_0214: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0219: ldc.i4.s 106 - IL_021b: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0220: ldstr "_" - IL_0225: ldloca.s V_0 - IL_0227: constrained. [mscorlib]System.Int32 - IL_022d: callvirt instance string [mscorlib]System.Object::ToString() - IL_0232: ldstr "_" - IL_0237: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_023c: stelem [mscorlib]System.String - IL_0241: call string [mscorlib]System.String::Concat(string[]) - IL_0246: ret - }""" - - let test5Source = """ -let test5 () = - ss 5 + ss 6 + ss 7 + String.Concat(ss 8, ss 9) + ss 10 + "_50_" + "_60_" + String.Concat(ss 100, (let x = String.Concat(ss 101, ss 102) in Console.WriteLine(x);x), ss 103) + String.Concat([|"_104_";"_105_"|]) + ss 106 -""" - let test5IL = """.method public static string test5() cil managed - { - - .maxstack 9 - .locals init (int32 V_0, - string V_1) - IL_0000: ldc.i4.s 12 - IL_0002: newarr [mscorlib]System.String - IL_0007: dup - IL_0008: ldc.i4.0 - IL_0009: ldc.i4.5 - IL_000a: stloc.0 - IL_000b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0010: ldc.i4.5 - IL_0011: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0016: ldstr "_" - IL_001b: ldloca.s V_0 - IL_001d: constrained. [mscorlib]System.Int32 - IL_0023: callvirt instance string [mscorlib]System.Object::ToString() - IL_0028: ldstr "_" - IL_002d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0032: stelem [mscorlib]System.String - IL_0037: dup - IL_0038: ldc.i4.1 - IL_0039: ldc.i4.6 - IL_003a: stloc.0 - IL_003b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0040: ldc.i4.6 - IL_0041: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0046: ldstr "_" - IL_004b: ldloca.s V_0 - IL_004d: constrained. [mscorlib]System.Int32 - IL_0053: callvirt instance string [mscorlib]System.Object::ToString() - IL_0058: ldstr "_" - IL_005d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0062: stelem [mscorlib]System.String - IL_0067: dup - IL_0068: ldc.i4.2 - IL_0069: ldc.i4.7 - IL_006a: stloc.0 - IL_006b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0070: ldc.i4.7 - IL_0071: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0076: ldstr "_" - IL_007b: ldloca.s V_0 - IL_007d: constrained. [mscorlib]System.Int32 - IL_0083: callvirt instance string [mscorlib]System.Object::ToString() - IL_0088: ldstr "_" - IL_008d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0092: stelem [mscorlib]System.String - IL_0097: dup - IL_0098: ldc.i4.3 - IL_0099: ldc.i4.8 - IL_009a: stloc.0 - IL_009b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_00a0: ldc.i4.8 - IL_00a1: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00a6: ldstr "_" - IL_00ab: ldloca.s V_0 - IL_00ad: constrained. [mscorlib]System.Int32 - IL_00b3: callvirt instance string [mscorlib]System.Object::ToString() - IL_00b8: ldstr "_" - IL_00bd: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00c2: stelem [mscorlib]System.String - IL_00c7: dup - IL_00c8: ldc.i4.4 - IL_00c9: ldc.i4.s 9 - IL_00cb: stloc.0 - IL_00cc: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_00d1: ldc.i4.s 9 - IL_00d3: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00d8: ldstr "_" - IL_00dd: ldloca.s V_0 - IL_00df: constrained. [mscorlib]System.Int32 - IL_00e5: callvirt instance string [mscorlib]System.Object::ToString() - IL_00ea: ldstr "_" - IL_00ef: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00f4: stelem [mscorlib]System.String - IL_00f9: dup - IL_00fa: ldc.i4.5 - IL_00fb: ldc.i4.s 10 - IL_00fd: stloc.0 - IL_00fe: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0103: ldc.i4.s 10 - IL_0105: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_010a: ldstr "_" - IL_010f: ldloca.s V_0 - IL_0111: constrained. [mscorlib]System.Int32 - IL_0117: callvirt instance string [mscorlib]System.Object::ToString() - IL_011c: ldstr "_" - IL_0121: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0126: stelem [mscorlib]System.String - IL_012b: dup - IL_012c: ldc.i4.6 - IL_012d: ldstr "_50__60_" - IL_0132: stelem [mscorlib]System.String - IL_0137: dup - IL_0138: ldc.i4.7 - IL_0139: ldc.i4.s 100 - IL_013b: stloc.0 - IL_013c: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0141: ldc.i4.s 100 - IL_0143: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0148: ldstr "_" - IL_014d: ldloca.s V_0 - IL_014f: constrained. [mscorlib]System.Int32 - IL_0155: callvirt instance string [mscorlib]System.Object::ToString() - IL_015a: ldstr "_" - IL_015f: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0164: stelem [mscorlib]System.String - IL_0169: dup - IL_016a: ldc.i4.8 - IL_016b: ldc.i4.s 101 - IL_016d: stloc.0 - IL_016e: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0173: ldc.i4.s 101 - IL_0175: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_017a: ldstr "_" - IL_017f: ldloca.s V_0 - IL_0181: constrained. [mscorlib]System.Int32 - IL_0187: callvirt instance string [mscorlib]System.Object::ToString() - IL_018c: ldstr "_" - IL_0191: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0196: ldc.i4.s 102 - IL_0198: stloc.0 - IL_0199: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_019e: ldc.i4.s 102 - IL_01a0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_01a5: ldstr "_" - IL_01aa: ldloca.s V_0 - IL_01ac: constrained. [mscorlib]System.Int32 - IL_01b2: callvirt instance string [mscorlib]System.Object::ToString() - IL_01b7: ldstr "_" - IL_01bc: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_01c1: call string [mscorlib]System.String::Concat(string, - string) - IL_01c6: stloc.1 - IL_01c7: ldloc.1 - IL_01c8: call void [mscorlib]System.Console::WriteLine(string) - IL_01cd: ldloc.1 - IL_01ce: stelem [mscorlib]System.String - IL_01d3: dup - IL_01d4: ldc.i4.s 9 - IL_01d6: ldc.i4.s 103 - IL_01d8: stloc.0 - IL_01d9: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_01de: ldc.i4.s 103 - IL_01e0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_01e5: ldstr "_" - IL_01ea: ldloca.s V_0 - IL_01ec: constrained. [mscorlib]System.Int32 - IL_01f2: callvirt instance string [mscorlib]System.Object::ToString() - IL_01f7: ldstr "_" - IL_01fc: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0201: stelem [mscorlib]System.String - IL_0206: dup - IL_0207: ldc.i4.s 10 - IL_0209: ldstr "_104__105_" - IL_020e: stelem [mscorlib]System.String - IL_0213: dup - IL_0214: ldc.i4.s 11 - IL_0216: ldc.i4.s 106 - IL_0218: stloc.0 - IL_0219: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_021e: ldc.i4.s 106 - IL_0220: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0225: ldstr "_" - IL_022a: ldloca.s V_0 - IL_022c: constrained. [mscorlib]System.Int32 - IL_0232: callvirt instance string [mscorlib]System.Object::ToString() - IL_0237: ldstr "_" - IL_023c: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0241: stelem [mscorlib]System.String - IL_0246: call string [mscorlib]System.String::Concat(string[]) - IL_024b: ret - }""" - - let test6Source = """ -let inline inlineStringConcat str1 str2 = str1 + str2 - -let test6 () = - inlineStringConcat (inlineStringConcat (ss 1) (ss 2)) (ss 3) + ss 4 -""" - let test6IL = """.method public static string test6() cil managed - { - - .maxstack 8 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0007: ldc.i4.1 - IL_0008: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_000d: ldstr "_" - IL_0012: ldloca.s V_0 - IL_0014: constrained. [mscorlib]System.Int32 - IL_001a: callvirt instance string [mscorlib]System.Object::ToString() - IL_001f: ldstr "_" - IL_0024: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0029: ldc.i4.2 - IL_002a: stloc.0 - IL_002b: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0030: ldc.i4.2 - IL_0031: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0036: ldstr "_" - IL_003b: ldloca.s V_0 - IL_003d: constrained. [mscorlib]System.Int32 - IL_0043: callvirt instance string [mscorlib]System.Object::ToString() - IL_0048: ldstr "_" - IL_004d: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_0052: ldc.i4.3 - IL_0053: stloc.0 - IL_0054: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0059: ldc.i4.3 - IL_005a: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_005f: ldstr "_" - IL_0064: ldloca.s V_0 - IL_0066: constrained. [mscorlib]System.Int32 - IL_006c: callvirt instance string [mscorlib]System.Object::ToString() - IL_0071: ldstr "_" - IL_0076: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_007b: ldc.i4.4 - IL_007c: stloc.0 - IL_007d: call class [mscorlib]System.Collections.Generic.List`1 Test::get_arr() - IL_0082: ldc.i4.4 - IL_0083: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0088: ldstr "_" - IL_008d: ldloca.s V_0 - IL_008f: constrained. [mscorlib]System.Int32 - IL_0095: callvirt instance string [mscorlib]System.Object::ToString() - IL_009a: ldstr "_" - IL_009f: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_00a4: call string [mscorlib]System.String::Concat(string, - string, - string, - string) - IL_00a9: ret - }""" - - let test7Source = """ -let test7 () = - let x = 1 - x.ToString() + x.ToString() + x.ToString() -""" - let test7IL = """.method public static string test7() cil managed - { - - .maxstack 5 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: ldloca.s V_0 - IL_0004: constrained. [mscorlib]System.Int32 - IL_000a: callvirt instance string [mscorlib]System.Object::ToString() - IL_000f: ldloca.s V_0 - IL_0011: constrained. [mscorlib]System.Int32 - IL_0017: callvirt instance string [mscorlib]System.Object::ToString() - IL_001c: ldloca.s V_0 - IL_001e: constrained. [mscorlib]System.Int32 - IL_0024: callvirt instance string [mscorlib]System.Object::ToString() - IL_0029: call string [mscorlib]System.String::Concat(string, - string, - string) - IL_002e: ret - }""" - - let test8Source = """ -let test8 () = - let x = 1 - x.ToString() + x.ToString() + x.ToString() + x.ToString() -""" - let test8IL = """.method public static string test8() cil managed - { - - .maxstack 6 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: ldloca.s V_0 - IL_0004: constrained. [mscorlib]System.Int32 - IL_000a: callvirt instance string [mscorlib]System.Object::ToString() - IL_000f: ldloca.s V_0 - IL_0011: constrained. [mscorlib]System.Int32 - IL_0017: callvirt instance string [mscorlib]System.Object::ToString() - IL_001c: ldloca.s V_0 - IL_001e: constrained. [mscorlib]System.Int32 - IL_0024: callvirt instance string [mscorlib]System.Object::ToString() - IL_0029: ldloca.s V_0 - IL_002b: constrained. [mscorlib]System.Int32 - IL_0031: callvirt instance string [mscorlib]System.Object::ToString() - IL_0036: call string [mscorlib]System.String::Concat(string, - string, - string, - string) - IL_003b: ret - }""" - - let test9Source = """ -let test9 () = - let x = 1 - x.ToString() + x.ToString() + x.ToString() + x.ToString() + x.ToString() -""" - let test9IL = """.method public static string test9() cil managed - { - - .maxstack 6 - .locals init (int32 V_0) - IL_0000: ldc.i4.1 - IL_0001: stloc.0 - IL_0002: ldc.i4.5 - IL_0003: newarr [mscorlib]System.String - IL_0008: dup - IL_0009: ldc.i4.0 - IL_000a: ldloca.s V_0 - IL_000c: constrained. [mscorlib]System.Int32 - IL_0012: callvirt instance string [mscorlib]System.Object::ToString() - IL_0017: stelem [mscorlib]System.String - IL_001c: dup - IL_001d: ldc.i4.1 - IL_001e: ldloca.s V_0 - IL_0020: constrained. [mscorlib]System.Int32 - IL_0026: callvirt instance string [mscorlib]System.Object::ToString() - IL_002b: stelem [mscorlib]System.String - IL_0030: dup - IL_0031: ldc.i4.2 - IL_0032: ldloca.s V_0 - IL_0034: constrained. [mscorlib]System.Int32 - IL_003a: callvirt instance string [mscorlib]System.Object::ToString() - IL_003f: stelem [mscorlib]System.String - IL_0044: dup - IL_0045: ldc.i4.3 - IL_0046: ldloca.s V_0 - IL_0048: constrained. [mscorlib]System.Int32 - IL_004e: callvirt instance string [mscorlib]System.Object::ToString() - IL_0053: stelem [mscorlib]System.String - IL_0058: dup - IL_0059: ldc.i4.4 - IL_005a: ldloca.s V_0 - IL_005c: constrained. [mscorlib]System.Int32 - IL_0062: callvirt instance string [mscorlib]System.Object::ToString() - IL_0067: stelem [mscorlib]System.String - IL_006c: call string [mscorlib]System.String::Concat(string[]) - IL_0071: ret - }""" - - let sources = - [ - baseSource - test1Source - test2Source - test3Source - test4Source - test5Source - test6Source - test7Source - test8Source - test9Source - ] - let source = String.Join("", sources) - ILChecker.check source - [ - test1IL - test2IL - test3IL - test4IL - test5IL - test6IL - test7IL - test8IL - test9IL - ] diff --git a/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj b/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj index 926080b65b..c02a1e398d 100644 --- a/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj +++ b/tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj @@ -1,6 +1,7 @@ netstandard2.0 + 4.5.* diff --git a/tests/scripts/longLines.fsx b/tests/scripts/longLines.fsx new file mode 100644 index 0000000000..f6c8e0c5b8 --- /dev/null +++ b/tests/scripts/longLines.fsx @@ -0,0 +1,37 @@ + + +open System.IO + +let lines = + [| for dir in [ "src/fsharp"; "src/fsharp/symbols"; "src/fsharp/service"; "src/absil" ]do + for file in Directory.EnumerateFiles(__SOURCE_DIRECTORY__ + "/../../" + dir,"*.fs") do + // TcGlobals.fs gets an exception + let lines = File.ReadAllLines file + for (line, lineText) in Array.indexed lines do + + // We hardwire some exceptions + if not (Path.GetFileName(file) = "service.fs") && // churning + not (lineText.Contains("SuppressMessage")) && // old fxcop annotation + not (Path.GetFileName(file) = "TcGlobals.fs") && + not (Path.GetFileName(file) = "tast.fs" && line > 2100 && line < 2400) then + + yield file, (line+1, lineText) |] + +let totalLines = lines.Length +let buckets = lines |> Array.groupBy (fun (_file, (_line, lineText)) -> lineText.Length / 10) |> Array.sortByDescending (fun (key, vs) -> key) + +for (key, sz) in buckets do + printfn "bucket %d-%d - %%%2.1f" (key*10) (key*10+9) (double sz.Length / double totalLines * 100.0) + +printfn "top bucket: " + +for (file, (line, text)) in snd buckets.[0] do + printfn "%s %d %s..." file line text.[0..50] + +let numLong = lines |> Array.filter (fun (_, (line, lineText)) -> lineText.Length > 120) |> Array.length +let numHuge = lines |> Array.filter (fun (_, (line, lineText)) -> lineText.Length > 160) |> Array.length +let numHumungous = lines |> Array.filter (fun (_, (line, lineText)) -> lineText.Length > 200) |> Array.length + +printfn "%d long lines = %2.2f%%" numLong (double numLong / double totalLines) +printfn "%d huge lines = %2.2f%%" numHuge (double numHuge / double totalLines) +printfn "%d humungous lines = %2.2f%%" numHumungous (double numHumungous / double totalLines) diff --git a/tests/service/AssemblyContentProviderTests.fs b/tests/service/AssemblyContentProviderTests.fs index 30f11f4cdd..a3e7586996 100644 --- a/tests/service/AssemblyContentProviderTests.fs +++ b/tests/service/AssemblyContentProviderTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -11,7 +11,7 @@ open System open System.IO open System.Text open NUnit.Framework -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices let private filePath = "C:\\test.fs" diff --git a/tests/service/AssemblyReaderShim.fs b/tests/service/AssemblyReaderShim.fs index e7fd0a48ba..223f46d066 100644 --- a/tests/service/AssemblyReaderShim.fs +++ b/tests/service/AssemblyReaderShim.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -9,7 +9,7 @@ module FSharp.Compiler.Service.Tests.AssemblyReaderShim open FSharp.Compiler.Service.Tests.Common open FsUnit -open Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader +open FSharp.Compiler.AbstractIL.ILBinaryReader open NUnit.Framework [] diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index 1aea1c82ef..14f390a094 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -1,8 +1,8 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive #r "../../bin/v4.5/CSharp_Analysis.dll" -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -16,9 +16,9 @@ open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler +open FSharp.Compiler open FSharp.Compiler.Service.Tests -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 589bcb3528..49ae76b382 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -3,8 +3,8 @@ module internal FSharp.Compiler.Service.Tests.Common open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices #if FX_RESHAPED_REFLECTION open ReflectionAdapters @@ -86,7 +86,7 @@ let sysLib nm = module Helpers = open System type DummyType = A | B - let PathRelativeToTestAssembly p = Path.Combine(Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath), p) + let PathRelativeToTestAssembly p = Path.Combine(Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath), p) let fsCoreDefaultReference() = PathRelativeToTestAssembly "FSharp.Core.dll" diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 91990f95b7..5d5eb49f35 100755 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -19,8 +19,8 @@ // Use F# Interactive. This only works for FSHarp.Compiler.Service.dll which has a public API #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -31,8 +31,8 @@ open NUnit.Framework open FsUnit open System open System.IO -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let stringMethods = @@ -347,6 +347,50 @@ type Test() = let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 4, inputLines.[3], PartialLongName.Empty(14), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously decls.Items |> Seq.exists (fun d -> d.Name = "abc") |> shouldEqual true + +[] +let ``Completion in base constructor`` () = + let input = + """ +type A(foo) = + class + end + +type B(bar) = + inherit A(bar)""" + + // Split the input & define file name + let inputLines = input.Split('\n') + let file = "/home/user/Test.fsx" + let parseResult, typeCheckResults = parseAndCheckScript(file, input) + + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, inputLines.[6], PartialLongName.Empty(17), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true + + + +[] +let ``Completion in do in base constructor`` () = + let input = + """ +type A() = + class + end + +type B(bar) = + inherit A() + + do bar""" + + // Split the input & define file name + let inputLines = input.Split('\n') + let file = "/home/user/Test.fsx" + let parseResult, typeCheckResults = parseAndCheckScript(file, input) + + let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 9, inputLines.[8], PartialLongName.Empty(7), (fun _ -> []), fun _ -> false)|> Async.RunSynchronously + decls.Items |> Seq.exists (fun d -> d.Name = "bar") |> shouldEqual true + + [] let ``Symbol based find function from member 1`` () = let input = diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index 3e2df86ca5..d130ec2f99 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -1,8 +1,8 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../debug/fcs/net45/FSharp.Compiler.Service.ProjectCracker.dll" -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.ProjectCracker.dll" +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -15,8 +15,8 @@ open FsUnit open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service open FSharp.Compiler.Service.Tests.Common @@ -49,10 +49,14 @@ module internal Utils = | BasicPatterns.NewRecord(v,args) -> let fields = v.TypeDefinition.FSharpFields "{" + ((fields, args) ||> Seq.map2 (fun f a -> f.Name + " = " + printExpr 0 a) |> String.concat "; ") + "}" + | BasicPatterns.NewAnonRecord(v,args) -> + let fields = v.AnonRecordTypeDetails.SortedFieldNames + "{" + ((fields, args) ||> Seq.map2 (fun f a -> f+ " = " + printExpr 0 a) |> String.concat "; ") + "}" | BasicPatterns.NewTuple(v,args) -> printTupledArgs args | BasicPatterns.NewUnionCase(ty,uc,args) -> uc.CompiledName + printTupledArgs args | BasicPatterns.Quote(e1) -> "quote" + printTupledArgs [e1] | BasicPatterns.FSharpFieldGet(obj, ty,f) -> printObjOpt obj + f.Name + | BasicPatterns.AnonRecordGet(obj, ty, n) -> printExpr 0 obj + "." + ty.AnonRecordTypeDetails.SortedFieldNames.[n] | BasicPatterns.FSharpFieldSet(obj, ty,f,arg) -> printObjOpt obj + f.Name + " <- " + printExpr 0 arg | BasicPatterns.Sequential(e1,e2) -> "(" + printExpr 0 e1 + "; " + printExpr 0 e2 + ")" | BasicPatterns.ThisValue _ -> "this" @@ -535,6 +539,8 @@ module LetLambda = let letLambdaRes = [ 1, 2 ] |> List.map (fun (a, b) -> LetLambda.f a b) +let anonRecd = {| X = 1; Y = 2 |} +let anonRecdGet = (anonRecd.X, anonRecd.Y) """ File.WriteAllText(fileName1, fileSource1) @@ -732,6 +738,8 @@ let ``Test Unoptimized Declarations Project1`` () = "type LetLambda"; "let f = ((); fun a -> fun b -> Operators.op_Addition (a,b)) @ (246,8--247,24)"; "let letLambdaRes = Operators.op_PipeRight<(Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int) Microsoft.FSharp.Collections.list,Microsoft.FSharp.Core.int Microsoft.FSharp.Collections.list> (Cons((1,2),Empty()),let mapping: Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int = fun tupledArg -> let a: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b: Microsoft.FSharp.Core.int = tupledArg.Item1 in (LetLambda.f () a) b in fun list -> ListModule.Map (mapping,list)) @ (249,19--249,71)"; + "let anonRecd = {X = 1; Y = 2} @ (251,15--251,33)" + "let anonRecdGet = (M.anonRecd ().X,M.anonRecd ().Y) @ (252,19--252,41)" ] let expected2 = [ @@ -870,6 +878,8 @@ let ``Test Optimized Declarations Project1`` () = "type LetLambda"; "let f = fun a -> fun b -> Operators.op_Addition (a,b) @ (247,8--247,24)"; "let letLambdaRes = ListModule.Map (fun tupledArg -> let a: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b: Microsoft.FSharp.Core.int = tupledArg.Item1 in (LetLambda.f () a) b,Cons((1,2),Empty())) @ (249,19--249,71)"; + "let anonRecd = {X = 1; Y = 2} @ (251,15--251,33)" + "let anonRecdGet = (M.anonRecd ().X,M.anonRecd ().Y) @ (252,19--252,41)" ] let expected2 = [ diff --git a/tests/service/FileSystemTests.fs b/tests/service/FileSystemTests.fs index b9cf6cf888..6011d8d4c8 100644 --- a/tests/service/FileSystemTests.fs +++ b/tests/service/FileSystemTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -14,9 +14,9 @@ open System open System.IO open System.Collections.Generic open System.Text -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.Service.Tests.Common let fileName1 = @"c:\mycode\test1.fs" // note, the path doesn' exist diff --git a/tests/service/FscTests.fs b/tests/service/FscTests.fs index 553f5e468b..08e83950e4 100644 --- a/tests/service/FscTests.fs +++ b/tests/service/FscTests.fs @@ -1,7 +1,7 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -13,8 +13,8 @@ open System open System.Diagnostics open System.IO -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests open FSharp.Compiler.Service.Tests.Common @@ -248,7 +248,7 @@ let ``5. Compile from AST with explicit assembly reference`` () = let code = """ module Bar - open Microsoft.FSharp.Compiler.SourceCodeServices + open FSharp.Compiler.SourceCodeServices let f x = (x,x) @@ -367,9 +367,9 @@ let x = 3 + 4 [] let ``Check read of mscorlib`` () = - let options = Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader.mkDefault Microsoft.FSharp.Compiler.AbstractIL.IL.EcmaILGlobals + let options = FSharp.Compiler.AbstractIL.ILBinaryReader.mkDefault FSharp.Compiler.AbstractIL.IL.EcmaILGlobals let options = { options with optimizeForMemory=true} - let reader = Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes "C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\mscorlib.dll" options + let reader = FSharp.Compiler.AbstractIL.ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes "C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\mscorlib.dll" options let greg = reader.ILModuleDef.TypeDefs.FindByName "System.Globalization.GregorianCalendar" for attr in greg.CustomAttrs.AsList do printfn "%A" attr.Method diff --git a/tests/service/FsiTests.fs b/tests/service/FsiTests.fs index 23bf52b33e..279e031dce 100644 --- a/tests/service/FsiTests.fs +++ b/tests/service/FsiTests.fs @@ -1,16 +1,16 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else module FSharp.Compiler.Service.Tests.FsiTests #endif -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Interactive.Shell -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.SourceCodeServices open NUnit.Framework open FsUnit @@ -79,7 +79,7 @@ let ``EvalExpression test 1 nothrow``() = [] // 'fsi' can be evaluated because we passed it in explicitly up above let ``EvalExpression fsi test``() = - evalExpression "fsi" |> shouldEqual "Microsoft.FSharp.Compiler.Interactive.InteractiveSession" + evalExpression "fsi" |> shouldEqual "FSharp.Compiler.Interactive.InteractiveSession" [] // 'fsi' can be evaluated because we passed it in explicitly up above diff --git a/tests/service/InteractiveCheckerTests.fs b/tests/service/InteractiveCheckerTests.fs index 136505b6dd..1f28a271be 100644 --- a/tests/service/InteractiveCheckerTests.fs +++ b/tests/service/InteractiveCheckerTests.fs @@ -1,7 +1,7 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -11,8 +11,8 @@ module FSharp.Compiler.Service.Tests.InteractiveChecker open NUnit.Framework open FsUnit open System -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let internal longIdentToString (longIdent: Ast.LongIdent) = diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index 0e4d38a332..0189945731 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -1,15 +1,15 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else module Tests.Service.MultiProjectAnalysisTests #endif -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open NUnit.Framework open FsUnit @@ -18,7 +18,7 @@ open System.IO open System open System.Collections.Generic -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let numProjectsForStressTest = 100 diff --git a/tests/service/PerfTests.fs b/tests/service/PerfTests.fs index 662e00c564..1b3a660527 100644 --- a/tests/service/PerfTests.fs +++ b/tests/service/PerfTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -14,8 +14,8 @@ open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common @@ -42,38 +42,67 @@ module internal Project1 = [] let ``Test request for parse and check doesn't check whole project`` () = + printfn "starting test..." let backgroundParseCount = ref 0 let backgroundCheckCount = ref 0 checker.FileChecked.Add (fun x -> incr backgroundCheckCount) checker.FileParsed.Add (fun x -> incr backgroundParseCount) + checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() let pB, tB = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic + + printfn "ParseFile()..." let parseResults1 = checker.ParseFile(Project1.fileNames.[5], Project1.fileSources2.[5], Project1.parsingOptions) |> Async.RunSynchronously let pC, tC = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic (pC - pB) |> shouldEqual 1 (tC - tB) |> shouldEqual 0 + printfn "checking backgroundParseCount.Value = %d" backgroundParseCount.Value backgroundParseCount.Value |> shouldEqual 0 + printfn "checking backgroundCheckCount.Value = %d" backgroundCheckCount.Value backgroundCheckCount.Value |> shouldEqual 0 + + printfn "CheckFileInProject()..." let checkResults1 = checker.CheckFileInProject(parseResults1, Project1.fileNames.[5], 0, Project1.fileSources2.[5], Project1.options) |> Async.RunSynchronously let pD, tD = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic - backgroundParseCount.Value |> shouldEqual 5 - backgroundCheckCount.Value |> shouldEqual 5 + + printfn "checking background parsing happened...., backgroundParseCount.Value = %d" backgroundParseCount.Value + (backgroundParseCount.Value >= 5) |> shouldEqual true // but note, the project does not get reparsed + printfn "checking background typechecks happened...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value + (backgroundCheckCount.Value >= 5) |> shouldEqual true // only two extra typechecks of files + + printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files + + printfn "checking (pD - pC) = %d" (pD - pC) (pD - pC) |> shouldEqual 0 + printfn "checking (tD - tC) = %d" (tD - tC) (tD - tC) |> shouldEqual 1 + printfn "CheckFileInProject()..." let checkResults2 = checker.CheckFileInProject(parseResults1, Project1.fileNames.[7], 0, Project1.fileSources2.[7], Project1.options) |> Async.RunSynchronously let pE, tE = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic + printfn "checking no extra foreground parsing...., (pE - pD) = %d" (pE - pD) (pE - pD) |> shouldEqual 0 + printfn "checking one foreground typecheck...., tE - tD = %d" (tE - tD) (tE - tD) |> shouldEqual 1 - (backgroundParseCount.Value <= 9) |> shouldEqual true // but note, the project does not get reparsed - (backgroundCheckCount.Value <= 9) |> shouldEqual true // only two extra typechecks of files + printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files + printfn "ParseAndCheckFileInProject()..." // A subsequent ParseAndCheck of identical source code doesn't do any more anything let checkResults2 = checker.ParseAndCheckFileInProject(Project1.fileNames.[7], 0, Project1.fileSources2.[7], Project1.options) |> Async.RunSynchronously let pF, tF = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic + printfn "checking no extra foreground parsing...." (pF - pE) |> shouldEqual 0 // note, no new parse of the file + printfn "checking no extra foreground typechecks...." (tF - tE) |> shouldEqual 0 // note, no new typecheck of the file - (backgroundParseCount.Value <= 9) |> shouldEqual true // but note, the project does not get reparsed - (backgroundCheckCount.Value <= 9) |> shouldEqual true // only two extra typechecks of files + printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value + (backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed + printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value + (backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files () diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 5ea55a4050..90d052edbb 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -15,8 +15,8 @@ open System open System.IO open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common @@ -5161,57 +5161,6 @@ module internal ProjectBig = let parsingOptions, _ = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args) -[] -let ``Test request for parse and check doesn't check whole project`` () = - - let backgroundParseCount = ref 0 - let backgroundCheckCount = ref 0 - checker.FileChecked.Add (fun x -> incr backgroundCheckCount) - checker.FileParsed.Add (fun x -> incr backgroundParseCount) - - checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() - let pB, tB = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic - let parseResults1 = checker.ParseFile(ProjectBig.fileNames.[5], ProjectBig.fileSources2.[5], ProjectBig.parsingOptions) |> Async.RunSynchronously - let pC, tC = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic - (pC - pB) |> shouldEqual 1 - (tC - tB) |> shouldEqual 0 - backgroundParseCount.Value |> shouldEqual 0 - backgroundCheckCount.Value |> shouldEqual 0 - let checkResults1 = checker.CheckFileInProject(parseResults1, ProjectBig.fileNames.[5], 0, ProjectBig.fileSources2.[5], ProjectBig.options) |> Async.RunSynchronously - let pD, tD = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - backgroundParseCount.Value |> shouldEqual 10 -#else - backgroundParseCount.Value |> shouldEqual 5 -#endif - backgroundCheckCount.Value |> shouldEqual 5 - (pD - pC) |> shouldEqual 0 - (tD - tC) |> shouldEqual 1 - - let checkResults2 = checker.CheckFileInProject(parseResults1, ProjectBig.fileNames.[7], 0, ProjectBig.fileSources2.[7], ProjectBig.options) |> Async.RunSynchronously - let pE, tE = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic - (pE - pD) |> shouldEqual 0 - (tE - tD) |> shouldEqual 1 -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - backgroundParseCount.Value |> shouldEqual 10 // but note, the project does not get reparsed -#else - (backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed -#endif - (backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files - - // A subsequent ParseAndCheck of identical source code doesn't do any more anything - let checkResults2 = checker.ParseAndCheckFileInProject(ProjectBig.fileNames.[7], 0, ProjectBig.fileSources2.[7], ProjectBig.options) |> Async.RunSynchronously - let pF, tF = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic - (pF - pE) |> shouldEqual 0 // note, no new parse of the file - (tF - tE) |> shouldEqual 0 // note, no new typecheck of the file -#if FCS_RETAIN_BACKGROUND_PARSE_RESULTS - backgroundParseCount.Value |> shouldEqual 10 // but note, the project does not get reparsed -#else - (backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed -#endif - (backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files - - () [] // Simplified repro for https://github.com/Microsoft/visualfsharp/issues/2679 diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index b390f53e62..a757e81670 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -1,7 +1,7 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../debug/fcs/net45/FSharp.Compiler.Service.ProjectCracker.dll" -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.ProjectCracker.dll" +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -14,8 +14,8 @@ open System open System.IO open NUnit.Framework open FsUnit -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Ast +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common diff --git a/tests/service/ServiceUntypedParseTests.fs b/tests/service/ServiceUntypedParseTests.fs index ccda4f5bac..73789a1a97 100644 --- a/tests/service/ServiceUntypedParseTests.fs +++ b/tests/service/ServiceUntypedParseTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -11,8 +11,8 @@ open System open System.IO open System.Text open NUnit.Framework -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common open Tests.Service diff --git a/tests/service/StructureTests.fs b/tests/service/StructureTests.fs index c98027c4ca..41607f8d47 100644 --- a/tests/service/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -9,9 +9,9 @@ module Tests.Service.StructureTests open System.IO open NUnit.Framework -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.SourceCodeServices.Structure +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices.Structure open FSharp.Compiler.Service.Tests.Common open System.Text diff --git a/tests/service/Symbols.fs b/tests/service/Symbols.fs index da2a779557..b01c13d709 100644 --- a/tests/service/Symbols.fs +++ b/tests/service/Symbols.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -10,7 +10,7 @@ module Tests.Service.Symbols open FSharp.Compiler.Service.Tests.Common open FsUnit open NUnit.Framework -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices module ActivePatterns = diff --git a/tests/service/TokenizerTests.fs b/tests/service/TokenizerTests.fs index 84b95e5175..74348b3d47 100644 --- a/tests/service/TokenizerTests.fs +++ b/tests/service/TokenizerTests.fs @@ -1,16 +1,16 @@  #if INTERACTIVE -#r "../../debug/fcs/net45/FSharp.Compiler.Service.dll" // note, run 'build fcs debug' to generate this, this DLL has a public API so can be used from F# Interactive -#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" +#r "../../artifacts/bin/fcs/net46/FSharp.Compiler.Service.dll" // note, build FSharp.Compiler.Service.Tests.fsproj to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../artifacts/bin/fcs/net46/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else module FSharp.Compiler.Service.Tests.TokenizerTests #endif -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Interactive.Shell -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.SourceCodeServices open NUnit.Framework open FsUnit diff --git a/tests/service/TreeVisitorTests.fs b/tests/service/TreeVisitorTests.fs index e81d140011..2beb2a09bc 100644 --- a/tests/service/TreeVisitorTests.fs +++ b/tests/service/TreeVisitorTests.fs @@ -1,8 +1,8 @@ module Tests.Service.TreeVisitorTests open FSharp.Compiler.Service.Tests.Common -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices.AstTraversal +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices.AstTraversal open NUnit.Framework []