diff --git a/.gitignore b/.gitignore index 9a5400d0d2..4b905ca5d3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,15 @@ # (These aren't generally useful to commit directly; if anything, they should be applied.) scripts/*.patch +/fcs/FSharp.Compiler.Service/illex.fs +/fcs/FSharp.Compiler.Service/ilpars.fs +/fcs/FSharp.Compiler.Service/ilpars.fsi +/fcs/FSharp.Compiler.Service/lex.fs +/fcs/FSharp.Compiler.Service/pars.fs +/fcs/FSharp.Compiler.Service/pars.fsi +/fcs/FSharp.Compiler.Service/pplex.fs +/fcs/FSharp.Compiler.Service/pppars.fs +/fcs/FSharp.Compiler.Service/pppars.fsi /src/*.userprefs /src/fsharp/FSStrings.resources /src/fsharp/FSharp.Build/*.resx @@ -21,29 +30,29 @@ scripts/*.patch /src/fsharp/FSharp.Compiler.Server.Shared/*.resx /src/fsharp/fsi/Fsi.sln /src/fsharp/FSharp.Build/*.resources -/src/fsharp/FSharp.Compiler/*.resx -/src/fsharp/FSharp.Compiler/*.resources -/src/fsharp/FSharp.Compiler/*.sln -/src/fsharp/FSharp.Compiler/*.userprefs +/src/fsharp/FSharp.Compiler.Private/*.resx +/src/fsharp/FSharp.Compiler.Private/*.resources +/src/fsharp/FSharp.Compiler.Private/*.sln +/src/fsharp/FSharp.Compiler.Private/*.userprefs /src/*.log -/src/fsharp/FSharp.Compiler/illex.fs -/src/fsharp/FSharp.Compiler/ilpars.fs -/src/fsharp/FSharp.Compiler/ilpars.fsi -/src/fsharp/FSharp.Compiler/lex.fs -/src/fsharp/FSharp.Compiler/pars.fs -/src/fsharp/FSharp.Compiler/pars.fsi -/src/fsharp/FSharp.Compiler/pplex.fs -/src/fsharp/FSharp.Compiler/pppars.fs -/src/fsharp/FSharp.Compiler/pppars.fsi -/src/fsharp/FSharp.Compiler-proto/illex.fs -/src/fsharp/FSharp.Compiler-proto/ilpars.fs -/src/fsharp/FSharp.Compiler-proto/ilpars.fsi -/src/fsharp/FSharp.Compiler-proto/lex.fs -/src/fsharp/FSharp.Compiler-proto/pars.fs -/src/fsharp/FSharp.Compiler-proto/pars.fsi -/src/fsharp/FSharp.Compiler-proto/pplex.fs -/src/fsharp/FSharp.Compiler-proto/pppars.fs -/src/fsharp/FSharp.Compiler-proto/pppars.fsi +/src/fsharp/FSharp.Compiler.Private/illex.fs +/src/fsharp/FSharp.Compiler.Private/ilpars.fs +/src/fsharp/FSharp.Compiler.Private/ilpars.fsi +/src/fsharp/FSharp.Compiler.Private/lex.fs +/src/fsharp/FSharp.Compiler.Private/pars.fs +/src/fsharp/FSharp.Compiler.Private/pars.fsi +/src/fsharp/FSharp.Compiler.Private/pplex.fs +/src/fsharp/FSharp.Compiler.Private/pppars.fs +/src/fsharp/FSharp.Compiler.Private/pppars.fsi +/src/fsharp/Fsc-proto/illex.fs +/src/fsharp/Fsc-proto/ilpars.fs +/src/fsharp/Fsc-proto/ilpars.fsi +/src/fsharp/Fsc-proto/lex.fs +/src/fsharp/Fsc-proto/pars.fs +/src/fsharp/Fsc-proto/pars.fsi +/src/fsharp/Fsc-proto/pplex.fs +/src/fsharp/Fsc-proto/pppars.fs +/src/fsharp/Fsc-proto/pppars.fsi /src/fsharp/FSharp.LanguageService.Compiler/illex.* /src/fsharp/FSharp.LanguageService.Compiler/ilpars.* /src/fsharp/FSharp.LanguageService.Compiler/lex.* @@ -65,6 +74,8 @@ scripts/*.patch /tests/fsharpqa/Source/*net40-fsharpqa-suite-failures.env /tests/fsharpqa/Source/*net40-fsharpqa-suite-failures.lst /tests/**/FSharp.Core.dll +/tests/fsharp/optimize/stats/FSharpOptimizationInfo.FSharp.Core +/tests/fsharp/optimize/stats/FSharpSignatureInfo.FSharp.Core lib/debug lib/release lib/proto diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000000..225a0237b7 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000000..9f8781de0d Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000000..82ece0f622 --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,138 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + /Library/Frameworks/Mono.framework/Commands/mono + mono + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + $(MonoPath) --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 146fa9ee8d..a991ca14a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ sudo: false install: script: - - ./build.sh NuGet + - ./fcs/build.sh NuGet # Fails on Travis OSX too often because there are network outages on that configuration getting the Mono MDK diff --git a/CHANGELOG-fsharp.md b/CHANGELOG-fsharp.md deleted file mode 100644 index b0cfed8286..0000000000 --- a/CHANGELOG-fsharp.md +++ /dev/null @@ -1,136 +0,0 @@ -4.1.15 - * fix regression on binding redirects for System.Collections.Immutable - -4.1.10 - * Integrate visualfsharp to 55ffe91 - -4.1.9 - * Fix duplicate resources on OSX - -4.1.8 - * [Fix regression in Microsoft.Build.FSharp.targets](https://github.com/fsharp/fsharp/pull/707) - -4.1.7 - * [fix binding redirects for System.Collections.Immutable](https://github.com/fsharp/fsharp/issues/699) - -4.1.6 - * fix version of library going in /usr/lib/mono/fsharp - -4.1.4 - * [align fsc task and target file](https://github.com/fsharp/fsharp/pull/690) - * [use install layout that includes mono/fsharp](https://github.com/fsharp/fsharp/pull/689) - * [fix F# Intereactive on Mono 4.9+](https://github.com/fsharp/fsharp/pull/687) - -4.1.1 - * Update compiler tools - -4.1.0.2 - * Include DiaSymReader DLLs in nuget package - -4.1.0.0 - * Updates to FSharp.Core nuget package for F# 4.1 - -4.0.1.21 - * Fix [#656](https://github.com/fsharp/fsharp/issues/656) - error FS0193: internal error: No access to the given key - -4.0.1.20 - * Fix #639 - Problems with F# scripts on Mono - -4.0.1.19 - * Fix FSharp.Compiler.Tools targets for .NET Core usage - -4.0.1.16 - * Fix FSharp.Compiler.Tools package dependencies - -4.0.1.15 - * Fix null condition in Fsc task - -4.0.1.13 - * Integrate visualfsharp master to 2002675/216a38b - -4.0.1.3 - * Integrate Microsoft\visualfsharp to 688c26bdbbfc766326fc45e4d918f87fcba1e7ba. F# 4.1 work - * [Inlined function causes "FS0078: Unable to find the file"](https://github.com/fsharp/fsharp/issues/584) - -4.0.1.2 - * Integrate Microsoft\visualfsharp to 5d8126a. F# 4.1 work - * FCS API integration and alignment - * [#528 Compiler does not catch typing error in pattern matching when using literals](https://github.com/Microsoft/visualfsharp/issues/528) - * [#659 Fsi fails to augment a type constructor](https://github.com/Microsoft/visualfsharp/issues/659) - * [#807 Async.Choice](https://github.com/Microsoft/visualfsharp/pull/807) - * [Response files for fsc/fsi](https://github.com/Microsoft/visualfsharp/pull/831) - * [#919 Fix handling of optional IDispatch, IUnknown method args](https://github.com/Microsoft/visualfsharp/pull/919) - -4.0.1.1 - * Integrate Microsoft\visualfsharp to 8111c63. See CHANGELOG-visualfsharp.md for changes from Microsoft\visualfsharp - * 04cd959 - fix problem with loop optimization - * d995c59 - Assume we are inside XBuild when 4.5/Mono.Posix.dll exists - * Fix [#483](https://github.com/fsharp/fsharp/issues/483) - Call to Type.GetType for a missing type causes FSI on Mono to produce an erroneous error - -4.0.0.4 - * Integrate Microsoft\visualfsharp to 2d413fb94. See CHANGELOG.md for changes from Microsoft\visualfsharp - -4.0.0.3 - * Fix build problems - -4.0.0.1 - * Integrate F# 4.0 - -3.1.1.25 - * Upstream fix: implement correct version number scheme for new PCL profiles - -3.1.1.20 - * Upstream fix:: #! treated as a comment when it is at the start of an fsharp file - * Upstream fix visualfsharp.codeplex.com issue #78 - allow space characters in active pattern case identifiers - * Upstream fix visualfsharp.codeplex.com issue #78 - Adjust parser to disallow vertical pipes in active pattern case identifiers. - * Upstream fix for visualfsharp.codeplex.com issue #69 - Invalid code generated when calling C# method with optional nullable args - * Upstream fix for visualfsharp.codeplex.com issue #9 - XML doc comments on F# record type fields do not appear when accessing in C# - -3.1.1.19 - * Added files for the nuget packages - -3.1.1.18 - * Do not install FSharp.Build.dll in the GAC. It is not in the GAC on Windows. - -3.1.1.17 - * Remove service components from FSharp.Compiler.dll since. All clients should now use FSharp.Compiler.Service.dll - -3.1.1.15 - * Upstream 2d8ebcd43: XmlDoc generation bugfix: remove duplicate namespaces - * Upstream 3bd52625b: Address-of optimizations for better performance on structs - * Upstream c46aa237a: Perf improvement for Seq.windowed - * Upstream 301a6f33: make it possible to set breakpoint inside quotation - * FSharp.Core for portable profiles 7, 78, 259 if reference assemblies are present (delay-signed) - -3.1.1.14 - * Change monotouch and monodroid FSharp.Core.dll to both use 2.3.98.1 - -3.1.1.12 - * Add build command "all-monotouch-monodroid" - -3.1.1.11 - - * F# Interactive now uses .NET 4.5 profile - * Fix for performance regression in 3.1 with extension members - * Add query support to FSharp.Core portable profiles - * Fix problem with building portable libraries (https://github.com/fsharp/fsharp/issues/299) - -3.1.1.10 - * Include fixes from Microsoft included with Visual F# Tools 3.1.1 - -3.1.1.7 - * Build back versions of FSharp.Core 2.3.0.0, 2.3.5.0, 4.3.0.0 to include code generation fix. - * Build Profile7 (portable47) FSharp.Core - -3.0.30 - * Partial fix for allowing F# 3.1 projects to compile using xbuild (also - requires xbuild fix) - - * Remove a multitude of links in xbuild directories in favour of targets - files which include the canonical targets - -3.0.29 - - * Proper DESTDIR support (very useful for making custom deb/rpm packages) - - diff --git a/CHANGELOG-visualfsharp.md b/CHANGELOG-visualfsharp.md deleted file mode 100644 index 1c1ea83329..0000000000 --- a/CHANGELOG-visualfsharp.md +++ /dev/null @@ -1,231 +0,0 @@ - - Copyright (c) Microsoft Corporation. All Rights Reserved. - - Licensed under the Apache License, Version 2.0. - See License.txt in the project root for license information. - -Visual F# -====================== - -All notable changes to this project will be documented in this file. - -### [4.0.0] - Visual Studio 2015 Update 1 - 30 November 2015 - -#### Enhancements -* Perf: `for i in expr do body` optimization [#219](https://github.com/Microsoft/visualfsharp/pull/219) -* Remove type provider security dialog and use custom icon for type provider assembly reference [#448](https://github.com/Microsoft/visualfsharp/pull/448) -* Perf: Enable parallel build inside Visual Studio [#487](https://github.com/Microsoft/visualfsharp/pull/487) -* Perf: Remove StructBox for Value Types [#549](https://github.com/Microsoft/visualfsharp/pull/549) -* Add compiler warnings for redundant arguments in raise/failwith/failwithf/nullArg/invalidOp/invalidArg [#630](https://github.com/Microsoft/visualfsharp/pull/630) -* Add a compiler warning for lower case literals in patterns [#666](https://github.com/Microsoft/visualfsharp/pull/666) - -#### Bug fixes -* Fix scope of types for named values in attributes improperly set [#437](https://github.com/Microsoft/visualfsharp/pull/437) -* Add general check for escaping typars to check phase [#442](https://github.com/Microsoft/visualfsharp/pull/442) -* Fix AccessViolationException on obfuscated assemblies [#519](https://github.com/Microsoft/visualfsharp/pull/519) -* Fix memory leaks while reloading solutions in Visual Studio [#591](https://github.com/Microsoft/visualfsharp/pull/591) -* Enable breakpoints in `with` augmentations for class types [#608](https://github.com/Microsoft/visualfsharp/pull/608) -* Fix false escaping type parameter check error [#613](https://github.com/Microsoft/visualfsharp/pull/613) -* Fix quotation of readonly fields [#622](https://github.com/Microsoft/visualfsharp/pull/622) -* Keep the reference icons when opening references [#623](https://github.com/Microsoft/visualfsharp/pull/623) -* Don't suppress missing FSI transitive references [#626](https://github.com/Microsoft/visualfsharp/pull/626) -* Make Seq.cast's non-generic and generic IEnumerable implementations equivalent [#651](https://github.com/Microsoft/visualfsharp/pull/651) - -### [4.0.0] - 20 July 2015 - -Includes commits up to `dd8252eb8d20aaedf7b1c7576cd2a8a82d24f587` - -#### Language, compiler, runtime, interactive - -* Normalization and expansion of `Array`, `List`, and `Seq` modules - * New APIs for 4.0: `chunkBySize`, `contains`, `except`, `findBack`, `findInstanceBack`, `indexed`, `item`, `mapFold`, `mapFoldBack`, `sortByDescending`, `sortDescending`, `splitInto`, `tryFindBack`, `tryFindIndexBack`, `tryHead`, `tryItem`, `tryLast` - ![Collection API additions](http://i.imgur.com/SdJ7Doh.png) -* Other new APIs - * `Option.filter`, `Option.toObj`, `Option.ofObj`, `Option.toNullable`, `Option.ofNullable` - * `String.filter` - * `Checked.int8`, `Checked.uint8` - * `Async.AwaitTask` (non-generic) - * `WebClient.AsyncDownloadFile`, `WebClient.AsyncDownloadData` - * `tryUnbox`, `isNull` -* New active pattern to match constant `Decimal` in quotations -* Slicing support for lists -* Support for consuming high-rank (> 4) arrays -* Support for units of measure in `printf`-family functions -* Support for constructors/class names as first-class functions -* Improved exception stack traces in async code -* Automatic `mutable`/`ref` conversion -* Support for static arguments to provided methods -* Support for non-nullable provided types -* Added `NonStructuralComparison` module containing non-structural comparison operators -* Support for rational exponents in units of measure -* Give fsi.exe, fsiAnyCpi.exe nice icons -* `Microsoft.` optional in namepsace paths from FSharp.Core -* Support for extension properties in object initializers -* Pre-support (not yet used) for additional nativeptr intrinsics -* Simplified, more robust resolution of type references in quotations -* Support for inheritance of types that have multiple interface instantiations -* Extended preprocessor grammar -* Support for implicit quotation of expressions used as method arguments -* Support for multiple properties in `[]` -* Eliminate tuple allocation for implicitly returned formal arguments -* Perf: fsc.exe now uses `GCLatencyMode.Batch` -* Perf: Improved `hash`/`compare`/`distinctBy`/`groupBy` performance -* Perf: `Seq.toArray` perf improvement -* Perf: Use `OptimizedClosures.FSharpFunc` in seq.fs where applicable -* Perf: Use literals and mutable variables instead of ref cells for better performance in SHA1 calc -* Perf: Use smart blend of `System.Array.Copy` and iterative copy for array copies -* Perf: Change `Seq.toList` to mutation-based to remove reliance on `List.rev` -* Perf: Change `pdbClose` to test if files are locked before inducing GCs -* Perf: Use server GC mode for compiler -* Bugfix: Changed an error message within the Set module to use the correct module name. -* Bugfix: Fix assembly name of warning FS2003 -* Bugfix [#132](http://visualfsharp.codeplex.com/workitem/132): FSI Shadowcopy causes a significant degrade in the fsi first execute time -* Bugfix [#131](https://visualfsharp.codeplex.com/workitem/131): Fix getentryassembly return value when shadowcopy is enabled in FSI -* Bugfix [#61](https://visualfsharp.codeplex.com/workitem/61) Nonverifiable code generated with units of measure conversion -* Bugfix [#68](https://visualfsharp.codeplex.com/workitem/68) BadImageFormatException with Units of Measure -* Bugfix [#146](https://visualfsharp.codeplex.com/workitem/146) BadImageFormatException in both Release and Debug build with units of measure -* Bugfix: Incorrent cross-module inlining between different .NET profiles -* Bugfix: Properly document exceptions in `Array` module -* Bugfix [#24](https://visualfsharp.codeplex.com/workitem/24): Error reporting of exceptions in type providers `AddMemberDelayed` -* Bugfix [#13](https://github.com/fsharp/fsharp/issues/13): Error on FSI terminal resize -* Bugfix [#29](https://github.com/fsharp/fsharp/issues/29): Module access modifier `internal` does not give internal access if no namespaces are used -* Bugfix: Fix typo in error message for invalid attribute combination -* Bugfix [#27](https://github.com/microsoft/visualfsharp/issues/27): Private module values can be mutated by other modules -* Bugfix [#38](https://github.com/microsoft/visualfsharp/issues/38): ICE - System.ArgumentException: not a measure abbreviation, or incorrect kind -* Bugfix [#44](https://github.com/microsoft/visualfsharp/issues/44): Problems using FSI to `#load` multiple files contributing to the same namespace -* Bugfix [#95](https://github.com/microsoft/visualfsharp/issues/95): `[]` allows access to DU member if qualified only by module name -* Bugfix [#89](https://github.com/microsoft/visualfsharp/issues/89): Embedding an untyped quotation in a typed quotation results in ArgumentException -* Bugfix: Show warning when Record is accessed without type but `[]` was set -* Bugfix [#139](https://visualfsharp.codeplex.com/workitem/139): Memory leak in `Async.AwaitWaitHandle` -* Bugfix [#122](https://github.com/microsoft/visualfsharp/issues/122): `stfld` does not give `.volatile` annotation -* Bugfix [#30](https://github.com/microsoft/visualfsharp/issues/30): Compilation error "Incorrect number of type arguments to local call" -* Bugfix [#163](https://github.com/microsoft/visualfsharp/issues/163): Array slicing does not work properly with non 0-based arrays -* Bugfix [#148](https://github.com/microsoft/visualfsharp/issues/148): XML doc comment generation adding empty garbage -* Bugfix [#98](https://github.com/Microsoft/visualfsharp/issues/98): Using a single, optional, static parameter to a type provider causes failure -* Bugfix [#109](https://github.com/Microsoft/visualfsharp/issues/109): Invalid interface generated by --sig -* Bugfix [#123](https://github.com/Microsoft/visualfsharp/issues/123): Union types without sub-classes should be sealed -* Bugfix [#68](https://github.com/Microsoft/visualfsharp/issues/68): F# 3.1 / Profile 259: `<@ System.Exception() @>` causes AmbiguousMatchException at runtime -* Bugfix [#9](https://github.com/Microsoft/visualfsharp/issues/9): Internal error in FSI: FS0192: binding null type in envBindTypeRef -* Bugfix [#10](https://github.com/Microsoft/visualfsharp/issues/10): Internal error: binding null type in envBindTypeRef -* Bugfix [#266](https://github.com/Microsoft/visualfsharp/issues/266): `windowed` error message incorrectly flags "non-negative" input when "positive" is what's needed -* Bugfix [#270](https://github.com/Microsoft/visualfsharp/issues/270): "internal error: null: convTypeRefAux" in interactive when consuming quotation containing type name with commas or spaces -* Bugfix [#276](https://github.com/Microsoft/visualfsharp/issues/276): Combining struct field with units of measure will result managed type instead of unmanaged type -* Bugfix [#269](https://github.com/Microsoft/visualfsharp/issues/269): Accidentally `#load`ing a DLL in script causes internal error -* Bugfix [#293](https://github.com/Microsoft/visualfsharp/issues/293): `#r` references without relative path are not loaded when file is local -* Bugfix [#237](https://github.com/Microsoft/visualfsharp/issues/237): Problems using FSI on multiple namespaces in a single file -* Bugfix [#338](https://github.com/Microsoft/visualfsharp/issues/338): Escaped unicode characters are encoded incorrectly -* Bugfix [#370](https://github.com/Microsoft/visualfsharp/issues/370): `Seq.sortBy` cannot handle sequences of floats containing NaN -* Bugfix [#368](https://github.com/Microsoft/visualfsharp/issues/368): Optimizer incorrectly assumes immutable field accesses are side-effect free -* Bugfix [#337](https://github.com/Microsoft/visualfsharp/issues/337): Skip interfaces that lie outside the set of referenced assemblies -* Bugfix [#383](https://github.com/Microsoft/visualfsharp/issues/383): Class with `[]` barred from inheriting from normal non-nullable class -* Bugfix [#420](https://github.com/Microsoft/visualfsharp/issues/420): Compiler emits incorrect visibility modifier for internal constructors of abstract class -* Bugfix [#362](https://github.com/Microsoft/visualfsharp/issues/362): Depickling assertion followed by nullref internal errors in units-of-measure case -* Bugfix [#342](https://github.com/Microsoft/visualfsharp/issues/342): FS0193 error when specifying sequential struct layout of a type -* Bugfix [#299](https://github.com/Microsoft/visualfsharp/issues/299): AmbiguousMatchException with `[]` on overloaded extension methods -* Bugfix [#316](https://github.com/Microsoft/visualfsharp/issues/316): Null array-valued attribute causes internal compiler error -* Bugfix [#147](https://github.com/Microsoft/visualfsharp/issues/147): FS0073: internal error: Undefined or unsolved type variable: 'a -* Bugfix [#34](https://github.com/Microsoft/visualfsharp/issues/34): Error in pass2 for type FSharp.DataFrame.FSharpFrameExtensions, error: duplicate entry 'Frame2.GroupRowsBy' in method table -* Bugfix [#212](https://github.com/Microsoft/visualfsharp/issues/212): Record fields initialized in wrong order -* Bugfix [#445](https://github.com/Microsoft/visualfsharp/issues/445): Inconsistent compiler prompt message when using `--pause` switch -* Bugfix [#238](https://github.com/Microsoft/visualfsharp/issues/238): Generic use of member constraint solved to record field causes crash - -#### Visual Studio - -* Updated all templates (except tutorial) to include AssemblyInfo.fs setup in the same manner as default C# project templates -* Add keyboard shortcuts for FSI reset and clear all -* Improved debugger view for Map values -* Improved performance reading stdout/stderr from fsi.exe to F# Interactive window -* Support for VS project up-to-date check -* Improved project template descriptions, make it clearer how to target Xamarin platforms -* Intellisense completion in object initializers -* Add menu entry "Open folder in File Explorer" on folder nodes -* Intellisense completion for named arguments -* `Alt+Enter` sends current line of code to interactive if there is no selection -* Support for debugging F# scripts with the VS debugger -* Add support for hexadecimal values (like 0xFF) ??to MSBuild property BaseAddress -* Updated menu icons used for F# interactive to align with other VS interactive windows -* Bugfix: Fix url of fsharp.org website in vs templates -* Bugfix [#141](https://visualfsharp.codeplex.com/workitem/141): The "Error List" window does not parse MSBuild messages correctly -* Bugfix [#147](https://visualfsharp.codeplex.com/workitem/147): Go to definition doesn't work for default struct ctors -* Bugfix [#50](https://github.com/microsoft/visualfsharp/issues/50): Members hidden from IntelliSense still show up in tooltips -* Bugfix [#57](https://github.com/microsoft/visualfsharp/issues/57) (partial): Visual Studio locking access to XML doc files -* Bugfix [#157](https://github.com/Microsoft/visualfsharp/issues/157): Should not allow Framework 4 / F# 3.1 combination in project properties -* Bugfix [#114](https://github.com/Microsoft/visualfsharp/issues/114): Portable Library (legacy) template displays wrong target framework version -* Bugfix [#273](https://github.com/Microsoft/visualfsharp/issues/273): VS editor shows bogus errors when scripts use multi-hop `#r` and `#load` with relative paths -* Bugfix [#312](https://github.com/Microsoft/visualfsharp/issues/312): F# library project templates and portable library templates do not have `AutoGenerateBindingRedirects` set to true -* Bugfix [#321](https://github.com/Microsoft/visualfsharp/issues/321): Provided type quickinfo shouldn't show hidden and obsolete members from base class -* Bugfix [#319](https://github.com/Microsoft/visualfsharp/issues/319): Projects with target runtime 3.0 don't show up correctly on the VS project dialog -* Bugfix [#283](https://github.com/Microsoft/visualfsharp/issues/283): Changing target framework causes incorrect binding redirects to be added to app.config -* Bugfix [#278](https://github.com/Microsoft/visualfsharp/issues/278): NullReferenceException when trying to add some COM references -* Bugfix [#259](https://github.com/Microsoft/visualfsharp/issues/259): Renaming files in folders causes strange UI display -* Bugfix [#350](https://github.com/Microsoft/visualfsharp/issues/350): Renaming linked file results in error dialog -* Bugfix [#381](https://github.com/Microsoft/visualfsharp/issues/381): Intellisense stops working when referencing PCL component from script (requires `#r "System.Runtime"`) -* Bugfix [#104](https://github.com/Microsoft/visualfsharp/issues/104): Using paste to add files to an F# project causes the order of files in the project and on the UI to get out of sync -* Bugfix [#417](https://github.com/Microsoft/visualfsharp/issues/417): 'Move file up/down' keybindings should be scoped to solution explorer -* Bugfix [#246](https://github.com/Microsoft/visualfsharp/issues/246): Fix invalid already rendered folder error -* Bugfix [#106](https://github.com/Microsoft/visualfsharp/issues/106) (partial): Visual F# Tools leak memory while reloading solutions - -### [3.1.2] - 20 August 2014 - -Includes commits up to `3385e58aabc91368c8e1f551650ba48705aaa285` - -#### Language, compiler, runtime, interactive - -* Allow arbitrary-dimensional slicing -* Ship versions FSharp.Core.dll built on portable profiles 78 and 259 -* Support "shebang" (`#!`) in F# source files -* Vertical pipes disallowed in active pattern case identifiers -* Enable non-locking shadow copy of reference assemblies in fsi/fsianycpu -* Inline codegen optimization using structs -* Perf improvement for `Seq.windowed` -* exe.config files for fsc, fsi, fsianycpu now use simple version range instead of long set of explicit version redirects -* Bugfix [#72](https://visualfsharp.codeplex.com/workitem/72): Indexer properties with more than 4 arguments cannot be accessed -* Bugfix [#113](https://visualfsharp.codeplex.com/workitem/113): `Async.Sleep` in .NETCore profiles does not invoke error continuation -* Bugfix [#91](https://visualfsharp.codeplex.com/workitem/91): String module documentation is false -* Bugfix [#78](https://visualfsharp.codeplex.com/workitem/78): Allow space characters in active pattern case identifiers -* Bugfix: Invalid code generated when calling VB methods with optional byref args -* Bugfix [#69](https://visualfsharp.codeplex.com/workitem/69): Invalid code generated when calling C# method with optional nullable args -* Bugfix [#9](https://visualfsharp.codeplex.com/workitem/9): XML doc comments on F# record type fields do not appear when accessing in C# -* Bugfix [#59](https://visualfsharp.codeplex.com/workitem/59): Compiler always requires System.Runtime.InteropServices, this is not present in all portable profiles -* Bugfix [#17](https://visualfsharp.codeplex.com/workitem/17): Incorrect generation of XML from doc comments for Record fields -* Bugfix [#7](https://visualfsharp.codeplex.com/workitem/17): NullRef in list comprehension, when for loop works -* Bugfix [#1](https://visualfsharp.codeplex.com/workitem/1): Type inference involving generic param arrays -* Bugfix [#37](https://visualfsharp.codeplex.com/workitem/37): Perf regression in 3.1.0 related to resolving extension methods -* Bugfix: Can't run F# console application with 'update' in name -* Bugfix: Slicing and range expression inconsistent -* Bugfix: Invalid code is generated when using field initializers in struct constructor - -#### Visual Studio - -* Project templates for F# portable libraries targeting profiles 78 and 259 -* Enable non-locking shadow copy of reference assemblies in fsi/fsianycpu (VS options added) -* Allow breakpoints to be set inside of quotations -* Support "Publish" action in project system for web, Azure -* Bugfix [#126](https://visualfsharp.codeplex.com/workitem/126): F# package installer does not honor custom install paths for express SKUs -* Bugfix [#75](https://visualfsharp.codeplex.com/workitem/75): Microsoft.FSharp.targets shim not deployed with F# SDK -* Bugfix: Fix crash in smart indent provider -* Bugfix [#55](https://visualfsharp.codeplex.com/workitem/55): Cannot add reference to F# PCL project -* Bugfix: Typos in tutorial project script -* Bugfix: Required C# event members do not appear in intellisense when signature is (object, byref) - - -### [3.1.1] - 24 January 2014 - -#### Language, compiler, runtime, interactive - -* Improve F# compiler telemetry -* Bugfix: Improper treatment of * in AssemblyVersion attribute -* Bugfix: ``sprintf "%%"`` returns `"%%"` in F# 3.1.0, previously returned `"%"` in F# 3.0 and earlier -* Bugfix: F# 3.0 1D slice setter does not compile in F# 3.1.0 - -#### Visual Studio - -* Enable installation of Visual F# on VS Desktop Express -* Added support for showing xml doc comments for named arguments -* Visual F# package deployable on non-VS machines. Deploys compiler and runtime toolchain plus msbuild targets -* Bugfix: Errors when attempting to add reference to .NET core library -* Bugfix: Crash in `FSComp.SR.RunStartupValidation()` - -[4.0.0]: http://fsharp.org -[3.1.2]: http://blogs.msdn.com/b/fsharpteam/archive/2014/08/20/announcing-the-release-of-visual-f-tools-3-1-2.aspx -[3.1.1]: http://blogs.msdn.com/b/fsharpteam/archive/2014/01/22/announcing-visual-f-3-1-1-and-support-for-desktop-express.aspx diff --git a/DEVGUIDE.md b/DEVGUIDE.md new file mode 100644 index 0000000000..5abd611460 --- /dev/null +++ b/DEVGUIDE.md @@ -0,0 +1,212 @@ +# Development Guide + +Follow the instructions below to build and develop the F# Compiler, Core Library and tools on Windows, macOS and Linux. + +* [Developing the F# Compiler (Windows)](#developing-the-f-compiler-windows) +* [Developing the F# Compiler (Linux)](#developing-the-f-compiler-linux) +* [Developing the F# Compiler (macOS)](#developing-the-f-compiler-macos) +* [Developing the Visual F# IDE Tools (Windows Only)](#developing-the-visual-f-ide-tools-windows-only) +* [Notes and Resources](#notes) + +### Developing the F# Compiler (Windows) + +Install + +- [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779) +- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760) + +On Windows you can build the F# compiler for .NET Framework as follows: + + build.cmd + +This is the same as + + build.cmd net40 + +There are various qualifiers: + + build.cmd release -- build release (the default) + build.cmd debug -- build debug instead of release + + build.cmd net40 -- build .NET Framework compiler (the default) + build.cmd coreclr -- build .NET Core compiler + build.cmd vs -- build the Visual F# IDE Tools (see below) + build.cmd pcls -- build the PCL FSharp.Core libraries + build.cmd all -- build all + + build.cmd proto -- force the rebuild of the Proto bootstrap compiler in addition to other things + + build.cmd test -- build default targets, run suitable tests + build.cmd net40 test -- build net40, run suitable tests + build.cmd coreclr test -- build coreclr, run suitable tests + build.cmd vs test -- build Visual F# IDE Tools, run all tests (see below) + build.cmd all test -- build all, run all tests + + build.cmd test-smoke -- build, run smoke tests + build.cmd test-net40-fsharp -- build, run tests\fsharp suite for .NET Framework + build.cmd test-net40-fsharpqa -- build, run tests\fsharpqa suite for .NET Framework + +After you build the first time you can open and use this solution: + + .\FSharp.sln + +or just build it directly: + + msbuild FSharp.sln + +Building ``FSharp.sln`` builds nearly everything. However building portable profiles of +FSharp.Core.dll is not included. If you are just developing the core compiler and library +then building the solution will be enough. + +### Developing the F# Compiler (Linux) + +For Linux/Mono, follow [these instructions](http://www.mono-project.com/docs/getting-started/install/linux/). Also you may need: + + sudo apt-get install mono-complete autoconf libtool pkg-config make git automake + +Then: + + ./autoconf.sh --prefix /usr + make + make install + +Full testing is not yet enabled on Linux, nor is a .NET Core build of the compiler. + +You can alternatively use + + ./build.sh + +### Developing the F# Compiler (macOS) + +Install Xamarin Studio, then + + ./autogen.sh --prefix=/Library/Frameworks/Mono.framework/Versions/Current/ + make + sudo make install + +### Developing the Visual F# IDE Tools (Windows Only) + +To build and test Visual F# IDE Tools, install these requirements: +- [Visual Studio 2017](https://www.visualstudio.com/downloads/) + - Under the "Windows" workloads, select ".NET desktop development" + - Select "F# language support" under the optional components + - Under the "Other Toolsets" workloads, select "Visual Studio extension development" + - Under the "Individual components" tab select "Windows 10 SDK" as shown below (needed for compiling RC resource, see #2556): \ + ![image](https://cloud.githubusercontent.com/assets/1249087/23730261/5c78c850-041b-11e7-9d9d-62766351fd0f.png) + - Failing to install this will lead to error FS0193: Could not find file visualfsharp\vsintegration\src\FSharp.ProjectSystem.FSharp\obj\net40\ProjectResources.rc.res. + +Steps to build: + + build.cmd vs -- build the Visual F# IDE Tools in Release configuration (see below) + build.cmd vs debug -- build the Visual F# IDE Tools in Debug configuration (see below) + build.cmd vs test -- build Visual F# IDE Tools, run all tests (see below) + +Use ``VisualFSharp.sln`` if you're building the Visual F# IDE Tools. + + +Note on Debug vs Release: ``Release`` Configuration has a degraded debugging experience, so if you want to test a change locally, it is recommended to do it in the ``Debug`` configuration. For more information see https://github.com/Microsoft/visualfsharp/issues/2771 and https://github.com/Microsoft/visualfsharp/pull/2773. + +Note: if you face this error [#2351](https://github.com/Microsoft/visualfsharp/issues/2351): + +> error VSSDK1077: Unable to locate the extensions directory. "ExternalSettingsManager::GetScopePaths failed to initialize PkgDefManager for C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe". + +Or hard crash on launch ("Unknown Error"), delete these folders: + +* `%localappdata%\Microsoft\VisualStudio\15.0_(some number here)RoslynDev` +* `%localappdata%\Microsoft\VisualStudio\15.0_(some number here)` + +#### [Optional] Install the Visual F# IDE Tools (Windows Only) + +At time of writing, the Visual F# IDE Tools can only be installed into the latest Visual Studio 2017 RC releases. +The new builds of the Visual F# IDE Tools can no longer be installed into Visual Studio 2015. + +You can install Visual Studio 2017 from https://www.visualstudio.com/downloads/. + +**Note:** This step will install a VSIX extension into Visual Studio "Next" that changes the Visual F# IDE Tools +components installed in that VS installation. You can revert this step by disabling or uninstalling the addin. + +For **Debug**, uninstall then reinstall: + + VSIXInstaller.exe /u:"VisualFSharp" + VSIXInstaller.exe debug\net40\bin\VisualFSharpOpenSource.vsix + +For **Release**, uninstall then reinstall: + + VSIXInstaller.exe /u:"VisualFSharp" + VSIXInstaller.exe release\net40\bin\VisualFSharpOpenSource.vsix + +Restart Visual Studio, it should now be running your freshly-built Visual F# IDE Tools with updated F# Interactive. + +#### [Optional] F5 testing of local changes + +To test your changes locally _without_ overwriting your default installed Visual F# tools, set the `VisualFSharp\Vsix\VisualFSharpOpenSource` +project as the startup project. When you hit F5 a new instance of Visual Studio will be started in the `RoslynDev` hive with your +changes, but the root (default) hive will remain untouched. You can also start this hive automatically using + + devenv.exe /rootsuffix RoslynDev + +Because this uses the "RoslynDev" hive you can simultaneously test changes to an appropriate build of Roslyn binaries. + + +#### [Optional] Rapid deployment of incremental changes to Visual F# IDE Tools components + +For the brave, you can rapidly deploy incrementally updated versions of Visual F# IDE Tool components such as ``FSHarp.Editor.dll`` by copying them directly into the extension directory in your user AppData folder: + + xcopy /y debug\net40\bin\FSharp.* "%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\15.0_7c5620b7FSharpDev\Extensions\Microsoft.VisualFSharpTools\Visual F# Tools\15.4.1.9055" + +This gives a much tighter inner development loop than uninstalling/reinstalling the VSIX, as you do not have to restart VIsual Studio. Caveat emptor. + +#### [Optional] Clobber the F# SDK on the machine + +**Note:** The step below will try to clobber the machine-wide installed F# SDK on your machine. This replaces the ``fsc.exe`` used by the standard install location or ``Microsoft.FSharp.Targets``. **Repairing Visual Studio 15 is currently the only way to revert this step.** + +For **Debug**: + + vsintegration\update-vsintegration.cmd debug + +For **Release**: + + vsintegration\update-vsintegration.cmd release + + +# Notes + +#### Windows: Links to Additional frameworks + +- [Git for windows](http://msysgit.github.io/) +- [.NET 3.5](http://www.microsoft.com/en-us/download/details.aspx?id=21) +- [.NET 4.5](http://www.microsoft.com/en-us/download/details.aspx?id=30653) +- [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779) +- [.NET 4.6](http://www.microsoft.com/en-us/download/details.aspx?id=48137) +- [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760) +- [Windows 7 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=8279) +- [Windows 8 SDK](http://msdn.microsoft.com/en-us/windows/desktop/hh852363.aspx) +- [Windows 8.1 SDK](http://msdn.microsoft.com/en-us/library/windows/desktop/bg162891.aspx) +- [Windows 10 SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk) + + +#### Notes on the Windows .NET Framework build + +1. The `update.cmd` script adds required strong name validation skips, and NGens the compiler and libraries. This requires admin privileges. +1. The compiler binaries produced are "private" and strong-named signed with a test key. +1. Some additional tools are required to build the compiler, notably `fslex.exe`, `fsyacc.exe`, `FSharp.PowerPack.Build.Tasks.dll`, `FsSrGen.exe`, `FSharp.SRGen.Build.Tasks.dll`, and the other tools found in the `lkg` directory. +1. The overall bootstrapping process executes as follows + - We first need an existing F# compiler. We use the one in the `lkg` directory. Let's assume this compiler has an `FSharp.Core.dll` with version X. + - We use this compiler to compile the source in this distribution, to produce a "proto" compiler, dropped to the `proto` directory. When run, this compiler still relies on `FSharp.Core.dll` with version X. + - We use the proto compiler to compile the source for `FSharp.Core.dll` in this distribution. + - We use the proto compiler to compile the source for `FSharp.Compiler.dll`, `fsc.exe`, `fsi.exe`, and other binaries found in this distribution. + +#### Configuring proxy server + +If you are behind a proxy server, NuGet client tool must be configured to use it: + + .nuget\nuget.exe config -set http_proxy=proxy.domain.com:8080 -ConfigFile .nuget\NuGet.Config + .nuget\nuget.exe config -set http_proxy.user=user_name -ConfigFile .nuget\NuGet.Config + .nuget\nuget.exe config -set http_proxy.password=user_password -ConfigFile .nuget\NuGet.Config + +Where you should set proper proxy address, user name and password. + +#### Resources + +The primary technical guide to the core compiler code is [The F# Compiler Technical Guide](http://fsharp.github.io/2015/09/29/fsharp-compiler-guide.html). Please read and contribute to that guide. + diff --git a/DotnetCLIToolsVersion.txt b/DotnetCLIToolsVersion.txt new file mode 100644 index 0000000000..0286f3da09 --- /dev/null +++ b/DotnetCLIToolsVersion.txt @@ -0,0 +1 @@ +2.0.0-preview2-006502 diff --git a/FSharp.Compiler.Service.netcore.sln b/FSharp.Compiler.Service.netcore.sln deleted file mode 100644 index fc874f7783..0000000000 --- a/FSharp.Compiler.Service.netcore.sln +++ /dev/null @@ -1,89 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C359421F-622E-4E66-9893-19310EA7F5AB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fsharp", "fsharp", "{16543C7E-1DBC-4053-A923-9C05E155E8A7}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.netcore", "src\fsharp\FSharp.Compiler.Service\FSharp.Compiler.Service.netcore.fsproj", "{36B9F520-14B1-4431-AAF2-75433B87D851}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker.netcore", "src\fsharp\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.netcore.fsproj", "{5F1CB2F1-B98A-4072-9777-219A93B4AB93}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCrackerTool.netcore", "src\fsharp\FSharp.Compiler.Service.ProjectCrackerTool\FSharp.Compiler.Service.ProjectCrackerTool.netcore.fsproj", "{1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{81813410-487C-4486-95AF-41671011C4C5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharp.Compiler.Service.Tests.netcore", "tests\service\FSharp.Compiler.Service.Tests.netcore.fsproj", "{1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|Any CPU.Build.0 = Debug|Any CPU - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x64.ActiveCfg = Debug|x64 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x64.Build.0 = Debug|x64 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x86.ActiveCfg = Debug|x86 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x86.Build.0 = Debug|x86 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|Any CPU.ActiveCfg = Release|Any CPU - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|Any CPU.Build.0 = Release|Any CPU - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x64.ActiveCfg = Release|x64 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x64.Build.0 = Release|x64 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x86.ActiveCfg = Release|x86 - {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x86.Build.0 = Release|x86 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|x64.ActiveCfg = Debug|x64 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|x64.Build.0 = Debug|x64 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|x86.ActiveCfg = Debug|x86 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Debug|x86.Build.0 = Debug|x86 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|Any CPU.Build.0 = Release|Any CPU - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|x64.ActiveCfg = Release|x64 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|x64.Build.0 = Release|x64 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|x86.ActiveCfg = Release|x86 - {5F1CB2F1-B98A-4072-9777-219A93B4AB93}.Release|x86.Build.0 = Release|x86 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|x64.ActiveCfg = Debug|x64 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|x64.Build.0 = Debug|x64 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|x86.ActiveCfg = Debug|x86 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Debug|x86.Build.0 = Debug|x86 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|Any CPU.Build.0 = Release|Any CPU - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|x64.ActiveCfg = Release|x64 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|x64.Build.0 = Release|x64 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|x86.ActiveCfg = Release|x86 - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94}.Release|x86.Build.0 = Release|x86 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x64.ActiveCfg = Debug|x64 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x64.Build.0 = Debug|x64 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x86.ActiveCfg = Debug|x86 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x86.Build.0 = Debug|x86 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|Any CPU.Build.0 = Release|Any CPU - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x64.ActiveCfg = Release|x64 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x64.Build.0 = Release|x64 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x86.ActiveCfg = Release|x86 - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {16543C7E-1DBC-4053-A923-9C05E155E8A7} = {C359421F-622E-4E66-9893-19310EA7F5AB} - {36B9F520-14B1-4431-AAF2-75433B87D851} = {16543C7E-1DBC-4053-A923-9C05E155E8A7} - {5F1CB2F1-B98A-4072-9777-219A93B4AB93} = {16543C7E-1DBC-4053-A923-9C05E155E8A7} - {1B0F19D7-17CD-4610-9B56-AC7C3C45CB94} = {16543C7E-1DBC-4053-A923-9C05E155E8A7} - {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7} = {81813410-487C-4486-95AF-41671011C4C5} - EndGlobalSection -EndGlobal diff --git a/FSharp.Compiler.Service.sln b/FSharp.Compiler.Service.sln deleted file mode 100644 index bb7f97e377..0000000000 --- a/FSharp.Compiler.Service.sln +++ /dev/null @@ -1,244 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}" - ProjectSection(SolutionItems) = preProject - build.cmd = build.cmd - build.fsx = build.fsx - build.sh = build.sh - nuget\FSharp.Compiler.Service.nuspec = nuget\FSharp.Compiler.Service.nuspec - paket.dependencies = paket.dependencies - README.md = README.md - RELEASE_NOTES.md = RELEASE_NOTES.md - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{83FEE492-6701-4E59-9184-16B1D30E91F8}" - ProjectSection(SolutionItems) = preProject - docs\content\caches.fsx = docs\content\caches.fsx - docs\content\corelib.fsx = docs\content\corelib.fsx - docs\content\devnotes.md = docs\content\devnotes.md - docs\content\editor.fsx = docs\content\editor.fsx - docs\content\filesystem.fsx = docs\content\filesystem.fsx - docs\content\fsharp-readme.md = docs\content\fsharp-readme.md - docs\content\index.md = docs\content\index.md - docs\content\interactive.fsx = docs\content\interactive.fsx - docs\content\project.fsx = docs\content\project.fsx - docs\content\queue.fsx = docs\content\queue.fsx - docs\content\symbols.fsx = docs\content\symbols.fsx - docs\content\tokenizer.fsx = docs\content\tokenizer.fsx - docs\content\typedtree.fsx = docs\content\typedtree.fsx - docs\content\untypedtree.fsx = docs\content\untypedtree.fsx - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{0554567F-1DCB-46A5-9EF2-E1938A3D4F14}" - ProjectSection(SolutionItems) = preProject - docs\tools\generate.fsx = docs\tools\generate.fsx - docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml - EndProjectSection -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service", "src\fsharp\FSharp.Compiler.Service\FSharp.Compiler.Service.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E396742E-B4E5-4584-A9E4-CC1A491F5BC1}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "EditorService", "samples\EditorService\EditorService.fsproj", "{A40507D6-FA48-43D3-B18A-AE3DAACE4020}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "InteractiveService", "samples\InteractiveService\InteractiveService.fsproj", "{067E95E5-E3DC-4CA7-813A-4D1E277D2D52}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tokenizer", "samples\Tokenizer\Tokenizer.fsproj", "{92793069-816F-4F69-84AC-0966F8275E65}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UntypedTree", "samples\UntypedTree\UntypedTree.fsproj", "{C816728D-BBEA-472D-9F6C-E8913957A673}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.Tests", "tests\service\FSharp.Compiler.Service.Tests.fsproj", "{5EF9FF95-1C75-458A-983A-168E43945913}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FscExe", "samples\FscExe\FscExe.fsproj", "{C94C257C-3C0A-4858-B5D8-D746498D1F08}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp_Analysis", "tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj", "{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiExe", "samples\FsiExe\FsiExe.fsproj", "{F9540CA8-1CE0-4546-A23A-A461E416E95B}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCrackerTool", "src\fsharp\FSharp.Compiler.Service.ProjectCrackerTool\FSharp.Compiler.Service.ProjectCrackerTool.fsproj", "{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker", "src\fsharp\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj", "{893C3CD9-5AF8-4027-A667-21E62FC2C703}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestTP", "tests\service\data\TestTP\TestTP.fsproj", "{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{098D1C35-D0FB-4720-83DD-8002293EA237}" - ProjectSection(SolutionItems) = preProject - .gitattributes = .gitattributes - .gitignore = .gitignore - .travis.yml = .travis.yml - appveyor.yml = appveyor.yml - NuGet.Config = NuGet.Config - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "package", "package", "{9020E136-794A-473F-9B1B-9623C97B7161}" - ProjectSection(SolutionItems) = preProject - nuget\FSharp.Compiler.Service.template = nuget\FSharp.Compiler.Service.template - nuget\projectcracker.template = nuget\projectcracker.template - EndProjectSection -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.MSBuild.v12", "src\fsharp\FSharp.Compiler.Service.MSBuild.v12\FSharp.Compiler.Service.MSBuild.v12.fsproj", "{8157B50E-397D-4232-A4E0-1977AFC7076D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|x86.Build.0 = Debug|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.Build.0 = Release|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|x86.ActiveCfg = Release|Any CPU - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|x86.Build.0 = Release|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|x86.ActiveCfg = Debug|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Any CPU.Build.0 = Release|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|x86.ActiveCfg = Release|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Any CPU.Build.0 = Debug|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|x86.ActiveCfg = Debug|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Any CPU.ActiveCfg = Release|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Any CPU.Build.0 = Release|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|x86.ActiveCfg = Release|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Any CPU.Build.0 = Debug|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Debug|x86.ActiveCfg = Debug|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Release|Any CPU.ActiveCfg = Release|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Release|Any CPU.Build.0 = Release|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {92793069-816F-4F69-84AC-0966F8275E65}.Release|x86.ActiveCfg = Release|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|x86.ActiveCfg = Debug|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Any CPU.Build.0 = Release|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|x86.ActiveCfg = Release|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Debug|x86.ActiveCfg = Debug|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Release|Any CPU.Build.0 = Release|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {5EF9FF95-1C75-458A-983A-168E43945913}.Release|x86.ActiveCfg = Release|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|x86.ActiveCfg = Debug|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Any CPU.Build.0 = Release|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|x86.ActiveCfg = Release|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|x86.ActiveCfg = Debug|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Any CPU.Build.0 = Release|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|x86.ActiveCfg = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|x86.ActiveCfg = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|x86.Build.0 = Debug|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Any CPU.Build.0 = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|x86.ActiveCfg = Release|Any CPU - {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|x86.Build.0 = Release|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|x86.ActiveCfg = Debug|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.Build.0 = Release|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|x86.ActiveCfg = Release|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.Build.0 = Debug|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|x86.ActiveCfg = Debug|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.ActiveCfg = Release|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.Build.0 = Release|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|x86.ActiveCfg = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|x86.ActiveCfg = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|x86.Build.0 = Debug|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Any CPU.Build.0 = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|x86.ActiveCfg = Release|Any CPU - {FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|x86.Build.0 = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|x86.ActiveCfg = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|x86.Build.0 = Debug|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Any CPU.Build.0 = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|x86.ActiveCfg = Release|Any CPU - {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {0554567F-1DCB-46A5-9EF2-E1938A3D4F14} = {83FEE492-6701-4E59-9184-16B1D30E91F8} - {A40507D6-FA48-43D3-B18A-AE3DAACE4020} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - {067E95E5-E3DC-4CA7-813A-4D1E277D2D52} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - {92793069-816F-4F69-84AC-0966F8275E65} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - {C816728D-BBEA-472D-9F6C-E8913957A673} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - {C94C257C-3C0A-4858-B5D8-D746498D1F08} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - {F9540CA8-1CE0-4546-A23A-A461E416E95B} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} - EndGlobalSection -EndGlobal diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 4668ba7b2c..452ecef05d 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -10,6 +10,9 @@ Provide the steps required to reproduce the problem 2. Step B +If possible attach a zip file with the repro case. This often makes it easier for others to reproduce. +The zip file should ideally represent the situation just before the call/step that is problematic. + #### Expected behavior Provide a description of the expected behaviour. @@ -33,5 +36,3 @@ Provide any related information * Links to F# RFCs or entries on https://github.com/fsharp/fslang-suggestions * Links to performance testing scripts * Indications of severity - - diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..7900fa869d --- /dev/null +++ b/Makefile @@ -0,0 +1,127 @@ +include $(topsrcdir)mono/config.make + +.PHONY: restore + +restore: + MONO_ENV_OPTIONS=$(monoopts) mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config + +# Make the proto using the bootstrap, then make the final compiler using the proto +# We call MAKE sequentially because we don't want build-final to explicitly depend on build-proto, +# as that causes a complete recompilation of both proto and final everytime you touch the +# compiler sources. +all: + $(MAKE) build-proto + $(MAKE) build + +build-proto: restore + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=Proto /p:TargetFramework=$(TargetFramework) src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=Proto /p:TargetFramework=$(TargetFramework) src/fsharp/Fsc-proto/Fsc-proto.fsproj + +# The main targets +build: + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Core/FSharp.Core.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Build/FSharp.Build.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/Fsc/Fsc.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Compiler.Interactive.Settings/FSharp.Compiler.Interactive.Settings.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Compiler.Server.Shared/FSharp.Compiler.Server.Shared.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/fsi/Fsi.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/fsiAnyCpu/FsiAnyCPU.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 src/fsharp/FSharp.Core.Unittests/FSharp.Core.Unittests.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 /p:FSharpCoreBackVersion=3.0 src/fsharp/FSharp.Core/FSharp.Core.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 /p:FSharpCoreBackVersion=3.1 src/fsharp/FSharp.Core/FSharp.Core.fsproj + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=net40 /p:FSharpCoreBackVersion=4.0 src/fsharp/FSharp.Core/FSharp.Core.fsproj + $(MAKE) -C mono/policy.2.0.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.2.3.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.3.3.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.3.7.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.3.47.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.3.78.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.3.259.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.4.0.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.4.3.FSharp.Core TargetFramework=net40 $@ + $(MAKE) -C mono/policy.4.4.FSharp.Core TargetFramework=net40 $@ +ifeq ("$(pclenabled47)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=portable47 src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif +ifeq ("$(pclenabled7)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=portable7 src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif +ifeq ("$(pclenabled78)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=portable78 src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif +ifeq ("$(pclenabled259)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=portable259 src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif +ifeq ("$(monodroidenabled)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=monoandroid10+monotouch10+xamarinios10 src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif +ifeq ("$(xamarinmacenabled)", "yes") + MONO_ENV_OPTIONS=$(monoopts) $(XBUILD) /p:Configuration=$(Configuration) /p:TargetFramework=xamarinmacmobile src/fsharp/FSharp.Core/FSharp.Core.fsproj +endif + + + +install: + -rm -fr $(DESTDIR)$(monodir)/fsharp + -rm -fr $(DESTDIR)$(monodir)/Microsoft\ F# + -rm -fr $(DESTDIR)$(monodir)/Microsoft\ SDKs/F# + -rm -fr $(DESTDIR)$(monodir)/gac/FSharp.Core + -rm -fr $(DESTDIR)$(monodir)/gac/FSharp.Compiler.Private + -rm -fr $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v/FSharp + -rm -fr $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v11.0/FSharp + -rm -fr $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v12.0/FSharp + -rm -fr $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v14.0/FSharp + -rm -fr $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v15.0/FSharp + $(MAKE) -C mono/FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/FSharp.Build install + $(MAKE) -C mono/FSharp.Compiler.Private install + $(MAKE) -C mono/Fsc install + $(MAKE) -C mono/FSharp.Compiler.Interactive.Settings install + $(MAKE) -C mono/FSharp.Compiler.Server.Shared install + $(MAKE) -C mono/fsi install + $(MAKE) -C mono/fsiAnyCpu install + $(MAKE) -C mono/FSharp.Core TargetFramework=net40 FSharpCoreBackVersion=3.0 install + $(MAKE) -C mono/FSharp.Core TargetFramework=net40 FSharpCoreBackVersion=3.1 install + $(MAKE) -C mono/FSharp.Core TargetFramework=net40 FSharpCoreBackVersion=4.0 install + $(MAKE) -C mono/policy.2.0.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.2.3.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.3.3.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.3.7.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.3.47.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.3.78.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.3.259.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.4.0.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.4.3.FSharp.Core TargetFramework=net40 install + $(MAKE) -C mono/policy.4.4.FSharp.Core TargetFramework=net40 install +ifeq ("$(pclenabled47)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=portable47 install +endif +ifeq ("$(pclenabled7)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=portable7 install +endif +ifeq ("$(pclenabled78)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=portable78 install +endif +ifeq ("$(pclenabled259)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=portable259 install +endif +ifeq ("$(monodroidenabled)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=monoandroid10+monotouch10+xamarinios10 install +endif +ifeq ("$(xamarinmacenabled)", "yes") + $(MAKE) -C mono/FSharp.Core TargetFramework=xamarinmacmobile install +endif + echo "------------------------------ INSTALLED FILES --------------" + ls -xlR $(DESTDIR)$(monodir)/fsharp $(DESTDIR)$(monodir)/xbuild $(DESTDIR)$(monodir)/gac/FSharp* $(DESTDIR)$(monodir)/Microsoft* + +dist: + -rm -r fsharp-$(DISTVERSION) fsharp-$(DISTVERSION).tar.bz2 + mkdir -p fsharp-$(DISTVERSION) + (cd $(topdir) && git archive HEAD |(cd $(builddir)fsharp-$(DISTVERSION) && tar xf -)) + list='$(EXTRA_DIST)'; for s in $$list; do \ + (cp $(topdir)$$s fsharp-$(DISTVERSION)/$$s) \ + done; + tar cvjf fsharp-$(DISTVERSION).tar.bz2 $(patsubst %,--exclude=%, $(NO_DIST)) fsharp-$(DISTVERSION) + du -b fsharp-$(DISTVERSION).tar.bz2 + diff --git a/README.md b/README.md index 7815a4a731..899c779b16 100644 --- a/README.md +++ b/README.md @@ -19,18 +19,20 @@ Build and Test .NET Framework: - Install [.NET 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40779) and [MSBuild 12.0](http://www.microsoft.com/en-us/download/details.aspx?id=40760) + fcs\build.cmd Test.NetFx - build.cmd All.NetFx - (unix: ./build.sh All.NetFx) + fcs/build.sh Test.NetFx -.NET Core +.NET Core / .NET Standard - build All.NetCore + fcs\build.cmd Test.NetStd -Both: + fcs/build.sh Test.NetStd - build All +Packages: + + build NuGet + build TestAndNuGet Build Status @@ -55,4 +57,4 @@ Maintainers The maintainers of this repository from the F# Core Engineering Group are: - [Don Syme](http://github.com/dsyme), [Dave Thomas](http://github.com/7sharp9), [Enrico Sada](http://github.com/enricosada) - - with help and guidance from [Robin Neatherway](https://github.com/rneatherway), [Tomas Petricek](http://github.com/tpetricek), [Lincoln Atkinson](http://github.com/latkin), [Kevin Ransom](http://github.com/KevinRansom), [Vladimir Matveev](http://github.com/vladima) and others + - with help and guidance from [Robin Neatherway](https://github.com/rneatherway), [Tomas Petricek](http://github.com/tpetricek), [Lincoln Atkinson](http://github.com/latkin), [Kevin Ransom](http://github.com/KevinRansom), [Vladimir Matveev](http://github.com/vladima) and others \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index f447bbee5a..af7031073b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,9 +1,7 @@ -os: Visual Studio 2015 +os: Visual Studio 2017 environment: - CLI_VERSION: 1.0.1 - matrix: - - BUILD_TARGET: CreatePackage + CLI_VERSION: 2.0.0 install: - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" @@ -17,12 +15,10 @@ init: build_script: - cmd: dotnet --info - - cmd: build.cmd %BUILD_TARGET% + - cmd: fcs\build.cmd TestAndNuGet test: off version: '{build}' artifacts: - - path: artefacts\release\*.nupkg - type: NuGetPackage - - path: artefacts\debug\*.nupkg + - path: release\*.nupkg type: NuGetPackage diff --git a/before_install.sh b/before_install.sh new file mode 100755 index 0000000000..db4e9cbf67 --- /dev/null +++ b/before_install.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +# OS detection + +OSName=$(uname -s) +case $OSName in + Darwin) + OS=OSX + ;; + + Linux) + OS=Linux + ;; + + *) + echo "Unsupported OS '$OSName' detected. Cannot continue with build, the scripts must be updated to support this OS." + exit 1 + ;; +esac + +# On Linux (or at least, Ubuntu), when building with Mono, need to install the mono-devel package first. +if [ $OS = 'Linux' ]; then + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list + sudo apt-get update + sudo apt-get -y install mono-devel autoconf libtool pkg-config make git +fi + +# Check if SSL certificates have been imported into Mono's certificate store. +# If certs haven't been installed, some/all of the Nuget packages will fail to restore. +# Note, the result of the certmgr and grep commands returns the number of installed X.509 certificates. +# We need to run the command twice -- on some systems (e.g. macOS) the certs are installed in the user store, +# and on other systems (e.g., Ubuntu) they're installed to the machine store. certmgr only shows what's in +# the selected store, which is why we need to check both. +if [ "$(certmgr -list -c Trust | grep -c -F "X.509")" -le 1 ] && [ "$(certmgr -list -c -m Trust | grep -c -F "X.509")" -le 1 ]; then + echo "No SSL certificates installed so unable to restore NuGet packages." >&2; + echo "Run 'mozroots --sync --import' to install certificates to Mono's certificate store." >&2; + exit 1 +fi + +# Restore NuGet packages (needed for compiler bootstrap and tests). +mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config + +(if test x-$BUILD_CORECLR = x-1; then \ + sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'; \ + sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893; \ + sudo apt-get update; \ + sudo apt-get -y install dotnet-dev-1.0.0-preview2-003131; \ + (cd tests/fsharp; mono ../../.nuget/NuGet.exe restore project.json -PackagesDirectory ../../packages -ConfigFile ../../.nuget/NuGet.Config); \ + ./init-tools.sh; \ + echo "------ start log"; \ + cat ./init-tools.log; echo "------ end log"; \ +fi) + +(if test x-$BUILD_PROTO_WITH_CORECLR_LKG = x-1; then \ + (cd lkg/fsc && dotnet restore --packages ../packages && dotnet publish project.json -o ../Tools/lkg -r ubuntu.14.04-x64); \ + (cd lkg/fsi && dotnet restore --packages ../packages && dotnet publish project.json -o ../Tools/lkg -r ubuntu.14.04-x64); \ +fi) + +#TODO: work out how to avoid the need for this +chmod u+x packages/FSharp.Compiler.Tools.4.1.23/tools/fsi.exe +chmod u+x packages/FsLexYacc.7.0.6/build/fslex.exe +chmod u+x packages/FsLexYacc.7.0.6/build/fsyacc.exe + +# The FSharp.Compiler.Tools package doesn't work correctly unless a proper install of F# has been done on the machine. +# OSX can skip this because the OSX Mono installer includes F#. +if [ $OS != 'OSX' ]; then + sudo apt-get -y install fsharp +fi + +# "access to the path /etc/mono/registry/last-time is denied" +# On non-OSX systems, may need to create Mono's registry folder to avoid exceptions during builds. +# This doesn't seem to be necessary on OSX, as the folder is created by the installer. +if [ $OS != 'OSX' ]; then + # This registry folder path is correct for Linux; + # on OSX the folder is /Library/Frameworks/Mono.framework/Versions/Current/etc/mono/registry + # and may be different for *BSD systems. + __MonoRegistryDir="/etc/mono/registry" + if [ ! -d "$__MonoRegistryDir" ]; then + echo "Mono registry directory does not exist (it may not have been created yet)." + echo "The directory needs to be created now; superuser permissions are required for this." + { sudo -- sh -c "mkdir -p $__MonoRegistryDir && chmod uog+rw $__MonoRegistryDir"; } || { echo "Unable to create/chmod Mono registry directory '$__MonoRegistryDir'." >&2; } + fi +fi diff --git a/build-everything.proj b/build-everything.proj new file mode 100644 index 0000000000..a169a82cc5 --- /dev/null +++ b/build-everything.proj @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.fsx b/build.fsx deleted file mode 100644 index 82c30fd2a9..0000000000 --- a/build.fsx +++ /dev/null @@ -1,418 +0,0 @@ -// -------------------------------------------------------------------------------------- -// FAKE build script -// -------------------------------------------------------------------------------------- - -#I "packages/FAKE/tools" -#r "packages/FAKE/tools/FakeLib.dll" -open System -open Fake.AppVeyor -open Fake -open Fake.Git -open Fake.ReleaseNotesHelper -open Fake.UserInputHelper -open Fake.AssemblyInfoFile - -#if MONO -// prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196) -System.Console.OutputEncoding <- System.Text.Encoding.UTF8 -#endif - -// -------------------------------------------------------------------------------------- -// Information about the project to be used at NuGet and in AssemblyInfo files -// -------------------------------------------------------------------------------------- - -let project = "FSharp.Compiler.Service" -let authors = ["Microsoft Corporation, Dave Thomas, Anh-Dung Phan, Tomas Petricek"] - -let gitOwner = "fsharp" -let gitHome = "https://github.com/" + gitOwner - -let gitName = "FSharp.Compiler.Service" -let gitRaw = environVarOrDefault "gitRaw" "https://raw.githubusercontent.com/fsharp" - -let netFrameworks = [(* "v4.0"; *) "v4.5"] - -// -------------------------------------------------------------------------------------- -// The rest of the code is standard F# build script -// -------------------------------------------------------------------------------------- - -let buildDir = "bin" -let releaseDir = "artefacts/release" -let debugDir = "artefacts/debug" - - -let publishDebugPackage = environVar "DEBUG_PACKAGE_PUBLISH" = "true" -let buildDebugPackage = publishDebugPackage || environVar "DEBUG_PACKAGE" <> "false" - -// Read release notes & version info from RELEASE_NOTES.md -let release = LoadReleaseNotes (__SOURCE_DIRECTORY__ + "/RELEASE_NOTES.md") -let isAppVeyorBuild = buildServer = BuildServer.AppVeyor -let isVersionTag tag = Version.TryParse tag |> fst -let hasRepoVersionTag = isAppVeyorBuild && AppVeyorEnvironment.RepoTag && isVersionTag AppVeyorEnvironment.RepoTagName -let assemblyVersion = if hasRepoVersionTag then AppVeyorEnvironment.RepoTagName else release.NugetVersion -let nugetVersion = release.NugetVersion -open SemVerHelper -let nugetDebugVersion = - let semVer = SemVerHelper.parse nugetVersion - let debugPatch, debugPreRelease = - match semVer.PreRelease with - | None -> semVer.Patch + 1, { Origin = "alpha001"; Name = "alpha"; Number = Some 1; Parts = [AlphaNumeric "alpha001"] } - | Some pre -> - let num = match pre.Number with Some i -> i + 1 | None -> 1 - let name = pre.Name - let newOrigin = sprintf "%s%03d" name num - semVer.Patch, { Origin = newOrigin; Name = name; Number = Some num; Parts = [AlphaNumeric newOrigin] } - let debugVer = - { semVer with - Patch = debugPatch - PreRelease = Some debugPreRelease } - debugVer.ToString() -let buildDate = DateTime.UtcNow -let buildVersion = - if hasRepoVersionTag then assemblyVersion - else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber - else assemblyVersion - -let netcoresln = gitName + ".netcore.sln"; - -Target "BuildVersion" (fun _ -> - Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore -) - -// Generate assembly info files with the right version & up-to-date information -Target "AssemblyInfo" (fun _ -> - let fileName = "src/assemblyinfo/assemblyinfo.shared.fs" - CreateFSharpAssemblyInfo fileName - [ Attribute.Version assemblyVersion - Attribute.FileVersion assemblyVersion - Attribute.InformationalVersion assemblyVersion ] -) - -// -------------------------------------------------------------------------------------- -// Clean build results & restore NuGet packages - -Target "Clean" (fun _ -> - CleanDirs [ buildDir; releaseDir; debugDir ] -) - -Target "CleanDocs" (fun _ -> - CleanDirs ["docs"] -) - -Target "Build.NetFx" (fun _ -> - netFrameworks - |> List.iter (fun framework -> - !! (project + ".sln") - |> MSBuild "" "Build" ["Configuration","Release"; "TargetFrameworkVersion", framework] - |> Log (".NET " + framework + " Build-Output: ")) - CopyDir releaseDir buildDir allFiles - CleanDir buildDir -) - -Target "Build.NetFx.Debug" (fun _ -> - netFrameworks - |> List.iter (fun framework -> - !! (project + ".sln") - |> MSBuild "" "Build" ["Configuration","Debug"; "TargetFrameworkVersion", framework] - |> Log (".NET " + framework + " Build-Output: ")) - CopyDir debugDir buildDir allFiles - CleanDir buildDir -) - -// -------------------------------------------------------------------------------------- -// Run the unit tests using test runner - -Target "RunTests.NetFx" (fun _ -> - // Tests seem to depend on this path :/ - CopyDir buildDir releaseDir allFiles - !! (if isAppVeyorBuild then sprintf "./bin/v4.5/FSharp.Compiler.Service.Tests.dll" - else sprintf "./bin/**/FSharp.Compiler.Service.Tests.dll") - |> NUnit (fun p -> - { p with - Framework = "v4.0.30319" - DisableShadowCopy = true - TimeOut = TimeSpan.FromMinutes 20. - OutputFile = "TestResults.xml" }) - CleanDir buildDir -) - -// -------------------------------------------------------------------------------------- -// Build a NuGet package -Target "NuGet.NetFx" (fun _ -> - CopyDir buildDir releaseDir allFiles - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.template" - Version = nugetVersion - OutputPath = releaseDir - ReleaseNotes = toLines release.Notes }) - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.ProjectCracker.template" - Version = nugetVersion - OutputPath = releaseDir - ReleaseNotes = toLines release.Notes }) - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.MSBuild.v12.template" - Version = nugetVersion - OutputPath = releaseDir - ReleaseNotes = toLines release.Notes }) - CleanDir buildDir -) -Target "NuGet.NetFx.Debug" (fun _ -> - CopyDir buildDir debugDir allFiles - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.template" - Version = nugetDebugVersion - OutputPath = debugDir - ReleaseNotes = toLines release.Notes }) - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.ProjectCracker.template" - Version = nugetDebugVersion - OutputPath = debugDir - ReleaseNotes = toLines release.Notes }) - Paket.Pack (fun p -> - { p with - TemplateFile = "nuget/FSharp.Compiler.Service.MSBuild.v12.template" - Version = nugetDebugVersion - OutputPath = debugDir - ReleaseNotes = toLines release.Notes }) - CleanDir buildDir -) - - -Target "PublishNuGet" (fun _ -> - Paket.Push (fun p -> - let apikey = - match getBuildParam "nuget-apikey" with - | s when not (String.IsNullOrWhiteSpace s) -> s - | _ -> getUserInput "Nuget API Key: " - { p with - ApiKey = apikey - WorkingDir = releaseDir }) - if publishDebugPackage then - Paket.Push (fun p -> - let apikey = - match getBuildParam "nuget-apikey" with - | s when not (String.IsNullOrWhiteSpace s) -> s - | _ -> getUserInput "Nuget API Key: " - { p with - ApiKey = apikey - WorkingDir = debugDir }) -) - -// -------------------------------------------------------------------------------------- -// Generate the documentation - -Target "GenerateDocs" (fun _ -> - executeFSIWithArgs "docsrc/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore -) - -Target "GenerateDocsJa" (fun _ -> - executeFSIWithArgs "docsrc/tools" "generate.ja.fsx" ["--define:RELEASE"] [] |> ignore -) - -// -------------------------------------------------------------------------------------- -// Release Scripts - - -#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx" -open Octokit - -Target "GitHubRelease" (fun _ -> - let user = - match getBuildParam "github-user" with - | s when not (String.IsNullOrWhiteSpace s) -> s - | _ -> getUserInput "GitHub Username: " - let pw = - match getBuildParam "github-pw" with - | s when not (String.IsNullOrWhiteSpace s) -> s - | _ -> getUserPassword "GitHub Password: " - let remote = - Git.CommandHelper.getGitResult "" "remote -v" - |> Seq.filter (fun (s: string) -> s.EndsWith("(push)")) - |> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName)) - |> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0] - - StageAll "" - Git.Commit.Commit "" (sprintf "Bump version to %s (%s)" nugetVersion nugetDebugVersion) - Branches.pushBranch "" remote (Information.getBranchName "") - - Branches.tag "" nugetVersion - Branches.pushTag "" remote nugetVersion - if publishDebugPackage then - Branches.tag "" nugetDebugVersion - Branches.pushTag "" remote nugetDebugVersion - - // release on github - createClient user pw - |> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes - |> uploadFile (releaseDir("FSharp.Compiler.Service." + nugetVersion + ".nupkg")) - |> releaseDraft - |> Async.RunSynchronously - - if publishDebugPackage then - createClient user pw - |> createDraft gitOwner gitName nugetDebugVersion true release.Notes - |> uploadFile (debugDir("FSharp.Compiler.Service." + nugetDebugVersion + ".nupkg")) - |> releaseDraft - |> Async.RunSynchronously -) - -// -------------------------------------------------------------------------------------- -// .NET Core and .NET Core SDK - -let isDotnetSDKInstalled = - match Fake.EnvironmentHelper.environVarOrNone "FCS_DNC" with - | Some flag -> - match bool.TryParse flag with - | true, result -> result - | _ -> false - | None -> - try - Shell.Exec("dotnet", "--info") = 0 - with - _ -> false - -let assertExitCodeZero x = if x = 0 then () else failwithf "Command failed with exit code %i" x -let runCmdIn mono workDir exe = Printf.ksprintf (fun args -> - if mono - then - printfn "mono %s/%s %s" workDir exe args - Shell.Exec("mono", sprintf "%s %s" exe args, workDir) - |> assertExitCodeZero - else - printfn "%s/%s %s" workDir exe args - Shell.Exec(exe, args, workDir) - |> assertExitCodeZero -) -let run mono exe = runCmdIn mono "." exe - -Target "CodeGen.NetCore" (fun _ -> - let lexArgs = "--lexlib Internal.Utilities.Text.Lexing" - let yaccArgs = "--internal --parslib Internal.Utilities.Text.Parsing" - let module1 = "--module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser" - let module2 = "--module Microsoft.FSharp.Compiler.Parser" - let module3 = "--module Microsoft.FSharp.Compiler.PPParser" - let open1 = "--open Microsoft.FSharp.Compiler.AbstractIL" - let open2 = "--open Microsoft.FSharp.Compiler" - let open3 = "--open Microsoft.FSharp.Compiler" - - // restore all the required tools, declared in each fsproj - run false "dotnet" "restore %s" netcoresln - run false "dotnet" "restore %s" "tools.fsproj" - - // run tools - let toolDir = "packages/FsLexYacc/build" - let fcsNetcore = "src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.netcore.fsproj" - let fsLex fsl out = runCmdIn isMono "." (sprintf "%s/fslex.exe" toolDir) "%s --unicode %s -o %s" fsl lexArgs out - let fsYacc fsy out m o = runCmdIn isMono "." (sprintf "%s/fsyacc.exe" toolDir) "%s %s %s %s %s -o %s" fsy lexArgs yaccArgs m o out - - run false "dotnet" "fssrgen src/fsharp/FSComp.txt src/fsharp/FSharp.Compiler.Service/FSComp.fs src/fsharp/FSharp.Compiler.Service/FSComp.resx" - run false "dotnet" "fssrgen src/fsharp/fsi/FSIstrings.txt src/fsharp/FSharp.Compiler.Service/FSIstrings.fs src/fsharp/FSharp.Compiler.Service/FSIstrings.resx" - fsLex "src/fsharp/lex.fsl" "src/fsharp/FSharp.Compiler.Service/lex.fs" - fsLex "src/fsharp/pplex.fsl" "src/fsharp/FSharp.Compiler.Service/pplex.fs" - fsLex "src/absil/illex.fsl" "src/fsharp/FSharp.Compiler.Service/illex.fs" - fsYacc "src/absil/ilpars.fsy" "src/fsharp/FSharp.Compiler.Service/ilpars.fs" module1 open1 - fsYacc "src/fsharp/pars.fsy" "src/fsharp/FSharp.Compiler.Service/pars.fs" module2 open2 - fsYacc "src/fsharp/pppars.fsy" "src/fsharp/FSharp.Compiler.Service/pppars.fs" module3 open3 -) - -Target "Build.NetCore" (fun _ -> - run false "dotnet" "pack %s -v n -c Release" netcoresln -) - -Target "Build.NetCore.Debug" (fun _ -> - run false "dotnet" "pack %s -v n -c Debug" netcoresln -) - -Target "RunTests.NetCore" (fun _ -> - run false "dotnet" "run -p tests/service/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetCore.xml;format=nunit3" -) - - -//use dotnet-mergenupkg to merge the .netcore nuget package into the default one -Target "Nuget.AddNetCore" (fun _ -> - do - let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" releaseDir release.AssemblyVersion - let netcoreNupkg = sprintf "src/fsharp/FSharp.Compiler.Service/bin/Release/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion - runCmdIn false "." "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg - - do - let nupkg = sprintf "%s/FSharp.Compiler.Service.ProjectCracker.%s.nupkg" releaseDir release.AssemblyVersion - let netcoreNupkg = sprintf "src/fsharp/FSharp.Compiler.Service.ProjectCracker/bin/Release/FSharp.Compiler.Service.ProjectCracker.%s.nupkg" release.AssemblyVersion - runCmdIn false "." "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg -) - -Target "Nuget.AddNetCore.Debug" (fun _ -> - do - let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" debugDir nugetDebugVersion - let netcoreNupkg = sprintf "src/fsharp/FSharp.Compiler.Service/bin/Debug/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion - runCmdIn false "." "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg - - do - let nupkg = sprintf "%s/FSharp.Compiler.Service.ProjectCracker.%s.nupkg" debugDir nugetDebugVersion - let netcoreNupkg = sprintf "src/fsharp/FSharp.Compiler.Service.ProjectCracker/bin/Debug/FSharp.Compiler.Service.ProjectCracker.%s.nupkg" release.AssemblyVersion - runCmdIn false "." "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg -) - -// -------------------------------------------------------------------------------------- -// Run all targets by default. Invoke 'build ' to override - -Target "Release" DoNothing -Target "CreatePackage" DoNothing -Target "NuGet" DoNothing -Target "All" DoNothing -Target "All.NetCore" DoNothing -Target "All.NetFx" DoNothing - -"Clean" - =?> ("BuildVersion", isAppVeyorBuild) - ==> "AssemblyInfo" - ==> "CodeGen.NetCore" - ==> "Build.NetCore" - =?> ("Build.NetCore.Debug", buildDebugPackage) - ==> "RunTests.NetCore" - ==> "All.NetCore" - -"Clean" - =?> ("BuildVersion", isAppVeyorBuild) - ==> "AssemblyInfo" - ==> "Build.NetFx" - =?> ("Build.NetFx.Debug", buildDebugPackage) - ==> "RunTests.NetFx" - ==> "All.NetFx" - -"All.NetFx" - =?> ("All.NetCore", isDotnetSDKInstalled) - ==> "All" - -"All.NetCore" - ==> "Nuget.AddNetCore" - -"All.NetCore" - =?> ("Nuget.AddNetCore.Debug", buildDebugPackage) - -"All.NetFx" - ==> "NuGet.NetFx" - =?> ("NuGet.NetFx.Debug", buildDebugPackage) - =?> ("Nuget.AddNetCore", isDotnetSDKInstalled) - =?> ("Nuget.AddNetCore.Debug", buildDebugPackage && isDotnetSDKInstalled) - ==> "NuGet" - -"All" - ==> "NuGet" - ==> "CreatePackage" - ==> "GitHubRelease" - ==> "PublishNuGet" - ==> "Release" - -"CleanDocs" - ==> "GenerateDocsJa" - ==> "GenerateDocs" - ==> "Release" - -RunTargetOrDefault "All" diff --git a/.paket/Paket.Restore.targets b/fcs/.paket/Paket.Restore.targets similarity index 100% rename from .paket/Paket.Restore.targets rename to fcs/.paket/Paket.Restore.targets diff --git a/.paket/paket.bootstrapper.exe b/fcs/.paket/paket.bootstrapper.exe similarity index 100% rename from .paket/paket.bootstrapper.exe rename to fcs/.paket/paket.bootstrapper.exe diff --git a/.paket/paket.targets b/fcs/.paket/paket.targets similarity index 100% rename from .paket/paket.targets rename to fcs/.paket/paket.targets diff --git a/src/fsharp/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj b/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj similarity index 62% rename from src/fsharp/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj rename to fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj index 7aaaf51efc..deef4f0e68 100644 --- a/src/fsharp/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj +++ b/fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj @@ -1,15 +1,12 @@  + + $(MSBuildProjectDirectory)\..\..\src + + Debug AnyCPU @@ -19,26 +16,23 @@ $(NoWarn);44;62;9 {8157b50e-397d-4232-a4e0-1977afc7076d} true - v4.5 0x06800000 - $(OtherFlags) /warnon:1182 true true $(OtherFlags) --times $(NoWarn);69;65;54;61;75 true - ..\..\..\bin\$(TargetFrameworkVersion) - $(OutputPath)\$(AssemblyName).xml - $(DefineConstants);CROSS_PLATFORM_COMPILER - $(DefineConstants);ENABLE_MONO_SUPPORT - $(DefineConstants);FX_ATLEAST_45 - $(DefineConstants);FX_ATLEAST_40 - $(DefineConstants);FX_MSBUILDRESOLVER_RUNTIMELIKE - 4.4.0.0 + ..\..\$(Configuration)\fcs\net45\ false true AnyCPU + $(DefineConstants);CROSS_PLATFORM_COMPILER + $(DefineConstants);ENABLE_MONO_SUPPORT + $(OtherFlags) /warnon:1182 + $(OtherFlags) --version:$(VersionPrefix).0 + + v4.5 @@ -50,13 +44,7 @@ true - - AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.MSBuild.v12.dll.fs - - - AssemblyInfo/assemblyinfo.shared.fs - - + Service/MSBuildReferenceResolver.fs @@ -68,35 +56,37 @@ - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Framework.dll + false - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Engine.dll + false - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.dll + false - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll + false - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Tasks.v12.0.dll + false - - False + + + $(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + false + + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - + \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj b/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj similarity index 73% rename from src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj rename to fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj index 82d7749b27..07625e300e 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj @@ -1,21 +1,28 @@  - + + $(MSBuildProjectDirectory)\..\..\src + + Debug AnyCPU $(MSBuildProjectDirectory)\..\..\..\ 2.0 893c3cd9-5af8-4027-a667-21e62fc2c703 - Library FSharp.Compiler.Service.ProjectCracker FSharp.Compiler.Service.ProjectCracker - v4.5 - 4.4.0.0 FSharp.Compiler.Service.ProjectCracker - ..\..\..\bin\$(TargetFrameworkVersion) - ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.ProjectCracker.xml + Library + ..\..\$(Configuration)\fcs\net45\ + $(OutputPath)$(AssemblyName).xml false + + v4.5 + true + AnyCPU + 3 + $(OtherFlags) --version:$(VersionPrefix).0 true @@ -23,29 +30,25 @@ false false DEBUG;TRACE - 3 - AnyCPU - true pdbonly true true TRACE - 3 - AnyCPU - true - - False - + + + $(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + false + @@ -60,5 +63,5 @@ True - + \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs similarity index 97% rename from src/fsharp/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs rename to fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs index baf8102279..462c749f2d 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs @@ -33,7 +33,7 @@ type ProjectCracker = logMap := Map.add opts.ProjectFile opts.LogOutput !logMap { ProjectFileName = opts.ProjectFile - ProjectFileNames = sourceFiles + SourceFiles = sourceFiles OtherOptions = otherOptions ReferencedProjects = referencedProjects IsIncompleteTypeCheckEnvironment = false @@ -41,7 +41,8 @@ type ProjectCracker = LoadTime = loadedTimeStamp UnresolvedReferences = None OriginalLoadReferences = [] - ExtraProjectInfo = None } + ExtraProjectInfo = None + Stamp = None } #if NETSTANDARD1_6 let arguments = [| diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/App.config b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/App.config similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/App.config rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/App.config diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj similarity index 64% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj index 69c44eb009..bb29e5b736 100644 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj @@ -1,6 +1,9 @@  - + + $(MSBuildProjectDirectory)\..\..\src + + Debug AnyCPU @@ -8,18 +11,21 @@ 2.0 b1bdd96d-47e1-4e65-8107-fbae23a06db4 Exe + ..\..\$(Configuration)\fcs\net45\ + $(OutputPath)$(AssemblyName).xml FSharp.Compiler.Service.ProjectCrackerTool FSharp.Compiler.Service.ProjectCrackerTool - v4.5 - 4.4.0.0 FSharp.Compiler.Service.ProjectCrackerTool $(OtherFlags) --staticlink:FSharp.Core - $(NoWarn);40 + $(NoWarn);40;44;2011 true - FSharp.Compiler.Service.ProjectCrackerTool - $(SolutionDir)bin\$(TargetFrameworkVersion) - $(SolutionDir)bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.ProjectCrackerTool.xml false + + v4.5 + 3 + AnyCPU + true + $(OtherFlags) --version:$(VersionPrefix).0 true @@ -27,23 +33,13 @@ false false DEBUG;TRACE - 3 - AnyCPU - true pdbonly true true TRACE - 3 - AnyCPU - true - - 11 - - @@ -53,23 +49,20 @@ - True - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll + false - True - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll + false - True - True + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll + false - True - - - - False + $(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll + false @@ -78,12 +71,13 @@ + + + + $(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + false + + - + \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/Program.fs diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs rename to fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs diff --git a/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj b/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj new file mode 100644 index 0000000000..058a83e551 --- /dev/null +++ b/fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj @@ -0,0 +1,59 @@ + + + netcoreapp1.0 + $(DefineConstants);DOTNETCORE;FX_ATLEAST_45;FX_ATLEAST_PORTABLE;FX_NO_RUNTIMEENVIRONMENT;FX_RESHAPED_REFLECTION;TODO_REWORK_ASSEMBLY_LOAD; + $(NoWarn);44; + true + true + true + false + + + + ReshapedReflection.fs + + + FsUnit.fs + + + Common.fs + + + EditorTests.fs + + + ExprTests.fs + + + TokenizerTests.fs + + + PerfTests.fs + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/FscExe/App.config b/fcs/FSharp.Compiler.Service.Tests/App.config similarity index 86% rename from samples/FscExe/App.config rename to fcs/FSharp.Compiler.Service.Tests/App.config index 76e86b6d2a..76cc57718b 100644 --- a/samples/FscExe/App.config +++ b/fcs/FSharp.Compiler.Service.Tests/App.config @@ -5,7 +5,7 @@ - + diff --git a/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj new file mode 100644 index 0000000000..95498ca69c --- /dev/null +++ b/fcs/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj @@ -0,0 +1,133 @@ + + + + $(MSBuildProjectDirectory)\..\..\src + + + + Debug + AnyCPU + $(MSBuildProjectDirectory)\..\..\..\ + 2.0 + EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F + Library + FSharp + FSharp.Compiler.Service.Tests + FSharp.Compiler.Service.Tests + LIBRARY + 58;75 + v4.6 + EXTENSIONTYPING;$(DefineConstants) + false + ..\..\$(Configuration)\fcs\net45\ + true + 3 + true + + + true + full + false + AnyCPU + true + + + pdbonly + true + AnyCPU + true + + + + FsUnit.fs + + + Common.fs + + + EditorTests.fs + + + FileSystemTests.fs + + + ProjectAnalysisTests.fs + + + MultiProjectAnalysisTests.fs + + + PerfTests.fs + + + InteractiveCheckerTests.fs + + + ExprTests.fs + + + CSharpProjectAnalysis.fs + + + ProjectOptionsTests.fs + + + FSharp.Core.optdata + PreserveNewest + + + FSharp.Core.sigdata + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + $(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + True + + + True + ..\..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll + + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true + + + + CSharp_Analysis + {887630A3-4B1D-40EA-B8B3-2D842E9C40DB} + True + + + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + FSharp.Compiler.Service + True + + + FSharp.Compiler.Service.ProjectCracker + {893c3cd9-5af8-4027-a667-21e62fc2c703} + True + + + + \ No newline at end of file diff --git a/fcs/FSharp.Compiler.Service.netstandard.sln b/fcs/FSharp.Compiler.Service.netstandard.sln new file mode 100644 index 0000000000..5cb21d4663 --- /dev/null +++ b/fcs/FSharp.Compiler.Service.netstandard.sln @@ -0,0 +1,50 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.8 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.netstandard", "FSharp.Compiler.Service.netstandard\FSharp.Compiler.Service.netstandard.fsproj", "{36B9F520-14B1-4431-AAF2-75433B87D851}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharp.Compiler.Service.Tests.netcore", "FSharp.Compiler.Service.Tests.netcore\FSharp.Compiler.Service.Tests.netcore.fsproj", "{1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x64.ActiveCfg = Debug|x64 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x64.Build.0 = Debug|x64 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x86.ActiveCfg = Debug|x86 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Debug|x86.Build.0 = Debug|x86 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|Any CPU.Build.0 = Release|Any CPU + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x64.ActiveCfg = Release|x64 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x64.Build.0 = Release|x64 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x86.ActiveCfg = Release|x86 + {36B9F520-14B1-4431-AAF2-75433B87D851}.Release|x86.Build.0 = Release|x86 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x64.ActiveCfg = Debug|x64 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x64.Build.0 = Debug|x64 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x86.ActiveCfg = Debug|x86 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Debug|x86.Build.0 = Debug|x86 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|Any CPU.Build.0 = Release|Any CPU + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x64.ActiveCfg = Release|x64 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x64.Build.0 = Release|x64 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x86.ActiveCfg = Release|x86 + {1004CE3D-0CCB-47F5-8DBF-657D1B9C19D7}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEDB1900-EFFF-4691-89B1-6DBEE6B77491} + EndGlobalSection +EndGlobal diff --git a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.netcore.fsproj b/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj old mode 100755 new mode 100644 similarity index 50% rename from src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.netcore.fsproj rename to fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj index aa7082abd1..eb20755c31 --- a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.netcore.fsproj +++ b/fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj @@ -1,10 +1,14 @@ - + + + $(MSBuildProjectDirectory)\..\..\src + + - 13.0.0 netstandard1.6 FSharp.Compiler.Service $(DefineConstants);BUILDING_WITH_LKG - $(DefineConstants);COMPILED_AS_LANGUAGE_SERVICE_DLL + $(DefineConstants);COMPILER_PUBLIC_API + $(DefineConstants);COMPILER_SERVICE_AS_DLL $(DefineConstants);COMPILER $(DefineConstants);COMPILER_SERVICE $(DefineConstants);COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0 @@ -41,6 +45,7 @@ $(DefineConstants);FX_NO_WEB_CLIENT $(DefineConstants);FX_NO_WINFORMS $(DefineConstants);FX_NO_WIN_REGISTRY + $(DefineConstants);FX_NO_INDENTED_TEXT_WRITER $(DefineConstants);FX_REDUCED_CONSOLE $(DefineConstants);FX_REDUCED_EXCEPTIONS $(DefineConstants);FX_RESHAPED_CONSOLE @@ -55,7 +60,7 @@ $(DefineConstants);NO_INLINE_IL_PARSER $(DefineConstants);NO_LOADER_OPTIMIZATION $(DefineConstants);NO_LOGGING_GUI - $(DefineConstants);RESHAPED_MSBUILD + $(DefineConstants);FX_RESHAPED_MSBUILD $(DefineConstants);SIGNED $(DefineConstants);STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY $(DefineConstants);TODO_REWORK_ASSEMBLY_LOAD @@ -64,178 +69,179 @@ true true true - - false - + AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.dll.fs - - AssemblyInfo/assemblyinfo.shared.fs - - - FSComp.resx - - + + FSComp.txt + + + FSIstrings.txt + + FSStrings.resx - - FSIstrings.resx - - - - + + --module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser --open Microsoft.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 + pars.fsy + + Reshaped/reshapedreflection.fs - + ErrorText/sformat.fsi - + ErrorText/sformat.fs - + ErrorText/sr.fsi - + ErrorText/sr.fs - + LexYaccRuntime/prim-lexing.fsi - + LexYaccRuntime/prim-lexing.fs - + LexYaccRuntime/prim-parsing.fsi - + LexYaccRuntime/prim-parsing.fs - + Utilities/ResizeArray.fsi - + Utilities/ResizeArray.fs - + Utilities/HashMultiMap.fsi - + Utilities/HashMultiMap.fs - + Utilities/EditDistance.fs - + Utilities/TaggedCollections.fsi - + Utilities/TaggedCollections.fs - + Utilities/QueueList.fs - + Utilities/ildiag.fsi - + Utilities/ildiag.fs - + Utilities/illib.fs - + Utilities/filename.fsi - + Utilities/filename.fs - + Utilities/zmap.fsi - + Utilities/zmap.fs - + Utilities/zset.fsi - + Utilities/zset.fs - + Utilities/bytes.fsi - + Utilities/bytes.fs - + Utilities/lib.fs - + Utilities/InternalCollections.fsi - + Utilities/InternalCollections.fs - + Utilities/rational.fsi - + Utilities/rational.fs - + ErrorLogging/range.fsi - + ErrorLogging/range.fs - + ErrorLogging/ErrorLogger.fs - + ErrorLogging/ErrorResolutionHints.fs - + ReferenceResolution/ReferenceResolver.fs - + AbsIL/il.fsi - + AbsIL/il.fs - + AbsIL/ilx.fsi - + AbsIL/ilx.fs - + AbsIL/ilascii.fsi - + AbsIL/ilascii.fs - + AbsIL/ilprint.fsi - + AbsIL/ilprint.fs - + AbsIL/ilmorph.fsi - + AbsIL/ilmorph.fs - + AbsIL/ilsign.fs - + AbsIL/ilsupp.fsi - + AbsIL/ilsupp.fs @@ -244,67 +250,83 @@ AbsIL/illex.fs - + AbsIL/ilbinary.fsi - + AbsIL/ilbinary.fs - + AbsIL/ilread.fsi - + AbsIL/ilread.fs - + AbsIL/ilwritepdb.fsi - + AbsIL/ilwritepdb.fs - + AbsIL/ilwrite.fsi - + AbsIL/ilwrite.fs - + AbsIL/ilreflect.fs - + CompilerLocation/CompilerLocationUtils.fs - + PrettyNaming/PrettyNaming.fs - + ILXErase/ilxsettings.fs - + ILXErase/EraseClosures.fsi - + ILXErase/EraseClosures.fs - + ILXErase/EraseUnions.fsi - + ILXErase/EraseUnions.fs - + + --unicode --lexlib Internal.Utilities.Text.Lexing + AbsIL/illex.fsl + + + --unicode --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/lex.fsl + + + --unicode --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/pplex.fsl + + + --module Microsoft.FSharp.Compiler.PPParser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + ParserAndUntypedAST/pppars.fsy + + ParserAndUntypedAST/UnicodeLexing.fsi - + ParserAndUntypedAST/UnicodeLexing.fs - + ParserAndUntypedAST/layout.fsi - + ParserAndUntypedAST/layout.fs - + ParserAndUntypedAST/ast.fs @@ -313,10 +335,10 @@ ParserAndUntypedAST/pars.fs - + ParserAndUntypedAST/lexhelp.fsi - + ParserAndUntypedAST/lexhelp.fs @@ -325,273 +347,291 @@ ParserAndUntypedAST/lex.fs - + ParserAndUntypedAST/LexFilter.fs - + TypedAST/tainted.fsi - + TypedAST/tainted.fs - + TypedAST/ExtensionTyping.fsi - + TypedAST/ExtensionTyping.fs - + TypedAST/QuotationPickler.fsi - + TypedAST/QuotationPickler.fs - + TypedAST/tast.fs - + TypedAST/TcGlobals.fs - + TypedAST/TastOps.fsi - + TypedAST/TastOps.fs - + TypedAST/TastPickle.fsi - + TypedAST/TastPickle.fs - + Logic/import.fsi - + Logic/import.fs - + Logic/infos.fs - + Logic/AccessibilityLogic.fs - + Logic/AttributeChecking.fs - + Logic/InfoReader.fs - + Logic/NicePrint.fs - + Logic/AugmentWithHashCompare.fsi - + Logic/AugmentWithHashCompare.fs - + Logic/NameResolution.fsi - + Logic/NameResolution.fs - + Logic/TypeRelations.fs - + Logic/SignatureConformance.fs - + Logic/MethodOverrides.fs - + Logic/MethodCalls.fs - + Logic/PatternMatchCompilation.fsi - + Logic/PatternMatchCompilation.fs - + Logic/ConstraintSolver.fsi - + Logic/ConstraintSolver.fs - + Logic/CheckFormatStrings.fsi - + Logic/CheckFormatStrings.fs - + Logic/FindUnsolved.fs - + Logic/QuotationTranslator.fsi - + Logic/QuotationTranslator.fs - + Logic/PostInferenceChecks.fsi - + Logic/PostInferenceChecks.fs - + Logic/TypeChecker.fsi - + Logic/TypeChecker.fs - + Optimize/Optimizer.fsi - + Optimize/Optimizer.fs - + Optimize/DetupleArgs.fsi - + Optimize/DetupleArgs.fs - + Optimize/InnerLambdasToTopLevelFuncs.fsi - + Optimize/InnerLambdasToTopLevelFuncs.fs - + Optimize/LowerCallsAndSeqs.fs - + Optimize/autobox.fs - + CodeGen/IlxGen.fsi - + CodeGen/IlxGen.fs - + Driver/CompileOps.fsi - + Driver/CompileOps.fs - + Driver/CompileOptions.fsi - + Driver/CompileOptions.fs - + Driver/fsc.fsi - + Driver/fsc.fs - - Service/IncrementalBuild.fsi + + Symbols/SymbolHelpers.fsi - - Service/IncrementalBuild.fs + + Symbols/SymbolHelpers.fs - - Service/Reactor.fsi + + Symbols/Symbols.fsi - - Service/Reactor.fs + + Symbols/Symbols.fs - - Service/ServiceConstants.fs + + Symbols/Exprs.fsi - - Service/ServiceDeclarations.fsi + + Symbols/Exprs.fs - - Service/ServiceDeclarations.fs + + Service/IncrementalBuild.fsi - - Service/Symbols.fsi + + Service/IncrementalBuild.fs - - Service/Symbols.fs + + Service/Reactor.fsi - - Service/Exprs.fsi + + Service/Reactor.fs - - Service/Exprs.fs + + Service/ServiceConstants.fs - + Service/ServiceLexing.fsi - + Service/ServiceLexing.fs - + Service/ServiceParseTreeWalk.fs - + Service/ServiceNavigation.fsi - + Service/ServiceNavigation.fs - + Service/ServiceParamInfoLocations.fsi - + Service/ServiceParamInfoLocations.fs - + Service/ServiceUntypedParse.fsi - + Service/ServiceUntypedParse.fs - + Service/reshapedmsbuild.fs - + Service/SimulatedMSBuildReferenceResolver.fs - + + Service/ServiceDeclarationLists.fsi + + + Service/ServiceDeclarationLists.fs + + Service/ServiceAssemblyContent.fsi - + Service/ServiceAssemblyContent.fs - + + Service/ServiceXmlDocParser.fsi + + + Service/ServiceXmlDocParser.fs + + + Service/ExternalSymbol.fsi + + + Service/ExternalSymbol.fs + + Service/service.fsi - + Service/service.fs - - Service/SimpleServices.fsi + + Service/ServiceInterfaceStubGenerator.fsi + + + Service/ServiceInterfaceStubGenerator.fs + + + Service/ServiceStructure.fsi - - Service/SimpleServices.fs + + Service/ServiceStructure.fs - + Service/fsi.fsi - + Service/fsi.fs - - - - - - @@ -603,7 +643,8 @@ - - + + + \ No newline at end of file diff --git a/fcs/FSharp.Compiler.Service.sln b/fcs/FSharp.Compiler.Service.sln new file mode 100644 index 0000000000..e1be709379 --- /dev/null +++ b/fcs/FSharp.Compiler.Service.sln @@ -0,0 +1,151 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.8 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}" + ProjectSection(SolutionItems) = preProject + build.cmd = build.cmd + build.fsx = build.fsx + build.sh = build.sh + nuget\FSharp.Compiler.Service.nuspec = nuget\FSharp.Compiler.Service.nuspec + paket.dependencies = paket.dependencies + README.md = README.md + RELEASE_NOTES.md = RELEASE_NOTES.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docsrc", "docsrc", "{83FEE492-6701-4E59-9184-16B1D30E91F8}" + ProjectSection(SolutionItems) = preProject + docsrc\content\caches.fsx = docsrc\content\caches.fsx + docsrc\content\corelib.fsx = docsrc\content\corelib.fsx + docsrc\content\devnotes.md = docsrc\content\devnotes.md + docsrc\content\editor.fsx = docsrc\content\editor.fsx + docsrc\content\filesystem.fsx = docsrc\content\filesystem.fsx + docsrc\content\fsharp-readme.md = docsrc\content\fsharp-readme.md + docsrc\content\index.md = docsrc\content\index.md + docsrc\content\interactive.fsx = docsrc\content\interactive.fsx + docsrc\content\project.fsx = docsrc\content\project.fsx + docsrc\content\queue.fsx = docsrc\content\queue.fsx + docsrc\content\symbols.fsx = docsrc\content\symbols.fsx + docsrc\content\tokenizer.fsx = docsrc\content\tokenizer.fsx + docsrc\content\typedtree.fsx = docsrc\content\typedtree.fsx + docsrc\content\untypedtree.fsx = docsrc\content\untypedtree.fsx + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{0554567F-1DCB-46A5-9EF2-E1938A3D4F14}" + ProjectSection(SolutionItems) = preProject + docsrc\tools\generate.fsx = docsrc\tools\generate.fsx + docsrc\tools\templates\template.cshtml = docsrc\tools\templates\template.cshtml + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E396742E-B4E5-4584-A9E4-CC1A491F5BC1}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "EditorService", "samples\EditorService\EditorService.fsproj", "{A40507D6-FA48-43D3-B18A-AE3DAACE4020}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "InteractiveService", "samples\InteractiveService\InteractiveService.fsproj", "{067E95E5-E3DC-4CA7-813A-4D1E277D2D52}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Tokenizer", "samples\Tokenizer\Tokenizer.fsproj", "{92793069-816F-4F69-84AC-0966F8275E65}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "UntypedTree", "samples\UntypedTree\UntypedTree.fsproj", "{C816728D-BBEA-472D-9F6C-E8913957A673}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FscExe", "samples\FscExe\FscExe.fsproj", "{C94C257C-3C0A-4858-B5D8-D746498D1F08}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp_Analysis", "..\tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj", "{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiExe", "samples\FsiExe\FsiExe.fsproj", "{F9540CA8-1CE0-4546-A23A-A461E416E95B}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCrackerTool", "FSharp.Compiler.Service.ProjectCrackerTool\FSharp.Compiler.Service.ProjectCrackerTool.fsproj", "{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker", "FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj", "{893C3CD9-5AF8-4027-A667-21E62FC2C703}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{098D1C35-D0FB-4720-83DD-8002293EA237}" + ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes + .gitignore = .gitignore + .travis.yml = .travis.yml + appveyor.yml = appveyor.yml + NuGet.Config = NuGet.Config + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "package", "package", "{9020E136-794A-473F-9B1B-9623C97B7161}" + ProjectSection(SolutionItems) = preProject + nuget\FSharp.Compiler.Service.template = nuget\FSharp.Compiler.Service.template + nuget\projectcracker.template = nuget\projectcracker.template + EndProjectSection +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.MSBuild.v12", "FSharp.Compiler.Service.MSBuild.v12\FSharp.Compiler.Service.MSBuild.v12.fsproj", "{8157B50E-397D-4232-A4E0-1977AFC7076D}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service", "FSharp.Compiler.Service\FSharp.Compiler.Service.fsproj", "{2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.Tests", "FSharp.Compiler.Service.Tests\FSharp.Compiler.Service.Tests.fsproj", "{EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A40507D6-FA48-43D3-B18A-AE3DAACE4020}.Release|Any CPU.Build.0 = Release|Any CPU + {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {067E95E5-E3DC-4CA7-813A-4D1E277D2D52}.Release|Any CPU.Build.0 = Release|Any CPU + {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92793069-816F-4F69-84AC-0966F8275E65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92793069-816F-4F69-84AC-0966F8275E65}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92793069-816F-4F69-84AC-0966F8275E65}.Release|Any CPU.Build.0 = Release|Any CPU + {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C816728D-BBEA-472D-9F6C-E8913957A673}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C816728D-BBEA-472D-9F6C-E8913957A673}.Release|Any CPU.Build.0 = Release|Any CPU + {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C94C257C-3C0A-4858-B5D8-D746498D1F08}.Release|Any CPU.Build.0 = Release|Any CPU + {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Any CPU.Build.0 = Release|Any CPU + {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9540CA8-1CE0-4546-A23A-A461E416E95B}.Release|Any CPU.Build.0 = Release|Any CPU + {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Any CPU.Build.0 = Release|Any CPU + {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.Build.0 = Debug|Any CPU + {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.ActiveCfg = Release|Any CPU + {893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.Build.0 = Release|Any CPU + {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8157B50E-397D-4232-A4E0-1977AFC7076D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8157B50E-397D-4232-A4E0-1977AFC7076D}.Release|Any CPU.Build.0 = Release|Any CPU + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3}.Release|Any CPU.Build.0 = Release|Any CPU + {EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE85AAB7-CDA0-4C4E-BDA0-A64DDDD13E3F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0554567F-1DCB-46A5-9EF2-E1938A3D4F14} = {83FEE492-6701-4E59-9184-16B1D30E91F8} + {A40507D6-FA48-43D3-B18A-AE3DAACE4020} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + {067E95E5-E3DC-4CA7-813A-4D1E277D2D52} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + {92793069-816F-4F69-84AC-0966F8275E65} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + {C816728D-BBEA-472D-9F6C-E8913957A673} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + {C94C257C-3C0A-4858-B5D8-D746498D1F08} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + {F9540CA8-1CE0-4546-A23A-A461E416E95B} = {E396742E-B4E5-4584-A9E4-CC1A491F5BC1} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9E9BAC7B-3834-497C-B7AC-6B7988778D1A} + EndGlobalSection +EndGlobal diff --git a/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj new file mode 100644 index 0000000000..915e1945a0 --- /dev/null +++ b/fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj @@ -0,0 +1,645 @@ + + + + + + $(MSBuildProjectDirectory)\..\..\src + + + + Debug + AnyCPU + $(MSBuildProjectDirectory)\..\..\ + Library + FSharp.Compiler.Service + $(NoWarn);44;62;9 + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + true + 0x06800000 + true + $(NoWarn);69;65;54;61;75 + true + ..\..\$(Configuration)\fcs\net45\ + $(OutputPath)$(AssemblyName).xml + + v4.5 + + $(DefineConstants);EXTENSIONTYPING + $(DefineConstants);CROSS_PLATFORM_COMPILER + $(DefineConstants);ENABLE_MONO_SUPPORT + $(DefineConstants);COMPILER + $(DefineConstants);COMPILER_SERVICE_AS_DLL + $(DefineConstants);COMPILER_PUBLIC_API + $(DefineConstants);NO_STRONG_NAMES + $(OtherFlags) /warnon:1182 + $(OtherFlags) --times + $(OtherFlags) --version:$(VersionPrefix).0 + false + true + + + + true + full + false + AnyCPU + + + pdbonly + true + AnyCPU + + + + AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.dll.fs + + + FSComp.txt + + + FSIstrings.txt + + + FSStrings.resx + + + --module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser --open Microsoft.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 + pars.fsy + + + Reshaped/reshapedreflection.fs + + + ErrorText/sformat.fsi + + + ErrorText/sformat.fs + + + ErrorText/sr.fsi + + + ErrorText/sr.fs + + + LexYaccRuntime/prim-lexing.fsi + + + LexYaccRuntime/prim-lexing.fs + + + LexYaccRuntime/prim-parsing.fsi + + + LexYaccRuntime/prim-parsing.fs + + + Utilities\ResizeArray.fsi + + + Utilities\ResizeArray.fs + + + Utilities/HashMultiMap.fsi + + + Utilities/HashMultiMap.fs + + + Utilities\EditDistance.fs + + + Utilities/TaggedCollections.fsi + + + Utilities/TaggedCollections.fs + + + Utilities/QueueList.fs + + + Utilities/ildiag.fsi + + + Utilities/ildiag.fs + + + Utilities/illib.fs + + + Utilities/filename.fsi + + + Utilities/filename.fs + + + Utilities/zmap.fsi + + + Utilities/zmap.fs + + + Utilities/zset.fsi + + + Utilities/zset.fs + + + Utilities/bytes.fsi + + + Utilities/bytes.fs + + + Utilities/lib.fs + + + Utilities/InternalCollections.fsi + + + Utilities/InternalCollections.fs + + + Utilities/rational.fsi + + + Utilities/rational.fs + + + ErrorLogging/range.fsi + + + ErrorLogging/range.fs + + + ErrorLogging/ErrorLogger.fs + + + ErrorLogging/ErrorResolutionHints.fs + + + ReferenceResolution/ReferenceResolver.fs + + + --unicode --lexlib Internal.Utilities.Text.Lexing + AbsIL/illex.fsl + + + AbsIL/il.fsi + + + AbsIL/il.fs + + + AbsIL/ilx.fsi + + + AbsIL/ilx.fs + + + AbsIL/ilascii.fsi + + + AbsIL/ilascii.fs + + + AbsIL/ilprint.fsi + + + AbsIL/ilprint.fs + + + AbsIL/ilmorph.fsi + + + AbsIL/ilmorph.fs + + + AbsIL/ilsupp.fsi + + + AbsIL/ilsupp.fs + + + AbsIL/ilpars.fs + + + AbsIL/illex.fs + + + AbsIL/ilbinary.fsi + + + AbsIL/ilbinary.fs + + + AbsIL/ilread.fsi + + + AbsIL/ilread.fs + + + AbsIL/ilwritepdb.fsi + + + AbsIL/ilwritepdb.fs + + + AbsIL/ilwrite.fsi + + + AbsIL/ilwrite.fs + + + AbsIL/ilreflect.fs + + + CompilerLocation/CompilerLocationUtils.fs + + + PrettyNaming/PrettyNaming.fs + + + ILXErase/ilxsettings.fs + + + ILXErase/EraseClosures.fsi + + + ILXErase/EraseClosures.fs + + + ILXErase/EraseUnions.fsi + + + ILXErase/EraseUnions.fs + + + --unicode --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/lex.fsl + + + --unicode --lexlib Internal.Utilities.Text.Lexing + ParserAndUntypedAST/pplex.fsl + + + --module Microsoft.FSharp.Compiler.PPParser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing + ParserAndUntypedAST/pppars.fsy + + + ParserAndUntypedAST/UnicodeLexing.fsi + + + ParserAndUntypedAST/UnicodeLexing.fs + + + ParserAndUntypedAST/layout.fsi + + + ParserAndUntypedAST/layout.fs + + + ParserAndUntypedAST/ast.fs + + + ParserAndUntypedAST/pppars.fs + + + ParserAndUntypedAST/pars.fs + + + ParserAndUntypedAST/lexhelp.fsi + + + ParserAndUntypedAST/lexhelp.fs + + + ParserAndUntypedAST/pplex.fs + + + ParserAndUntypedAST/lex.fs + + + ParserAndUntypedAST/LexFilter.fs + + + TypedAST/tainted.fsi + + + TypedAST/tainted.fs + + + TypedAST/ExtensionTyping.fsi + + + TypedAST/ExtensionTyping.fs + + + TypedAST/QuotationPickler.fsi + + + TypedAST/QuotationPickler.fs + + + TypedAST/tast.fs + + + TypedAST/TcGlobals.fs + + + TypedAST/TastOps.fsi + + + TypedAST/TastOps.fs + + + TypedAST/TastPickle.fsi + + + TypedAST/TastPickle.fs + + + Logic/import.fsi + + + Logic/import.fs + + + Logic/infos.fs + + + Logic/AccessibilityLogic.fs + + + Logic/AttributeChecking.fs + + + Logic/InfoReader.fs + + + Logic/NicePrint.fs + + + Logic/AugmentWithHashCompare.fsi + + + Logic/AugmentWithHashCompare.fs + + + Logic/NameResolution.fsi + + + Logic/NameResolution.fs + + + Logic/TypeRelations.fs + + + Logic/SignatureConformance.fs + + + Logic/MethodOverrides.fs + + + Logic/MethodCalls.fs + + + Logic/PatternMatchCompilation.fsi + + + Logic/PatternMatchCompilation.fs + + + Logic/ConstraintSolver.fsi + + + Logic/ConstraintSolver.fs + + + Logic/CheckFormatStrings.fsi + + + Logic/CheckFormatStrings.fs + + + Logic/FindUnsolved.fs + + + Logic/QuotationTranslator.fsi + + + Logic/QuotationTranslator.fs + + + Logic/PostInferenceChecks.fsi + + + Logic/PostInferenceChecks.fs + + + Logic/TypeChecker.fsi + + + Logic/TypeChecker.fs + + + Optimize/Optimizer.fsi + + + Optimize/Optimizer.fs + + + Optimize/DetupleArgs.fsi + + + Optimize/DetupleArgs.fs + + + Optimize/InnerLambdasToTopLevelFuncs.fsi + + + Optimize/InnerLambdasToTopLevelFuncs.fs + + + Optimize/LowerCallsAndSeqs.fs + + + Optimize\autobox.fs + + + CodeGen/IlxGen.fsi + + + CodeGen/IlxGen.fs + + + Driver/CompileOps.fsi + + + Driver/CompileOps.fs + + + Driver/CompileOptions.fsi + + + Driver/CompileOptions.fs + + + Driver/fsc.fsi + + + Driver/fsc.fs + + + Symbols/SymbolHelpers.fsi + + + Symbols/SymbolHelpers.fs + + + Symbols/Symbols.fsi + + + Symbols/Symbols.fs + + + Symbols/Exprs.fsi + + + Symbols/Exprs.fs + + + Service/IncrementalBuild.fsi + + + Service/IncrementalBuild.fs + + + Service/Reactor.fsi + + + Service/Reactor.fs + + + Service/ServiceConstants.fs + + + Service/ServiceLexing.fsi + + + Service/ServiceLexing.fs + + + Service/ServiceParseTreeWalk.fs + + + Service/ServiceNavigation.fsi + + + Service/ServiceNavigation.fs + + + Service/ServiceParamInfoLocations.fsi + + + Service/ServiceParamInfoLocations.fs + + + Service/ServiceUntypedParse.fsi + + + Service/ServiceUntypedParse.fs + + + Service/reshapedmsbuild.fs + + + Service/SimulatedMSBuildReferenceResolver.fs + + + Service/ServiceDeclarationLists.fsi + + + Service/ServiceDeclarationLists.fs + + + Service/ServiceAssemblyContent.fsi + + + Service/ServiceAssemblyContent.fs + + + Service/ServiceXmlDocParser.fsi + + + Service/ServiceXmlDocParser.fs + + + Service/ExternalSymbol.fsi + + + Service/ExternalSymbol.fs + + + Service/service.fsi + + + Service/service.fs + + + Service/ServiceInterfaceStubGenerator.fsi + + + Service/ServiceInterfaceStubGenerator.fs + + + Service/ServiceStructure.fsi + + + Service/ServiceStructure.fs + + + Service/fsi.fsi + + + Service/fsi.fs + + + + + + + + + + + $(FSharpSourcesRoot)\..\packages\Microsoft.DiaSymReader.PortablePdb.1.1.0\lib\portable-net45+win8\Microsoft.DiaSymReader.PortablePdb.dll + + + $(FSharpSourcesRoot)\..\packages\Microsoft.DiaSymReader.1.1.0\lib\portable-net45+win8\Microsoft.DiaSymReader.dll + + + $(FSharpSourcesRoot)\..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll + + + $(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll + + + $(FSharpSourcesRoot)\..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + + + + + $(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + false + + + + + + + \ No newline at end of file diff --git a/fcs/README.md b/fcs/README.md new file mode 100644 index 0000000000..cb2d32dbf8 --- /dev/null +++ b/fcs/README.md @@ -0,0 +1,105 @@ + + +# The FSharp.Compiler.Service components and nuget package + +This directory contains the build, packaging, test and documentation-generation logic for the nuget package ``FSharp.Compiler.Service``. The source for this nuget +package is in ``..\src``. + +Basically we are packaging up the compiler as a DLL and publishing it as a nuget package. + +## FSharp.Compiler.Service v. FSharp.Compiler.Private + +There are subtle differences between FSharp.Compiler.Service and FSharp.Compiler.Private (shipped with the Visual F# Tools) + +- FCS has a public API +- FCS is built against **.NET 4.5** and **FSharp.Core 4.0.0.0** to give broader reach +- FCS has a Nuget package +- FCS has a .NET Standard 1.6 version in the nuget package +- FCS testing also tests the "Project Cracker" (see below) +- FCS doesn't add the System.ValueTuple.dll reference by default, see ``#if COMPILER_SERVICE_AS_DLL`` in compiler codebase + + +## Version Numbers + +FCS uses its own version number sequence for assemblies and packages, approximately following SemVer rules. +To update the version number a global replace through fcs\... is currently needed, e.g. + + fcs.props + nuget/FSharp.Compiler.Service.nuspec + nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec + nuget/FSharp.Compiler.Service.ProjectCracker.nuspec + RELEASE_NOTES.md + +## Building, Testing, Packaging, Releases + +To build the package use any of: + + fcs\build Build.NetFx + fcs\build Test.NetFx + fcs\build NuGet.NetFx + + fcs\build Build.NetStd + fcs\build Test.NetStd + fcs\build NuGet.NetStd + + fcs\build Build + fcs\build Test + fcs\build NuGet + fcs\build Release + +which does things like: + + cd fcs + .paket\paket.bootstrapper.exe + .paket\paket.exe restore + dotnet restore tools.proj + packages\FAKE\tools\FAKE.exe build.fsx WhateverTarget + +### Manual push of packages + +Yu can push the packages if you have permissions, either automatically using ``build Release`` or manually + + set APIKEY=... + .nuget\nuget.exe push Release\FSharp.Compiler.Service.14.0.2.nupkg %APIKEY% -Source https://nuget.org + .nuget\nuget.exe push Release\FSharp.Compiler.Service.MSBuild.v12.14.0.2.nupkg %APIKEY% -Source https://nuget.org + .nuget\nuget.exe push Release\FSharp.Compiler.Service.ProjectCracker.14.0.2.nupkg %APIKEY% -Source https://nuget.org + + +### Use of Paket and FAKE + +Paket is only used to get fake and formating tools. Eventually we will likely remove this once we update the project files to .NET SDK 2.0. + +FAKE is only used to run build.fsx. Eventually we will likely remove this once we update the project files to .NET SDK 2.0. + +### Testing + +Testing reuses the test files from ..\tests\service which were are also FCS tests. + + +### Documentation Generation + + fcs\build GenerateDocs + +Output is in ``docs``. In the ``FSharp.Compiler.Service`` repo this is checked in and hosted as http://fsharp.github.io/FSharp.Compiler.Service. + + +## The two other nuget packages + +It also contains both the source, build, packaging and test logic for + +* ``FSharp.Compiler.Service.MSBuild.v12`` adds legacy MSBuild v12 support to an instance of FSharp.Compiler.Service, if exact compatibility for scripting references such as ``#r "Foo, Version=1.3.4"`` is required. + +* ``FSharp.Compiler.Service.ProjectCracker`` is part of ``FsAutoComplete`` and Ionide and is used to crack old-style project formats using MSBuild. It used to be part of the FCS API. + +Both of these components are gradually becoming obsolete + +## Engineering road map + +FSharp.Compiler.Service is a somewhat awkward component. There are some things we can do to simplify things: + +1. Remove the use of Paket and FAKE +1. Move all projects under fcs\... to new .NET SDK project file format +1. Drop the use of ``dotnet mergenupkg`` since we should be able to use cross targeting +1. Make FCS a DLL similar ot the rest of the build and make this an official component from Microsoft (signed etc.) +1. Replace FSharp.Compiler.Private by FSharp.Compiler.Service + diff --git a/fcs/RELEASE_NOTES.md b/fcs/RELEASE_NOTES.md new file mode 100644 index 0000000000..18f26ff87e --- /dev/null +++ b/fcs/RELEASE_NOTES.md @@ -0,0 +1,587 @@ +#### 14.0.2 + * Fix non-public API in .NET Standard 1.6 version + +#### 14.0.1 + * Integrate latest changes from visualfsharp + * Trial release for new build in fcs\... + +#### 13.0.1 + * Move docs --> docssrc + +#### 13.0.0 + * Move FSharp.Compiler.Service.MSBuild.v12.dll to a separate nuget package + +#### 12.0.8 + * Set bit on output executables correctly + +#### 12.0.7 + * Integrate visualfsharp master + +#### 12.0.6 + * [758: Fix project cracker when invalid path given](https://github.com/fsharp/FSharp.Compiler.Service/pull/758) + +#### 12.0.5 + * Remove dependency on System.ValueTuple + +#### 12.0.3 + * [De-duplicate module names again](https://github.com/fsharp/FSharp.Compiler.Service/pull/749) + +#### 12.0.2 + * De-duplicate module names + +#### 12.0.1 + * [Integrate visualfsharp and fsharp](https://github.com/fsharp/fsharp/pull/696) + +#### 11.0.10 + * [Fix F# Interactive on Mono 4.0.9+](https://github.com/fsharp/fsharp/pull/696) + +#### 11.0.9 + * [Make incremental builder counter atomic](https://github.com/fsharp/FSharp.Compiler.Service/pull/724) + * [Add IsValCompiledAsMethod to FSharpMemberOrFunctionOrValue](https://github.com/fsharp/FSharp.Compiler.Service/pull/727) + * [Check before ILTypeInfo.FromType](https://github.com/fsharp/FSharp.Compiler.Service/issues/734) + * [Transition over to dotnet cli Fsproj](https://github.com/fsharp/FSharp.Compiler.Service/issues/700) + +#### 11.0.8 + * Depend on FSharp.Core package + +#### 11.0.6 + * Fix [stack overflow exception](https://github.com/fsharp/FSharp.Compiler.Service/issues/672) + +#### 11.0.4 + * Fix [out of range exception](https://github.com/fsharp/FSharp.Compiler.Service/issues/709) + +#### 11.0.2 + * Integrate fsharp\fsharp and Microsoft\visualfsharp to 262deb017cfcd0f0d4138779ff42ede7dbf44c46 + +#### 11.0.1 + * Integrate fsharp\fsharp and Microsoft\visualfsharp to d0cc249b951374257d5a806939e42714d8a2f4c6 + +#### 10.0.3 + * [Expose assumeDotNetFramework in FSharpChecker.GetProjectOptionsFromScript](https://github.com/fsharp/FSharp.Compiler.Service/pull/699) + * [SemanticClassificationType should not be internal](https://github.com/fsharp/FSharp.Compiler.Service/pull/696) + +#### 10.0.1 + * [Adds FormatValue to FsiEvaluationSession, using the fsi object values for formatting](https://github.com/fsharp/FSharp.Compiler.Service/pull/686) + +#### 10.0.0 + * Integrate fsharp\fsharp and Microsoft\visualfsharp to c3e55bf0b10bf08790235dc585b8cdc75f71618e + * Integrate fsharp\fsharp and Microsoft\visualfsharp to 11c0a085c96a91102cc881145ce281271ac159fe + * Some API changes for structured text provision for tagged structured text + +#### 9.0.0 + * Update names of union fields in AST API + * Fix load closure for ParseAndCheckInteraction + * [Fix #631 compiler dependency on MSBuild](https://github.com/fsharp/FSharp.Compiler.Service/pull/657) + * Fixed netcore codegen on Linux + * Explicit error when cracker exe is missing + +#### 8.0.0 + * Integrate fsharp\fsharp and Microsoft\visualfsharp to c494a9cab525dbd89585f7b733ea5310471a8001 + * Then integrate to 2002675f8aba5b3576a924a2e1e47b18e4e9a83d + * [Add module values to navigable items](https://github.com/fsharp/FSharp.Compiler.Service/pull/650) + * Optionally remove dependency on MSBuild reference resolution https://github.com/fsharp/FSharp.Compiler.Service/pull/649 + * [Compiler api harmonise](https://github.com/fsharp/FSharp.Compiler.Service/pull/639) + * Various bits of work on .NET Core version (buildable from source but not in nuget package) + +#### 7.0.0 + * Integrate fsharp\fsharp and Microsoft\visualfsharp to 835b79c041f9032fceeceb39f680e0662cba92ec + +#### 6.0.2 + * [Fix #568: recognize provided expressions](https://github.com/fsharp/FSharp.Compiler.Service/pull/568) + +#### 6.0.1 + * [Fix ProjectFileNames order when getting project options from script](https://github.com/fsharp/FSharp.Compiler.Service/pull/594) + +#### 6.0.0 + * Switch to new major version on assumption integrated F# compiler changes induce API change + +#### 5.0.2 + * Integrate Microsoft\visualfsharp to 688c26bdbbfc766326fc45e4d918f87fcba1e7ba. F# 4.1 work + +#### 5.0.1 +* [Fixed dependencies in nuget package](https://github.com/fsharp/FSharp.Compiler.Service/pull/608) + +#### 5.0.0 +* Fixed empty symbol declared pdb #564 from kekyo/fix-empty-pdb +* .NET Core ProjectCracker - updated version and dependencies +* Properly embed 'FSIstrings' resource, fixes #591 +* make build.sh work on windows (git bash). +* Added default script references for .NET Core +* Store useMonoResolution flag +* Updated MSBuild version +* Assume FSharp.Core 4.4.0.0 + +#### 4.0.1 +* Integrate Microsoft\visualfsharp and fsharp\fsharp to master (including portable PDB) +* Remove .NET Framework 4.0 support (now needs .NET Framework 4.5) + +#### 4.0.0 +* Integrate Microsoft\visualfsharp and fsharp\fsharp to master + +#### 3.0.0.0 +* #538 - BackgroundCompiler takes a very long time on a big solution with a very connected project dependency graph +* #544 - Losing operator call when one of operands is application of a partially applied function +* #534 - Function valued property erasing calls +* #495 - Detupling missing when calling a module function value +* #543 - Tuple not being destructured in AST +* #541 - Results of multiple calls to active pattern are always bound to variable with same name +* #539 - BasicPatterns.NewDelegate shows same value for different arguments + +#### 2.0.0.6 +* #530 - Adjust ProjectCracker NuGet for VS/NuGet + +#### 2.0.0.5 +* #527 - Provide API that includes printf specifier arities along with ranges + +#### 2.0.0.4 +* #519 - Change nuget layout for ProjectCracker package +* #523 - Project cracking: spaces in file paths + +#### 2.0.0.3 +* #508 - Integrate visualfsharp/master removal of Silverlight #if +* #513 - Make CrackerTool `internal` to prevent accidental usage +* #515 - Add simple Visual Studio version detection for project cracker + +#### 2.0.0.2 +* Integrate visualfsharp/master and fsharp/master --> master +* Expose QualifiedName and FileName of FSharpImplementationFileContents +* Add FSharpErrorInfo.ErrorNumber + +#### 2.0.0.1-beta +* Fix 452 - FSharpField.IsMutable = true for BCL enum cases +* Fix 414 - Add IsInstanceMemberInCompiledCode + +#### 2.0.0.0-beta +* Feature #470, #478, #479 - Move ProjectCracker to separate nuget package and DLL, used ProjectCrackerTool.exe to run +* Feature #463 - Expose slot signatures of members in object expressions +* Feature #469, #475 - Add EvalExpressionNonThrowing, EvalInteractionNonThrowing, EvalScriptNonThrowing +* Fix #456 - FCS makes calls to kernel32.dll when running on OSX +* Fix #473 - stack overflow in resolution logic +* Fix #460 - Failure getting expression for a provided method call + +#### 1.4.2.3 - +* Fix bug in loop optimization, apply https://github.com/Microsoft/visualfsharp/pull/756/ + +#### 1.4.2.2 - +* #488 - Performance problems with project references + +#### 1.4.2.1 - +* #450 - Correct generation of ReferencedProjects + +#### 1.4.2.0 - +* Fix bug in double lookup of cache, see https://github.com/fsharp/FSharp.Compiler.Service/pull/447 + +#### 1.4.1 - +* Add pause before backgrounnd work starts. The FCS request queue must be empty for 1 second before work will start +* Write trace information about the reactor queue to the event log +* Rewrite reactor to consistently prioritize queued work +* Implement cancellation for queued work if it is cancelled prior to being executed +* Adjust caching to check cache correctly if there is a gap before the request is executed + +#### 1.4.0.9 - +* FSharpType.Format fix +* Disable maximum-memory trigger by default until use case ironed out + +#### 1.4.0.8 - +* FSharpType.Format now prettifies type variables. If necessary, FSharpType.Prettify can also be called +* Add maximum-memory trigger to downsize FCS caches. Defaults to 1.7GB of allocaed memory in the system + process for a 32-bit process, and 2x this for a 64-bit process + +#### 1.4.0.7 - +* fix 427 - Make event information available for properties which represent first-class uses of F#-declared events +* fix 410 - Symbols for C# fields (and especially enum fields) +* Expose implemented abstract slots +* Fix problem with obscure filenames caught by Microsoft\visualfsharp tests +* Integrate with visualfsharp master + +#### 1.4.0.6 - +* fix 423 - Symbols for non-standard C# events +* fix 235 - XmlDocSigs for references assemblies +* fix 177 - GetAllUsesOfAllSymbolsInFile returns nothing for C# nested enum +* make Internal.Utilities.Text.Lexing.Position a struct +* Exposing assembly attributes on FSharpAssemblySignature +* clean up IncrementalFSharpBuild.frameworkTcImportsCache + +#### 1.4.0.5 - +* add more entries to FSharpTokenTag + +#### 1.4.0.4 - +* add more entries to FSharpTokenTag +* add PrettyNaming.QuoteIdentifierIfNeeded and PrettyNaming.KeywordNames + +#### 1.4.0.3 - +* integrate Microsoft/visualfsharp OOB cleanup via fsharp/fsharp +* Make Parser and Lexer private + +#### 1.4.0.2 - +* #387 - types and arrays in F# attribute contructor arguments + +#### 1.4.0.1 - F# 4.0 support +* Use FSharp.Core 4.4.0.0 by default for scripting scenarios if not FSharp.Core referenced by host process + +#### 1.4.0.0-beta - F# 4.0 support +* Integrate F# 4.0 support into FSharp.Compiler.Service + +#### 1.3.1.0 - +* simplified source indexing with new SourceLink +* Add noframework option in AST compiler methods + +#### 0.0.90 - +* Add fix for #343 Use ResolveReferences task +* Expose BinFolderOfDefaultFSharpCompiler to editors +* Fix the registry checking on mono to avoid unnecessary exceptions being thrown + +#### 0.0.89 - +* Fix output location of referenced projects + +#### 0.0.88 - +* Added Fix to allow implicit PCL references to be retrieved + +#### 0.0.87 - +* Don't report fake symbols in indexing #325 +* Add EnclosingEntity for an active pattern group #327 +* Add ImmediateSubExpressions #284 +* integrate fsharp/fsharp master into master + +#### 0.0.85 - +* Fix for FSharpSymbolUse for single case union type #301 +* Added supprt for ReturnParameter in nested functions + +#### 0.0.84 - +* Added curried parameter groups for nested functions + +#### 0.0.83 - +* Add Overloads to the symbols signature so it is publicly visible +* Update OnEvaluation event to have FSharpSymbolUse information available + +#### 0.0.82 - +* Better support for Metadata of C# (and other) Assemblies. +* Expose the DefaultFileSystem as a type instead of anonymous + +#### 0.0.81 - +* Update GetDeclarationListSymbols to expose FSharpSymbolUse +* Improve reporting of format specifiers + +#### 0.0.80 - +* Update to latest F# 3.1.3 (inclunding updated FsLex/FsYacc used in build of FCS) +* Report printf specifiers from Service API +* Improve Accessibility of non-F# symbols + +#### 0.0.79 - +* Do not use memory mapped files when cracking a DLL to get an assembly reference +* Fix for multilanguage projects in project cracker + +#### 0.0.78 - +* Reduce background checker memory usage +* add docs on FSharp.Core +* docs on caches and queues + +#### 0.0.77 - +* Update to github.com/fsharp/fsharp 05f426cee85609f2fe51b71473b07d7928bb01c8 + +#### 0.0.76 - +* Fix #249 - Fix TryFullName when used on namespaces of provided erased type definitions +* Add OnEvaluation event to FCS to allow detailed information to be exposed + +#### 0.0.75 - +* Do not use shared cursor for IL binaries (https://github.com/fsprojects/VisualFSharpPowerTools/issues/822) + +#### 0.0.74 - +* Extension members are returned as members of current modules +* Fix exceptions while cross-reference a type provider project + +#### 0.0.73 - +* Add AssemblyContents and FSharpExpr to allow access to resolved, checked expression trees +* Populate ReferencedProjects using ProjectFileInfo +* Fix finding symbols declared in signature files +* Add logging to project cracking facility + +#### 0.0.72 - +* Allow project parser to be used on project file with relative paths +* Expose attributes for non-F# symbols + +#### 0.0.71 - +* More renamings in SourceCodeServices API for more consistent use of 'FSharp' prefix + +#### 0.0.70 - +* Make FSharpProjectFileParser public +* Fixes to project parser for Mono (.NET 4.0 component) +* Renamings in SourceCodeServices API for more consistent use of 'FSharp' prefix + +#### 0.0.67 - +* Fixes to project parser for Mono + +#### 0.0.66 - +* Fixes to project parser for Mono +* Use MSBuild v12.0 for reference resolution on .NET 4.5+ + +#### 0.0.65 - +* Fixes to project parser + +#### 0.0.64 - +* Add project parser, particularly GetProjectOptionsFromProjectFile + +#### 0.0.63 - +* #221 - Normalize return types of .NET events + +#### 0.0.62 - +* Integrate to latest http://github.com/fsharp/fsharp (#80f9221f811217bd890b3a670d717ebc510aeeaf) + +#### 0.0.61 - +* #216 - Return associated getters/setters from F# properties +* #214 - Added missing XmlDocSig for FSharpMemberOrFunctionOrValue's Events, Methods and Properties +* #213 - Retrieve information for all active pattern cases +* #188 - Fix leak in file handles when using multiple instances of FsiEvaluationSession, and add optionally collectible assemblies + +#### 0.0.60 - +* #207 - Add IsLiteral/LiteralValue to FSharpField +* #205 - Add IsOptionalArg and related properties to FSharpParameter +* #210 - Check default/override members via 'IsOverrideOrExplicitMember' +* #209 - Add TryFullName to FSharpEntity + +#### 0.0.59 - +* Fix for #184 - Fix EvalScript by using verbatim string for #Load +* Fix for #183 - The line no. reporting is still using 0-based indexes in errors. This is confusing. + +#### 0.0.58 - +* Fix for #156 - The FSharp.Core should be retrieved from the hosting environment + +#### 0.0.57 - +* Second fix for #160 - Nuget package now contains .NET 4.0 and 4.5 + +#### 0.0.56 - +* Fix for #160 - Nuget package contains .NET 4.0 and 4.5 + +#### 0.0.55 - +* Integrate changes for F# 3.1.x, Fix #166 + +#### 0.0.54 - +* Fix for #159 - Unsubscribe from TP Invalidate events when disposing builders + +#### 0.0.53 - +* Add queue length to InteractiveChecker + +#### 0.0.52 - +* Fix caches keeping hold of stale entries + +#### 0.0.51 - +* Add IsAccessible to FSharpSymbol, and ProjectContext.AccessibilityRights to give the context of an access + +#### 0.0.50 - +* Fix #79 - FindUsesOfSymbol returns None at definition of properties with explicit getters and setters + +#### 0.0.49 - +* Fix #138 - Fix symbol equality for provided type members +* Fix #150 - Return IsGetterMethod = true for declarations of F# properties (no separate 'property' symbol is yet returned, see #79) +* Fix #132 - Add IsStaticInstantiation on FSharpEntity to allow clients to detect fake symbols arising from application of static parameters +* Fix #154 - Add IsArrayType on FSharpEntity to allow clients to detect the symbols for array types +* Fix #96 - Return resolutions of 'Module' and 'Type' in "Module.field" and "Type.field" + +#### 0.0.48 - +* Allow own fsi object without referencing FSharp.Compiler.Interactive.Settings.dll (#127) + +#### 0.0.47 - +* Adjust fix for #143 for F# types with abstract+default events + +#### 0.0.46 - +* Fix multi-project analysis when referenced projects have changed (#141) +* Fix process exit on bad arguments to FsiEvaluationSession (#126) +* Deprecate FsiEvaluationSession constructor and add FsiEvaluationSession.Create static method to allow for future API that can return errors +* Return additional 'property' and 'event' methods for F#-defined types to regularize symbols (#108, #143) +* Add IsPropertySetterMethod and IsPropertyGetterMethod which only return true for getter/setter methods, not properties. Deprecate IsSetterMethod and IsGetterMethod in favour of these. +* Add IsEventAddMethod and IsEventRemoveMethod which return true for add/remove methods with an associated event +* Change IsProperty and IsEvent to only return true for the symbols for properties and events, rather than the methods assocaited with these +* Fix value of Assembly for some symbols (e.g. property symbols) + +#### 0.0.45 - +* Add optional project cache size parameter to InteractiveChecker +* Switch to openBinariesInMemory for SimpleSourceCodeServices +* Cleanup SimpleSourceCodeServices to avoid code duplication + +#### 0.0.44 - +* Integrate latest changes from visualfsharp.codeplex.com via github.com/fsharp/fsharp +* Fix problem with task that generates description text of declaration +* Add AllInterfaceTypes to FSharpEntity and FSharpType +* Add BaseType to FSharpType to propagate instantiation +* Add Instantiate to FSharpType + +#### 0.0.43 - +* Fix #109 - Duplicates in GetUsesOfSymbolInFile + +#### 0.0.42 - +* Fix #105 - Register enum symbols in patterns +* Fix #107 - Return correct results for inheritance chain of .NET types +* Fix #101 - Add DeclaringEntity property + +#### 0.0.41 - +* Fixed #104 - Make all operations that may utilize the FCS reactor async +* Add FSharpDisplayContext and FSharpType.Format +* Replace GetSymbolAtLocationAlternate by GetSymbolUseAtLocation + +#### 0.0.40 - +* Fixed #86 - Expose Microsoft.FSharp.Compiler.Interactive.Shell.Settings.fsi +* Fixed #99 - Add IsNamespace property to FSharpEntity + +#### 0.0.39 - +* Fixed #79 - Usage points for symbols in union patterns + +#### 0.0.38 - +* Fixed #94 and #89 by addition of new properties to the FSharpSymbolUse type +* Fixed #93 by addition of IsOpaque to FSharpEntity type +* Fixed #92 - Issue with nested classes +* Fixed #87 - Allow analysis of members from external assemblies + +#### 0.0.37 - +* Obsolete HasDefaultValue - see https://github.com/fsharp/FSharp.Compiler.Service/issues/77 + +#### 0.0.36 - +* Fix #71 - Expose static parameters and xml docs of type providers +* Fix #63 - SourceCodeServices: #r ignores include paths passed as command-line flags + +#### 0.0.35 - +* Fix #38 - FSharp.Compiler.Services should tolerate an FSharp.Core without siginfo/optdata in the search path + + +#### 0.0.34 - +* Add StaticParameters property to entities, plus FSharpStaticParameter symbol +* Fix #65 + +#### 0.0.33 - +* Add FullName and Assembly properties for symbols +* Fix #76 +* Add Japanese documentation + +#### 0.0.32 - +* Make ParseFileInProject asynchronous +* Add ParseAndCheckFileInProject +* Use cached results in ParseAndCheckFileInProject if available + +#### 0.0.31 - +* Fix performance problem with CheckFileInProject + +#### 0.0.30 - +* Add initial prototype version of multi-project support, through optional ProjectReferences in ProjectOptions. Leave this empty + to use DLL/file-based references to results from other projects. + +#### 0.0.29 - +* Fix symbols for named union fields in patterns + +#### 0.0.28 - +* Fix symbols for named union fields +* Add FSharpActivePatternCase to refine FSharpSymbol + +#### 0.0.27 - +* Fix exception tag symbol reporting + +#### 0.0.26 - +* Fix off-by-one in reporting of range for active pattern name + +#### 0.0.25 - +* Add optional source argument to TryGetRecentTypeCheckResultsForFile to specify that source must match exactly + +#### 0.0.24 - +* Update version number as nuget package may not have published properly + +#### 0.0.23 - +* Move to one-based line numbering everywhere +* Provide better symbol information for active patterns + +#### 0.0.22 - +* Provide symbol location for type parameters + +#### 0.0.21 - +* Add GetUsesOfSymbolInFile +* Better symbol resolution results for type parameter symbols + +#### 0.0.20 - +* Update version number as nuget package may not have published properly + +#### 0.0.19 - +* Change return type of GetAllUsesOfSymbol, GetAllUsesOfAllSymbols and GetAllUsesOfAllSymbolsInFile to FSharpSymbolUse +* Add symbol uses when an abstract member is implemented. + +#### 0.0.18 - +* Add GetAllUsesOfAllSymbols and GetAllUsesOfAllSymbolsInFile + +#### 0.0.17 - +* Improvements to symbol accuracy w.r.t. type abbreviations + +#### 0.0.16 - +* Make FSharpEntity.BaseType return an option +* FsiSesion got a new "EvalScript" method which allows to evaluate .fsx files + +#### 0.0.15 - +* Update version number as nuget package may not have published properly + +#### 0.0.14 - +* Update version number as nuget package may not have published properly + +#### 0.0.13-alpha - +* Fix #39 - Constructor parameters are mistaken for record fields in classes + +#### 0.0.12-alpha - +* Make the parts of the lexer/parser used by 'XmlDoc' tools in F# VS Power tools public + +#### 0.0.11-alpha - +* Add 'IsUnresolved' + +#### 0.0.10-alpha - +* Fix bug where 'multiple references to FSharp.Core' was given as error for scripts + +#### 0.0.9-alpha - +* Fix fsc corrupting assemblies when generating pdb files (really) +* Give better error messages for missing assemblies +* Report more information about symbols returned by GetSymbolAtLocation (through subtypes) +* Fix typos in docs +* Return full project results from ParseAndCheckInteraction +* Be more robust to missing assembly references by default. + +#### 0.0.8-alpha - +* Fix fsc corrupting assemblies when generating pdb files + +#### 0.0.7-alpha - +* Fix docs +* Make symbols more robust to missing assemblies +* Be robust to failures on IncrementalBuilder creation +* Allow use of MSBuild resolution by IncrementalBuilder + +#### 0.0.6-alpha - +* Fix version number + +#### 0.0.5-alpha - +* Added GetUsesOfSymbol(), FSharpSymbol type, GetSymbolAtLocation(...) + +#### 0.0.4-alpha - +* Added documentation of file system API +* Reporte errors correctly from ParseAndCheckProject + + +#### 0.0.3-alpha - +* Integrate FSharp.PowerPack.Metadata as the FSharp* symbol API +* Renamed Param --> MethodGroupItemParameter and hid record from view, made into an object +* Renamed Method --> MethodGroupItem and hid record from view, made into an object +* Renamed Methods --> MethodGroup and hid record from view, made into an object +* Renamed MethodGroup.Name --> MethodGroup.MethodName +* Renamed DataTip --> ToolTip consistently across all text +* Renamed CheckOptions --> ProjectOptions +* Renamed TypeCheckAnswer --> CheckFileAnswer +* Renamed UntypedParseInfo --> ParseFileResults +* Removed GetCheckOptionsFromScriptRoot member overload in favour of optional argument +* Renamed GetCheckOptionsFromScriptRoot --> GetProjectOptionsFromScript +* Renamed UntypedParse --> ParseFileInProject +* Renamed TypeCheckSource --> CheckFileInProjectIfReady +* Added numerous methods to API including CheckFileInProject +* Added experimental GetBackgroundCheckResultsForFileInProject, GetBackgroundParseResultsForFileInProject +* Added PartialAssemblySignature to TypeCheckResults/CheckFileResults +* Added CurrentPartialAssemblySignature to FsiEvaluationSession +* Added ParseAndCheckInteraction to FsiEvaluationSession to support intellisense implementation against a script fragment +* Added initial testing in tests/service +* Added ParseAndCheckProject to SourceCodeServices API. This will eventually return "whole project" information such as symbol tables. +* Added GetDefaultConfiguration to simplify process of configuring FsiEvaluationSession +* Added PartialAssemblySignatureUpdated event to FsiEvaluationSession +* Added travis build + +#### 0.0.2-alpha - +* Integrate hosted FSI configuration, SimpleSourceCodeServices, cleanup to SourceCodeServices API + + diff --git a/build.cmd b/fcs/build.cmd similarity index 50% rename from build.cmd rename to fcs/build.cmd index 4f9265e2d2..312c7ed738 100644 --- a/build.cmd +++ b/fcs/build.cmd @@ -1,12 +1,24 @@ @echo off +.nuget\NuGet.exe restore -PackagesDirectory packages +setlocal +cd fcs .paket\paket.bootstrapper.exe +dotnet restore tools.fsproj if errorlevel 1 ( + endlocal exit /b %errorlevel% ) .paket\paket.exe restore if errorlevel 1 ( + endlocal exit /b %errorlevel% ) packages\FAKE\tools\FAKE.exe build.fsx %* +if errorlevel 1 ( + endlocal + exit /b %errorlevel% +) +endlocal +exit /b 0 diff --git a/fcs/build.fsx b/fcs/build.fsx new file mode 100644 index 0000000000..9580a3aa5f --- /dev/null +++ b/fcs/build.fsx @@ -0,0 +1,223 @@ +// -------------------------------------------------------------------------------------- +// FAKE build script +// -------------------------------------------------------------------------------------- + +#I "packages/FAKE/tools" +#r "packages/FAKE/tools/FakeLib.dll" +open System +open System.IO +open Fake +open Fake.AppVeyor +open Fake.ReleaseNotesHelper + +#if MONO +// prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196) +System.Console.OutputEncoding <- System.Text.Encoding.UTF8 +#endif + +// -------------------------------------------------------------------------------------- +// Utilities +// -------------------------------------------------------------------------------------- + +let assertExitCodeZero x = if x = 0 then () else failwithf "Command failed with exit code %i" x +let runCmdIn workDir (exe:string) = Printf.ksprintf (fun (args:string) -> +#if MONO + let exe = exe.Replace("\\","/") + let args = args.Replace("\\","/") + printfn "[%s] mono %s %s" workDir exe args + Shell.Exec("mono", sprintf "%s %s" exe args, workDir) +#else + printfn "[%s] %s %s" workDir exe args + Shell.Exec(exe, args, workDir) +#endif + |> assertExitCodeZero +) + +// -------------------------------------------------------------------------------------- +// The rest of the code is standard F# build script +// -------------------------------------------------------------------------------------- + +let releaseDir = Path.Combine(__SOURCE_DIRECTORY__, "../Release") + + +// Read release notes & version info from RELEASE_NOTES.md +let release = LoadReleaseNotes (__SOURCE_DIRECTORY__ + "/RELEASE_NOTES.md") +let isAppVeyorBuild = buildServer = BuildServer.AppVeyor +let isVersionTag tag = Version.TryParse tag |> fst +let hasRepoVersionTag = isAppVeyorBuild && AppVeyorEnvironment.RepoTag && isVersionTag AppVeyorEnvironment.RepoTagName +let assemblyVersion = if hasRepoVersionTag then AppVeyorEnvironment.RepoTagName else release.NugetVersion +let nugetVersion = release.NugetVersion +open SemVerHelper +let nugetDebugVersion = + let semVer = SemVerHelper.parse nugetVersion + let debugPatch, debugPreRelease = + match semVer.PreRelease with + | None -> semVer.Patch + 1, { Origin = "alpha001"; Name = "alpha"; Number = Some 1; Parts = [AlphaNumeric "alpha001"] } + | Some pre -> + let num = match pre.Number with Some i -> i + 1 | None -> 1 + let name = pre.Name + let newOrigin = sprintf "%s%03d" name num + semVer.Patch, { Origin = newOrigin; Name = name; Number = Some num; Parts = [AlphaNumeric newOrigin] } + let debugVer = + { semVer with + Patch = debugPatch + PreRelease = Some debugPreRelease } + debugVer.ToString() +let buildDate = DateTime.UtcNow +let buildVersion = + if hasRepoVersionTag then assemblyVersion + else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber + else assemblyVersion + +Target "BuildVersion" (fun _ -> + Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore +) + +// -------------------------------------------------------------------------------------- +// Clean build results & restore NuGet packages + + +Target "Build.NetFx" (fun _ -> + !! "FSharp.Compiler.Service.sln" + |> MSBuild "" "Build" ["Configuration","Release" ] + |> Log (".NETFxBuild-Output: ") +) + + +// -------------------------------------------------------------------------------------- +// Run the unit tests using test runner + +Target "Test.NetFx" (fun _ -> + !! (releaseDir + "/fcs/net45/FSharp.Compiler.Service.Tests.dll") + |> Fake.Testing.NUnit3.NUnit3 (fun p -> + { p with + ToolPath = @"..\packages\NUnit.Console.3.0.0\tools\nunit3-console.exe" + ShadowCopy = false + TimeOut = TimeSpan.FromMinutes 20. }) +) + +// -------------------------------------------------------------------------------------- +// Build a NuGet package +Target "NuGet.NetFx" (fun _ -> + runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.nuspec -OutputDirectory %s" releaseDir + runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.MSBuild.v12.nuspec -OutputDirectory %s" releaseDir + runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.ProjectCracker.nuspec -OutputDirectory %s" releaseDir +) + + + +// -------------------------------------------------------------------------------------- +// .NET Core and .NET Core SDK + +let isDotnetSDKInstalled = + match Fake.EnvironmentHelper.environVarOrNone "FCS_DNC" with + | Some flag -> + match bool.TryParse flag with + | true, result -> result + | _ -> false + | None -> + try + Shell.Exec("dotnet", "--info") = 0 + with + _ -> false + + +Target "Build.NetStd" (fun _ -> + runCmdIn __SOURCE_DIRECTORY__ "dotnet" "pack %s -v n -c Release" "FSharp.Compiler.Service.netstandard.sln" +) + + +Target "Test.NetStd" (fun _ -> + runCmdIn __SOURCE_DIRECTORY__ "dotnet" "run -p FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj -c Release -- --result:TestResults.NetStd.xml;format=nunit3" +) + + +//use dotnet-mergenupkg to merge the .NETstandard nuget package into the default one +Target "Nuget.AddNetStd" (fun _ -> + let nupkg = sprintf "%s/FSharp.Compiler.Service.%s.nupkg" releaseDir release.AssemblyVersion + let netcoreNupkg = sprintf "FSharp.Compiler.Service.netstandard/bin/Release/FSharp.Compiler.Service.%s.nupkg" release.AssemblyVersion + runCmdIn __SOURCE_DIRECTORY__ "dotnet" "mergenupkg --source %s --other %s --framework netstandard1.6" nupkg netcoreNupkg +) + + +// -------------------------------------------------------------------------------------- +// Generate the documentation + +Target "GenerateDocs" (fun _ -> + executeFSIWithArgs "docsrc/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore +) + +Target "GenerateDocsJa" (fun _ -> + executeFSIWithArgs "docsrc/tools" "generate.ja.fsx" ["--define:RELEASE"] [] |> ignore +) + +// -------------------------------------------------------------------------------------- +// Release Scripts + +Target "PublishNuGet" (fun _ -> + Paket.Push (fun p -> + let apikey = + match getBuildParam "nuget-apikey" with + | s when not (String.IsNullOrWhiteSpace s) -> s + | _ -> getUserInput "Nuget API Key: " + { p with + ApiKey = apikey + WorkingDir = releaseDir }) +) + +// -------------------------------------------------------------------------------------- +// Run all targets by default. Invoke 'build ' to override + +Target "Clean" DoNothing +Target "CleanDocs" DoNothing +Target "Release" DoNothing +Target "NuGet" DoNothing +Target "Build" DoNothing +Target "TestAndNuGet" DoNothing + +"Clean" + =?> ("BuildVersion", isAppVeyorBuild) + ==> "Build.NetStd" + +"Clean" + =?> ("BuildVersion", isAppVeyorBuild) + ==> "Build.NetFx" + +"Build.NetFx" + ==> "Test.NetFx" + +"Build.NetStd" + ==> "Test.NetStd" + +"Build.NetFx" + =?> ("Build.NetStd", isDotnetSDKInstalled) + ==> "Build" + +"Build.NetStd" + =?> ("Nuget.AddNetStd", isDotnetSDKInstalled) + +"Build.NetFx" + ==> "NuGet.NetFx" + =?> ("Nuget.AddNetStd", isDotnetSDKInstalled) + ==> "NuGet" + +"Test.NetFx" + ==> "TestAndNuGet" + +"NuGet" + ==> "TestAndNuGet" + +//"Test.NetStd" +// ==> "TestAndNuGet" + +"Build" + ==> "NuGet" + ==> "PublishNuGet" + ==> "Release" + +"CleanDocs" + ==> "GenerateDocs" + ==> "GenerateDocsJa" + ==> "Release" + +RunTargetOrDefault "Build" diff --git a/build.sh b/fcs/build.sh similarity index 64% rename from build.sh rename to fcs/build.sh index a7ff60d4ee..3e7e80e7d8 100755 --- a/build.sh +++ b/fcs/build.sh @@ -2,25 +2,19 @@ if test "$OS" = "Windows_NT" then # use .Net - .paket/paket.bootstrapper.exe - exit_code=$? - if [ $exit_code -ne 0 ]; then - exit $exit_code - fi + cmd fcs/build.cmd $@ +else + mono .nuget/NuGet.exe restore -PackagesDirectory packages - .paket/paket.exe restore - exit_code=$? - if [ $exit_code -ne 0 ]; then - exit $exit_code - fi + cd fcs - packages/FAKE/tools/FAKE.exe build.fsx $@ -else # use mono if [[ ! -e ~/.config/.mono/certs ]]; then mozroots --import --sync --quiet fi + dotnet restore tools.fsproj + mono .paket/paket.bootstrapper.exe exit_code=$? if [ $exit_code -ne 0 ]; then diff --git a/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Engine.dll b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Engine.dll new file mode 100644 index 0000000000..da712783aa Binary files /dev/null and b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Engine.dll differ diff --git a/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Framework.dll b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Framework.dll new file mode 100644 index 0000000000..f13d4f40fc Binary files /dev/null and b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Framework.dll differ diff --git a/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Tasks.v12.0.dll b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Tasks.v12.0.dll new file mode 100644 index 0000000000..116eadc118 Binary files /dev/null and b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Tasks.v12.0.dll differ diff --git a/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll new file mode 100644 index 0000000000..9a8014abc3 Binary files /dev/null and b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll differ diff --git a/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.dll b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.dll new file mode 100644 index 0000000000..2ca81182c0 Binary files /dev/null and b/fcs/dependencies/MSBuild.v12.0/Microsoft.Build.dll differ diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll new file mode 100644 index 0000000000..0661150997 Binary files /dev/null and b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll differ diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll new file mode 100644 index 0000000000..74d6e05b85 Binary files /dev/null and b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll differ diff --git a/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll new file mode 100644 index 0000000000..c702184ec0 Binary files /dev/null and b/fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll differ diff --git a/samples/EditorService/paket.references b/fcs/dependencies/README.md similarity index 100% rename from samples/EditorService/paket.references rename to fcs/dependencies/README.md diff --git a/docsrc/content/caches.fsx b/fcs/docsrc/content/caches.fsx similarity index 100% rename from docsrc/content/caches.fsx rename to fcs/docsrc/content/caches.fsx diff --git a/docsrc/content/compiler.fsx b/fcs/docsrc/content/compiler.fsx similarity index 100% rename from docsrc/content/compiler.fsx rename to fcs/docsrc/content/compiler.fsx diff --git a/docsrc/content/corelib.fsx b/fcs/docsrc/content/corelib.fsx similarity index 100% rename from docsrc/content/corelib.fsx rename to fcs/docsrc/content/corelib.fsx diff --git a/docsrc/content/devnotes.md b/fcs/docsrc/content/devnotes.md similarity index 100% rename from docsrc/content/devnotes.md rename to fcs/docsrc/content/devnotes.md diff --git a/docsrc/content/editor.fsx b/fcs/docsrc/content/editor.fsx similarity index 100% rename from docsrc/content/editor.fsx rename to fcs/docsrc/content/editor.fsx diff --git a/docsrc/content/filesystem.fsx b/fcs/docsrc/content/filesystem.fsx similarity index 100% rename from docsrc/content/filesystem.fsx rename to fcs/docsrc/content/filesystem.fsx diff --git a/docsrc/content/fsharp-readme.md b/fcs/docsrc/content/fsharp-readme.md similarity index 100% rename from docsrc/content/fsharp-readme.md rename to fcs/docsrc/content/fsharp-readme.md diff --git a/docsrc/content/index.md b/fcs/docsrc/content/index.md similarity index 100% rename from docsrc/content/index.md rename to fcs/docsrc/content/index.md diff --git a/docsrc/content/interactive.fsx b/fcs/docsrc/content/interactive.fsx similarity index 100% rename from docsrc/content/interactive.fsx rename to fcs/docsrc/content/interactive.fsx diff --git a/docsrc/content/ja/compiler.fsx b/fcs/docsrc/content/ja/compiler.fsx similarity index 100% rename from docsrc/content/ja/compiler.fsx rename to fcs/docsrc/content/ja/compiler.fsx diff --git a/docsrc/content/ja/corelib.fsx b/fcs/docsrc/content/ja/corelib.fsx similarity index 100% rename from docsrc/content/ja/corelib.fsx rename to fcs/docsrc/content/ja/corelib.fsx diff --git a/docsrc/content/ja/devnotes.md b/fcs/docsrc/content/ja/devnotes.md similarity index 100% rename from docsrc/content/ja/devnotes.md rename to fcs/docsrc/content/ja/devnotes.md diff --git a/docsrc/content/ja/editor.fsx b/fcs/docsrc/content/ja/editor.fsx similarity index 100% rename from docsrc/content/ja/editor.fsx rename to fcs/docsrc/content/ja/editor.fsx diff --git a/docsrc/content/ja/filesystem.fsx b/fcs/docsrc/content/ja/filesystem.fsx similarity index 100% rename from docsrc/content/ja/filesystem.fsx rename to fcs/docsrc/content/ja/filesystem.fsx diff --git a/docsrc/content/ja/fsharp-readme.md b/fcs/docsrc/content/ja/fsharp-readme.md similarity index 100% rename from docsrc/content/ja/fsharp-readme.md rename to fcs/docsrc/content/ja/fsharp-readme.md diff --git a/docsrc/content/ja/index.md b/fcs/docsrc/content/ja/index.md similarity index 100% rename from docsrc/content/ja/index.md rename to fcs/docsrc/content/ja/index.md diff --git a/docsrc/content/ja/interactive.fsx b/fcs/docsrc/content/ja/interactive.fsx similarity index 100% rename from docsrc/content/ja/interactive.fsx rename to fcs/docsrc/content/ja/interactive.fsx diff --git a/docsrc/content/ja/project.fsx b/fcs/docsrc/content/ja/project.fsx similarity index 100% rename from docsrc/content/ja/project.fsx rename to fcs/docsrc/content/ja/project.fsx diff --git a/docsrc/content/ja/symbols.fsx b/fcs/docsrc/content/ja/symbols.fsx similarity index 100% rename from docsrc/content/ja/symbols.fsx rename to fcs/docsrc/content/ja/symbols.fsx diff --git a/docsrc/content/ja/tokenizer.fsx b/fcs/docsrc/content/ja/tokenizer.fsx similarity index 100% rename from docsrc/content/ja/tokenizer.fsx rename to fcs/docsrc/content/ja/tokenizer.fsx diff --git a/docsrc/content/ja/untypedtree.fsx b/fcs/docsrc/content/ja/untypedtree.fsx similarity index 100% rename from docsrc/content/ja/untypedtree.fsx rename to fcs/docsrc/content/ja/untypedtree.fsx diff --git a/docsrc/content/project.fsx b/fcs/docsrc/content/project.fsx similarity index 100% rename from docsrc/content/project.fsx rename to fcs/docsrc/content/project.fsx diff --git a/docsrc/content/queue.fsx b/fcs/docsrc/content/queue.fsx similarity index 100% rename from docsrc/content/queue.fsx rename to fcs/docsrc/content/queue.fsx diff --git a/docsrc/content/react.fsx b/fcs/docsrc/content/react.fsx similarity index 100% rename from docsrc/content/react.fsx rename to fcs/docsrc/content/react.fsx diff --git a/docsrc/content/symbols.fsx b/fcs/docsrc/content/symbols.fsx similarity index 100% rename from docsrc/content/symbols.fsx rename to fcs/docsrc/content/symbols.fsx diff --git a/docsrc/content/tokenizer.fsx b/fcs/docsrc/content/tokenizer.fsx similarity index 100% rename from docsrc/content/tokenizer.fsx rename to fcs/docsrc/content/tokenizer.fsx diff --git a/docsrc/content/typedtree.fsx b/fcs/docsrc/content/typedtree.fsx similarity index 100% rename from docsrc/content/typedtree.fsx rename to fcs/docsrc/content/typedtree.fsx diff --git a/docsrc/content/untypedtree.fsx b/fcs/docsrc/content/untypedtree.fsx similarity index 100% rename from docsrc/content/untypedtree.fsx rename to fcs/docsrc/content/untypedtree.fsx diff --git a/docsrc/files/content/fcs.css b/fcs/docsrc/files/content/fcs.css similarity index 100% rename from docsrc/files/content/fcs.css rename to fcs/docsrc/files/content/fcs.css diff --git a/docsrc/files/content/style.ja.css b/fcs/docsrc/files/content/style.ja.css similarity index 100% rename from docsrc/files/content/style.ja.css rename to fcs/docsrc/files/content/style.ja.css diff --git a/docsrc/files/images/en.png b/fcs/docsrc/files/images/en.png similarity index 100% rename from docsrc/files/images/en.png rename to fcs/docsrc/files/images/en.png diff --git a/docsrc/files/images/ja.png b/fcs/docsrc/files/images/ja.png similarity index 100% rename from docsrc/files/images/ja.png rename to fcs/docsrc/files/images/ja.png diff --git a/docsrc/files/images/logo.png b/fcs/docsrc/files/images/logo.png similarity index 100% rename from docsrc/files/images/logo.png rename to fcs/docsrc/files/images/logo.png diff --git a/docsrc/tools/generate.fsx b/fcs/docsrc/tools/generate.fsx similarity index 94% rename from docsrc/tools/generate.fsx rename to fcs/docsrc/tools/generate.fsx index f6aece3d80..e22ee8e326 100644 --- a/docsrc/tools/generate.fsx +++ b/fcs/docsrc/tools/generate.fsx @@ -32,9 +32,9 @@ open FSharp.MetadataFormat let root = "." // Paths with template/source/output locations -let bin = __SOURCE_DIRECTORY__ @@ "../../bin/v4.5" +let bin = __SOURCE_DIRECTORY__ @@ "../../../Release/fcs/net45" let content = __SOURCE_DIRECTORY__ @@ "../content" -let output = __SOURCE_DIRECTORY__ @@ "../../docs" +let output = __SOURCE_DIRECTORY__ @@ "../../../docs" let files = __SOURCE_DIRECTORY__ @@ "../files" let templates = __SOURCE_DIRECTORY__ @@ "templates" let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting/" @@ -60,7 +60,7 @@ let buildReference () = ( bin @@ lib, output @@ "reference", layoutRoots, parameters = ("root", root)::info, sourceRepo = "https://github.com/fsharp/FSharp.Compiler.Service/tree/master/src", - sourceFolder = @"..\..\src" ) + sourceFolder = @"..\..\..\src" ) // Build documentation from `fsx` and `md` files in `docsrc/content` let buildDocumentation () = @@ -73,6 +73,6 @@ let buildDocumentation () = // Generate copyFiles() -buildDocumentation() +//buildDocumentation() buildReference() diff --git a/docsrc/tools/generate.ja.fsx b/fcs/docsrc/tools/generate.ja.fsx similarity index 80% rename from docsrc/tools/generate.ja.fsx rename to fcs/docsrc/tools/generate.ja.fsx index 28c18f6cbc..b7e9b25d00 100644 --- a/docsrc/tools/generate.ja.fsx +++ b/fcs/docsrc/tools/generate.ja.fsx @@ -3,8 +3,6 @@ // (the generated documentation is stored in the 'docs' directory) // -------------------------------------------------------------------------------------- -// Binaries that have XML documentation (in a corresponding generated XML file) -let referenceBinaries = [ "FSharp.Compiler.Service.dll" ] // Web site location for the generated documentation let website = "/FSharp.Compiler.Service/ja" @@ -47,30 +45,20 @@ let root = "file://" + (__SOURCE_DIRECTORY__ @@ "../output/ja") #endif // Paths with template/source/output locations -let bin = __SOURCE_DIRECTORY__ @@ "../../bin/v4.5" +let bin = __SOURCE_DIRECTORY__ @@ "../../../Release/fcs/net45" let content = __SOURCE_DIRECTORY__ @@ "../content/ja" -let output = __SOURCE_DIRECTORY__ @@ "../../docs" -let outputJa = __SOURCE_DIRECTORY__ @@ "../../docs/ja" +let outputJa = __SOURCE_DIRECTORY__ @@ "../../../docs/ja" let files = __SOURCE_DIRECTORY__ @@ "../files" let templates = __SOURCE_DIRECTORY__ @@ "templates/ja" -let reference = __SOURCE_DIRECTORY__ @@ "reference" let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting/" let docTemplate = formatting @@ "templates/docpage.cshtml" // Where to look for *.csproj templates (in this order) let layoutRoots = [ templates - reference - formatting @@ "templates" - formatting @@ "templates/reference" ] + formatting @@ "templates"] // Copy static files and CSS + JS from F# Formatting -let copyFiles () = - CopyRecursive files output true |> Log "Copying file: " - ensureDirectory (output @@ "content") - CopyRecursive (formatting @@ "styles") (output @@ "content") true - |> Log "Copying styles and scripts: " - // Build documentation from `fsx` and `md` files in `docsrc/content` let buildDocumentation () = let subdirs = Directory.EnumerateDirectories(content, "*", SearchOption.AllDirectories) @@ -82,5 +70,4 @@ let buildDocumentation () = layoutRoots = layoutRoots, generateAnchors = true ) // Generate -copyFiles() buildDocumentation() diff --git a/docsrc/tools/templates/ja/template.cshtml b/fcs/docsrc/tools/templates/ja/template.cshtml similarity index 100% rename from docsrc/tools/templates/ja/template.cshtml rename to fcs/docsrc/tools/templates/ja/template.cshtml diff --git a/docsrc/tools/templates/template.cshtml b/fcs/docsrc/tools/templates/template.cshtml similarity index 100% rename from docsrc/tools/templates/template.cshtml rename to fcs/docsrc/tools/templates/template.cshtml diff --git a/fcs/fcs.props b/fcs/fcs.props new file mode 100644 index 0000000000..2753da7407 --- /dev/null +++ b/fcs/fcs.props @@ -0,0 +1,13 @@ + + + + + + 14.0.2 + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools + fsi.exe + + + \ No newline at end of file diff --git a/misc/logo.pdn b/fcs/misc/logo.pdn similarity index 100% rename from misc/logo.pdn rename to fcs/misc/logo.pdn diff --git a/misc/logo.png b/fcs/misc/logo.png similarity index 100% rename from misc/logo.png rename to fcs/misc/logo.png diff --git a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec new file mode 100644 index 0000000000..e2fc6d2fd7 --- /dev/null +++ b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec @@ -0,0 +1,22 @@ + + + + FSharp.Compiler.Service.MSBuild.v12 + + Adds legacy MSBuild 12.0 support to the F# compiler services package for + resolving references such as #r "System, Version=4.1.0.0,..." + + en-US + false + 14.0.2 + Microsoft Corporation and F# community contributors + https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE + https://github.com/fsharp/FSharp.Compiler.Service + https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png + F#, fsharp, interactive, compiler, editor + F# compiler services for creating IDE tools, language extensions and for F# embedding. + + + + + diff --git a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec new file mode 100644 index 0000000000..f9275ce232 --- /dev/null +++ b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec @@ -0,0 +1,31 @@ + + + + FSharp.Compiler.Service.ProjectCracker + + The F# compiler services package contains a custom build of the F# compiler that + exposes additional functionality for implementing F# language bindings, additional + tools based on the compiler or refactoring tools. The package also includes F# + interactive service that can be used for embedding F# scripting into your applications. + + en-US + false + 14.0.2 + Microsoft Corporation and F# community contributors + https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE + https://github.com/fsharp/FSharp.Compiler.Service + https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png + F#, fsharp, interactive, compiler, editor + F# compiler services for creating IDE tools, language extensions and for F# embedding. + + + + + + + + + + + + diff --git a/fcs/nuget/FSharp.Compiler.Service.nuspec b/fcs/nuget/FSharp.Compiler.Service.nuspec new file mode 100644 index 0000000000..5b05dba395 --- /dev/null +++ b/fcs/nuget/FSharp.Compiler.Service.nuspec @@ -0,0 +1,32 @@ + + + + FSharp.Compiler.Service + + The F# compiler services package contains a custom build of the F# compiler that + exposes additional functionality for implementing F# language bindings, additional + tools based on the compiler or refactoring tools. The package also includes F# + interactive service that can be used for embedding F# scripting into your applications. + + en-US + false + 14.0.2 + Microsoft Corporation and F# community contributors + https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE + https://github.com/fsharp/FSharp.Compiler.Service + https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png + F#, fsharp, interactive, compiler, editor + F# compiler services for creating IDE tools, language extensions and for F# embedding. + + + + + + + + + + + + + diff --git a/fcs/paket.dependencies b/fcs/paket.dependencies new file mode 100644 index 0000000000..e0071842a8 --- /dev/null +++ b/fcs/paket.dependencies @@ -0,0 +1,7 @@ +frameworks: net45 + +source https://www.nuget.org/api/v2/ + +nuget FAKE +nuget FSharp.Formatting + diff --git a/fcs/paket.lock b/fcs/paket.lock new file mode 100644 index 0000000000..8df1dc9765 --- /dev/null +++ b/fcs/paket.lock @@ -0,0 +1,17 @@ +RESTRICTION: == net45 +NUGET + remote: https://www.nuget.org/api/v2 + FAKE (4.63) + FSharp.Compiler.Service (2.0.0.6) + FSharp.Formatting (2.14.4) + FSharp.Compiler.Service (2.0.0.6) + FSharpVSPowerTools.Core (>= 2.3 < 2.4) + FSharpVSPowerTools.Core (2.3) + FSharp.Compiler.Service (>= 2.0.0.3) + NUnit (2.6.3) + NUnit.Runners (2.6.3) + Octokit (0.24) +GITHUB + remote: fsharp/FAKE + modules/Octokit/Octokit.fsx (291f58cc70aba6dd871cf18e66d2d88357e4f208) + Octokit (>= 0.20) \ No newline at end of file diff --git a/samples/EditorService/App.config b/fcs/samples/EditorService/App.config similarity index 100% rename from samples/EditorService/App.config rename to fcs/samples/EditorService/App.config diff --git a/samples/EditorService/EditorService.fsproj b/fcs/samples/EditorService/EditorService.fsproj similarity index 84% rename from samples/EditorService/EditorService.fsproj rename to fcs/samples/EditorService/EditorService.fsproj index 72d9bf35aa..cf96ec6157 100644 --- a/samples/EditorService/EditorService.fsproj +++ b/fcs/samples/EditorService/EditorService.fsproj @@ -40,8 +40,9 @@ true - - True + + + $(SolutionDir)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -53,12 +54,12 @@ - + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True - + \ No newline at end of file diff --git a/samples/EditorService/Program.fs b/fcs/samples/EditorService/Program.fs similarity index 94% rename from samples/EditorService/Program.fs rename to fcs/samples/EditorService/Program.fs index c69167b6e7..20bf20cda7 100644 --- a/samples/EditorService/Program.fs +++ b/fcs/samples/EditorService/Program.fs @@ -31,7 +31,7 @@ let file = "/home/user/Test.fsx" let identTokenTag = FSharpTokenTag.Identifier let untyped, parsed = parseWithTypeInfo (file, input) // Get tool tip at the specified location -let tip = parsed.GetToolTipTextAlternate(2, 7, inputLines.[1], [ "foo" ], identTokenTag) +let tip = parsed.GetToolTipText(2, 7, inputLines.[1], [ "foo" ], identTokenTag) printfn "%A" tip diff --git a/samples/FscExe/paket.references b/fcs/samples/EditorService/paket.references similarity index 100% rename from samples/FscExe/paket.references rename to fcs/samples/EditorService/paket.references diff --git a/fcs/samples/FscExe/App.config b/fcs/samples/FscExe/App.config new file mode 100644 index 0000000000..a895438e29 --- /dev/null +++ b/fcs/samples/FscExe/App.config @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/samples/FscExe/FscExe.fsproj b/fcs/samples/FscExe/FscExe.fsproj similarity index 78% rename from samples/FscExe/FscExe.fsproj rename to fcs/samples/FscExe/FscExe.fsproj index 5fe71765d8..8c36589804 100644 --- a/samples/FscExe/FscExe.fsproj +++ b/fcs/samples/FscExe/FscExe.fsproj @@ -1,6 +1,10 @@  + + + $(MSBuildProjectDirectory)\..\..\..\src + Debug AnyCPU @@ -47,26 +51,28 @@ true - - Resources/assemblyinfo.fsc.exe.fs - Driver/FscMain.fs - - True + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true - - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + + + FSharp.Compiler.Service + {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} + True - + \ No newline at end of file diff --git a/samples/FscExe/FscMain.fs b/fcs/samples/FscExe/FscMain.fs old mode 100755 new mode 100644 similarity index 100% rename from samples/FscExe/FscMain.fs rename to fcs/samples/FscExe/FscMain.fs diff --git a/samples/FsiExe/paket.references b/fcs/samples/FscExe/paket.references similarity index 100% rename from samples/FsiExe/paket.references rename to fcs/samples/FscExe/paket.references diff --git a/fcs/samples/FsiExe/App.config b/fcs/samples/FsiExe/App.config new file mode 100644 index 0000000000..ac481ec64a --- /dev/null +++ b/fcs/samples/FsiExe/App.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/samples/FsiExe/FsiExe.fsproj b/fcs/samples/FsiExe/FsiExe.fsproj similarity index 82% rename from samples/FsiExe/FsiExe.fsproj rename to fcs/samples/FsiExe/FsiExe.fsproj index 564a857119..18435f8ff0 100644 --- a/samples/FsiExe/FsiExe.fsproj +++ b/fcs/samples/FsiExe/FsiExe.fsproj @@ -1,6 +1,9 @@  + + $(MSBuildProjectDirectory)\..\..\..\src + Debug AnyCPU @@ -12,7 +15,7 @@ FsiExe v4.5 FsiExe - 4.4.0.0 + 40 true @@ -42,8 +45,10 @@ true - - True + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true @@ -60,11 +65,11 @@ - + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True - + \ No newline at end of file diff --git a/samples/FsiExe/console.fs b/fcs/samples/FsiExe/console.fs old mode 100755 new mode 100644 similarity index 100% rename from samples/FsiExe/console.fs rename to fcs/samples/FsiExe/console.fs diff --git a/samples/FsiExe/fsimain.fs b/fcs/samples/FsiExe/fsimain.fs old mode 100755 new mode 100644 similarity index 96% rename from samples/FsiExe/fsimain.fs rename to fcs/samples/FsiExe/fsimain.fs index 6cd75b9c56..c11d3f0009 --- a/samples/FsiExe/fsimain.fs +++ b/fcs/samples/FsiExe/fsimain.fs @@ -154,8 +154,9 @@ let MainMain argv = try let console = new Microsoft.FSharp.Compiler.Interactive.ReadLineConsole() - let getConsoleReadLine () = - let probeToSeeIfConsoleWorks = + let getConsoleReadLine (probeToSeeIfConsoleWorks) = + let consoleIsOperational = + if probeToSeeIfConsoleWorks then //if progress then fprintfn outWriter "probing to see if console works..." try // Probe to see if the console looks functional on this version of .NET @@ -168,11 +169,12 @@ let MainMain argv = with _ -> //if progress then fprintfn outWriter "probe failed, we have no console..." false - if probeToSeeIfConsoleWorks then - Some (fun () -> console.ReadLine()) - else - None - + else true + if consoleIsOperational then + Some (fun () -> console.ReadLine()) + else + None + #if USE_FSharp_Compiler_Interactive_Settings let fsiConfig0 = FsiEvaluationSession.GetDefaultConfiguration(fsi) #else @@ -200,7 +202,7 @@ let MainMain argv = member __.StartServer(fsiServerName) = StartServer fsiSession fsiServerName // Connect the configuration through to the 'fsi' Event loop - member __.OptionalConsoleReadLine = getConsoleReadLine() } + member __.GetOptionalConsoleReadLine(probe) = getConsoleReadLine(probe) } and fsiSession = FsiEvaluationSession.Create (fsiConfig, argv, Console.In, Console.Out, Console.Error) diff --git a/samples/FsiExe/fsiserver.fs b/fcs/samples/FsiExe/fsiserver.fs similarity index 100% rename from samples/FsiExe/fsiserver.fs rename to fcs/samples/FsiExe/fsiserver.fs diff --git a/samples/InteractiveService/paket.references b/fcs/samples/FsiExe/paket.references similarity index 100% rename from samples/InteractiveService/paket.references rename to fcs/samples/FsiExe/paket.references diff --git a/samples/UntypedTree/App.config b/fcs/samples/InteractiveService/App.config similarity index 55% rename from samples/UntypedTree/App.config rename to fcs/samples/InteractiveService/App.config index 58f580b925..423a5517bd 100644 --- a/samples/UntypedTree/App.config +++ b/fcs/samples/InteractiveService/App.config @@ -5,10 +5,6 @@ - - - - \ No newline at end of file diff --git a/samples/InteractiveService/InteractiveService.fsproj b/fcs/samples/InteractiveService/InteractiveService.fsproj similarity index 82% rename from samples/InteractiveService/InteractiveService.fsproj rename to fcs/samples/InteractiveService/InteractiveService.fsproj index 72f73e1bb9..c6b7ee6240 100644 --- a/samples/InteractiveService/InteractiveService.fsproj +++ b/fcs/samples/InteractiveService/InteractiveService.fsproj @@ -1,6 +1,9 @@  + + $(MSBuildProjectDirectory)\..\..\..\src + Debug AnyCPU @@ -40,8 +43,10 @@ true - - True + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true @@ -53,11 +58,11 @@ - + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True - + \ No newline at end of file diff --git a/samples/InteractiveService/Program.fs b/fcs/samples/InteractiveService/Program.fs similarity index 100% rename from samples/InteractiveService/Program.fs rename to fcs/samples/InteractiveService/Program.fs diff --git a/samples/Tokenizer/paket.references b/fcs/samples/InteractiveService/paket.references similarity index 100% rename from samples/Tokenizer/paket.references rename to fcs/samples/InteractiveService/paket.references diff --git a/samples/Tokenizer/App.config b/fcs/samples/Tokenizer/App.config similarity index 55% rename from samples/Tokenizer/App.config rename to fcs/samples/Tokenizer/App.config index 58f580b925..423a5517bd 100644 --- a/samples/Tokenizer/App.config +++ b/fcs/samples/Tokenizer/App.config @@ -5,10 +5,6 @@ - - - - \ No newline at end of file diff --git a/samples/Tokenizer/Program.fs b/fcs/samples/Tokenizer/Program.fs similarity index 100% rename from samples/Tokenizer/Program.fs rename to fcs/samples/Tokenizer/Program.fs diff --git a/samples/Tokenizer/Tokenizer.fsproj b/fcs/samples/Tokenizer/Tokenizer.fsproj similarity index 83% rename from samples/Tokenizer/Tokenizer.fsproj rename to fcs/samples/Tokenizer/Tokenizer.fsproj index 896c4cf0a5..6cbabe463e 100644 --- a/samples/Tokenizer/Tokenizer.fsproj +++ b/fcs/samples/Tokenizer/Tokenizer.fsproj @@ -1,6 +1,9 @@  + + $(MSBuildProjectDirectory)\..\..\..\src + Debug AnyCPU @@ -40,8 +43,10 @@ true - - True + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true @@ -53,7 +58,7 @@ - + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True @@ -62,5 +67,5 @@ 11 - + \ No newline at end of file diff --git a/samples/UntypedTree/paket.references b/fcs/samples/Tokenizer/paket.references similarity index 100% rename from samples/UntypedTree/paket.references rename to fcs/samples/Tokenizer/paket.references diff --git a/fcs/samples/UntypedTree/App.config b/fcs/samples/UntypedTree/App.config new file mode 100644 index 0000000000..423a5517bd --- /dev/null +++ b/fcs/samples/UntypedTree/App.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/samples/UntypedTree/Program.fs b/fcs/samples/UntypedTree/Program.fs similarity index 100% rename from samples/UntypedTree/Program.fs rename to fcs/samples/UntypedTree/Program.fs diff --git a/samples/UntypedTree/UntypedTree.fsproj b/fcs/samples/UntypedTree/UntypedTree.fsproj similarity index 83% rename from samples/UntypedTree/UntypedTree.fsproj rename to fcs/samples/UntypedTree/UntypedTree.fsproj index 129309aee4..c99bbab7eb 100644 --- a/samples/UntypedTree/UntypedTree.fsproj +++ b/fcs/samples/UntypedTree/UntypedTree.fsproj @@ -1,6 +1,9 @@  + + $(MSBuildProjectDirectory)\..\..\..\src + Debug AnyCPU @@ -40,8 +43,10 @@ true - - True + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools\FSharp.Core.dll + true @@ -53,7 +58,7 @@ - + FSharp.Compiler.Service {2e4d67b4-522d-4cf7-97e4-ba940f0b18f3} True @@ -62,5 +67,5 @@ 11 - + \ No newline at end of file diff --git a/samples/UntypedTree/UntypedTree.sln b/fcs/samples/UntypedTree/UntypedTree.sln similarity index 100% rename from samples/UntypedTree/UntypedTree.sln rename to fcs/samples/UntypedTree/UntypedTree.sln diff --git a/src/fsharp/FSharp.Compiler.Service.MSBuild.v12/paket.references b/fcs/samples/UntypedTree/paket.references similarity index 100% rename from src/fsharp/FSharp.Compiler.Service.MSBuild.v12/paket.references rename to fcs/samples/UntypedTree/paket.references diff --git a/fcs/tools.fsproj b/fcs/tools.fsproj new file mode 100644 index 0000000000..45aa251d76 --- /dev/null +++ b/fcs/tools.fsproj @@ -0,0 +1,10 @@ + + + Exe + net45 + + + + + + \ No newline at end of file diff --git a/init-tools.cmd b/init-tools.cmd new file mode 100644 index 0000000000..111c8c80de --- /dev/null +++ b/init-tools.cmd @@ -0,0 +1,108 @@ +@if not defined _echo @echo off +setlocal + +set INIT_TOOLS_LOG=%~dp0init-tools.log +set PACKAGES_DIR=%~dp0packages\ +set TOOLRUNTIME_DIR=%~dp0Tools + +set DOTNET_PATH=%TOOLRUNTIME_DIR%\dotnetcli\ +set DOTNET_CMD=%DOTNET_PATH%dotnet.exe + +set DOTNET_TOOLS_PATH=%TOOLRUNTIME_DIR%\dotnet20\ +set DOTNET_TOOLS_CMD=%DOTNET_TOOLS_PATH%dotnet.exe + +if [%BUILDTOOLS_SOURCE%]==[] set BUILDTOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json +set /P BUILDTOOLS_VERSION=< "%~dp0BuildToolsVersion.txt" +set BUILD_TOOLS_PATH=%PACKAGES_DIR%microsoft.dotnet.buildtools\%BUILDTOOLS_VERSION%\lib\ +set PROJECT_JSON_PATH=%TOOLRUNTIME_DIR%\%BUILDTOOLS_VERSION% +set PROJECT_JSON_FILE=%PROJECT_JSON_PATH%\project.json +set PROJECT_JSON_CONTENTS={ "dependencies": { "Microsoft.DotNet.BuildTools": "%BUILDTOOLS_VERSION%" , "Microsoft.DotNet.BuildTools.Coreclr": "1.0.4-prerelease"}, "frameworks": { "dnxcore50": { } } } +set BUILD_TOOLS_SEMAPHORE=%PROJECT_JSON_PATH%\init-tools.completed0 +set TOOLS_INIT_RETURN_CODE=0 + +:: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated +if [%1]==[force] ( + if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%" + if exist "%PACKAGES_DIR%microsoft.dotnet.buildtools" rmdir /S /Q "%PACKAGES_DIR%microsoft.dotnet.buildtools" +) + +:: If sempahore exists do nothing +if exist "%BUILD_TOOLS_SEMAPHORE%" ( + echo Tools are already initialized. + goto :DONE +) + +if exist "%TOOLRUNTIME_DIR%" rmdir /S /Q "%TOOLRUNTIME_DIR%" + +:: Download Nuget.exe +if NOT exist "%PACKAGES_DIR%NuGet.exe" ( + if NOT exist "%PACKAGES_DIR%" mkdir "%PACKAGES_DIR%" + powershell -NoProfile -ExecutionPolicy unrestricted -Command "$wc = New-Object System.Net.WebClient; $wc.Proxy = [System.Net.WebRequest]::DefaultWebProxy; $wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials; $wc.DownloadFile('https://www.nuget.org/nuget.exe', '%PACKAGES_DIR%NuGet.exe') +) + +if NOT exist "%PROJECT_JSON_PATH%" mkdir "%PROJECT_JSON_PATH%" +echo %PROJECT_JSON_CONTENTS% > "%PROJECT_JSON_FILE%" +echo Running %0 > "%INIT_TOOLS_LOG%" + +set /p DOTNET_TOOLS_VERSION=< "%~dp0DotnetCLIToolsVersion.txt" +if exist "%DOTNET_TOOLS_PATH%" goto :afterdotnettoolsrestore + +echo Installing dotnet OLD VERSION OF THE cli... +echo ========================================== +echo This is temporary until we build using the new dotnetcli +echo The dotnet cli is a large file it may take a few minutes ... +echo powershell -ExecutionPolicy unrestricted -NoProfile -Command ".\scripts\dotnet-install.ps1 -InstallDir %DOTNET_TOOLS_PATH% -Architecture x64 -Version %DOTNET_TOOLS_VERSION% -NoPath true; exit $LastExitCode;" +powershell -ExecutionPolicy unrestricted -NoProfile -Command ".\scripts\dotnet-install.ps1 -InstallDir %DOTNET_TOOLS_PATH% -Architecture x64 -Version %DOTNET_TOOLS_VERSION% -NoPath true; exit $LastExitCode;" +if errorlevel 1 ( + echo ERROR: Could not install dotnet cli correctly. + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE +) +:afterdotnettoolsrestore + +set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt" +if exist "%DOTNET_CMD%" goto :afterdotnetrestore + +echo Installing dotnet cli... +echo The dotnet cli is a large file it may take a few minutes ... +echo powershell -ExecutionPolicy unrestricted -NoProfile -Command ".\scripts\dotnet-install.ps1 -InstallDir %DOTNET_PATH% -Architecture x64 -Version %DOTNET_VERSION% -NoPath true; exit $LastExitCode;" +powershell -ExecutionPolicy unrestricted -NoProfile -Command ".\scripts\dotnet-install.ps1 -InstallDir %DOTNET_PATH% -Architecture x64 -Version %DOTNET_VERSION% -NoPath true; exit $LastExitCode;" +if errorlevel 1 ( + echo ERROR: Could not install dotnet cli correctly. + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE +) +:afterdotnetrestore + +if exist "%BUILD_TOOLS_PATH%" goto :afterbuildtoolsrestore +echo Restoring BuildTools version %BUILDTOOLS_VERSION%... +echo Running: "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages "%PACKAGES_DIR% " --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%" +call "%DOTNET_CMD%" restore "%PROJECT_JSON_FILE%" --packages "%PACKAGES_DIR% " --source "%BUILDTOOLS_SOURCE%" >> "%INIT_TOOLS_LOG%" +if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" ( + echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details. + set TOOLS_INIT_RETURN_CODE=1 + goto :DONE +) + +:afterbuildtoolsrestore + +echo Initializing BuildTools ... +echo Running: "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%" +call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%" + +echo Updating CLI NuGet Frameworks map... +robocopy "%TOOLRUNTIME_DIR%" "%DOTNET_PATH%\sdk\%DOTNET_VERSION%" NuGet.Frameworks.dll /XO >> "%INIT_TOOLS_LOG%" +set UPDATE_CLI_ERRORLEVEL=%ERRORLEVEL% +if %UPDATE_CLI_ERRORLEVEL% GTR 1 ( + echo ERROR: Failed to update Nuget for CLI {Error level %UPDATE_CLI_ERRORLEVEL%}. Please check '%INIT_TOOLS_LOG%' for more details. 1>&2 + exit /b %UPDATE_CLI_ERRORLEVEL% +) + +:: Create sempahore file +echo Done initializing tools. +echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%" + +:DONE + +exit /b %TOOLS_INIT_RETURN_CODE% + diff --git a/init-tools.sh b/init-tools.sh new file mode 100755 index 0000000000..9d5a2e2f8c --- /dev/null +++ b/init-tools.sh @@ -0,0 +1,176 @@ +#!/usr/bin/env bash + +__scriptpath=$(cd "$(dirname "$0")"; pwd -P) +__init_tools_log=$__scriptpath/init-tools.log +__PACKAGES_DIR=$__scriptpath/packages +__TOOLRUNTIME_DIR=$__scriptpath/Tools + +__DOTNET_PATH=$__TOOLRUNTIME_DIR/dotnetcli +__DOTNET_CMD=$__DOTNET_PATH/dotnet +__DOTNET_VERSION=$(cat $__scriptpath/DotnetCLIVersion.txt) + +if [ -z "$__BUILDTOOLS_SOURCE" ]; then __BUILDTOOLS_SOURCE=https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json; fi +__BUILD_TOOLS_PACKAGE_VERSION=$(cat $__scriptpath/BuildToolsVersion.txt) + + +__BUILD_TOOLS_PATH=$__PACKAGES_DIR/microsoft.dotnet.buildtools/$__BUILD_TOOLS_PACKAGE_VERSION/lib +__PROJECT_JSON_PATH=$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION +__PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json +__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }" +__INIT_TOOLS_DONE_MARKER=$__PROJECT_JSON_PATH/done + +# Extended version of platform detection logic from dotnet/cli/scripts/obtain/dotnet-install.sh 16692fc +get_current_linux_name() { + # Detect Distro + if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 16.04)" -eq 1 ]; then + echo "ubuntu.16.04" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 16.10)" -eq 1 ]; then + echo "ubuntu.16.10" + return 0 + fi + + echo "ubuntu" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then + echo "centos" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then + echo "rhel" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then + echo "debian" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 alpine)" -eq 1 ]; then + echo "alpine" + return 0 + elif [ "$(cat /etc/*-release | grep -cim1 fedora)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 23)" -eq 1 ]; then + echo "fedora.23" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 24)" -eq 1 ]; then + echo "fedora.24" + return 0 + fi + elif [ "$(cat /etc/*-release | grep -cim1 opensuse)" -eq 1 ]; then + if [ "$(cat /etc/*-release | grep -cim1 13.2)" -eq 1 ]; then + echo "opensuse.13.2" + return 0 + fi + if [ "$(cat /etc/*-release | grep -cim1 42.1)" -eq 1 ]; then + echo "opensuse.42.1" + return 0 + fi + fi + + # Cannot determine Linux distribution, assuming Ubuntu 14.04. + echo "ubuntu" + return 0 +} + +if [ -z "$__DOTNET_PKG" ]; then +OSName=$(uname -s) + case $OSName in + Darwin) + OS=OSX + __DOTNET_PKG=dotnet-dev-osx-x64 + ulimit -n 2048 + ;; + + Linux) + __DOTNET_PKG="dotnet-dev-$(get_current_linux_name)-x64" + OS=Linux + ;; + + *) + echo "Unsupported OS '$OSName' detected. Downloading ubuntu-x64 tools." + OS=Linux + __DOTNET_PKG=dotnet-dev-ubuntu-x64 + ;; + esac +fi + +if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then + __PATCH_CLI_NUGET_FRAMEWORKS=0 + + if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi + echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log + + if [ ! -e $__DOTNET_PATH ]; then + + mkdir -p "$__DOTNET_PATH" + + if [ -n "$DOTNET_TOOLSET_DIR" ] && [ -d "$DOTNET_TOOLSET_DIR/$__DOTNET_VERSION" ]; then + echo "Copying $DOTNET_TOOLSET_DIR/$__DOTNET_VERSION to $__DOTNET_PATH" >> $__init_tools_log + cp -r $DOTNET_TOOLSET_DIR/$__DOTNET_VERSION/* $__DOTNET_PATH + elif [ -n "$DOTNET_TOOL_DIR" ] && [ -d "$DOTNET_TOOL_DIR" ]; then + echo "Copying $DOTNET_TOOL_DIR to $__DOTNET_PATH" >> $__init_tools_log + cp -r $DOTNET_TOOL_DIR/* $__DOTNET_PATH + else + echo "Installing dotnet cli..." + echo "The dotnet cli is a large file it may take a few minutes ..." + ./scripts/dotnet-install.sh --install-dir "$__DOTNET_PATH" --architecture "x64" --runtime-id "linux-x64" --version "$__DOTNET_VERSION" + fi + fi + + if [ ! -e $__DOTNET_TOOLS_PATH ]; then + + mkdir -p "$__DOTNET_PATH" + + if [ -n "$DOTNET_TOOLSET_DIR" ] && [ -d "$DOTNET_TOOLSET_DIR/$__DOTNET_TOOLS_VERSION" ]; then + echo "Copying $DOTNET_TOOLSET_DIR/$__DOTNET_TOOLS_VERSION to $__DOTNET_TOOLS_PATH" >> $__init_tools_log + cp -r $DOTNET_TOOLSET_DIR/$__DOTNET_VERSION/* $__DOTNET_PATH + elif [ -n "$DOTNET_TOOL_DIR" ] && [ -d "$DOTNET_TOOL_DIR" ]; then + echo "Copying $DOTNET_TOOL_DIR to $__DOTNET_TOOLS_PATH" >> $__init_tools_log + cp -r $DOTNET_TOOL_DIR/* $__DOTNET_PATH + else + echo "Installing dotnet cli..." + echo "The dotnet cli is a large file it may take a few minutes ..." + ./scripts/dotnet-install.sh --channel "release/2.0.0" --install-dir "$__DOTNET_PATH" --architecture "x64" --runtime-id "linux-x64" --version "$__DOTNET_VERSION" + fi + fi + + if [ -n "$BUILD_TOOLS_TOOLSET_DIR" ] && [ -d "$BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION" ]; then + echo "Copying $BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION to $__TOOLRUNTIME_DIR" >> $__init_tools_log + cp -r $BUILD_TOOLS_TOOLSET_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/* $__TOOLRUNTIME_DIR + elif [ -n "$BUILD_TOOLS_TOOL_DIR" ] && [ -d "$BUILD_TOOLS_TOOL_DIR" ]; then + echo "Copying $BUILD_TOOLS_TOOL_DIR to $__TOOLRUNTIME_DIR" >> $__init_tools_log + cp -r $BUILD_TOOLS_TOOL_DIR/* $__TOOLRUNTIME_DIR + else + if [ ! -d "$__PROJECT_JSON_PATH" ]; then mkdir "$__PROJECT_JSON_PATH"; fi + echo $__PROJECT_JSON_CONTENTS > "$__PROJECT_JSON_FILE" + + if [ ! -e $__BUILD_TOOLS_PATH ]; then + echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..." + echo "Running: $__DOTNET_CMD restore \"$__PROJECT_JSON_FILE\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE" >> $__init_tools_log + $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE >> $__init_tools_log + if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."1>&2; fi + fi + + echo "Initializing BuildTools..." + echo "Running: $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR" >> $__init_tools_log + $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log + if [ "$?" != "0" ]; then + echo "ERROR: An error occured when trying to initialize the tools. Please check '$__init_tools_log' for more details."1>&2 + exit 1 + fi + fi + + if [ $__PATCH_CLI_NUGET_FRAMEWORKS -eq 1 ]; then + echo "Updating CLI NuGet Frameworks map..." + cp $__TOOLRUNTIME_DIR/NuGet.Frameworks.dll $__TOOLRUNTIME_DIR/dotnetcli/sdk/$__DOTNET_VERSION >> $__init_tools_log + if [ "$?" != "0" ]; then + echo "ERROR: An error occured when updating Nuget for CLI . Please check '$__init_tools_log' for more details."1>&2 + exit 1 + fi + fi + + touch $__INIT_TOOLS_DONE_MARKER + + echo "Done initializing tools." +else + echo "Tools are already initialized" +fi \ No newline at end of file diff --git a/mono/FSharp.Compiler.Private/Makefile b/mono/FSharp.Compiler.Private/Makefile new file mode 100644 index 0000000000..88a3d797b0 --- /dev/null +++ b/mono/FSharp.Compiler.Private/Makefile @@ -0,0 +1,10 @@ +NAME=FSharp.Compiler.Private +ASSEMBLY = $(NAME).dll +TOKEN=$(SIGN_TOKEN) + +include ../config.make + +install: install-sdk-lib + + + diff --git a/mono/build.bat b/mono/build.bat new file mode 100644 index 0000000000..330f9fd108 --- /dev/null +++ b/mono/build.bat @@ -0,0 +1,45 @@ +@echo off + +:: Check prerequisites +set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" +if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe" +if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe" +if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe" +if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. Please see http://www.microsoft.com/en-us/download/details.aspx?id=40760. && goto :eof + +set msbuildflags=/maxcpucount +set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe" +if not exist %_ngenexe% echo Note: Could not find ngen.exe. + +::Build + +%_ngenexe% install .\.nuget\NuGet.exe + +.\.nuget\NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget\nuget.config +@if ERRORLEVEL 1 echo Error: Nuget restore failed && goto :failure + +%_ngenexe% install packages\FSharp.Compiler.Tools.4.0.1.21\tools\fsc.exe + +set BUILD_NET40=1 +set BUILD_NET40_FSHARP_CORE=1 +set BUILD_PORTABLE=1 +set TEST_NET40_COREUNIT_SUITE=1 +set TEST_PORTABLE_COREUNIT_SUITE=1 + +%_msbuildexe% src\fsharp-proto-build.proj +@if ERRORLEVEL 1 echo Error: "%_msbuildexe% src\fsharp-proto-build.proj" failed && goto :failure + +%_ngenexe% install Proto\net440\bin\fsc-proto.exe + +%_msbuildexe% %msbuildflags% build-everything.proj /p:TargetDotnetProfile=net40 /p:Configuration=Release +@if ERRORLEVEL 1 echo Error: "%_msbuildexe% %msbuildflags% src\fsharp-library-build.proj /p:TargetDotnetProfile=net40 /p:Configuration=Release" failed && goto :failure + +%_msbuildexe% %msbuildflags% src/fsharp/FSharp.Core/FSharp.Core.fsproj /p:TargetDotnetProfile=monotouch /p:Configuration=Release /p:KeyFile=..\..\..\mono\mono.snk +@if ERRORLEVEL 1 echo Error: "%_msbuildexe% %msbuildflags% src\fsharp-library-build.proj /p:TargetDotnetProfile=monotouch /p:Configuration=Release /p:KeyFile=..\..\..\mono.snk" failed && goto :failure + + +@echo "Finished" +goto :eof + +:failure +exit /b 1 diff --git a/mono/config.make.in b/mono/config.make.in new file mode 100644 index 0000000000..ef700f132b --- /dev/null +++ b/mono/config.make.in @@ -0,0 +1,311 @@ +DEFAULT: all + +.PHONY: install-sdk-lib install-gac-lib + +prefix := @prefix@ +topdir := @abs_top_srcdir@/ +builddir := @abs_top_builddir@/ +libdir := ${prefix}/lib/ +bindir := ${prefix}/bin/ +monobindir := @MONOBINDIR@ +monolibdir := @MONOLIBDIR@ +monogacdir := @MONOGACDIR@ + +monogacdir40 := @MONOGACDIR40@ + +pclenabled47 := @PCLENABLED47@ +pclenabled7 := @PCLENABLED7@ +pclenabled78 := @PCLENABLED78@ +pclenabled259 := @PCLENABLED259@ +monotouchenabled := @MONOTOUCHENABLED@ +monodroidenabled := @MONODROIDENABLED@ +xamarinmacenabled := @XAMARINMACENABLED@ + +monodir := ${libdir}mono + +TargetDotnetProfile = net40 +CONFIG = release +Configuration = Release +DISTVERSION = 201011 + +# Version number mappings for various versions of FSharp.Core + +ifeq (x-$(TargetDotnetProfile)-,x-net40-) + +ifeq (x-$(FSharpCoreBackVersion)-,x--) +VERSION = 4.4.1.0 +PKGINSTALL = yes +REFASSEMPATH = .NETFramework/v4.0 +outsuffix = $(TargetDotnetProfile) +endif + +ifeq (x-$(FSharpCoreBackVersion)-,x-3.0-) +VERSION = 4.3.0.0 +REFASSEMPATH = .NETFramework/v4.0 +outsuffix = fsharp30/$(TargetDotnetProfile) +endif + +ifeq (x-$(FSharpCoreBackVersion)-,x-3.1-) +VERSION = 4.3.1.0 +REFASSEMPATH = .NETFramework/v4.0 +outsuffix = fsharp31/$(TargetDotnetProfile) +endif + +ifeq (x-$(FSharpCoreBackVersion)-,x-4.0-) +VERSION = 4.4.0.0 +REFASSEMPATH = .NETFramework/v4.0 +outsuffix = fsharp40/$(TargetDotnetProfile) +endif + +endif + +ifeq (x-$(TargetDotnetProfile)-,x-monoandroid10+monotouch10+xamarinios10-) +VERSION = 3.98.41.0 +outsuffix = $(TargetDotnetProfile) +endif + + +ifeq (x-$(TargetDotnetProfile)-,x-xamarinmacmobile-) +VERSION = 3.99.41.0 +outsuffix = $(TargetDotnetProfile) +endif + +ifeq (x-$(TargetDotnetProfile)-,x-portable47-) +VERSION = 3.47.41.0 +PCLPATH = .NETPortable +outsuffix = $(TargetDotnetProfile) +endif + +ifeq (x-$(TargetDotnetProfile)-,x-portable7-) +VERSION = 3.7.41.0 +PCLPATH = .NETCore +outsuffix = $(TargetDotnetProfile) +endif + +ifeq (x-$(TargetDotnetProfile)-,x-portable78-) +VERSION = 3.78.41.0 +PCLPATH = .NETCore +outsuffix = $(TargetDotnetProfile) +endif + +ifeq (x-$(TargetDotnetProfile)-,x-portable259-) +VERSION = 3.259.41.0 +PCLPATH = .NETCore +outsuffix = $(TargetDotnetProfile) +endif + + +FSCORE_DELAY_SIGN_TOKEN = b03f5f7f11d50a3a +SIGN_TOKEN = f536804aa0eb945b + +tmpdir = .libs/$(Configuration)/ +outdir = $(builddir)$(Configuration)/$(outsuffix)/bin/ + +INSTALL = $(SHELL) $(topdir)/mono/install-sh +INSTALL_BIN = $(INSTALL) -c -m 755 +INSTALL_LIB = $(INSTALL_BIN) + +XBUILD = @XBUILD@ + +EXTRA_DIST = configure +NO_DIST = .gitignore lib/debug lib/proto lib/release + + +# Install .optdata/.sigdata if they exist (they go alongside FSharp.Core) +# Install the .Targets file. The XBuild targets file gets installed into the place(s) expected for standard F# project +# files. For F# 2.0 project files this is +# /usr/lib/mono/Microsoft F#/v4.0/Microsoft.FSharp.Targets +# For F# 3.0 project files this is +# /usr/lib/mono/Microsoft SDKs/F#/3.0/Framework/v4.0/Microsoft.FSharp.Targets +# For F# 3.1 project files this is +# /usr/lib/mono/xbuild/Microsoft/VisualStudio/v12.0/FSharp/Microsoft.FSharp.Targets +# For F# 4.0 project files this is +# /usr/lib/mono/xbuild/Microsoft/VisualStudio/v14.0/FSharp/Microsoft.FSharp.Targets +# For F# 4.1 project files this is +# /usr/lib/mono/xbuild/Microsoft/VisualStudio/v15.0/FSharp/Microsoft.FSharp.Targets +# +# Here 12.0/14.0/15.0 is 'VisualStudioVersion'. xbuild should set this to 11.0/12.0/14.0/15.0, copying MSBuild. +# +# We put the F# targets and link the SDK DLLs for all these locations +# +# We put a forwarding targets file into all three locations. We also put one in +# .../lib/mono/xbuild/Microsoft/VisualStudio/v/FSharp/Microsoft.FSharp.Targets +# since this is the location if 'xbuild' fails to set VisualStudioVersion. +# +install-sdk-lib: + @echo "Installing $(ASSEMBLY)" + @mkdir -p $(DESTDIR)$(monodir)/fsharp + @if test "x$(DELAY_SIGN)" = "x1"; then \ + echo "Signing $(outdir)$(ASSEMBLY) with Mono key"; \ + $(monobindir)/sn -q -R $(outdir)$(ASSEMBLY) $(topdir)mono/mono.snk; \ + fi + @if test x-$(NAME) = x-FSharp.Compiler.Private; then \ + echo "Installing extra dependency System.Collections.Immutable.dll to $(DESTDIR)$(monodir)/fsharp/"; \ + $(INSTALL_LIB) $(outdir)System.Collections.Immutable.dll $(DESTDIR)$(monodir)/fsharp/; \ + echo "Installing extra dependency System.Reflection.Metadata.dll to $(DESTDIR)$(monodir)/fsharp/"; \ + $(INSTALL_LIB) $(outdir)System.Reflection.Metadata.dll $(DESTDIR)$(monodir)/fsharp/; \ + fi + @if test x-$(NAME) = x-FSharp.Build; then \ + echo "Installing Microsoft.FSharp.Targets and Microsoft.Portable.FSharp.Targets into install locations matching Visual Studio"; \ + echo " --> $(DESTDIR)$(monodir)/fsharp/"; \ + echo " --> $(DESTDIR)$(monodir)/Microsoft\ F#/v4.0/"; \ + echo " --> $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.0/Framework/v4.0/"; \ + echo " --> $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.1/Framework/v4.0/"; \ + echo " --> $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.0/Framework/v4.0/"; \ + echo " --> $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.1/Framework/v4.0/"; \ + echo " --> $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v/FSharp/"; \ + echo " --> $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v11.0/FSharp/"; \ + echo " --> $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v12.0/FSharp/"; \ + echo " --> $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v14.0/FSharp/"; \ + echo " --> $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v15.0/FSharp/"; \ + \ + mkdir -p $(tmpdir); \ + mkdir -p $(DESTDIR)$(monodir)/Microsoft\ F#/v4.0/; \ + mkdir -p $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.0/Framework/v4.0/; \ + mkdir -p $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.1/Framework/v4.0/; \ + mkdir -p $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.0/Framework/v4.0/; \ + mkdir -p $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.1/Framework/v4.0/; \ + mkdir -p $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v/FSharp/; \ + mkdir -p $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v11.0/FSharp/; \ + mkdir -p $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v12.0/FSharp/; \ + mkdir -p $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v14.0/FSharp/; \ + mkdir -p $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v15.0/FSharp/; \ + \ + $(INSTALL_LIB) $(outdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/fsharp/; \ + \ + echo '' > $(tmpdir)Microsoft.FSharp.Targets; \ + echo ' ' >> $(tmpdir)Microsoft.FSharp.Targets; \ + echo '' >> $(tmpdir)Microsoft.FSharp.Targets; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ F#/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.0/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.1/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.0/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.1/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v11.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v12.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v14.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v15.0/FSharp/; \ + \ + echo '' > $(tmpdir)Microsoft.Portable.FSharp.Targets; \ + echo ' ' >> $(tmpdir)Microsoft.Portable.FSharp.Targets; \ + echo '' >> $(tmpdir)Microsoft.Portable.FSharp.Targets; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ F#/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.0/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/3.1/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.0/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/Microsoft\ SDKs/F#/4.1/Framework/v4.0/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v11.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v12.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v14.0/FSharp/; \ + $(INSTALL_LIB) $(tmpdir)Microsoft.Portable.FSharp.Targets $(DESTDIR)$(monodir)/xbuild/Microsoft/VisualStudio/v15.0/FSharp/; \ + fi + @if test x-$(outsuffix) = x-net40; then \ + if test -e $(outdir)$(NAME).dll; then \ + echo "Installing $(outdir)$(NAME).dll to $(DESTDIR)$(monodir)/fsharp/"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)$(NAME).dll $(DESTDIR)$(monodir)/fsharp/; \ + fi; \ + if test -e $(outdir)$(NAME).dll.config; then \ + echo "Installing $(outdir)$(NAME).dll to $(DESTDIR)$(monodir)/fsharp/"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)$(NAME).dll.config $(DESTDIR)$(monodir)/fsharp/; \ + fi; \ + if test -e $(outdir)$(NAME).xml; then \ + echo "Installing $(outdir)$(NAME).xml into $(DESTDIR)$(monodir)/fsharp/"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)$(NAME).xml $(DESTDIR)$(monodir)/fsharp/; \ + fi; \ + if test -e $(outdir)$(NAME).sigdata; then \ + echo "Installing $(outdir)$(NAME).sigdata into $(DESTDIR)$(monodir)/fsharp/"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)$(NAME).sigdata $(DESTDIR)$(monodir)/fsharp/; \ + fi; \ + if test -e $(outdir)$(NAME).optdata; then \ + echo "Installing $(outdir)$(NAME).optdata into $(DESTDIR)$(monodir)/fsharp/"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/; \ + $(INSTALL_LIB) $(outdir)$(NAME).optdata $(DESTDIR)$(monodir)/fsharp/; \ + fi; \ + fi + @if test x-$(NAME) = x-FSharp.Core && test x-$(REFASSEMPATH) != x-; then \ + echo "Installing FSharp.Core $(VERSION) reference assembly into api location"; \ + echo " --> $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION)"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION); \ + $(INSTALL_LIB) $(outdir)$(NAME).xml $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).sigdata $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).optdata $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).dll $(DESTDIR)$(monodir)/fsharp/api/$(REFASSEMPATH)/$(VERSION)/; \ + fi + @if test x-$(NAME) = x-FSharp.Core && test x-$(PCLPATH) != x-; then \ + echo "Installing FSharp.Core $(VERSION) reference assembly into api location"; \ + echo " --> $(DESTDIR)$(monodir)/fsharp/$(PCLPATH)/$(VERSION)"; \ + mkdir -p $(DESTDIR)$(monodir)/fsharp/api/$(PCLPATH)/$(VERSION); \ + $(INSTALL_LIB) $(outdir)$(NAME).xml $(DESTDIR)$(monodir)/fsharp/api/$(PCLPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).sigdata $(DESTDIR)$(monodir)/fsharp/api/$(PCLPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).optdata $(DESTDIR)$(monodir)/fsharp/api/$(PCLPATH)/$(VERSION)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).dll $(DESTDIR)$(monodir)/fsharp/api/$(PCLPATH)/$(VERSION)/; \ + fi + +# Install the library binaries in the GAC directory, +install-gac-lib: + $(eval TARGET = "4.5") + @echo "Installing $(ASSEMBLY)" + @if test "x$(DELAY_SIGN)" = "x1"; then \ + echo "Signing $(outdir)$(ASSEMBLY) with Mono key"; \ + $(monobindir)/sn -q -R $(outdir)$(ASSEMBLY) $(topdir)mono/mono.snk; \ + fi + @if test -e $(outdir)$(NAME).dll; then \ + if test x-$(NAME) = x-FSharp.Core && test x-$(PKGINSTALL) = x-yes; then \ + echo "Using gacutil to install $(outdir)$(ASSEMBLY) into GAC root $(DESTDIR)$(libdir) as package $(TARGET)"; \ + $(monobindir)/gacutil -i $(outdir)$(ASSEMBLY) -root $(DESTDIR)$(libdir) -package $(TARGET); \ + else \ + echo "Installing $(outdir)$(NAME).dll to $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/"; \ + mkdir -p $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).dll $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + fi; \ + fi + + @if test -e $(outdir)$(NAME).xml; then \ + echo "Installing $(outdir)$(NAME).xml into $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/"; \ + mkdir -p $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).xml $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + if test x-$(PKGINSTALL) = x-yes && test x-$(NAME) = x-FSharp.Core; then \ + echo "Using linking to ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).xml to install $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).xml"; \ + ln -fs ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).xml $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).xml; \ + fi; \ + fi + @if test -e $(outdir)$(NAME).sigdata; then \ + echo "Installing $(outdir)$(NAME).sigdata into $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/"; \ + mkdir -p $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).sigdata $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + if test x-$(PKGINSTALL) = x-yes; then \ + echo "Using linking to ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).sigdata to install $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).sigdata"; \ + ln -fs ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).sigdata $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).sigdata; \ + fi; \ + fi + @if test -e $(outdir)$(NAME).optdata; then \ + echo "Installing $(outdir)$(NAME).optdata into $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/"; \ + mkdir -p $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + $(INSTALL_LIB) $(outdir)$(NAME).optdata $(DESTDIR)$(monodir)/gac/$(NAME)/$(VERSION)__$(TOKEN)/; \ + if test x-$(PKGINSTALL) = x-yes; then \ + echo "Using linking to ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).optdata to install $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).optdata"; \ + ln -fs ../gac/$(NAME)/$(VERSION)__$(TOKEN)/$(NAME).optdata $(DESTDIR)$(libdir)mono/$(TARGET)/$(NAME).optdata; \ + fi; \ + fi + + +# The binaries fsc.exe and fsi.exe only get installed for Mono 4.5 profile +# This also installs 'fsharpc' and 'fsharpi' and 'fsharpiAnyCpu' +install-bin: + chmod +x $(outdir)$(ASSEMBLY) + sed -e 's,[@]DIR[@],$(monodir)/fsharp,g' -e 's,[@]TOOL[@],$(ASSEMBLY),g' -e 's,[@]MONOBINDIR[@],$(monobindir),g' < $(topdir)mono/launcher > $(outdir)$(subst fs,fsharp,$(NAME)) + chmod +x $(outdir)$(subst fs,fsharp,$(NAME)) + @mkdir -p $(DESTDIR)$(monodir)/fsharp + @mkdir -p $(DESTDIR)$(bindir) + $(INSTALL_BIN) $(outdir)$(ASSEMBLY) $(DESTDIR)$(monodir)/fsharp + $(INSTALL_BIN) $(outdir)$(ASSEMBLY).config $(DESTDIR)$(monodir)/fsharp + $(INSTALL_BIN) $(outdir)$(subst fs,fsharp,$(NAME)) $(DESTDIR)$(bindir) + + diff --git a/mono/prepare-mono.sh b/mono/prepare-mono.sh new file mode 100755 index 0000000000..9354510319 --- /dev/null +++ b/mono/prepare-mono.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env sh + +# OS detection + +OSName=$(uname -s) +case $OSName in + Darwin) + OS=OSX + ;; + + Linux) + OS=Linux + ;; + + *) + echo "Unsupported OS '$OSName' detected. Cannot continue with build, the scripts must be updated to support this OS." + exit 1 + ;; +esac + +# On Linux (or at least, Ubuntu), when building with Mono, need to install the mono-devel package first. +if [ $OS = 'Linux' ]; then + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list + sudo apt-get update + sudo apt-get -y install mono-devel +fi + +# Check if SSL certificates have been imported into Mono's certificate store. +# If certs haven't been installed, some/all of the Nuget packages will fail to restore. +#if [ $('certmgr -list -c Trust | grep -c -F "X.509"') -le 1 ]; then +# echo "No SSL certificates installed so unable to restore NuGet packages." >&2; +# echo "Run 'mozroots --sync --import' to install certificates to Mono's certificate store." >&2; +# exit 1 +#fi + +# Restore NuGet packages (needed for compiler bootstrap and tests). +mono .nuget/NuGet.exe restore packages.config -PackagesDirectory packages -ConfigFile .nuget/NuGet.Config + +(if test x-$BUILD_CORECLR = x-1; then \ + sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'; \ + sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893; \ + sudo apt-get update; \ + sudo apt-get -y install dotnet-dev-1.0.0-preview2-003131; \ + (cd tests/fsharp; mono ../../.nuget/NuGet.exe restore project.json -PackagesDirectory ../../packages -ConfigFile ../../.nuget/NuGet.Config); \ + ./init-tools.sh; \ + echo "------ start log"; \ + cat ./init-tools.log; echo "------ end log"; \ +fi) + +(if test x-$BUILD_PROTO_WITH_CORECLR_LKG = x-1; then \ + (cd lkg/fsc && dotnet restore --packages ../packages && dotnet publish project.json -o ../Tools/lkg -r ubuntu.14.04-x64); \ + (cd lkg/fsi && dotnet restore --packages ../packages && dotnet publish project.json -o ../Tools/lkg -r ubuntu.14.04-x64); \ +fi) + +#TODO: work out how to avoid the need for this +echo "chmod u+x packages/FSharp.Compiler.Tools.4.1.23/tools/fsi.exe" +echo "chmod u+x packages/FsLexYacc.7.0.4/build/fslex.exe" +echo "chmod u+x packages/FsLexYacc.7.0.4/build/fsyacc.exe" +chmod u+x packages/FSharp.Compiler.Tools.4.1.23/tools/fsi.exe +chmod u+x packages/FsLexYacc.7.0.6/build/fslex.exe +chmod u+x packages/FsLexYacc.7.0.6/build/fsyacc.exe + +# The FSharp.Compiler.Tools package doesn't work correctly unless a proper install of F# has been done on the machine. +# OSX can skip this because the OSX Mono installer includes F#. +if [ $OS != 'OSX' ]; then + sudo apt-get -y install fsharp +fi + +# "access to the path /etc/mono/registry/last-time is denied" +# On non-OSX systems, may need to create Mono's registry folder to avoid exceptions during builds. +# This doesn't seem to be necessary on OSX, as the folder is created by the installer. +if [ $OS != 'OSX' ]; then + # This registry folder path is correct for Linux; + # on OSX the folder is /Library/Frameworks/Mono.framework/Versions/Current/etc/mono/registry + # and may be different for *BSD systems. + __MonoRegistryDir="/etc/mono/registry" + if [ ! -d "$__MonoRegistryDir" ]; then + echo "Mono registry directory does not exist (it may not have been created yet)." + echo "The directory needs to be created now; superuser permissions are required for this." + { sudo -- sh -c "mkdir -p $__MonoRegistryDir && chmod uog+rw $__MonoRegistryDir"; } || { echo "Unable to create/chmod Mono registry directory '$__MonoRegistryDir'." >&2; } + fi +fi diff --git a/netci.groovy b/netci.groovy new file mode 100644 index 0000000000..ba971aaf9c --- /dev/null +++ b/netci.groovy @@ -0,0 +1,95 @@ +import jobs.generation.Utilities; +import jobs.generation.JobReport; + +def project = GithubProject +def branch = GithubBranchName + +def osList = ['Windows_NT', 'Ubuntu14.04'] //, 'OSX'], 'CentOS7.1' + +def static getBuildJobName(def configuration, def os) { + return configuration.toLowerCase() + '_' + os.toLowerCase() +} + +[true, false].each { isPullRequest -> + osList.each { os -> + def configurations = ['Debug', 'Release_ci_part1', 'Release_ci_part2', 'Release_ci_part3', 'Release_net40_no_vs' ]; + if (os != 'Windows_NT') { + // Only build one configuration on Linux/... so far + configurations = ['Release']; + } + configurations.each { configuration -> + + def lowerConfiguration = configuration.toLowerCase() + + // Calculate job name + def jobName = getBuildJobName(configuration, os) + + def buildCommand = ''; + + def buildFlavor= ''; + if (configuration == "Debug") { + buildFlavor = "debug" + build_args = "" + } + else { + buildFlavor = "release" + if (configuration == "Release_ci_part1") { + build_args = "ci_part1" + } + else if (configuration == "Release_ci_part2") { + build_args = "ci_part2" + } + else if (configuration == "Release_ci_part3") { + build_args = "ci_part3" + } + else if (configuration == "Release_net40_no_vs") { + build_args = "net40" + } + else { + build_args = "ci" + } + } + + if (os == 'Windows_NT') { + buildCommand = ".\\build.cmd ${buildFlavor} ${build_args}" + } + else { + buildCommand = "./build.sh ${buildFlavor} ${build_args}" + } + + def newJobName = Utilities.getFullJobName(project, jobName, isPullRequest) + def newJob = job(newJobName) { + steps { + if (os == 'Windows_NT') { + batchFile(""" +echo *** Build Visual F# Tools *** + +.\\build.cmd ${buildFlavor} ${build_args}""") + } + else { + // Shell + shell(buildCommand) + } + } + } + + // TODO: set to false after tests are fully enabled + def skipIfNoTestFiles = true + + def affinity = configuration == 'Release_net40_no_vs' ? 'latest-or-auto' : (os == 'Windows_NT' ? 'latest-or-auto-dev15-0' : 'latest-or-auto') + Utilities.setMachineAffinity(newJob, os, affinity) + Utilities.standardJobSetup(newJob, project, isPullRequest, "*/${branch}") + Utilities.addArchival(newJob, "tests/TestResults/*.*", "", skipIfNoTestFiles, false) + Utilities.addArchival(newJob, "${buildFlavor}/**") + + if (isPullRequest) { + Utilities.addGithubPRTriggerForBranch(newJob, branch, "${os} ${configuration} Build") + } + else { + Utilities.addGithubPushTrigger(newJob) + } + } + } +} + +JobReport.Report.generateJobReport(out) diff --git a/nuget/FSharp.Compiler.Service.MSBuild.v12.template b/nuget/FSharp.Compiler.Service.MSBuild.v12.template deleted file mode 100644 index 1a3473ec89..0000000000 --- a/nuget/FSharp.Compiler.Service.MSBuild.v12.template +++ /dev/null @@ -1,16 +0,0 @@ -type file -id FSharp.Compiler.Service.MSBuild.v12 -description - Adds legacy MSBuild 12.0 support to the F# compiler services package for - resolving references such as #r "System, Version=4.1.0.0,..." -authors - Microsoft Corporation, Dave Thomas, Anh-Dung Phan, Tomas Petricek -summary - Adds legacy MSBuild 12.0 support to the F# compiler services package -licenseurl https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE -projecturl https://github.com/fsharp/FSharp.Compiler.Service -iconurl https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png -tags - F#, fsharp, interactive, compiler, editor -files - ../bin/v4.5/FSharp.Compiler.Service.MSBuild.v12.dll ==> lib/net45 diff --git a/nuget/FSharp.Compiler.Service.ProjectCracker.template b/nuget/FSharp.Compiler.Service.ProjectCracker.template deleted file mode 100644 index cadb13b569..0000000000 --- a/nuget/FSharp.Compiler.Service.ProjectCracker.template +++ /dev/null @@ -1,21 +0,0 @@ -type file -id FSharp.Compiler.Service.ProjectCracker -description - Adds F# project cracking capabilities. -authors - Microsoft Corporation, Robin Neatherway -summary - Cracking projects -licenseurl https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE -projecturl https://github.com/fsharp/FSharp.Compiler.Service -iconurl https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png -tags - F#, fsharp, msbuild, editor -files - ../src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCracker.targets ==> build/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerTool.exe ==> utilities/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerTool.exe.config ==> utilities/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerTool.?db ==> utilities/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll ==> lib/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.xml ==> lib/net45 - ../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.?db ==> lib/net45 diff --git a/nuget/FSharp.Compiler.Service.template b/nuget/FSharp.Compiler.Service.template deleted file mode 100644 index 9c3b7a4eda..0000000000 --- a/nuget/FSharp.Compiler.Service.template +++ /dev/null @@ -1,24 +0,0 @@ -type file -id FSharp.Compiler.Service -description - The F# compiler services package contains a custom build of the F# compiler that - exposes additional functionality for implementing F# language bindings, additional - tools based on the compiler or refactoring tools. The package also includes F# - interactive service that can be used for embedding F# scripting into your applications. -authors - Microsoft Corporation, Dave Thomas, Anh-Dung Phan, Tomas Petricek -summary - F# compiler services for creating IDE tools, language extensions and for F# embedding. -licenseurl https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE -projecturl https://github.com/fsharp/FSharp.Compiler.Service -iconurl https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png -tags - F#, fsharp, interactive, compiler, editor -files - ../bin/v4.5/FSharp.Compiler.Service.dll ==> lib/net45 - ../bin/v4.5/FSharp.Compiler.Service.xml ==> lib/net45 - ../bin/v4.5/FSharp.Compiler.Service.?db ==> lib/net45 - ../bin/v4.5/FSharp.Compiler.Service.dll.?db ==> lib/net45 -dependencies - System.Collections.Immutable >= LOCKEDVERSION - System.Reflection.Metadata >= LOCKEDVERSION \ No newline at end of file diff --git a/packages.config b/packages.config new file mode 100644 index 0000000000..5fb1b04cfb --- /dev/null +++ b/packages.config @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/paket.dependencies b/paket.dependencies deleted file mode 100644 index 9dc81adc3e..0000000000 --- a/paket.dependencies +++ /dev/null @@ -1,26 +0,0 @@ -frameworks: net45, netstandard16, netcoreapp10 - -# source https://www.myget.org/F/dotnet-core/api/v3/index.json -source https://www.nuget.org/api/v2/ - -nuget NUnit 2.6.3 -nuget NUnit.Runners 2.6.3 -nuget SQLite.Net-PCL 3.0.5 -nuget SQLite.Net.Platform.Generic 2.4.1 - -# build dependencies -# FAKE 4.53.0 is needed - latest FAKE invokes msbuild on Unix but on Mono 4.8.x that causes a failure with -nuget FAKE -nuget FSharp.Formatting -nuget SourceLink.Fake -nuget FsLexYacc -nuget FSharp.Core 4.0.0.1 -nuget FSharp.Compiler.Tools 4.1.17 -nuget System.ValueTuple 4.3.0 - -nuget System.Collections.Immutable 1.3.1 -nuget System.Reflection.Metadata 1.4.2 -nuget Microsoft.DiaSymReader.PortablePdb 1.2.0 -nuget Microsoft.DiaSymReader 1.1.0 - -github fsharp/FAKE modules/Octokit/Octokit.fsx \ No newline at end of file diff --git a/paket.lock b/paket.lock deleted file mode 100644 index 0e1f84c04b..0000000000 --- a/paket.lock +++ /dev/null @@ -1,190 +0,0 @@ -FRAMEWORK: NET45, NETSTANDARD16, NETCORE10 -NUGET - remote: https://www.nuget.org/api/v2 - FAKE (4.61) - FSharp.Compiler.Service (2.0.0.6) - FSharp.Compiler.Tools (4.1.17) - FSharp.Core (4.0.0.1) - FSharp.Formatting (2.14.4) - FSharp.Compiler.Service (2.0.0.6) - FSharpVSPowerTools.Core (>= 2.3 < 2.4) - FSharpVSPowerTools.Core (2.3) - FSharp.Compiler.Service (>= 2.0.0.3) - FsLexYacc (7.0.5) - FsLexYacc.Runtime (>= 7.0.5 < 7.1) - FsLexYacc.Runtime (7.0.5) - FSharp.Core (>= 3.1.2.5) - Microsoft.DiaSymReader (1.1) - System.Diagnostics.Debug (>= 4.0.11) - framework: net45, netstandard16 - System.Runtime (>= 4.1) - framework: net45, netstandard16 - System.Runtime.InteropServices (>= 4.1) - framework: net45, netstandard16 - Microsoft.DiaSymReader.PortablePdb (1.2) - Microsoft.DiaSymReader (>= 1.1) - framework: net45, netstandard16 - System.Collections (>= 4.3) - framework: net45, netstandard16 - System.Collections.Immutable (>= 1.3.1) - framework: net45, netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: net45, netstandard16 - System.Globalization (>= 4.3) - framework: net45, netstandard16 - System.IO (>= 4.3) - framework: net45, netstandard16 - System.Linq (>= 4.3) - framework: net45, netstandard16 - System.Reflection (>= 4.3) - framework: net45, netstandard16 - System.Reflection.Metadata (>= 1.4.2) - framework: net45, netstandard16 - System.Reflection.Primitives (>= 4.3) - framework: net45, netstandard16 - System.Runtime (>= 4.3) - framework: net45, netstandard16 - System.Runtime.Extensions (>= 4.3) - framework: net45, netstandard16 - System.Runtime.InteropServices (>= 4.3) - framework: net45, netstandard16 - System.Text.Encoding (>= 4.3) - framework: net45, netstandard16 - System.Threading (>= 4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (1.1) - Microsoft.NETCore.Targets (1.1) - NUnit (2.6.3) - NUnit.Runners (2.6.3) - Octokit (0.24) - runtime.native.System (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - runtime.native.System.IO.Compression (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - Microsoft.NETCore.Targets (>= 1.1) - SourceLink.Fake (1.1) - SQLite.Net-PCL (3.0.5) - SQLite.Net.Platform.Generic (2.4.1) - SQLite.Net-PCL - System.Buffers (4.3) - framework: net45, netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: netstandard16 - System.Diagnostics.Tracing (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Threading (>= 4.3) - framework: netstandard16 - System.Collections (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Collections.Immutable (1.3.1) - System.Collections (>= 4.3) - framework: netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: netstandard16 - System.Globalization (>= 4.3) - framework: netstandard16 - System.Linq (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.Extensions (>= 4.3) - framework: netstandard16 - System.Threading (>= 4.3) - framework: netstandard16 - System.Diagnostics.Debug (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Diagnostics.Tracing (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Globalization (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.IO (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Text.Encoding (>= 4.3) - framework: netstandard16 - System.Threading.Tasks (>= 4.3) - framework: netstandard16 - System.IO.Compression (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - runtime.native.System (>= 4.3) - framework: netstandard16 - runtime.native.System.IO.Compression (>= 4.3) - framework: netstandard16 - System.Buffers (>= 4.3) - framework: netstandard16 - System.Collections (>= 4.3) - framework: netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: netstandard16 - System.IO (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.Extensions (>= 4.3) - framework: netstandard16 - System.Runtime.Handles (>= 4.3) - framework: netstandard16 - System.Runtime.InteropServices (>= 4.3) - framework: netstandard16 - System.Text.Encoding (>= 4.3) - framework: netstandard16 - System.Threading (>= 4.3) - framework: netstandard16 - System.Threading.Tasks (>= 4.3) - framework: netstandard16 - System.Linq (4.3) - System.Collections (>= 4.3) - framework: netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.Extensions (>= 4.3) - framework: netstandard16 - System.Reflection (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.IO (>= 4.3) - framework: netstandard16 - System.Reflection.Primitives (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Reflection.Extensions (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Reflection (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Reflection.Metadata (1.4.2) - System.Collections (>= 4.3) - framework: netstandard16 - System.Collections.Immutable (>= 1.3.1) - framework: net45, netstandard16 - System.Diagnostics.Debug (>= 4.3) - framework: netstandard16 - System.IO (>= 4.3) - framework: netstandard16 - System.IO.Compression (>= 4.3) - framework: netstandard16 - System.Linq (>= 4.3) - framework: netstandard16 - System.Reflection (>= 4.3) - framework: netstandard16 - System.Reflection.Extensions (>= 4.3) - framework: netstandard16 - System.Reflection.Primitives (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.Extensions (>= 4.3) - framework: netstandard16 - System.Runtime.InteropServices (>= 4.3) - framework: netstandard16 - System.Text.Encoding (>= 4.3) - framework: netstandard16 - System.Text.Encoding.Extensions (>= 4.3) - framework: netstandard16 - System.Threading (>= 4.3) - framework: netstandard16 - System.Reflection.Primitives (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Globalization (>= 4.3) - framework: netstandard16 - System.Reflection (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime.Extensions (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.Handles (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Runtime.InteropServices (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Reflection (>= 4.3) - framework: netstandard16 - System.Reflection.Primitives (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: net45, >= net462, netstandard16 - System.Runtime.Handles (>= 4.3) - framework: netstandard16 - System.Text.Encoding (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Text.Encoding.Extensions (4.3) - framework: net45, netstandard16 - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.Text.Encoding (>= 4.3) - framework: netstandard16 - System.Threading (4.3) - System.Runtime (>= 4.3) - framework: netstandard16 - System.Threading.Tasks (>= 4.3) - framework: netstandard16 - System.Threading.Tasks (4.3) - Microsoft.NETCore.Platforms (>= 1.1) - framework: netstandard16 - Microsoft.NETCore.Targets (>= 1.1) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 - System.ValueTuple (4.3) - System.Collections (>= 4.3) - framework: netstandard16 - System.Resources.ResourceManager (>= 4.3) - framework: netstandard16 - System.Runtime (>= 4.3) - framework: netstandard16 -GITHUB - remote: fsharp/FAKE - modules/Octokit/Octokit.fsx (1d6610b1e593270db040fc30c9c06d15fb57388c) - Octokit (>= 0.20) \ No newline at end of file diff --git a/scripts/dotnet-install.ps1 b/scripts/dotnet-install.ps1 new file mode 100644 index 0000000000..93d964540f --- /dev/null +++ b/scripts/dotnet-install.ps1 @@ -0,0 +1,503 @@ +# +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +<# +.SYNOPSIS + Installs dotnet cli +.DESCRIPTION + Installs dotnet cli. If dotnet installation already exists in the given directory + it will update it only if the requested version differs from the one already installed. +.PARAMETER Channel + Default: LTS + Download from the Channel specified. Possible values: + - Current - most current release + - LTS - most current supported release + - 2-part version in a format A.B - represents a specific release + examples: 2.0; 1.0 + - Branch name + examples: release/2.0.0; Master +.PARAMETER Version + Default: latest + Represents a build version on specific channel. Possible values: + - latest - most latest build on specific channel + - coherent - most latest coherent build on specific channel + coherent applies only to SDK downloads + - 3-part version in a format A.B.C - represents specific version of build + examples: 2.0.0-preview2-006120; 1.1.0 +.PARAMETER InstallDir + Default: %LocalAppData%\Microsoft\dotnet + Path to where to install dotnet. Note that binaries will be placed directly in a given directory. +.PARAMETER Architecture + Default: - this value represents currently running OS architecture + Architecture of dotnet binaries to be installed. + Possible values are: , x64 and x86 +.PARAMETER SharedRuntime + Default: false + Installs just the shared runtime bits, not the entire SDK +.PARAMETER DryRun + If set it will not perform installation but instead display what command line to use to consistently install + currently requested version of dotnet cli. In example if you specify version 'latest' it will display a link + with specific version so that this command can be used deterministicly in a build script. + It also displays binaries location if you prefer to install or download it yourself. +.PARAMETER NoPath + By default this script will set environment variable PATH for the current process to the binaries folder inside installation folder. + If set it will display binaries location but not set any environment variable. +.PARAMETER Verbose + Displays diagnostics information. +.PARAMETER AzureFeed + Default: https://dotnetcli.azureedge.net/dotnet + This parameter typically is not changed by the user. + It allows to change URL for the Azure feed used by this installer. +.PARAMETER UncachedFeed + This parameter typically is not changed by the user. + It allows to change URL for the Uncached feed used by this installer. +.PARAMETER ProxyAddress + If set, the installer will use the proxy when making web requests +.PARAMETER ProxyUseDefaultCredentials + Default: false + Use default credentials, when using proxy address. +#> +[cmdletbinding()] +param( + [string]$Channel="LTS", + [string]$Version="Latest", + [string]$InstallDir="", + [string]$Architecture="", + [switch]$SharedRuntime, + [switch]$DryRun, + [switch]$NoPath, + [string]$AzureFeed="https://dotnetcli.azureedge.net/dotnet", + [string]$UncachedFeed="https://dotnetcli.blob.core.windows.net/dotnet", + [string]$ProxyAddress, + [switch]$ProxyUseDefaultCredentials +) + +Set-StrictMode -Version Latest +$ErrorActionPreference="Stop" +$ProgressPreference="SilentlyContinue" + +$BinFolderRelativePath="" + +# example path with regex: shared/1.0.0-beta-12345/somepath +$VersionRegEx="/\d+\.\d+[^/]+/" +$OverrideNonVersionedFiles=$true + +function Say($str) { + Write-Output "dotnet-install: $str" +} + +function Say-Verbose($str) { + Write-Verbose "dotnet-install: $str" +} + +function Say-Invocation($Invocation) { + $command = $Invocation.MyCommand; + $args = (($Invocation.BoundParameters.Keys | foreach { "-$_ `"$($Invocation.BoundParameters[$_])`"" }) -join " ") + Say-Verbose "$command $args" +} + +function Invoke-With-Retry([ScriptBlock]$ScriptBlock, [int]$MaxAttempts = 3, [int]$SecondsBetweenAttempts = 1) { + $Attempts = 0 + + while ($true) { + try { + return $ScriptBlock.Invoke() + } + catch { + $Attempts++ + if ($Attempts -lt $MaxAttempts) { + Start-Sleep $SecondsBetweenAttempts + } + else { + throw + } + } + } +} + +function Get-Machine-Architecture() { + Say-Invocation $MyInvocation + + # possible values: AMD64, IA64, x86 + return $ENV:PROCESSOR_ARCHITECTURE +} + +# TODO: Architecture and CLIArchitecture should be unified +function Get-CLIArchitecture-From-Architecture([string]$Architecture) { + Say-Invocation $MyInvocation + + switch ($Architecture.ToLower()) { + { $_ -eq "" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) } + { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } + { $_ -eq "x86" } { return "x86" } + default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" } + } +} + +function Get-Version-Info-From-Version-Text([string]$VersionText) { + Say-Invocation $MyInvocation + + $Data = @($VersionText.Split([char[]]@(), [StringSplitOptions]::RemoveEmptyEntries)); + + $VersionInfo = @{} + $VersionInfo.CommitHash = $Data[0].Trim() + $VersionInfo.Version = $Data[1].Trim() + return $VersionInfo +} + +function Load-Assembly([string] $Assembly) { + try { + Add-Type -Assembly $Assembly | Out-Null + } + catch { + # On Nano Server, Powershell Core Edition is used. Add-Type is unable to resolve base class assemblies because they are not GAC'd. + # Loading the base class assemblies is not unnecessary as the types will automatically get resolved. + } +} + +function GetHTTPResponse([Uri] $Uri) +{ + Invoke-With-Retry( + { + + $HttpClient = $null + + try { + # HttpClient is used vs Invoke-WebRequest in order to support Nano Server which doesn't support the Invoke-WebRequest cmdlet. + Load-Assembly -Assembly System.Net.Http + + if(-not $ProxyAddress) + { + # Despite no proxy being explicitly specified, we may still be behind a default proxy + $DefaultProxy = [System.Net.WebRequest]::DefaultWebProxy; + if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){ + $ProxyAddress = $DefaultProxy.GetProxy($Uri).OriginalString + $ProxyUseDefaultCredentials = $true + } + } + + if($ProxyAddress){ + $HttpClientHandler = New-Object System.Net.Http.HttpClientHandler + $HttpClientHandler.Proxy = New-Object System.Net.WebProxy -Property @{Address=$ProxyAddress;UseDefaultCredentials=$ProxyUseDefaultCredentials} + $HttpClient = New-Object System.Net.Http.HttpClient -ArgumentList $HttpClientHandler + } + else { + $HttpClient = New-Object System.Net.Http.HttpClient + } + # Default timeout for HttpClient is 100s. For a 50 MB download this assumes 500 KB/s average, any less will time out + # 10 minutes allows it to work over much slower connections. + $HttpClient.Timeout = New-TimeSpan -Minutes 10 + $Response = $HttpClient.GetAsync($Uri).Result + if (($Response -eq $null) -or (-not ($Response.IsSuccessStatusCode))) + { + $ErrorMsg = "Failed to download $Uri." + if ($Response -ne $null) + { + $ErrorMsg += " $Response" + } + + throw $ErrorMsg + } + + return $Response + } + finally { + if ($HttpClient -ne $null) { + $HttpClient.Dispose() + } + } + }) +} + + +function Get-Latest-Version-Info([string]$AzureFeed, [string]$Channel, [bool]$Coherent) { + Say-Invocation $MyInvocation + + $VersionFileUrl = $null + if ($SharedRuntime) { + $VersionFileUrl = "$UncachedFeed/Runtime/$Channel/latest.version" + } + else { + if ($Coherent) { + $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.coherent.version" + } + else { + $VersionFileUrl = "$UncachedFeed/Sdk/$Channel/latest.version" + } + } + + $Response = GetHTTPResponse -Uri $VersionFileUrl + $StringContent = $Response.Content.ReadAsStringAsync().Result + + switch ($Response.Content.Headers.ContentType) { + { ($_ -eq "application/octet-stream") } { $VersionText = [Text.Encoding]::UTF8.GetString($StringContent) } + { ($_ -eq "text/plain") } { $VersionText = $StringContent } + { ($_ -eq "text/plain; charset=UTF-8") } { $VersionText = $StringContent } + default { throw "``$Response.Content.Headers.ContentType`` is an unknown .version file content type." } + } + + $VersionInfo = Get-Version-Info-From-Version-Text $VersionText + + return $VersionInfo +} + + +function Get-Specific-Version-From-Version([string]$AzureFeed, [string]$Channel, [string]$Version) { + Say-Invocation $MyInvocation + + switch ($Version.ToLower()) { + { $_ -eq "latest" } { + $LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $False + return $LatestVersionInfo.Version + } + { $_ -eq "coherent" } { + $LatestVersionInfo = Get-Latest-Version-Info -AzureFeed $AzureFeed -Channel $Channel -Coherent $True + return $LatestVersionInfo.Version + } + default { return $Version } + } +} + +function Get-Download-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { + Say-Invocation $MyInvocation + + if ($SharedRuntime) { + $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-runtime-$SpecificVersion-win-$CLIArchitecture.zip" + } + else { + $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-$CLIArchitecture.zip" + } + + Say-Verbose "Constructed primary payload URL: $PayloadURL" + + return $PayloadURL +} + +function Get-LegacyDownload-Link([string]$AzureFeed, [string]$Channel, [string]$SpecificVersion, [string]$CLIArchitecture) { + Say-Invocation $MyInvocation + + if ($SharedRuntime) { + $PayloadURL = "$AzureFeed/Runtime/$SpecificVersion/dotnet-win-$CLIArchitecture.$SpecificVersion.zip" + } + else { + $PayloadURL = "$AzureFeed/Sdk/$SpecificVersion/dotnet-dev-win-$CLIArchitecture.$SpecificVersion.zip" + } + + Say-Verbose "Constructed legacy payload URL: $PayloadURL" + + return $PayloadURL +} + +function Get-User-Share-Path() { + Say-Invocation $MyInvocation + + $InstallRoot = $env:DOTNET_INSTALL_DIR + if (!$InstallRoot) { + $InstallRoot = "$env:LocalAppData\Microsoft\dotnet" + } + return $InstallRoot +} + +function Resolve-Installation-Path([string]$InstallDir) { + Say-Invocation $MyInvocation + + if ($InstallDir -eq "") { + return Get-User-Share-Path + } + return $InstallDir +} + +function Get-Version-Info-From-Version-File([string]$InstallRoot, [string]$RelativePathToVersionFile) { + Say-Invocation $MyInvocation + + $VersionFile = Join-Path -Path $InstallRoot -ChildPath $RelativePathToVersionFile + Say-Verbose "Local version file: $VersionFile" + + if (Test-Path $VersionFile) { + $VersionText = cat $VersionFile + Say-Verbose "Local version file text: $VersionText" + return Get-Version-Info-From-Version-Text $VersionText + } + + Say-Verbose "Local version file not found." + + return $null +} + +function Is-Dotnet-Package-Installed([string]$InstallRoot, [string]$RelativePathToPackage, [string]$SpecificVersion) { + Say-Invocation $MyInvocation + + $DotnetPackagePath = Join-Path -Path $InstallRoot -ChildPath $RelativePathToPackage | Join-Path -ChildPath $SpecificVersion + Say-Verbose "Is-Dotnet-Package-Installed: Path to a package: $DotnetPackagePath" + return Test-Path $DotnetPackagePath -PathType Container +} + +function Get-Absolute-Path([string]$RelativeOrAbsolutePath) { + # Too much spam + # Say-Invocation $MyInvocation + + return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelativeOrAbsolutePath) +} + +function Get-Path-Prefix-With-Version($path) { + $match = [regex]::match($path, $VersionRegEx) + if ($match.Success) { + return $entry.FullName.Substring(0, $match.Index + $match.Length) + } + + return $null +} + +function Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package([System.IO.Compression.ZipArchive]$Zip, [string]$OutPath) { + Say-Invocation $MyInvocation + + $ret = @() + foreach ($entry in $Zip.Entries) { + $dir = Get-Path-Prefix-With-Version $entry.FullName + if ($dir -ne $null) { + $path = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $dir) + if (-Not (Test-Path $path -PathType Container)) { + $ret += $dir + } + } + } + + $ret = $ret | Sort-Object | Get-Unique + + $values = ($ret | foreach { "$_" }) -join ";" + Say-Verbose "Directories to unpack: $values" + + return $ret +} + +# Example zip content and extraction algorithm: +# Rule: files if extracted are always being extracted to the same relative path locally +# .\ +# a.exe # file does not exist locally, extract +# b.dll # file exists locally, override only if $OverrideFiles set +# aaa\ # same rules as for files +# ... +# abc\1.0.0\ # directory contains version and exists locally +# ... # do not extract content under versioned part +# abc\asd\ # same rules as for files +# ... +# def\ghi\1.0.1\ # directory contains version and does not exist locally +# ... # extract content +function Extract-Dotnet-Package([string]$ZipPath, [string]$OutPath) { + Say-Invocation $MyInvocation + + Load-Assembly -Assembly System.IO.Compression.FileSystem + Set-Variable -Name Zip + try { + $Zip = [System.IO.Compression.ZipFile]::OpenRead($ZipPath) + + $DirectoriesToUnpack = Get-List-Of-Directories-And-Versions-To-Unpack-From-Dotnet-Package -Zip $Zip -OutPath $OutPath + + foreach ($entry in $Zip.Entries) { + $PathWithVersion = Get-Path-Prefix-With-Version $entry.FullName + if (($PathWithVersion -eq $null) -Or ($DirectoriesToUnpack -contains $PathWithVersion)) { + $DestinationPath = Get-Absolute-Path $(Join-Path -Path $OutPath -ChildPath $entry.FullName) + $DestinationDir = Split-Path -Parent $DestinationPath + $OverrideFiles=$OverrideNonVersionedFiles -Or (-Not (Test-Path $DestinationPath)) + if ((-Not $DestinationPath.EndsWith("\")) -And $OverrideFiles) { + New-Item -ItemType Directory -Force -Path $DestinationDir | Out-Null + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $DestinationPath, $OverrideNonVersionedFiles) + } + } + } + } + finally { + if ($Zip -ne $null) { + $Zip.Dispose() + } + } +} + +function DownloadFile([Uri]$Uri, [string]$OutPath) { + $Stream = $null + + try { + $Response = GetHTTPResponse -Uri $Uri + $Stream = $Response.Content.ReadAsStreamAsync().Result + $File = [System.IO.File]::Create($OutPath) + $Stream.CopyTo($File) + $File.Close() + } + finally { + if ($Stream -ne $null) { + $Stream.Dispose() + } + } +} + +function Prepend-Sdk-InstallRoot-To-Path([string]$InstallRoot, [string]$BinFolderRelativePath) { + $BinPath = Get-Absolute-Path $(Join-Path -Path $InstallRoot -ChildPath $BinFolderRelativePath) + if (-Not $NoPath) { + Say "Adding to current process PATH: `"$BinPath`". Note: This change will not be visible if PowerShell was run as a child process." + $env:path = "$BinPath;" + $env:path + } + else { + Say "Binaries of dotnet can be found in $BinPath" + } +} + +$CLIArchitecture = Get-CLIArchitecture-From-Architecture $Architecture +$SpecificVersion = Get-Specific-Version-From-Version -AzureFeed $AzureFeed -Channel $Channel -Version $Version +$DownloadLink = Get-Download-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture +$LegacyDownloadLink = Get-LegacyDownload-Link -AzureFeed $AzureFeed -Channel $Channel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture + +if ($DryRun) { + Say "Payload URLs:" + Say "Primary - $DownloadLink" + Say "Legacy - $LegacyDownloadLink" + Say "Repeatable invocation: .\$($MyInvocation.MyCommand) -Version $SpecificVersion -Channel $Channel -Architecture $CLIArchitecture -InstallDir $InstallDir" + exit 0 +} + +$InstallRoot = Resolve-Installation-Path $InstallDir +Say-Verbose "InstallRoot: $InstallRoot" + +$IsSdkInstalled = Is-Dotnet-Package-Installed -InstallRoot $InstallRoot -RelativePathToPackage "sdk" -SpecificVersion $SpecificVersion +Say-Verbose ".NET SDK installed? $IsSdkInstalled" +if ($IsSdkInstalled) { + Say ".NET SDK version $SpecificVersion is already installed." + Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath + exit 0 +} + +New-Item -ItemType Directory -Force -Path $InstallRoot | Out-Null + +$installDrive = $((Get-Item $InstallRoot).PSDrive.Name); +Write-Output "${installDrive}:"; +$free = Get-CimInstance -Class win32_logicaldisk | where Deviceid -eq "${installDrive}:" +if ($free.Freespace / 1MB -le 100 ) { + Say "There is not enough disk space on drive ${installDrive}:" + exit 0 +} + +$ZipPath = [System.IO.Path]::GetTempFileName() +Say-Verbose "Zip path: $ZipPath" +Say "Downloading link: $DownloadLink" +try { + DownloadFile -Uri $DownloadLink -OutPath $ZipPath +} +catch { + Say "Cannot download: $DownloadLink" + $DownloadLink = $LegacyDownloadLink + $ZipPath = [System.IO.Path]::GetTempFileName() + Say-Verbose "Legacy zip path: $ZipPath" + Say "Downloading legacy link: $DownloadLink" + DownloadFile -Uri $DownloadLink -OutPath $ZipPath +} + +Say "Extracting zip from $DownloadLink" +Extract-Dotnet-Package -ZipPath $ZipPath -OutPath $InstallRoot + +Remove-Item $ZipPath + +Prepend-Sdk-InstallRoot-To-Path -InstallRoot $InstallRoot -BinFolderRelativePath $BinFolderRelativePath + +Say "Installation finished" +exit 0 diff --git a/scripts/dotnet-install.sh b/scripts/dotnet-install.sh new file mode 100644 index 0000000000..451525269e --- /dev/null +++ b/scripts/dotnet-install.sh @@ -0,0 +1,815 @@ +#!/usr/bin/env bash +# Copyright (c) .NET Foundation and contributors. All rights reserved. +# Licensed under the MIT license. See LICENSE file in the project root for full license information. +# + +# Stop script on NZEC +set -e +# Stop script if unbound variable found (use ${var:-} if intentional) +set -u +# By default cmd1 | cmd2 returns exit code of cmd2 regardless of cmd1 success +# This is causing it to fail +set -o pipefail + +# Use in the the functions: eval $invocation +invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' + +# standard output may be used as a return value in the functions +# we need a way to write text on the screen in the functions so that +# it won't interfere with the return value. +# Exposing stream 3 as a pipe to standard output of the script itself +exec 3>&1 + +# Setup some colors to use. These need to work in fairly limited shells, like the Ubuntu Docker container where there are only 8 colors. +# See if stdout is a terminal +if [ -t 1 ]; then + # see if it supports colors + ncolors=$(tput colors) + if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then + bold="$(tput bold || echo)" + normal="$(tput sgr0 || echo)" + black="$(tput setaf 0 || echo)" + red="$(tput setaf 1 || echo)" + green="$(tput setaf 2 || echo)" + yellow="$(tput setaf 3 || echo)" + blue="$(tput setaf 4 || echo)" + magenta="$(tput setaf 5 || echo)" + cyan="$(tput setaf 6 || echo)" + white="$(tput setaf 7 || echo)" + fi +fi + +say_err() { + printf "%b\n" "${red:-}dotnet_install: Error: $1${normal:-}" >&2 +} + +say() { + # using stream 3 (defined in the beginning) to not interfere with stdout of functions + # which may be used as return value + printf "%b\n" "${cyan:-}dotnet-install:${normal:-} $1" >&3 +} + +say_verbose() { + if [ "$verbose" = true ]; then + say "$1" + fi +} + +get_os_download_name_from_platform() { + eval $invocation + + platform="$1" + case "$platform" in + "centos.7") + echo "centos" + return 0 + ;; + "debian.8") + echo "debian" + return 0 + ;; + "fedora.23") + echo "fedora.23" + return 0 + ;; + "fedora.24") + echo "fedora.24" + return 0 + ;; + "opensuse.13.2") + echo "opensuse.13.2" + return 0 + ;; + "opensuse.42.1") + echo "opensuse.42.1" + return 0 + ;; + "rhel.7"*) + echo "rhel" + return 0 + ;; + "ubuntu.14.04") + echo "ubuntu" + return 0 + ;; + "ubuntu.16.04") + echo "ubuntu.16.04" + return 0 + ;; + "ubuntu.16.10") + echo "ubuntu.16.10" + return 0 + ;; + "alpine.3.4.3") + echo "alpine" + return 0 + ;; + esac + return 1 +} + +get_current_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + else + if [ "$uname" = "Linux" ]; then + echo "linux" + return 0 + fi + fi + + say_err "OS name could not be detected: $ID.$VERSION_ID" + return 1 +} + +get_distro_specific_os_name() { + eval $invocation + + local uname=$(uname) + if [ "$uname" = "Darwin" ]; then + echo "osx" + return 0 + elif [ -n "$runtime_id" ]; then + echo $(get_os_download_name_from_platform "${runtime_id%-*}" || echo "${runtime_id%-*}") + return 0 + else + if [ -e /etc/os-release ]; then + . /etc/os-release + os=$(get_os_download_name_from_platform "$ID.$VERSION_ID" || echo "") + if [ -n "$os" ]; then + echo "$os" + return 0 + fi + fi + fi + + say_verbose "Distribution specific OS name and version could not be detected: $ID.$VERSION_ID" + return 1 +} + +machine_has() { + eval $invocation + + hash "$1" > /dev/null 2>&1 + return $? +} + + +check_min_reqs() { + local hasMinimum=false + if machine_has "curl"; then + hasMinimum=true + elif machine_has "wget"; then + hasMinimum=true + fi + + if [ "$hasMinimum" = "false" ]; then + say_err "curl (recommended) or wget are required to download dotnet. Install missing prerequisite to proceed." + return 1 + fi + return 0 +} + +check_pre_reqs() { + eval $invocation + + local failing=false; + + if [ "${DOTNET_INSTALL_SKIP_PREREQS:-}" = "1" ]; then + return 0 + fi + + if [ "$(uname)" = "Linux" ]; then + if ! [ -x "$(command -v ldconfig)" ]; then + echo "ldconfig is not in PATH, trying /sbin/ldconfig." + LDCONFIG_COMMAND="/sbin/ldconfig" + else + LDCONFIG_COMMAND="ldconfig" + fi + + [ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && failing=true + fi + + if [ "$failing" = true ]; then + return 1 + fi + + return 0 +} + +# args: +# input - $1 +to_lowercase() { + #eval $invocation + + echo "$1" | tr '[:upper:]' '[:lower:]' + return 0 +} + +# args: +# input - $1 +remove_trailing_slash() { + #eval $invocation + + local input=${1:-} + echo "${input%/}" + return 0 +} + +# args: +# input - $1 +remove_beginning_slash() { + #eval $invocation + + local input=${1:-} + echo "${input#/}" + return 0 +} + +# args: +# root_path - $1 +# child_path - $2 - this parameter can be empty +combine_paths() { + eval $invocation + + # TODO: Consider making it work with any number of paths. For now: + if [ ! -z "${3:-}" ]; then + say_err "combine_paths: Function takes two parameters." + return 1 + fi + + local root_path=$(remove_trailing_slash $1) + local child_path=$(remove_beginning_slash ${2:-}) + say_verbose "combine_paths: root_path=$root_path" + say_verbose "combine_paths: child_path=$child_path" + echo "$root_path/$child_path" + return 0 +} + +get_machine_architecture() { + eval $invocation + + # Currently the only one supported + echo "x64" + return 0 +} + +# args: +# architecture - $1 +get_normalized_architecture_from_architecture() { + eval $invocation + + local architecture=$(to_lowercase $1) + case $architecture in + \) + echo "$(get_normalized_architecture_from_architecture $(get_machine_architecture))" + return 0 + ;; + amd64|x64) + echo "x64" + return 0 + ;; + x86) + say_err "Architecture \`x86\` currently not supported" + return 1 + ;; + esac + + say_err "Architecture \`$architecture\` not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" + return 1 +} + +# version_info is a conceptual two line string representing commit hash and 4-part version +# format: +# Line 1: # commit_hash +# Line 2: # 4-part version + +# args: +# version_text - stdin +get_version_from_version_info() { + eval $invocation + + cat | tail -n 1 + return 0 +} + +# args: +# version_text - stdin +get_commit_hash_from_version_info() { + eval $invocation + + cat | head -n 1 + return 0 +} + +# args: +# install_root - $1 +# relative_path_to_package - $2 +# specific_version - $3 +is_dotnet_package_installed() { + eval $invocation + + local install_root=$1 + local relative_path_to_package=$2 + local specific_version=${3//[$'\t\r\n']} + + local dotnet_package_path=$(combine_paths $(combine_paths $install_root $relative_path_to_package) $specific_version) + say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path" + + if [ -d "$dotnet_package_path" ]; then + return 0 + else + return 1 + fi +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +get_latest_version_info() { + eval $invocation + + local azure_feed=$1 + local channel=$2 + local normalized_architecture=$3 + local coherent=$4 + + local version_file_url=null + if [ "$shared_runtime" = true ]; then + version_file_url="$uncached_feed/Runtime/$channel/latest.version" + else + if [ "$coherent" = true ]; then + version_file_url="$uncached_feed/Sdk/$channel/latest.coherent.version" + else + version_file_url="$uncached_feed/Sdk/$channel/latest.version" + fi + fi + say_verbose "get_latest_version_info: latest url: $version_file_url" + + download $version_file_url + return $? +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# version - $4 +get_specific_version_from_version() { + eval $invocation + + local azure_feed=$1 + local channel=$2 + local normalized_architecture=$3 + local version=$(to_lowercase $4) + + case $version in + latest) + local version_info + version_info="$(get_latest_version_info $azure_feed $channel $normalized_architecture false)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_version_info + return 0 + ;; + coherent) + local version_info + version_info="$(get_latest_version_info $azure_feed $channel $normalized_architecture true)" || return 1 + say_verbose "get_specific_version_from_version: version_info=$version_info" + echo "$version_info" | get_version_from_version_info + return 0 + ;; + *) + echo $version + return 0 + ;; + esac +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_download_link() { + eval $invocation + + local azure_feed=$1 + local channel=$2 + local normalized_architecture=$3 + local specific_version=${4//[$'\t\r\n']} + + local osname + osname=$(get_current_os_name) || return 1 + + local download_link=null + if [ "$shared_runtime" = true ]; then + download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz" + else + download_link="$azure_feed/Sdk/$specific_version/dotnet-sdk-$specific_version-$osname-$normalized_architecture.tar.gz" + fi + + echo "$download_link" + return 0 +} + +# args: +# azure_feed - $1 +# channel - $2 +# normalized_architecture - $3 +# specific_version - $4 +construct_legacy_download_link() { + eval $invocation + + local azure_feed=$1 + local channel=$2 + local normalized_architecture=$3 + local specific_version=${4//[$'\t\r\n']} + + local distro_specific_osname + distro_specific_osname=$(get_distro_specific_os_name) || return 1 + + local legacy_download_link=null + if [ "$shared_runtime" = true ]; then + legacy_download_link="$azure_feed/Runtime/$specific_version/dotnet-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + else + legacy_download_link="$azure_feed/Sdk/$specific_version/dotnet-dev-$distro_specific_osname-$normalized_architecture.$specific_version.tar.gz" + fi + + echo "$legacy_download_link" + return 0 +} + +get_user_install_path() { + eval $invocation + + if [ ! -z "${DOTNET_INSTALL_DIR:-}" ]; then + echo $DOTNET_INSTALL_DIR + else + echo "$HOME/.dotnet" + fi + return 0 +} + +# args: +# install_dir - $1 +resolve_installation_path() { + eval $invocation + + local install_dir=$1 + if [ "$install_dir" = "" ]; then + local user_install_path=$(get_user_install_path) + say_verbose "resolve_installation_path: user_install_path=$user_install_path" + echo "$user_install_path" + return 0 + fi + + echo "$install_dir" + return 0 +} + +# args: +# install_root - $1 +get_installed_version_info() { + eval $invocation + + local install_root=$1 + local version_file=$(combine_paths "$install_root" "$local_version_file_relative_path") + say_verbose "Local version file: $version_file" + if [ ! -z "$version_file" ] | [ -r "$version_file" ]; then + local version_info="$(cat $version_file)" + echo "$version_info" + return 0 + fi + + say_verbose "Local version file not found." + return 0 +} + +# args: +# relative_or_absolute_path - $1 +get_absolute_path() { + eval $invocation + + local relative_or_absolute_path=$1 + echo $(cd $(dirname "$1") && pwd -P)/$(basename "$1") + return 0 +} + +# args: +# input_files - stdin +# root_path - $1 +# out_path - $2 +# override - $3 +copy_files_or_dirs_from_list() { + eval $invocation + + local root_path=$(remove_trailing_slash $1) + local out_path=$(remove_trailing_slash $2) + local override=$3 + local override_switch=$(if [ "$override" = false ]; then printf -- "-n"; fi) + + cat | uniq | while read -r file_path; do + local path=$(remove_beginning_slash ${file_path#$root_path}) + local target=$out_path/$path + if [ "$override" = true ] || (! ([ -d "$target" ] || [ -e "$target" ])); then + mkdir -p $out_path/$(dirname $path) + cp -R $override_switch $root_path/$path $target + fi + done +} + +# args: +# zip_path - $1 +# out_path - $2 +extract_dotnet_package() { + eval $invocation + + local zip_path=$1 + local out_path=$2 + + local temp_out_path=$(mktemp -d $temporary_file_template) + + local failed=false + tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true + + local folders_with_version_regex='^.*/[0-9]+\.[0-9]+[^/]+/' + find $temp_out_path -type f | grep -Eo $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path false + find $temp_out_path -type f | grep -Ev $folders_with_version_regex | copy_files_or_dirs_from_list $temp_out_path $out_path true + + rm -rf $temp_out_path + + if [ "$failed" = true ]; then + say_err "Extraction failed" + return 1 + fi +} + +# args: +# remote_path - $1 +# [out_path] - $2 - stdout if not provided +download() { + eval $invocation + + local remote_path=$1 + local out_path=${2:-} + + local failed=false + if machine_has "curl"; then + downloadcurl $remote_path $out_path || failed=true + elif machine_has "wget"; then + downloadwget $remote_path $out_path || failed=true + else + failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Download failed: $remote_path" + return 1 + fi + return 0 +} + +downloadcurl() { + eval $invocation + local remote_path=$1 + local out_path=${2:-} + + local failed=false + if [ -z "$out_path" ]; then + curl --retry 10 -sSL -f --create-dirs $remote_path || failed=true + else + curl --retry 10 -sSL -f --create-dirs -o $out_path $remote_path || failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Curl download failed" + return 1 + fi + return 0 +} + +downloadwget() { + eval $invocation + local remote_path=$1 + local out_path=${2:-} + + local failed=false + if [ -z "$out_path" ]; then + wget -q --tries 10 $remote_path || failed=true + else + wget -v --tries 10 -O $out_path $remote_path || failed=true + fi + if [ "$failed" = true ]; then + say_verbose "Wget download failed" + return 1 + fi + return 0 +} + +calculate_vars() { + eval $invocation + valid_legacy_download_link=true + + normalized_architecture=$(get_normalized_architecture_from_architecture "$architecture") + say_verbose "normalized_architecture=$normalized_architecture" + + specific_version=$(get_specific_version_from_version $azure_feed $channel $normalized_architecture $version) + say_verbose "specific_version=$specific_version" + if [ -z "$specific_version" ]; then + say_err "Could not get version information." + return 1 + fi + + download_link=$(construct_download_link $azure_feed $channel $normalized_architecture $specific_version) + say_verbose "download_link=$download_link" + + legacy_download_link=$(construct_legacy_download_link $azure_feed $channel $normalized_architecture $specific_version) || valid_legacy_download_link=false + + if [ "$valid_legacy_download_link" = true ]; then + say_verbose "legacy_download_link=$legacy_download_link" + else + say_verbose "Cound not construct a legacy_download_link; omitting..." + fi + + install_root=$(resolve_installation_path $install_dir) + say_verbose "install_root=$install_root" +} + +install_dotnet() { + eval $invocation + local download_failed=false + + if is_dotnet_package_installed $install_root "sdk" $specific_version; then + say ".NET SDK version $specific_version is already installed." + return 0 + fi + + mkdir -p $install_root + zip_path=$(mktemp $temporary_file_template) + say_verbose "Zip path: $zip_path" + + say "Downloading link: $download_link" + download "$download_link" $zip_path || download_failed=true + + # if the download fails, download the legacy_download_link + if [ "$download_failed" = true ] && [ "$valid_legacy_download_link" = true ]; then + say "Cannot download: $download_link" + download_link=$legacy_download_link + zip_path=$(mktemp $temporary_file_template) + say_verbose "Legacy zip path: $zip_path" + say "Downloading legacy link: $download_link" + download "$download_link" $zip_path + fi + + say "Extracting zip from $download_link" + extract_dotnet_package $zip_path $install_root + + return 0 +} + +local_version_file_relative_path="/.version" +bin_folder_relative_path="" +temporary_file_template="${TMPDIR:-/tmp}/dotnet.XXXXXXXXX" + +channel="LTS" +version="Latest" +install_dir="" +architecture="" +dry_run=false +no_path=false +azure_feed="https://dotnetcli.azureedge.net/dotnet" +uncached_feed="https://dotnetcli.blob.core.windows.net/dotnet" +verbose=false +shared_runtime=false +runtime_id="" + +while [ $# -ne 0 ] +do + name=$1 + case $name in + -c|--channel|-[Cc]hannel) + shift + channel=$1 + ;; + -v|--version|-[Vv]ersion) + shift + version="$1" + ;; + -i|--install-dir|-[Ii]nstall[Dd]ir) + shift + install_dir="$1" + ;; + --arch|--architecture|-[Aa]rch|-[Aa]rchitecture) + shift + architecture="$1" + ;; + --shared-runtime|-[Ss]hared[Rr]untime) + shared_runtime=true + ;; + --dry-run|-[Dd]ry[Rr]un) + dry_run=true + ;; + --no-path|-[Nn]o[Pp]ath) + no_path=true + ;; + --verbose|-[Vv]erbose) + verbose=true + ;; + --azure-feed|-[Aa]zure[Ff]eed) + shift + azure_feed="$1" + ;; + --uncached-feed|-[Uu]ncached[Ff]eed) + shift + uncached_feed="$1" + ;; + --runtime-id|-[Rr]untime[Ii]d) + shift + runtime_id="$1" + ;; + -?|--?|-h|--help|-[Hh]elp) + script_name="$(basename $0)" + echo ".NET Tools Installer" + echo "Usage: $script_name [-c|--channel ] [-v|--version ] [-p|--prefix ]" + echo " $script_name -h|-?|--help" + echo "" + echo "$script_name is a simple command line interface for obtaining dotnet cli." + echo "" + echo "Options:" + echo " -c,--channel Download from the CHANNEL specified, Defaults to \`$channel\`." + echo " -Channel" + echo " Possible values:" + echo " - Current - most current release" + echo " - LTS - most current supported release" + echo " - 2-part version in a format A.B - represents a specific release" + echo " examples: 2.0; 1.0" + echo " - Branch name" + echo " examples: release/2.0.0; Master" + echo " -v,--version Use specific VERSION, Defaults to \`$version\`." + echo " -Version" + echo " Possible values:" + echo " - latest - most latest build on specific channel" + echo " - coherent - most latest coherent build on specific channel" + echo " coherent applies only to SDK downloads" + echo " - 3-part version in a format A.B.C - represents specific version of build" + echo " examples: 2.0.0-preview2-006120; 1.1.0" + echo " -i,--install-dir Install under specified location (see Install Location below)" + echo " -InstallDir" + echo " --architecture Architecture of .NET Tools. Currently only x64 is supported." + echo " --arch,-Architecture,-Arch" + echo " --shared-runtime Installs just the shared runtime bits, not the entire SDK." + echo " -SharedRuntime" + echo " --dry-run,-DryRun Do not perform installation. Display download link." + echo " --no-path, -NoPath Do not set PATH for the current process." + echo " --verbose,-Verbose Display diagnostics information." + echo " --azure-feed,-AzureFeed Azure feed location. Defaults to $azure_feed, This parameter typically is not changed by the user." + echo " --uncached-feed,-UncachedFeed Uncached feed location. This parameter typically is not changed by the user." + echo " --runtime-id Installs the .NET Tools for the given platform (use linux-x64 for portable linux)." + echo " -RuntimeId" + echo " -?,--?,-h,--help,-Help Shows this help message" + echo "" + echo "Install Location:" + echo " Location is chosen in following order:" + echo " - --install-dir option" + echo " - Environmental variable DOTNET_INSTALL_DIR" + echo " - $HOME/.dotnet" + exit 0 + ;; + *) + say_err "Unknown argument \`$name\`" + exit 1 + ;; + esac + + shift +done + +check_min_reqs +calculate_vars + +if [ "$dry_run" = true ]; then + say "Payload URL: $download_link" + if [ "$valid_legacy_download_link" = true ]; then + say "Legacy payload URL: $legacy_download_link" + fi + say "Repeatable invocation: ./$(basename $0) --version $specific_version --channel $channel --install-dir $install_dir" + exit 0 +fi + +check_pre_reqs +install_dotnet + +bin_path=$(get_absolute_path $(combine_paths $install_root $bin_folder_relative_path)) +if [ "$no_path" = false ]; then + say "Adding to current process PATH: \`$bin_path\`. Note: This change will be visible only when sourcing script." + export PATH=$bin_path:$PATH +else + say "Binaries of dotnet can be found in $bin_path" +fi + +say "Installation finished successfully." diff --git a/src/FSharpSource.BuildFromSource.targets b/src/FSharpSource.BuildFromSource.targets new file mode 100644 index 0000000000..5b658bd0c1 --- /dev/null +++ b/src/FSharpSource.BuildFromSource.targets @@ -0,0 +1,150 @@ + + + + + + 4.4.1.0 + $(MSBuildThisFileDirectory)../BuildFromSource/$(Configuration)/bin + + true + true + false + + + $(DefineConstants);STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY + $(MSBuildThisFileDirectory)buildtools/keys/MSFT.snk + true + $(OtherFlags) --publicsign --keyfile:$(KeyFile) + $(OtherFlags) --nocopyfsharpcore + + dotnet + dotnet.exe + $(MSBuildThisFileDirectory)../Tools/dotnet20/$(DotNetExe) + $(MSBuildBinPath)/../../$(DotNetExe) + + + $(IntermediateOutputFile)\BuildVersionFile.props + + + + + coreclr + net40 + + + + + + + + + + + $([System.Text.RegularExpressions.Regex]::Replace($([System.IO.File]::ReadAllText("%(CopyAndSubstituteText.FullPath)")), "%(CopyAndSubstituteText.Pattern1)", "%(CopyAndSubstituteText.Replacement1)")) + + + $([System.Text.RegularExpressions.Regex]::Replace($(FileText), "%(CopyAndSubstituteText.Pattern2)", "%(CopyAndSubstituteText.Replacement2)")) + + + + + + + + + + + + $(MSBuildThisFileDirectory)../Tools/fssrgen/fssrgen.dll + + + + + + + + + + + + + + + + + %(FsSrGen.Filename) + Resx + false + + + + + + + false + + + false + + + + + + + + $(MSBuildThisFileDirectory)../Tools/fslex/fslex.dll + + + + + + + + + + + + + + + + + + + $(MSBuildThisFileDirectory)../Tools/fsyacc/fsyacc.dll + + + + + + + + + + + + + + + diff --git a/src/FSharpSource.Profiles.targets b/src/FSharpSource.Profiles.targets new file mode 100644 index 0000000000..6ce6354bb3 --- /dev/null +++ b/src/FSharpSource.Profiles.targets @@ -0,0 +1,61 @@ + + + + + + $(DefineConstants);CROSS_PLATFORM_COMPILER + $(DefineConstants);PREFERRED_UI_LANG + $(DefineConstants);ENABLE_MONO_SUPPORT + $(DefineConstants);BE_SECURITY_TRANSPARENT + $(DefineConstants);FX_LCIDFROMCODEPAGE + + + + $(DefineConstants);FX_PORTABLE_OR_NETSTANDARD + $(DefineConstants);NETSTANDARD1_6 + $(DefineConstants);PREFERRED_UI_LANG + $(DefineConstants);FX_NO_APP_DOMAINS + $(DefineConstants);FX_NO_ARRAY_LONG_LENGTH + $(DefineConstants);FX_NO_BEGINEND_READWRITE + $(DefineConstants);FX_NO_BINARY_SERIALIZATION + $(DefineConstants);FX_NO_CONVERTER + $(DefineConstants);FX_NO_DEFAULT_DEPENDENCY_TYPE + $(DefineConstants);FX_NO_CORHOST_SIGNER + $(DefineConstants);FX_NO_CRYPTO + $(DefineConstants);FX_NO_EVENTWAITHANDLE_IDISPOSABLE + $(DefineConstants);FX_NO_EXIT_CONTEXT_FLAGS + $(DefineConstants);FX_NO_HEAPTERMINATION + $(DefineConstants);FX_NO_LINKEDRESOURCES + $(DefineConstants);FX_NO_LOADER_OPTIMIZATION + $(DefineConstants);FX_NO_SIMPLIFIED_LOADER + $(DefineConstants);FX_NO_PARAMETERIZED_THREAD_START + $(DefineConstants);FX_NO_PDB_READER + $(DefineConstants);FX_NO_PDB_WRITER + $(DefineConstants);FX_NO_REFLECTION_MODULE_HANDLES + $(DefineConstants);FX_NO_REFLECTION_ONLY + $(DefineConstants);FX_NO_RUNTIMEENVIRONMENT + $(DefineConstants);FX_NO_SECURITY_PERMISSIONS + $(DefineConstants);FX_NO_SERVERCODEPAGES + $(DefineConstants);FX_NO_SYMBOLSTORE + $(DefineConstants);FX_NO_SYSTEM_CONFIGURATION + $(DefineConstants);FX_NO_THREAD + $(DefineConstants);FX_NO_THREADABORT + $(DefineConstants);FX_NO_WAITONE_MILLISECONDS + $(DefineConstants);FX_NO_WEB_CLIENT + $(DefineConstants);FX_NO_WIN_REGISTRY + $(DefineConstants);FX_NO_WINFORMS + $(DefineConstants);FX_REDUCED_EXCEPTIONS + $(DefineConstants);FX_REDUCED_CONSOLE + $(DefineConstants);FX_RESHAPED_REFEMIT + $(DefineConstants);FX_RESHAPED_CONSOLE + $(DefineConstants);FX_RESHAPED_GLOBALIZATION + $(DefineConstants);FX_RESHAPED_REFLECTION + $(DefineConstants);FX_JITTRACKING_ISSUE + $(DefineConstants);FX_NO_INDENTED_TEXT_WRITER + $(DefineConstants);FX_RESHAPED_REFLECTION_CORECLR + $(DefineConstants);FX_RESHAPED_MSBUILD + $(DefineConstants);FSI_TODO_NETCORE + $(OtherFlags) --simpleresolution + + + diff --git a/src/FSharpSource.Settings.targets b/src/FSharpSource.Settings.targets new file mode 100644 index 0000000000..c1a0b2935b --- /dev/null +++ b/src/FSharpSource.Settings.targets @@ -0,0 +1,149 @@ + + + + + + + Debug + $(ConfigurationGroup) + $(TargetGroup)_$(Configuration) + $(OSGroup)_$(Configuration) + + + + Debug + Release + Debug + + + + + true + net40 + + + net40 + FSharp + true + true + true + + false + + 2.3.0-beta2-61719-01 + 15.0 + 15.0.26201 + Microsoft.VSSDK.BuildTools.15.0.26201 + + 15.3.23 + 15.3.15 + + + obj\$(Configuration)\$(TargetDotnetProfile)\ + obj\$(Configuration)\$(TargetDotnetProfile)\$(PortableProfileBeingReferenced)\ + + 4.1.19 + 4.1.20 + 4.1.21 + 4.2.4 + + + + true + false + true + $(MSBuildThisFileDirectory)..\packages\$(VSSDK_BUILDTOOLS_VERSION)\tools\vssdk + $(MSBuildThisFileDirectory)..\packages\$(VSSDK_BUILDTOOLS_VERSION)\tools\vssdk\bin + $(MSBuildThisFileDirectory)..\packages\$(VSSDK_BUILDTOOLS_VERSION)\tools\vssdk\Microsoft.VsSDK.targets + $(MSBuildThisFileDirectory)..\packages\$(VSSDK_BUILDTOOLS_VERSION)\tools\vssdk\inc + $(MSBuildThisFileDirectory)..\packages\$(VSSDK_BUILDTOOLS_VERSION)\tools\vssdk\schemas\VSIXManifestSchema.xsd + + + + + $(OtherFlags) --times + $(NoWarn);69;65;54;61;75 + + + + + full + + false + prompt + $(OtherFlags) --no-jit-optimize + true + DEBUG;TRACE;CODE_ANALYSIS;$(DefineConstants) + DEBUG=True,TRACE=True,CODE_ANALYSIS=True,$(DefineConstants) + + + + + pdbonly + + true + false + prompt + TRACE;$(DefineConstants) + TRACE=True,$(DefineConstants) + + + + + full + true + DEBUG;NO_STRONG_NAMES;$(DefineConstants) + + + + + bin\$(Configuration) + 3 + + + + $(DefineConstants),VS_VERSION_DEV12=True + $(DefineConstants);VS_VERSION_DEV12 + $(DefineConstants),VS_VERSION_DEV14=True + $(DefineConstants);VS_VERSION_DEV14 + $(DefineConstants),VS_VERSION_DEV15=True + $(DefineConstants);VS_VERSION_DEV15 + + $(DefineConstants),VS_VERSION_DEV14=True + $(DefineConstants);VS_VERSION_DEV14 + + + + + $([System.DateTime]::Now.ToString(`yyMMdd`)) + 1.0.0 + $(NuGetReleaseVersion)-rc + $(NuGetPreReleaseVersion)-$(BuildRevision.Trim()) + $(MSBuildThisFileDirectory)..\packages + $(NUGET_PACKAGES) + + + + + $(FSharpSourcesRoot)\..\packages\FsLexYacc.7.0.6\build + $(FSharpSourcesRoot)\..\packages\FsLexYacc.7.0.6\build + fsi.exe + fslex.exe + fsyacc.exe + + + + v12.0 + 12.0.0.0 + + + + $(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.23\tools + + + + + + diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets new file mode 100644 index 0000000000..effcaf5a59 --- /dev/null +++ b/src/FSharpSource.targets @@ -0,0 +1,398 @@ + + + + + + 4.4.1.0 + + + + + + false + true + + + + + + + + + true + false + $(FSCoreVersion) + fs + + + + + + $(OtherFlags) --keyfile:"$(FSharpSourcesRoot)\fsharp\test.snk" + STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY;$(DefineConstants) + true + $(FSCoreVersion) + fs + + + + + + + $(OtherFlags) --delaysign+ + $(OtherFlags) --publicsign+ + $(OtherFlags) --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey" + STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY;$(DefineConstants) + true + $(FSCoreVersion) + + 15.4.1.0 + fs + + + + + + + + true + $(FSharpSourcesRoot)\fsharp\msft.pubkey + STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY;$(DefineConstants) + true + true + $(FSCoreVersion) + fs + + + + + + + + NO_STRONG_NAMES;$(DefineConstants) + $(FSCoreVersion) + fs + + + + + + $(OtherFlags) --version:"$(MicroBuildAssemblyVersion)" + + + + $(IntermediateOutputPath)source_link.json + + + + NO_STRONG_NAMES;$(DefineConstants) + + + + MSBUILD_AT_LEAST_14;$(DefineConstants) + + + + + false + + + + $(FSharpSourcesRoot)\..\packages + 3.5.0 + 3.5.0.0 + $(FSharpSourcesRoot)\..\packages\NUnit.$(NUnitVersion)\lib\net45 + $(FSharpSourcesRoot)\..\packages\NUnit.ConsoleRunner\$(NUnitVersion)\tools\ + 2.6.2 + 2.6.2.0 + $(FSharpSourcesRoot)\..\packages\FsCheck.$(FsCheckVersion)\lib\ + + + + + + v4.5 + + + + + + netcore + + v5.0 + false + .NETStandard,Version=v1.6 + true + + + + bin\$(Configuration)\netcoreapp1.0 + true + true + win7-x64 + $(FSharpSourcesRoot)\..\tests\testbin\$(Configuration)\coreclr\$(AssemblyName) + Exe + .dll + + + + true + $(FSharpSourcesRoot)\..\tests\testbin\$(Configuration)\coreclr\FSC + true + $(FSharpSourcesRoot)\..\tests\testbin\$(Configuration)\coreclr\FSC + + + + + $(TargetDotnetProfile) + fsharp30\$(TargetDotnetProfile) + fsharp31\$(TargetDotnetProfile) + fsharp40\$(TargetDotnetProfile) + obj\$(TargetFrameworkOutputDirectory)\ + + + + + + $(FSharpSourcesRoot)\..\$(Configuration)\$(ProtoFlavour)\bin + + $(FSharpSourcesRoot)\..\Tools\dotnet20\sdk\2.0.0-preview2-006502\FSharp + ..\packages\FSharp.Compiler.Tools.4.1.23\tools\Microsoft.FSharp.Targets + + + $(FSharpSourcesRoot)\..\Tools\dotnet20 + dotnet.exe + dotnet + $(FSharpNetCoreLkgPath)\fsc.exe + + + + + + $(FSharpSourcesRoot)\..\$(Configuration)\$(ProtoFlavour)\bin + ..\packages\FSharp.Compiler.Tools.4.1.23\tools\Microsoft.FSharp.Targets + + + + + + $(FSharpSourcesRoot)\..\$(Configuration)\$(TargetFrameworkOutputDirectory)\bin + $(FSharpSourcesRoot)\..\Proto\$(ProtoFlavour)\bin + fsc-proto.exe + ..\Proto\$(ProtoFlavour)\bin\Microsoft.Portable.FSharp-proto.targets + + + + + + $(FSharpSourcesRoot)\..\$(Configuration)\$(TargetFrameworkOutputDirectory)\bin + $(FSharpSourcesRoot)\..\Proto\$(ProtoFlavour)\bin + fsc-proto.exe + ..\Proto\$(ProtoFlavour)\bin\Microsoft.FSharp-proto.targets + + + + + + ValidateBuildTools;$(CompileDependsOn) + + + + + + + + + + + + + + + + + + + + + + + + + + $(NUGET_PACKAGES) + + $(FSharpSourcesRoot)\..\.nuget\ + -ConfigFile "$(NuGetConfigFile)" + "$(NuGetToolPath)NuGet.exe install -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config" + "$(NuGetToolPath)NuGet.exe" restore -OutputDirectory "$(PackagesDir)" -Config "$(NuGetToolPath)NuGet.Config" + + + true + + + + + + $(OutputPath)$(AssemblyName).xml + + + + https://github.com/Microsoft/visualfsharp/blob/master/License.txt + https://github.com/Microsoft/visualfsharp + $(NuGetPerBuildPreReleaseVersion) + Microsoft + Visual F# Compiler FSharp coreclr functional programming + + + + + $(CompileDependsOn);CopyAndSubstituteTextFiles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory.TrimEnd("\")))) + $(SrcRootDirectory.Replace("\", "\\")) + + + + + + + + + + + + + + + + + + + + + + $([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath))) + + + + + + + + $([System.IO.Path]::GetDirectoryName($(BuildVersionFilePath))) + $(NuGetPerBuildPreReleaseVersion) + $([MSBuild]::Add($(PackageVersionMinor), 1)) + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/absil/il.fs b/src/absil/il.fs index 956afc6368..8d4bc02132 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.AbstractIL.IL +module Microsoft.FSharp.Compiler.AbstractIL.IL #nowarn "49" #nowarn "343" // The type 'ILAssemblyRef' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'. @@ -52,15 +52,18 @@ let lazyMap f (x:Lazy<_>) = [] type PrimaryAssembly = | Mscorlib - | DotNetCore + | System_Runtime + | NetStandard member this.Name = match this with | Mscorlib -> "mscorlib" - | DotNetCore -> "System.Runtime" + | System_Runtime -> "System.Runtime" + | NetStandard -> "netstandard" static member IsSomePrimaryAssembly n = n = PrimaryAssembly.Mscorlib.Name - || n = PrimaryAssembly.DotNetCore.Name + || n = PrimaryAssembly.System_Runtime.Name + || n = PrimaryAssembly.NetStandard.Name // -------------------------------------------------------------------- // Utilities: type names @@ -561,8 +564,7 @@ type ILTypeRef = member x.ApproxId = x.hashCode member x.AsBoxedType (tspec:ILTypeSpec) = - match List.length tspec.tspecInst with - | 0 -> + if isNil tspec.tspecInst then let v = x.asBoxedType match box v with | null -> @@ -570,7 +572,8 @@ type ILTypeRef = x.asBoxedType <- r r | _ -> v - | _ -> ILType.Boxed tspec + else + ILType.Boxed tspec override x.GetHashCode() = x.hashCode override x.Equals(yobj) = @@ -1072,6 +1075,7 @@ type ILMethodBody = { IsZeroInit: bool; MaxStack: int32; NoInlining: bool; + AggressiveInlining: bool; Locals: ILLocals; Code: ILCode; SourceMarker: ILSourceMarker option } @@ -1371,6 +1375,7 @@ type ILMethodDef = IsPreserveSig: bool; IsMustRun: bool; IsNoInline: bool; + IsAggressiveInline : bool GenericParams: ILGenericParameterDefs; CustomAttrs: ILAttributes; } member x.ParameterTypes = typesOfILParams x.Parameters @@ -1588,7 +1593,7 @@ and [] ILTypeDefs(f : unit -> (string list * string * ILAttributes * Laz t) member x.AsArray = [| for (_,_,_,ltd) in array.Value -> ltd.Force() |] - member x.AsList = x.AsArray |> Array.toList + member x.AsList = [ for (_,_,_,ltd) in array.Value -> ltd.Force() ] interface IEnumerable with member x.GetEnumerator() = ((x :> IEnumerable).GetEnumerator() :> IEnumerator) @@ -2276,6 +2281,7 @@ let mkILMethodBody (zeroinit,locals,maxstack,code,tag) : ILMethodBody = { IsZeroInit=zeroinit MaxStack=maxstack NoInlining=false + AggressiveInlining=false Locals= locals Code= code SourceMarker=tag } @@ -2311,6 +2317,7 @@ let mkILCtor (access,args,impl) = IsUnmanagedExport=false; IsSynchronized=false; IsNoInline=false; + IsAggressiveInline=false IsMustRun=false; IsPreserveSig=false; CustomAttrs = emptyILCustomAttrs; } @@ -2364,6 +2371,7 @@ let mkILStaticMethod (genparams,nm,access,args,ret,impl) = IsUnmanagedExport=false; IsSynchronized=false; IsNoInline=false; + IsAggressiveInline=false; IsMustRun=false; IsPreserveSig=false; } @@ -2393,6 +2401,7 @@ let mkILClassCtor impl = IsUnmanagedExport=false; IsSynchronized=false; IsNoInline=false; + IsAggressiveInline=false IsMustRun=false; IsPreserveSig=false; } @@ -2433,6 +2442,7 @@ let mkILGenericVirtualMethod (nm,access,genparams,actual_args,actual_ret,impl) = IsUnmanagedExport=false; IsSynchronized=false; IsNoInline=false; + IsAggressiveInline=false IsMustRun=false; IsPreserveSig=false; } @@ -2462,6 +2472,7 @@ let mkILGenericNonVirtualMethod (nm,access,genparams, actual_args,actual_ret, im IsUnmanagedExport=false; IsSynchronized=false; IsNoInline=false; + IsAggressiveInline=false IsMustRun=false; IsPreserveSig=false; } diff --git a/src/absil/il.fsi b/src/absil/il.fsi index 3c9de895d0..11574eed33 100755 --- a/src/absil/il.fsi +++ b/src/absil/il.fsi @@ -2,7 +2,11 @@ /// The "unlinked" view of .NET metadata and code. Central to /// to Abstract IL library -module (*internal*) Microsoft.FSharp.Compiler.AbstractIL.IL +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.AbstractIL.IL +#else +module internal Microsoft.FSharp.Compiler.AbstractIL.IL +#endif open Internal.Utilities open System.Collections.Generic @@ -10,7 +14,8 @@ open System.Collections.Generic [] type PrimaryAssembly = | Mscorlib - | DotNetCore + | System_Runtime + | NetStandard member Name: string @@ -799,9 +804,10 @@ type ILLocals = list [] type ILMethodBody = { IsZeroInit: bool; - /// strictly speakin should be a uint16 + /// strictly speaking should be a uint16 MaxStack: int32; NoInlining: bool; + AggressiveInlining: bool; Locals: ILLocals; Code: ILCode; SourceMarker: ILSourceMarker option } @@ -850,6 +856,7 @@ type ILAttribute = [] type ILAttributes = + member AsArray : ILAttribute [] member AsList : ILAttribute list /// Method parameters and return values. @@ -1048,6 +1055,7 @@ type ILMethodDef = /// .NET 2.0 feature: SafeHandle finalizer must be run. IsMustRun: bool; IsNoInline: bool; + IsAggressiveInline: bool; GenericParams: ILGenericParameterDefs; CustomAttrs: ILAttributes; } diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 3a8d7d92d8..d3051cf477 100755 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +#else +module internal Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +#endif #nowarn "1178" // The struct, record or union type 'internal_instr_extension' is not structurally comparable because the type @@ -21,6 +25,20 @@ let (>>>&) (x:int32) (n:int32) = int32 (uint32 x >>> n) let notlazy v = Lazy<_>.CreateFromValue v let inline isNil l = List.isEmpty l + +/// Returns true if the list has less than 2 elements. Otherwise false. +let inline isNilOrSingleton l = + match l with + | [] + | [_] -> true + | _ -> false + +/// Returns true if the list contains exactly 1 element. Otherwise false. +let inline isSingleton l = + match l with + | [_] -> true + | _ -> false + let inline isNonNull x = not (isNull x) let inline nonNull msg x = if isNull x then failwith ("null: " ^ msg) else x let (===) x y = LanguagePrimitives.PhysicalEquality x y @@ -265,7 +283,7 @@ module Option = module List = - let item n xs = List.nth xs n + //let item n xs = List.nth xs n #if FX_RESHAPED_REFLECTION open PrimReflectionAdapters open Microsoft.FSharp.Core.ReflectionAdapters @@ -431,17 +449,7 @@ module List = match l with | [] -> false | h::t -> LanguagePrimitives.PhysicalEquality x h || memq x t - - // must be tail recursive - let mapFold (f:'a -> 'b -> 'c * 'a) (s:'a) (l:'b list) : 'c list * 'a = - match l with - | [] -> [], s - | [h] -> let f = OptimizedClosures.FSharpFunc<_,_,_>.Adapt(f) - let h',s' = f.Invoke(s, h) - [h'], s' - | _ -> - List.mapFold f s l - + // Not tail recursive let rec mapFoldBack f l s = match l with @@ -469,7 +477,7 @@ module List = | x::xs -> fhead x :: List.map ftail xs let collectFold f s l = - let l, s = mapFold f s l + let l, s = List.mapFold f s l List.concat l, s let collect2 f xs ys = List.concat (List.map2 f xs ys) @@ -478,7 +486,7 @@ module List = let iterSquared f xss = xss |> List.iter (List.iter f) let collectSquared f xss = xss |> List.collect (List.collect f) let mapSquared f xss = xss |> List.map (List.map f) - let mapFoldSquared f z xss = mapFold (mapFold f) z xss + let mapFoldSquared f z xss = List.mapFold (List.mapFold f) z xss let forallSquared f xss = xss |> List.forall (List.forall f) let mapiSquared f xss = xss |> List.mapi (fun i xs -> xs |> List.mapi (fun j x -> f i j x)) let existsSquared f xss = xss |> List.exists (fun xs -> xs |> List.exists (fun x -> f x)) @@ -1074,6 +1082,42 @@ module Tables = else res <- f x; t.[x] <- res; res + +/// Interface that defines methods for comparing objects using partial equality relation +type IPartialEqualityComparer<'T> = + inherit IEqualityComparer<'T> + /// Can the specified object be tested for equality? + abstract InEqualityRelation : 'T -> bool + +module IPartialEqualityComparer = + let On f (c: IPartialEqualityComparer<_>) = + { new IPartialEqualityComparer<_> with + member __.InEqualityRelation x = c.InEqualityRelation (f x) + member __.Equals(x, y) = c.Equals(f x, f y) + member __.GetHashCode x = c.GetHashCode(f x) } + + + + // Wrapper type for use by the 'partialDistinctBy' function + [] + type private WrapType<'T> = Wrap of 'T + + // Like Seq.distinctBy but only filters out duplicates for some of the elements + let partialDistinctBy (per:IPartialEqualityComparer<'T>) seq = + let wper = + { new IPartialEqualityComparer> with + member __.InEqualityRelation (Wrap x) = per.InEqualityRelation (x) + member __.Equals(Wrap x, Wrap y) = per.Equals(x, y) + member __.GetHashCode (Wrap x) = per.GetHashCode(x) } + // Wrap a Wrap _ around all keys in case the key type is itself a type using null as a representation + let dict = Dictionary,obj>(wper) + seq |> List.filter (fun v -> + let key = Wrap(v) + if (per.InEqualityRelation(v)) then + if dict.ContainsKey(key) then false else (dict.[key] <- null; true) + else true) + + //------------------------------------------------------------------------- // Library: Name maps //------------------------------------------------------------------------ diff --git a/src/absil/ilprint.fs b/src/absil/ilprint.fs index 75cc2a0bf9..79c4fe0b91 100755 --- a/src/absil/ilprint.fs +++ b/src/absil/ilprint.fs @@ -846,10 +846,11 @@ let goutput_mdef env os md = output_string os " "; (goutput_params menv) os md.Parameters; output_string os " "; - if md.IsSynchronized then output_string os "synchronized "; - if md.IsMustRun then output_string os "/* mustrun */ "; - if md.IsPreserveSig then output_string os "preservesig "; - if md.IsNoInline then output_string os "noinlining "; + if md.IsSynchronized then output_string os "synchronized " + if md.IsMustRun then output_string os "/* mustrun */ " + if md.IsPreserveSig then output_string os "preservesig " + if md.IsNoInline then output_string os "noinlining " + if md.IsAggressiveInline then output_string os "aggressiveinlining " (goutput_mbody is_entrypoint menv) os md; output_string os "\n" diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index 4f4533af81..41e534aedb 100755 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -2301,6 +2301,7 @@ and seekReadMethod ctxt numtypars (idx:int) = let internalcall = (implflags &&& 0x1000) <> 0x0 let synchronized = (implflags &&& 0x0020) <> 0x0 let noinline = (implflags &&& 0x0008) <> 0x0 + let aggressiveinline = (implflags &&& 0x0100) <> 0x0 let mustrun = (implflags &&& 0x0040) <> 0x0 let cctor = (nm = ".cctor") let ctor = (nm = ".ctor") @@ -2338,6 +2339,7 @@ and seekReadMethod ctxt numtypars (idx:int) = IsUnmanagedExport=export IsSynchronized=synchronized IsNoInline=noinline + IsAggressiveInline=aggressiveinline IsMustRun=mustrun IsPreserveSig=preservesig IsManaged = not unmanaged @@ -2358,7 +2360,7 @@ and seekReadMethod ctxt numtypars (idx:int) = //if codeRVA <> 0x0 then dprintn "non-IL or abstract method with non-zero RVA" mkMethBodyLazyAux (notlazy MethodBody.Abstract) else - seekReadMethodRVA ctxt (idx,nm,internalcall,noinline,numtypars) codeRVA + seekReadMethodRVA ctxt (idx,nm,internalcall,noinline,aggressiveinline,numtypars) codeRVA } @@ -2877,9 +2879,9 @@ and seekReadTopCode ctxt numtypars (sz:int) start seqpoints = instrs,rawToLabel, lab2pc, raw2nextLab #if FX_NO_PDB_READER -and seekReadMethodRVA ctxt (_idx,nm,_internalcall,noinline,numtypars) rva = +and seekReadMethodRVA ctxt (_idx,nm,_internalcall,noinline,aggressiveinline,numtypars) rva = #else -and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,numtypars) rva = +and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,aggressiveinline,numtypars) rva = #endif mkMethBodyLazyAux (lazy @@ -2965,6 +2967,7 @@ and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,numtypars) rva = { IsZeroInit=false MaxStack= 8 NoInlining=noinline + AggressiveInlining=aggressiveinline Locals=List.empty SourceMarker=methRangePdbInfo Code=code } @@ -3090,6 +3093,7 @@ and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,numtypars) rva = { IsZeroInit=initlocals MaxStack= maxstack NoInlining=noinline + AggressiveInlining=aggressiveinline Locals = locals Code=code SourceMarker=methRangePdbInfo} @@ -3967,7 +3971,7 @@ let OpenILModuleReader infile opts = // ++GLOBAL MUTABLE STATE (concurrency safe via locking) type ILModuleReaderCacheLockToken() = interface LockToken -let ilModuleReaderCache = new AgedLookup(0, areSame=(fun (x,y) -> x = y)) +let ilModuleReaderCache = new AgedLookup(0, areSimilar=(fun (x,y) -> x = y)) let ilModuleReaderCacheLock = Lock() let OpenILModuleReaderAfterReadingAllBytes infile opts = @@ -3976,15 +3980,17 @@ let OpenILModuleReaderAfterReadingAllBytes infile opts = try (FileSystem.GetFullPathShim(infile), FileSystem.GetLastWriteTimeShim(infile), - opts.ilGlobals.primaryAssemblyName, + opts.ilGlobals.primaryAssemblyScopeRef, opts.pdbPath.IsSome), true with e -> - System.Diagnostics.Debug.Assert(false, "Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache. Falling back to uncached.") - ("",System.DateTime.Now,"",false), false + System.Diagnostics.Debug.Assert(false, sprintf "Failed to compute key in OpenILModuleReaderAfterReadingAllBytes cache for '%s'. Falling back to uncached." infile) + ("",System.DateTime.Now,ILScopeRef.Local,false), false + let cacheResult = if not succeeded then None // Fall back to uncached. else if opts.pdbPath.IsSome then None // can't used a cached entry when reading PDBs, since it makes the returned object IDisposable else ilModuleReaderCacheLock.AcquireLock (fun ltok -> ilModuleReaderCache.TryGet(ltok, key)) + match cacheResult with | Some(ilModuleReader) -> ilModuleReader | None -> diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index 9af6d441de..8a67b5e084 100755 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -301,7 +301,7 @@ module Zmap = let force x m str = match Zmap.tryFind x m with Some y -> y | None -> failwithf "Zmap.force: %s: x = %+A" str x let equalTypes (s:Type) (t:Type) = s.Equals(t) -let equalTypeLists ss tt = List.lengthsEqAndForall2 equalTypes ss tt +let equalTypeLists ss tt = List.lengthsEqAndForall2 equalTypes ss tt let getGenericArgumentsOfType (typT : Type) = if typT.IsGenericType then typT.GetGenericArguments() else [| |] @@ -1466,6 +1466,7 @@ let convMethodImplFlags mdef = ||| flagsIf mdef.IsPreserveSig MethodImplAttributes.PreserveSig ||| flagsIf mdef.IsSynchronized MethodImplAttributes.Synchronized ||| flagsIf (match mdef.mdBody.Contents with MethodBody.IL b -> b.NoInlining | _ -> false) MethodImplAttributes.NoInlining + ||| flagsIf (match mdef.mdBody.Contents with MethodBody.IL b -> b.AggressiveInlining | _ -> false) MethodImplAttributes.AggressiveInlining //---------------------------------------------------------------------------- // buildMethodPass2 diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index 0349ae5ca7..c75b4a7735 100755 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -105,7 +105,8 @@ let getUncodedToken (tab:TableName) idx = ((tab.Index <<< 24) ||| idx) // 0x01-0x08, 0x0E-0x1F, 0x27, 0x2D, // 0x7F. Otherwise, it holds 0. The 1 signifies Unicode characters that require handling beyond that normally provided for 8-bit encoding sets. -// HOWEVER, there is a discrepancy here between the ECMA spec and the Microsoft C# implementation. The code below follows the latter. We�ve raised the issue with both teams. See Dev10 bug 850073 for details. +// HOWEVER, there is a discrepancy here between the ECMA spec and the Microsoft C# implementation. +// The code below follows the latter. We've raised the issue with both teams. See Dev10 bug 850073 for details. let markerForUnicodeBytes (b:byte[]) = let len = b.Length @@ -550,6 +551,7 @@ type MetadataTable = type cenv = { ilg: ILGlobals emitTailcalls: bool + deterministic: bool showTimes: bool desiredMetadataVersion: ILVersionInfo requiredDataFixups: (int32 * (int * bool)) list ref @@ -2537,6 +2539,7 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) = | _ -> false) then 0x1000 else 0x0) ||| // RTSpecialName (if md.IsReqSecObj then 0x8000 else 0x0) ||| (if md.HasSecurity || not md.SecurityDecls.AsList.IsEmpty then 0x4000 else 0x0) + let implflags = (match md.mdCodeKind with | MethodCodeKind.Native -> 0x0001 @@ -2548,7 +2551,8 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) = (if md.IsPreserveSig then 0x0080 else 0x0000) ||| (if md.IsSynchronized then 0x0020 else 0x0000) ||| (if md.IsMustRun then 0x0040 else 0x0000) ||| - (if (md.IsNoInline || (match md.mdBody.Contents with MethodBody.IL il -> il.NoInlining | _ -> false)) then 0x0008 else 0x0000) + (if (md.IsNoInline || (match md.mdBody.Contents with MethodBody.IL il -> il.NoInlining | _ -> false)) then 0x0008 else 0x0000) ||| + (if (md.IsAggressiveInline || (match md.mdBody.Contents with MethodBody.IL il -> il.AggressiveInlining | _ -> false)) then 0x0100 else 0x0000) if md.IsEntryPoint then if cenv.entrypoint <> None then failwith "duplicate entrypoint" @@ -2780,8 +2784,8 @@ let rec GenTypeDefPass3 enc cenv (td:ILTypeDef) = if Option.isSome layout.Pack || Option.isSome layout.Size then AddUnsharedRow cenv TableNames.ClassLayout (UnsharedRow - [| UShort (match layout.Pack with None -> uint16 0x0 | Some p -> p) - ULong (match layout.Size with None -> 0x0 | Some p -> p) + [| UShort (defaultArg layout.Pack (uint16 0x0)) + ULong (defaultArg layout.Size 0x0) SimpleIndex (TableNames.TypeDef, tidx) |]) |> ignore td.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_TypeDef,tidx) @@ -2902,9 +2906,15 @@ and newGuid (modul: ILModuleDef) = let m2 = hash modul.Name [| b0 m; b1 m; b2 m; b3 m; b0 m2; b1 m2; b2 m2; b3 m2; 0xa7uy; 0x45uy; 0x03uy; 0x83uy; b0 n; b1 n; b2 n; b3 n |] -and GetModuleAsRow cenv (modul: ILModuleDef) = +and deterministicGuid (modul: ILModuleDef) = + let n = 16909060 + let m = hash n + let m2 = hash modul.Name + [| b0 m; b1 m; b2 m; b3 m; b0 m2; b1 m2; b2 m2; b3 m2; 0xa7uy; 0x45uy; 0x03uy; 0x83uy; b0 n; b1 n; b2 n; b3 n |] + +and GetModuleAsRow (cenv:cenv) (modul: ILModuleDef) = // Store the generated MVID in the environment (needed for generating debug information) - let modulGuid = newGuid modul + let modulGuid = if cenv.deterministic then deterministicGuid modul else newGuid modul cenv.moduleGuid <- modulGuid UnsharedRow [| UShort (uint16 0x0) @@ -2953,11 +2963,12 @@ let GenModule (cenv : cenv) (modul: ILModuleDef) = GenTypeDefsPass4 [] cenv tds reportTime cenv.showTimes "Module Generation Pass 4" -let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILGlobals, emitTailcalls,showTimes) (m : ILModuleDef) cilStartAddress = +let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILGlobals, emitTailcalls, deterministic, showTimes) (m : ILModuleDef) cilStartAddress = let isDll = m.IsDLL let cenv = { emitTailcalls=emitTailcalls + deterministic = deterministic showTimes=showTimes ilg = ilg desiredMetadataVersion=desiredMetadataVersion @@ -3097,7 +3108,7 @@ module FileSystemUtilites = #endif () -let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls,showTimes) modul cilStartAddress = +let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls,deterministic,showTimes) modul cilStartAddress = // When we know the real RVAs of the data section we fixup the references for the FieldRVA table. // These references are stored as offsets into the metadata we return from this function @@ -3106,7 +3117,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls let next = cilStartAddress let strings,userStrings,blobs,guids,tables,entryPointToken,code,requiredStringFixups,data,resources,pdbData,mappings = - generateIL requiredDataFixups (desiredMetadataVersion,generatePdb,ilg,emitTailcalls,showTimes) modul cilStartAddress + generateIL requiredDataFixups (desiredMetadataVersion,generatePdb,ilg,emitTailcalls,deterministic,showTimes) modul cilStartAddress reportTime showTimes "Generated Tables and Code" let tableSize (tab: TableName) = tables.[tab.Index].Count @@ -3403,7 +3414,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls reportTime showTimes "Layout Metadata" - let metadata = + let metadata, guidStart = let mdbuf = ByteBuffer.Create 500000 mdbuf.EmitIntsAsBytes [| 0x42; 0x53; 0x4a; 0x42; // Magic signature @@ -3461,6 +3472,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls reportTime showTimes "Write Metadata User Strings"; // The GUID stream + let guidStart = mdbuf.Position Array.iter mdbuf.EmitBytes guids; // The blob stream @@ -3472,7 +3484,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls mdbuf.EmitIntAsByte 0x00; reportTime showTimes "Write Blob Stream"; // Done - close the buffer and return the result. - mdbuf.Close() + mdbuf.Close(), guidStart // Now we know the user string tables etc. we can fixup the @@ -3487,7 +3499,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls applyFixup32 code locInCode token reportTime showTimes "Fixup Metadata"; - entryPointToken,code, codePadding,metadata,data,resources,!requiredDataFixups,pdbData,mappings + entryPointToken,code, codePadding,metadata,data,resources,!requiredDataFixups,pdbData,mappings,guidStart //--------------------------------------------------------------------- // PHYSICAL METADATA+BLOBS --> PHYSICAL PE FORMAT @@ -3549,7 +3561,7 @@ let writeBytes (os: BinaryWriter) (chunk:byte[]) = os.Write(chunk,0,chunk.Length let writeBinaryAndReportMappings (outfile, ilg: ILGlobals, pdbfile: string option, signer: ILStrongNameSigner option, portablePDB, embeddedPDB, - embedAllSource, embedSourceList, sourceLink, emitTailcalls, showTimes, dumpDebugInfo) modul = + embedAllSource, embedSourceList, sourceLink, emitTailcalls, deterministic, showTimes, dumpDebugInfo ) modul = // Store the public key from the signer into the manifest. This means it will be written // to the binary and also acts as an indicator to leave space for delay sign @@ -3665,8 +3677,8 @@ let writeBinaryAndReportMappings (outfile, | Some v -> v | None -> failwith "Expected msorlib to have a version number" - let entryPointToken,code,codePadding,metadata,data,resources,requiredDataFixups,pdbData,mappings = - writeILMetadataAndCode ((pdbfile <> None), desiredMetadataVersion, ilg,emitTailcalls,showTimes) modul next + let entryPointToken,code,codePadding,metadata,data,resources,requiredDataFixups,pdbData,mappings,guidStart = + writeILMetadataAndCode ((pdbfile <> None), desiredMetadataVersion, ilg,emitTailcalls, deterministic, showTimes) modul next reportTime showTimes "Generated IL and metadata"; let _codeChunk,next = chunk code.Length next @@ -3702,7 +3714,7 @@ let writeBinaryAndReportMappings (outfile, let pdbOpt = match portablePDB with | true -> - let (uncompressedLength, contentId, stream) as pdbStream = generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData + 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 @@ -3848,7 +3860,33 @@ let writeBinaryAndReportMappings (outfile, writeInt32AsUInt16 os 0x014c; // Machine - IMAGE_FILE_MACHINE_I386 writeInt32AsUInt16 os numSections; - writeInt32 os timestamp // date since 1970 + + let pdbData = + if deterministic then + // Hash code, data and metadata + use sha = System.Security.Cryptography.SHA1.Create() // IncrementalHash is core only + let hCode = sha.ComputeHash code + let hData = sha.ComputeHash data + let hMeta = sha.ComputeHash metadata + let final = [| hCode; hData; hMeta |] |> Array.collect id |> sha.ComputeHash + + // Confirm we have found the correct data and aren't corrupting the metadata + if metadata.[ guidStart..guidStart+3] <> [| 4uy; 3uy; 2uy; 1uy |] then failwith "Failed to find MVID" + if metadata.[ guidStart+12..guidStart+15] <> [| 4uy; 3uy; 2uy; 1uy |] then failwith "Failed to find MVID" + + // Update MVID guid in metadata + Array.blit final 0 metadata guidStart 16 + + // Use last 4 bytes for timestamp - High bit set, to stop tool chains becoming confused + let timestamp = int final.[16] ||| (int final.[17] <<< 8) ||| (int final.[18] <<< 16) ||| (int (final.[19] ||| 128uy) <<< 24) + writeInt32 os timestamp + // Update pdbData with new guid and timestamp. Portable and embedded PDBs don't need the ModuleID + // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-determinsitic Windows native code + { pdbData with ModuleID = final.[0..15] ; Timestamp = timestamp } + else + writeInt32 os timestamp // date since 1970 + pdbData + writeInt32 os 0x00; // Pointer to Symbol Table Always 0 // 00000090 writeInt32 os 0x00; // Number of Symbols Always 0 @@ -4276,12 +4314,13 @@ type options = sourceLink: string signer: ILStrongNameSigner option emitTailcalls : bool + deterministic : bool showTimes: bool dumpDebugInfo:bool } let WriteILBinary (outfile, (args: options), modul) = writeBinaryAndReportMappings (outfile, args.ilg, args.pdbfile, args.signer, args.portablePDB, args.embeddedPDB, args.embedAllSource, - args.embedSourceList, args.sourceLink, args.emitTailcalls, args.showTimes, args.dumpDebugInfo) modul + args.embedSourceList, args.sourceLink, args.emitTailcalls, args.deterministic, args.showTimes, args.dumpDebugInfo) modul |> ignore diff --git a/src/absil/ilwrite.fsi b/src/absil/ilwrite.fsi index 6ab71287d3..89c6fd0354 100755 --- a/src/absil/ilwrite.fsi +++ b/src/absil/ilwrite.fsi @@ -25,6 +25,7 @@ type options = sourceLink: string signer : ILStrongNameSigner option emitTailcalls: bool + deterministic: bool showTimes : bool dumpDebugInfo : bool } diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index 4ee0a0f0d8..0c7d112235 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -219,7 +219,7 @@ let getRowCounts tableRowCounts = tableRowCounts |> Seq.iter(fun x -> builder.Add(x)) builder.MoveToImmutable() -let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sourceLink:string) showTimes (info:PdbData) = +let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sourceLink:string) showTimes (info:PdbData) isDeterministic = sortMethods showTimes info let externalRowCounts = getRowCounts info.TableRowCounts let docs = @@ -260,12 +260,9 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou let documentIndex = let includeSource file = - let isInList = - if isNil embedSourceList then false - else - embedSourceList |> List.tryFind(fun f -> String.Compare(file, f, StringComparison.OrdinalIgnoreCase ) = 0) |> Option.isSome + let isInList = embedSourceList |> List.exists (fun f -> String.Compare(file, f, StringComparison.OrdinalIgnoreCase ) = 0) - if not embedAllSource && not isInList || not (File.Exists(file)) then + if not embedAllSource && not isInList || not (File.Exists file) then None else let stream = File.OpenRead(file) @@ -448,7 +445,19 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou | None -> MetadataTokens.MethodDefinitionHandle(0) | Some x -> MetadataTokens.MethodDefinitionHandle(x) - let serializer = PortablePdbBuilder(metadata, externalRowCounts, entryPoint, null) + let deterministicIdProvider isDeterministic : System.Func, BlobContentId> = + match isDeterministic with + | false -> null + | true -> + let convert (content:IEnumerable) = + use sha = System.Security.Cryptography.SHA1.Create() // IncrementalHash is core only + let hash = content + |> Seq.map ( fun c -> c.GetBytes().Array |> sha.ComputeHash ) + |> Seq.collect id |> Array.ofSeq |> sha.ComputeHash + BlobContentId.FromHash(hash) + System.Func, BlobContentId>( convert ) + + let serializer = PortablePdbBuilder(metadata, externalRowCounts, entryPoint, deterministicIdProvider isDeterministic) let blobBuilder = new BlobBuilder() let contentId= serializer.Serialize(blobBuilder) let portablePdbStream = new MemoryStream() diff --git a/src/absil/ilwritepdb.fsi b/src/absil/ilwritepdb.fsi index d6a3f8d83c..e2b310747b 100644 --- a/src/absil/ilwritepdb.fsi +++ b/src/absil/ilwritepdb.fsi @@ -82,7 +82,7 @@ type idd = iddData: byte[]; iddChunk: BinaryChunk } -val generatePortablePdb : embedAllSource:bool -> embedSourceList:string list -> sourceLink: string -> showTimes:bool -> info:PdbData -> (int64 * BlobContentId * MemoryStream) +val generatePortablePdb : embedAllSource:bool -> embedSourceList:string list -> sourceLink: string -> showTimes:bool -> info:PdbData -> isDeterministic:bool -> (int64 * BlobContentId * MemoryStream) val compressPortablePdbStream : uncompressedLength:int64 -> contentId:BlobContentId -> stream:MemoryStream -> (int64 * BlobContentId * MemoryStream) val embedPortablePdbInfo : uncompressedLength:int64 -> contentId:BlobContentId -> stream:MemoryStream -> showTimes:bool -> fpdb:string -> cvChunk:BinaryChunk -> pdbChunk:BinaryChunk -> idd[] val writePortablePdbInfo : contentId:BlobContentId -> stream:MemoryStream -> showTimes:bool -> fpdb:string -> cvChunk:BinaryChunk -> idd[] diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs new file mode 100644 index 0000000000..bbb567bd41 --- /dev/null +++ b/src/assemblyinfo/assemblyinfo.FSharp.Build.dll.fs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp +open System.Reflection +[] +[] +[] +[] +[] +do() + +#if NO_STRONG_NAMES +[] +#endif +#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY +[] +#endif + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + +do() diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs new file mode 100644 index 0000000000..59cfa768ea --- /dev/null +++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp +open System.Reflection +open System.Runtime.InteropServices + +[] +[] +[] +[] +[] +[] + +#if NO_STRONG_NAMES +[] +[] +#endif + +#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY +[] +[] +#endif + +#if STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY +[] +[] +#endif + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + +do() diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs new file mode 100644 index 0000000000..99584f0034 --- /dev/null +++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Private.dll.fs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp +open System.Reflection +open System.Runtime.InteropServices + +[] +[] +[] +[] +[] +[] + +#if NO_STRONG_NAMES +[] +[] +[] +[] +[] +[] +[] +[] +[] + +// Note: internals visible to unit test DLLs in Retail (and all) builds. +[] +[] +[] +[] +[] +#endif +#if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY + +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +#endif +#if STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +[] +#endif + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + +do() diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs old mode 100755 new mode 100644 index 13141ee3b6..a3a2d38968 --- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs +++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Service.dll.fs @@ -4,31 +4,30 @@ namespace Microsoft.FSharp open System.Reflection open System.Runtime.InteropServices -[] -[] -[] -[] - -[] -[] -[] -[] -[] -[] -[] +[] +[] +[] +[] +[] [] #if NO_STRONG_NAMES [] [] [] -[] [] [] [] [] [] [] +[] +[] +[] +[] +[] +[] +[] // Note: internals visible to unit test DLLs in Retail (and all) builds. [] @@ -38,10 +37,10 @@ open System.Runtime.InteropServices [] #endif #if STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY + [] [] [] -[] [] [] [] @@ -59,7 +58,6 @@ open System.Runtime.InteropServices [] [] [] -[] [] [] [] @@ -72,4 +70,12 @@ open System.Runtime.InteropServices [] [] #endif + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + do() diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs new file mode 100644 index 0000000000..4b51c78289 --- /dev/null +++ b/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp +open System.Reflection +open System.Runtime.InteropServices + +[] +[] +[] +[] +[] +#if !FSCORE_PORTABLE_OLD +[] +#endif + +#if PORTABLE +[] +[] +#endif + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + +do() + diff --git a/src/assemblyinfo/assemblyinfo.fsc.exe.fs b/src/assemblyinfo/assemblyinfo.fsc.exe.fs index 353c1635ca..f431d42923 100755 --- a/src/assemblyinfo/assemblyinfo.fsc.exe.fs +++ b/src/assemblyinfo/assemblyinfo.fsc.exe.fs @@ -12,4 +12,12 @@ open System.Runtime.InteropServices [] [] + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + do() diff --git a/src/assemblyinfo/assemblyinfo.fsi.exe.fs b/src/assemblyinfo/assemblyinfo.fsi.exe.fs index 3c906f8805..5023b66eac 100755 --- a/src/assemblyinfo/assemblyinfo.fsi.exe.fs +++ b/src/assemblyinfo/assemblyinfo.fsi.exe.fs @@ -7,4 +7,12 @@ open System.Reflection [] [] [] + +// Until dotnet sdk can version assemblies, use this +#if BUILD_FROM_SOURCE +[] +[] +[] +#endif + do() diff --git a/src/buildfromsource.cmd b/src/buildfromsource.cmd new file mode 100644 index 0000000000..9d50b36d78 --- /dev/null +++ b/src/buildfromsource.cmd @@ -0,0 +1,35 @@ +@if "%_echo%"=="" echo off + +set __scriptpath=%~dp0 + +rem build tools +dotnet restore %__scriptpath%buildtools\fssrgen\fssrgen.fsproj +if ERRORLEVEL 1 echo Error: failed && goto :failure +dotnet publish %__scriptpath%buildtools\fssrgen\fssrgen.fsproj -o %__scriptpath%..\Tools\fssrgen +if ERRORLEVEL 1 echo Error: failed && goto :failure + +dotnet restore %__scriptpath%buildtools\fslex\fslex.fsproj +if ERRORLEVEL 1 echo Error: failed && goto :failure +dotnet publish %__scriptpath%buildtools\fslex\fslex.fsproj -o %__scriptpath%..\Tools\fslex +if ERRORLEVEL 1 echo Error: failed && goto :failure +dotnet restore %__scriptpath%buildtools\fsyacc\fsyacc.fsproj +if ERRORLEVEL 1 echo Error: failed && goto :failure +dotnet publish %__scriptpath%buildtools\fsyacc\fsyacc.fsproj -o %__scriptpath%..\Tools\fsyacc +if ERRORLEVEL 1 echo Error: failed && goto :failure + +rem build and pack tools +dotnet restore %__scriptpath%fsharp\FSharp.Compiler.nuget\FSharp.Compiler.nuget.BuildFromSource.fsproj +if ERRORLEVEL 1 echo Error: failed && goto :failure +dotnet pack %__scriptpath%fsharp\FSharp.Compiler.nuget\FSharp.Compiler.nuget.BuildFromSource.fsproj -c release +if ERRORLEVEL 1 echo Error: failed && goto :failure + +goto :success + +REM ------ exit ------------------------------------- +:failure +endlocal +exit /b 1 + +:success +endlocal +exit /b 0 diff --git a/src/buildfromsource.sh b/src/buildfromsource.sh new file mode 100755 index 0000000000..64f0a11f45 --- /dev/null +++ b/src/buildfromsource.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + +__scriptpath=$(cd "$(dirname "$0")"; pwd -P) + +# build tools +dotnet restore $__scriptpath/buildtools/fssrgen/fssrgen.fsproj +dotnet publish $__scriptpath/buildtools/fssrgen/fssrgen.fsproj -o $__scriptpath/../Tools/fssrgen +dotnet restore $__scriptpath/buildtools/fslex/fslex.fsproj +dotnet publish $__scriptpath/buildtools/fslex/fslex.fsproj -o $__scriptpath/../Tools/fslex +dotnet restore $__scriptpath/buildtools/fsyacc/fsyacc.fsproj +dotnet publish $__scriptpath/buildtools/fsyacc/fsyacc.fsproj -o $__scriptpath/../Tools/fsyacc + +# build tools +dotnet restore $__scriptpath/fsharp/FSharp.Build/FSharp.Build.BuildFromSource.fsproj +dotnet publish $__scriptpath/fsharp/FSharp.Build/FSharp.Build.BuildFromSource.fsproj + +dotnet restore $__scriptpath/fsharp/fsi/Fsi.BuildFromSource.fsproj +dotnet publish fsharp/fsi/Fsi.BuildFromSource.fsproj + +dotnet restore $__scriptpath/fsharp/Fsc/Fsc.BuildFromSource.fsproj +dotnet publish $__scriptpath/fsharp/Fsc/Fsc.BuildFromSource.fsproj + +# build and pack tools +dotnet restore $__scriptpath/fsharp/FSharp.Compiler.nuget/FSharp.Compiler.nuget.BuildFromSource.fsproj +dotnet pack $__scriptpath/fsharp/FSharp.Compiler.nuget/FSharp.Compiler.nuget.BuildFromSource.fsproj -c release diff --git a/src/buildtools/buildtools.targets b/src/buildtools/buildtools.targets new file mode 100644 index 0000000000..f82f981542 --- /dev/null +++ b/src/buildtools/buildtools.targets @@ -0,0 +1,69 @@ + + + + + CallFsLex;CallFsYacc;$(CompileDependsOn) + $(MSBuildThisFileDirectory) + fslex.exe + $(MSBuildThisFileDirectory) + fsyacc.exe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + + + diff --git a/samples/FsiExe/App.config b/src/buildtools/fslex/App.config similarity index 76% rename from samples/FsiExe/App.config rename to src/buildtools/fslex/App.config index 150b1ea19a..e1b09eda9f 100644 --- a/samples/FsiExe/App.config +++ b/src/buildtools/fslex/App.config @@ -1,15 +1,14 @@ + + + - - + - - - \ No newline at end of file diff --git a/src/buildtools/fslex/Arg.fs b/src/buildtools/fslex/Arg.fs new file mode 100644 index 0000000000..a1f63bd963 --- /dev/null +++ b/src/buildtools/fslex/Arg.fs @@ -0,0 +1,133 @@ +// (c) Microsoft Corporation 2005-2009. + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities +#else +namespace Microsoft.FSharp.Text +#endif + + +type ArgType = + | ClearArg of bool ref + | FloatArg of (float -> unit) + | IntArg of (int -> unit) + | RestArg of (string -> unit) + | SetArg of bool ref + | StringArg of (string -> unit) + | UnitArg of (unit -> unit) + static member Clear r = ClearArg r + static member Float r = FloatArg r + static member Int r = IntArg r + static member Rest r = RestArg r + static member Set r = SetArg r + static member String r = StringArg r + static member Unit r = UnitArg r + + +type ArgInfo (name,action,help) = + member x.Name = name + member x.ArgType = action + member x.HelpText = help + +exception Bad of string +exception HelpText of string + +[] +type ArgParser() = + static let getUsage specs u = + let sbuf = new System.Text.StringBuilder 100 + let pstring (s:string) = sbuf.Append s |> ignore + let pendline s = pstring s; pstring "\n" + pendline u; + List.iter (fun (arg:ArgInfo) -> + match arg.Name, arg.ArgType, arg.HelpText with + | (s, (UnitArg _ | SetArg _ | ClearArg _), helpText) -> pstring "\t"; pstring s; pstring ": "; pendline helpText + | (s, StringArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, IntArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, FloatArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, RestArg _, helpText) -> pstring "\t"; pstring s; pstring " ...: "; pendline helpText) + specs; + pstring "\t"; pstring "--help"; pstring ": "; pendline "display this list of options"; + pstring "\t"; pstring "-help"; pstring ": "; pendline "display this list of options"; + sbuf.ToString() + + + static member ParsePartial(cursor,argv,argSpecs:seq,?other,?usageText) = + let other = defaultArg other (fun _ -> ()) + let usageText = defaultArg usageText "" + let nargs = Array.length argv + incr cursor; + let argSpecs = argSpecs |> Seq.toList + let specs = argSpecs |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType) + while !cursor < nargs do + let arg = argv.[!cursor] + let rec findMatchingArg args = + match args with + | ((s, action) :: _) when s = arg -> + let getSecondArg () = + if !cursor + 1 >= nargs then + raise(Bad("option "+s+" needs an argument.\n"+getUsage argSpecs usageText)); + argv.[!cursor+1] + + match action with + | UnitArg f -> + f (); + incr cursor + | SetArg f -> + f := true; + incr cursor + | ClearArg f -> + f := false; + incr cursor + | StringArg f-> + let arg2 = getSecondArg() + f arg2; + cursor := !cursor + 2 + | IntArg f -> + let arg2 = getSecondArg () + let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in + f arg2; + cursor := !cursor + 2; + | FloatArg f -> + let arg2 = getSecondArg() + let arg2 = try float arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in + f arg2; + cursor := !cursor + 2; + | RestArg f -> + incr cursor; + while !cursor < nargs do + f (argv.[!cursor]); + incr cursor; + + | (_ :: more) -> findMatchingArg more + | [] -> + if arg = "-help" || arg = "--help" || arg = "/help" || arg = "/help" || arg = "/?" then + raise (HelpText (getUsage argSpecs usageText)) + // Note: for '/abc/def' does not count as an argument + // Note: '/abc' does + elif arg.Length>0 && (arg.[0] = '-' || (arg.[0] = '/' && not (arg.Length > 1 && arg.[1..].Contains ("/")))) then + raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage argSpecs usageText)) + else + other arg; + incr cursor + findMatchingArg specs + + static member Usage (specs,?usage) = + let usage = defaultArg usage "" + System.Console.Error.WriteLine (getUsage (Seq.toList specs) usage) + + #if FX_NO_COMMAND_LINE_ARGS + #else + static member Parse (specs,?other,?usageText) = + let current = ref 0 + let argv = System.Environment.GetCommandLineArgs() + try ArgParser.ParsePartial (current, argv, specs, ?other=other, ?usageText=usageText) + with + | Bad h + | HelpText h -> + System.Console.Error.WriteLine h; + System.Console.Error.Flush(); + System.Environment.Exit(1); + | e -> + reraise() + #endif diff --git a/src/buildtools/fslex/Arg.fsi b/src/buildtools/fslex/Arg.fsi new file mode 100644 index 0000000000..367f69f959 --- /dev/null +++ b/src/buildtools/fslex/Arg.fsi @@ -0,0 +1,50 @@ +// (c) Microsoft Corporation 2005-2009. + +/// A simple command-line argument processor. +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities +#else +namespace Microsoft.FSharp.Text +#endif + +/// The spec value describes the action of the argument, +/// and whether it expects a following parameter. +[] +type ArgType = + static member Clear : bool ref -> ArgType + static member Float : (float -> unit) -> ArgType + static member Int : (int -> unit) -> ArgType + static member Rest : (string -> unit) -> ArgType + static member Set : bool ref -> ArgType + static member String : (string -> unit) -> ArgType + static member Unit : (unit -> unit) -> ArgType + +type ArgInfo = + new : name:string * action:ArgType * help:string -> ArgInfo + /// Return the name of the argument + member Name : string + /// Return the argument type and action of the argument + member ArgType : ArgType + /// Return the usage help associated with the argument + member HelpText : string + +[] +type ArgParser = + #if FX_NO_COMMAND_LINE_ARGS + #else + + /// Parse some of the arguments given by 'argv', starting at the given position + [] + static member ParsePartial: cursor: int ref * argv: string[] * arguments:seq * ?otherArgs: (string -> unit) * ?usageText:string -> unit + + /// Parse the arguments given by System.Environment.GetEnvironmentVariables() + /// according to the argument processing specifications "specs". + /// Args begin with "-". Non-arguments are passed to "f" in + /// order. "use" is printed as part of the usage line if an error occurs. + + static member Parse: arguments:seq * ?otherArgs: (string -> unit) * ?usageText:string -> unit + #endif + + /// Prints the help for each argument. + static member Usage : arguments:seq * ?usage:string -> unit + diff --git a/src/buildtools/fslex/Lexing.fs b/src/buildtools/fslex/Lexing.fs new file mode 100644 index 0000000000..8337717d6f --- /dev/null +++ b/src/buildtools/fslex/Lexing.fs @@ -0,0 +1,423 @@ +// (c) Microsoft Corporation 2005-2009. + +#nowarn "47" // recursive initialization of LexBuffer + + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Lexing + +#else +namespace Microsoft.FSharp.Text.Lexing +#endif + + open System.Collections.Generic + + // REVIEW: This type showed up on a parsing-intensive performance measurement. Consider whether it can be a struct-record later when we have this feature. -jomo +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal Position = +#else + type Position = +#endif + { pos_fname : string; + pos_lnum : int; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum : int; +#endif + pos_bol : int; + pos_cnum : int; } + member x.FileName = x.pos_fname + member x.Line = x.pos_lnum +#if INTERNALIZED_FSLEXYACC_RUNTIME + member x.OriginalLine = x.pos_orig_lnum +#endif + member x.Char = x.pos_cnum + member x.AbsoluteOffset = x.pos_cnum + member x.StartOfLine = x.pos_bol + member x.StartOfLineAbsoluteOffset = x.pos_bol + member x.Column = x.pos_cnum - x.pos_bol + member pos.NextLine = + { pos with +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = pos.OriginalLine + 1; +#endif + pos_lnum = pos.Line+1; + pos_bol = pos.AbsoluteOffset } + member pos.EndOfToken(n) = {pos with pos_cnum=pos.pos_cnum + n } + member pos.AsNewLinePos() = pos.NextLine + member pos.ShiftColumnBy(by) = {pos with pos_cnum = pos.pos_cnum + by} + static member Empty = + { pos_fname=""; + pos_lnum= 0; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = 0; +#endif + pos_bol= 0; + pos_cnum=0 } + static member FirstLine(filename) = + { pos_fname=filename; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = 1; +#endif + pos_lnum= 1; + pos_bol= 0; + pos_cnum=0 } + +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal LexBufferFiller<'char> = +#else + type LexBufferFiller<'char> = +#endif + { fillSync : (LexBuffer<'char> -> unit) option + fillAsync : (LexBuffer<'char> -> Async) option } + + and [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + internal LexBuffer<'char>(filler: LexBufferFiller<'char>) as this = +#else + LexBuffer<'char>(filler: LexBufferFiller<'char>) as this = +#endif + let context = new Dictionary(1) in + let extendBufferSync = (fun () -> match filler.fillSync with Some refill -> refill this | None -> invalidOp "attempt to read synchronously from an asynchronous lex buffer") + let extendBufferAsync = (fun () -> match filler.fillAsync with Some refill -> refill this | None -> invalidOp "attempt to read asynchronously from a synchronous lex buffer") + let mutable buffer=[||]; + /// number of valid charactes beyond bufferScanStart + let mutable bufferMaxScanLength=0; + /// count into the buffer when scanning + let mutable bufferScanStart=0; + /// number of characters scanned so far + let mutable bufferScanLength=0; + /// length of the scan at the last accepting state + let mutable lexemeLength=0; + /// action related to the last accepting state + let mutable bufferAcceptAction=0; + let mutable eof = false; + let mutable startPos = Position.Empty ; + let mutable endPos = Position.Empty + + // Throw away all the input besides the lexeme + + let discardInput () = + let keep = Array.sub buffer bufferScanStart bufferScanLength + let nkeep = keep.Length + Array.blit keep 0 buffer 0 nkeep; + bufferScanStart <- 0; + bufferMaxScanLength <- nkeep + + + member lexbuf.EndOfScan () : int = + // Printf.eprintf "endOfScan, lexBuffer.lexemeLength = %d\n" lexBuffer.lexemeLength; + if bufferAcceptAction < 0 then + failwith "unrecognized input" + + // Printf.printf "endOfScan %d state %d on unconsumed input '%c' (%d)\n" a s (Char.chr inp) inp; + // Printf.eprintf "accept, lexeme = %s\n" (lexeme lexBuffer); + lexbuf.StartPos <- endPos; + lexbuf.EndPos <- endPos.EndOfToken(lexbuf.LexemeLength); + bufferAcceptAction + + member lexbuf.StartPos + with get() = startPos + and set(b) = startPos <- b + + member lexbuf.EndPos + with get() = endPos + and set(b) = endPos <- b + + member lexbuf.Lexeme = Array.sub buffer bufferScanStart lexemeLength + member lexbuf.LexemeChar(n) = buffer.[n+bufferScanStart] + + member lexbuf.BufferLocalStore = (context :> IDictionary<_,_>) + member lexbuf.LexemeLength with get() : int = lexemeLength and set v = lexemeLength <- v + member internal lexbuf.Buffer with get() : 'char[] = buffer and set v = buffer <- v + member internal lexbuf.BufferMaxScanLength with get() = bufferMaxScanLength and set v = bufferMaxScanLength <- v + member internal lexbuf.BufferScanLength with get() = bufferScanLength and set v = bufferScanLength <- v + member internal lexbuf.BufferScanStart with get() : int = bufferScanStart and set v = bufferScanStart <- v + member internal lexbuf.BufferAcceptAction with get() = bufferAcceptAction and set v = bufferAcceptAction <- v + member internal lexbuf.RefillBuffer = extendBufferSync + member internal lexbuf.AsyncRefillBuffer = extendBufferAsync + + static member LexemeString(lexbuf:LexBuffer) = + new System.String(lexbuf.Buffer,lexbuf.BufferScanStart,lexbuf.LexemeLength) + + member lexbuf.IsPastEndOfStream + with get() = eof + and set(b) = eof <- b + + member lexbuf.DiscardInput() = discardInput () + + member x.BufferScanPos = bufferScanStart + bufferScanLength + + member lexbuf.EnsureBufferSize n = + if lexbuf.BufferScanPos + n >= buffer.Length then + let repl = Array.zeroCreate (lexbuf.BufferScanPos + n) + Array.blit buffer bufferScanStart repl bufferScanStart bufferScanLength; + buffer <- repl + + static member FromReadFunctions (syncRead : ('char[] * int * int -> int) option, asyncRead : ('char[] * int * int -> Async) option) : LexBuffer<'char> = + let extension= Array.zeroCreate 4096 + let fillers = + { fillSync = + match syncRead with + | None -> None + | Some read -> + Some (fun lexBuffer -> + let n = read(extension,0,extension.Length) + lexBuffer.EnsureBufferSize n; + Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n); + fillAsync = + match asyncRead with + | None -> None + | Some read -> + Some (fun lexBuffer -> + async { + let! n = read(extension,0,extension.Length) + lexBuffer.EnsureBufferSize n; + Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n }) } + new LexBuffer<_>(fillers) + + // A full type signature is required on this method because it is used at more specific types within its own scope + static member FromFunction (f : 'char[] * int * int -> int) : LexBuffer<'char> = LexBuffer<_>.FromReadFunctions(Some(f),None) + static member FromAsyncFunction (f : 'char[] * int * int -> Async) : LexBuffer<'char> = LexBuffer<_>.FromReadFunctions(None,Some(f)) + + static member FromCharFunction f : LexBuffer = + LexBuffer.FromFunction(fun (buff,start,len) -> + let buff2 = Array.zeroCreate len + let n = f buff2 len + Array.blit buff2 0 buff start len + n) + static member FromByteFunction f : LexBuffer = + LexBuffer.FromFunction(fun (buff,start,len) -> + let buff2 = Array.zeroCreate len + let n = f buff2 len + Array.blit buff2 0 buff start len + n) + + // A full type signature is required on this method because it is used at more specific types within its own scope + static member FromArray (s: 'char[]) : LexBuffer<'char> = + let lexBuffer = + new LexBuffer<_> + { fillSync = Some (fun _ -> ()); + fillAsync = Some (fun _ -> async { return () }) } + let buffer = Array.copy s + lexBuffer.Buffer <- buffer; + lexBuffer.BufferMaxScanLength <- buffer.Length; + lexBuffer + + static member FromBytes (arr) = LexBuffer.FromArray(arr) + static member FromChars (arr) = LexBuffer.FromArray(arr) + static member FromString (s:string) = LexBuffer.FromChars (s.ToCharArray()) + + static member FromTextReader (tr:System.IO.TextReader) : LexBuffer = + LexBuffer.FromFunction(tr.Read) + + static member FromBinaryReader (br:System.IO.BinaryReader) : LexBuffer = + LexBuffer.FromFunction(br.Read) + + static member FromStream (stream:System.IO.Stream) : LexBuffer = + LexBuffer.FromReadFunctions(Some(stream.Read),Some(fun (buf,offset,len) -> stream.AsyncRead(buf,offset=offset,count=len))) + + module GenericImplFragments = + let startInterpret(lexBuffer:LexBuffer<_>)= + lexBuffer.BufferScanStart <- lexBuffer.BufferScanStart + lexBuffer.LexemeLength; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferMaxScanLength - lexBuffer.LexemeLength; + lexBuffer.BufferScanLength <- 0; + lexBuffer.LexemeLength <- 0; + lexBuffer.BufferAcceptAction <- -1; + + let afterRefill (trans: uint16[] array,sentinel,lexBuffer:LexBuffer<_>,scanUntilSentinel,endOfScan,state,eofPos) = + // end of file occurs if we couldn't extend the buffer + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + let snew = int trans.[state].[eofPos] // == EOF + if snew = sentinel then + endOfScan() + else + if lexBuffer.IsPastEndOfStream then failwith "End of file on lexing stream"; + lexBuffer.IsPastEndOfStream <- true; + // Printf.printf "state %d --> %d on eof\n" state snew; + scanUntilSentinel(lexBuffer,snew) + else + scanUntilSentinel(lexBuffer, state) + + let onAccept (lexBuffer:LexBuffer<_>,a) = + lexBuffer.LexemeLength <- lexBuffer.BufferScanLength; + lexBuffer.BufferAcceptAction <- a; + + open GenericImplFragments + + [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal AsciiTables(trans: uint16[] array, accept: uint16[]) = +#else + type AsciiTables(trans: uint16[] array, accept: uint16[]) = +#endif + let rec scanUntilSentinel(lexBuffer, state) = + let sentinel = 255 * 256 + 255 + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept (lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,lexBuffer.EndOfScan,state,256 (* == EOF *) ) + else + // read a character - end the scan if there are no further transitions + let inp = int(lexBuffer.Buffer.[lexBuffer.BufferScanPos]) + let snew = int trans.[state].[inp] + if snew = sentinel then + lexBuffer.EndOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + // Printf.printf "state %d --> %d on '%c' (%d)\n" state snew (Char.chr inp) inp; + scanUntilSentinel(lexBuffer, snew) + + /// Interpret tables for an ascii lexer generated by fslex. + member tables.Interpret(initialState,lexBuffer : LexBuffer) = + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + /// Interpret tables for an ascii lexer generated by fslex. + member tables.AsyncInterpret(initialState,lexBuffer : LexBuffer) = + + let rec scanUntilSentinel(lexBuffer,state) : Async = + async { + let sentinel = 255 * 256 + 255 + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept (lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + do! lexBuffer.AsyncRefillBuffer (); + // end of file occurs if we couldn't extend the buffer + return! afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,endOfScan,state,256 (* == EOF *) ) + else + // read a character - end the scan if there are no further transitions + let inp = int(lexBuffer.Buffer.[lexBuffer.BufferScanPos]) + let snew = int trans.[state].[inp] + if snew = sentinel then + return! endOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + return! scanUntilSentinel(lexBuffer,snew) + } + and endOfScan() = + async { return lexBuffer.EndOfScan() } + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + + static member Create(trans,accept) = new AsciiTables(trans,accept) + + [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal UnicodeTables(trans: uint16[] array, accept: uint16[]) = +#else + type UnicodeTables(trans: uint16[] array, accept: uint16[]) = +#endif + let sentinel = 255 * 256 + 255 + let numUnicodeCategories = 30 + let numLowUnicodeChars = 128 + let numSpecificUnicodeChars = (trans.[0].Length - 1 - numLowUnicodeChars - numUnicodeCategories)/2 + let lookupUnicodeCharacters (state,inp) = + let inpAsInt = int inp + // Is it a fast ASCII character? + if inpAsInt < numLowUnicodeChars then + int trans.[state].[inpAsInt] + else + // Search for a specific unicode character + let baseForSpecificUnicodeChars = numLowUnicodeChars + let rec loop i = + if i >= numSpecificUnicodeChars then + // OK, if we failed then read the 'others' entry in the alphabet, + // which covers all Unicode characters not covered in other + // ways + let baseForUnicodeCategories = numLowUnicodeChars+numSpecificUnicodeChars*2 + let unicodeCategory = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(inp) + //System.Console.WriteLine("inp = {0}, unicodeCategory = {1}", [| box inp; box unicodeCategory |]); + int trans.[state].[baseForUnicodeCategories + int32 unicodeCategory] + else + // This is the specific unicode character + let c = char (int trans.[state].[baseForSpecificUnicodeChars+i*2]) + //System.Console.WriteLine("c = {0}, inp = {1}, i = {2}", [| box c; box inp; box i |]); + // OK, have we found the entry for a specific unicode character? + if c = inp + then int trans.[state].[baseForSpecificUnicodeChars+i*2+1] + else loop(i+1) + + loop 0 + let eofPos = numLowUnicodeChars + 2*numSpecificUnicodeChars + numUnicodeCategories + + let rec scanUntilSentinel(lexBuffer,state) = + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept(lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,lexBuffer.EndOfScan,state,eofPos) + else + // read a character - end the scan if there are no further transitions + let inp = lexBuffer.Buffer.[lexBuffer.BufferScanPos] + + // Find the new state + let snew = lookupUnicodeCharacters (state,inp) + + if snew = sentinel then + lexBuffer.EndOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + // Printf.printf "state %d --> %d on '%c' (%d)\n" s snew (char inp) inp; + scanUntilSentinel(lexBuffer,snew) + + // Each row for the Unicode table has format + // 128 entries for ASCII characters + // A variable number of 2*UInt16 entries for SpecificUnicodeChars + // 30 entries, one for each UnicodeCategory + // 1 entry for EOF + + member tables.Interpret(initialState,lexBuffer : LexBuffer) = + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + member tables.AsyncInterpret(initialState,lexBuffer : LexBuffer) = + + let rec scanUntilSentinel(lexBuffer, state) = + async { + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept(lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + return! afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,endOfScan,state,eofPos) + else + // read a character - end the scan if there are no further transitions + let inp = lexBuffer.Buffer.[lexBuffer.BufferScanPos] + + // Find the new state + let snew = lookupUnicodeCharacters (state,inp) + + if snew = sentinel then + return! endOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + return! scanUntilSentinel(lexBuffer, snew) + } + and endOfScan() = + async { return lexBuffer.EndOfScan() } + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + static member Create(trans,accept) = new UnicodeTables(trans,accept) diff --git a/src/buildtools/fslex/Lexing.fsi b/src/buildtools/fslex/Lexing.fsi new file mode 100644 index 0000000000..e31ad411aa --- /dev/null +++ b/src/buildtools/fslex/Lexing.fsi @@ -0,0 +1,151 @@ +//========================================================================== +// LexBuffers are for use with automatically generated lexical analyzers, +// in particular those produced by 'fslex'. +// +// (c) Microsoft Corporation 2005-2008. +//=========================================================================== + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Lexing +#else +namespace Microsoft.FSharp.Text.Lexing +#endif + +open System.Collections.Generic + +/// Position information stored for lexing tokens +// +// Note: this is an OCaml compat record type. +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Position = +#else +type Position = +#endif + { /// The file name for the position + pos_fname: string; + /// The line number for the position + pos_lnum: int; +#if INTERNALIZED_FSLEXYACC_RUNTIME + /// The line number for the position in the original source file + pos_orig_lnum : int; +#endif + /// The absolute offset of the beginning of the line + pos_bol: int; + /// The absolute offset of the column for the position + pos_cnum: int; } + /// The file name associated with the input stream. + member FileName : string + /// The line number in the input stream, assuming fresh positions have been updated + /// using AsNewLinePos() and by modifying the EndPos property of the LexBuffer. + member Line : int +#if INTERNALIZED_FSLEXYACC_RUNTIME + /// The line number for the position in the input stream, assuming fresh positions have been updated + /// using AsNewLinePos() + member OriginalLine : int +#endif + [] + member Char : int + /// The character number in the input stream + member AbsoluteOffset : int + /// Return absolute offset of the start of the line marked by the position + member StartOfLineAbsoluteOffset : int + /// Return the column number marked by the position, i.e. the difference between the AbsoluteOffset and the StartOfLineAbsoluteOffset + member Column : int + // Given a position just beyond the end of a line, return a position at the start of the next line + member NextLine : Position + + /// Given a position at the start of a token of length n, return a position just beyond the end of the token + member EndOfToken: n:int -> Position + /// Gives a position shifted by specified number of characters + member ShiftColumnBy: by:int -> Position + + [] + member AsNewLinePos : unit -> Position + + /// Get an arbitrary position, with the empty string as filename, and + static member Empty : Position + + /// Get a position corresponding to the first line (line number 1) in a given file + static member FirstLine : filename:string -> Position + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal LexBuffer<'char> = +#else +/// Input buffers consumed by lexers generated by fslex.exe +type LexBuffer<'char> = +#endif + /// The start position for the lexeme + member StartPos: Position with get,set + /// The end position for the lexeme + member EndPos: Position with get,set + /// The matched string + member Lexeme: 'char array + + /// Fast helper to turn the matched characters into a string, avoiding an intermediate array + static member LexemeString : LexBuffer -> string + + /// The length of the matched string + member LexemeLength: int + /// Fetch a particular character in the matched string + member LexemeChar: int -> 'char + + /// Dynamically typed, non-lexically scoped parameter table + member BufferLocalStore : IDictionary + + /// True if the refill of the buffer ever failed , or if explicitly set to true. + member IsPastEndOfStream: bool with get,set + /// Remove all input, though don't discard the current lexeme + member DiscardInput: unit -> unit + + /// Create a lex buffer suitable for byte lexing that reads characters from the given array + static member FromBytes: byte[] -> LexBuffer + /// Create a lex buffer suitable for Unicode lexing that reads characters from the given array + static member FromChars: char[] -> LexBuffer + /// Create a lex buffer suitable for Unicode lexing that reads characters from the given string + static member FromString: string -> LexBuffer + /// Create a lex buffer that reads character or byte inputs by using the given function + static member FromFunction: ('char[] * int * int -> int) -> LexBuffer<'char> + /// Create a lex buffer that asynchronously reads character or byte inputs by using the given function + static member FromAsyncFunction: ('char[] * int * int -> Async) -> LexBuffer<'char> + + + [.FromFunction instead")>] + static member FromCharFunction: (char[] -> int -> int) -> LexBuffer + [.FromFunction instead")>] + static member FromByteFunction: (byte[] -> int -> int) -> LexBuffer + + /// Create a lex buffer suitable for use with a Unicode lexer that reads character inputs from the given text reader + static member FromTextReader: System.IO.TextReader -> LexBuffer + /// Create a lex buffer suitable for use with ASCII byte lexing that reads byte inputs from the given binary reader + static member FromBinaryReader: System.IO.BinaryReader -> LexBuffer + + +/// The type of tables for an ascii lexer generated by fslex. +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal AsciiTables = +#else +type AsciiTables = +#endif + static member Create : uint16[] array * uint16[] -> AsciiTables + /// Interpret tables for an ascii lexer generated by fslex. + member Interpret: initialState:int * LexBuffer -> int + /// Interpret tables for an ascii lexer generated by fslex, processing input asynchronously + member AsyncInterpret: initialState:int * LexBuffer -> Async + + +/// The type of tables for an unicode lexer generated by fslex. +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal UnicodeTables = +#else +type UnicodeTables = +#endif + static member Create : uint16[] array * uint16[] -> UnicodeTables + /// Interpret tables for a unicode lexer generated by fslex. + member Interpret: initialState:int * LexBuffer -> int + + /// Interpret tables for a unicode lexer generated by fslex, processing input asynchronously + member AsyncInterpret: initialState:int * LexBuffer -> Async + diff --git a/src/buildtools/fslex/Parsing.fs b/src/buildtools/fslex/Parsing.fs new file mode 100644 index 0000000000..01dccfb610 --- /dev/null +++ b/src/buildtools/fslex/Parsing.fs @@ -0,0 +1,514 @@ +// (c) Microsoft Corporation 2005-2009. + +#if INTERNALIZED_FSLEXYACC_RUNTIME + +namespace Internal.Utilities.Text.Parsing +open Internal.Utilities +open Internal.Utilities.Text.Lexing + +#else +namespace Microsoft.FSharp.Text.Parsing +open Microsoft.FSharp.Text.Lexing +#endif + + + +open System +open System.Collections.Generic + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal IParseState = +#else +type IParseState = +#endif + abstract InputRange: int -> Position * Position + abstract InputEndPosition: int -> Position + abstract InputStartPosition: int -> Position + abstract ResultRange: Position * Position + abstract GetInput: int -> obj + abstract ParserLocalStore : IDictionary + abstract RaiseError<'b> : unit -> 'b + +//------------------------------------------------------------------------- +// This context is passed to the error reporter when a syntax error occurs + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal ParseErrorContext<'tok> +#else +type ParseErrorContext<'tok> +#endif + (//lexbuf: LexBuffer<_>, + stateStack:int list, + parseState: IParseState, + reduceTokens: int list, + currentToken: 'tok option, + reducibleProductions: int list list, + shiftableTokens: int list , + message : string) = + //member x.LexBuffer = lexbuf + member x.StateStack = stateStack + member x.ReduceTokens = reduceTokens + member x.CurrentToken = currentToken + member x.ParseState = parseState + member x.ReducibleProductions = reducibleProductions + member x.ShiftTokens = shiftableTokens + member x.Message = message + + +//------------------------------------------------------------------------- +// This is the data structure emitted as code by FSYACC. + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> = +#else +type Tables<'tok> = +#endif + { reductions: (IParseState -> obj) array; + endOfInputTag: int; + tagOfToken: 'tok -> int; + dataOfToken: 'tok -> obj; + actionTableElements: uint16[]; + actionTableRowOffsets: uint16[]; + reductionSymbolCounts: uint16[]; + immediateActions: uint16[]; + gotos: uint16[]; + sparseGotoTableRowOffsets: uint16[]; + stateToProdIdxsTableElements: uint16[]; + stateToProdIdxsTableRowOffsets: uint16[]; + productionToNonTerminalTable: uint16[]; + /// For fsyacc.exe, this entry is filled in by context from the generated parser file. If no 'parse_error' function + /// is defined by the user then ParseHelpers.parse_error is used by default (ParseHelpers is opened + /// at the top of the generated parser file) + parseError: ParseErrorContext<'tok> -> unit; + numTerminals: int; + tagOfErrorTerminal: int } + +//------------------------------------------------------------------------- +// An implementation of stacks. + +// This type is in System.dll so for the moment we can't use it in FSharp.Core.dll +//type Stack<'a> = System.Collections.Generic.Stack<'a> + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type Stack<'a>(n) = +#else +type internal Stack<'a>(n) = +#endif + let mutable contents = Array.zeroCreate<'a>(n) + let mutable count = 0 + + member buf.Ensure newSize = + let oldSize = Array.length contents + if newSize > oldSize then + let old = contents + contents <- Array.zeroCreate (max newSize (oldSize * 2)); + Array.blit old 0 contents 0 count; + + member buf.Count = count + member buf.Pop() = count <- count - 1 + member buf.Peep() = contents.[count - 1] + member buf.Top(n) = [ for x in contents.[max 0 (count-n)..count - 1] -> x ] |> List.rev + member buf.Push(x) = + buf.Ensure(count + 1); + contents.[count] <- x; + count <- count + 1 + + member buf.IsEmpty = (count = 0) +#if __DEBUG + member buf.PrintStack() = + for i = 0 to (count - 1) do +#if FX_NO_CONSOLE + () +#else + System.Console.Write("{0}{1}",(contents.[i]),if i=count-1 then ":" else "-") +#endif +#endif +exception RecoverableParseError +exception Accept of obj + +#if __DEBUG +module Flags = + let mutable debug = false +#endif + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal Implementation = +#else +module Implementation = +#endif + + // Definitions shared with fsyacc + let anyMarker = 0xffff + let shiftFlag = 0x0000 + let reduceFlag = 0x4000 + let errorFlag = 0x8000 + let acceptFlag = 0xc000 + let actionMask = 0xc000 + + let actionValue action = action &&& (~~~ actionMask) + let actionKind action = action &&& actionMask + + //------------------------------------------------------------------------- + // Read the tables written by FSYACC. + + type AssocTable(elemTab:uint16[], offsetTab:uint16[]) = + let cache = new Dictionary<_,_>(2000) + + member t.readAssoc (minElemNum,maxElemNum,defaultValueOfAssoc,keyToFind) = + // do a binary chop on the table + let elemNumber : int = (minElemNum+maxElemNum)/2 + if elemNumber = maxElemNum + then defaultValueOfAssoc + else + let x = int elemTab.[elemNumber*2] + if keyToFind = x then + int elemTab.[elemNumber*2+1] + elif keyToFind < x then t.readAssoc (minElemNum ,elemNumber,defaultValueOfAssoc,keyToFind) + else t.readAssoc (elemNumber+1,maxElemNum,defaultValueOfAssoc,keyToFind) + + member t.Read(rowNumber ,keyToFind) = + + // First check the sparse lookaside table + // Performance note: without this lookaside table the binary chop in readAssoc + // takes up around 10% of of parsing time + // for parsing intensive samples such as the bootstrapped F# compiler. + // + // Note: using a .NET Dictionary for this int -> int table looks like it could be sub-optimal. + // Some other better sparse lookup table may be better. + let mutable res = 0 + let cacheKey = (rowNumber <<< 16) ||| keyToFind + let ok = cache.TryGetValue(cacheKey, &res) + if ok then res + else + let headOfTable = int offsetTab.[rowNumber] + let firstElemNumber = headOfTable + 1 + let numberOfElementsInAssoc = int elemTab.[headOfTable*2] + let defaultValueOfAssoc = int elemTab.[headOfTable*2+1] + let res = t.readAssoc (firstElemNumber,(firstElemNumber+numberOfElementsInAssoc),defaultValueOfAssoc,keyToFind) + cache.[cacheKey] <- res + res + + // Read all entries in the association table + // Used during error recovery to find all valid entries in the table + member x.ReadAll(n) = + let headOfTable = int offsetTab.[n] + let firstElemNumber = headOfTable + 1 + let numberOfElementsInAssoc = int32 elemTab.[headOfTable*2] + let defaultValueOfAssoc = int elemTab.[headOfTable*2+1] + [ for i in firstElemNumber .. (firstElemNumber+numberOfElementsInAssoc-1) -> + (int elemTab.[i*2], int elemTab.[i*2+1]) ], defaultValueOfAssoc + + type IdxToIdxListTable(elemTab:uint16[], offsetTab:uint16[]) = + + // Read all entries in a row of the table + member x.ReadAll(n) = + let headOfTable = int offsetTab.[n] + let firstElemNumber = headOfTable + 1 + let numberOfElements = int32 elemTab.[headOfTable] + [ for i in firstElemNumber .. (firstElemNumber+numberOfElements-1) -> int elemTab.[i] ] + + //------------------------------------------------------------------------- + // interpret the tables emitted by FSYACC. + + [] + [] + type ValueInfo = + val value: obj + val startPos: Position + val endPos: Position + new(value,startPos,endPos) = { value=value; startPos=startPos;endPos=endPos } + + let interpret (tables: Tables<'tok>) lexer (lexbuf : LexBuffer<_>) initialState = + let localStore = new Dictionary() in + localStore.["LexBuffer"] <- lexbuf; +#if __DEBUG + if Flags.debug then System.Console.WriteLine("\nParser: interpret tables"); +#endif + let stateStack : Stack = new Stack<_>(100) + stateStack.Push(initialState); + let valueStack = new Stack(100) + let mutable haveLookahead = false + let mutable lookaheadToken = Unchecked.defaultof<'tok> + let mutable lookaheadEndPos = Unchecked.defaultof + let mutable lookaheadStartPos = Unchecked.defaultof + let mutable finished = false + // After an error occurs, we suppress errors until we've shifted three tokens in a row. + let mutable errorSuppressionCountDown = 0 + + // When we hit the end-of-file we don't fail straight away but rather keep permitting shift + // and reduce against the last token in the token stream 20 times or until we've accepted + // or exhausted the stack. This allows error recovery rules of the form + // input : realInput EOF | realInput error EOF | error EOF + // where consuming one EOF to trigger an error doesn't result in overall parse failure + // catastrophe and the loss of intermediate results. + // + let mutable inEofCountDown = false + let mutable eofCountDown = 20 // Number of EOFs to supply at the end for error recovery + // The 100 here means a maximum of 100 elements for each rule + let ruleStartPoss = (Array.zeroCreate 100 : Position array) + let ruleEndPoss = (Array.zeroCreate 100 : Position array) + let ruleValues = (Array.zeroCreate 100 : obj array) + let lhsPos = (Array.zeroCreate 2 : Position array) + let reductions = tables.reductions + let actionTable = new AssocTable(tables.actionTableElements, tables.actionTableRowOffsets) + let gotoTable = new AssocTable(tables.gotos, tables.sparseGotoTableRowOffsets) + let stateToProdIdxsTable = new IdxToIdxListTable(tables.stateToProdIdxsTableElements, tables.stateToProdIdxsTableRowOffsets) + + let parseState = + { new IParseState with + member p.InputRange(n) = ruleStartPoss.[n-1], ruleEndPoss.[n-1]; + member p.InputStartPosition(n) = ruleStartPoss.[n-1] + member p.InputEndPosition(n) = ruleEndPoss.[n-1]; + member p.GetInput(n) = ruleValues.[n-1]; + member p.ResultRange = (lhsPos.[0], lhsPos.[1]); + member p.ParserLocalStore = (localStore :> IDictionary<_,_>); + member p.RaiseError() = raise RecoverableParseError (* NOTE: this binding tests the fairly complex logic associated with an object expression implementing a generic abstract method *) + } + +#if __DEBUG + let report haveLookahead lookaheadToken = + if haveLookahead then sprintf "%A" lookaheadToken + else "[TBC]" +#endif + + // Pop the stack until we can shift the 'error' token. If 'tokenOpt' is given + // then keep popping until we can shift both the 'error' token and the token in 'tokenOpt'. + // This is used at end-of-file to make sure we can shift both the 'error' token and the 'EOF' token. + let rec popStackUntilErrorShifted(tokenOpt) = + // Keep popping the stack until the "error" terminal is shifted +#if __DEBUG + if Flags.debug then System.Console.WriteLine("popStackUntilErrorShifted"); +#endif + if stateStack.IsEmpty then +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("state stack empty during error recovery - generating parse error"); +#endif + failwith "parse error"; + + let currState = stateStack.Peep() +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("In state {0} during error recovery", currState); +#endif + + let action = actionTable.Read(currState, tables.tagOfErrorTerminal) + + if actionKind action = shiftFlag && + (match tokenOpt with + | None -> true + | Some(token) -> + let nextState = actionValue action + actionKind (actionTable.Read(nextState, tables.tagOfToken(token))) = shiftFlag) then + +#if __DEBUG + if Flags.debug then System.Console.WriteLine("shifting error, continuing with error recovery"); +#endif + let nextState = actionValue action + // The "error" non terminal needs position information, though it tends to be unreliable. + // Use the StartPos/EndPos from the lex buffer + valueStack.Push(ValueInfo(box (), lexbuf.StartPos, lexbuf.EndPos)); + stateStack.Push(nextState) + else + if valueStack.IsEmpty then + failwith "parse error"; +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("popping stack during error recovery"); +#endif + valueStack.Pop(); + stateStack.Pop(); + popStackUntilErrorShifted(tokenOpt) + + while not finished do + if stateStack.IsEmpty then + finished <- true + else + let state = stateStack.Peep() +#if __DEBUG + if Flags.debug then (Console.Write("{0} value(state), state ",valueStack.Count); stateStack.PrintStack()) +#endif + let action = + let immediateAction = int tables.immediateActions.[state] + if not (immediateAction = anyMarker) then + // Action has been pre-determined, no need to lookahead + // Expecting it to be a Reduce action on a non-fakeStartNonTerminal ? + immediateAction + else + // Lookahead required to determine action + if not haveLookahead then + if lexbuf.IsPastEndOfStream then + // When the input runs out, keep supplying the last token for eofCountDown times + if eofCountDown>0 then + haveLookahead <- true + eofCountDown <- eofCountDown - 1 + inEofCountDown <- true + else + haveLookahead <- false + else + lookaheadToken <- lexer lexbuf + lookaheadStartPos <- lexbuf.StartPos + lookaheadEndPos <- lexbuf.EndPos + haveLookahead <- true; + + let tag = + if haveLookahead then tables.tagOfToken lookaheadToken + else tables.endOfInputTag + + // Printf.printf "state %d\n" state + actionTable.Read(state,tag) + + let kind = actionKind action + if kind = shiftFlag then ( + if errorSuppressionCountDown > 0 then + errorSuppressionCountDown <- errorSuppressionCountDown - 1; +#if __DEBUG + if Flags.debug then Console.WriteLine("shifting, reduced errorRecoverylevel to {0}\n", errorSuppressionCountDown); +#endif + let nextState = actionValue action + if not haveLookahead then failwith "shift on end of input!"; + let data = tables.dataOfToken lookaheadToken + valueStack.Push(ValueInfo(data, lookaheadStartPos, lookaheadEndPos)); + stateStack.Push(nextState); +#if __DEBUG + if Flags.debug then Console.WriteLine("shift/consume input {0}, shift to state {1}", report haveLookahead lookaheadToken, nextState); +#endif + haveLookahead <- false + + ) elif kind = reduceFlag then + let prod = actionValue action + let reduction = reductions.[prod] + let n = int tables.reductionSymbolCounts.[prod] + // pop the symbols, populate the values and populate the locations +#if __DEBUG + if Flags.debug then Console.Write("reduce popping {0} values/states, lookahead {1}", n, report haveLookahead lookaheadToken); +#endif + + lhsPos.[0] <- Position.Empty; + lhsPos.[1] <- Position.Empty; + for i = 0 to n - 1 do + if valueStack.IsEmpty then failwith "empty symbol stack"; + let topVal = valueStack.Peep() + valueStack.Pop(); + stateStack.Pop(); + ruleValues.[(n-i)-1] <- topVal.value; + ruleStartPoss.[(n-i)-1] <- topVal.startPos; + ruleEndPoss.[(n-i)-1] <- topVal.endPos; + if lhsPos.[1] = Position.Empty then lhsPos.[1] <- topVal.endPos; + if not (topVal.startPos = Position.Empty) then lhsPos.[0] <- topVal.startPos + done; + + try + // Printf.printf "reduce %d\n" prod; + let redResult = reduction parseState + valueStack.Push(ValueInfo(redResult, lhsPos.[0], lhsPos.[1])); + let currState = stateStack.Peep() + let newGotoState = gotoTable.Read(int tables.productionToNonTerminalTable.[prod], currState) + stateStack.Push(newGotoState) +#if __DEBUG + if Flags.debug then Console.WriteLine(" goto state {0}", newGotoState) +#endif + with + | Accept res -> + finished <- true; + valueStack.Push(ValueInfo(res, lhsPos.[0], lhsPos.[1])) + | RecoverableParseError -> +#if __DEBUG + if Flags.debug then Console.WriteLine("RecoverableParseErrorException...\n"); +#endif + popStackUntilErrorShifted(None); + // User code raised a Parse_error. Don't report errors again until three tokens have been shifted + errorSuppressionCountDown <- 3 + elif kind = errorFlag then ( +#if __DEBUG + if Flags.debug then Console.Write("ErrorFlag... "); +#endif + // Silently discard inputs and don't report errors + // until three tokens in a row have been shifted +#if __DEBUG + if Flags.debug then printfn "error on token '%A' " (if haveLookahead then Some(lookaheadToken) else None); +#endif + if errorSuppressionCountDown > 0 then + // If we're in the end-of-file count down then we're very keen to 'Accept'. + // We can only do this by repeatedly popping the stack until we can shift both an 'error' token + // and an EOF token. + if inEofCountDown && eofCountDown < 10 then +#if __DEBUG + if Flags.debug then printfn "poppin stack, lokking to shift both 'error' and that token, during end-of-file error recovery" ; +#endif + popStackUntilErrorShifted(if haveLookahead then Some(lookaheadToken) else None); + + // If we don't haveLookahead then the end-of-file count down is over and we have no further options. + if not haveLookahead then + failwith "parse error: unexpected end of file" + +#if __DEBUG + if Flags.debug then printfn "discarding token '%A' during error suppression" (if haveLookahead then Some(lookaheadToken) else None); +#endif + // Discard the token + haveLookahead <- false + // Try again to shift three tokens + errorSuppressionCountDown <- 3 + else ( + + let currentToken = if haveLookahead then Some(lookaheadToken) else None + let actions,defaultAction = actionTable.ReadAll(state) + let explicit = Set.ofList [ for (tag,_action) in actions -> tag ] + + let shiftableTokens = + [ for (tag,action) in actions do + if (actionKind action) = shiftFlag then + yield tag + if actionKind defaultAction = shiftFlag then + for tag in 0 .. tables.numTerminals-1 do + if not (explicit.Contains(tag)) then + yield tag ] in + + let stateStack = stateStack.Top(12) in + let reducibleProductions = + [ for state in stateStack do + yield stateToProdIdxsTable.ReadAll(state) ] + + let reduceTokens = + [ for (tag,action) in actions do + if actionKind(action) = reduceFlag then + yield tag + if actionKind(defaultAction) = reduceFlag then + for tag in 0 .. tables.numTerminals-1 do + if not (explicit.Contains(tag)) then + yield tag ] in + //let activeRules = stateStack |> List.iter (fun state -> + let errorContext = new ParseErrorContext<'tok>(stateStack,parseState, reduceTokens,currentToken,reducibleProductions, shiftableTokens, "syntax error") + tables.parseError(errorContext); + popStackUntilErrorShifted(None); + errorSuppressionCountDown <- 3; +#if __DEBUG + if Flags.debug then System.Console.WriteLine("generated syntax error and shifted error token, haveLookahead = {0}\n", haveLookahead); +#endif + ) + ) elif kind = acceptFlag then + finished <- true +#if __DEBUG + else + if Flags.debug then System.Console.WriteLine("ALARM!!! drop through case in parser"); +#endif + done; + // OK, we're done - read off the overall generated value + valueStack.Peep().value + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> with +#else +type Tables<'tok> with +#endif + member tables.Interpret (lexer,lexbuf,initialState) = + Implementation.interpret tables lexer lexbuf initialState + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal ParseHelpers = +#else +module ParseHelpers = +#endif + let parse_error (_s:string) = () + let parse_error_rich = (None : (ParseErrorContext<_> -> unit) option) diff --git a/src/buildtools/fslex/Parsing.fsi b/src/buildtools/fslex/Parsing.fsi new file mode 100644 index 0000000000..2fef45975a --- /dev/null +++ b/src/buildtools/fslex/Parsing.fsi @@ -0,0 +1,130 @@ +//========================================================================== +// (c) Microsoft Corporation 2005-2009. +//========================================================================= + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Parsing +open Internal.Utilities +open Internal.Utilities.Text.Lexing +#else +namespace Microsoft.FSharp.Text.Parsing +open Microsoft.FSharp.Text.Lexing +#endif + +open System.Collections.Generic + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal IParseState = +#else +/// The information accessible via the parseState value within parser actions. +type IParseState = +#endif + /// Get the start and end position for the terminal or non-terminal at a given index matched by the production + abstract InputRange: index:int -> Position * Position + /// Get the end position for the terminal or non-terminal at a given index matched by the production + abstract InputEndPosition: int -> Position + /// Get the start position for the terminal or non-terminal at a given index matched by the production + abstract InputStartPosition: int -> Position + /// Get the full range of positions matched by the production + abstract ResultRange: Position * Position + /// Get the value produced by the terminal or non-terminal at the given position + abstract GetInput : int -> obj + /// Get the store of local values associated with this parser + // Dynamically typed, non-lexically scoped local store + abstract ParserLocalStore : IDictionary + /// Raise an error in this parse context + abstract RaiseError<'b> : unit -> 'b + + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal ParseErrorContext<'tok> = +#else +/// The context provided when a parse error occurs +type ParseErrorContext<'tok> = +#endif + /// The stack of state indexes active at the parse error + member StateStack : int list + /// The state active at the parse error + member ParseState : IParseState + /// The tokens that would cause a reduction at the parse error + member ReduceTokens: int list + /// The stack of productions that would be reduced at the parse error + member ReducibleProductions : int list list + /// The token that caused the parse error + member CurrentToken : 'tok option + /// The token that would cause a shift at the parse error + member ShiftTokens : int list + /// The message associated with the parse error + member Message : string + +/// Tables generated by fsyacc +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> = +#else +/// The type of the tables contained in a file produced by the fsyacc.exe parser generator. +type Tables<'tok> = +#endif + { /// The reduction table + reductions: (IParseState -> obj) array ; + /// The token number indicating the end of input + endOfInputTag: int; + /// A function to compute the tag of a token + tagOfToken: 'tok -> int; + /// A function to compute the data carried by a token + dataOfToken: 'tok -> obj; + /// The sparse action table elements + actionTableElements: uint16[]; + /// The sparse action table row offsets + actionTableRowOffsets: uint16[]; + /// The number of symbols for each reduction + reductionSymbolCounts: uint16[]; + /// The immediate action table + immediateActions: uint16[]; + /// The sparse goto table + gotos: uint16[]; + /// The sparse goto table row offsets + sparseGotoTableRowOffsets: uint16[]; + /// The sparse table for the productions active for each state + stateToProdIdxsTableElements: uint16[]; + /// The sparse table offsets for the productions active for each state + stateToProdIdxsTableRowOffsets: uint16[]; + /// This table is logically part of the Goto table + productionToNonTerminalTable: uint16[]; + /// This function is used to hold the user specified "parse_error" or "parse_error_rich" functions + parseError: ParseErrorContext<'tok> -> unit; + /// The total number of terminals + numTerminals: int; + /// The tag of the error terminal + tagOfErrorTerminal: int } + + /// Interpret the parser table taking input from the given lexer, using the given lex buffer, and the given start state. + /// Returns an object indicating the final synthesized value for the parse. + member Interpret : lexer:(LexBuffer<'char> -> 'tok) * lexbuf:LexBuffer<'char> * startState:int -> obj + +#if INTERNALIZED_FSLEXYACC_RUNTIME +exception internal Accept of obj +exception internal RecoverableParseError +#else +/// Indicates an accept action has occured +exception Accept of obj +/// Indicates a parse error has occured and parse recovery is in progress +exception RecoverableParseError +#endif + +#if __DEBUG +module internal Flags = + val mutable debug : bool +#endif + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal ParseHelpers = +#else +/// Helpers used by generated parsers. +module ParseHelpers = +#endif + /// The default implementation of the parse_error_rich function + val parse_error_rich: (ParseErrorContext<'tok> -> unit) option + /// The default implementation of the parse_error function + val parse_error: string -> unit + diff --git a/src/buildtools/fslex/fslex.fs b/src/buildtools/fslex/fslex.fs new file mode 100644 index 0000000000..46795d728e --- /dev/null +++ b/src/buildtools/fslex/fslex.fs @@ -0,0 +1,225 @@ +// (c) Microsoft Corporation 2005-2009. + +module internal FsLexYacc.FsLex.Driver + +open FsLexYacc.FsLex +open FsLexYacc.FsLex.AST +open FsLexYacc.FsLex.Parser +open Printf +open Internal.Utilities +open Internal.Utilities.Text.Lexing +open System +open System.Collections.Generic +open System.IO + +//------------------------------------------------------------------ +// This code is duplicated from Microsoft.FSharp.Compiler.UnicodeLexing + +type Lexbuf = LexBuffer + +/// Standard utility to create a Unicode LexBuffer +/// +/// One small annoyance is that LexBuffers and not IDisposable. This means +/// we can't just return the LexBuffer object, since the file it wraps wouldn't +/// get closed when we're finished with the LexBuffer. Hence we return the stream, +/// the reader and the LexBuffer. The caller should dispose the first two when done. +let UnicodeFileAsLexbuf (filename,codePage : int option) : FileStream * StreamReader * Lexbuf = + // Use the .NET functionality to auto-detect the unicode encoding + // It also presents the bytes read to the lexer in UTF8 decoded form + let stream = new FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.Read) + let reader = + match codePage with + | None -> new StreamReader(stream,true) + | Some n -> new StreamReader(stream,System.Text.Encoding.GetEncoding(n)) + let lexbuf = LexBuffer.FromFunction(reader.Read) + lexbuf.EndPos <- Position.FirstLine(filename); + stream, reader, lexbuf + +//------------------------------------------------------------------ +// This is the program proper + +let input = ref None +let out = ref None +let inputCodePage = ref None +let light = ref None + +let mutable lexlib = "Microsoft.FSharp.Text.Lexing" + +let usage = + [ ArgInfo ("-o", ArgType.String (fun s -> out := Some s), "Name the output file."); + ArgInfo ("--codepage", ArgType.Int (fun i -> inputCodePage := Some i), "Assume input lexer specification file is encoded with the given codepage."); + ArgInfo ("--light", ArgType.Unit (fun () -> light := Some true), "(ignored)"); + ArgInfo ("--light-off", ArgType.Unit (fun () -> light := Some false), "Add #light \"off\" to the top of the generated file"); + ArgInfo ("--lexlib", ArgType.String (fun s -> lexlib <- s), "Specify the namespace for the implementation of the lexer table interpreter (default Microsoft.FSharp.Text.Lexing)"); + ArgInfo ("--unicode", ArgType.Set unicode, "Produce a lexer for use with 16-bit unicode characters."); + ] + +let _ = ArgParser.Parse(usage, (fun x -> match !input with Some _ -> failwith "more than one input given" | None -> input := Some x), "fslex ") + +let outputInt (os: TextWriter) (n:int) = os.Write(string n) + +let outputCodedUInt16 (os: #TextWriter) (n:int) = + os.Write n; + os.Write "us; "; + +let sentinel = 255 * 256 + 255 + +let lineCount = ref 0 +let cfprintfn (os: #TextWriter) fmt = Printf.kfprintf (fun () -> incr lineCount; os.WriteLine()) os fmt + +let main() = + try + let filename = (match !input with Some x -> x | None -> failwith "no input given") + let domain = if !unicode then "Unicode" else "Ascii" + let spec = + let stream,reader,lexbuf = UnicodeFileAsLexbuf(filename, !inputCodePage) + use stream = stream + use reader = reader + try + Parser.spec Lexer.token lexbuf + with e -> + eprintf "%s(%d,%d): error: %s" filename lexbuf.StartPos.Line lexbuf.StartPos.Column + (match e with + | Failure s -> s + | _ -> e.Message); + exit 1 + printfn "compiling to dfas (can take a while...)"; + let perRuleData, dfaNodes = AST.Compile spec + let dfaNodes = dfaNodes |> List.sortBy (fun n -> n.Id) + + printfn "%d states" dfaNodes.Length; + printfn "writing output"; + + let output = + match !out with + | Some x -> x + | _ -> + Path.Combine (Path.GetDirectoryName filename,Path.GetFileNameWithoutExtension(filename)) + ".fs" + use os = System.IO.File.CreateText output + + if (!light = Some(false)) || (!light = None && (Path.HasExtension(output) && Path.GetExtension(output) = ".ml")) then + cfprintfn os "#light \"off\""; + + let printLinesIfCodeDefined (code,pos:Position) = + if pos <> Position.Empty // If bottom code is unspecified, then position is empty. + then + cfprintfn os "# %d \"%s\"" pos.Line pos.FileName; + cfprintfn os "%s" code; + + printLinesIfCodeDefined spec.TopCode + let code = fst spec.TopCode + lineCount := !lineCount + code.Replace("\r","").Split([| '\n' |]).Length; + cfprintfn os "# %d \"%s\"" !lineCount output; + + cfprintfn os "let trans : uint16[] array = "; + cfprintfn os " [| "; + if !unicode then + let specificUnicodeChars = GetSpecificUnicodeChars() + // This emits a (numLowUnicodeChars+NumUnicodeCategories+(2*#specificUnicodeChars)+1) * #states array of encoded UInt16 values + + // Each row for the Unicode table has format + // 128 entries for ASCII characters + // A variable number of 2*UInt16 entries for SpecificUnicodeChars + // 30 entries, one for each UnicodeCategory + // 1 entry for EOF + // + // Each entry is an encoded UInt16 value indicating the next state to transition to for this input. + // + // For the SpecificUnicodeChars the entries are char/next-state pairs. + for state in dfaNodes do + cfprintfn os " (* State %d *)" state.Id; + fprintf os " [| "; + let trans = + let dict = new Dictionary<_,_>() + state.Transitions |> List.iter dict.Add + dict + let emit n = + if trans.ContainsKey(n) then + outputCodedUInt16 os trans.[n].Id + else + outputCodedUInt16 os sentinel + for i = 0 to numLowUnicodeChars-1 do + let c = char i + emit (EncodeChar c); + for c in specificUnicodeChars do + outputCodedUInt16 os (int c); + emit (EncodeChar c); + for i = 0 to NumUnicodeCategories-1 do + emit (EncodeUnicodeCategoryIndex i); + emit Eof; + cfprintfn os "|];" + done; + + else + // Each row for the ASCII table has format + // 256 entries for ASCII characters + // 1 entry for EOF + // + // Each entry is an encoded UInt16 value indicating the next state to transition to for this input. + + // This emits a (256+1) * #states array of encoded UInt16 values + for state in dfaNodes do + cfprintfn os " (* State %d *)" state.Id; + fprintf os " [|"; + let trans = + let dict = new Dictionary<_,_>() + state.Transitions |> List.iter dict.Add + dict + let emit n = + if trans.ContainsKey(n) then + outputCodedUInt16 os trans.[n].Id + else + outputCodedUInt16 os sentinel + for i = 0 to 255 do + let c = char i + emit (EncodeChar c); + emit Eof; + cfprintfn os "|];" + done; + + cfprintfn os " |] "; + + fprintf os "let actions : uint16[] = [|"; + for state in dfaNodes do + if state.Accepted.Length > 0 then + outputCodedUInt16 os (snd state.Accepted.Head) + else + outputCodedUInt16 os sentinel + done; + cfprintfn os "|]"; + cfprintfn os "let _fslex_tables = %s.%sTables.Create(trans,actions)" lexlib domain; + + cfprintfn os "let rec _fslex_dummy () = _fslex_dummy() "; + + // These actions push the additional start state and come first, because they are then typically inlined into later + // rules. This means more tailcalls are taken as direct branches, increasing efficiency and + // improving stack usage on platforms that do not take tailcalls. + for ((startNode, actions),(ident,args,_)) in List.zip perRuleData spec.Rules do + cfprintfn os "(* Rule %s *)" ident; + cfprintfn os "and %s %s (lexbuf : %s.LexBuffer<_>) = _fslex_%s %s %d lexbuf" ident (String.Join(" ",Array.ofList args)) lexlib ident (String.Join(" ",Array.ofList args)) startNode.Id; + for ((startNode, actions),(ident,args,_)) in List.zip perRuleData spec.Rules do + cfprintfn os "(* Rule %s *)" ident; + cfprintfn os "and _fslex_%s %s _fslex_state lexbuf =" ident (String.Join(" ",Array.ofList args)); + cfprintfn os " match _fslex_tables.Interpret(_fslex_state,lexbuf) with" ; + actions |> Seq.iteri (fun i (code,pos) -> + cfprintfn os " | %d -> ( " i; + cfprintfn os "# %d \"%s\"" pos.Line pos.FileName; + let lines = code.Split([| '\r'; '\n' |], StringSplitOptions.RemoveEmptyEntries) + for line in lines do + cfprintfn os " %s" line; + cfprintfn os "# %d \"%s\"" !lineCount output; + cfprintfn os " )") + cfprintfn os " | _ -> failwith \"%s\"" ident + + + cfprintfn os ""; + + printLinesIfCodeDefined spec.BottomCode + cfprintfn os "# 3000000 \"%s\"" output; + + with e -> + eprintf "FSLEX: error FSL000: %s" (match e with Failure s -> s | e -> e.ToString()); + exit 1 + + +let result = main() diff --git a/src/buildtools/fslex/fslex.fsproj b/src/buildtools/fslex/fslex.fsproj new file mode 100644 index 0000000000..9fba6aab33 --- /dev/null +++ b/src/buildtools/fslex/fslex.fsproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.0 + INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstant) + + + + + + + diff --git a/src/buildtools/fslex/fslex.fsx b/src/buildtools/fslex/fslex.fsx new file mode 100644 index 0000000000..82e434bcbb --- /dev/null +++ b/src/buildtools/fslex/fslex.fsx @@ -0,0 +1,3 @@ +#load "Lexing.fsi" "Lexing.fs" "Parsing.fsi" "Parsing.fs" "Arg.fsi" "Arg.fs" "fslexast.fs" "fslexpars.fs" "fslexlex.fs" "fslex.fs" + +let v = FsLexYacc.FsLex.Driver.result diff --git a/src/buildtools/fslex/fslexast.fs b/src/buildtools/fslex/fslexast.fs new file mode 100644 index 0000000000..96619645dd --- /dev/null +++ b/src/buildtools/fslex/fslexast.fs @@ -0,0 +1,409 @@ +(* (c) Microsoft Corporation 2005-2008. *) + +module FsLexYacc.FsLex.AST + +open System.Collections.Generic +open Microsoft.FSharp.Text +open Microsoft.FSharp.Collections +open Internal.Utilities +open Internal.Utilities.Text.Lexing + +let (|KeyValue|) (kvp:KeyValuePair<_,_>) = kvp.Key,kvp.Value + +type Ident = string +type Code = string * Position + +type Alphabet = uint32 + +let Eof : Alphabet = 0xFFFFFFFEu +let Epsilon : Alphabet = 0xFFFFFFFFu + + +let unicode = ref false + +let unicodeCategories = + dict + [| "Pe", System.Globalization.UnicodeCategory.ClosePunctuation; // (Pe) + "Pc", System.Globalization.UnicodeCategory.ConnectorPunctuation; // (Pc) + "Cc", System.Globalization.UnicodeCategory.Control; // (Cc) + "Sc", System.Globalization.UnicodeCategory.CurrencySymbol; // (Sc) + "Pd", System.Globalization.UnicodeCategory.DashPunctuation; // (Pd) + "Nd", System.Globalization.UnicodeCategory.DecimalDigitNumber; // (Nd) + "Me", System.Globalization.UnicodeCategory.EnclosingMark; // (Me) + "Pf", System.Globalization.UnicodeCategory.FinalQuotePunctuation; // (Pf) + "Cf", enum 15; //System.Globalization.UnicodeCategory.Format; // (Cf) + "Pi", System.Globalization.UnicodeCategory.InitialQuotePunctuation; // (Pi) + "Nl", System.Globalization.UnicodeCategory.LetterNumber; // (Nl) + "Zl", System.Globalization.UnicodeCategory.LineSeparator; // (Zl) + "Ll", System.Globalization.UnicodeCategory.LowercaseLetter; // (Ll) + "Sm", System.Globalization.UnicodeCategory.MathSymbol; // (Sm) + "Lm", System.Globalization.UnicodeCategory.ModifierLetter; // (Lm) + "Sk", System.Globalization.UnicodeCategory.ModifierSymbol; // (Sk) + "Mn", System.Globalization.UnicodeCategory.NonSpacingMark; // (Mn) + "Ps", System.Globalization.UnicodeCategory.OpenPunctuation; // (Ps) + "Lo", System.Globalization.UnicodeCategory.OtherLetter; // (Lo) + "Cn", System.Globalization.UnicodeCategory.OtherNotAssigned; // (Cn) + "No", System.Globalization.UnicodeCategory.OtherNumber; // (No) + "Po", System.Globalization.UnicodeCategory.OtherPunctuation; // (Po) + "So", System.Globalization.UnicodeCategory.OtherSymbol; // (So) + "Zp", System.Globalization.UnicodeCategory.ParagraphSeparator; // (Zp) + "Co", System.Globalization.UnicodeCategory.PrivateUse; // (Co) + "Zs", System.Globalization.UnicodeCategory.SpaceSeparator; // (Zs) + "Mc", System.Globalization.UnicodeCategory.SpacingCombiningMark; // (Mc) + "Cs", System.Globalization.UnicodeCategory.Surrogate; // (Cs) + "Lt", System.Globalization.UnicodeCategory.TitlecaseLetter; // (Lt) + "Lu", System.Globalization.UnicodeCategory.UppercaseLetter; // (Lu) + |] + +let NumUnicodeCategories = unicodeCategories.Count +let _ = assert (NumUnicodeCategories = 30) // see table interpreter +let encodedUnicodeCategoryBase = 0xFFFFFF00u +let EncodeUnicodeCategoryIndex(idx:int) = encodedUnicodeCategoryBase + uint32 idx +let EncodeUnicodeCategory(s:string) = + if not (!unicode) then + failwith "unicode category classes may only be used if --unicode is specified"; + if unicodeCategories.ContainsKey(s) then + EncodeUnicodeCategoryIndex (int32 unicodeCategories.[s]) + else + failwithf "invalid Unicode category: '%s'" s + +let IsUnicodeCategory(x:Alphabet) = (encodedUnicodeCategoryBase <= x) && (x < encodedUnicodeCategoryBase + uint32 NumUnicodeCategories) +let UnicodeCategoryIndex(x:Alphabet) = (x - encodedUnicodeCategoryBase) + +let numLowUnicodeChars = 128 +let _ = assert (numLowUnicodeChars = 128) // see table interpreter +let specificUnicodeChars = new Dictionary<_,_>() +let specificUnicodeCharsDecode = new Dictionary<_,_>() +let EncodeChar(c:char) = + let x = System.Convert.ToUInt32 c + if !unicode then + if x < uint32 numLowUnicodeChars then x + else + if not(specificUnicodeChars.ContainsKey(c)) then + let idx = uint32 numLowUnicodeChars + uint32 specificUnicodeChars.Count + specificUnicodeChars.[c] <- idx + specificUnicodeCharsDecode.[idx] <- c + specificUnicodeChars.[c] + else + if x >= 256u then failwithf "the Unicode character '%c' may not be used unless --unicode is specified" c; + x +let DecodeChar(x:Alphabet) = + if !unicode then + if x < uint32 numLowUnicodeChars then System.Convert.ToChar x + else specificUnicodeCharsDecode.[x] + else + if x >= 256u then failwithf "the Unicode character '%x' may not be used unless --unicode is specified" x; + System.Convert.ToChar x + + + +let NumSpecificUnicodeChars() = specificUnicodeChars.Count +let GetSpecificUnicodeChars() = + specificUnicodeChars + |> Seq.sortBy (fun (KeyValue(k,v)) -> v) + |> Seq.map (fun (KeyValue(k,v)) -> k) + +let GetSingleCharAlphabet() = + if !unicode + then Set.ofList [ for c in 0..numLowUnicodeChars-1 do yield (char c) + for c in GetSpecificUnicodeChars() do yield c ] + else Set.ofList [ for x in 0..255 -> (char x) ] + +let GetAlphabet() = + if !unicode + then Set.ofList [ for c in GetSingleCharAlphabet() do yield EncodeChar c + for uc in 0 .. NumUnicodeCategories-1 do yield EncodeUnicodeCategoryIndex uc ] + else Set.ofList [ for c in GetSingleCharAlphabet() do yield EncodeChar c ] + + +//let DecodeAlphabet (x:Alphabet) = System.Convert.ToChar(x) + +(* +for i in 0 .. 65535 do + let c = char i + if System.Char.GetUnicodeCategory c = System.Globalization.UnicodeCategory.PrivateUse then + printfn "i = %x" i +*) + +type Spec = + { TopCode: Code; + Macros: (Ident * Regexp) list; + Rules: (Ident * Ident list * Clause list) list; + BottomCode: Code } +and Clause = Regexp * Code +and Regexp = + | Alt of Regexp list + | Seq of Regexp list + | Inp of Input + | Star of Regexp + | Macro of Ident +and Input = + | Alphabet of Alphabet + | UnicodeCategory of string + | Any + | NotCharSet of Set + +type NodeId = int + +type NfaNode = + { Id: NodeId; + Name: string; + Transitions: Dictionary; + Accepted: (int * int) list } + +type DfaNode = + { Id: int; + Name: string; + mutable Transitions: (Alphabet * DfaNode) list; + Accepted: (int * int) list } + +type MultiMap<'a,'b> = Dictionary<'a,'b list> +let LookupMultiMap (trDict:MultiMap<_,_>) a = + if trDict.ContainsKey(a) then trDict.[a] else [] + +let AddToMultiMap (trDict:MultiMap<_,_>) a b = + let prev = LookupMultiMap trDict a + trDict.[a] <- b::prev + +type NfaNodeMap() = + let map = new Dictionary(100) + member x.Item with get(nid) = map.[nid] + member x.Count = map.Count + + member x.NewNfaNode(trs,ac) = + let nodeId = map.Count+1 // ID zero is reserved + let trDict = new Dictionary<_,_>(List.length trs) + for (a,b) in trs do + AddToMultiMap trDict a b + + let node : NfaNode = {Id=nodeId; Name=string nodeId; Transitions=trDict; Accepted=ac} + map.[nodeId] <-node; + node + +let LexerStateToNfa (macros: Map) (clauses: Clause list) = + + /// Table allocating node ids + let nfaNodeMap = new NfaNodeMap() + + /// Compile a regular expression into the NFA + let rec CompileRegexp re dest = + match re with + | Alt res -> + let trs = res |> List.map (fun re -> (Epsilon,CompileRegexp re dest)) + nfaNodeMap.NewNfaNode(trs,[]) + | Seq res -> + List.foldBack (CompileRegexp) res dest + | Inp (Alphabet c) -> + nfaNodeMap.NewNfaNode([(c, dest)],[]) + + | Star re -> + let nfaNode = nfaNodeMap.NewNfaNode([(Epsilon, dest)],[]) + let sre = CompileRegexp re nfaNode + AddToMultiMap nfaNode.Transitions Epsilon sre + nfaNodeMap.NewNfaNode([(Epsilon,sre); (Epsilon,dest)],[]) + | Macro m -> + if not (macros.ContainsKey(m)) then failwith ("The macro "+m+" is not defined"); + CompileRegexp (macros.[m]) dest + + // These cases unwind the difficult cases in the syntax that rely on knowing the + // entire alphabet. + // + // Note we've delayed the expension of these until we've worked out all the 'special' Unicode characters + // mentioned in the entire lexer spec, i.e. we wait until GetAlphabet returns a reliable and stable answer. + | Inp (UnicodeCategory uc) -> + let re = Alt([ yield Inp(Alphabet(EncodeUnicodeCategory uc)) + // Also include any specific characters in this category + for c in GetSingleCharAlphabet() do + if System.Char.GetUnicodeCategory(c) = unicodeCategories.[uc] then + yield Inp(Alphabet(EncodeChar(c))) ]) + CompileRegexp re dest + + | Inp Any -> + let re = Alt([ for n in GetAlphabet() do yield Inp(Alphabet(n)) ]) + CompileRegexp re dest + + | Inp (NotCharSet chars) -> + let re = Alt [ // Include any characters from those in the alphabet besides those that are not immediately excluded + for c in GetSingleCharAlphabet() do + let ec = EncodeChar c + if not (chars.Contains(ec)) then + yield Inp(Alphabet(ec)) + + // Include all unicode categories + // That is, negations _only_ exclude precisely the given set of characters. You can't + // exclude whole classes of characters as yet + if !unicode then + let ucs = chars |> Set.map(DecodeChar >> System.Char.GetUnicodeCategory) + for KeyValue(nm,uc) in unicodeCategories do + //if ucs.Contains(uc) then + // do printfn "warning: the unicode category '\\%s' ('%s') is automatically excluded by this character set negation. Consider adding this to the negation." nm (uc.ToString()) + // yield! [] + //else + yield Inp(Alphabet(EncodeUnicodeCategory nm)) + ] + CompileRegexp re dest + + let actions = new System.Collections.Generic.List<_>() + + /// Compile an acceptance of a regular expression into the NFA + let sTrans macros nodeId (regexp,code) = + let actionId = actions.Count + actions.Add(code) + let sAccept = nfaNodeMap.NewNfaNode([],[(nodeId,actionId)]) + CompileRegexp regexp sAccept + + let trs = clauses |> List.mapi (fun n x -> (Epsilon,sTrans macros n x)) + let nfaStartNode = nfaNodeMap.NewNfaNode(trs,[]) + nfaStartNode,(actions |> Seq.readonly), nfaNodeMap + +// TODO: consider a better representation here. +type internal NfaNodeIdSetBuilder = HashSet + +type internal NfaNodeIdSet(nodes: NfaNodeIdSetBuilder) = + // BEWARE: the next line is performance critical + let s = nodes |> Seq.toArray |> (fun arr -> Array.sortInPlaceWith compare arr; arr) // 19 + + // These are all surprisingly slower: + //let s = nodes |> Seq.toArray |> Array.sort + //let s = nodes |> Seq.toArray |> Array.sortWith compare // 76 + //let s = nodes |> Seq.toArray |> (fun arr -> Array.sortInPlace arr; arr) // 76 + + member x.Representation = s + member x.Elements = s + member x.Fold f z = Array.fold f z s + interface System.IComparable with + member x.CompareTo(y:obj) = + let y = (y :?> NfaNodeIdSet) + let xr = x.Representation + let yr = y.Representation + let c = compare xr.Length yr.Length + if c <> 0 then c else + let n = yr.Length + let rec go i = + if i >= n then 0 else + let c = compare xr.[i] yr.[i] + if c <> 0 then c else + go (i+1) + go 0 + + override x.Equals(y:obj) = + match y with + | :? NfaNodeIdSet as y -> + let xr = x.Representation + let yr = y.Representation + let n = yr.Length + xr.Length = n && + (let rec go i = (i < n) && xr.[i] = yr.[i] && go (i+1) + go 0) + | _ -> false + + override x.GetHashCode() = hash s + + member x.IsEmpty = (s.Length = 0) + member x.Iterate f = s |> Array.iter f + +type NodeSetSet = Set + +let newDfaNodeId = + let i = ref 0 + fun () -> let res = !i in incr i; res + +let NfaToDfa (nfaNodeMap:NfaNodeMap) nfaStartNode = + let numNfaNodes = nfaNodeMap.Count + let rec EClosure1 (acc:NfaNodeIdSetBuilder) (n:NfaNode) = + if not (acc.Contains(n.Id)) then + acc.Add(n.Id) |> ignore; + if n.Transitions.ContainsKey(Epsilon) then + match n.Transitions.[Epsilon] with + | [] -> () // this Clause is an optimization - the list is normally empty + | tr -> + //printfn "n.Id = %A, #Epsilon = %d" n.Id tr.Length + tr |> List.iter (EClosure1 acc) + + let EClosure (moves:list) = + let acc = new NfaNodeIdSetBuilder(HashIdentity.Structural) + for i in moves do + EClosure1 acc nfaNodeMap.[i]; + new NfaNodeIdSet(acc) + + // Compute all the immediate one-step moves for a set of NFA states, as a dictionary + // mapping inputs to destination lists + let ComputeMoves (nset:NfaNodeIdSet) = + let moves = new MultiMap<_,_>() + nset.Iterate(fun nodeId -> + for (KeyValue(inp,dests)) in nfaNodeMap.[nodeId].Transitions do + if inp <> Epsilon then + match dests with + | [] -> () // this Clause is an optimization - the list is normally empty + | tr -> tr |> List.iter(fun dest -> AddToMultiMap moves inp dest.Id)) + moves + + let acc = new NfaNodeIdSetBuilder(HashIdentity.Structural) + EClosure1 acc nfaStartNode; + let nfaSet0 = new NfaNodeIdSet(acc) + + let dfaNodes = ref (Map.empty) + + let GetDfaNode nfaSet = + if (!dfaNodes).ContainsKey(nfaSet) then + (!dfaNodes).[nfaSet] + else + let dfaNode = + { Id= newDfaNodeId(); + Name = nfaSet.Fold (fun s nid -> nfaNodeMap.[nid].Name+"-"+s) ""; + Transitions=[]; + Accepted= nfaSet.Elements + |> Seq.map (fun nid -> nfaNodeMap.[nid].Accepted) + |> List.concat } + //Printf.printfn "id = %d" dfaNode.Id; + + dfaNodes := (!dfaNodes).Add(nfaSet,dfaNode); + dfaNode + + let workList = ref [nfaSet0] + let doneSet = ref Set.empty + + //let count = ref 0 + let rec Loop () = + match !workList with + | [] -> () + | nfaSet ::t -> + workList := t; + if (!doneSet).Contains(nfaSet) then + Loop () + else + let moves = ComputeMoves nfaSet + for (KeyValue(inp,movesForInput)) in moves do + assert (inp <> Epsilon); + let moveSet = EClosure movesForInput; + if not moveSet.IsEmpty then + //incr count + let dfaNode = GetDfaNode nfaSet + dfaNode.Transitions <- (inp, GetDfaNode moveSet) :: dfaNode.Transitions; + (* Printf.printf "%d (%s) : %s --> %d (%s)\n" dfaNode.Id dfaNode.Name (match inp with EncodeChar c -> String.make 1 c | LEof -> "eof") moveSetDfaNode.Id moveSetDfaNode.Name;*) + workList := moveSet :: !workList; + + doneSet := (!doneSet).Add(nfaSet); + + + Loop() + Loop(); + //Printf.printfn "count = %d" !count; + let ruleStartNode = GetDfaNode nfaSet0 + let ruleNodes = + (!dfaNodes) + |> Seq.map (fun kvp -> kvp.Value) + |> Seq.toList + |> List.sortBy (fun s -> s.Id) + ruleStartNode,ruleNodes + +let Compile spec = + List.foldBack + (fun (name,args,clauses) (perRuleData,dfaNodes) -> + let nfa, actions, nfaNodeMap = LexerStateToNfa (Map.ofList spec.Macros) clauses + let ruleStartNode, ruleNodes = NfaToDfa nfaNodeMap nfa + //Printf.printfn "name = %s, ruleStartNode = %O" name ruleStartNode.Id; + (ruleStartNode,actions) :: perRuleData, ruleNodes @ dfaNodes) + spec.Rules + ([],[]) + diff --git a/src/buildtools/fslex/fslexlex.fs b/src/buildtools/fslex/fslexlex.fs new file mode 100644 index 0000000000..b29bd10f84 --- /dev/null +++ b/src/buildtools/fslex/fslexlex.fs @@ -0,0 +1,735 @@ +# 1 "fslexlex.fsl" + +(* (c) Microsoft Corporation 2005-2008. *) + +module internal FsLexYacc.FsLex.Lexer + +open FsLexYacc.FsLex.AST +open FsLexYacc.FsLex.Parser +open Internal.Utilities +open Internal.Utilities.Text.Lexing +open System.Text + +let escape c = + match c with + | '\\' -> '\\' + | '\'' -> '\'' + | 'n' -> '\n' + | 't' -> '\t' + | 'b' -> '\b' + | 'r' -> '\r' + | c -> c + +let lexeme (lexbuf : LexBuffer) = new System.String(lexbuf.Lexeme) +let newline (lexbuf:LexBuffer<_>) = lexbuf.EndPos <- lexbuf.EndPos.NextLine + +let unexpected_char lexbuf = + failwith ("Unexpected character '"+(lexeme lexbuf)+"'") + +let digit d = + if d >= '0' && d <= '9' then int32 d - int32 '0' + else failwith "digit" + +let hexdigit d = + if d >= '0' && d <= '9' then digit d + else if d >= 'a' && d <= 'f' then int32 d - int32 'a' + 10 + else if d >= 'A' && d <= 'F' then int32 d - int32 'A' + 10 + else failwithf "bad hexdigit: %c" d + +let trigraph c1 c2 c3 = + char (digit c1 * 100 + digit c2 * 10 + digit c3) + +let hexgraph c1 c2 = + char (hexdigit c1 * 16 + hexdigit c2) + +let unicodegraph_short (s:string) = + if s.Length <> 4 then failwith "unicodegraph"; + char(hexdigit s.[0] * 4096 + hexdigit s.[1] * 256 + hexdigit s.[2] * 16 + hexdigit s.[3]) + +let unicodegraph_long (s:string) = + if s.Length <> 8 then failwith "unicodegraph_long"; + let high = hexdigit s.[0] * 4096 + hexdigit s.[1] * 256 + hexdigit s.[2] * 16 + hexdigit s.[3] in + let low = hexdigit s.[4] * 4096 + hexdigit s.[5] * 256 + hexdigit s.[6] * 16 + hexdigit s.[7] in + if high = 0 then None, char low + else + (* A surrogate pair - see http://www.unicode.org/unicode/uni2book/ch03.pdf, section 3.7 *) + Some (char(0xD800 + ((high * 0x10000 + low - 0x10000) / 0x400))), + char(0xDF30 + ((high * 0x10000 + low - 0x10000) % 0x400)) + + +# 60 "fslexlex.fs" +let trans : uint16[] array = + [| + (* State 0 *) + [| 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 4us; 8us; 8us; 5us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 2us; 8us; 8us; 8us; 8us; 1us; 3us; 9us; 6us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 7us; |]; + (* State 1 *) + [| 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 15us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 14us; 65535us; |]; + (* State 2 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 3 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 13us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 4 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 5 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 12us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 6 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 11us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 7 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 8 *) + [| 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; 10us; 10us; 65535us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; 10us; 10us; 10us; 10us; 65535us; 65535us; 65535us; 65535us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; |]; + (* State 9 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 10 *) + [| 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; 10us; 10us; 65535us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; 10us; 10us; 10us; 10us; 65535us; 65535us; 65535us; 65535us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 10us; 65535us; |]; + (* State 11 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 12 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 13 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 14 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 16us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 15 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 14us; 65535us; 65535us; 65535us; 65535us; 14us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 14us; 65535us; 65535us; 65535us; 65535us; 65535us; 14us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 14us; 65535us; 65535us; 65535us; 14us; 65535us; 14us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 16 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 17 *) + [| 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 22us; 20us; 24us; 24us; 21us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 22us; 24us; 19us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 24us; 18us; 24us; 24us; 24us; 24us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 22us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 23us; |]; + (* State 18 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 27us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 27us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 19 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 20 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 21 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 26us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 22 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 23 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 24 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 25 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 26 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 27 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 28 *) + [| 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 35us; 33us; 38us; 38us; 34us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 35us; 38us; 32us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 36us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 38us; 31us; 38us; 38us; 38us; 38us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 30us; 38us; 29us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 38us; 37us; |]; + (* State 29 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 30 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 31 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 43us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 43us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 32 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 33 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 34 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 42us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 35 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 36 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 39us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 37 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 38 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 39 *) + [| 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 65535us; 40us; 40us; 65535us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 65535us; |]; + (* State 40 *) + [| 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 65535us; 40us; 40us; 65535us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 40us; 65535us; |]; + (* State 41 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 42 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 43 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 44 *) + [| 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 49us; 47us; 51us; 51us; 48us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 49us; 51us; 46us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 51us; 45us; 51us; 51us; 51us; 51us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 49us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 50us; |]; + (* State 45 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 54us; 65535us; 65535us; 55us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 56us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 46 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 47 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 48 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 53us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 49 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 50 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 51 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 52 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 53 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 54 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 55 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 54us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 56 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 57 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 58 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 59us; 59us; 59us; 59us; 59us; 59us; 59us; 59us; 59us; 59us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 59 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 60 *) + [| 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 69us; 70us; 87us; 87us; 71us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 69us; 87us; 68us; 87us; 87us; 87us; 87us; 66us; 81us; 82us; 76us; 75us; 87us; 85us; 74us; 86us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 78us; 87us; 77us; 87us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 79us; 87us; 80us; 84us; 83us; 87us; 65us; 72us; 72us; 72us; 63us; 72us; 72us; 72us; 72us; 72us; 72us; 64us; 72us; 72us; 72us; 62us; 72us; 61us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 72us; 67us; 73us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 87us; 88us; |]; + (* State 61 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 136us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 62 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 132us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 63 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 130us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 64 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 128us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 65 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 126us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 66 *) + [| 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 96us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 95us; 65535us; |]; + (* State 67 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 68 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 69 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 94us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 94us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 70 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 71 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 93us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 72 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 73 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 74 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 75 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 76 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 77 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 78 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 79 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 80 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 81 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 91us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 82 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 83 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 84 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 85 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 86 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 89us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 87 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 88 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 89 *) + [| 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 65535us; 90us; 90us; 65535us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 65535us; |]; + (* State 90 *) + [| 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 65535us; 90us; 90us; 65535us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 90us; 65535us; |]; + (* State 91 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 92 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 93 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 94 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 94us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 94us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 95 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 125us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 96 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 95us; 65535us; 65535us; 65535us; 65535us; 95us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 97us; 97us; 97us; 97us; 97us; 97us; 97us; 97us; 97us; 97us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 101us; 100us; 101us; 101us; 101us; 101us; 101us; 65535us; 95us; 65535us; 65535us; 65535us; 65535us; 65535us; 95us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 95us; 65535us; 65535us; 65535us; 95us; 65535us; 95us; 99us; 65535us; 65535us; 98us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 97 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 122us; 122us; 122us; 122us; 122us; 122us; 122us; 122us; 122us; 122us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 98 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 119us; 119us; 119us; 119us; 119us; 119us; 119us; 119us; 119us; 119us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 119us; 119us; 119us; 119us; 119us; 119us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 119us; 119us; 119us; 119us; 119us; 119us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 99 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 114us; 114us; 114us; 114us; 114us; 114us; 114us; 114us; 114us; 114us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 114us; 114us; 114us; 114us; 114us; 114us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 114us; 114us; 114us; 114us; 114us; 114us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 100 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 104us; 104us; 104us; 104us; 104us; 104us; 104us; 104us; 104us; 104us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 104us; 104us; 104us; 104us; 104us; 104us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 105us; 105us; 105us; 105us; 105us; 105us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 101 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 102us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 102 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 103us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 103 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 104 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 105 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 103us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 106us; 106us; 106us; 106us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 106 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 107us; 107us; 107us; 107us; 107us; 107us; 107us; 107us; 107us; 107us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 107us; 107us; 107us; 107us; 107us; 107us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 107us; 107us; 107us; 107us; 107us; 107us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 107 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 108us; 108us; 108us; 108us; 108us; 108us; 108us; 108us; 108us; 108us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 108us; 108us; 108us; 108us; 108us; 108us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 108us; 108us; 108us; 108us; 108us; 108us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 108 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 109us; 109us; 109us; 109us; 109us; 109us; 109us; 109us; 109us; 109us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 109us; 109us; 109us; 109us; 109us; 109us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 109us; 109us; 109us; 109us; 109us; 109us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 109 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 110us; 110us; 110us; 110us; 110us; 110us; 110us; 110us; 110us; 110us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 110us; 110us; 110us; 110us; 110us; 110us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 110us; 110us; 110us; 110us; 110us; 110us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 110 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 111us; 111us; 111us; 111us; 111us; 111us; 111us; 111us; 111us; 111us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 111us; 111us; 111us; 111us; 111us; 111us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 111us; 111us; 111us; 111us; 111us; 111us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 111 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 112us; 112us; 112us; 112us; 112us; 112us; 112us; 112us; 112us; 112us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 112us; 112us; 112us; 112us; 112us; 112us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 112us; 112us; 112us; 112us; 112us; 112us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 112 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 113us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 113 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 114 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 115us; 115us; 115us; 115us; 115us; 115us; 115us; 115us; 115us; 115us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 115us; 115us; 115us; 115us; 115us; 115us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 115us; 115us; 115us; 115us; 115us; 115us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 115 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 116us; 116us; 116us; 116us; 116us; 116us; 116us; 116us; 116us; 116us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 116us; 116us; 116us; 116us; 116us; 116us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 116us; 116us; 116us; 116us; 116us; 116us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 116 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 117us; 117us; 117us; 117us; 117us; 117us; 117us; 117us; 117us; 117us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 117us; 117us; 117us; 117us; 117us; 117us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 117us; 117us; 117us; 117us; 117us; 117us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 117 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 118us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 118 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 119 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 120us; 120us; 120us; 120us; 120us; 120us; 120us; 120us; 120us; 120us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 120us; 120us; 120us; 120us; 120us; 120us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 120us; 120us; 120us; 120us; 120us; 120us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 120 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 121us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 121 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 122 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 123us; 123us; 123us; 123us; 123us; 123us; 123us; 123us; 123us; 123us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 123 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 124us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 124 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 125 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 126 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 127us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 127 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 128 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 129us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 129 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 130 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 131us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 131 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 132 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 133us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 133 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 134us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 134 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 135us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 135 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 136 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 137us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 137 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 138us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 138 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + |] +let actions : uint16[] = [|65535us; 7us; 1us; 7us; 3us; 7us; 7us; 5us; 6us; 7us; 6us; 4us; 3us; 2us; 65535us; 65535us; 0us; 65535us; 5us; 1us; 2us; 5us; 3us; 4us; 5us; 3us; 2us; 0us; 65535us; 0us; 1us; 8us; 3us; 4us; 8us; 5us; 8us; 7us; 8us; 6us; 6us; 5us; 4us; 2us; 65535us; 7us; 3us; 4us; 7us; 5us; 6us; 7us; 5us; 4us; 0us; 65535us; 1us; 65535us; 65535us; 2us; 65535us; 15us; 15us; 15us; 15us; 15us; 31us; 11us; 12us; 13us; 14us; 31us; 15us; 16us; 17us; 18us; 19us; 20us; 21us; 22us; 23us; 24us; 25us; 26us; 27us; 28us; 31us; 31us; 32us; 30us; 30us; 29us; 15us; 14us; 13us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 10us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 9us; 65535us; 65535us; 65535us; 65535us; 8us; 65535us; 65535us; 7us; 65535us; 65535us; 6us; 5us; 15us; 4us; 15us; 3us; 15us; 2us; 15us; 15us; 15us; 1us; 15us; 15us; 0us; |] +let _fslex_tables = Internal.Utilities.Text.Lexing.UnicodeTables.Create(trans,actions) +let rec _fslex_dummy () = _fslex_dummy() +(* Rule token *) +and token (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_token 60 lexbuf +(* Rule string *) +and string p buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_string p buff 44 lexbuf +(* Rule code *) +and code p buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_code p buff 28 lexbuf +(* Rule codestring *) +and codestring buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_codestring buff 17 lexbuf +(* Rule comment *) +and comment p (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_comment p 0 lexbuf +(* Rule token *) +and _fslex_token _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 76 "fslexlex.fsl" + RULE +# 361 "fslexlex.fs" + ) + | 1 -> ( +# 77 "fslexlex.fsl" + PARSE +# 366 "fslexlex.fs" + ) + | 2 -> ( +# 78 "fslexlex.fsl" + EOF +# 371 "fslexlex.fs" + ) + | 3 -> ( +# 79 "fslexlex.fsl" + LET +# 376 "fslexlex.fs" + ) + | 4 -> ( +# 80 "fslexlex.fsl" + AND +# 381 "fslexlex.fs" + ) + | 5 -> ( +# 82 "fslexlex.fsl" + let s = lexeme lexbuf in + CHAR (if s.[1] = '\\' then escape s.[2] else s.[1]) +# 387 "fslexlex.fs" + ) + | 6 -> ( +# 86 "fslexlex.fsl" + let s = lexeme lexbuf in + CHAR (trigraph s.[2] s.[3] s.[4]) +# 393 "fslexlex.fs" + ) + | 7 -> ( +# 90 "fslexlex.fsl" + let s = lexeme lexbuf in + CHAR (hexgraph s.[3] s.[4]) +# 399 "fslexlex.fs" + ) + | 8 -> ( +# 94 "fslexlex.fsl" + let s = lexeme lexbuf in + CHAR (unicodegraph_short s.[3..6]) +# 405 "fslexlex.fs" + ) + | 9 -> ( +# 98 "fslexlex.fsl" + let s = lexeme lexbuf in + match (unicodegraph_long s.[3..10]) with + | None, c -> CHAR(c) + | Some _ , _ -> failwith "Unicode characters needing surrogate pairs are not yet supported by this tool" +# 413 "fslexlex.fs" + ) + | 10 -> ( +# 104 "fslexlex.fsl" + let s = (lexeme lexbuf).[2..3] in + UNICODE_CATEGORY (s) +# 419 "fslexlex.fs" + ) + | 11 -> ( +# 107 "fslexlex.fsl" + let p = lexbuf.StartPos in + let buff = (new StringBuilder 100) in + // adjust the first line to get even indentation for all lines w.r.t. the left hand margin + buff.Append (String.replicate (lexbuf.StartPos.Column+1) " ") |> ignore; + code p buff lexbuf +# 428 "fslexlex.fs" + ) + | 12 -> ( +# 113 "fslexlex.fsl" + string lexbuf.StartPos (new StringBuilder 100) lexbuf +# 433 "fslexlex.fs" + ) + | 13 -> ( +# 115 "fslexlex.fsl" + token lexbuf +# 438 "fslexlex.fs" + ) + | 14 -> ( +# 116 "fslexlex.fsl" + newline lexbuf; token lexbuf +# 443 "fslexlex.fs" + ) + | 15 -> ( +# 117 "fslexlex.fsl" + IDENT (lexeme lexbuf) +# 448 "fslexlex.fs" + ) + | 16 -> ( +# 118 "fslexlex.fsl" + BAR +# 453 "fslexlex.fs" + ) + | 17 -> ( +# 119 "fslexlex.fsl" + DOT +# 458 "fslexlex.fs" + ) + | 18 -> ( +# 120 "fslexlex.fsl" + PLUS +# 463 "fslexlex.fs" + ) + | 19 -> ( +# 121 "fslexlex.fsl" + STAR +# 468 "fslexlex.fs" + ) + | 20 -> ( +# 122 "fslexlex.fsl" + QMARK +# 473 "fslexlex.fs" + ) + | 21 -> ( +# 123 "fslexlex.fsl" + EQUALS +# 478 "fslexlex.fs" + ) + | 22 -> ( +# 124 "fslexlex.fsl" + LBRACK +# 483 "fslexlex.fs" + ) + | 23 -> ( +# 125 "fslexlex.fsl" + RBRACK +# 488 "fslexlex.fs" + ) + | 24 -> ( +# 126 "fslexlex.fsl" + LPAREN +# 493 "fslexlex.fs" + ) + | 25 -> ( +# 127 "fslexlex.fsl" + RPAREN +# 498 "fslexlex.fs" + ) + | 26 -> ( +# 128 "fslexlex.fsl" + UNDERSCORE +# 503 "fslexlex.fs" + ) + | 27 -> ( +# 129 "fslexlex.fsl" + HAT +# 508 "fslexlex.fs" + ) + | 28 -> ( +# 130 "fslexlex.fsl" + DASH +# 513 "fslexlex.fs" + ) + | 29 -> ( +# 131 "fslexlex.fsl" + ignore(comment lexbuf.StartPos lexbuf); token lexbuf +# 518 "fslexlex.fs" + ) + | 30 -> ( +# 132 "fslexlex.fsl" + token lexbuf +# 523 "fslexlex.fs" + ) + | 31 -> ( +# 133 "fslexlex.fsl" + unexpected_char lexbuf +# 528 "fslexlex.fs" + ) + | 32 -> ( +# 134 "fslexlex.fsl" + EOF +# 533 "fslexlex.fs" + ) + | _ -> failwith "token" +(* Rule string *) +and _fslex_string p buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 136 "fslexlex.fsl" + newline lexbuf; string p buff lexbuf +# 542 "fslexlex.fs" + ) + | 1 -> ( +# 138 "fslexlex.fsl" + let _ = buff.Append (escape (lexeme lexbuf).[1]) in + string p buff lexbuf +# 548 "fslexlex.fs" + ) + | 2 -> ( +# 141 "fslexlex.fsl" + let s = lexeme lexbuf in + let _ = buff.Append (trigraph s.[1] s.[2] s.[3]) in + string p buff lexbuf +# 555 "fslexlex.fs" + ) + | 3 -> ( +# 144 "fslexlex.fsl" + STRING (buff.ToString()) +# 560 "fslexlex.fs" + ) + | 4 -> ( +# 145 "fslexlex.fsl" + newline lexbuf; + let _ = buff.Append System.Environment.NewLine in + string p buff lexbuf +# 567 "fslexlex.fs" + ) + | 5 -> ( +# 149 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + string p buff lexbuf +# 573 "fslexlex.fs" + ) + | 6 -> ( +# 151 "fslexlex.fsl" + failwith (Printf.sprintf "end of file in string started at (%d,%d)" p.pos_lnum (p.pos_cnum - p.pos_bol)) +# 578 "fslexlex.fs" + ) + | 7 -> ( +# 152 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf).[0] in + string p buff lexbuf +# 584 "fslexlex.fs" + ) + | _ -> failwith "string" +(* Rule code *) +and _fslex_code p buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 155 "fslexlex.fsl" + CODE (buff.ToString(), p) +# 593 "fslexlex.fs" + ) + | 1 -> ( +# 156 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + ignore(code p buff lexbuf); + let _ = buff.Append "}" in + code p buff lexbuf +# 601 "fslexlex.fs" + ) + | 2 -> ( +# 161 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + code p buff lexbuf +# 607 "fslexlex.fs" + ) + | 3 -> ( +# 163 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + ignore(codestring buff lexbuf); + code p buff lexbuf +# 614 "fslexlex.fs" + ) + | 4 -> ( +# 166 "fslexlex.fsl" + newline lexbuf; + let _ = buff.Append System.Environment.NewLine in + code p buff lexbuf +# 621 "fslexlex.fs" + ) + | 5 -> ( +# 170 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + code p buff lexbuf +# 627 "fslexlex.fs" + ) + | 6 -> ( +# 173 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + code p buff lexbuf +# 633 "fslexlex.fs" + ) + | 7 -> ( +# 175 "fslexlex.fsl" + EOF +# 638 "fslexlex.fs" + ) + | 8 -> ( +# 176 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf).[0] in + code p buff lexbuf +# 644 "fslexlex.fs" + ) + | _ -> failwith "code" +(* Rule codestring *) +and _fslex_codestring buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 181 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + codestring buff lexbuf +# 654 "fslexlex.fs" + ) + | 1 -> ( +# 183 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + buff.ToString() +# 660 "fslexlex.fs" + ) + | 2 -> ( +# 185 "fslexlex.fsl" + newline lexbuf; + let _ = buff.Append System.Environment.NewLine in + codestring buff lexbuf +# 667 "fslexlex.fs" + ) + | 3 -> ( +# 189 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf) in + codestring buff lexbuf +# 673 "fslexlex.fs" + ) + | 4 -> ( +# 191 "fslexlex.fsl" + failwith "unterminated string in code" +# 678 "fslexlex.fs" + ) + | 5 -> ( +# 192 "fslexlex.fsl" + let _ = buff.Append (lexeme lexbuf).[0] in + codestring buff lexbuf +# 684 "fslexlex.fs" + ) + | _ -> failwith "codestring" +(* Rule comment *) +and _fslex_comment p _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 196 "fslexlex.fsl" + comment p lexbuf +# 693 "fslexlex.fs" + ) + | 1 -> ( +# 197 "fslexlex.fsl" + ignore(try string lexbuf.StartPos (new StringBuilder 100) lexbuf + with Failure s -> failwith (s + "\n" + Printf.sprintf "error while processing string nested in comment started at (%d,%d)" p.pos_lnum (p.pos_cnum - p.pos_bol))); + comment p lexbuf +# 700 "fslexlex.fs" + ) + | 2 -> ( +# 200 "fslexlex.fsl" + ignore(try comment p lexbuf with Failure s -> failwith (s + "\n" + Printf.sprintf "error while processing nested comment started at (%d,%d)" p.pos_lnum (p.pos_cnum - p.pos_bol))); + comment p lexbuf +# 706 "fslexlex.fs" + ) + | 3 -> ( +# 202 "fslexlex.fsl" + newline lexbuf; comment p lexbuf +# 711 "fslexlex.fs" + ) + | 4 -> ( +# 203 "fslexlex.fsl" + () +# 716 "fslexlex.fs" + ) + | 5 -> ( +# 204 "fslexlex.fsl" + failwith (Printf.sprintf "end of file in comment started at (%d,%d)" p.pos_lnum (p.pos_cnum - p.pos_bol)) +# 721 "fslexlex.fs" + ) + | 6 -> ( +# 205 "fslexlex.fsl" + comment p lexbuf +# 726 "fslexlex.fs" + ) + | 7 -> ( +# 206 "fslexlex.fsl" + comment p lexbuf +# 731 "fslexlex.fs" + ) + | _ -> failwith "comment" + +# 3000000 "fslexlex.fs" diff --git a/src/buildtools/fslex/fslexpars.fs b/src/buildtools/fslex/fslexpars.fs new file mode 100644 index 0000000000..87268dcb7f --- /dev/null +++ b/src/buildtools/fslex/fslexpars.fs @@ -0,0 +1,651 @@ +// Implementation file for parser generated by fsyacc +module internal FsLexYacc.FsLex.Parser +#nowarn "64";; // turn off warnings that type variables used in production annotations are instantiated to concrete type +open Internal.Utilities.Text.Lexing +open Internal.Utilities.Text.Parsing.ParseHelpers +# 1 "fslexpars.fsy" + +(* (c) Microsoft Corporation 2005-2008. *) + +open FsLexYacc.FsLex +open FsLexYacc.FsLex.AST + + +# 14 "fslexpars.fs" +// This type is the type of tokens accepted by the parser +type token = + | EOF + | BAR + | DOT + | PLUS + | STAR + | QMARK + | EQUALS + | UNDERSCORE + | LBRACK + | RBRACK + | HAT + | DASH + | RULE + | PARSE + | LET + | AND + | LPAREN + | RPAREN + | UNICODE_CATEGORY of (string) + | CHAR of (char) + | CODE of (AST.Code) + | STRING of (string) + | IDENT of (string) +// This type is used to give symbolic names to token indexes, useful for error messages +type tokenId = + | TOKEN_EOF + | TOKEN_BAR + | TOKEN_DOT + | TOKEN_PLUS + | TOKEN_STAR + | TOKEN_QMARK + | TOKEN_EQUALS + | TOKEN_UNDERSCORE + | TOKEN_LBRACK + | TOKEN_RBRACK + | TOKEN_HAT + | TOKEN_DASH + | TOKEN_RULE + | TOKEN_PARSE + | TOKEN_LET + | TOKEN_AND + | TOKEN_LPAREN + | TOKEN_RPAREN + | TOKEN_UNICODE_CATEGORY + | TOKEN_CHAR + | TOKEN_CODE + | TOKEN_STRING + | TOKEN_IDENT + | TOKEN_end_of_input + | TOKEN_error +// This type is used to give symbolic names to token indexes, useful for error messages +type nonTerminalId = + | NONTERM__startspec + | NONTERM_spec + | NONTERM_codeopt + | NONTERM_Macros + | NONTERM_macro + | NONTERM_Rules + | NONTERM_rule + | NONTERM_args + | NONTERM_optbar + | NONTERM_clauses + | NONTERM_clause + | NONTERM_regexp + | NONTERM_charset + +// This function maps tokens to integer indexes +let tagOfToken (t:token) = + match t with + | EOF -> 0 + | BAR -> 1 + | DOT -> 2 + | PLUS -> 3 + | STAR -> 4 + | QMARK -> 5 + | EQUALS -> 6 + | UNDERSCORE -> 7 + | LBRACK -> 8 + | RBRACK -> 9 + | HAT -> 10 + | DASH -> 11 + | RULE -> 12 + | PARSE -> 13 + | LET -> 14 + | AND -> 15 + | LPAREN -> 16 + | RPAREN -> 17 + | UNICODE_CATEGORY _ -> 18 + | CHAR _ -> 19 + | CODE _ -> 20 + | STRING _ -> 21 + | IDENT _ -> 22 + +// This function maps integer indexes to symbolic token ids +let tokenTagToTokenId (tokenIdx:int) = + match tokenIdx with + | 0 -> TOKEN_EOF + | 1 -> TOKEN_BAR + | 2 -> TOKEN_DOT + | 3 -> TOKEN_PLUS + | 4 -> TOKEN_STAR + | 5 -> TOKEN_QMARK + | 6 -> TOKEN_EQUALS + | 7 -> TOKEN_UNDERSCORE + | 8 -> TOKEN_LBRACK + | 9 -> TOKEN_RBRACK + | 10 -> TOKEN_HAT + | 11 -> TOKEN_DASH + | 12 -> TOKEN_RULE + | 13 -> TOKEN_PARSE + | 14 -> TOKEN_LET + | 15 -> TOKEN_AND + | 16 -> TOKEN_LPAREN + | 17 -> TOKEN_RPAREN + | 18 -> TOKEN_UNICODE_CATEGORY + | 19 -> TOKEN_CHAR + | 20 -> TOKEN_CODE + | 21 -> TOKEN_STRING + | 22 -> TOKEN_IDENT + | 25 -> TOKEN_end_of_input + | 23 -> TOKEN_error + | _ -> failwith "tokenTagToTokenId: bad token" + +/// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production +let prodIdxToNonTerminal (prodIdx:int) = + match prodIdx with + | 0 -> NONTERM__startspec + | 1 -> NONTERM_spec + | 2 -> NONTERM_codeopt + | 3 -> NONTERM_codeopt + | 4 -> NONTERM_Macros + | 5 -> NONTERM_Macros + | 6 -> NONTERM_macro + | 7 -> NONTERM_Rules + | 8 -> NONTERM_Rules + | 9 -> NONTERM_rule + | 10 -> NONTERM_args + | 11 -> NONTERM_args + | 12 -> NONTERM_optbar + | 13 -> NONTERM_optbar + | 14 -> NONTERM_clauses + | 15 -> NONTERM_clauses + | 16 -> NONTERM_clause + | 17 -> NONTERM_regexp + | 18 -> NONTERM_regexp + | 19 -> NONTERM_regexp + | 20 -> NONTERM_regexp + | 21 -> NONTERM_regexp + | 22 -> NONTERM_regexp + | 23 -> NONTERM_regexp + | 24 -> NONTERM_regexp + | 25 -> NONTERM_regexp + | 26 -> NONTERM_regexp + | 27 -> NONTERM_regexp + | 28 -> NONTERM_regexp + | 29 -> NONTERM_regexp + | 30 -> NONTERM_regexp + | 31 -> NONTERM_charset + | 32 -> NONTERM_charset + | 33 -> NONTERM_charset + | _ -> failwith "prodIdxToNonTerminal: bad production index" + +let _fsyacc_endOfInputTag = 25 +let _fsyacc_tagOfErrorTerminal = 23 + +// This function gets the name of a token as a string +let token_to_string (t:token) = + match t with + | EOF -> "EOF" + | BAR -> "BAR" + | DOT -> "DOT" + | PLUS -> "PLUS" + | STAR -> "STAR" + | QMARK -> "QMARK" + | EQUALS -> "EQUALS" + | UNDERSCORE -> "UNDERSCORE" + | LBRACK -> "LBRACK" + | RBRACK -> "RBRACK" + | HAT -> "HAT" + | DASH -> "DASH" + | RULE -> "RULE" + | PARSE -> "PARSE" + | LET -> "LET" + | AND -> "AND" + | LPAREN -> "LPAREN" + | RPAREN -> "RPAREN" + | UNICODE_CATEGORY _ -> "UNICODE_CATEGORY" + | CHAR _ -> "CHAR" + | CODE _ -> "CODE" + | STRING _ -> "STRING" + | IDENT _ -> "IDENT" + +// This function gets the data carried by a token as an object +let _fsyacc_dataOfToken (t:token) = + match t with + | EOF -> (null : System.Object) + | BAR -> (null : System.Object) + | DOT -> (null : System.Object) + | PLUS -> (null : System.Object) + | STAR -> (null : System.Object) + | QMARK -> (null : System.Object) + | EQUALS -> (null : System.Object) + | UNDERSCORE -> (null : System.Object) + | LBRACK -> (null : System.Object) + | RBRACK -> (null : System.Object) + | HAT -> (null : System.Object) + | DASH -> (null : System.Object) + | RULE -> (null : System.Object) + | PARSE -> (null : System.Object) + | LET -> (null : System.Object) + | AND -> (null : System.Object) + | LPAREN -> (null : System.Object) + | RPAREN -> (null : System.Object) + | UNICODE_CATEGORY _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | CHAR _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | CODE _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | STRING _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | IDENT _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x +let _fsyacc_gotos = [| 0us; 65535us; 1us; 65535us; 0us; 1us; 2us; 65535us; 0us; 2us; 5us; 6us; 2us; 65535us; 2us; 3us; 8us; 9us; 2us; 65535us; 2us; 8us; 8us; 8us; 2us; 65535us; 4us; 5us; 15us; 16us; 2us; 65535us; 4us; 14us; 15us; 14us; 2us; 65535us; 17us; 18us; 23us; 24us; 1us; 65535us; 20us; 21us; 2us; 65535us; 21us; 22us; 27us; 28us; 2us; 65535us; 21us; 26us; 27us; 26us; 10us; 65535us; 12us; 13us; 13us; 37us; 21us; 29us; 27us; 29us; 29us; 37us; 37us; 37us; 38us; 37us; 39us; 37us; 43us; 38us; 44us; 39us; 5us; 65535us; 46us; 47us; 47us; 55us; 49us; 50us; 50us; 55us; 55us; 55us; |] +let _fsyacc_sparseGotoTableRowOffsets = [|0us; 1us; 3us; 6us; 9us; 12us; 15us; 18us; 21us; 23us; 26us; 29us; 40us; |] +let _fsyacc_stateToProdIdxsTableElements = [| 1us; 0us; 1us; 0us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 2us; 1us; 5us; 1us; 5us; 1us; 6us; 1us; 6us; 1us; 6us; 6us; 6us; 23us; 24us; 25us; 26us; 27us; 2us; 7us; 8us; 1us; 7us; 1us; 7us; 1us; 9us; 1us; 9us; 1us; 9us; 1us; 9us; 1us; 9us; 1us; 9us; 1us; 11us; 1us; 11us; 1us; 13us; 2us; 14us; 15us; 1us; 14us; 1us; 14us; 6us; 16us; 23us; 24us; 25us; 26us; 27us; 1us; 16us; 1us; 17us; 1us; 18us; 1us; 19us; 1us; 20us; 1us; 21us; 1us; 22us; 6us; 23us; 23us; 24us; 25us; 26us; 27us; 6us; 23us; 24us; 25us; 26us; 27us; 27us; 6us; 23us; 24us; 25us; 26us; 27us; 28us; 1us; 24us; 1us; 25us; 1us; 26us; 1us; 27us; 1us; 28us; 1us; 28us; 2us; 29us; 30us; 2us; 29us; 33us; 1us; 29us; 1us; 30us; 2us; 30us; 33us; 1us; 30us; 2us; 31us; 32us; 1us; 32us; 1us; 32us; 2us; 33us; 33us; |] +let _fsyacc_stateToProdIdxsTableRowOffsets = [|0us; 2us; 4us; 6us; 8us; 10us; 12us; 14us; 16us; 18us; 20us; 22us; 24us; 26us; 33us; 36us; 38us; 40us; 42us; 44us; 46us; 48us; 50us; 52us; 54us; 56us; 58us; 61us; 63us; 65us; 72us; 74us; 76us; 78us; 80us; 82us; 84us; 86us; 93us; 100us; 107us; 109us; 111us; 113us; 115us; 117us; 119us; 122us; 125us; 127us; 129us; 132us; 134us; 137us; 139us; 141us; |] +let _fsyacc_action_rows = 56 +let _fsyacc_actionTableElements = [|1us; 16387us; 20us; 7us; 0us; 49152us; 1us; 16388us; 14us; 10us; 1us; 32768us; 12us; 4us; 1us; 32768us; 22us; 17us; 1us; 16387us; 20us; 7us; 0us; 16385us; 0us; 16386us; 1us; 16388us; 14us; 10us; 0us; 16389us; 1us; 32768us; 22us; 11us; 1us; 32768us; 6us; 12us; 8us; 32768us; 0us; 33us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 12us; 16390us; 0us; 33us; 1us; 43us; 3us; 40us; 4us; 41us; 5us; 42us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 1us; 16392us; 15us; 15us; 1us; 32768us; 22us; 17us; 0us; 16391us; 1us; 16394us; 22us; 23us; 1us; 32768us; 6us; 19us; 1us; 32768us; 13us; 20us; 1us; 16396us; 1us; 25us; 8us; 32768us; 0us; 33us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 0us; 16393us; 1us; 16394us; 22us; 23us; 0us; 16395us; 0us; 16397us; 1us; 16399us; 1us; 27us; 8us; 32768us; 0us; 33us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 0us; 16398us; 13us; 32768us; 0us; 33us; 1us; 43us; 3us; 40us; 4us; 41us; 5us; 42us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 20us; 30us; 21us; 35us; 22us; 36us; 0us; 16400us; 0us; 16401us; 0us; 16402us; 0us; 16403us; 0us; 16404us; 0us; 16405us; 0us; 16406us; 11us; 16407us; 0us; 33us; 3us; 40us; 4us; 41us; 5us; 42us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 11us; 16411us; 0us; 33us; 3us; 40us; 4us; 41us; 5us; 42us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 13us; 32768us; 0us; 33us; 1us; 43us; 3us; 40us; 4us; 41us; 5us; 42us; 7us; 34us; 8us; 46us; 16us; 44us; 17us; 45us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 0us; 16408us; 0us; 16409us; 0us; 16410us; 8us; 32768us; 0us; 33us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 8us; 32768us; 0us; 33us; 7us; 34us; 8us; 46us; 16us; 44us; 18us; 32us; 19us; 31us; 21us; 35us; 22us; 36us; 0us; 16412us; 2us; 32768us; 10us; 49us; 19us; 52us; 2us; 32768us; 9us; 48us; 19us; 52us; 0us; 16413us; 1us; 32768us; 19us; 52us; 2us; 32768us; 9us; 51us; 19us; 52us; 0us; 16414us; 1us; 16415us; 11us; 53us; 1us; 32768us; 19us; 54us; 0us; 16416us; 1us; 16417us; 19us; 52us; |] +let _fsyacc_actionTableRowOffsets = [|0us; 2us; 3us; 5us; 7us; 9us; 11us; 12us; 13us; 15us; 16us; 18us; 20us; 29us; 42us; 44us; 46us; 47us; 49us; 51us; 53us; 55us; 64us; 65us; 67us; 68us; 69us; 71us; 80us; 81us; 95us; 96us; 97us; 98us; 99us; 100us; 101us; 102us; 114us; 126us; 140us; 141us; 142us; 143us; 152us; 161us; 162us; 165us; 168us; 169us; 171us; 174us; 175us; 177us; 179us; 180us; |] +let _fsyacc_reductionSymbolCounts = [|1us; 5us; 1us; 0us; 0us; 2us; 4us; 3us; 1us; 6us; 0us; 2us; 0us; 1us; 3us; 1us; 2us; 1us; 1us; 1us; 1us; 1us; 1us; 2us; 2us; 2us; 2us; 3us; 3us; 3us; 4us; 1us; 3us; 2us; |] +let _fsyacc_productionToNonTerminalTable = [|0us; 1us; 2us; 2us; 3us; 3us; 4us; 5us; 5us; 6us; 7us; 7us; 8us; 8us; 9us; 9us; 10us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 11us; 12us; 12us; 12us; |] +let _fsyacc_immediateActions = [|65535us; 49152us; 65535us; 65535us; 65535us; 65535us; 16385us; 16386us; 65535us; 16389us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 16391us; 65535us; 65535us; 65535us; 65535us; 65535us; 16393us; 65535us; 16395us; 16397us; 65535us; 65535us; 16398us; 65535us; 16400us; 16401us; 16402us; 16403us; 16404us; 16405us; 16406us; 65535us; 65535us; 65535us; 16408us; 16409us; 16410us; 65535us; 65535us; 16412us; 65535us; 65535us; 16413us; 65535us; 65535us; 16414us; 65535us; 65535us; 16416us; 65535us; |] +let _fsyacc_reductions () = [| +# 246 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : AST.Spec)) in + Microsoft.FSharp.Core.Operators.box + ( + ( + raise (Internal.Utilities.Text.Parsing.Accept(Microsoft.FSharp.Core.Operators.box _1)) + ) + : '_startspec)); +# 255 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'codeopt)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'Macros)) in + let _4 = (let data = parseState.GetInput(4) in (Microsoft.FSharp.Core.Operators.unbox data : 'Rules)) in + let _5 = (let data = parseState.GetInput(5) in (Microsoft.FSharp.Core.Operators.unbox data : 'codeopt)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 24 "fslexpars.fsy" + { TopCode=_1;Macros=_2;Rules=_4;BottomCode=_5 } + ) +# 24 "fslexpars.fsy" + : AST.Spec)); +# 269 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : AST.Code)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 25 "fslexpars.fsy" + _1 + ) +# 25 "fslexpars.fsy" + : 'codeopt)); +# 280 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 25 "fslexpars.fsy" + "", (parseState.ResultRange |> fst) + ) +# 25 "fslexpars.fsy" + : 'codeopt)); +# 290 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 26 "fslexpars.fsy" + [] + ) +# 26 "fslexpars.fsy" + : 'Macros)); +# 300 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'macro)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'Macros)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 26 "fslexpars.fsy" + _1 :: _2 + ) +# 26 "fslexpars.fsy" + : 'Macros)); +# 312 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _4 = (let data = parseState.GetInput(4) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 27 "fslexpars.fsy" + (_2, _4) + ) +# 27 "fslexpars.fsy" + : 'macro)); +# 324 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'rule)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'Rules)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 28 "fslexpars.fsy" + _1 :: _3 + ) +# 28 "fslexpars.fsy" + : 'Rules)); +# 336 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'rule)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 28 "fslexpars.fsy" + [_1] + ) +# 28 "fslexpars.fsy" + : 'Rules)); +# 347 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'args)) in + let _5 = (let data = parseState.GetInput(5) in (Microsoft.FSharp.Core.Operators.unbox data : 'optbar)) in + let _6 = (let data = parseState.GetInput(6) in (Microsoft.FSharp.Core.Operators.unbox data : 'clauses)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 29 "fslexpars.fsy" + (_1,_2,_6) + ) +# 29 "fslexpars.fsy" + : 'rule)); +# 361 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 30 "fslexpars.fsy" + [] + ) +# 30 "fslexpars.fsy" + : 'args)); +# 371 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'args)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 30 "fslexpars.fsy" + _1 :: _2 + ) +# 30 "fslexpars.fsy" + : 'args)); +# 383 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 31 "fslexpars.fsy" + + ) +# 31 "fslexpars.fsy" + : 'optbar)); +# 393 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 31 "fslexpars.fsy" + + ) +# 31 "fslexpars.fsy" + : 'optbar)); +# 403 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'clause)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'clauses)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 32 "fslexpars.fsy" + _1 :: _3 + ) +# 32 "fslexpars.fsy" + : 'clauses)); +# 415 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'clause)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 32 "fslexpars.fsy" + [_1] + ) +# 32 "fslexpars.fsy" + : 'clauses)); +# 426 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : AST.Code)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 33 "fslexpars.fsy" + _1, _2 + ) +# 33 "fslexpars.fsy" + : 'clause)); +# 438 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : char)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 35 "fslexpars.fsy" + Inp(Alphabet(EncodeChar _1)) + ) +# 35 "fslexpars.fsy" + : 'regexp)); +# 449 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 36 "fslexpars.fsy" + Inp(UnicodeCategory _1) + ) +# 36 "fslexpars.fsy" + : 'regexp)); +# 460 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 37 "fslexpars.fsy" + Inp(Alphabet(Eof)) + ) +# 37 "fslexpars.fsy" + : 'regexp)); +# 470 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 38 "fslexpars.fsy" + Inp Any + ) +# 38 "fslexpars.fsy" + : 'regexp)); +# 480 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 39 "fslexpars.fsy" + Seq([ for n in 0 .. _1.Length - 1 -> Inp(Alphabet(EncodeChar _1.[n]))]) + ) +# 39 "fslexpars.fsy" + : 'regexp)); +# 491 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 40 "fslexpars.fsy" + Macro(_1) + ) +# 40 "fslexpars.fsy" + : 'regexp)); +# 502 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 41 "fslexpars.fsy" + Seq[_1;_2] + ) +# 41 "fslexpars.fsy" + : 'regexp)); +# 514 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 42 "fslexpars.fsy" + Seq[_1;Star _1] + ) +# 42 "fslexpars.fsy" + : 'regexp)); +# 525 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 43 "fslexpars.fsy" + Star _1 + ) +# 43 "fslexpars.fsy" + : 'regexp)); +# 536 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 44 "fslexpars.fsy" + Alt[Seq[];_1] + ) +# 44 "fslexpars.fsy" + : 'regexp)); +# 547 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 45 "fslexpars.fsy" + Alt[_1;_3] + ) +# 45 "fslexpars.fsy" + : 'regexp)); +# 559 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'regexp)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 46 "fslexpars.fsy" + _2 + ) +# 46 "fslexpars.fsy" + : 'regexp)); +# 570 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'charset)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 47 "fslexpars.fsy" + Alt [ for c in _2 -> Inp(Alphabet(c)) ] + ) +# 47 "fslexpars.fsy" + : 'regexp)); +# 581 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'charset)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 48 "fslexpars.fsy" + Inp(NotCharSet(_3)) + ) +# 48 "fslexpars.fsy" + : 'regexp)); +# 592 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : char)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 51 "fslexpars.fsy" + Set.singleton(EncodeChar _1) + ) +# 51 "fslexpars.fsy" + : 'charset)); +# 603 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : char)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : char)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 52 "fslexpars.fsy" + Set.ofSeq [ for c in _1 .. _3 -> EncodeChar c ] + ) +# 52 "fslexpars.fsy" + : 'charset)); +# 615 "fslexpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'charset)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'charset)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 53 "fslexpars.fsy" + Set.union _1 _2 + ) +# 53 "fslexpars.fsy" + : 'charset)); +|] +# 628 "fslexpars.fs" +let tables () : Internal.Utilities.Text.Parsing.Tables<_> = + { reductions= _fsyacc_reductions (); + endOfInputTag = _fsyacc_endOfInputTag; + tagOfToken = tagOfToken; + dataOfToken = _fsyacc_dataOfToken; + actionTableElements = _fsyacc_actionTableElements; + actionTableRowOffsets = _fsyacc_actionTableRowOffsets; + stateToProdIdxsTableElements = _fsyacc_stateToProdIdxsTableElements; + stateToProdIdxsTableRowOffsets = _fsyacc_stateToProdIdxsTableRowOffsets; + reductionSymbolCounts = _fsyacc_reductionSymbolCounts; + immediateActions = _fsyacc_immediateActions; + gotos = _fsyacc_gotos; + sparseGotoTableRowOffsets = _fsyacc_sparseGotoTableRowOffsets; + tagOfErrorTerminal = _fsyacc_tagOfErrorTerminal; + parseError = (fun (ctxt:Internal.Utilities.Text.Parsing.ParseErrorContext<_>) -> + match parse_error_rich with + | Some f -> f ctxt + | None -> parse_error ctxt.Message); + numTerminals = 26; + productionToNonTerminalTable = _fsyacc_productionToNonTerminalTable } +let engine lexer lexbuf startState = (tables ()).Interpret(lexer, lexbuf, startState) +let spec lexer lexbuf : AST.Spec = + Microsoft.FSharp.Core.Operators.unbox ((tables ()).Interpret(lexer, lexbuf, 0)) diff --git a/src/buildtools/fssrgen/fssrgen.fsproj b/src/buildtools/fssrgen/fssrgen.fsproj new file mode 100644 index 0000000000..d6d06d53df --- /dev/null +++ b/src/buildtools/fssrgen/fssrgen.fsproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.0 + COMPILED;$(DefineConstant) + + + + + + + diff --git a/src/buildtools/fssrgen/fssrgen.fsx b/src/buildtools/fssrgen/fssrgen.fsx new file mode 100644 index 0000000000..e7f2fb1555 --- /dev/null +++ b/src/buildtools/fssrgen/fssrgen.fsx @@ -0,0 +1,476 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +let PrintErr(filename, line, msg) = + printfn "%s(%d): error : %s" filename line msg + +let Err(filename, line, msg) = + PrintErr(filename, line, msg) + printfn "Note that the syntax of each line is one of these three alternatives:" + printfn "# comment" + printfn "ident,\"string\"" + printfn "errNum,ident,\"string\"" + failwith (sprintf "there were errors in the file '%s'" filename) + +let xmlBoilerPlateString = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + +" + + +type HoleType = string + + +// The kinds of 'holes' we can do +let ComputeHoles filename lineNum (txt:string) : ResizeArray * string = + // takes in a %d%s kind of string, returns array of HoleType and {0}{1} kind of string + let mutable i = 0 + let mutable holeNumber = 0 + let mutable holes = ResizeArray() // order + let sb = new System.Text.StringBuilder() + let AddHole holeType = + sb.Append(sprintf "{%d}" holeNumber) |> ignore + holeNumber <- holeNumber + 1 + holes.Add(holeType) + while i < txt.Length do + if txt.[i] = '%' then + if i+1 = txt.Length then + Err(filename, lineNum, "(at end of string) % must be followed by d, f, s, or %") + else + match txt.[i+1] with + | 'd' -> AddHole "System.Int32" + | 'f' -> AddHole "System.Double" + | 's' -> AddHole "System.String" + | '%' -> sb.Append('%') |> ignore + | c -> Err(filename, lineNum, sprintf "'%%%c' is not a valid sequence, only %%d %%f %%s or %%%%" c) + i <- i + 2 + else + match txt.[i] with + | '{' -> sb.Append "{{" |> ignore + | '}' -> sb.Append "}}" |> ignore + | c -> sb.Append c |> ignore + i <- i + 1 + //printfn "holes.Length = %d, lineNum = %d" holes.Length //lineNum txt + (holes, sb.ToString()) + +let Unquote (s : string) = + if s.StartsWith "\"" && s.EndsWith "\"" then s.Substring(1, s.Length - 2) + else failwith "error message string should be quoted" + +let ParseLine filename lineNum (txt:string) = + let mutable errNum = None + let identB = new System.Text.StringBuilder() + let mutable i = 0 + // parse optional error number + if i < txt.Length && System.Char.IsDigit txt.[i] then + let numB = new System.Text.StringBuilder() + while i < txt.Length && System.Char.IsDigit txt.[i] do + numB.Append txt.[i] |> ignore + i <- i + 1 + errNum <- Some(int (numB.ToString())) + if i = txt.Length || not(txt.[i] = ',') then + Err(filename, lineNum, sprintf "After the error number '%d' there should be a comma" errNum.Value) + // Skip the comma + i <- i + 1 + // parse short identifier + if i < txt.Length && not(System.Char.IsLetter(txt.[i])) then + Err(filename, lineNum, sprintf "The first character in the short identifier should be a letter, but found '%c'" txt.[i]) + while i < txt.Length && System.Char.IsLetterOrDigit txt.[i] do + identB.Append txt.[i] |> ignore + i <- i + 1 + let ident = identB.ToString() + if ident.Length = 0 then + Err(filename, lineNum, "Did not find the short identifier") + else + if i = txt.Length || not(txt.[i] = ',') then + Err(filename, lineNum, sprintf "After the identifier '%s' there should be a comma" ident) + else + // Skip the comma + i <- i + 1 + if i = txt.Length then + Err(filename, lineNum, sprintf "After the identifier '%s' and comma, there should be the quoted string resource" ident) + else + let str = + try + System.String.Format(Unquote(txt.Substring i)) // Format turns e.g '\n' into that char, but also requires that we 'escape' curlies in the original .txt file, e.g. "{{" + with + e -> Err(filename, lineNum, sprintf "Error calling System.String.Format (note that curly braces must be escaped, and there cannot be trailing space on the line): >>>%s<<< -- %s" (txt.Substring i) e.Message) + let holes, netFormatString = ComputeHoles filename lineNum str + (lineNum, (errNum,ident), str, holes.ToArray(), netFormatString) + +let stringBoilerPlatePrefix = @" +open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators +open Microsoft.FSharp.Reflection +open System.Reflection +// (namespaces below for specific case of using the tool to compile FSharp.Core itself) +open Microsoft.FSharp.Core +open Microsoft.FSharp.Core.Operators +open Microsoft.FSharp.Text +open Microsoft.FSharp.Collections +open Printf +" +let StringBoilerPlate filename = + + @" + // BEGIN BOILERPLATE + + static let getCurrentAssembly () = + #if DNXCORE50 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETCOREAPP1_0 + typeof.GetTypeInfo().Assembly + #else + System.Reflection.Assembly.GetExecutingAssembly() + #endif + + static let getTypeInfo (t: System.Type) = + #if DNXCORE50 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETCOREAPP1_0 + t.GetTypeInfo() + #else + t + #endif + + static let resources = lazy (new System.Resources.ResourceManager(""" + filename + @""", getCurrentAssembly())) + + static let GetString(name:string) = + let s = resources.Value.GetString(name, System.Globalization.CultureInfo.CurrentUICulture) + #if DEBUG + if null = s then + System.Diagnostics.Debug.Assert(false, sprintf ""**RESOURCE ERROR**: Resource token %s does not exist!"" name) + #endif + s + + static let mkFunctionValue (tys: System.Type[]) (impl:obj->obj) = + FSharpValue.MakeFunction(FSharpType.MakeFunctionType(tys.[0],tys.[1]), impl) + + static let funTyC = typeof<(obj -> obj)>.GetGenericTypeDefinition() + + static let isNamedType(ty:System.Type) = not (ty.IsArray || ty.IsByRef || ty.IsPointer) + static let isFunctionType (ty1:System.Type) = + isNamedType(ty1) && getTypeInfo(ty1).IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(funTyC) + + static let rec destFunTy (ty:System.Type) = + if isFunctionType ty then + ty, ty.GetGenericArguments() + else + match getTypeInfo(ty).BaseType with + | null -> failwith ""destFunTy: not a function type"" + | b -> destFunTy b + + static let buildFunctionForOneArgPat (ty: System.Type) impl = + let _,tys = destFunTy ty + let rty = tys.[1] + // PERF: this technique is a bit slow (e.g. in simple cases, like 'sprintf ""%x""') + mkFunctionValue tys (fun inp -> impl rty inp) + + static let capture1 (fmt:string) i args ty (go : obj list -> System.Type -> int -> obj) : obj = + match fmt.[i] with + | '%' -> go args ty (i+1) + | 'd' + | 'f' + | 's' -> buildFunctionForOneArgPat ty (fun rty n -> go (n::args) rty (i+1)) + | _ -> failwith ""bad format specifier"" + + // newlines and tabs get converted to strings when read from a resource file + // this will preserve their original intention + static let postProcessString (s : string) = + s.Replace(""\\n"",""\n"").Replace(""\\t"",""\t"").Replace(""\\r"",""\r"").Replace(""\\\"""", ""\"""") + + static let createMessageString (messageString : string) (fmt : Printf.StringFormat<'T>) : 'T = + let fmt = fmt.Value // here, we use the actual error string, as opposed to the one stored as fmt + let len = fmt.Length + + /// Function to capture the arguments and then run. + let rec capture args ty i = + if i >= len || (fmt.[i] = '%' && i+1 >= len) then + let b = new System.Text.StringBuilder() + b.AppendFormat(messageString, [| for x in List.rev args -> x |]) |> ignore + box(b.ToString()) + // REVIEW: For these purposes, this should be a nop, but I'm leaving it + // in incase we ever decide to support labels for the error format string + // E.g., ""%s%d"" + elif System.Char.IsSurrogatePair(fmt,i) then + capture args ty (i+2) + else + match fmt.[i] with + | '%' -> + let i = i+1 + capture1 fmt i args ty capture + | _ -> + capture args ty (i+1) + + (unbox (capture [] (typeof<'T>) 0) : 'T) + + static let mutable swallowResourceText = false + + static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T = + if swallowResourceText then + sprintf fmt + else + let mutable messageString = GetString(messageID) + messageString <- postProcessString messageString + createMessageString messageString fmt + + /// If set to true, then all error messages will just return the filled 'holes' delimited by ',,,'s - this is for language-neutral testing (e.g. localization-invariant baselines). + static member SwallowResourceText with get () = swallowResourceText + and set (b) = swallowResourceText <- b + // END BOILERPLATE +" + +let RunMain(filename, outFilename, outXmlFilenameOpt, projectNameOpt) = + try + let justfilename = System.IO.Path.GetFileNameWithoutExtension(filename) + if justfilename |> Seq.exists (fun c -> not(System.Char.IsLetterOrDigit(c))) then + Err(filename, 0, sprintf "The filename '%s' is not allowed; only letters and digits can be used, as the filename also becomes the namespace for the SR class" justfilename) + + printfn "fssrgen.fsx: Reading %s" filename + let lines = System.IO.File.ReadAllLines(filename) + |> Array.mapi (fun i s -> i,s) // keep line numbers + |> Array.filter (fun (i,s) -> not(s.StartsWith "#")) // filter out comments + + printfn "fssrgen.fsx: Parsing %s" filename + let stringInfos = lines |> Array.map (fun (i,s) -> ParseLine filename i s) + // now we have array of (lineNum, ident, str, holes, netFormatString) // str has %d, netFormatString has {0} + + printfn "fssrgen.fsx: Validating %s" filename + // validate that all the idents are unique + let allIdents = new System.Collections.Generic.Dictionary() + for (line,(_,ident),_,_,_) in stringInfos do + if allIdents.ContainsKey(ident) then + Err(filename,line,sprintf "Identifier '%s' is already used previously on line %d - each identifier must be unique" ident allIdents.[ident]) + allIdents.Add(ident,line) + + printfn "fssrgen.fsx: Validating uniqueness of %s" filename + // validate that all the strings themselves are unique + let allStrs = new System.Collections.Generic.Dictionary() + for (line,(_,ident),str,_,_) in stringInfos do + if allStrs.ContainsKey(str) then + let prevLine,prevIdent = allStrs.[str] + Err(filename,line,sprintf "String '%s' already appears on line %d with identifier '%s' - each string must be unique" str prevLine prevIdent) + allStrs.Add(str,(line,ident)) + + printfn "fssrgen.fsx: Generating %s" outFilename + use outStream = System.IO.File.Create outFilename + use out = new System.IO.StreamWriter(outStream) + fprintfn out "// This is a generated file; the original input is '%s'" filename + fprintfn out "namespace %s" justfilename + if Option.isNone outXmlFilenameOpt then + fprintfn out "type internal SR private() =" + else + fprintfn out "%s" stringBoilerPlatePrefix + fprintfn out "type internal SR private() =" + let theResourceName = match projectNameOpt with Some p -> sprintf "%s.%s" p justfilename | None -> justfilename + fprintfn out "%s" (StringBoilerPlate theResourceName) + + printfn "fssrgen.fsx: Generating resource methods for %s" outFilename + // gen each resource method + stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + let formalArgs = new System.Text.StringBuilder() + let actualArgs = new System.Text.StringBuilder() + let firstTime = ref true + let n = ref 0 + formalArgs.Append "(" |> ignore + for hole in holes do + if !firstTime then + firstTime := false + else + formalArgs.Append ", " |> ignore + actualArgs.Append " " |> ignore + formalArgs.Append(sprintf "a%d : %s" !n hole) |> ignore + actualArgs.Append(sprintf "a%d" !n) |> ignore + n := !n + 1 + formalArgs.Append ")" |> ignore + fprintfn out " /// %s" str + fprintfn out " /// (Originally from %s:%d)" filename (lineNum+1) + let justPercentsFromFormatString = + (holes |> Array.fold (fun acc holeType -> + acc + match holeType with + | "System.Int32" -> ",,,%d" + | "System.Double" -> ",,,%f" + | "System.String" -> ",,,%s" + | _ -> failwith "unreachable") "") + ",,," + let errPrefix = match optErrNum with + | None -> "" + | Some n -> sprintf "%d, " n + if Option.isNone outXmlFilenameOpt then + fprintfn out " static member %s%s = (%ssprintf \"%s\" %s)" ident (formalArgs.ToString()) errPrefix str (actualArgs.ToString()) + else + fprintfn out " static member %s%s = (%sGetStringFunc(\"%s\",\"%s\") %s)" ident (formalArgs.ToString()) errPrefix ident justPercentsFromFormatString (actualArgs.ToString()) + ) + + if Option.isSome outXmlFilenameOpt then + printfn "fssrgen.fsx: Generating .resx for %s" outFilename + fprintfn out "" + // gen validation method + fprintfn out " /// Call this method once to validate that all known resources are valid; throws if not" + fprintfn out " static member RunStartupValidation() =" + stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + fprintfn out " ignore(GetString(\"%s\"))" ident + ) + fprintfn out " ()" // in case there are 0 strings, we need the generated code to parse + // gen to resx + let xd = new System.Xml.XmlDocument() + xd.LoadXml(xmlBoilerPlateString) + stringInfos |> Seq.iter (fun (lineNum, (optErrNum,ident), str, holes, netFormatString) -> + let xn = xd.CreateElement("data") + xn.SetAttribute("name",ident) |> ignore + xn.SetAttribute("xml:space","preserve") |> ignore + let xnc = xd.CreateElement "value" + xn.AppendChild xnc |> ignore + xnc.AppendChild(xd.CreateTextNode netFormatString) |> ignore + xd.LastChild.AppendChild xn |> ignore + ) + use outXmlStream = System.IO.File.Create outXmlFilenameOpt.Value + xd.Save outXmlStream + printfn "fssrgen.fsx: Done %s" outFilename + 0 + with e -> + PrintErr(filename, 0, sprintf "An exception occurred when processing '%s'\n%s" filename (e.ToString())) + 1 + +#if COMPILED +[] +#endif +let Main args = + + match args |> List.ofArray with + | [ inputFile; outFile; ] -> + let filename = System.IO.Path.GetFullPath(inputFile) + let outFilename = System.IO.Path.GetFullPath(outFile) + + RunMain(filename, outFilename, None, None) + + | [ inputFile; outFile; outXml ] -> + let filename = System.IO.Path.GetFullPath inputFile + let outFilename = System.IO.Path.GetFullPath outFile + let outXmlFilename = System.IO.Path.GetFullPath outXml + + RunMain(filename, outFilename, Some outXmlFilename, None) + + | [ inputFile; outFile; outXml; projectName ] -> + let filename = System.IO.Path.GetFullPath inputFile + let outFilename = System.IO.Path.GetFullPath outFile + let outXmlFilename = System.IO.Path.GetFullPath outXml + + RunMain(filename, outFilename, Some outXmlFilename, Some projectName) + + | _ -> + printfn "Error: invalid arguments." + printfn "Usage: " + 1 +#if !COMPILED +printfn "fssrgen: args = %A" fsi.CommandLineArgs +Main (fsi.CommandLineArgs |> Seq.skip 1 |> Seq.toArray) +#endif diff --git a/src/buildtools/fssrgen/fssrgen.targets b/src/buildtools/fssrgen/fssrgen.targets new file mode 100644 index 0000000000..f090cd0cd2 --- /dev/null +++ b/src/buildtools/fssrgen/fssrgen.targets @@ -0,0 +1,56 @@ + + + + + ProcessFsSrGen;$(PrepareForBuildDependsOn) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + diff --git a/samples/InteractiveService/App.config b/src/buildtools/fsyacc/App.config similarity index 71% rename from samples/InteractiveService/App.config rename to src/buildtools/fsyacc/App.config index 58f580b925..e1b09eda9f 100644 --- a/samples/InteractiveService/App.config +++ b/src/buildtools/fsyacc/App.config @@ -1,4 +1,4 @@ - + @@ -7,8 +7,8 @@ - - + + \ No newline at end of file diff --git a/src/buildtools/fsyacc/Arg.fs b/src/buildtools/fsyacc/Arg.fs new file mode 100644 index 0000000000..a1f63bd963 --- /dev/null +++ b/src/buildtools/fsyacc/Arg.fs @@ -0,0 +1,133 @@ +// (c) Microsoft Corporation 2005-2009. + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities +#else +namespace Microsoft.FSharp.Text +#endif + + +type ArgType = + | ClearArg of bool ref + | FloatArg of (float -> unit) + | IntArg of (int -> unit) + | RestArg of (string -> unit) + | SetArg of bool ref + | StringArg of (string -> unit) + | UnitArg of (unit -> unit) + static member Clear r = ClearArg r + static member Float r = FloatArg r + static member Int r = IntArg r + static member Rest r = RestArg r + static member Set r = SetArg r + static member String r = StringArg r + static member Unit r = UnitArg r + + +type ArgInfo (name,action,help) = + member x.Name = name + member x.ArgType = action + member x.HelpText = help + +exception Bad of string +exception HelpText of string + +[] +type ArgParser() = + static let getUsage specs u = + let sbuf = new System.Text.StringBuilder 100 + let pstring (s:string) = sbuf.Append s |> ignore + let pendline s = pstring s; pstring "\n" + pendline u; + List.iter (fun (arg:ArgInfo) -> + match arg.Name, arg.ArgType, arg.HelpText with + | (s, (UnitArg _ | SetArg _ | ClearArg _), helpText) -> pstring "\t"; pstring s; pstring ": "; pendline helpText + | (s, StringArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, IntArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, FloatArg _, helpText) -> pstring "\t"; pstring s; pstring " : "; pendline helpText + | (s, RestArg _, helpText) -> pstring "\t"; pstring s; pstring " ...: "; pendline helpText) + specs; + pstring "\t"; pstring "--help"; pstring ": "; pendline "display this list of options"; + pstring "\t"; pstring "-help"; pstring ": "; pendline "display this list of options"; + sbuf.ToString() + + + static member ParsePartial(cursor,argv,argSpecs:seq,?other,?usageText) = + let other = defaultArg other (fun _ -> ()) + let usageText = defaultArg usageText "" + let nargs = Array.length argv + incr cursor; + let argSpecs = argSpecs |> Seq.toList + let specs = argSpecs |> List.map (fun (arg:ArgInfo) -> arg.Name, arg.ArgType) + while !cursor < nargs do + let arg = argv.[!cursor] + let rec findMatchingArg args = + match args with + | ((s, action) :: _) when s = arg -> + let getSecondArg () = + if !cursor + 1 >= nargs then + raise(Bad("option "+s+" needs an argument.\n"+getUsage argSpecs usageText)); + argv.[!cursor+1] + + match action with + | UnitArg f -> + f (); + incr cursor + | SetArg f -> + f := true; + incr cursor + | ClearArg f -> + f := false; + incr cursor + | StringArg f-> + let arg2 = getSecondArg() + f arg2; + cursor := !cursor + 2 + | IntArg f -> + let arg2 = getSecondArg () + let arg2 = try int32 arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in + f arg2; + cursor := !cursor + 2; + | FloatArg f -> + let arg2 = getSecondArg() + let arg2 = try float arg2 with _ -> raise(Bad(getUsage argSpecs usageText)) in + f arg2; + cursor := !cursor + 2; + | RestArg f -> + incr cursor; + while !cursor < nargs do + f (argv.[!cursor]); + incr cursor; + + | (_ :: more) -> findMatchingArg more + | [] -> + if arg = "-help" || arg = "--help" || arg = "/help" || arg = "/help" || arg = "/?" then + raise (HelpText (getUsage argSpecs usageText)) + // Note: for '/abc/def' does not count as an argument + // Note: '/abc' does + elif arg.Length>0 && (arg.[0] = '-' || (arg.[0] = '/' && not (arg.Length > 1 && arg.[1..].Contains ("/")))) then + raise (Bad ("unrecognized argument: "+ arg + "\n" + getUsage argSpecs usageText)) + else + other arg; + incr cursor + findMatchingArg specs + + static member Usage (specs,?usage) = + let usage = defaultArg usage "" + System.Console.Error.WriteLine (getUsage (Seq.toList specs) usage) + + #if FX_NO_COMMAND_LINE_ARGS + #else + static member Parse (specs,?other,?usageText) = + let current = ref 0 + let argv = System.Environment.GetCommandLineArgs() + try ArgParser.ParsePartial (current, argv, specs, ?other=other, ?usageText=usageText) + with + | Bad h + | HelpText h -> + System.Console.Error.WriteLine h; + System.Console.Error.Flush(); + System.Environment.Exit(1); + | e -> + reraise() + #endif diff --git a/src/buildtools/fsyacc/Arg.fsi b/src/buildtools/fsyacc/Arg.fsi new file mode 100644 index 0000000000..367f69f959 --- /dev/null +++ b/src/buildtools/fsyacc/Arg.fsi @@ -0,0 +1,50 @@ +// (c) Microsoft Corporation 2005-2009. + +/// A simple command-line argument processor. +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities +#else +namespace Microsoft.FSharp.Text +#endif + +/// The spec value describes the action of the argument, +/// and whether it expects a following parameter. +[] +type ArgType = + static member Clear : bool ref -> ArgType + static member Float : (float -> unit) -> ArgType + static member Int : (int -> unit) -> ArgType + static member Rest : (string -> unit) -> ArgType + static member Set : bool ref -> ArgType + static member String : (string -> unit) -> ArgType + static member Unit : (unit -> unit) -> ArgType + +type ArgInfo = + new : name:string * action:ArgType * help:string -> ArgInfo + /// Return the name of the argument + member Name : string + /// Return the argument type and action of the argument + member ArgType : ArgType + /// Return the usage help associated with the argument + member HelpText : string + +[] +type ArgParser = + #if FX_NO_COMMAND_LINE_ARGS + #else + + /// Parse some of the arguments given by 'argv', starting at the given position + [] + static member ParsePartial: cursor: int ref * argv: string[] * arguments:seq * ?otherArgs: (string -> unit) * ?usageText:string -> unit + + /// Parse the arguments given by System.Environment.GetEnvironmentVariables() + /// according to the argument processing specifications "specs". + /// Args begin with "-". Non-arguments are passed to "f" in + /// order. "use" is printed as part of the usage line if an error occurs. + + static member Parse: arguments:seq * ?otherArgs: (string -> unit) * ?usageText:string -> unit + #endif + + /// Prints the help for each argument. + static member Usage : arguments:seq * ?usage:string -> unit + diff --git a/src/buildtools/fsyacc/Lexing.fs b/src/buildtools/fsyacc/Lexing.fs new file mode 100644 index 0000000000..8337717d6f --- /dev/null +++ b/src/buildtools/fsyacc/Lexing.fs @@ -0,0 +1,423 @@ +// (c) Microsoft Corporation 2005-2009. + +#nowarn "47" // recursive initialization of LexBuffer + + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Lexing + +#else +namespace Microsoft.FSharp.Text.Lexing +#endif + + open System.Collections.Generic + + // REVIEW: This type showed up on a parsing-intensive performance measurement. Consider whether it can be a struct-record later when we have this feature. -jomo +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal Position = +#else + type Position = +#endif + { pos_fname : string; + pos_lnum : int; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum : int; +#endif + pos_bol : int; + pos_cnum : int; } + member x.FileName = x.pos_fname + member x.Line = x.pos_lnum +#if INTERNALIZED_FSLEXYACC_RUNTIME + member x.OriginalLine = x.pos_orig_lnum +#endif + member x.Char = x.pos_cnum + member x.AbsoluteOffset = x.pos_cnum + member x.StartOfLine = x.pos_bol + member x.StartOfLineAbsoluteOffset = x.pos_bol + member x.Column = x.pos_cnum - x.pos_bol + member pos.NextLine = + { pos with +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = pos.OriginalLine + 1; +#endif + pos_lnum = pos.Line+1; + pos_bol = pos.AbsoluteOffset } + member pos.EndOfToken(n) = {pos with pos_cnum=pos.pos_cnum + n } + member pos.AsNewLinePos() = pos.NextLine + member pos.ShiftColumnBy(by) = {pos with pos_cnum = pos.pos_cnum + by} + static member Empty = + { pos_fname=""; + pos_lnum= 0; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = 0; +#endif + pos_bol= 0; + pos_cnum=0 } + static member FirstLine(filename) = + { pos_fname=filename; +#if INTERNALIZED_FSLEXYACC_RUNTIME + pos_orig_lnum = 1; +#endif + pos_lnum= 1; + pos_bol= 0; + pos_cnum=0 } + +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal LexBufferFiller<'char> = +#else + type LexBufferFiller<'char> = +#endif + { fillSync : (LexBuffer<'char> -> unit) option + fillAsync : (LexBuffer<'char> -> Async) option } + + and [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + internal LexBuffer<'char>(filler: LexBufferFiller<'char>) as this = +#else + LexBuffer<'char>(filler: LexBufferFiller<'char>) as this = +#endif + let context = new Dictionary(1) in + let extendBufferSync = (fun () -> match filler.fillSync with Some refill -> refill this | None -> invalidOp "attempt to read synchronously from an asynchronous lex buffer") + let extendBufferAsync = (fun () -> match filler.fillAsync with Some refill -> refill this | None -> invalidOp "attempt to read asynchronously from a synchronous lex buffer") + let mutable buffer=[||]; + /// number of valid charactes beyond bufferScanStart + let mutable bufferMaxScanLength=0; + /// count into the buffer when scanning + let mutable bufferScanStart=0; + /// number of characters scanned so far + let mutable bufferScanLength=0; + /// length of the scan at the last accepting state + let mutable lexemeLength=0; + /// action related to the last accepting state + let mutable bufferAcceptAction=0; + let mutable eof = false; + let mutable startPos = Position.Empty ; + let mutable endPos = Position.Empty + + // Throw away all the input besides the lexeme + + let discardInput () = + let keep = Array.sub buffer bufferScanStart bufferScanLength + let nkeep = keep.Length + Array.blit keep 0 buffer 0 nkeep; + bufferScanStart <- 0; + bufferMaxScanLength <- nkeep + + + member lexbuf.EndOfScan () : int = + // Printf.eprintf "endOfScan, lexBuffer.lexemeLength = %d\n" lexBuffer.lexemeLength; + if bufferAcceptAction < 0 then + failwith "unrecognized input" + + // Printf.printf "endOfScan %d state %d on unconsumed input '%c' (%d)\n" a s (Char.chr inp) inp; + // Printf.eprintf "accept, lexeme = %s\n" (lexeme lexBuffer); + lexbuf.StartPos <- endPos; + lexbuf.EndPos <- endPos.EndOfToken(lexbuf.LexemeLength); + bufferAcceptAction + + member lexbuf.StartPos + with get() = startPos + and set(b) = startPos <- b + + member lexbuf.EndPos + with get() = endPos + and set(b) = endPos <- b + + member lexbuf.Lexeme = Array.sub buffer bufferScanStart lexemeLength + member lexbuf.LexemeChar(n) = buffer.[n+bufferScanStart] + + member lexbuf.BufferLocalStore = (context :> IDictionary<_,_>) + member lexbuf.LexemeLength with get() : int = lexemeLength and set v = lexemeLength <- v + member internal lexbuf.Buffer with get() : 'char[] = buffer and set v = buffer <- v + member internal lexbuf.BufferMaxScanLength with get() = bufferMaxScanLength and set v = bufferMaxScanLength <- v + member internal lexbuf.BufferScanLength with get() = bufferScanLength and set v = bufferScanLength <- v + member internal lexbuf.BufferScanStart with get() : int = bufferScanStart and set v = bufferScanStart <- v + member internal lexbuf.BufferAcceptAction with get() = bufferAcceptAction and set v = bufferAcceptAction <- v + member internal lexbuf.RefillBuffer = extendBufferSync + member internal lexbuf.AsyncRefillBuffer = extendBufferAsync + + static member LexemeString(lexbuf:LexBuffer) = + new System.String(lexbuf.Buffer,lexbuf.BufferScanStart,lexbuf.LexemeLength) + + member lexbuf.IsPastEndOfStream + with get() = eof + and set(b) = eof <- b + + member lexbuf.DiscardInput() = discardInput () + + member x.BufferScanPos = bufferScanStart + bufferScanLength + + member lexbuf.EnsureBufferSize n = + if lexbuf.BufferScanPos + n >= buffer.Length then + let repl = Array.zeroCreate (lexbuf.BufferScanPos + n) + Array.blit buffer bufferScanStart repl bufferScanStart bufferScanLength; + buffer <- repl + + static member FromReadFunctions (syncRead : ('char[] * int * int -> int) option, asyncRead : ('char[] * int * int -> Async) option) : LexBuffer<'char> = + let extension= Array.zeroCreate 4096 + let fillers = + { fillSync = + match syncRead with + | None -> None + | Some read -> + Some (fun lexBuffer -> + let n = read(extension,0,extension.Length) + lexBuffer.EnsureBufferSize n; + Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n); + fillAsync = + match asyncRead with + | None -> None + | Some read -> + Some (fun lexBuffer -> + async { + let! n = read(extension,0,extension.Length) + lexBuffer.EnsureBufferSize n; + Array.blit extension 0 lexBuffer.Buffer lexBuffer.BufferScanPos n; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferScanLength + n }) } + new LexBuffer<_>(fillers) + + // A full type signature is required on this method because it is used at more specific types within its own scope + static member FromFunction (f : 'char[] * int * int -> int) : LexBuffer<'char> = LexBuffer<_>.FromReadFunctions(Some(f),None) + static member FromAsyncFunction (f : 'char[] * int * int -> Async) : LexBuffer<'char> = LexBuffer<_>.FromReadFunctions(None,Some(f)) + + static member FromCharFunction f : LexBuffer = + LexBuffer.FromFunction(fun (buff,start,len) -> + let buff2 = Array.zeroCreate len + let n = f buff2 len + Array.blit buff2 0 buff start len + n) + static member FromByteFunction f : LexBuffer = + LexBuffer.FromFunction(fun (buff,start,len) -> + let buff2 = Array.zeroCreate len + let n = f buff2 len + Array.blit buff2 0 buff start len + n) + + // A full type signature is required on this method because it is used at more specific types within its own scope + static member FromArray (s: 'char[]) : LexBuffer<'char> = + let lexBuffer = + new LexBuffer<_> + { fillSync = Some (fun _ -> ()); + fillAsync = Some (fun _ -> async { return () }) } + let buffer = Array.copy s + lexBuffer.Buffer <- buffer; + lexBuffer.BufferMaxScanLength <- buffer.Length; + lexBuffer + + static member FromBytes (arr) = LexBuffer.FromArray(arr) + static member FromChars (arr) = LexBuffer.FromArray(arr) + static member FromString (s:string) = LexBuffer.FromChars (s.ToCharArray()) + + static member FromTextReader (tr:System.IO.TextReader) : LexBuffer = + LexBuffer.FromFunction(tr.Read) + + static member FromBinaryReader (br:System.IO.BinaryReader) : LexBuffer = + LexBuffer.FromFunction(br.Read) + + static member FromStream (stream:System.IO.Stream) : LexBuffer = + LexBuffer.FromReadFunctions(Some(stream.Read),Some(fun (buf,offset,len) -> stream.AsyncRead(buf,offset=offset,count=len))) + + module GenericImplFragments = + let startInterpret(lexBuffer:LexBuffer<_>)= + lexBuffer.BufferScanStart <- lexBuffer.BufferScanStart + lexBuffer.LexemeLength; + lexBuffer.BufferMaxScanLength <- lexBuffer.BufferMaxScanLength - lexBuffer.LexemeLength; + lexBuffer.BufferScanLength <- 0; + lexBuffer.LexemeLength <- 0; + lexBuffer.BufferAcceptAction <- -1; + + let afterRefill (trans: uint16[] array,sentinel,lexBuffer:LexBuffer<_>,scanUntilSentinel,endOfScan,state,eofPos) = + // end of file occurs if we couldn't extend the buffer + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + let snew = int trans.[state].[eofPos] // == EOF + if snew = sentinel then + endOfScan() + else + if lexBuffer.IsPastEndOfStream then failwith "End of file on lexing stream"; + lexBuffer.IsPastEndOfStream <- true; + // Printf.printf "state %d --> %d on eof\n" state snew; + scanUntilSentinel(lexBuffer,snew) + else + scanUntilSentinel(lexBuffer, state) + + let onAccept (lexBuffer:LexBuffer<_>,a) = + lexBuffer.LexemeLength <- lexBuffer.BufferScanLength; + lexBuffer.BufferAcceptAction <- a; + + open GenericImplFragments + + [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal AsciiTables(trans: uint16[] array, accept: uint16[]) = +#else + type AsciiTables(trans: uint16[] array, accept: uint16[]) = +#endif + let rec scanUntilSentinel(lexBuffer, state) = + let sentinel = 255 * 256 + 255 + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept (lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,lexBuffer.EndOfScan,state,256 (* == EOF *) ) + else + // read a character - end the scan if there are no further transitions + let inp = int(lexBuffer.Buffer.[lexBuffer.BufferScanPos]) + let snew = int trans.[state].[inp] + if snew = sentinel then + lexBuffer.EndOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + // Printf.printf "state %d --> %d on '%c' (%d)\n" state snew (Char.chr inp) inp; + scanUntilSentinel(lexBuffer, snew) + + /// Interpret tables for an ascii lexer generated by fslex. + member tables.Interpret(initialState,lexBuffer : LexBuffer) = + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + /// Interpret tables for an ascii lexer generated by fslex. + member tables.AsyncInterpret(initialState,lexBuffer : LexBuffer) = + + let rec scanUntilSentinel(lexBuffer,state) : Async = + async { + let sentinel = 255 * 256 + 255 + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept (lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + do! lexBuffer.AsyncRefillBuffer (); + // end of file occurs if we couldn't extend the buffer + return! afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,endOfScan,state,256 (* == EOF *) ) + else + // read a character - end the scan if there are no further transitions + let inp = int(lexBuffer.Buffer.[lexBuffer.BufferScanPos]) + let snew = int trans.[state].[inp] + if snew = sentinel then + return! endOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + return! scanUntilSentinel(lexBuffer,snew) + } + and endOfScan() = + async { return lexBuffer.EndOfScan() } + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + + static member Create(trans,accept) = new AsciiTables(trans,accept) + + [] +#if INTERNALIZED_FSLEXYACC_RUNTIME + type internal UnicodeTables(trans: uint16[] array, accept: uint16[]) = +#else + type UnicodeTables(trans: uint16[] array, accept: uint16[]) = +#endif + let sentinel = 255 * 256 + 255 + let numUnicodeCategories = 30 + let numLowUnicodeChars = 128 + let numSpecificUnicodeChars = (trans.[0].Length - 1 - numLowUnicodeChars - numUnicodeCategories)/2 + let lookupUnicodeCharacters (state,inp) = + let inpAsInt = int inp + // Is it a fast ASCII character? + if inpAsInt < numLowUnicodeChars then + int trans.[state].[inpAsInt] + else + // Search for a specific unicode character + let baseForSpecificUnicodeChars = numLowUnicodeChars + let rec loop i = + if i >= numSpecificUnicodeChars then + // OK, if we failed then read the 'others' entry in the alphabet, + // which covers all Unicode characters not covered in other + // ways + let baseForUnicodeCategories = numLowUnicodeChars+numSpecificUnicodeChars*2 + let unicodeCategory = System.Globalization.CharUnicodeInfo.GetUnicodeCategory(inp) + //System.Console.WriteLine("inp = {0}, unicodeCategory = {1}", [| box inp; box unicodeCategory |]); + int trans.[state].[baseForUnicodeCategories + int32 unicodeCategory] + else + // This is the specific unicode character + let c = char (int trans.[state].[baseForSpecificUnicodeChars+i*2]) + //System.Console.WriteLine("c = {0}, inp = {1}, i = {2}", [| box c; box inp; box i |]); + // OK, have we found the entry for a specific unicode character? + if c = inp + then int trans.[state].[baseForSpecificUnicodeChars+i*2+1] + else loop(i+1) + + loop 0 + let eofPos = numLowUnicodeChars + 2*numSpecificUnicodeChars + numUnicodeCategories + + let rec scanUntilSentinel(lexBuffer,state) = + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept(lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,lexBuffer.EndOfScan,state,eofPos) + else + // read a character - end the scan if there are no further transitions + let inp = lexBuffer.Buffer.[lexBuffer.BufferScanPos] + + // Find the new state + let snew = lookupUnicodeCharacters (state,inp) + + if snew = sentinel then + lexBuffer.EndOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + // Printf.printf "state %d --> %d on '%c' (%d)\n" s snew (char inp) inp; + scanUntilSentinel(lexBuffer,snew) + + // Each row for the Unicode table has format + // 128 entries for ASCII characters + // A variable number of 2*UInt16 entries for SpecificUnicodeChars + // 30 entries, one for each UnicodeCategory + // 1 entry for EOF + + member tables.Interpret(initialState,lexBuffer : LexBuffer) = + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + member tables.AsyncInterpret(initialState,lexBuffer : LexBuffer) = + + let rec scanUntilSentinel(lexBuffer, state) = + async { + // Return an endOfScan after consuming the input + let a = int accept.[state] + if a <> sentinel then + onAccept(lexBuffer,a) + + if lexBuffer.BufferScanLength = lexBuffer.BufferMaxScanLength then + lexBuffer.DiscardInput(); + lexBuffer.RefillBuffer (); + // end of file occurs if we couldn't extend the buffer + return! afterRefill (trans,sentinel,lexBuffer,scanUntilSentinel,endOfScan,state,eofPos) + else + // read a character - end the scan if there are no further transitions + let inp = lexBuffer.Buffer.[lexBuffer.BufferScanPos] + + // Find the new state + let snew = lookupUnicodeCharacters (state,inp) + + if snew = sentinel then + return! endOfScan() + else + lexBuffer.BufferScanLength <- lexBuffer.BufferScanLength + 1; + return! scanUntilSentinel(lexBuffer, snew) + } + and endOfScan() = + async { return lexBuffer.EndOfScan() } + startInterpret(lexBuffer) + scanUntilSentinel(lexBuffer, initialState) + + static member Create(trans,accept) = new UnicodeTables(trans,accept) diff --git a/src/buildtools/fsyacc/Lexing.fsi b/src/buildtools/fsyacc/Lexing.fsi new file mode 100644 index 0000000000..e31ad411aa --- /dev/null +++ b/src/buildtools/fsyacc/Lexing.fsi @@ -0,0 +1,151 @@ +//========================================================================== +// LexBuffers are for use with automatically generated lexical analyzers, +// in particular those produced by 'fslex'. +// +// (c) Microsoft Corporation 2005-2008. +//=========================================================================== + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Lexing +#else +namespace Microsoft.FSharp.Text.Lexing +#endif + +open System.Collections.Generic + +/// Position information stored for lexing tokens +// +// Note: this is an OCaml compat record type. +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Position = +#else +type Position = +#endif + { /// The file name for the position + pos_fname: string; + /// The line number for the position + pos_lnum: int; +#if INTERNALIZED_FSLEXYACC_RUNTIME + /// The line number for the position in the original source file + pos_orig_lnum : int; +#endif + /// The absolute offset of the beginning of the line + pos_bol: int; + /// The absolute offset of the column for the position + pos_cnum: int; } + /// The file name associated with the input stream. + member FileName : string + /// The line number in the input stream, assuming fresh positions have been updated + /// using AsNewLinePos() and by modifying the EndPos property of the LexBuffer. + member Line : int +#if INTERNALIZED_FSLEXYACC_RUNTIME + /// The line number for the position in the input stream, assuming fresh positions have been updated + /// using AsNewLinePos() + member OriginalLine : int +#endif + [] + member Char : int + /// The character number in the input stream + member AbsoluteOffset : int + /// Return absolute offset of the start of the line marked by the position + member StartOfLineAbsoluteOffset : int + /// Return the column number marked by the position, i.e. the difference between the AbsoluteOffset and the StartOfLineAbsoluteOffset + member Column : int + // Given a position just beyond the end of a line, return a position at the start of the next line + member NextLine : Position + + /// Given a position at the start of a token of length n, return a position just beyond the end of the token + member EndOfToken: n:int -> Position + /// Gives a position shifted by specified number of characters + member ShiftColumnBy: by:int -> Position + + [] + member AsNewLinePos : unit -> Position + + /// Get an arbitrary position, with the empty string as filename, and + static member Empty : Position + + /// Get a position corresponding to the first line (line number 1) in a given file + static member FirstLine : filename:string -> Position + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal LexBuffer<'char> = +#else +/// Input buffers consumed by lexers generated by fslex.exe +type LexBuffer<'char> = +#endif + /// The start position for the lexeme + member StartPos: Position with get,set + /// The end position for the lexeme + member EndPos: Position with get,set + /// The matched string + member Lexeme: 'char array + + /// Fast helper to turn the matched characters into a string, avoiding an intermediate array + static member LexemeString : LexBuffer -> string + + /// The length of the matched string + member LexemeLength: int + /// Fetch a particular character in the matched string + member LexemeChar: int -> 'char + + /// Dynamically typed, non-lexically scoped parameter table + member BufferLocalStore : IDictionary + + /// True if the refill of the buffer ever failed , or if explicitly set to true. + member IsPastEndOfStream: bool with get,set + /// Remove all input, though don't discard the current lexeme + member DiscardInput: unit -> unit + + /// Create a lex buffer suitable for byte lexing that reads characters from the given array + static member FromBytes: byte[] -> LexBuffer + /// Create a lex buffer suitable for Unicode lexing that reads characters from the given array + static member FromChars: char[] -> LexBuffer + /// Create a lex buffer suitable for Unicode lexing that reads characters from the given string + static member FromString: string -> LexBuffer + /// Create a lex buffer that reads character or byte inputs by using the given function + static member FromFunction: ('char[] * int * int -> int) -> LexBuffer<'char> + /// Create a lex buffer that asynchronously reads character or byte inputs by using the given function + static member FromAsyncFunction: ('char[] * int * int -> Async) -> LexBuffer<'char> + + + [.FromFunction instead")>] + static member FromCharFunction: (char[] -> int -> int) -> LexBuffer + [.FromFunction instead")>] + static member FromByteFunction: (byte[] -> int -> int) -> LexBuffer + + /// Create a lex buffer suitable for use with a Unicode lexer that reads character inputs from the given text reader + static member FromTextReader: System.IO.TextReader -> LexBuffer + /// Create a lex buffer suitable for use with ASCII byte lexing that reads byte inputs from the given binary reader + static member FromBinaryReader: System.IO.BinaryReader -> LexBuffer + + +/// The type of tables for an ascii lexer generated by fslex. +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal AsciiTables = +#else +type AsciiTables = +#endif + static member Create : uint16[] array * uint16[] -> AsciiTables + /// Interpret tables for an ascii lexer generated by fslex. + member Interpret: initialState:int * LexBuffer -> int + /// Interpret tables for an ascii lexer generated by fslex, processing input asynchronously + member AsyncInterpret: initialState:int * LexBuffer -> Async + + +/// The type of tables for an unicode lexer generated by fslex. +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal UnicodeTables = +#else +type UnicodeTables = +#endif + static member Create : uint16[] array * uint16[] -> UnicodeTables + /// Interpret tables for a unicode lexer generated by fslex. + member Interpret: initialState:int * LexBuffer -> int + + /// Interpret tables for a unicode lexer generated by fslex, processing input asynchronously + member AsyncInterpret: initialState:int * LexBuffer -> Async + diff --git a/src/buildtools/fsyacc/Parsing.fs b/src/buildtools/fsyacc/Parsing.fs new file mode 100644 index 0000000000..01dccfb610 --- /dev/null +++ b/src/buildtools/fsyacc/Parsing.fs @@ -0,0 +1,514 @@ +// (c) Microsoft Corporation 2005-2009. + +#if INTERNALIZED_FSLEXYACC_RUNTIME + +namespace Internal.Utilities.Text.Parsing +open Internal.Utilities +open Internal.Utilities.Text.Lexing + +#else +namespace Microsoft.FSharp.Text.Parsing +open Microsoft.FSharp.Text.Lexing +#endif + + + +open System +open System.Collections.Generic + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal IParseState = +#else +type IParseState = +#endif + abstract InputRange: int -> Position * Position + abstract InputEndPosition: int -> Position + abstract InputStartPosition: int -> Position + abstract ResultRange: Position * Position + abstract GetInput: int -> obj + abstract ParserLocalStore : IDictionary + abstract RaiseError<'b> : unit -> 'b + +//------------------------------------------------------------------------- +// This context is passed to the error reporter when a syntax error occurs + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal ParseErrorContext<'tok> +#else +type ParseErrorContext<'tok> +#endif + (//lexbuf: LexBuffer<_>, + stateStack:int list, + parseState: IParseState, + reduceTokens: int list, + currentToken: 'tok option, + reducibleProductions: int list list, + shiftableTokens: int list , + message : string) = + //member x.LexBuffer = lexbuf + member x.StateStack = stateStack + member x.ReduceTokens = reduceTokens + member x.CurrentToken = currentToken + member x.ParseState = parseState + member x.ReducibleProductions = reducibleProductions + member x.ShiftTokens = shiftableTokens + member x.Message = message + + +//------------------------------------------------------------------------- +// This is the data structure emitted as code by FSYACC. + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> = +#else +type Tables<'tok> = +#endif + { reductions: (IParseState -> obj) array; + endOfInputTag: int; + tagOfToken: 'tok -> int; + dataOfToken: 'tok -> obj; + actionTableElements: uint16[]; + actionTableRowOffsets: uint16[]; + reductionSymbolCounts: uint16[]; + immediateActions: uint16[]; + gotos: uint16[]; + sparseGotoTableRowOffsets: uint16[]; + stateToProdIdxsTableElements: uint16[]; + stateToProdIdxsTableRowOffsets: uint16[]; + productionToNonTerminalTable: uint16[]; + /// For fsyacc.exe, this entry is filled in by context from the generated parser file. If no 'parse_error' function + /// is defined by the user then ParseHelpers.parse_error is used by default (ParseHelpers is opened + /// at the top of the generated parser file) + parseError: ParseErrorContext<'tok> -> unit; + numTerminals: int; + tagOfErrorTerminal: int } + +//------------------------------------------------------------------------- +// An implementation of stacks. + +// This type is in System.dll so for the moment we can't use it in FSharp.Core.dll +//type Stack<'a> = System.Collections.Generic.Stack<'a> + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type Stack<'a>(n) = +#else +type internal Stack<'a>(n) = +#endif + let mutable contents = Array.zeroCreate<'a>(n) + let mutable count = 0 + + member buf.Ensure newSize = + let oldSize = Array.length contents + if newSize > oldSize then + let old = contents + contents <- Array.zeroCreate (max newSize (oldSize * 2)); + Array.blit old 0 contents 0 count; + + member buf.Count = count + member buf.Pop() = count <- count - 1 + member buf.Peep() = contents.[count - 1] + member buf.Top(n) = [ for x in contents.[max 0 (count-n)..count - 1] -> x ] |> List.rev + member buf.Push(x) = + buf.Ensure(count + 1); + contents.[count] <- x; + count <- count + 1 + + member buf.IsEmpty = (count = 0) +#if __DEBUG + member buf.PrintStack() = + for i = 0 to (count - 1) do +#if FX_NO_CONSOLE + () +#else + System.Console.Write("{0}{1}",(contents.[i]),if i=count-1 then ":" else "-") +#endif +#endif +exception RecoverableParseError +exception Accept of obj + +#if __DEBUG +module Flags = + let mutable debug = false +#endif + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal Implementation = +#else +module Implementation = +#endif + + // Definitions shared with fsyacc + let anyMarker = 0xffff + let shiftFlag = 0x0000 + let reduceFlag = 0x4000 + let errorFlag = 0x8000 + let acceptFlag = 0xc000 + let actionMask = 0xc000 + + let actionValue action = action &&& (~~~ actionMask) + let actionKind action = action &&& actionMask + + //------------------------------------------------------------------------- + // Read the tables written by FSYACC. + + type AssocTable(elemTab:uint16[], offsetTab:uint16[]) = + let cache = new Dictionary<_,_>(2000) + + member t.readAssoc (minElemNum,maxElemNum,defaultValueOfAssoc,keyToFind) = + // do a binary chop on the table + let elemNumber : int = (minElemNum+maxElemNum)/2 + if elemNumber = maxElemNum + then defaultValueOfAssoc + else + let x = int elemTab.[elemNumber*2] + if keyToFind = x then + int elemTab.[elemNumber*2+1] + elif keyToFind < x then t.readAssoc (minElemNum ,elemNumber,defaultValueOfAssoc,keyToFind) + else t.readAssoc (elemNumber+1,maxElemNum,defaultValueOfAssoc,keyToFind) + + member t.Read(rowNumber ,keyToFind) = + + // First check the sparse lookaside table + // Performance note: without this lookaside table the binary chop in readAssoc + // takes up around 10% of of parsing time + // for parsing intensive samples such as the bootstrapped F# compiler. + // + // Note: using a .NET Dictionary for this int -> int table looks like it could be sub-optimal. + // Some other better sparse lookup table may be better. + let mutable res = 0 + let cacheKey = (rowNumber <<< 16) ||| keyToFind + let ok = cache.TryGetValue(cacheKey, &res) + if ok then res + else + let headOfTable = int offsetTab.[rowNumber] + let firstElemNumber = headOfTable + 1 + let numberOfElementsInAssoc = int elemTab.[headOfTable*2] + let defaultValueOfAssoc = int elemTab.[headOfTable*2+1] + let res = t.readAssoc (firstElemNumber,(firstElemNumber+numberOfElementsInAssoc),defaultValueOfAssoc,keyToFind) + cache.[cacheKey] <- res + res + + // Read all entries in the association table + // Used during error recovery to find all valid entries in the table + member x.ReadAll(n) = + let headOfTable = int offsetTab.[n] + let firstElemNumber = headOfTable + 1 + let numberOfElementsInAssoc = int32 elemTab.[headOfTable*2] + let defaultValueOfAssoc = int elemTab.[headOfTable*2+1] + [ for i in firstElemNumber .. (firstElemNumber+numberOfElementsInAssoc-1) -> + (int elemTab.[i*2], int elemTab.[i*2+1]) ], defaultValueOfAssoc + + type IdxToIdxListTable(elemTab:uint16[], offsetTab:uint16[]) = + + // Read all entries in a row of the table + member x.ReadAll(n) = + let headOfTable = int offsetTab.[n] + let firstElemNumber = headOfTable + 1 + let numberOfElements = int32 elemTab.[headOfTable] + [ for i in firstElemNumber .. (firstElemNumber+numberOfElements-1) -> int elemTab.[i] ] + + //------------------------------------------------------------------------- + // interpret the tables emitted by FSYACC. + + [] + [] + type ValueInfo = + val value: obj + val startPos: Position + val endPos: Position + new(value,startPos,endPos) = { value=value; startPos=startPos;endPos=endPos } + + let interpret (tables: Tables<'tok>) lexer (lexbuf : LexBuffer<_>) initialState = + let localStore = new Dictionary() in + localStore.["LexBuffer"] <- lexbuf; +#if __DEBUG + if Flags.debug then System.Console.WriteLine("\nParser: interpret tables"); +#endif + let stateStack : Stack = new Stack<_>(100) + stateStack.Push(initialState); + let valueStack = new Stack(100) + let mutable haveLookahead = false + let mutable lookaheadToken = Unchecked.defaultof<'tok> + let mutable lookaheadEndPos = Unchecked.defaultof + let mutable lookaheadStartPos = Unchecked.defaultof + let mutable finished = false + // After an error occurs, we suppress errors until we've shifted three tokens in a row. + let mutable errorSuppressionCountDown = 0 + + // When we hit the end-of-file we don't fail straight away but rather keep permitting shift + // and reduce against the last token in the token stream 20 times or until we've accepted + // or exhausted the stack. This allows error recovery rules of the form + // input : realInput EOF | realInput error EOF | error EOF + // where consuming one EOF to trigger an error doesn't result in overall parse failure + // catastrophe and the loss of intermediate results. + // + let mutable inEofCountDown = false + let mutable eofCountDown = 20 // Number of EOFs to supply at the end for error recovery + // The 100 here means a maximum of 100 elements for each rule + let ruleStartPoss = (Array.zeroCreate 100 : Position array) + let ruleEndPoss = (Array.zeroCreate 100 : Position array) + let ruleValues = (Array.zeroCreate 100 : obj array) + let lhsPos = (Array.zeroCreate 2 : Position array) + let reductions = tables.reductions + let actionTable = new AssocTable(tables.actionTableElements, tables.actionTableRowOffsets) + let gotoTable = new AssocTable(tables.gotos, tables.sparseGotoTableRowOffsets) + let stateToProdIdxsTable = new IdxToIdxListTable(tables.stateToProdIdxsTableElements, tables.stateToProdIdxsTableRowOffsets) + + let parseState = + { new IParseState with + member p.InputRange(n) = ruleStartPoss.[n-1], ruleEndPoss.[n-1]; + member p.InputStartPosition(n) = ruleStartPoss.[n-1] + member p.InputEndPosition(n) = ruleEndPoss.[n-1]; + member p.GetInput(n) = ruleValues.[n-1]; + member p.ResultRange = (lhsPos.[0], lhsPos.[1]); + member p.ParserLocalStore = (localStore :> IDictionary<_,_>); + member p.RaiseError() = raise RecoverableParseError (* NOTE: this binding tests the fairly complex logic associated with an object expression implementing a generic abstract method *) + } + +#if __DEBUG + let report haveLookahead lookaheadToken = + if haveLookahead then sprintf "%A" lookaheadToken + else "[TBC]" +#endif + + // Pop the stack until we can shift the 'error' token. If 'tokenOpt' is given + // then keep popping until we can shift both the 'error' token and the token in 'tokenOpt'. + // This is used at end-of-file to make sure we can shift both the 'error' token and the 'EOF' token. + let rec popStackUntilErrorShifted(tokenOpt) = + // Keep popping the stack until the "error" terminal is shifted +#if __DEBUG + if Flags.debug then System.Console.WriteLine("popStackUntilErrorShifted"); +#endif + if stateStack.IsEmpty then +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("state stack empty during error recovery - generating parse error"); +#endif + failwith "parse error"; + + let currState = stateStack.Peep() +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("In state {0} during error recovery", currState); +#endif + + let action = actionTable.Read(currState, tables.tagOfErrorTerminal) + + if actionKind action = shiftFlag && + (match tokenOpt with + | None -> true + | Some(token) -> + let nextState = actionValue action + actionKind (actionTable.Read(nextState, tables.tagOfToken(token))) = shiftFlag) then + +#if __DEBUG + if Flags.debug then System.Console.WriteLine("shifting error, continuing with error recovery"); +#endif + let nextState = actionValue action + // The "error" non terminal needs position information, though it tends to be unreliable. + // Use the StartPos/EndPos from the lex buffer + valueStack.Push(ValueInfo(box (), lexbuf.StartPos, lexbuf.EndPos)); + stateStack.Push(nextState) + else + if valueStack.IsEmpty then + failwith "parse error"; +#if __DEBUG + if Flags.debug then + System.Console.WriteLine("popping stack during error recovery"); +#endif + valueStack.Pop(); + stateStack.Pop(); + popStackUntilErrorShifted(tokenOpt) + + while not finished do + if stateStack.IsEmpty then + finished <- true + else + let state = stateStack.Peep() +#if __DEBUG + if Flags.debug then (Console.Write("{0} value(state), state ",valueStack.Count); stateStack.PrintStack()) +#endif + let action = + let immediateAction = int tables.immediateActions.[state] + if not (immediateAction = anyMarker) then + // Action has been pre-determined, no need to lookahead + // Expecting it to be a Reduce action on a non-fakeStartNonTerminal ? + immediateAction + else + // Lookahead required to determine action + if not haveLookahead then + if lexbuf.IsPastEndOfStream then + // When the input runs out, keep supplying the last token for eofCountDown times + if eofCountDown>0 then + haveLookahead <- true + eofCountDown <- eofCountDown - 1 + inEofCountDown <- true + else + haveLookahead <- false + else + lookaheadToken <- lexer lexbuf + lookaheadStartPos <- lexbuf.StartPos + lookaheadEndPos <- lexbuf.EndPos + haveLookahead <- true; + + let tag = + if haveLookahead then tables.tagOfToken lookaheadToken + else tables.endOfInputTag + + // Printf.printf "state %d\n" state + actionTable.Read(state,tag) + + let kind = actionKind action + if kind = shiftFlag then ( + if errorSuppressionCountDown > 0 then + errorSuppressionCountDown <- errorSuppressionCountDown - 1; +#if __DEBUG + if Flags.debug then Console.WriteLine("shifting, reduced errorRecoverylevel to {0}\n", errorSuppressionCountDown); +#endif + let nextState = actionValue action + if not haveLookahead then failwith "shift on end of input!"; + let data = tables.dataOfToken lookaheadToken + valueStack.Push(ValueInfo(data, lookaheadStartPos, lookaheadEndPos)); + stateStack.Push(nextState); +#if __DEBUG + if Flags.debug then Console.WriteLine("shift/consume input {0}, shift to state {1}", report haveLookahead lookaheadToken, nextState); +#endif + haveLookahead <- false + + ) elif kind = reduceFlag then + let prod = actionValue action + let reduction = reductions.[prod] + let n = int tables.reductionSymbolCounts.[prod] + // pop the symbols, populate the values and populate the locations +#if __DEBUG + if Flags.debug then Console.Write("reduce popping {0} values/states, lookahead {1}", n, report haveLookahead lookaheadToken); +#endif + + lhsPos.[0] <- Position.Empty; + lhsPos.[1] <- Position.Empty; + for i = 0 to n - 1 do + if valueStack.IsEmpty then failwith "empty symbol stack"; + let topVal = valueStack.Peep() + valueStack.Pop(); + stateStack.Pop(); + ruleValues.[(n-i)-1] <- topVal.value; + ruleStartPoss.[(n-i)-1] <- topVal.startPos; + ruleEndPoss.[(n-i)-1] <- topVal.endPos; + if lhsPos.[1] = Position.Empty then lhsPos.[1] <- topVal.endPos; + if not (topVal.startPos = Position.Empty) then lhsPos.[0] <- topVal.startPos + done; + + try + // Printf.printf "reduce %d\n" prod; + let redResult = reduction parseState + valueStack.Push(ValueInfo(redResult, lhsPos.[0], lhsPos.[1])); + let currState = stateStack.Peep() + let newGotoState = gotoTable.Read(int tables.productionToNonTerminalTable.[prod], currState) + stateStack.Push(newGotoState) +#if __DEBUG + if Flags.debug then Console.WriteLine(" goto state {0}", newGotoState) +#endif + with + | Accept res -> + finished <- true; + valueStack.Push(ValueInfo(res, lhsPos.[0], lhsPos.[1])) + | RecoverableParseError -> +#if __DEBUG + if Flags.debug then Console.WriteLine("RecoverableParseErrorException...\n"); +#endif + popStackUntilErrorShifted(None); + // User code raised a Parse_error. Don't report errors again until three tokens have been shifted + errorSuppressionCountDown <- 3 + elif kind = errorFlag then ( +#if __DEBUG + if Flags.debug then Console.Write("ErrorFlag... "); +#endif + // Silently discard inputs and don't report errors + // until three tokens in a row have been shifted +#if __DEBUG + if Flags.debug then printfn "error on token '%A' " (if haveLookahead then Some(lookaheadToken) else None); +#endif + if errorSuppressionCountDown > 0 then + // If we're in the end-of-file count down then we're very keen to 'Accept'. + // We can only do this by repeatedly popping the stack until we can shift both an 'error' token + // and an EOF token. + if inEofCountDown && eofCountDown < 10 then +#if __DEBUG + if Flags.debug then printfn "poppin stack, lokking to shift both 'error' and that token, during end-of-file error recovery" ; +#endif + popStackUntilErrorShifted(if haveLookahead then Some(lookaheadToken) else None); + + // If we don't haveLookahead then the end-of-file count down is over and we have no further options. + if not haveLookahead then + failwith "parse error: unexpected end of file" + +#if __DEBUG + if Flags.debug then printfn "discarding token '%A' during error suppression" (if haveLookahead then Some(lookaheadToken) else None); +#endif + // Discard the token + haveLookahead <- false + // Try again to shift three tokens + errorSuppressionCountDown <- 3 + else ( + + let currentToken = if haveLookahead then Some(lookaheadToken) else None + let actions,defaultAction = actionTable.ReadAll(state) + let explicit = Set.ofList [ for (tag,_action) in actions -> tag ] + + let shiftableTokens = + [ for (tag,action) in actions do + if (actionKind action) = shiftFlag then + yield tag + if actionKind defaultAction = shiftFlag then + for tag in 0 .. tables.numTerminals-1 do + if not (explicit.Contains(tag)) then + yield tag ] in + + let stateStack = stateStack.Top(12) in + let reducibleProductions = + [ for state in stateStack do + yield stateToProdIdxsTable.ReadAll(state) ] + + let reduceTokens = + [ for (tag,action) in actions do + if actionKind(action) = reduceFlag then + yield tag + if actionKind(defaultAction) = reduceFlag then + for tag in 0 .. tables.numTerminals-1 do + if not (explicit.Contains(tag)) then + yield tag ] in + //let activeRules = stateStack |> List.iter (fun state -> + let errorContext = new ParseErrorContext<'tok>(stateStack,parseState, reduceTokens,currentToken,reducibleProductions, shiftableTokens, "syntax error") + tables.parseError(errorContext); + popStackUntilErrorShifted(None); + errorSuppressionCountDown <- 3; +#if __DEBUG + if Flags.debug then System.Console.WriteLine("generated syntax error and shifted error token, haveLookahead = {0}\n", haveLookahead); +#endif + ) + ) elif kind = acceptFlag then + finished <- true +#if __DEBUG + else + if Flags.debug then System.Console.WriteLine("ALARM!!! drop through case in parser"); +#endif + done; + // OK, we're done - read off the overall generated value + valueStack.Peep().value + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> with +#else +type Tables<'tok> with +#endif + member tables.Interpret (lexer,lexbuf,initialState) = + Implementation.interpret tables lexer lexbuf initialState + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal ParseHelpers = +#else +module ParseHelpers = +#endif + let parse_error (_s:string) = () + let parse_error_rich = (None : (ParseErrorContext<_> -> unit) option) diff --git a/src/buildtools/fsyacc/Parsing.fsi b/src/buildtools/fsyacc/Parsing.fsi new file mode 100644 index 0000000000..2fef45975a --- /dev/null +++ b/src/buildtools/fsyacc/Parsing.fsi @@ -0,0 +1,130 @@ +//========================================================================== +// (c) Microsoft Corporation 2005-2009. +//========================================================================= + +#if INTERNALIZED_FSLEXYACC_RUNTIME +namespace Internal.Utilities.Text.Parsing +open Internal.Utilities +open Internal.Utilities.Text.Lexing +#else +namespace Microsoft.FSharp.Text.Parsing +open Microsoft.FSharp.Text.Lexing +#endif + +open System.Collections.Generic + +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal IParseState = +#else +/// The information accessible via the parseState value within parser actions. +type IParseState = +#endif + /// Get the start and end position for the terminal or non-terminal at a given index matched by the production + abstract InputRange: index:int -> Position * Position + /// Get the end position for the terminal or non-terminal at a given index matched by the production + abstract InputEndPosition: int -> Position + /// Get the start position for the terminal or non-terminal at a given index matched by the production + abstract InputStartPosition: int -> Position + /// Get the full range of positions matched by the production + abstract ResultRange: Position * Position + /// Get the value produced by the terminal or non-terminal at the given position + abstract GetInput : int -> obj + /// Get the store of local values associated with this parser + // Dynamically typed, non-lexically scoped local store + abstract ParserLocalStore : IDictionary + /// Raise an error in this parse context + abstract RaiseError<'b> : unit -> 'b + + +[] +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal ParseErrorContext<'tok> = +#else +/// The context provided when a parse error occurs +type ParseErrorContext<'tok> = +#endif + /// The stack of state indexes active at the parse error + member StateStack : int list + /// The state active at the parse error + member ParseState : IParseState + /// The tokens that would cause a reduction at the parse error + member ReduceTokens: int list + /// The stack of productions that would be reduced at the parse error + member ReducibleProductions : int list list + /// The token that caused the parse error + member CurrentToken : 'tok option + /// The token that would cause a shift at the parse error + member ShiftTokens : int list + /// The message associated with the parse error + member Message : string + +/// Tables generated by fsyacc +#if INTERNALIZED_FSLEXYACC_RUNTIME +type internal Tables<'tok> = +#else +/// The type of the tables contained in a file produced by the fsyacc.exe parser generator. +type Tables<'tok> = +#endif + { /// The reduction table + reductions: (IParseState -> obj) array ; + /// The token number indicating the end of input + endOfInputTag: int; + /// A function to compute the tag of a token + tagOfToken: 'tok -> int; + /// A function to compute the data carried by a token + dataOfToken: 'tok -> obj; + /// The sparse action table elements + actionTableElements: uint16[]; + /// The sparse action table row offsets + actionTableRowOffsets: uint16[]; + /// The number of symbols for each reduction + reductionSymbolCounts: uint16[]; + /// The immediate action table + immediateActions: uint16[]; + /// The sparse goto table + gotos: uint16[]; + /// The sparse goto table row offsets + sparseGotoTableRowOffsets: uint16[]; + /// The sparse table for the productions active for each state + stateToProdIdxsTableElements: uint16[]; + /// The sparse table offsets for the productions active for each state + stateToProdIdxsTableRowOffsets: uint16[]; + /// This table is logically part of the Goto table + productionToNonTerminalTable: uint16[]; + /// This function is used to hold the user specified "parse_error" or "parse_error_rich" functions + parseError: ParseErrorContext<'tok> -> unit; + /// The total number of terminals + numTerminals: int; + /// The tag of the error terminal + tagOfErrorTerminal: int } + + /// Interpret the parser table taking input from the given lexer, using the given lex buffer, and the given start state. + /// Returns an object indicating the final synthesized value for the parse. + member Interpret : lexer:(LexBuffer<'char> -> 'tok) * lexbuf:LexBuffer<'char> * startState:int -> obj + +#if INTERNALIZED_FSLEXYACC_RUNTIME +exception internal Accept of obj +exception internal RecoverableParseError +#else +/// Indicates an accept action has occured +exception Accept of obj +/// Indicates a parse error has occured and parse recovery is in progress +exception RecoverableParseError +#endif + +#if __DEBUG +module internal Flags = + val mutable debug : bool +#endif + +#if INTERNALIZED_FSLEXYACC_RUNTIME +module internal ParseHelpers = +#else +/// Helpers used by generated parsers. +module ParseHelpers = +#endif + /// The default implementation of the parse_error_rich function + val parse_error_rich: (ParseErrorContext<'tok> -> unit) option + /// The default implementation of the parse_error function + val parse_error: string -> unit + diff --git a/src/buildtools/fsyacc/fsyacc.fs b/src/buildtools/fsyacc/fsyacc.fs new file mode 100644 index 0000000000..513262f29d --- /dev/null +++ b/src/buildtools/fsyacc/fsyacc.fs @@ -0,0 +1,531 @@ +(* (c) Microsoft Corporation 2005-2008. *) + +module internal FsLexYacc.FsYacc.Driver + +open System.IO +open System.Collections.Generic +open Printf +open Internal.Utilities +open Internal.Utilities.Text.Lexing + +open FsLexYacc.FsYacc +open FsLexYacc.FsYacc.AST + +//------------------------------------------------------------------ +// This code is duplicated from Microsoft.FSharp.Compiler.UnicodeLexing + +type Lexbuf = LexBuffer + +/// Standard utility to create a Unicode LexBuffer +/// +/// One small annoyance is that LexBuffers and not IDisposable. This means +/// we can't just return the LexBuffer object, since the file it wraps wouldn't +/// get closed when we're finished with the LexBuffer. Hence we return the stream, +/// the reader and the LexBuffer. The caller should dispose the first two when done. +let UnicodeFileAsLexbuf (filename,codePage : int option) : FileStream * StreamReader * Lexbuf = + // Use the .NET functionality to auto-detect the unicode encoding + // It also uses Lexing.from_text_reader to present the bytes read to the lexer in UTF8 decoded form + let stream = new FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.Read) + let reader = + match codePage with + | None -> new StreamReader(stream,true) + | Some n -> new StreamReader(stream,System.Text.Encoding.GetEncoding(n)) + let lexbuf = LexBuffer.FromFunction(reader.Read) + lexbuf.EndPos <- Position.FirstLine(filename); + stream, reader, lexbuf + +//------------------------------------------------------------------ +// This is the program proper + +let input = ref None +let modname= ref None +let internal_module = ref false +let opens= ref [] +let out = ref None +let tokenize = ref false +let compat = ref false +let log = ref false +let light = ref None +let inputCodePage = ref None +let mutable lexlib = "Microsoft.FSharp.Text.Lexing" +let mutable parslib = "Microsoft.FSharp.Text.Parsing" + +let usage = + [ ArgInfo("-o", ArgType.String (fun s -> out := Some s), "Name the output file."); + ArgInfo("-v", ArgType.Unit (fun () -> log := true), "Produce a listing file."); + ArgInfo("--module", ArgType.String (fun s -> modname := Some s), "Define the F# module name to host the generated parser."); + ArgInfo("--internal", ArgType.Unit (fun () -> internal_module := true), "Generate an internal module"); + ArgInfo("--open", ArgType.String (fun s -> opens := !opens @ [s]), "Add the given module to the list of those to open in both the generated signature and implementation."); + ArgInfo("--light", ArgType.Unit (fun () -> light := Some true), "(ignored)"); + ArgInfo("--light-off", ArgType.Unit (fun () -> light := Some false), "Add #light \"off\" to the top of the generated file"); + ArgInfo("--ml-compatibility", ArgType.Set compat, "Support the use of the global state from the 'Parsing' module in FSharp.PowerPack.dll."); + ArgInfo("--tokens", ArgType.Set tokenize, "Simply tokenize the specification file itself."); + ArgInfo("--lexlib", ArgType.String (fun s -> lexlib <- s), "Specify the namespace for the implementation of the lexer (default: Microsoft.FSharp.Text.Lexing)"); + ArgInfo("--parslib", ArgType.String (fun s -> parslib <- s), "Specify the namespace for the implementation of the parser table interpreter (default: Microsoft.FSharp.Text.Parsing)"); + ArgInfo("--codepage", ArgType.Int (fun i -> inputCodePage := Some i), "Assume input lexer specification file is encoded with the given codepage."); ] + +let _ = ArgParser.Parse(usage,(fun x -> match !input with Some _ -> failwith "more than one input given" | None -> input := Some x),"fsyacc ") + +let output_int (os: #TextWriter) (n:int) = os.Write(string n) + +let outputCodedUInt16 (os: #TextWriter) (n:int) = + os.Write n; + os.Write "us; "; + +let shiftFlag = 0x0000 +let reduceFlag = 0x4000 +let errorFlag = 0x8000 +let acceptFlag = 0xc000 +let actionMask = 0xc000 + +let anyMarker = 0xffff + +let actionCoding action = + match action with + | Accept -> acceptFlag + | Shift n -> shiftFlag ||| n + | Reduce n -> reduceFlag ||| n + | Error -> errorFlag + +let main() = + let filename = (match !input with Some x -> x | None -> failwith "no input given") in + let spec = + let stream,reader,lexbuf = UnicodeFileAsLexbuf(filename, !inputCodePage) + use stream = stream + use reader = reader + + try + if !tokenize then begin + while true do + printf "tokenize - getting one token"; + let t = Lexer.token lexbuf in + (*F# printf "tokenize - got %s" (Parser.token_to_string t); F#*) + if t = Parser.EOF then exit 0; + done; + end; + + Parser.spec Lexer.token lexbuf + with e -> + eprintf "%s(%d,%d): error: %s" filename lexbuf.StartPos.Line lexbuf.StartPos.Column e.Message; + exit 1 in + + let has_extension (s:string) = + (s.Length >= 1 && s.[s.Length - 1] = '.') + || Path.HasExtension(s) + + let chop_extension (s:string) = + if not (has_extension s) then invalidArg "s" "the file name does not have an extension" + Path.Combine (Path.GetDirectoryName s,Path.GetFileNameWithoutExtension(s)) + + let checkSuffix (x:string) (y:string) = x.EndsWith(y) + + let output = match !out with Some x -> x | _ -> chop_extension filename + (if checkSuffix filename ".mly" then ".ml" else ".fs") in + let outputi = match !out with Some x -> chop_extension x + (if checkSuffix x ".ml" then ".mli" else ".fsi") | _ -> chop_extension filename + (if checkSuffix filename ".mly" then ".mli" else ".fsi") in + let outputo = + if !log then Some (match !out with Some x -> chop_extension x + ".fsyacc.output" | _ -> chop_extension filename + ".fsyacc.output") + else None + + use os = (File.CreateText output :> TextWriter) + use osi = (File.CreateText outputi :> TextWriter) + + let lineCountOutput = ref 0 + let lineCountSignature = ref 0 + let cos = (os,lineCountOutput) + let cosi = (osi,lineCountSignature) + let cprintf (os:TextWriter,lineCount) fmt = Printf.fprintf os fmt + let cprintfn (os:TextWriter,lineCount) fmt = Printf.kfprintf (fun () -> incr lineCount; os.WriteLine()) os fmt + + let logf = + match outputo with + | None -> (fun f -> ()) + | Some filename -> + let oso = (File.CreateText filename :> TextWriter) + (fun f -> f oso) + + logf (fun oso -> fprintfn oso " Output file describing compiled parser placed in %s and %s" output outputi); + + printfn " building tables"; + let spec1 = ProcessParserSpecAst spec + let (prods,states, startStates,actionTable,immediateActionTable,gotoTable,endOfInputTerminalIdx,errorTerminalIdx,nonTerminals) = + CompilerLalrParserSpec logf spec1 + + let (code,pos) = spec.Header + printfn " %d states" states.Length; + printfn " %d nonterminals" gotoTable.[0].Length; + printfn " %d terminals" actionTable.[0].Length; + printfn " %d productions" prods.Length; + printfn " #rows in action table: %d" actionTable.Length; +(* + printfn "#unique rows in action table: %d" (List.length (Array.foldBack (fun row acc -> insert (Array.to_list row) acc) actionTable [])); + printfn "maximum #different actions per state: %d" (Array.foldBack (fun row acc ->max (List.length (List.foldBack insert (Array.to_list row) [])) acc) actionTable 0); + printfn "average #different actions per state: %d" ((Array.foldBack (fun row acc -> (List.length (List.foldBack insert (Array.to_list row) [])) + acc) actionTable 0) / (Array.length states)); +*) + + cprintfn cos "// Implementation file for parser generated by fsyacc"; + cprintfn cosi "// Signature file for parser generated by fsyacc"; + + if (!light = Some(false)) || (!light = None && checkSuffix output ".ml") then + cprintfn cos "#light \"off\""; + cprintfn cosi "#light \"off\""; + + match !modname with + | None -> () + | Some s -> + match !internal_module with + | true -> + cprintfn cos "module internal %s" s; + cprintfn cosi "module internal %s" s; + | false -> + cprintfn cos "module %s" s; + cprintfn cosi "module %s" s; + + cprintfn cos "#nowarn \"64\";; // turn off warnings that type variables used in production annotations are instantiated to concrete type"; + + for s in !opens do + cprintfn cos "open %s" s; + cprintfn cosi "open %s" s; + + cprintfn cos "open %s" lexlib; + cprintfn cos "open %s.ParseHelpers" parslib; + if !compat then + cprintfn cos "open Microsoft.FSharp.Compatibility.OCaml.Parsing"; + + cprintfn cos "# %d \"%s\"" pos.pos_lnum pos.pos_fname; + cprintfn cos "%s" code; + lineCountOutput := !lineCountOutput + code.Replace("\r","").Split([| '\n' |]).Length; + + cprintfn cos "# %d \"%s\"" !lineCountOutput output; + // Print the datatype for the tokens + cprintfn cos "// This type is the type of tokens accepted by the parser"; + for out in [cos;cosi] do + cprintfn out "type token = "; + for id,typ in spec.Tokens do + match typ with + | None -> cprintfn out " | %s" id + | Some ty -> cprintfn out " | %s of (%s)" id ty; + + // Print the datatype for the token names + cprintfn cos "// This type is used to give symbolic names to token indexes, useful for error messages"; + for out in [cos;cosi] do + cprintfn out "type tokenId = "; + for id,typ in spec.Tokens do + cprintfn out " | TOKEN_%s" id; + cprintfn out " | TOKEN_end_of_input"; + cprintfn out " | TOKEN_error"; + + cprintfn cos "// This type is used to give symbolic names to token indexes, useful for error messages"; + for out in [cos;cosi] do + cprintfn out "type nonTerminalId = "; + for nt in nonTerminals do + cprintfn out " | NONTERM_%s" nt; + + cprintfn cos ""; + cprintfn cos "// This function maps tokens to integer indexes"; + cprintfn cos "let tagOfToken (t:token) = "; + cprintfn cos " match t with"; + spec.Tokens |> List.iteri (fun i (id,typ) -> + cprintfn cos " | %s %s -> %d " id (match typ with Some _ -> "_" | None -> "") i); + cprintfn cosi "/// This function maps tokens to integer indexes"; + cprintfn cosi "val tagOfToken: token -> int"; + + cprintfn cos ""; + cprintfn cos "// This function maps integer indexes to symbolic token ids"; + cprintfn cos "let tokenTagToTokenId (tokenIdx:int) = "; + cprintfn cos " match tokenIdx with"; + spec.Tokens |> List.iteri (fun i (id,typ) -> + cprintfn cos " | %d -> TOKEN_%s " i id) + cprintfn cos " | %d -> TOKEN_end_of_input" endOfInputTerminalIdx; + cprintfn cos " | %d -> TOKEN_error" errorTerminalIdx; + cprintfn cos " | _ -> failwith \"tokenTagToTokenId: bad token\"" + + cprintfn cosi ""; + cprintfn cosi "/// This function maps integer indexes to symbolic token ids"; + cprintfn cosi "val tokenTagToTokenId: int -> tokenId"; + + cprintfn cos ""; + cprintfn cos "/// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production"; + cprintfn cos "let prodIdxToNonTerminal (prodIdx:int) = "; + cprintfn cos " match prodIdx with"; + prods |> Array.iteri (fun i (nt,ntIdx,syms,code) -> + cprintfn cos " | %d -> NONTERM_%s " i nt); + cprintfn cos " | _ -> failwith \"prodIdxToNonTerminal: bad production index\"" + + cprintfn cosi ""; + cprintfn cosi "/// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production"; + cprintfn cosi "val prodIdxToNonTerminal: int -> nonTerminalId"; + + cprintfn cos ""; + cprintfn cos "let _fsyacc_endOfInputTag = %d " endOfInputTerminalIdx; + cprintfn cos "let _fsyacc_tagOfErrorTerminal = %d" errorTerminalIdx; + cprintfn cos ""; + cprintfn cos "// This function gets the name of a token as a string"; + cprintfn cos "let token_to_string (t:token) = "; + cprintfn cos " match t with "; + spec.Tokens |> List.iteri (fun i (id,typ) -> + cprintfn cos " | %s %s -> \"%s\" " id (match typ with Some _ -> "_" | None -> "") id); + + cprintfn cosi ""; + cprintfn cosi "/// This function gets the name of a token as a string"; + cprintfn cosi "val token_to_string: token -> string"; + + cprintfn cos ""; + cprintfn cos "// This function gets the data carried by a token as an object"; + cprintfn cos "let _fsyacc_dataOfToken (t:token) = "; + cprintfn cos " match t with "; + + for (id,typ) in spec.Tokens do + cprintfn cos " | %s %s -> %s " + id + (match typ with Some _ -> "_fsyacc_x" | None -> "") + (match typ with Some _ -> "Microsoft.FSharp.Core.Operators.box _fsyacc_x" | None -> "(null : System.Object)") + + let tychar = "'cty" + + for (key,_) in spec.Types |> Seq.countBy fst |> Seq.filter (fun (_,n) -> n > 1) do + failwithf "%s is given multiple %%type declarations" key; + + for (key,_) in spec.Tokens |> Seq.countBy fst |> Seq.filter (fun (_,n) -> n > 1) do + failwithf "%s is given %%token declarations" key + + let types = Map.ofList spec.Types + let tokens = Map.ofList spec.Tokens + + let nStates = states.Length + begin + cprintf cos "let _fsyacc_gotos = [| " ; + let numGotoNonTerminals = gotoTable.[0].Length + let gotoIndexes = Array.create numGotoNonTerminals 0 + let gotoTableCurrIndex = ref 0 in + for j = 0 to numGotoNonTerminals-1 do + gotoIndexes.[j] <- !gotoTableCurrIndex; + + (* Count the number of entries in the association table. *) + let count = ref 0 in + for i = 0 to nStates - 1 do + let goto = gotoTable.[i].[j] + match goto with + | None -> () + | Some _ -> incr count + + (* Write the head of the table (i.e. the number of entries and the default value) *) + gotoTableCurrIndex := !gotoTableCurrIndex + 1; + outputCodedUInt16 os !count; + outputCodedUInt16 os anyMarker; + + (* Write the pairs of entries in incremental order by key *) + (* This lets us implement the lookup by a binary chop. *) + for i = 0 to nStates - 1 do + let goto = gotoTable.[i].[j] + match goto with + | None -> () + | Some n -> + gotoTableCurrIndex := !gotoTableCurrIndex + 1; + outputCodedUInt16 os i; + outputCodedUInt16 os n; + cprintfn cos "|]" ; + (* Output offsets into gotos table where the gotos for a particular nonterminal begin *) + cprintf cos "let _fsyacc_sparseGotoTableRowOffsets = [|" ; + for j = 0 to numGotoNonTerminals-1 do + outputCodedUInt16 os gotoIndexes.[j]; + cprintfn cos "|]" ; + end; + + begin + cprintf cos "let _fsyacc_stateToProdIdxsTableElements = [| " ; + let indexes = Array.create states.Length 0 + let currIndex = ref 0 + for j = 0 to states.Length - 1 do + let state = states.[j] + indexes.[j] <- !currIndex; + + (* Write the head of the table (i.e. the number of entries) *) + outputCodedUInt16 os state.Length; + currIndex := !currIndex + state.Length + 1; + + (* Write the pairs of entries in incremental order by key *) + (* This lets us implement the lookup by a binary chop. *) + for prodIdx in state do + outputCodedUInt16 os prodIdx; + cprintfn cos "|]" ; + (* Output offsets into gotos table where the gotos for a particular nonterminal begin *) + cprintf cos "let _fsyacc_stateToProdIdxsTableRowOffsets = [|" ; + for idx in indexes do + outputCodedUInt16 os idx; + cprintfn cos "|]" ; + end; + + begin + let numActionRows = (Array.length actionTable) + let maxActionColumns = Array.length actionTable.[0] + cprintfn cos "let _fsyacc_action_rows = %d" numActionRows; + cprintf cos "let _fsyacc_actionTableElements = [|" ; + let actionIndexes = Array.create numActionRows 0 + + let actionTableCurrIndex = ref 0 + for i = 0 to nStates-1 do + actionIndexes.[i] <- !actionTableCurrIndex; + let actions = actionTable.[i] + let terminalsByAction = new Dictionary<_,int list>(10) + let countPerAction = new Dictionary<_,_>(10) + for terminal = 0 to actions.Length - 1 do + let action = snd actions.[terminal] + if terminalsByAction.ContainsKey action then + terminalsByAction.[action] <- terminal :: terminalsByAction.[action] ; + else + terminalsByAction.[action] <- [terminal]; + if countPerAction.ContainsKey action then + countPerAction.[action] <- countPerAction.[action]+1 + else + countPerAction.[action] <- 1 + + let mostCommonAction = + let mostCommon = ref Error + let max = ref 0 + for (KeyValue(x,y)) in countPerAction do + if y > !max then (mostCommon := x; max := y) + !mostCommon + + (* Count the number of entries in the association table. *) + let count = ref 0 + for (KeyValue(action,terminals)) in terminalsByAction do + for terminals in terminals do + if action <> mostCommonAction then + incr count; + + (* Write the head of the table (i.e. the number of entries and the default value) *) + actionTableCurrIndex := !actionTableCurrIndex + 1; + outputCodedUInt16 os !count; + outputCodedUInt16 os (actionCoding mostCommonAction); + + (* Write the pairs of entries in incremental order by key *) + (* This lets us implement the lookup by a binary chop. *) + for terminal = 0 to Array.length actions-1 do + let action = snd actions.[terminal] in + if action <> mostCommonAction then ( + actionTableCurrIndex := !actionTableCurrIndex + 1; + outputCodedUInt16 os terminal; + outputCodedUInt16 os (actionCoding action); + ); + cprintfn cos "|]" ; + (* Output offsets into actions table where the actions for a particular nonterminal begin *) + cprintf cos "let _fsyacc_actionTableRowOffsets = [|" ; + for j = 0 to numActionRows-1 do + cprintf cos "%a" outputCodedUInt16 actionIndexes.[j]; + cprintfn cos "|]" ; + + end; + begin + cprintf cos "let _fsyacc_reductionSymbolCounts = [|" ; + for nt,ntIdx,syms,code in prods do + cprintf cos "%a" outputCodedUInt16 (List.length syms); + cprintfn cos "|]" ; + end; + begin + cprintf cos "let _fsyacc_productionToNonTerminalTable = [|" ; + for nt,ntIdx,syms,code in prods do + cprintf cos "%a" outputCodedUInt16 ntIdx; + cprintfn cos "|]" ; + end; + begin + cprintf cos "let _fsyacc_immediateActions = [|" ; + for prodIdx in immediateActionTable do + match prodIdx with + | None -> cprintf cos "%a" outputCodedUInt16 anyMarker (* NONE REP *) + | Some act -> cprintf cos "%a" outputCodedUInt16 (actionCoding act) + cprintfn cos "|]" ; + end; + + let getType nt = if types.ContainsKey nt then types.[nt] else "'"+nt + begin + cprintf cos "let _fsyacc_reductions () =" ; + cprintfn cos " [| " ; + for nt,ntIdx,syms,code in prods do + cprintfn cos "# %d \"%s\"" !lineCountOutput output; + cprintfn cos " (fun (parseState : %s.IParseState) ->" parslib + if !compat then + cprintfn cos " Parsing.set_parse_state parseState;" + syms |> List.iteri (fun i sym -> + let tyopt = + match sym with + | Terminal t -> + if tokens.ContainsKey t then + tokens.[t] + else None + | NonTerminal nt -> Some (getType nt) + match tyopt with + | Some ty -> cprintfn cos " let _%d = (let data = parseState.GetInput(%d) in (Microsoft.FSharp.Core.Operators.unbox data : %s)) in" (i+1) (i+1) ty + | None -> ()) + cprintfn cos " Microsoft.FSharp.Core.Operators.box" + cprintfn cos " ("; + cprintfn cos " ("; + match code with + | Some (_,pos) -> cprintfn cos "# %d \"%s\"" pos.pos_lnum pos.pos_fname + | None -> () + match code with + | Some (code,_) -> + let dollar = ref false in + let c = code |> String.collect (fun c -> + if not !dollar && c = '$' then (dollar := true; "") + elif !dollar && c >= '0' && c <= '9' then (dollar := false; "_"+new System.String(c,1)) + elif !dollar then (dollar := false; "$"+new System.String(c,1)) + else new System.String(c,1)) + let lines = c.Split([| '\r'; '\n' |], System.StringSplitOptions.RemoveEmptyEntries); + for line in lines do + cprintfn cos " %s" line; + if !dollar then os.Write '$' + | None -> + cprintfn cos " raise (%s.Accept(Microsoft.FSharp.Core.Operators.box _1))" parslib + cprintfn cos " )"; + // Place the line count back for the type constraint + match code with + | Some (_,pos) -> cprintfn cos "# %d \"%s\"" pos.pos_lnum pos.pos_fname + | None -> () + cprintfn cos " : %s));" (if types.ContainsKey nt then types.[nt] else "'"+nt); + done; + cprintfn cos "|]" ; + end; + cprintfn cos "# %d \"%s\"" !lineCountOutput output; + cprintfn cos "let tables () : %s.Tables<_> = " parslib + cprintfn cos " { reductions= _fsyacc_reductions ();" + cprintfn cos " endOfInputTag = _fsyacc_endOfInputTag;" + cprintfn cos " tagOfToken = tagOfToken;" + cprintfn cos " dataOfToken = _fsyacc_dataOfToken; " + cprintfn cos " actionTableElements = _fsyacc_actionTableElements;" + cprintfn cos " actionTableRowOffsets = _fsyacc_actionTableRowOffsets;" + cprintfn cos " stateToProdIdxsTableElements = _fsyacc_stateToProdIdxsTableElements;" + cprintfn cos " stateToProdIdxsTableRowOffsets = _fsyacc_stateToProdIdxsTableRowOffsets;" + cprintfn cos " reductionSymbolCounts = _fsyacc_reductionSymbolCounts;" + cprintfn cos " immediateActions = _fsyacc_immediateActions;" + cprintfn cos " gotos = _fsyacc_gotos;" + cprintfn cos " sparseGotoTableRowOffsets = _fsyacc_sparseGotoTableRowOffsets;" + cprintfn cos " tagOfErrorTerminal = _fsyacc_tagOfErrorTerminal;" + cprintfn cos " parseError = (fun (ctxt:%s.ParseErrorContext<_>) -> " parslib + cprintfn cos " match parse_error_rich with " + cprintfn cos " | Some f -> f ctxt" + cprintfn cos " | None -> parse_error ctxt.Message);" + + cprintfn cos " numTerminals = %d;" (Array.length actionTable.[0]); + cprintfn cos " productionToNonTerminalTable = _fsyacc_productionToNonTerminalTable }" + cprintfn cos "let engine lexer lexbuf startState = (tables ()).Interpret(lexer, lexbuf, startState)" + + for (id,startState) in List.zip spec.StartSymbols startStates do + if not (types.ContainsKey id) then + failwith ("a %type declaration is required for for start token "+id); + let ty = types.[id] in + cprintfn cos "let %s lexer lexbuf : %s =" id ty; + cprintfn cos " Microsoft.FSharp.Core.Operators.unbox ((tables ()).Interpret(lexer, lexbuf, %d))" startState + + for id in spec.StartSymbols do + if not (types.ContainsKey id) then + failwith ("a %type declaration is required for start token "+id); + let ty = types.[id] in + cprintfn cosi "val %s : (%s.LexBuffer<%s> -> token) -> %s.LexBuffer<%s> -> (%s) " id lexlib tychar lexlib tychar ty; + + logf (fun oso -> oso.Close()) + +let result = + try main() + with e -> + eprintf "FSYACC: error FSY000: %s" (match e with Failure s -> s | e -> e.Message); + exit 1 + diff --git a/src/buildtools/fsyacc/fsyacc.fsproj b/src/buildtools/fsyacc/fsyacc.fsproj new file mode 100644 index 0000000000..32a1d6f331 --- /dev/null +++ b/src/buildtools/fsyacc/fsyacc.fsproj @@ -0,0 +1,12 @@ + + + + netcoreapp2.0 + INTERNALIZED_FSLEXYACC_RUNTIME;$(DefineConstant) + + + + + + + diff --git a/src/buildtools/fsyacc/fsyacc.fsx b/src/buildtools/fsyacc/fsyacc.fsx new file mode 100644 index 0000000000..65b608372f --- /dev/null +++ b/src/buildtools/fsyacc/fsyacc.fsx @@ -0,0 +1,3 @@ +#load "Lexing.fsi" "Lexing.fs" "Parsing.fsi" "Parsing.fs" "Arg.fsi" "Arg.fs" "fsyaccast.fs" "fsyaccpars.fs" "fsyacclex.fs" "fsyacc.fs" + +let v = FsLexYacc.FsYacc.Driver.result diff --git a/src/buildtools/fsyacc/fsyaccast.fs b/src/buildtools/fsyacc/fsyaccast.fs new file mode 100644 index 0000000000..deb2d3ef8a --- /dev/null +++ b/src/buildtools/fsyacc/fsyaccast.fs @@ -0,0 +1,1000 @@ +// (c) Microsoft Corporation 2005-2007. + +module internal FsLexYacc.FsYacc.AST + +#nowarn "62" // This construct is for ML compatibility. + + +open System +open System.Collections.Generic +open Printf +open Microsoft.FSharp.Collections +open Internal.Utilities +open Internal.Utilities.Text.Lexing + +/// An active pattern that should be in the F# standard library +let (|KeyValue|) (kvp:KeyValuePair<_,_>) = kvp.Key,kvp.Value + + +type Identifier = string +type Code = string * Position + +type ParserSpec= + { Header : Code; + Tokens : (Identifier * string option) list; + Types : (Identifier * string) list; + Associativities: (Identifier * Associativity) list list; + StartSymbols : Identifier list; + Rules : (Identifier * Rule list) list } + +and Rule = Rule of Identifier list * Identifier option * Code option +and Associativity = LeftAssoc | RightAssoc | NonAssoc + +type Terminal = string +type NonTerminal = string +type Symbol = Terminal of Terminal | NonTerminal of NonTerminal +type Symbols = Symbol list + + +//--------------------------------------------------------------------- +// Output Raw Parser Spec AST + +let StringOfSym sym = match sym with Terminal s -> "'" ^ s ^ "'" | NonTerminal s -> s + +let OutputSym os sym = fprintf os "%s" (StringOfSym sym) + +let OutputSyms os syms = + fprintf os "%s" (String.Join(" ",Array.map StringOfSym syms)) + +let OutputTerminalSet os (tset:string seq) = + fprintf os "%s" (String.Join(";", tset |> Seq.toArray)) + +let OutputAssoc os p = + match p with + | LeftAssoc -> fprintf os "left" + | RightAssoc -> fprintf os "right" + | NonAssoc -> fprintf os "nonassoc" + + +//--------------------------------------------------------------------- +// PreProcess Raw Parser Spec AST + +type PrecedenceInfo = + | ExplicitPrec of Associativity * int + | NoPrecedence + +type Production = Production of NonTerminal * PrecedenceInfo * Symbols * Code option + +type ProcessedParserSpec = + { Terminals: (Terminal * PrecedenceInfo) list; + NonTerminals: NonTerminal list; + Productions: Production list; + StartSymbols: NonTerminal list } + + +let ProcessParserSpecAst (spec: ParserSpec) = + let explicitPrecInfo = + spec.Associativities + |> List.mapi (fun n precSpecs -> precSpecs |> List.map (fun (precSym, assoc) -> precSym,ExplicitPrec (assoc, 10000 - n))) + |> List.concat + + for (key,_) in explicitPrecInfo |> Seq.countBy fst |> Seq.filter (fun (_,n) -> n > 1) do + failwithf "%s is given two associativities" key + + let explicitPrecInfo = + explicitPrecInfo |> Map.ofList + + let implicitSymPrecInfo = NoPrecedence + let terminals = List.map fst spec.Tokens @ ["error"]in + let terminalSet = Set.ofList terminals + let IsTerminal z = terminalSet.Contains(z) + let prec_of_terminal sym implicitPrecInfo = + if explicitPrecInfo.ContainsKey(sym) then explicitPrecInfo.[sym] + else match implicitPrecInfo with Some x -> x | None -> implicitSymPrecInfo + + let mkSym s = if IsTerminal s then Terminal s else NonTerminal s + let prods = + spec.Rules |> List.mapi (fun i (nonterm,rules) -> + rules |> List.mapi (fun j (Rule(syms,precsym,code)) -> + let precInfo = + let precsym = List.foldBack (fun x acc -> match acc with Some _ -> acc | None -> match x with z when IsTerminal z -> Some z | _ -> acc) syms precsym + let implicitPrecInfo = NoPrecedence + match precsym with + | None -> implicitPrecInfo + | Some sym -> if explicitPrecInfo.ContainsKey(sym) then explicitPrecInfo.[sym] else implicitPrecInfo + Production(nonterm, precInfo, List.map mkSym syms, code))) + |> List.concat + let nonTerminals = List.map fst spec.Rules + let nonTerminalSet = Set.ofList nonTerminals + let checkNonTerminal nt = + if nt <> "error" && not (nonTerminalSet.Contains(nt)) then + failwith (sprintf "NonTerminal '%s' has no productions" nt) + + for (Production(nt,_,syms,_)) in prods do + for sym in syms do + match sym with + | NonTerminal nt -> + checkNonTerminal nt + | Terminal t -> + if not (IsTerminal t) then failwith (sprintf "token %s is not declared" t) + + if spec.StartSymbols= [] then (failwith "at least one %start declaration is required"); + + for (nt,_) in spec.Types do + checkNonTerminal nt; + + let terminals = terminals |> List.map (fun t -> (t,prec_of_terminal t None)) + + { Terminals=terminals; + NonTerminals=nonTerminals; + Productions=prods; + StartSymbols=spec.StartSymbols } + + +//------------------------------------------------- +// Process LALR(1) grammars to tables + +type ProductionIndex = int +type ProdictionDotIndex = int + +/// Represent (ProductionIndex,ProdictionDotIndex) as one integer +type Item0 = uint32 + +let mkItem0 (prodIdx,dotIdx) : Item0 = (uint32 prodIdx <<< 16) ||| uint32 dotIdx +let prodIdx_of_item0 (item0:Item0) = int32 (item0 >>> 16) +let dotIdx_of_item0 (item0:Item0) = int32 (item0 &&& 0xFFFFu) + +/// Part of the output of CompilerLalrParserSpec +type Action = + | Shift of int + | Reduce of ProductionIndex + | Accept + | Error + +let outputPrecInfo os p = + match p with + | ExplicitPrec (assoc,n) -> fprintf os "explicit %a %d" OutputAssoc assoc n + | NoPrecedence -> fprintf os "noprec" + + +/// LR(0) kernels +type Kernel = Set + +/// Indexes of LR(0) kernels in the KernelTable +type KernelIdx = int + +/// Indexes in the TerminalTable and NonTerminalTable +type TerminalIndex = int +type NonTerminalIndex = int + +/// Representation of Symbols. +/// Ideally would be declared as +/// type SymbolIndex = PTerminal of TerminalIndex | PNonTerminal of NonTerminalIndex +/// but for performance reasons we embed as a simple integer (saves ~10%) +/// +/// We use an active pattern to reverse the embedding. +type SymbolIndex = int +let PTerminal(i:TerminalIndex) : SymbolIndex = -i-1 +let PNonTerminal(i:NonTerminalIndex) : SymbolIndex = i +let (|PTerminal|PNonTerminal|) x = if x < 0 then PTerminal (-(x+1)) else PNonTerminal x + +type SymbolIndexes = SymbolIndex list + +/// Indexes in the LookaheadTable, SpontaneousTable, PropagateTable +/// Embed in a single integer, since these are faster +/// keys for the dictionary hash tables +/// +/// Logically: +/// +/// type KernelItemIndex = KernelItemIdx of KernelIdx * Item0 +type KernelItemIndex = int64 +let KernelItemIdx (i1,i2) = ((int64 i1) <<< 32) ||| int64 i2 + + +/// Indexes into the memoizing table for the Goto computations +/// Embed in a single integer, since these are faster +/// keys for the dictionary hash tables +/// +/// Logically: +/// +/// type GotoItemIndex = GotoItemIdx of KernelIdx * SymbolIndex +type GotoItemIndex = uint64 +let GotoItemIdx (i1:KernelIdx,i2:SymbolIndex) = (uint64 (uint32 i1) <<< 32) ||| uint64 (uint32 i2) +let (|GotoItemIdx|) (i64:uint64) = int32 ((i64 >>> 32) &&& 0xFFFFFFFFUL), int32 (i64 &&& 0xFFFFFFFFUL) + +/// Create a work list and loop until it is exhausted, calling a worker function for +/// each element. Pass a function to queue additional work on the work list +/// to the worker function +let ProcessWorkList start f = + let work = ref (start : 'a list) + let queueWork = (fun x -> work := x :: !work) + let rec loop() = + match !work with + | [] -> () + | x::t -> + work := t; + f queueWork x; + loop() + loop() + +/// A standard utility to compute a least fixed point of a set under a generative computation +let LeastFixedPoint f set = + let acc = ref set + ProcessWorkList (Set.toList set) (fun queueWork item -> + f(item) |> List.iter (fun i2 -> if not (Set.contains i2 !acc) then (acc := Set.add i2 !acc; queueWork i2)) ) + !acc + +/// A general standard memoization utility. Be sure to apply to only one (function) argument to build the +/// residue function! +let Memoize f = + let t = new Dictionary<_,_>(1000) + fun x -> + let ok,v = t.TryGetValue(x) + if ok then v else let res = f x in t.[x] <- res; res + +/// A standard utility to create a dictionary from a list of pairs +let CreateDictionary xs = + let dict = new Dictionary<_,_>() + for x,y in xs do dict.Add(x,y) + dict + +/// Allocate indexes for each non-terminal +type NonTerminalTable(nonTerminals:NonTerminal list) = + let nonterminalsWithIdxs = List.mapi (fun (i:NonTerminalIndex) n -> (i,n)) nonTerminals + let nonterminalIdxs = List.map fst nonterminalsWithIdxs + let a = Array.ofList nonTerminals + let b = CreateDictionary [ for i,x in nonterminalsWithIdxs -> x,i ]; + member table.OfIndex(i) = a.[i] + member table.ToIndex(i) = b.[i] + member table.Indexes = nonterminalIdxs + +/// Allocate indexes for each terminal +type TerminalTable(terminals:(Terminal * PrecedenceInfo) list) = + let terminalsWithIdxs = List.mapi (fun i (t,_) -> (i,t)) terminals + let terminalIdxs = List.map fst terminalsWithIdxs + let a = Array.ofList (List.map fst terminals) + let b = Array.ofList (List.map snd terminals) + let c = CreateDictionary [ for i,x in terminalsWithIdxs -> x,i ] + + member table.OfIndex(i) = a.[i] + member table.PrecInfoOfIndex(i) = b.[i] + member table.ToIndex(i) = c.[i] + member table.Indexes = terminalIdxs + +/// Allocate indexes for each production +type ProductionTable(ntTab:NonTerminalTable, termTab:TerminalTable, nonTerminals:string list, prods: Production list) = + let prodsWithIdxs = List.mapi (fun i n -> (i,n)) prods + let a = + prodsWithIdxs + |> List.map(fun (_,Production(_,_,syms,_)) -> + syms + |> Array.ofList + |> Array.map (function + | Terminal t -> PTerminal (termTab.ToIndex t) + | NonTerminal nt -> PNonTerminal (ntTab.ToIndex nt )) ) + |> Array.ofList + let b = Array.ofList (List.map (fun (_,Production(nt,_,_,_)) -> ntTab.ToIndex nt) prodsWithIdxs) + let c = Array.ofList (List.map (fun (_,Production(_,prec,_,_)) -> prec) prodsWithIdxs) + let productions = + nonTerminals + |> List.map(fun nt -> (ntTab.ToIndex nt, List.choose (fun (i,Production(nt2,prec,syms,_)) -> if nt2=nt then Some i else None) prodsWithIdxs)) + |> CreateDictionary + + member prodTab.Symbols(i) = a.[i] + member prodTab.NonTerminal(i) = b.[i] + member prodTab.Precedence(i) = c.[i] + member prodTab.Symbol i n = + let syms = prodTab.Symbols i + if n >= syms.Length then None else Some (syms.[n]) + member prodTab.Productions = productions + +/// A mutable table maping kernels to sets of lookahead tokens +type LookaheadTable() = + let t = new Dictionary>() + member table.Add(x,y) = + let prev = if t.ContainsKey(x) then t.[x] else Set.empty + t.[x] <- prev.Add(y) + member table.Contains(x,y) = t.ContainsKey(x) && t.[x].Contains(y) + member table.GetLookaheads(idx:KernelItemIndex) = + let ok,v = t.TryGetValue(idx) + if ok then v else Set.empty + member table.Count = t |> Seq.fold(fun acc (KeyValue(_,v)) -> v.Count+acc) 0 + +/// A mutable table giving an index to each LR(0) kernel. Kernels are referred to only by index. +type KernelTable(kernels) = + // Give an index to each LR(0) kernel, and from now on refer to them only by index + // Also develop "kernelItemIdx" to refer to individual items within a kernel + let kernelsAndIdxs = List.mapi (fun i x -> (i,x)) kernels + let kernelIdxs = List.map fst kernelsAndIdxs + let toIdxMap = Map.ofList [ for i,x in kernelsAndIdxs -> x,i ] + let ofIdxMap = Array.ofList kernels + member t.Indexes = kernelIdxs + member t.Index(kernel) = toIdxMap.[kernel] + member t.Kernel(i) = ofIdxMap.[i] + +/// Hold the results of cpmuting the LALR(1) closure of an LR(0) kernel +type Closure1Table() = + let t = new Dictionary>() + member table.Add(a,b) = + if not (t.ContainsKey(a)) then t.[a] <- new HashSet<_>(HashIdentity.Structural) + t.[a].Add(b) + member table.Count = t.Count + member table.IEnumerable = (t :> seq<_>) + member table.Contains(a,b) = t.ContainsKey(a) && t.[a].Contains(b) + +/// A mutable table giving a lookahead set Set for each kernel. The terminals represent the +/// "spontaneous" items for the kernel. TODO: document this more w.r.t. the Dragon book. +type SpontaneousTable() = + let t = new Dictionary>() + member table.Add(a,b) = + if not (t.ContainsKey(a)) then t.[a] <- new HashSet<_>(HashIdentity.Structural) + t.[a].Add(b) + member table.Count = t.Count + member table.IEnumerable = (t :> seq<_>) + +/// A mutable table giving a Set for each kernel. The kernels represent the +/// "propagate" items for the kernel. TODO: document this more w.r.t. the Dragon book. +type PropagateTable() = + let t = new Dictionary>() + member table.Add(a,b) = + if not (t.ContainsKey(a)) then t.[a] <- new HashSet(HashIdentity.Structural) + t.[a].Add(b) + member table.Item + with get(a) = + let ok,v = t.TryGetValue(a) + if ok then v :> seq<_> else Seq.empty + member table.Count = t.Count + + +/// Compile a pre-processed LALR parser spec to tables following the Dragon book algorithm +let CompilerLalrParserSpec logf (spec : ProcessedParserSpec) = + let stopWatch = new System.Diagnostics.Stopwatch() + let reportTime() = printfn " time: %A" stopWatch.Elapsed; stopWatch.Reset(); stopWatch.Start() + stopWatch.Start() + + // Augment the grammar + let fakeStartNonTerminals = spec.StartSymbols |> List.map(fun nt -> "_start"^nt) + let nonTerminals = fakeStartNonTerminals@spec.NonTerminals + let endOfInputTerminal = "$$" + let dummyLookahead = "#" + let dummyPrec = NoPrecedence + let terminals = spec.Terminals @ [(dummyLookahead,dummyPrec); (endOfInputTerminal,dummyPrec)] + let prods = List.map2 (fun a b -> Production(a, dummyPrec,[NonTerminal b],None)) fakeStartNonTerminals spec.StartSymbols @ spec.Productions + let startNonTerminalIdx_to_prodIdx (i:int) = i + + // Build indexed tables + let ntTab = NonTerminalTable(nonTerminals) + let termTab = TerminalTable(terminals) + let prodTab = ProductionTable(ntTab,termTab,nonTerminals,prods) + let dummyLookaheadIdx = termTab.ToIndex dummyLookahead + let endOfInputTerminalIdx = termTab.ToIndex endOfInputTerminal + + let errorTerminalIdx = termTab.ToIndex "error" + + // Compute the FIRST function + printf "computing first function..."; stdout.Flush(); + + let computedFirstTable = + let seed = + Map.ofList + [ for term in termTab.Indexes do yield (PTerminal(term),Set.singleton (Some term)) + for nonTerm in ntTab.Indexes do + yield + (PNonTerminal nonTerm, + List.foldBack + (fun prodIdx acc -> match prodTab.Symbol prodIdx 0 with None -> Set.add None acc | Some _ -> acc) + prodTab.Productions.[nonTerm] + Set.empty) ] + + let add changed ss (x,y) = + let s = Map.find x ss + if Set.contains y s then ss + else (changed := true; Map.add x (Set.add y s) ss) + + let oneRound (ss:Map<_,_>) = + let changed = ref false + let frontier = + let res = ref [] + for nonTermX in ntTab.Indexes do + for prodIdx in prodTab.Productions.[nonTermX] do + let rhs = Array.toList (prodTab.Symbols prodIdx) + let rec place l = + match l with + | (yi::t) -> + res := + List.choose + (function None -> None | Some a -> Some (PNonTerminal nonTermX,Some a)) + (Set.toList ss.[yi]) + @ !res; + if ss.[yi].Contains(None) then place t; + | [] -> + res := (PNonTerminal nonTermX,None) :: !res + place rhs + !res + let ss' = List.fold (add changed) ss frontier + !changed, ss' + + let rec loop ss = + let changed, ss' = oneRound ss + if changed then loop ss' else ss' + loop seed + + + /// Compute the first set of the given sequence of non-terminals. If any of the non-terminals + /// have an empty token in the first set then we have to iterate through those. + let ComputeFirstSetOfTokenList = + Memoize (fun (str,term) -> + let acc = new System.Collections.Generic.List<_>() + let rec add l = + match l with + | [] -> acc.Add(term) + | sym::moreSyms -> + let firstSetOfSym = computedFirstTable.[sym] + firstSetOfSym |> Set.iter (function None -> () | Some v -> acc.Add(v)) + if firstSetOfSym.Contains(None) then add moreSyms + add str; + Set.ofSeq acc) + + // (int,int) representation of LR(0) items + let prodIdx_to_item0 idx = mkItem0(idx,0) + let prec_of_item0 item0 = prodTab.Precedence (prodIdx_of_item0 item0) + let ntIdx_of_item0 item0 = prodTab.NonTerminal (prodIdx_of_item0 item0) + + let lsyms_of_item0 item0 = + let prodIdx = prodIdx_of_item0 item0 + let dotIdx = dotIdx_of_item0 item0 + let syms = prodTab.Symbols prodIdx + if dotIdx <= 0 then [||] else syms.[..dotIdx-1] + + let rsyms_of_item0 item0 = + let prodIdx = prodIdx_of_item0 item0 + let dotIdx = dotIdx_of_item0 item0 + let syms = prodTab.Symbols prodIdx + syms.[dotIdx..] + + let rsym_of_item0 item0 = + let prodIdx = prodIdx_of_item0 item0 + let dotIdx = dotIdx_of_item0 item0 + prodTab.Symbol prodIdx dotIdx + + let advance_of_item0 item0 = + let prodIdx = prodIdx_of_item0 item0 + let dotIdx = dotIdx_of_item0 item0 + mkItem0(prodIdx,dotIdx+1) + let fakeStartNonTerminalsSet = Set.ofList (fakeStartNonTerminals |> List.map ntTab.ToIndex) + + let IsStartItem item0 = fakeStartNonTerminalsSet.Contains(ntIdx_of_item0 item0) + let IsKernelItem item0 = (IsStartItem item0 || dotIdx_of_item0 item0 <> 0) + + let StringOfSym sym = match sym with PTerminal s -> "'" ^ termTab.OfIndex s ^ "'" | PNonTerminal s -> ntTab.OfIndex s + + let OutputSym os sym = fprintf os "%s" (StringOfSym sym) + + let OutputSyms os syms = + fprintf os "%s" (String.Join(" ",Array.map StringOfSym syms)) + + // Print items and other stuff + let OutputItem0 os item0 = + fprintf os " %s -> %a . %a" (ntTab.OfIndex (ntIdx_of_item0 item0)) (* outputPrecInfo precInfo *) OutputSyms (lsyms_of_item0 item0) OutputSyms (rsyms_of_item0 item0) + + let OutputItem0Set os s = + Set.iter (fun item -> fprintfn os "%a" OutputItem0 item) s + + let OutputFirstSet os m = + Set.iter (function None -> fprintf os "" | Some x -> fprintfn os " term %s" x) m + + let OutputFirstMap os m = + Map.iter (fun x y -> fprintf os "first '%a' = " OutputSym x; fprintfn os "%a" OutputFirstSet y) m + + let OutputAction os m = + match m with + | Shift n -> fprintf os " shift %d" n + | Reduce prodIdx -> fprintf os " reduce %s --> %a" (ntTab.OfIndex (prodTab.NonTerminal prodIdx)) OutputSyms (prodTab.Symbols prodIdx) + | Error -> fprintf os " error" + | Accept -> fprintf os " accept" + + let OutputActions os m = + Array.iteri (fun i (prec,action) -> let term = termTab.OfIndex i in fprintfn os " action '%s' (%a): %a" term outputPrecInfo prec OutputAction action) m + + let OutputActionTable os m = + Array.iteri (fun i n -> fprintfn os "state %d:" i; fprintfn os "%a" OutputActions n) m + + let OutputImmediateActions os m = + match m with + | None -> fprintf os "" + | Some a -> OutputAction os a + + let OutputGotos os m = + Array.iteri (fun ntIdx s -> let nonterm = ntTab.OfIndex ntIdx in match s with Some st -> fprintfn os " goto %s: %d" nonterm st | None -> ()) m + + let OutputCombined os m = + Array.iteri (fun i (a,b,c,d) -> + fprintf os "state %d:" i + fprintf os " items:" + fprintf os "%a" OutputItem0Set a + fprintf os " actions:" + fprintf os "%a" OutputActions b + fprintf os " immediate action: " + fprintf os "%a" OutputImmediateActions c + fprintf os " gotos:" + fprintf os "%a" OutputGotos d) m + + let OutputLalrTables os (prods,states, startStates,actionTable,immediateActionTable,gotoTable,endOfInputTerminalIdx,errorTerminalIdx) = + let combined = Array.ofList (List.map2 (fun x (y,(z,w)) -> x,y,z,w) (Array.toList states) (List.zip (Array.toList actionTable) (List.zip (Array.toList immediateActionTable) (Array.toList gotoTable)))) + fprintfn os "------------------------"; + fprintfn os "states = "; + fprintfn os "%a" OutputCombined combined; + fprintfn os "startStates = %s" (String.Join(";",Array.ofList (List.map string startStates))); + fprintfn os "------------------------" + + + // Closure of LR(0) nonTerminals, items etc + let ComputeClosure0NonTerminal = + Memoize (fun nt -> + let seed = (List.foldBack (prodIdx_to_item0 >> Set.add) prodTab.Productions.[nt] Set.empty) + LeastFixedPoint + (fun item0 -> + match rsym_of_item0 item0 with + | None -> [] + | Some(PNonTerminal ntB) -> List.map prodIdx_to_item0 prodTab.Productions.[ntB] + | Some(PTerminal _) -> []) + seed) + + // Close a symbol under epsilon moves + let ComputeClosure0Symbol rsym acc = + match rsym with + | Some (PNonTerminal nt) -> Set.union (ComputeClosure0NonTerminal nt) acc + | _ -> acc + + // Close a set under epsilon moves + let ComputeClosure0 iset = + Set.fold (fun acc x -> ComputeClosure0Symbol (rsym_of_item0 x) acc) iset iset + + // Right symbols after closing under epsilon moves + let RelevantSymbolsOfKernel kernel = + let kernelClosure0 = ComputeClosure0 kernel + Set.fold (fun acc x -> Option.fold (fun acc x -> Set.add x acc) acc (rsym_of_item0 x)) Set.empty kernelClosure0 + + // Goto set of a kernel of LR(0) nonTerminals, items etc + // Input is kernel, output is kernel + let ComputeGotosOfKernel iset sym = + let isetClosure = ComputeClosure0 iset + let acc = new System.Collections.Generic.List<_>(10) + isetClosure |> Set.iter (fun item0 -> + match rsym_of_item0 item0 with + | Some sym2 when sym = sym2 -> acc.Add(advance_of_item0 item0) + | _ -> ()) + Set.ofSeq acc + + // Build the full set of LR(0) kernels + reportTime(); printf "building kernels..."; stdout.Flush(); + let startItems = List.mapi (fun i _ -> prodIdx_to_item0 (startNonTerminalIdx_to_prodIdx i)) fakeStartNonTerminals + let startKernels = List.map Set.singleton startItems + let kernels = + + /// We use a set-of-sets here. F# sets support structural comparison but at the time of writing + /// did not structural hashing. + let acc = ref Set.empty + ProcessWorkList startKernels (fun addToWorkList kernel -> + if not ((!acc).Contains(kernel)) then + acc := (!acc).Add(kernel); + for csym in RelevantSymbolsOfKernel kernel do + let gotoKernel = ComputeGotosOfKernel kernel csym + assert (gotoKernel.Count > 0) + addToWorkList gotoKernel ) + + !acc |> Seq.toList |> List.map (Set.filter IsKernelItem) + + reportTime(); printf "building kernel table..."; stdout.Flush(); + // Give an index to each LR(0) kernel, and from now on refer to them only by index + let kernelTab = new KernelTable(kernels) + let startKernelIdxs = List.map kernelTab.Index startKernels + let startKernelItemIdxs = List.map2 (fun a b -> KernelItemIdx(a,b)) startKernelIdxs startItems + + let outputKernelItemIdx os (kernelIdx,item0) = + fprintf os "kernel %d, item %a" kernelIdx OutputItem0 item0 + + /// A cached version of the "goto" computation on LR(0) kernels + let gotoKernel = + Memoize (fun (GotoItemIdx(kernelIdx,sym)) -> + let gset = ComputeGotosOfKernel (kernelTab.Kernel kernelIdx) sym + if gset.IsEmpty then None else Some (kernelTab.Index gset)) + + /// Iterate (iset,sym) pairs such that (gotoKernel kernelIdx sym) is not empty + let IterateGotosOfKernel kernelIdx f = + for sym in RelevantSymbolsOfKernel (kernelTab.Kernel kernelIdx) do + match gotoKernel (GotoItemIdx(kernelIdx,sym)) with + | None -> () + | Some k -> f sym k + + + // This is used to compute the closure of an LALR(1) kernel + // + // For each item [A --> X.BY, a] in I + // For each production B -> g in G' + // For each terminal b in FIRST(Ya) + // such that [B --> .g, b] is not in I do + // add [B --> .g, b] to I + + let ComputeClosure1 iset = + let acc = new Closure1Table() + ProcessWorkList iset (fun addToWorkList (item0,pretokens:Set) -> + pretokens |> Set.iter (fun pretoken -> + if not (acc.Contains(item0,pretoken)) then + acc.Add(item0,pretoken) |> ignore + let rsyms = rsyms_of_item0 item0 + if rsyms.Length > 0 then + match rsyms.[0] with + | (PNonTerminal ntB) -> + let firstSet = ComputeFirstSetOfTokenList (Array.toList rsyms.[1..],pretoken) + for prodIdx in prodTab.Productions.[ntB] do + addToWorkList (prodIdx_to_item0 prodIdx,firstSet) + | PTerminal _ -> ())) + acc + + // Compute the "spontaneous" and "propagate" maps for each LR(0) kernelItem + // + // Input: The kernal K of a set of LR(0) items I and a grammar symbol X + // + // Output: The lookaheads generated spontaneously by items in I for kernel items + // in goto(I,X) and the items I from which lookaheads are propagated to kernel + // items in goto(I,X) + // + // Method + // 1. Construct LR(0) kernel items (done - above) + // 2. + // TODO: this is very, very slow. + // + // PLAN TO OPTIMIZE THIS; + // - Clarify and comment what's going on here + // - verify if we really have to do these enormouos closure computations + // - assess if it's possible to use the symbol we're looking for to help trim the jset + + reportTime(); printf "computing lookahead relations..."; stdout.Flush(); + + + let spontaneous, propagate = + let closure1OfItem0WithDummy = + Memoize (fun item0 -> ComputeClosure1 [(item0,Set.ofList [dummyLookaheadIdx])]) + + let spontaneous = new SpontaneousTable() + let propagate = new PropagateTable() + let count = ref 0 + + for kernelIdx in kernelTab.Indexes do + printf "."; stdout.Flush(); + //printf "kernelIdx = %d\n" kernelIdx; stdout.Flush(); + let kernel = kernelTab.Kernel(kernelIdx) + for item0 in kernel do + let item0Idx = KernelItemIdx(kernelIdx,item0) + let jset = closure1OfItem0WithDummy item0 + //printf "#jset = %d\n" jset.Count; stdout.Flush(); + for (KeyValue(closureItem0, lookaheadTokens)) in jset.IEnumerable do + incr count + match rsym_of_item0 closureItem0 with + | None -> () + | Some rsym -> + match gotoKernel (GotoItemIdx(kernelIdx,rsym)) with + | None -> () + | Some gotoKernelIdx -> + let gotoItem = advance_of_item0 closureItem0 + let gotoItemIdx = KernelItemIdx(gotoKernelIdx,gotoItem) + for lookaheadToken in lookaheadTokens do + if lookaheadToken = dummyLookaheadIdx + then propagate.Add(item0Idx, gotoItemIdx) |> ignore + else spontaneous.Add(gotoItemIdx, lookaheadToken) |> ignore + + + //printfn "#kernelIdxs = %d, count = %d" kernelTab.Indexes.Length !count + spontaneous, + propagate + + //printfn "#spontaneous = %d, #propagate = %d" spontaneous.Count propagate.Count; stdout.Flush(); + + //exit 0; + // Repeatedly use the "spontaneous" and "propagate" maps to build the full set + // of lookaheads for each LR(0) kernelItem. + reportTime(); printf "building lookahead table..."; stdout.Flush(); + let lookaheadTable = + + // Seed the table with the startKernelItems and the spontaneous info + let initialWork = + [ for idx in startKernelItemIdxs do + yield (idx,endOfInputTerminalIdx) + for (KeyValue(kernelItemIdx,lookaheads)) in spontaneous.IEnumerable do + for lookahead in lookaheads do + yield (kernelItemIdx,lookahead) ] + + let acc = new LookaheadTable() + // Compute the closure + ProcessWorkList + initialWork + (fun queueWork (kernelItemIdx,lookahead) -> + acc.Add(kernelItemIdx,lookahead) + for gotoKernelIdx in propagate.[kernelItemIdx] do + if not (acc.Contains(gotoKernelIdx,lookahead)) then + queueWork(gotoKernelIdx,lookahead)) + acc + + //printf "built lookahead table, #lookaheads = %d\n" lookaheadTable.Count; stdout.Flush(); + + reportTime(); printf "building action table..."; stdout.Flush(); + let shiftReduceConflicts = ref 0 + let reduceReduceConflicts = ref 0 + let actionTable, immediateActionTable = + + // Now build the action tables. First a utility to merge the given action + // into the table, taking into account precedences etc. and reporting errors. + let addResolvingPrecedence (arr: _[]) kernelIdx termIdx (precNew, actionNew) = + // printf "DEBUG: state %d: adding action for %s, precNew = %a, actionNew = %a\n" kernelIdx (termTab.OfIndex termIdx) outputPrec precNew OutputAction actionNew; + // We add in order of precedence - however the precedences may be the same, and we give warnings when rpecedence resolution is based on implicit file orderings + + let (precSoFar, actionSoFar) as itemSoFar = arr.[termIdx] + + // printf "DEBUG: state %d: adding action for %s, precNew = %a, precSoFar = %a, actionSoFar = %a\n" kernelIdx (termTab.OfIndex termIdx) outputPrec precNew outputPrec precSoFar OutputAction actionSoFar; + // if compare_prec precSoFar precNew = -1 then failwith "addResolvingPrecedence"; + + let itemNew = (precNew, actionNew) + let winner = + let reportConflict x1 x2 reason = + let reportAction (p, a) = + let an, astr = + match a with + | Shift x -> "shift", sprintf "shift(%d)" x + | Reduce x -> + let nt = prodTab.NonTerminal x + "reduce", prodTab.Symbols x + |> Array.map StringOfSym + |> String.concat " " + |> sprintf "reduce(%s:%s)" (ntTab.OfIndex nt) + | _ -> "", "" + let pstr = + match p with + | ExplicitPrec (assoc,n) -> + let astr = + match assoc with + | LeftAssoc -> "left" + | RightAssoc -> "right" + | NonAssoc -> "nonassoc" + sprintf "[explicit %s %d]" astr n + | NoPrecedence -> + "noprec" + an, "{" + pstr + " " + astr + "}" + let a1n, astr1 = reportAction x1 + let a2n, astr2 = reportAction x2 + printfn " %s/%s error at state %d on terminal %s between %s and %s - assuming the former because %s" a1n a2n kernelIdx (termTab.OfIndex termIdx) astr1 astr2 reason + match itemSoFar,itemNew with + | (_,Shift s1),(_, Shift s2) -> + if actionSoFar <> actionNew then + reportConflict itemSoFar itemNew "internal error" + itemSoFar + + | (((precShift,Shift sIdx) as shiftItem), + ((precReduce,Reduce prodIdx) as reduceItem)) + | (((precReduce,Reduce prodIdx) as reduceItem), + ((precShift,Shift sIdx) as shiftItem)) -> + match precReduce, precShift with + | (ExplicitPrec (_,p1), ExplicitPrec(assocNew,p2)) -> + if p1 < p2 then shiftItem + elif p1 > p2 then reduceItem + else + match assocNew with + | LeftAssoc -> reduceItem + | RightAssoc -> shiftItem + | NonAssoc -> + reportConflict shiftItem reduceItem "we prefer shift on equal precedences" + incr shiftReduceConflicts; + shiftItem + | _ -> + reportConflict shiftItem reduceItem "we prefer shift when unable to compare precedences" + incr shiftReduceConflicts; + shiftItem + | ((_,Reduce prodIdx1),(_, Reduce prodIdx2)) -> + "we prefer the rule earlier in the file" + |> if prodIdx1 < prodIdx2 then reportConflict itemSoFar itemNew else reportConflict itemNew itemSoFar + incr reduceReduceConflicts; + if prodIdx1 < prodIdx2 then itemSoFar else itemNew + | _ -> itemNew + arr.[termIdx] <- winner + + + // This build the action table for one state. + let ComputeActions kernelIdx = + let kernel = kernelTab.Kernel kernelIdx + let arr = Array.create terminals.Length (NoPrecedence,Error) + + //printf "building lookahead table LR(1) items for kernelIdx %d\n" kernelIdx; stdout.Flush(); + + // Compute the LR(1) items based on lookaheads + let items = + [ for item0 in kernel do + let kernelItemIdx = KernelItemIdx(kernelIdx,item0) + let lookaheads = lookaheadTable.GetLookaheads(kernelItemIdx) + yield (item0,lookaheads) ] + |> ComputeClosure1 + + for (KeyValue(item0,lookaheads)) in items.IEnumerable do + + let nonTermA = ntIdx_of_item0 item0 + match rsym_of_item0 item0 with + | Some (PTerminal termIdx) -> + let action = + match gotoKernel (GotoItemIdx(kernelIdx,PTerminal termIdx)) with + | None -> failwith "action on terminal should have found a non-empty goto state" + | Some gkernelItemIdx -> Shift gkernelItemIdx + let prec = termTab.PrecInfoOfIndex termIdx + addResolvingPrecedence arr kernelIdx termIdx (prec, action) + | None -> + for lookahead in lookaheads do + if not (IsStartItem(item0)) then + let prodIdx = prodIdx_of_item0 item0 + let prec = prec_of_item0 item0 + let action = (prec, Reduce prodIdx) + addResolvingPrecedence arr kernelIdx lookahead action + elif lookahead = endOfInputTerminalIdx then + let prec = prec_of_item0 item0 + let action = (prec,Accept) + addResolvingPrecedence arr kernelIdx lookahead action + else () + | _ -> () + + // If there is a single item A -> B C . and no Shift or Accept actions (i.e. only Error or Reduce, so the choice of terminal + // cannot affect what we do) then we emit an immediate reduce action for the rule corresponding to that item + // Also do the same for Accept rules. + let closure = (ComputeClosure0 kernel) + + let immediateAction = + match Set.toList closure with + | [item0] -> + match (rsym_of_item0 item0) with + | None when (let reduceOrErrorAction = function Error | Reduce _ -> true | Shift _ | Accept -> false + termTab.Indexes |> List.forall(fun terminalIdx -> reduceOrErrorAction (snd(arr.[terminalIdx])))) + -> Some (Reduce (prodIdx_of_item0 item0)) + + | None when (let acceptOrErrorAction = function Error | Accept -> true | Shift _ | Reduce _ -> false + List.forall (fun terminalIdx -> acceptOrErrorAction (snd(arr.[terminalIdx]))) termTab.Indexes) + -> Some Accept + + | _ -> None + | _ -> None + + // A -> B C . rules give rise to reductions in favour of errors + for item0 in ComputeClosure0 kernel do + let prec = prec_of_item0 item0 + match rsym_of_item0 item0 with + | None -> + for terminalIdx in termTab.Indexes do + if snd(arr.[terminalIdx]) = Error then + let prodIdx = prodIdx_of_item0 item0 + let action = (prec, (if IsStartItem(item0) then Accept else Reduce prodIdx)) + addResolvingPrecedence arr kernelIdx terminalIdx action + | _ -> () + + arr,immediateAction + + let actionInfo = List.map ComputeActions kernelTab.Indexes + Array.ofList (List.map fst actionInfo), + Array.ofList (List.map snd actionInfo) + + // The goto table is much simpler - it is based on LR(0) kernels alone. + + reportTime(); printf " building goto table..."; stdout.Flush(); + let gotoTable = + let gotos kernelIdx = Array.ofList (List.map (fun nt -> gotoKernel (GotoItemIdx(kernelIdx,PNonTerminal nt))) ntTab.Indexes) + Array.ofList (List.map gotos kernelTab.Indexes) + + reportTime(); printfn " returning tables."; stdout.Flush(); + if !shiftReduceConflicts > 0 then printfn " %d shift/reduce conflicts" !shiftReduceConflicts; stdout.Flush(); + if !reduceReduceConflicts > 0 then printfn " %d reduce/reduce conflicts" !reduceReduceConflicts; stdout.Flush(); + if !shiftReduceConflicts > 0 || !reduceReduceConflicts > 0 then printfn " consider setting precedences explicitly using %%left %%right and %%nonassoc on terminals and/or setting explicit precedence on rules using %%prec" + + /// The final results + let states = kernels |> Array.ofList + let prods = Array.ofList (List.map (fun (Production(nt,prec,syms,code)) -> (nt, ntTab.ToIndex nt, syms,code)) prods) + + logf (fun logStream -> + printfn "writing tables to log"; stdout.Flush(); + OutputLalrTables logStream (prods, states, startKernelIdxs, actionTable, immediateActionTable, gotoTable, (termTab.ToIndex endOfInputTerminal), errorTerminalIdx)); + + let states = states |> Array.map (Set.toList >> List.map prodIdx_of_item0) + (prods, states, startKernelIdxs, + actionTable, immediateActionTable, gotoTable, + (termTab.ToIndex endOfInputTerminal), + errorTerminalIdx, nonTerminals) + + +(* Some examples for testing *) + +(* + +let example1 = + let e = "E" + let t = "Terminal" + let plus = "+" + let mul = "*" + let f = "F" + let lparen = "(" + let rparen = ")" + let id = "id" + + let terminals = [plus; mul; lparen; rparen; id] + let nonTerminals = [e; t; f] + + let p2 = e, (NonAssoc, ExplicitPrec 1), [NonTerminal e; Terminal plus; NonTerminal t], None + let p3 = e, (NonAssoc, ExplicitPrec 2), [NonTerminal t], None in + let p4 = t, (NonAssoc, ExplicitPrec 3), [NonTerminal t; Terminal mul; NonTerminal f], None + let p5 = t, (NonAssoc, ExplicitPrec 4), [NonTerminal f], None + let p6 = f, (NonAssoc, ExplicitPrec 5), [Terminal lparen; NonTerminal e; Terminal rparen], None + let p7 = f, (NonAssoc, ExplicitPrec 6), [Terminal id], None + + let prods = [p2;p3;p4;p5;p6;p7] + Spec(terminals,nonTerminals,prods, [e]) + +let example2 = + let prods = [ "S", (NonAssoc, ExplicitPrec 1), [NonTerminal "C";NonTerminal "C"], None; + "C", (NonAssoc, ExplicitPrec 2), [Terminal "c";NonTerminal "C"], None ; + "C", (NonAssoc, ExplicitPrec 3), [Terminal "d"] , None ]in + Spec(["c";"d"],["S";"C"],prods, ["S"]) + +let example3 = + let terminals = ["+"; "*"; "("; ")"; "id"] + let nonTerminals = ["E"; "Terminal"; "E'"; "F"; "Terminal'"] + let prods = [ "E", (NonAssoc, ExplicitPrec 1), [ NonTerminal "Terminal"; NonTerminal "E'" ], None; + "E'", (NonAssoc, ExplicitPrec 2), [ Terminal "+"; NonTerminal "Terminal"; NonTerminal "E'"], None; + "E'", (NonAssoc, ExplicitPrec 3), [ ], None; + "Terminal", (NonAssoc, ExplicitPrec 4), [ NonTerminal "F"; NonTerminal "Terminal'" ], None; + "Terminal'", (NonAssoc, ExplicitPrec 5), [ Terminal "*"; NonTerminal "F"; NonTerminal "Terminal'"], None; + "Terminal'", (NonAssoc, ExplicitPrec 6), [ ], None; + "F", (NonAssoc, ExplicitPrec 7), [ Terminal "("; NonTerminal "E"; Terminal ")"], None; + "F", (NonAssoc, ExplicitPrec 8), [ Terminal "id"], None ] + Spec(terminals,nonTerminals,prods, ["E"]) + +let example4 = + let terminals = ["+"; "*"; "("; ")"; "id"] + let nonTerminals = ["E"] + let prods = [ "E", (NonAssoc, ExplicitPrec 1), [ NonTerminal "E"; Terminal "+"; NonTerminal "E" ], None; + "E", (NonAssoc, ExplicitPrec 2), [ NonTerminal "E"; Terminal "*"; NonTerminal "E" ], None; + "E", (NonAssoc, ExplicitPrec 3), [ Terminal "("; NonTerminal "E"; Terminal ")"], None; + "E", (NonAssoc, ExplicitPrec 8), [ Terminal "id"], None ] + Spec(terminals,nonTerminals,prods, ["E"]) + +let example5 = + let terminals = ["+"; "*"; "("; ")"; "id"] + let nonTerminals = ["E"] + let prods = [ "E", (NonAssoc, ExplicitPrec 1), [ NonTerminal "E"; Terminal "+"; NonTerminal "E" ], None; + "E", (NonAssoc, ExplicitPrec 2), [ NonTerminal "E"; Terminal "*"; NonTerminal "E" ], None; + "E", (NonAssoc, ExplicitPrec 3), [ Terminal "("; NonTerminal "E"; Terminal ")"], None; + "E", (NonAssoc, ExplicitPrec 8), [ Terminal "id"], None ] + Spec(terminals,nonTerminals,prods, ["E"]) + +let example6 = + let terminals = ["+"; "*"; "("; ")"; "id"; "-"] + let nonTerminals = ["E"] + let prods = [ "E", (RightAssoc, ExplicitPrec 1), [ NonTerminal "E"; Terminal "-"; NonTerminal "E" ], None; + "E", (LeftAssoc, ExplicitPrec 1), [ NonTerminal "E"; Terminal "+"; NonTerminal "E" ], None; + "E", (LeftAssoc, ExplicitPrec 2), [ NonTerminal "E"; Terminal "*"; NonTerminal "E" ], None; + "E", (NonAssoc, ExplicitPrec 3), [ Terminal "("; NonTerminal "E"; Terminal ")"], None; + "E", (NonAssoc, ExplicitPrec 8), [ Terminal "id"], None ] + Spec(terminals,nonTerminals,prods, ["E"]) + + +let example7 = + let prods = [ "S", (NonAssoc, ExplicitPrec 1), [NonTerminal "L";Terminal "="; NonTerminal "R"], None; + "S", (NonAssoc, ExplicitPrec 2), [NonTerminal "R"], None ; + "L", (NonAssoc, ExplicitPrec 3), [Terminal "*"; NonTerminal "R"], None; + "L", (NonAssoc, ExplicitPrec 3), [Terminal "id"], None; + "R", (NonAssoc, ExplicitPrec 3), [NonTerminal "L"], None; ] + Spec(["*";"=";"id"],["S";"L";"R"],prods, ["S"]) + + + +let test ex = CompilerLalrParserSpec stdout ex + +(* let _ = test example2*) +(* let _ = exit 1*) +(* let _ = test example3 +let _ = test example1 +let _ = test example4 +let _ = test example5 +let _ = test example6 *) +*) diff --git a/src/buildtools/fsyacc/fsyacclex.fs b/src/buildtools/fsyacc/fsyacclex.fs new file mode 100644 index 0000000000..a035f6fe01 --- /dev/null +++ b/src/buildtools/fsyacc/fsyacclex.fs @@ -0,0 +1,644 @@ +# 1 "fsyacclex.fsl" + +(* (c) Microsoft Corporation 2005-2008. *) + +module internal FsLexYacc.FsYacc.Lexer + +open FsLexYacc.FsYacc.AST +open FsLexYacc.FsYacc.Parser +open System.Text +open Internal.Utilities.Text.Lexing + +let lexeme (lexbuf : LexBuffer) = new System.String(lexbuf.Lexeme) +let newline (lexbuf:LexBuffer<_>) = lexbuf.EndPos <- lexbuf.EndPos.NextLine + +let unexpected_char lexbuf = + failwith ("Unexpected character '"+(lexeme lexbuf)+"'") + +let typeDepth = ref 0 +let startPos = ref Position.Empty +let mutable str_buf = new System.Text.StringBuilder() + +let appendBuf (str:string) = str_buf.Append str |> ignore +let clearBuf () = str_buf <- new System.Text.StringBuilder() + + +# 26 "fsyacclex.fs" +let trans : uint16[] array = + [| + (* State 0 *) + [| 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 2us; 6us; 6us; 3us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 7us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 4us; 6us; 6us; 6us; 6us; 1us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 6us; 5us; |]; + (* State 1 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 11us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 2 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 3 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 10us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 4 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 9us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 5 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 6 *) + [| 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; |]; + (* State 7 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 8 *) + [| 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 65535us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 8us; 65535us; |]; + (* State 9 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 10 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 11 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 12 *) + [| 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 17us; 15us; 19us; 19us; 16us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 17us; 19us; 14us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 19us; 13us; 19us; 19us; 19us; 19us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 17us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 19us; 18us; |]; + (* State 13 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 14 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 15 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 16 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 21us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 17 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 18 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 19 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 20 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 21 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 22 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 23 *) + [| 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 30us; 26us; 33us; 33us; 27us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 30us; 33us; 29us; 33us; 33us; 33us; 33us; 28us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 31us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 33us; 33us; 33us; 33us; 33us; 33us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 25us; 33us; 24us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 32us; |]; + (* State 24 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 25 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 26 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 27 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 41us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 28 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 37us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 38us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 29 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 30 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 31 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 34us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 32 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 33 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 34 *) + [| 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 65535us; 35us; 35us; 65535us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 65535us; |]; + (* State 35 *) + [| 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 65535us; 35us; 35us; 65535us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 35us; 65535us; |]; + (* State 36 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 37 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 40us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 38 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 39us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 39 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 40us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 40 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 41 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 42 *) + [| 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 46us; 44us; 51us; 51us; 45us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 46us; 51us; 49us; 51us; 51us; 43us; 51us; 48us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 47us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 51us; 51us; 51us; 51us; 51us; 51us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 46us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 51us; 50us; |]; + (* State 43 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 60us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 44 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 45 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 59us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 46 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 47 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 56us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 48 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 52us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 53us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 49 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 50 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 51 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 52 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 55us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 53 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 54us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 54 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 55us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 55 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 56 *) + [| 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 65535us; 57us; 57us; 65535us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 65535us; |]; + (* State 57 *) + [| 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 65535us; 57us; 57us; 65535us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 57us; 65535us; |]; + (* State 58 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 58us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 59 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 60 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 61 *) + [| 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 62us; 64us; 63us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 64us; 65535us; |]; + (* State 62 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 63 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 64 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 65 *) + [| 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 72us; 73us; 79us; 79us; 74us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 72us; 79us; 79us; 79us; 79us; 66us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 77us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 78us; 70us; 68us; 79us; 69us; 79us; 79us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 79us; 79us; 79us; 79us; 79us; 79us; 75us; 75us; 75us; 75us; 67us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 75us; 71us; 76us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 79us; 80us; |]; + (* State 66 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 92us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 96us; 65535us; 98us; 65535us; 95us; 65535us; 97us; 94us; 93us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 91us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 67 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 87us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 68 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 69 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 70 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 71 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 72 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 86us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 86us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 73 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 74 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 85us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 75 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 76 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 77 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 81us; 65535us; 65535us; 65535us; 65535us; 82us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 78 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 79 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 80 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 81 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 82 *) + [| 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 65535us; 83us; 83us; 65535us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 65535us; |]; + (* State 83 *) + [| 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 65535us; 83us; 83us; 65535us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 83us; 65535us; |]; + (* State 84 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 85 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 86 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 86us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 86us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 87 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 88us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 88 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 89us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 89 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 90us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 90 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 84us; 65535us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 84us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 91 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 92 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 93 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 120us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 121us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 94 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 116us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 95 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 113us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 96 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 110us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 97 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 106us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 98 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 99us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 99 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 100us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 100 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 101us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 101 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 102us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 102 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 103us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 103 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 104us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 104 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 105us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 105 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 106 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 107us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 107 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 108us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 108 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 109us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 109 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 110 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 111us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 111 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 112us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 112 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 113 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 114us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 114 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 115us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 115 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 116 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 117us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 117 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 118us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 118 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 119us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 119 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 120 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 126us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 121 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 122us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 122 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 123us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 123 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 125us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 125us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 124us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 124 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 125 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 125us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 125us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 124us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 126 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 127us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 127 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 128us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 128 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 130us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 130us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 129us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 129 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + (* State 130 *) + [| 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 130us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 130us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 129us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |]; + |] +let actions : uint16[] = [|65535us; 5us; 1us; 5us; 5us; 3us; 4us; 5us; 4us; 2us; 1us; 0us; 65535us; 5us; 1us; 2us; 5us; 3us; 4us; 5us; 3us; 2us; 0us; 65535us; 0us; 1us; 2us; 8us; 8us; 4us; 5us; 8us; 7us; 8us; 6us; 6us; 5us; 65535us; 65535us; 65535us; 3us; 2us; 65535us; 7us; 1us; 7us; 2us; 7us; 7us; 5us; 6us; 7us; 65535us; 65535us; 65535us; 4us; 3us; 3us; 2us; 1us; 0us; 65535us; 0us; 1us; 2us; 65535us; 22us; 17us; 11us; 12us; 13us; 14us; 15us; 16us; 22us; 17us; 18us; 22us; 21us; 22us; 23us; 19us; 20us; 20us; 17us; 16us; 15us; 17us; 17us; 17us; 10us; 0us; 1us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 9us; 65535us; 65535us; 65535us; 8us; 65535us; 65535us; 7us; 65535us; 65535us; 5us; 65535us; 65535us; 65535us; 4us; 65535us; 65535us; 65535us; 65535us; 6us; 65535us; 65535us; 65535us; 3us; 2us; 65535us; |] +let _fslex_tables = Internal.Utilities.Text.Lexing.UnicodeTables.Create(trans,actions) +let rec _fslex_dummy () = _fslex_dummy() +(* Rule token *) +and token (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_token 65 lexbuf +(* Rule fs_type *) +and fs_type (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_fs_type 61 lexbuf +(* Rule header *) +and header p buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_header p buff 42 lexbuf +(* Rule code *) +and code p buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_code p buff 23 lexbuf +(* Rule codestring *) +and codestring buff (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_codestring buff 12 lexbuf +(* Rule comment *) +and comment (lexbuf : Internal.Utilities.Text.Lexing.LexBuffer<_>) = _fslex_comment 0 lexbuf +(* Rule token *) +and _fslex_token _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 35 "fsyacclex.fsl" + let p = lexbuf.StartPos in header p (new StringBuilder 100) lexbuf +# 313 "fsyacclex.fs" + ) + | 1 -> ( +# 36 "fsyacclex.fsl" + PERCENT_PERCENT +# 318 "fsyacclex.fs" + ) + | 2 -> ( +# 37 "fsyacclex.fsl" + typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TOKEN (fs_type lexbuf) +# 323 "fsyacclex.fs" + ) + | 3 -> ( +# 38 "fsyacclex.fsl" + TOKEN (None) +# 328 "fsyacclex.fs" + ) + | 4 -> ( +# 39 "fsyacclex.fsl" + START +# 333 "fsyacclex.fs" + ) + | 5 -> ( +# 40 "fsyacclex.fsl" + PREC +# 338 "fsyacclex.fs" + ) + | 6 -> ( +# 41 "fsyacclex.fsl" + typeDepth := 1; startPos := lexbuf.StartPos; clearBuf(); TYPE (match fs_type lexbuf with Some x -> x | None -> failwith "gettype") +# 343 "fsyacclex.fs" + ) + | 7 -> ( +# 42 "fsyacclex.fsl" + LEFT +# 348 "fsyacclex.fs" + ) + | 8 -> ( +# 43 "fsyacclex.fsl" + RIGHT +# 353 "fsyacclex.fs" + ) + | 9 -> ( +# 44 "fsyacclex.fsl" + NONASSOC +# 358 "fsyacclex.fs" + ) + | 10 -> ( +# 45 "fsyacclex.fsl" + ERROR +# 363 "fsyacclex.fs" + ) + | 11 -> ( +# 46 "fsyacclex.fsl" + LESS +# 368 "fsyacclex.fs" + ) + | 12 -> ( +# 47 "fsyacclex.fsl" + GREATER +# 373 "fsyacclex.fs" + ) + | 13 -> ( +# 48 "fsyacclex.fsl" + SEMI +# 378 "fsyacclex.fs" + ) + | 14 -> ( +# 49 "fsyacclex.fsl" + let p = lexbuf.StartPos in + let buff = (new StringBuilder 100) in + // adjust the first line to get even indentation for all lines w.r.t. the left hand margin + buff.Append (String.replicate (lexbuf.StartPos.Column+1) " ") |> ignore; + code p buff lexbuf +# 387 "fsyacclex.fs" + ) + | 15 -> ( +# 54 "fsyacclex.fsl" + token lexbuf +# 392 "fsyacclex.fs" + ) + | 16 -> ( +# 55 "fsyacclex.fsl" + newline lexbuf; token lexbuf +# 397 "fsyacclex.fs" + ) + | 17 -> ( +# 56 "fsyacclex.fsl" + IDENT (lexeme lexbuf) +# 402 "fsyacclex.fs" + ) + | 18 -> ( +# 57 "fsyacclex.fsl" + BAR +# 407 "fsyacclex.fs" + ) + | 19 -> ( +# 58 "fsyacclex.fsl" + ignore(comment lexbuf); token lexbuf +# 412 "fsyacclex.fs" + ) + | 20 -> ( +# 59 "fsyacclex.fsl" + token lexbuf +# 417 "fsyacclex.fs" + ) + | 21 -> ( +# 60 "fsyacclex.fsl" + COLON +# 422 "fsyacclex.fs" + ) + | 22 -> ( +# 61 "fsyacclex.fsl" + unexpected_char lexbuf +# 427 "fsyacclex.fs" + ) + | 23 -> ( +# 62 "fsyacclex.fsl" + EOF +# 432 "fsyacclex.fs" + ) + | _ -> failwith "token" +(* Rule fs_type *) +and _fslex_fs_type _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 65 "fsyacclex.fsl" + incr typeDepth; appendBuf(lexeme lexbuf); fs_type lexbuf +# 441 "fsyacclex.fs" + ) + | 1 -> ( +# 67 "fsyacclex.fsl" + decr typeDepth; + if !typeDepth = 0 + then Some(string str_buf) + else appendBuf(lexeme lexbuf); fs_type lexbuf +# 449 "fsyacclex.fs" + ) + | 2 -> ( +# 71 "fsyacclex.fsl" + appendBuf(lexeme lexbuf); fs_type lexbuf +# 454 "fsyacclex.fs" + ) + | _ -> failwith "fs_type" +(* Rule header *) +and _fslex_header p buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 74 "fsyacclex.fsl" + HEADER (buff.ToString(), p) +# 463 "fsyacclex.fs" + ) + | 1 -> ( +# 75 "fsyacclex.fsl" + newline lexbuf; + ignore <| buff.Append System.Environment.NewLine; + header p buff lexbuf +# 470 "fsyacclex.fs" + ) + | 2 -> ( +# 79 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + header p buff lexbuf +# 476 "fsyacclex.fs" + ) + | 3 -> ( +# 82 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + header p buff lexbuf +# 482 "fsyacclex.fs" + ) + | 4 -> ( +# 85 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + header p buff lexbuf +# 488 "fsyacclex.fs" + ) + | 5 -> ( +# 88 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + ignore(codestring buff lexbuf); + header p buff lexbuf +# 495 "fsyacclex.fs" + ) + | 6 -> ( +# 91 "fsyacclex.fsl" + EOF +# 500 "fsyacclex.fs" + ) + | 7 -> ( +# 92 "fsyacclex.fsl" + ignore <| buff.Append(lexeme lexbuf).[0]; + header p buff lexbuf +# 506 "fsyacclex.fs" + ) + | _ -> failwith "header" +(* Rule code *) +and _fslex_code p buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 95 "fsyacclex.fsl" + CODE (buff.ToString(), p) +# 515 "fsyacclex.fs" + ) + | 1 -> ( +# 96 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + ignore(code p buff lexbuf); + ignore <| buff.Append "}"; + code p buff lexbuf +# 523 "fsyacclex.fs" + ) + | 2 -> ( +# 100 "fsyacclex.fsl" + newline lexbuf; + ignore <| buff.Append System.Environment.NewLine; + code p buff lexbuf +# 530 "fsyacclex.fs" + ) + | 3 -> ( +# 104 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + code p buff lexbuf +# 536 "fsyacclex.fs" + ) + | 4 -> ( +# 106 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + ignore(codestring buff lexbuf); + code p buff lexbuf +# 543 "fsyacclex.fs" + ) + | 5 -> ( +# 110 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + code p buff lexbuf +# 549 "fsyacclex.fs" + ) + | 6 -> ( +# 113 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + code p buff lexbuf +# 555 "fsyacclex.fs" + ) + | 7 -> ( +# 115 "fsyacclex.fsl" + EOF +# 560 "fsyacclex.fs" + ) + | 8 -> ( +# 116 "fsyacclex.fsl" + ignore <| buff.Append(lexeme lexbuf).[0]; + code p buff lexbuf +# 566 "fsyacclex.fs" + ) + | _ -> failwith "code" +(* Rule codestring *) +and _fslex_codestring buff _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 122 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + codestring buff lexbuf +# 576 "fsyacclex.fs" + ) + | 1 -> ( +# 124 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + buff.ToString() +# 582 "fsyacclex.fs" + ) + | 2 -> ( +# 126 "fsyacclex.fsl" + newline lexbuf; + ignore <| buff.Append System.Environment.NewLine; + codestring buff lexbuf +# 589 "fsyacclex.fs" + ) + | 3 -> ( +# 130 "fsyacclex.fsl" + ignore <| buff.Append (lexeme lexbuf); + codestring buff lexbuf +# 595 "fsyacclex.fs" + ) + | 4 -> ( +# 132 "fsyacclex.fsl" + failwith "unterminated string in code" +# 600 "fsyacclex.fs" + ) + | 5 -> ( +# 133 "fsyacclex.fsl" + ignore <| buff.Append(lexeme lexbuf).[0]; + codestring buff lexbuf +# 606 "fsyacclex.fs" + ) + | _ -> failwith "codestring" +(* Rule comment *) +and _fslex_comment _fslex_state lexbuf = + match _fslex_tables.Interpret(_fslex_state,lexbuf) with + | 0 -> ( +# 138 "fsyacclex.fsl" + ignore(comment lexbuf); comment lexbuf +# 615 "fsyacclex.fs" + ) + | 1 -> ( +# 139 "fsyacclex.fsl" + newline lexbuf; comment lexbuf +# 620 "fsyacclex.fs" + ) + | 2 -> ( +# 140 "fsyacclex.fsl" + () +# 625 "fsyacclex.fs" + ) + | 3 -> ( +# 141 "fsyacclex.fsl" + failwith "end of file in comment" +# 630 "fsyacclex.fs" + ) + | 4 -> ( +# 142 "fsyacclex.fsl" + comment lexbuf +# 635 "fsyacclex.fs" + ) + | 5 -> ( +# 143 "fsyacclex.fsl" + comment lexbuf +# 640 "fsyacclex.fs" + ) + | _ -> failwith "comment" + +# 3000000 "fsyacclex.fs" diff --git a/src/buildtools/fsyacc/fsyaccpars.fs b/src/buildtools/fsyacc/fsyaccpars.fs new file mode 100644 index 0000000000..c6d614f269 --- /dev/null +++ b/src/buildtools/fsyacc/fsyaccpars.fs @@ -0,0 +1,562 @@ +// Implementation file for parser generated by fsyacc +module internal FsLexYacc.FsYacc.Parser +#nowarn "64";; // turn off warnings that type variables used in production annotations are instantiated to concrete type +open Internal.Utilities.Text.Lexing +open Internal.Utilities.Text.Parsing.ParseHelpers +# 1 "fsyaccpars.fsy" + +(* (c) Microsoft Corporation 2005-2008. *) + +// FsLexYacc.FsYacc.Parser + +open FsLexYacc.FsYacc +open FsLexYacc.FsYacc.AST + +#nowarn "62" // This construct is for ML compatibility + + +# 18 "fsyaccpars.fs" +// This type is the type of tokens accepted by the parser +type token = + | TOKEN of (string option) + | TYPE of (string) + | BAR + | PERCENT_PERCENT + | START + | LEFT + | RIGHT + | NONASSOC + | LESS + | GREATER + | COLON + | PREC + | SEMI + | EOF + | ERROR + | HEADER of (AST.Code) + | CODE of (AST.Code) + | IDENT of (string) +// This type is used to give symbolic names to token indexes, useful for error messages +type tokenId = + | TOKEN_TOKEN + | TOKEN_TYPE + | TOKEN_BAR + | TOKEN_PERCENT_PERCENT + | TOKEN_START + | TOKEN_LEFT + | TOKEN_RIGHT + | TOKEN_NONASSOC + | TOKEN_LESS + | TOKEN_GREATER + | TOKEN_COLON + | TOKEN_PREC + | TOKEN_SEMI + | TOKEN_EOF + | TOKEN_ERROR + | TOKEN_HEADER + | TOKEN_CODE + | TOKEN_IDENT + | TOKEN_end_of_input + | TOKEN_error +// This type is used to give symbolic names to token indexes, useful for error messages +type nonTerminalId = + | NONTERM__startspec + | NONTERM_spec + | NONTERM_headeropt + | NONTERM_decls + | NONTERM_decl + | NONTERM_idents + | NONTERM_rules + | NONTERM_rule + | NONTERM_optbar + | NONTERM_optsemi + | NONTERM_clauses + | NONTERM_clause + | NONTERM_syms + | NONTERM_optprec + +// This function maps tokens to integer indexes +let tagOfToken (t:token) = + match t with + | TOKEN _ -> 0 + | TYPE _ -> 1 + | BAR -> 2 + | PERCENT_PERCENT -> 3 + | START -> 4 + | LEFT -> 5 + | RIGHT -> 6 + | NONASSOC -> 7 + | LESS -> 8 + | GREATER -> 9 + | COLON -> 10 + | PREC -> 11 + | SEMI -> 12 + | EOF -> 13 + | ERROR -> 14 + | HEADER _ -> 15 + | CODE _ -> 16 + | IDENT _ -> 17 + +// This function maps integer indexes to symbolic token ids +let tokenTagToTokenId (tokenIdx:int) = + match tokenIdx with + | 0 -> TOKEN_TOKEN + | 1 -> TOKEN_TYPE + | 2 -> TOKEN_BAR + | 3 -> TOKEN_PERCENT_PERCENT + | 4 -> TOKEN_START + | 5 -> TOKEN_LEFT + | 6 -> TOKEN_RIGHT + | 7 -> TOKEN_NONASSOC + | 8 -> TOKEN_LESS + | 9 -> TOKEN_GREATER + | 10 -> TOKEN_COLON + | 11 -> TOKEN_PREC + | 12 -> TOKEN_SEMI + | 13 -> TOKEN_EOF + | 14 -> TOKEN_ERROR + | 15 -> TOKEN_HEADER + | 16 -> TOKEN_CODE + | 17 -> TOKEN_IDENT + | 20 -> TOKEN_end_of_input + | 18 -> TOKEN_error + | _ -> failwith "tokenTagToTokenId: bad token" + +/// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production +let prodIdxToNonTerminal (prodIdx:int) = + match prodIdx with + | 0 -> NONTERM__startspec + | 1 -> NONTERM_spec + | 2 -> NONTERM_headeropt + | 3 -> NONTERM_headeropt + | 4 -> NONTERM_decls + | 5 -> NONTERM_decls + | 6 -> NONTERM_decl + | 7 -> NONTERM_decl + | 8 -> NONTERM_decl + | 9 -> NONTERM_decl + | 10 -> NONTERM_decl + | 11 -> NONTERM_decl + | 12 -> NONTERM_idents + | 13 -> NONTERM_idents + | 14 -> NONTERM_rules + | 15 -> NONTERM_rules + | 16 -> NONTERM_rule + | 17 -> NONTERM_optbar + | 18 -> NONTERM_optbar + | 19 -> NONTERM_optsemi + | 20 -> NONTERM_optsemi + | 21 -> NONTERM_clauses + | 22 -> NONTERM_clauses + | 23 -> NONTERM_clause + | 24 -> NONTERM_syms + | 25 -> NONTERM_syms + | 26 -> NONTERM_syms + | 27 -> NONTERM_optprec + | 28 -> NONTERM_optprec + | _ -> failwith "prodIdxToNonTerminal: bad production index" + +let _fsyacc_endOfInputTag = 20 +let _fsyacc_tagOfErrorTerminal = 18 + +// This function gets the name of a token as a string +let token_to_string (t:token) = + match t with + | TOKEN _ -> "TOKEN" + | TYPE _ -> "TYPE" + | BAR -> "BAR" + | PERCENT_PERCENT -> "PERCENT_PERCENT" + | START -> "START" + | LEFT -> "LEFT" + | RIGHT -> "RIGHT" + | NONASSOC -> "NONASSOC" + | LESS -> "LESS" + | GREATER -> "GREATER" + | COLON -> "COLON" + | PREC -> "PREC" + | SEMI -> "SEMI" + | EOF -> "EOF" + | ERROR -> "ERROR" + | HEADER _ -> "HEADER" + | CODE _ -> "CODE" + | IDENT _ -> "IDENT" + +// This function gets the data carried by a token as an object +let _fsyacc_dataOfToken (t:token) = + match t with + | TOKEN _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | TYPE _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | BAR -> (null : System.Object) + | PERCENT_PERCENT -> (null : System.Object) + | START -> (null : System.Object) + | LEFT -> (null : System.Object) + | RIGHT -> (null : System.Object) + | NONASSOC -> (null : System.Object) + | LESS -> (null : System.Object) + | GREATER -> (null : System.Object) + | COLON -> (null : System.Object) + | PREC -> (null : System.Object) + | SEMI -> (null : System.Object) + | EOF -> (null : System.Object) + | ERROR -> (null : System.Object) + | HEADER _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | CODE _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x + | IDENT _fsyacc_x -> Microsoft.FSharp.Core.Operators.box _fsyacc_x +let _fsyacc_gotos = [| 0us; 65535us; 1us; 65535us; 0us; 1us; 1us; 65535us; 0us; 2us; 2us; 65535us; 2us; 3us; 7us; 8us; 2us; 65535us; 2us; 7us; 7us; 7us; 7us; 65535us; 9us; 10us; 11us; 12us; 13us; 14us; 15us; 16us; 17us; 18us; 19us; 20us; 21us; 22us; 2us; 65535us; 4us; 5us; 23us; 24us; 2us; 65535us; 4us; 23us; 23us; 23us; 1us; 65535us; 26us; 27us; 1us; 65535us; 28us; 29us; 2us; 65535us; 27us; 28us; 33us; 34us; 2us; 65535us; 27us; 32us; 33us; 32us; 4us; 65535us; 27us; 35us; 33us; 35us; 38us; 39us; 40us; 41us; 1us; 65535us; 35us; 36us; |] +let _fsyacc_sparseGotoTableRowOffsets = [|0us; 1us; 3us; 5us; 8us; 11us; 19us; 22us; 25us; 27us; 29us; 32us; 35us; 40us; |] +let _fsyacc_stateToProdIdxsTableElements = [| 1us; 0us; 1us; 0us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 1us; 2us; 1us; 5us; 1us; 5us; 1us; 6us; 1us; 6us; 1us; 7us; 1us; 7us; 1us; 8us; 1us; 8us; 1us; 9us; 1us; 9us; 1us; 10us; 1us; 10us; 1us; 11us; 1us; 11us; 1us; 12us; 1us; 12us; 2us; 14us; 15us; 1us; 14us; 1us; 16us; 1us; 16us; 1us; 16us; 1us; 16us; 1us; 16us; 1us; 18us; 1us; 20us; 2us; 21us; 22us; 1us; 21us; 1us; 21us; 1us; 23us; 1us; 23us; 1us; 23us; 1us; 24us; 1us; 24us; 1us; 25us; 1us; 25us; 1us; 28us; 1us; 28us; |] +let _fsyacc_stateToProdIdxsTableRowOffsets = [|0us; 2us; 4us; 6us; 8us; 10us; 12us; 14us; 16us; 18us; 20us; 22us; 24us; 26us; 28us; 30us; 32us; 34us; 36us; 38us; 40us; 42us; 44us; 46us; 49us; 51us; 53us; 55us; 57us; 59us; 61us; 63us; 65us; 68us; 70us; 72us; 74us; 76us; 78us; 80us; 82us; 84us; 86us; 88us; |] +let _fsyacc_action_rows = 44 +let _fsyacc_actionTableElements = [|1us; 16387us; 15us; 6us; 0us; 49152us; 6us; 16388us; 0us; 9us; 1us; 11us; 4us; 13us; 5us; 15us; 6us; 17us; 7us; 19us; 1us; 32768us; 3us; 4us; 1us; 32768us; 17us; 25us; 0us; 16385us; 0us; 16386us; 6us; 16388us; 0us; 9us; 1us; 11us; 4us; 13us; 5us; 15us; 6us; 17us; 7us; 19us; 0us; 16389us; 1us; 16397us; 17us; 21us; 0us; 16390us; 1us; 16397us; 17us; 21us; 0us; 16391us; 1us; 16397us; 17us; 21us; 0us; 16392us; 1us; 16397us; 17us; 21us; 0us; 16393us; 1us; 16397us; 17us; 21us; 0us; 16394us; 1us; 16397us; 17us; 21us; 0us; 16395us; 1us; 16397us; 17us; 21us; 0us; 16396us; 1us; 16399us; 17us; 25us; 0us; 16398us; 1us; 32768us; 10us; 26us; 1us; 16401us; 2us; 30us; 2us; 16410us; 14us; 40us; 17us; 38us; 1us; 16403us; 12us; 31us; 0us; 16400us; 0us; 16402us; 0us; 16404us; 1us; 16406us; 2us; 33us; 2us; 16410us; 14us; 40us; 17us; 38us; 0us; 16405us; 1us; 16411us; 11us; 42us; 1us; 32768us; 16us; 37us; 0us; 16407us; 2us; 16410us; 14us; 40us; 17us; 38us; 0us; 16408us; 2us; 16410us; 14us; 40us; 17us; 38us; 0us; 16409us; 1us; 32768us; 17us; 43us; 0us; 16412us; |] +let _fsyacc_actionTableRowOffsets = [|0us; 2us; 3us; 10us; 12us; 14us; 15us; 16us; 23us; 24us; 26us; 27us; 29us; 30us; 32us; 33us; 35us; 36us; 38us; 39us; 41us; 42us; 44us; 45us; 47us; 48us; 50us; 52us; 55us; 57us; 58us; 59us; 60us; 62us; 65us; 66us; 68us; 70us; 71us; 74us; 75us; 78us; 79us; 81us; |] +let _fsyacc_reductionSymbolCounts = [|1us; 4us; 1us; 0us; 0us; 2us; 2us; 2us; 2us; 2us; 2us; 2us; 2us; 0us; 2us; 1us; 5us; 0us; 1us; 0us; 1us; 3us; 1us; 3us; 2us; 2us; 0us; 0us; 2us; |] +let _fsyacc_productionToNonTerminalTable = [|0us; 1us; 2us; 2us; 3us; 3us; 4us; 4us; 4us; 4us; 4us; 4us; 5us; 5us; 6us; 6us; 7us; 8us; 8us; 9us; 9us; 10us; 10us; 11us; 12us; 12us; 12us; 13us; 13us; |] +let _fsyacc_immediateActions = [|65535us; 49152us; 65535us; 65535us; 65535us; 16385us; 16386us; 65535us; 16389us; 65535us; 16390us; 65535us; 16391us; 65535us; 16392us; 65535us; 16393us; 65535us; 16394us; 65535us; 16395us; 65535us; 16396us; 65535us; 16398us; 65535us; 65535us; 65535us; 65535us; 16400us; 16402us; 16404us; 65535us; 65535us; 16405us; 65535us; 65535us; 16407us; 65535us; 16408us; 65535us; 16409us; 65535us; 16412us; |] +let _fsyacc_reductions () = [| +# 216 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : AST.ParserSpec)) in + Microsoft.FSharp.Core.Operators.box + ( + ( + raise (Internal.Utilities.Text.Parsing.Accept(Microsoft.FSharp.Core.Operators.box _1)) + ) + : '_startspec)); +# 225 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'headeropt)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'decls)) in + let _4 = (let data = parseState.GetInput(4) in (Microsoft.FSharp.Core.Operators.unbox data : 'rules)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 25 "fsyaccpars.fsy" + List.foldBack (fun f x -> f x) _2 { Header=_1;Tokens=[];Types=[];Associativities=[];StartSymbols=[];Rules=_4 } + ) +# 25 "fsyaccpars.fsy" + : AST.ParserSpec)); +# 238 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : AST.Code)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 29 "fsyaccpars.fsy" + _1 + ) +# 29 "fsyaccpars.fsy" + : 'headeropt)); +# 249 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 31 "fsyaccpars.fsy" + "", (parseState.ResultRange |> fst) + ) +# 31 "fsyaccpars.fsy" + : 'headeropt)); +# 259 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 34 "fsyaccpars.fsy" + [] + ) +# 34 "fsyaccpars.fsy" + : 'decls)); +# 269 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'decl)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'decls)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 35 "fsyaccpars.fsy" + _1 :: _2 + ) +# 35 "fsyaccpars.fsy" + : 'decls)); +# 281 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string option)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 38 "fsyaccpars.fsy" + (fun x -> {x with Tokens = x.Tokens @ (List.map (fun x -> (x,_1)) _2)}) + ) +# 38 "fsyaccpars.fsy" + : 'decl)); +# 293 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 39 "fsyaccpars.fsy" + (fun x -> {x with Types = x.Types @ (List.map (fun x -> (x,_1)) _2)} ) + ) +# 39 "fsyaccpars.fsy" + : 'decl)); +# 305 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 40 "fsyaccpars.fsy" + (fun x -> {x with StartSymbols = x.StartSymbols @ _2} ) + ) +# 40 "fsyaccpars.fsy" + : 'decl)); +# 316 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 41 "fsyaccpars.fsy" + (fun x -> {x with Associativities = x.Associativities @ [(List.map (fun x -> (x,LeftAssoc)) _2)]} ) + ) +# 41 "fsyaccpars.fsy" + : 'decl)); +# 327 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 42 "fsyaccpars.fsy" + (fun x -> {x with Associativities = x.Associativities @ [(List.map (fun x -> (x,RightAssoc)) _2)]} ) + ) +# 42 "fsyaccpars.fsy" + : 'decl)); +# 338 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 43 "fsyaccpars.fsy" + (fun x -> {x with Associativities = x.Associativities @ [(List.map (fun x -> (x,NonAssoc)) _2)]} ) + ) +# 43 "fsyaccpars.fsy" + : 'decl)); +# 349 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'idents)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 45 "fsyaccpars.fsy" + _1 :: _2 + ) +# 45 "fsyaccpars.fsy" + : 'idents)); +# 361 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 45 "fsyaccpars.fsy" + [] + ) +# 45 "fsyaccpars.fsy" + : 'idents)); +# 371 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'rule)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'rules)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 46 "fsyaccpars.fsy" + _1 :: _2 + ) +# 46 "fsyaccpars.fsy" + : 'rules)); +# 383 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'rule)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 46 "fsyaccpars.fsy" + [_1] + ) +# 46 "fsyaccpars.fsy" + : 'rules)); +# 394 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'optbar)) in + let _4 = (let data = parseState.GetInput(4) in (Microsoft.FSharp.Core.Operators.unbox data : 'clauses)) in + let _5 = (let data = parseState.GetInput(5) in (Microsoft.FSharp.Core.Operators.unbox data : 'optsemi)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 47 "fsyaccpars.fsy" + (_1,_4) + ) +# 47 "fsyaccpars.fsy" + : 'rule)); +# 408 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 48 "fsyaccpars.fsy" + + ) +# 48 "fsyaccpars.fsy" + : 'optbar)); +# 418 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 48 "fsyaccpars.fsy" + + ) +# 48 "fsyaccpars.fsy" + : 'optbar)); +# 428 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 49 "fsyaccpars.fsy" + + ) +# 49 "fsyaccpars.fsy" + : 'optsemi)); +# 438 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 49 "fsyaccpars.fsy" + + ) +# 49 "fsyaccpars.fsy" + : 'optsemi)); +# 448 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'clause)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : 'clauses)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 50 "fsyaccpars.fsy" + _1 :: _3 + ) +# 50 "fsyaccpars.fsy" + : 'clauses)); +# 460 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'clause)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 50 "fsyaccpars.fsy" + [_1] + ) +# 50 "fsyaccpars.fsy" + : 'clauses)); +# 471 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : 'syms)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'optprec)) in + let _3 = (let data = parseState.GetInput(3) in (Microsoft.FSharp.Core.Operators.unbox data : AST.Code)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 51 "fsyaccpars.fsy" + Rule(_1,_2,Some _3) + ) +# 51 "fsyaccpars.fsy" + : 'clause)); +# 484 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _1 = (let data = parseState.GetInput(1) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'syms)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 52 "fsyaccpars.fsy" + _1 :: _2 + ) +# 52 "fsyaccpars.fsy" + : 'syms)); +# 496 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : 'syms)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 52 "fsyaccpars.fsy" + "error" :: _2 + ) +# 52 "fsyaccpars.fsy" + : 'syms)); +# 507 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 52 "fsyaccpars.fsy" + [] + ) +# 52 "fsyaccpars.fsy" + : 'syms)); +# 517 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + Microsoft.FSharp.Core.Operators.box + ( + ( +# 53 "fsyaccpars.fsy" + None + ) +# 53 "fsyaccpars.fsy" + : 'optprec)); +# 527 "fsyaccpars.fs" + (fun (parseState : Internal.Utilities.Text.Parsing.IParseState) -> + let _2 = (let data = parseState.GetInput(2) in (Microsoft.FSharp.Core.Operators.unbox data : string)) in + Microsoft.FSharp.Core.Operators.box + ( + ( +# 53 "fsyaccpars.fsy" + Some _2 + ) +# 53 "fsyaccpars.fsy" + : 'optprec)); +|] +# 539 "fsyaccpars.fs" +let tables () : Internal.Utilities.Text.Parsing.Tables<_> = + { reductions= _fsyacc_reductions (); + endOfInputTag = _fsyacc_endOfInputTag; + tagOfToken = tagOfToken; + dataOfToken = _fsyacc_dataOfToken; + actionTableElements = _fsyacc_actionTableElements; + actionTableRowOffsets = _fsyacc_actionTableRowOffsets; + stateToProdIdxsTableElements = _fsyacc_stateToProdIdxsTableElements; + stateToProdIdxsTableRowOffsets = _fsyacc_stateToProdIdxsTableRowOffsets; + reductionSymbolCounts = _fsyacc_reductionSymbolCounts; + immediateActions = _fsyacc_immediateActions; + gotos = _fsyacc_gotos; + sparseGotoTableRowOffsets = _fsyacc_sparseGotoTableRowOffsets; + tagOfErrorTerminal = _fsyacc_tagOfErrorTerminal; + parseError = (fun (ctxt:Internal.Utilities.Text.Parsing.ParseErrorContext<_>) -> + match parse_error_rich with + | Some f -> f ctxt + | None -> parse_error ctxt.Message); + numTerminals = 21; + productionToNonTerminalTable = _fsyacc_productionToNonTerminalTable } +let engine lexer lexbuf startState = (tables ()).Interpret(lexer, lexbuf, startState) +let spec lexer lexbuf : AST.ParserSpec = + Microsoft.FSharp.Core.Operators.unbox ((tables ()).Interpret(lexer, lexbuf, 0)) diff --git a/src/buildtools/keys/MSFT.snk b/src/buildtools/keys/MSFT.snk new file mode 100644 index 0000000000..110b59c7b0 Binary files /dev/null and b/src/buildtools/keys/MSFT.snk differ diff --git a/src/fsharp-proto-build.proj b/src/fsharp-proto-build.proj new file mode 100644 index 0000000000..e12d08739f --- /dev/null +++ b/src/fsharp-proto-build.proj @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/fsharp/AugmentWithHashCompare.fs b/src/fsharp/AugmentWithHashCompare.fs index abb0654722..c0be1b15f3 100755 --- a/src/fsharp/AugmentWithHashCompare.fs +++ b/src/fsharp/AugmentWithHashCompare.fs @@ -3,7 +3,6 @@ /// Generate the hash/compare functions we add to user-defined types by default. module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare -open Internal.Utilities open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.AbstractIL open Microsoft.FSharp.Compiler.AbstractIL.IL @@ -13,8 +12,6 @@ open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.Tastops open Microsoft.FSharp.Compiler.Ast open Microsoft.FSharp.Compiler.ErrorLogger -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Infos diff --git a/src/fsharp/CheckFormatStrings.fs b/src/fsharp/CheckFormatStrings.fs index 0b5fbe686e..49d9f19d65 100755 --- a/src/fsharp/CheckFormatStrings.fs +++ b/src/fsharp/CheckFormatStrings.fs @@ -4,12 +4,9 @@ module internal Microsoft.FSharp.Compiler.CheckFormatStrings open Internal.Utilities 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.Ast open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.ErrorLogger open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.Tastops open Microsoft.FSharp.Compiler.TcGlobals diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index eb972f1614..865869f56a 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -58,20 +58,10 @@ open Microsoft.FSharp.Core.ReflectionAdapters #endif #if DEBUG - -#if COMPILED_AS_LANGUAGE_SERVICE_DLL +[] module internal CompilerService = -#else -module internal FullCompiler = -#endif let showAssertForUnexpectedException = ref true -#if COMPILED_AS_LANGUAGE_SERVICE_DLL -open CompilerService -#else -open FullCompiler -#endif - -#endif +#endif // DEBUG //---------------------------------------------------------------------------- // Some Globals @@ -215,6 +205,9 @@ let GetRangeOfDiagnostic(err:PhasedDiagnostic) = | NotAFunction(_,_,mfun,_) -> Some mfun + + | NotAFunctionButIndexer(_,_,_,mfun,_) -> + Some mfun | IllegalFileNameChar(_) -> Some rangeCmdArgs @@ -253,6 +246,7 @@ let GetDiagnosticNumber(err:PhasedDiagnostic) = (* DO NOT CHANGE THESE NUMBERS *) | ErrorFromAddingTypeEquation _ -> 1 | FunctionExpected _ -> 2 + | NotAFunctionButIndexer _ -> 3217 | NotAFunction _ -> 3 | FieldNotMutable _ -> 5 | Recursion _ -> 6 @@ -450,7 +444,6 @@ let ConstraintSolverMissingConstraintE() = DeclareResourceString("ConstraintSolv let ConstraintSolverTypesNotInEqualityRelation1E() = DeclareResourceString("ConstraintSolverTypesNotInEqualityRelation1","%s%s") let ConstraintSolverTypesNotInEqualityRelation2E() = DeclareResourceString("ConstraintSolverTypesNotInEqualityRelation2", "%s%s") let ConstraintSolverTypesNotInSubsumptionRelationE() = DeclareResourceString("ConstraintSolverTypesNotInSubsumptionRelation","%s%s%s") -let ConstraintSolverErrorE() = DeclareResourceString("ConstraintSolverError","%s") let ErrorFromAddingTypeEquation1E() = DeclareResourceString("ErrorFromAddingTypeEquation1","%s%s%s") let ErrorFromAddingTypeEquation2E() = DeclareResourceString("ErrorFromAddingTypeEquation2","%s%s%s") let ErrorFromApplyingDefault1E() = DeclareResourceString("ErrorFromApplyingDefault1","%s") @@ -464,8 +457,6 @@ let BakedInMemberConstraintNameE() = DeclareResourceString("BakedInMemberConstra let BadEventTransformationE() = DeclareResourceString("BadEventTransformation","") let ParameterlessStructCtorE() = DeclareResourceString("ParameterlessStructCtor","") let InterfaceNotRevealedE() = DeclareResourceString("InterfaceNotRevealed","%s") -let NotAFunction1E() = DeclareResourceString("NotAFunction1","") -let NotAFunction2E() = DeclareResourceString("NotAFunction2","") let TyconBadArgsE() = DeclareResourceString("TyconBadArgs","%s%d%d") let IndeterminateTypeE() = DeclareResourceString("IndeterminateType","") let NameClash1E() = DeclareResourceString("NameClash1","%s%s") @@ -634,14 +625,11 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = os.Append(ConstraintSolverMissingConstraintE().Format (NicePrint.stringOfTyparConstraint denv (tpr,tpc))) |> ignore if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m)) |> ignore - | ConstraintSolverTypesNotInEqualityRelation(denv,(TType_measure _ as t1),(TType_measure _ as t2),m,m2,contextInfo) -> + | ConstraintSolverTypesNotInEqualityRelation(denv,(TType_measure _ as t1),(TType_measure _ as t2),m,m2,_) -> // REVIEW: consider if we need to show _cxs (the type parameter constraints) let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv t1 t2 - match contextInfo with - | ContextInfo.OmittedElseBranch range when range = m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore - | ContextInfo.ElseBranchResult range when range = m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2)) |> ignore - | _ -> os.Append(ConstraintSolverTypesNotInEqualityRelation1E().Format t1 t2 ) |> ignore + os.Append(ConstraintSolverTypesNotInEqualityRelation1E().Format t1 t2 ) |> ignore if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m)) |> ignore @@ -650,8 +638,16 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv t1 t2 match contextInfo with + | ContextInfo.IfExpression range when range = m -> os.Append(FSComp.SR.ifExpression(t1,t2)) |> ignore + | ContextInfo.CollectionElement (isArray,range) when range = m -> + if isArray then + os.Append(FSComp.SR.arrayElementHasWrongType(t1,t2)) |> ignore + else + os.Append(FSComp.SR.listElementHasWrongType(t1,t2)) |> ignore | ContextInfo.OmittedElseBranch range when range = m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore | ContextInfo.ElseBranchResult range when range = m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2)) |> ignore + | ContextInfo.FollowingPatternMatchClause range when range = m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1,t2)) |> ignore + | ContextInfo.PatternMatchGuard range when range = m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore | _ -> os.Append(ConstraintSolverTypesNotInEqualityRelation2E().Format t1 t2) |> ignore if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m)) |> ignore @@ -662,7 +658,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m2)) |> ignore | ConstraintSolverError(msg,m,m2) -> - os.Append(ConstraintSolverErrorE().Format msg) |> ignore + os.Append msg |> ignore if m.StartLine <> m2.StartLine then os.Append(SeeAlsoE().Format (stringOfRange m2)) |> ignore | ConstraintSolverRelatedInformation(fopt,_,e) -> @@ -675,8 +671,16 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = && typeEquiv g t2 t2' -> let t1,t2,tpcs = NicePrint.minimalStringsOfTwoTypes denv t1 t2 match contextInfo with + | ContextInfo.IfExpression range when range = m -> os.Append(FSComp.SR.ifExpression(t1,t2)) |> ignore + | ContextInfo.CollectionElement (isArray,range) when range = m -> + if isArray then + os.Append(FSComp.SR.arrayElementHasWrongType(t1,t2)) |> ignore + else + os.Append(FSComp.SR.listElementHasWrongType(t1,t2)) |> ignore | ContextInfo.OmittedElseBranch range when range = m -> os.Append(FSComp.SR.missingElseBranch(t2)) |> ignore | ContextInfo.ElseBranchResult range when range = m -> os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2)) |> ignore + | ContextInfo.FollowingPatternMatchClause range when range = m -> os.Append(FSComp.SR.followingPatternMatchClauseHasWrongType(t1,t2)) |> ignore + | ContextInfo.PatternMatchGuard range when range = m -> os.Append(FSComp.SR.patternMatchGuardIsNotBool(t2)) |> ignore | ContextInfo.TupleInRecordFields -> os.Append(ErrorFromAddingTypeEquation1E().Format t2 t1 tpcs) |> ignore os.Append(System.Environment.NewLine + FSComp.SR.commaInsteadOfSemicolonInRecord()) |> ignore @@ -754,12 +758,15 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = os.Append(ParameterlessStructCtorE().Format) |> ignore | InterfaceNotRevealed(denv,ity,_) -> os.Append(InterfaceNotRevealedE().Format (NicePrint.minimalStringOfType denv ity)) |> ignore + | NotAFunctionButIndexer(_,_,name,_,_) -> + match name with + | Some name -> os.Append(FSComp.SR.notAFunctionButMaybeIndexerWithName name) |> ignore + | _ -> os.Append(FSComp.SR.notAFunctionButMaybeIndexer()) |> ignore | NotAFunction(_,_,_,marg) -> - if marg.StartColumn = 0 then - os.Append(NotAFunction1E().Format) |> ignore + if marg.StartColumn = 0 then + os.Append(FSComp.SR.notAFunctionButMaybeDeclaration()) |> ignore else - os.Append(NotAFunction2E().Format) |> ignore - + os.Append(FSComp.SR.notAFunction()) |> ignore | TyconBadArgs(_,tcref,d,_) -> let exp = tcref.TyparsNoRange.Length if exp = 0 then @@ -814,7 +821,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = os.Append(TypeIsImplicitlyAbstractE().Format) |> ignore | NonRigidTypar(denv,tpnmOpt,typarRange,ty1,ty,_) -> // REVIEW: consider if we need to show _cxs (the type parameter constraints) - let _, (ty1,ty), _cxs = PrettyTypes.PrettifyTypes2 denv.g (ty1,ty) + let (ty1,ty), _cxs = PrettyTypes.PrettifyTypePair denv.g (ty1,ty) match tpnmOpt with | None -> os.Append(NonRigidTypar1E().Format (stringOfRange typarRange) (NicePrint.stringOfTy denv ty)) |> ignore @@ -1154,13 +1161,13 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = *) | RuntimeCoercionSourceSealed(denv,ty,_) -> // REVIEW: consider if we need to show _cxs (the type parameter constraints) - let _, ty, _cxs = PrettyTypes.PrettifyTypes1 denv.g ty + let ty, _cxs = PrettyTypes.PrettifyType denv.g ty if isTyparTy denv.g ty then os.Append(RuntimeCoercionSourceSealed1E().Format (NicePrint.stringOfTy denv ty)) |> ignore else os.Append(RuntimeCoercionSourceSealed2E().Format (NicePrint.stringOfTy denv ty)) |> ignore | CoercionTargetSealed(denv,ty,_) -> // REVIEW: consider if we need to show _cxs (the type parameter constraints) - let _, ty, _cxs= PrettyTypes.PrettifyTypes1 denv.g ty + let ty, _cxs= PrettyTypes.PrettifyType denv.g ty os.Append(CoercionTargetSealedE().Format (NicePrint.stringOfTy denv ty)) |> ignore | UpcastUnnecessary(_) -> os.Append(UpcastUnnecessaryE().Format) |> ignore @@ -1220,7 +1227,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = os.Append(DeprecatedThreadStaticBindingWarningE().Format) |> ignore | FunctionValueUnexpected (denv,ty,_) -> // REVIEW: consider if we need to show _cxs (the type parameter constraints) - let _, ty, _cxs = PrettyTypes.PrettifyTypes1 denv.g ty + let ty, _cxs = PrettyTypes.PrettifyType denv.g ty os.Append(FunctionValueUnexpectedE().Format (NicePrint.stringOfTy denv ty)) |> ignore | UnitTypeExpected (_,_,_) -> let warningText = UnitTypeExpectedE().Format @@ -1288,7 +1295,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = #if DEBUG Printf.bprintf os "\nStack Trace\n%s\n" (exn.ToString()) if !showAssertForUnexpectedException then - System.Diagnostics.Debug.Assert(false,sprintf "Bug seen in compiler: %s" (exn.ToString())) + System.Diagnostics.Debug.Assert(false,sprintf "Unexpected exception seen in compiler: %s\n%s" s (exn.ToString())) #endif | FullAbstraction(s,_) -> os.Append(FullAbstractionE().Format s) |> ignore | WrappedError (exn,_) -> OutputExceptionR os exn @@ -1419,7 +1426,7 @@ let OutputPhasedErrorR (os:StringBuilder) (err:PhasedDiagnostic) = #if DEBUG Printf.bprintf os "\nStack Trace\n%s\n" (e.ToString()) if !showAssertForUnexpectedException then - System.Diagnostics.Debug.Assert(false,sprintf "Bug seen in compiler: %s" (e.ToString())) + System.Diagnostics.Debug.Assert(false,sprintf "Unknown exception seen in compiler: %s" (e.ToString())) #endif OutputExceptionR os (err.Exception) @@ -1627,39 +1634,22 @@ let OutputDiagnosticContext prefix fileLineFn os err = let GetFSharpCoreLibraryName () = "FSharp.Core" -let GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) = - // On Mono, there is no good reference resolution - if useSimpleResolution then - GetFSharpCoreLibraryName()+".dll" - else - let fsCoreName = GetFSharpCoreLibraryName() -#if FX_RESHAPED_REFLECTION - // RESHAPED_REFLECTION does not have Assembly.GetReferencedAssemblies() - // So use the FSharp.Core.dll from alongside the fsc compiler. - // This can also be used for the out of gac work on DEV15 - let fscCoreLocation = - let fscLocation = typeof.Assembly.Location - Path.Combine(Path.GetDirectoryName(fscLocation), fsCoreName + ".dll") - if File.Exists(fscCoreLocation) then fscCoreLocation - else failwithf "Internal error: Could not find %s" fscCoreLocation +// If necessary assume a reference to the latest .NET Framework FSharp.Core with which those tools are built. +let GetDefaultFSharpCoreReference() = typeof>.Assembly.Location + +// If necessary assume a reference to the latest System.ValueTuple with which those tools are built. +let GetDefaultSystemValueTupleReference() = +#if COMPILER_SERVICE_AS_DLL + None // TODO, right now FCS doesn't add this reference automatically #else - // check if FSharp.Core can be found from the hosting environment - let foundReference = - match System.Reflection.Assembly.GetEntryAssembly() with - | null -> None - | entryAssembly -> - entryAssembly.GetReferencedAssemblies() - |> Array.tryPick (fun name -> - if name.Name = fsCoreName then Some(name.ToString()) - else None) - - // if not we use the referenced FSharp.Core from this project - match foundReference with - | Some fsharpCore -> fsharpCore - | None -> - // FSharp.Compiler.Service for F# 4.0 defaults to FSharp.Core 4.4.0.0 if no FSharp.Core is referenced statically by the host process. - "FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + try + let asm = typeof>.Assembly + if asm.FullName.StartsWith "System.ValueTuple" then + Some asm.Location + else None + with _ -> None #endif + let GetFsiLibraryName () = "FSharp.Compiler.Interactive.Settings" // This list is the default set of references for "non-project" files. @@ -1692,20 +1682,23 @@ let DefaultReferencesForScriptsAndOutOfProjectSources(assumeDotNetFramework) = yield "System.Collections" // System.Collections.Generic.List yield "System.Runtime.Numerics" // BigInteger yield "System.Threading" // OperationCanceledException - //yield "System.ValueTuple" + // always include a default reference to System.ValueTuple.dll in scripts and out-of-project sources + match GetDefaultSystemValueTupleReference() with + | None -> () + | Some v -> yield v yield "System.Web" yield "System.Web.Services" yield "System.Windows.Forms" yield "System.Numerics" - else + else yield Path.Combine(Path.GetDirectoryName(typeof.Assembly.Location),"mscorlib.dll"); // mscorlib yield typeof.Assembly.Location; // System.Console yield typeof.Assembly.Location; // System.Runtime yield typeof.Assembly.Location; // System.ObjectModel yield typeof.Assembly.Location; // System.IO yield typeof.Assembly.Location; // System.Linq - yield typeof.Assembly.Location; // System.Xml.Linq + //yield typeof.Assembly.Location; // System.Xml.Linq yield typeof.Assembly.Location; // System.Net.Requests yield typeof.Assembly.Location; // System.Runtime.Numerics yield typeof.Assembly.Location; // System.Threading.Tasks @@ -1719,6 +1712,7 @@ let DefaultReferencesForScriptsAndOutOfProjectSources(assumeDotNetFramework) = let SystemAssemblies () = HashSet [ yield "mscorlib" + yield "netstandard" yield "System.Runtime" yield GetFSharpCoreLibraryName() yield "System" @@ -1825,16 +1819,16 @@ let SystemAssemblies () = // // REVIEW: it isn't clear if there is any negative effect // of leaving an assembly off this list. -let BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib, assumeDotNetFramework) = +let BasicReferencesForScriptLoadClosure(useFsiAuxLib, assumeDotNetFramework) = [ if assumeDotNetFramework then -#if TODO_REWORK_ASSEMBLY_LOAD +#if COMPILER_SERVICE_ASSUMES_DOTNETCORE_COMPILATION yield Path.Combine(Path.GetDirectoryName(typeof.Assembly.Location),"mscorlib.dll"); // mscorlib #else yield "mscorlib" #endif - yield GetFSharpCoreReferenceUsedByCompiler(useSimpleResolution) ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are. + yield GetDefaultFSharpCoreReference() ] @ // Need to resolve these explicitly so they will be found in the reference assemblies directory which is where the .xml files are. DefaultReferencesForScriptsAndOutOfProjectSources(assumeDotNetFramework) @ [ if useFsiAuxLib then yield GetFsiLibraryName () ] @@ -2123,7 +2117,7 @@ type TcConfigBuilder = mutable win32manifest : string mutable includewin32manifest : bool mutable linkResources : string list - mutable referenceResolver: ReferenceResolver.Resolver + mutable legacyReferenceResolver: ReferenceResolver.Resolver mutable showFullPaths : bool mutable errorStyle : ErrorStyle @@ -2144,6 +2138,7 @@ type TcConfigBuilder = mutable optsOn : bool (* optimizations are turned on *) mutable optSettings : Optimizer.OptimizationSettings mutable emitTailcalls : bool + mutable deterministic : bool #if PREFERRED_UI_LANG mutable preferredUiLang: string option #endif @@ -2191,13 +2186,13 @@ type TcConfigBuilder = mutable shadowCopyReferences : bool } - static member CreateNew (referenceResolver,defaultFSharpBinariesDir,optimizeForMemory,implicitIncludeDir,isInteractive,isInvalidationSupported) = + static member CreateNew (legacyReferenceResolver,defaultFSharpBinariesDir,optimizeForMemory,implicitIncludeDir,isInteractive,isInvalidationSupported, defaultCopyFSharpCore) = System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(implicitIncludeDir), sprintf "implicitIncludeDir should be absolute: '%s'" implicitIncludeDir) if (String.IsNullOrEmpty(defaultFSharpBinariesDir)) then failwith "Expected a valid defaultFSharpBinariesDir" { -#if TODO_REWORK_ASSEMBLY_LOAD - primaryAssembly = PrimaryAssembly.DotNetCore // defaut value, can be overridden using the command line switch +#if COMPILER_SERVICE_ASSUMES_DOTNETCORE_COMPILATION + primaryAssembly = PrimaryAssembly.System_Runtime // defaut value, can be overridden using the command line switch #else primaryAssembly = PrimaryAssembly.Mscorlib // defaut value, can be overridden using the command line switch #endif @@ -2218,7 +2213,7 @@ type TcConfigBuilder = useFsiAuxLib=false implicitOpens=[] includes=[] - resolutionEnvironment=ReferenceResolver.CompileTimeLike + resolutionEnvironment=ResolutionEnvironment.EditingOrCompilation false framework=true implicitlyResolveAssemblies=true referencedDLLs = [] @@ -2293,7 +2288,7 @@ type TcConfigBuilder = win32manifest = "" includewin32manifest = true linkResources = [] - referenceResolver = referenceResolver + legacyReferenceResolver = legacyReferenceResolver showFullPaths =false errorStyle = ErrorStyle.DefaultErrors @@ -2312,6 +2307,7 @@ type TcConfigBuilder = optsOn = false optSettings = Optimizer.OptimizationSettings.Defaults emitTailcalls = true + deterministic = false #if PREFERRED_UI_LANG preferredUiLang = None #endif @@ -2335,7 +2331,7 @@ type TcConfigBuilder = sqmSessionStartedTime = System.DateTime.Now.Ticks emitDebugInfoInQuotations = false exename = None - copyFSharpCore = false + copyFSharpCore = defaultCopyFSharpCore shadowCopyReferences = false } @@ -2478,7 +2474,7 @@ let OpenILBinary(filename,optimizeForMemory,openBinariesInMemory,ilGlobalsOpt, p ILBinaryReader.OpenILModuleReaderAfterReadingAllBytes filename opts else let location = -#if FSI_SHADOW_COPY_REFERENCES +#if !FX_RESHAPED_REFLECTION_CORECLR // shadow copy not supported // In order to use memory mapped files on the shadow copied version of the Assembly, we `preload the assembly // We swallow all exceptions so that we do not change the exception contract of this API if shadowCopyReferences then @@ -2487,7 +2483,7 @@ let OpenILBinary(filename,optimizeForMemory,openBinariesInMemory,ilGlobalsOpt, p with e -> filename else #else - ignore shadowCopyReferences + ignore shadowCopyReferences #endif filename ILBinaryReader.OpenILModuleReader location opts @@ -2606,16 +2602,16 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = match fileNameOpt with | None -> // if FSharp.Core was not provided explicitly - use version that was referenced by compiler - AssemblyReference(range0, GetFSharpCoreReferenceUsedByCompiler(data.useSimpleResolution), None), None + AssemblyReference(range0, GetDefaultFSharpCoreReference(), None), None | _ -> res - // If either mscorlib.dll/System.Runtime.dll or FSharp.Core.dll are explicitly specified then we require the --noframework flag. + // If either mscorlib.dll/System.Runtime.dll/netstandard.dll or FSharp.Core.dll are explicitly specified then we require the --noframework flag. // The reason is that some non-default frameworks may not have the default dlls. For example, Client profile does // not have System.Web.dll. do if ((primaryAssemblyExplicitFilenameOpt.IsSome || fslibExplicitFilenameOpt.IsSome) && data.framework) then error(Error(FSComp.SR.buildExplicitCoreLibRequiresNoFramework("--noframework"),rangeStartup)) - let clrRootValue, (mscorlibMajorVersion,targetFrameworkVersionValue), primaryAssemblyIsSilverlight = + let clrRootValue, targetFrameworkVersionValue = match primaryAssemblyExplicitFilenameOpt with | Some(primaryAssemblyFilename) -> let filename = ComputeMakePathAbsolute data.implicitIncludeDir primaryAssemblyFilename @@ -2623,12 +2619,9 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = use ilReader = OpenILBinary(filename,data.optimizeForMemory,data.openBinariesInMemory,None,None, data.shadowCopyReferences) let ilModule = ilReader.ILModuleDef match ilModule.ManifestOfAssembly.Version with - | Some(v1,v2,v3,_) -> - if v1 = 1us then - warning(Error(FSComp.SR.buildRequiresCLI2(filename),rangeStartup)) + | Some(v1,v2,_,_) -> let clrRoot = Some(Path.GetDirectoryName(FileSystem.GetFullPathShim(filename))) - - clrRoot, (int v1, sprintf "v%d.%d" v1 v2), (v1=5us && v2=0us && v3=5us) // SL5 mscorlib is 5.0.5.0 + clrRoot, (sprintf "v%d.%d" v1 v2) | _ -> failwith (FSComp.SR.buildCouldNotReadVersionInfoFromMscorlib()) with e -> @@ -2637,48 +2630,15 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = #if !ENABLE_MONO_SUPPORT // TODO: we have to get msbuild out of this if data.useSimpleResolution then - None, (0, ""), false + None, "" else #endif - None, (4, data.referenceResolver.HighestInstalledNetFrameworkVersion()), false + None, data.legacyReferenceResolver.HighestInstalledNetFrameworkVersion() - // Note: anycpu32bitpreferred can only be used with .Net version 4.5 and above - // but now there is no way to discriminate between 4.0 and 4.5, - // so here we minimally validate if .Net version >= 4 or not. - do if data.prefer32Bit && mscorlibMajorVersion < 4 then - error(Error(FSComp.SR.invalidPlatformTargetForOldFramework(),rangeCmdArgs)) - let systemAssemblies = SystemAssemblies () - // Check that the referenced version of FSharp.Core.dll matches the referenced version of mscorlib.dll - let checkFSharpBinaryCompatWithMscorlib filename (ilAssemblyRefs: ILAssemblyRef list) explicitFscoreVersionToCheckOpt m = - let isfslib = fileNameOfPath filename = GetFSharpCoreLibraryName() + ".dll" - match ilAssemblyRefs |> List.tryFind (fun aref -> aref.Name = data.primaryAssembly.Name) with - | Some aref -> - match aref.Version with - | Some(v1,_,_,_) -> - if isfslib && ((v1 < 4us) <> (mscorlibMajorVersion < 4)) then - // the versions mismatch, however they are allowed to mismatch in one case: - if primaryAssemblyIsSilverlight && mscorlibMajorVersion=5 // SL5 - && (match explicitFscoreVersionToCheckOpt with - | Some(2us,3us,5us,_) // silverlight is supported for FSharp.Core 2.3.5.x and 3.47.x.y - | Some(3us,47us,_,_) - | None -> true // the 'None' code path happens after explicit FSCore was already checked, from now on SL5 path is always excepted - | _ -> false) - then - () - else - error(Error(FSComp.SR.buildMscorLibAndFSharpCoreMismatch(filename),m)) - // If you're building an assembly that references another assembly built for a more recent - // framework version, we want to raise a warning - elif not(isfslib) && ((v1 = 4us) && (mscorlibMajorVersion < 4)) then - warning(Error(FSComp.SR.buildMscorlibAndReferencedAssemblyMismatch(filename),m)) - else - () - | _ -> () - | _ -> () - // Look for an explicit reference to FSharp.Core and use that to compute fsharpBinariesDir + // FUTURE: remove this, we only read the binary for the exception it raises let fsharpBinariesDirValue = #if FX_NO_SIMPLIFIED_LOADER data.defaultFSharpBinariesDir @@ -2686,18 +2646,19 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = match fslibExplicitFilenameOpt with | Some(fslibFilename) -> let filename = ComputeMakePathAbsolute data.implicitIncludeDir fslibFilename - try - use ilReader = OpenILBinary(filename,data.optimizeForMemory,data.openBinariesInMemory,None,None, data.shadowCopyReferences) - checkFSharpBinaryCompatWithMscorlib filename ilReader.ILAssemblyRefs ilReader.ILModuleDef.ManifestOfAssembly.Version rangeStartup; - let fslibRoot = Path.GetDirectoryName(FileSystem.GetFullPathShim(filename)) - fslibRoot (* , sprintf "v%d.%d" v1 v2 *) - with e -> - error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup)) + if fslibReference.ProjectReference.IsNone then + try + use ilReader = OpenILBinary(filename,data.optimizeForMemory,data.openBinariesInMemory,None,None, data.shadowCopyReferences) + () + with e -> + error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup)) + + let fslibRoot = Path.GetDirectoryName(FileSystem.GetFullPathShim(filename)) + fslibRoot | _ -> data.defaultFSharpBinariesDir #endif - member x.MscorlibMajorVersion = mscorlibMajorVersion member x.primaryAssembly = data.primaryAssembly member x.autoResolveOpenDirectivesToDlls = data.autoResolveOpenDirectivesToDlls member x.noFeedback = data.noFeedback @@ -2800,6 +2761,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = member x.doFinalSimplify = data.doFinalSimplify member x.optSettings = data.optSettings member x.emitTailcalls = data.emitTailcalls + member x.deterministic = data.deterministic #if PREFERRED_UI_LANG member x.preferredUiLang = data.preferredUiLang #endif @@ -2828,7 +2790,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter TcConfig(builder,validate) - member x.referenceResolver = data.referenceResolver + member x.legacyReferenceResolver = data.legacyReferenceResolver member tcConfig.CloneOfOriginalBuilder = { data with conditionalCompilationDefines=data.conditionalCompilationDefines } @@ -2839,55 +2801,67 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = // This call can fail if no CLR is found (this is the path to mscorlib) member tcConfig.GetTargetFrameworkDirectories() = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter - match tcConfig.clrRoot with - | Some x -> - [tcConfig.MakePathAbsolute x] - | None -> -#if ENABLE_MONO_SUPPORT - if runningOnMono then - [ let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() - let runtimeRootWithoutSlash = runtimeRoot.TrimEnd('/', '\\') - let api = runtimeRootWithoutSlash + "-api" - let rootFacades = Path.Combine(runtimeRootWithoutSlash, "Facades") - let apiFacades = Path.Combine(api, "Facades") - match tcConfig.resolutionEnvironment with -#if !FSI_TODO_NETCORE - // For F# Interactive code we must inly reference impementation assemblies - | ReferenceResolver.RuntimeLike -> - yield runtimeRoot - if Directory.Exists(rootFacades) then - yield rootFacades // System.Runtime.dll is in /usr/lib/mono/4.5/Facades -#endif - | _ -> - // The default FSharp.Core is found in lib/mono/4.5 - yield runtimeRoot - if Directory.Exists(rootFacades) then - yield rootFacades // System.Runtime.dll is in /usr/lib/mono/4.5/Facades - // It's not clear why we would need to reference the 4.5-api directory. - if Directory.Exists(api) then - yield api - if Directory.Exists(apiFacades) then - yield apiFacades - ] - else + try + [ + // Check if we are given an explicit framework root - if so, use that + match tcConfig.clrRoot with + | Some x -> + yield tcConfig.MakePathAbsolute x + + | None -> +#if FSI_TODO_NETCORE // there is no really good notion of runtime directory on .NETCore + let runtimeRoot = Path.GetDirectoryName(typeof.Assembly.Location) +#else + let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() #endif - try - [ - match tcConfig.resolutionEnvironment with -#if !FSI_TODO_NETCORE - | ReferenceResolver.RuntimeLike -> - yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + let runtimeRootWithoutSlash = runtimeRoot.TrimEnd('/', '\\') + let runtimeRootFacades = Path.Combine(runtimeRootWithoutSlash, "Facades") + let runtimeRootWPF = Path.Combine(runtimeRootWithoutSlash, "WPF") + + match tcConfig.resolutionEnvironment with + | ResolutionEnvironment.CompilationAndEvaluation -> + // Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive + // + // In the current way of doing things, F# Interactive refers to implementation assemblies. + yield runtimeRoot + if Directory.Exists(runtimeRootFacades) then + yield runtimeRootFacades // System.Runtime.dll is in /usr/lib/mono/4.5/Facades + if Directory.Exists(runtimeRootWPF) then + yield runtimeRootWPF // PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF + + | ResolutionEnvironment.EditingOrCompilation _ -> +#if ENABLE_MONO_SUPPORT + if runningOnMono then + // Default compilation-time references on Mono + // + // On Mono, the default references come from the implementation assemblies. + // This is because we have had trouble reliably using MSBuild APIs to compute DotNetFrameworkReferenceAssembliesRootDirectory on Mono. + yield runtimeRoot + if Directory.Exists(runtimeRootFacades) then + yield runtimeRootFacades // System.Runtime.dll is in /usr/lib/mono/4.5/Facades + if Directory.Exists(runtimeRootWPF) then + yield runtimeRootWPF // PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF + // On Mono we also add a default reference to the 4.5-api and 4.5-api/Facades directories. + let runtimeRootApi = runtimeRootWithoutSlash + "-api" + let runtimeRootApiFacades = Path.Combine(runtimeRootApi, "Facades") + if Directory.Exists(runtimeRootApi) then + yield runtimeRootApi + if Directory.Exists(runtimeRootApiFacades) then + yield runtimeRootApiFacades + else #endif - | _ -> - let frameworkRoot = tcConfig.referenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory + // Default compilation-time references on .NET Framework + // + // This is the normal case for "fsc.exe a.fs". We refer to the reference assemblies folder. + let frameworkRoot = tcConfig.legacyReferenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory let frameworkRootVersion = Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersion) yield frameworkRootVersion let facades = Path.Combine(frameworkRootVersion, "Facades") if Directory.Exists(facades) then yield facades ] - with e -> - errorRecovery e range0; [] + with e -> + errorRecovery e range0; [] member tcConfig.ComputeLightSyntaxInitialStatus(filename) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter @@ -3026,10 +3000,6 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = member tcConfig.ResolveSourceFile(m, nm, pathLoadedFrom) = data.ResolveSourceFile(m, nm, pathLoadedFrom) - member tcConfig.CheckFSharpBinary (filename, ilAssemblyRefs, m) = - use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter - checkFSharpBinaryCompatWithMscorlib filename ilAssemblyRefs None m - // NOTE!! if mode=Speculative then this method must not report ANY warnings or errors through 'warning' or 'error'. Instead // it must return warnings and errors as data // @@ -3095,7 +3065,7 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) = // Whatever is left, pass to MSBuild. let Resolve(references,showMessages) = try - tcConfig.referenceResolver.Resolve + tcConfig.legacyReferenceResolver.Resolve (tcConfig.resolutionEnvironment, references, tcConfig.targetFrameworkVersion, @@ -3581,7 +3551,7 @@ type TcAssemblyResolutions(results : AssemblyResolution list, unresolved : Unres let assumeDotNetFramework = primaryReference.SimpleAssemblyNameIs("mscorlib") if tcConfig.framework then for s in DefaultReferencesForScriptsAndOutOfProjectSources(assumeDotNetFramework) do - yield AssemblyReference(rangeStartup,s+".dll",None) + yield AssemblyReference(rangeStartup,(if s.EndsWith(".dll",StringComparison.OrdinalIgnoreCase) then s else s+".dll"),None) if tcConfig.useFsiAuxLib then let name = Path.Combine(tcConfig.fsharpBinariesDir, GetFsiLibraryName() + ".dll") @@ -4171,7 +4141,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti if providerAssemblies.Count > 0 then // Find the SystemRuntimeAssemblyVersion value to report in the TypeProviderConfig. - let systemRuntimeAssemblyVersion = + let primaryAssemblyVersion = let primaryAssemblyRef = tcConfig.PrimaryAssemblyDllReference() let resolution = tcConfig.ResolveLibWithDirectories (CcuLoadFailureAction.RaiseError, primaryAssemblyRef) |> Option.get // MSDN: this method causes the file to be opened and closed, but the assembly is not added to this domain @@ -4182,7 +4152,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti { resolutionFolder = tcConfig.implicitIncludeDir outputFile = tcConfig.outputFile showResolutionMessages = tcConfig.showExtensionTypeMessages - referencedAssemblies = [| for r in tcImports.AllAssemblyResolutions() -> r.resolvedPath |] |> Seq.distinct |> Seq.toArray + referencedAssemblies = Array.distinct [| for r in tcImports.AllAssemblyResolutions() -> r.resolvedPath |] temporaryFolder = FileSystem.GetTempPathShim() } // The type provider should not hold strong references to disposed @@ -4198,7 +4168,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti let providers = [ for assemblyName in providerAssemblies do yield ExtensionTyping.GetTypeProvidersOfAssembly(fileNameOfRuntimeAssembly, ilScopeRefOfRuntimeAssembly, assemblyName, typeProviderEnvironment, - tcConfig.isInvalidationSupported, tcConfig.isInteractive, systemRuntimeContainsType, systemRuntimeAssemblyVersion, m) ] + tcConfig.isInvalidationSupported, tcConfig.isInteractive, systemRuntimeContainsType, primaryAssemblyVersion, m) ] let providers = providers |> List.concat // Note, type providers are disposable objects. The TcImports owns the provider objects - when/if it is disposed, the providers are disposed. @@ -4279,7 +4249,6 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti member tcImports.PrepareToImportReferencedILAssembly (ctok, m, filename, dllinfo:ImportedBinary) = CheckDisposed() let tcConfig = tcConfigP.Get(ctok) - tcConfig.CheckFSharpBinary (filename,dllinfo.ILAssemblyRefs,m) assert dllinfo.RawMetadata.TryGetRawILModule().IsSome let ilModule = dllinfo.RawMetadata.TryGetRawILModule().Value let ilScopeRef = dllinfo.ILScopeRef @@ -4316,9 +4285,9 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti member tcImports.PrepareToImportReferencedFSharpAssembly (ctok, m, filename, dllinfo:ImportedBinary) = CheckDisposed() +#if EXTENSIONTYPING let tcConfig = tcConfigP.Get(ctok) - tcConfig.CheckFSharpBinary (filename, dllinfo.ILAssemblyRefs, m) - +#endif let ilModule = dllinfo.RawMetadata let ilScopeRef = dllinfo.ILScopeRef let ilShortAssemName = getNameOfScopeRef ilScopeRef @@ -4566,8 +4535,8 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti // Note, if mode=ResolveAssemblyReferenceMode.Speculative and the resolution failed then TryResolveLibsUsingMSBuildRules returns // the empty list and we convert the failure into an AssemblyNotResolved here. ErrorD(AssemblyNotResolved(assemblyReference.Text,assemblyReference.Range)) - -#endif + +#endif member tcImports.ResolveAssemblyReference(ctok, assemblyReference, mode) : AssemblyResolution list = @@ -4649,7 +4618,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti // OK, now we have both mscorlib.dll and FSharp.Core.dll we can create TcGlobals let tcGlobals = TcGlobals(tcConfig.compilingFslib,ilGlobals,fslibCcu, tcConfig.implicitIncludeDir,tcConfig.mlCompatibility, - tcConfig.isInteractive,tryFindSysTypeCcu, tcConfig.emitDebugInfoInQuotations, (tcConfig.primaryAssembly.Name = "mscorlib"), tcConfig.noDebugData ) + tcConfig.isInteractive,tryFindSysTypeCcu, tcConfig.emitDebugInfoInQuotations, tcConfig.noDebugData ) #if DEBUG // the global_g reference cell is used only for debug printing @@ -4897,7 +4866,7 @@ type LoadClosure = [] type CodeContext = - | Evaluation // in fsi.exe + | CompilationAndEvaluation // in fsi.exe | Compilation // in fsc.exe | Editing // in VS @@ -4930,7 +4899,7 @@ module private ScriptPreprocessClosure = // .fsx -- EDITING + !COMPILED\INTERACTIVE let defines = match codeContext with - | CodeContext.Evaluation -> ["INTERACTIVE"] + | CodeContext.CompilationAndEvaluation -> ["INTERACTIVE"] | CodeContext.Compilation -> ["COMPILED"] | CodeContext.Editing -> "EDITING" :: (if IsScript filename then ["INTERACTIVE"] else ["COMPILED"]) let lexbuf = UnicodeLexing.StringAsLexbuf source @@ -4939,25 +4908,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 CreateScriptSourceTcConfig (referenceResolver, filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs, assumeDotNetFramework) = + let CreateScriptSourceTcConfig (legacyReferenceResolver, defaultFSharpBinariesDir, filename:string, codeContext, useSimpleResolution, useFsiAuxLib, basicReferences, applyCommandLineArgs, assumeDotNetFramework) = let projectDir = Path.GetDirectoryName(filename) - let isInteractive = (codeContext = CodeContext.Evaluation) + let isInteractive = (codeContext = CodeContext.CompilationAndEvaluation) let isInvalidationSupported = (codeContext = CodeContext.Editing) - // always use primary assembly = mscorlib for scripts - let tcConfigB = TcConfigBuilder.CreateNew(referenceResolver, Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(None).Value, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported) + let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, true (* optimize for memory *), projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore=false) applyCommandLineArgs tcConfigB match basicReferences with - | None -> BasicReferencesForScriptLoadClosure(useSimpleResolution, useFsiAuxLib, assumeDotNetFramework) |> List.iter(fun f->tcConfigB.AddReferencedAssemblyByPath(range0,f)) // Add script references + | 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) tcConfigB.resolutionEnvironment <- match codeContext with - | CodeContext.Editing -> ReferenceResolver.DesignTimeLike + | CodeContext.Editing -> ResolutionEnvironment.EditingOrCompilation true + | CodeContext.Compilation -> ResolutionEnvironment.EditingOrCompilation false + | CodeContext.CompilationAndEvaluation -> #if FSI_TODO_NETCORE - // "RuntimeLike" assembly resolution for F# Interactive is not yet properly figured out on .NET Core - | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.CompileTimeLike + // "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core + ResolutionEnvironment.EditingOrCompilation false #else - | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.RuntimeLike + ResolutionEnvironment.CompilationAndEvaluation #endif tcConfigB.framework <- false tcConfigB.useSimpleResolution <- useSimpleResolution @@ -5111,18 +5081,18 @@ module private ScriptPreprocessClosure = result /// Given source text, find the full load closure. Used from service.fs, when editing a script file - let GetFullClosureOfScriptSource(ctok, referenceResolver, filename, source, codeContext, useSimpleResolution,useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework) = + let GetFullClosureOfScriptSource(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, codeContext, useSimpleResolution,useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework) = // 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 = CreateScriptSourceTcConfig(referenceResolver, filename, codeContext, useSimpleResolution, useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework) + let tcConfig = CreateScriptSourceTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework) 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 = CreateScriptSourceTcConfig(referenceResolver, filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, applyCommmandLineArgs, assumeDotNetFramework) + let tcConfig = CreateScriptSourceTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, applyCommmandLineArgs, assumeDotNetFramework) let closureSources = [ClosureSource(filename,range0,source,true)] let closureFiles,tcConfig = FindClosureFiles(closureSources, tcConfig, codeContext, lexResourceManager) @@ -5138,9 +5108,9 @@ module private ScriptPreprocessClosure = type LoadClosure with // Used from service.fs, when editing a script file - static member ComputeClosureOfSourceText(ctok, referenceResolver, filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework) : LoadClosure = + static member ComputeClosureOfSourceText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename:string, source:string, codeContext, useSimpleResolution:bool, useFsiAuxLib, lexResourceManager:Lexhelp.LexResourceManager, applyCommmandLineArgs, assumeDotNetFramework) : LoadClosure = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse - ScriptPreprocessClosure.GetFullClosureOfScriptSource(ctok, referenceResolver, filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, applyCommmandLineArgs,assumeDotNetFramework) + ScriptPreprocessClosure.GetFullClosureOfScriptSource(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, codeContext, useSimpleResolution, useFsiAuxLib, lexResourceManager, applyCommmandLineArgs,assumeDotNetFramework) /// Used from fsi.fs and fsc.fs, for #load and command line. /// The resulting references are then added to a TcConfig. @@ -5218,12 +5188,15 @@ type TcState = tcsNiceNameGen: NiceNameGenerator tcsTcSigEnv: TcEnv tcsTcImplEnv: TcEnv + tcsCreatesGeneratedProvidedTypes: bool /// The accumulated results of type checking for this assembly tcsRootSigsAndImpls : TypecheckerSigsAndImpls } member x.NiceNameGenerator = x.tcsNiceNameGen member x.TcEnvFromSignatures = x.tcsTcSigEnv member x.TcEnvFromImpls = x.tcsTcImplEnv member x.Ccu = x.tcsCcu + member x.CreatesGeneratedProvidedTypes = x.tcsCreatesGeneratedProvidedTypes + member x.PartialAssemblySignature = let (RootSigsAndImpls(_rootSigs,_rootImpls,_allSigModulTyp,allImplementedSigModulTyp)) = x.tcsRootSigsAndImpls allImplementedSigModulTyp @@ -5272,6 +5245,7 @@ let GetInitialTcState(m,ccuName,tcConfig:TcConfig,tcGlobals,tcImports:TcImports, tcsNiceNameGen=niceNameGen tcsTcSigEnv=tcEnv0 tcsTcImplEnv=tcEnv0 + tcsCreatesGeneratedProvidedTypes=false tcsRootSigsAndImpls = RootSigsAndImpls (rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp) } @@ -5288,7 +5262,7 @@ let TypeCheckOneInputEventually let (RootSigsAndImpls(rootSigs,rootImpls,allSigModulTyp,allImplementedSigModulTyp)) = tcState.tcsRootSigsAndImpls let m = inp.Range let amap = tcImports.GetImportMap() - let! (topAttrs, mimpls,tcEnvAtEnd,tcSigEnv,tcImplEnv,topSigsAndImpls,ccuType) = + let! (topAttrs, implFiles,tcEnvAtEnd,tcSigEnv,tcImplEnv,topSigsAndImpls,ccuType,createsGeneratedProvidedTypes) = eventually { match inp with | ParsedInput.SigFile (ParsedSigFileInput(_, qualNameOfFile, _, _, _) as file) -> @@ -5302,10 +5276,10 @@ let TypeCheckOneInputEventually errorR(Error(FSComp.SR.buildImplementationAlreadyGivenDetail(qualNameOfFile.Text),m)) // Typecheck the signature file - let! (tcEnvAtEnd,tcEnv,smodulTypeRoot) = + let! (tcEnv,sigFileType,createsGeneratedProvidedTypes) = TypeCheckOneSigFile (tcGlobals,tcState.tcsNiceNameGen,amap,tcState.tcsCcu,checkForErrors,tcConfig.conditionalCompilationDefines,tcSink) tcState.tcsTcSigEnv file - let rootSigs = Zmap.add qualNameOfFile smodulTypeRoot rootSigs + let rootSigs = Zmap.add qualNameOfFile sigFileType rootSigs // Open the prefixPath for fsi.exe let tcEnv = @@ -5315,7 +5289,7 @@ let TypeCheckOneInputEventually let m = qualNameOfFile.Range TcOpenDecl tcSink tcGlobals amap m m tcEnv prefixPath - let res = (EmptyTopAttrs, [], tcEnvAtEnd, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType) + let res = (EmptyTopAttrs, [], tcEnv, tcEnv, tcState.tcsTcImplEnv, RootSigsAndImpls(rootSigs, rootImpls, allSigModulTyp, allImplementedSigModulTyp), tcState.tcsCcuType, createsGeneratedProvidedTypes) return res | ParsedInput.ImplFile (ParsedImplFileInput(filename,_,qualNameOfFile,_,_,_,_) as file) -> @@ -5332,7 +5306,7 @@ let TypeCheckOneInputEventually let tcImplEnv = tcState.tcsTcImplEnv // Typecheck the implementation file - let! topAttrs,implFile,tcEnvAtEnd = + let! topAttrs, implFile, tcEnvAtEnd, createsGeneratedProvidedTypes = TypeCheckOneImplFile (tcGlobals,tcState.tcsNiceNameGen,amap,tcState.tcsCcu,checkForErrors,tcConfig.conditionalCompilationDefines,tcSink) tcImplEnv rootSigOpt file let hadSig = Option.isSome rootSigOpt @@ -5375,14 +5349,15 @@ let TypeCheckOneInputEventually if verbose then dprintf "done TypeCheckOneInputEventually...\n" let topSigsAndImpls = RootSigsAndImpls(rootSigs,rootImpls,allSigModulTyp,allImplementedSigModulTyp) - let res = (topAttrs,[implFile], tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType) + let res = (topAttrs,[implFile], tcEnvAtEnd, tcSigEnv, tcImplEnv, topSigsAndImpls, ccuType, createsGeneratedProvidedTypes) return res } - return (tcEnvAtEnd,topAttrs,mimpls), + return (tcEnvAtEnd,topAttrs,implFiles), { tcState with tcsCcuType=ccuType tcsTcSigEnv=tcSigEnv tcsTcImplEnv=tcImplEnv + tcsCreatesGeneratedProvidedTypes=tcState.tcsCreatesGeneratedProvidedTypes || createsGeneratedProvidedTypes tcsRootSigsAndImpls = topSigsAndImpls } with e -> errorRecovery e range0 @@ -5399,14 +5374,14 @@ let TypeCheckOneInput (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, pre /// Finish checking multiple files (or one interactive entry into F# Interactive) let TypeCheckMultipleInputsFinish(results,tcState: TcState) = - let tcEnvsAtEndFile,topAttrs,mimpls = List.unzip3 results + let tcEnvsAtEndFile,topAttrs,implFiles = List.unzip3 results let topAttrs = List.foldBack CombineTopAttrs topAttrs EmptyTopAttrs - let mimpls = List.concat mimpls + let implFiles = List.concat implFiles // This is the environment required by fsi.exe when incrementally adding definitions let tcEnvAtEndOfLastFile = (match tcEnvsAtEndFile with h :: _ -> h | _ -> tcState.TcEnvFromSignatures) - (tcEnvAtEndOfLastFile,topAttrs,mimpls),tcState + (tcEnvAtEndOfLastFile,topAttrs,implFiles),tcState /// Check multiple files (or one interactive entry into F# Interactive) let TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) = @@ -5433,7 +5408,7 @@ let TypeCheckClosedInputSetFinish (declaredImpls: TypedImplFile list, tcState) = let TypeCheckClosedInputSet (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) = // tcEnvAtEndOfLastFile is the environment required by fsi.exe when incrementally adding definitions - let (tcEnvAtEndOfLastFile, topAttrs, mimpls),tcState = TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) - let tcState, declaredImpls = TypeCheckClosedInputSetFinish (mimpls, tcState) + let (tcEnvAtEndOfLastFile, topAttrs, implFiles),tcState = TypeCheckMultipleInputs (ctok, checkForErrors, tcConfig, tcImports, tcGlobals, prefixPathOpt, tcState, inputs) + let tcState, declaredImpls = TypeCheckClosedInputSetFinish (implFiles, tcState) tcState, topAttrs, declaredImpls, tcEnvAtEndOfLastFile diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index e257c967ad..ff9bf5b129 100755 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -30,13 +30,8 @@ open Microsoft.FSharp.Compiler.ExtensionTyping #if DEBUG -#if COMPILED_AS_LANGUAGE_SERVICE_DLL module internal CompilerService = -#else -module internal FullCompiler = -#endif val showAssertForUnexpectedException : bool ref - #endif //---------------------------------------------------------------------------- @@ -328,7 +323,7 @@ type TcConfigBuilder = mutable win32manifest : string mutable includewin32manifest : bool mutable linkResources : string list - mutable referenceResolver: ReferenceResolver.Resolver + mutable legacyReferenceResolver: ReferenceResolver.Resolver mutable showFullPaths : bool mutable errorStyle : ErrorStyle mutable utf8output : bool @@ -347,6 +342,7 @@ type TcConfigBuilder = mutable optsOn : bool mutable optSettings : Optimizer.OptimizationSettings mutable emitTailcalls : bool + mutable deterministic : bool #if PREFERRED_UI_LANG mutable preferredUiLang: string option #endif @@ -376,12 +372,13 @@ type TcConfigBuilder = } static member CreateNew : - referenceResolver: ReferenceResolver.Resolver * + legacyReferenceResolver: ReferenceResolver.Resolver * defaultFSharpBinariesDir: string * optimizeForMemory: bool * implicitIncludeDir: string * isInteractive: bool * - isInvalidationSupported: bool -> TcConfigBuilder + isInvalidationSupported: bool * + defaultCopyFSharpCore: bool -> TcConfigBuilder member DecideNames : string list -> outfile: string * pdbfile: string option * assemblyName: string member TurnWarningOff : range * string -> unit @@ -498,6 +495,7 @@ type TcConfig = member doFinalSimplify : bool member optSettings : Optimizer.OptimizationSettings member emitTailcalls : bool + member deterministic : bool #if PREFERRED_UI_LANG member preferredUiLang: string option #else @@ -539,9 +537,7 @@ type TcConfig = member sqmNumOfSourceFiles : int member sqmSessionStartedTime : int64 member copyFSharpCore : bool -#if FSI_SHADOW_COPY_REFERENCES member shadowCopyReferences : bool -#endif static member Create : TcConfigBuilder * validate: bool -> TcConfig /// Represents a computation to return a TcConfig. Normally this is just a constant immutable TcConfig, @@ -728,6 +724,8 @@ type TcState = member NextStateAfterIncrementalFragment : TcEnv -> TcState + member CreatesGeneratedProvidedTypes : bool + /// Get the initial type checking state for a set of inputs val GetInitialTcState : range * string * TcConfig * TcGlobals * TcImports * Ast.NiceNameGenerator * TcEnv -> TcState @@ -763,7 +761,7 @@ val ReportWarningAsError : globalWarnLevel: int * specificWarnOff: int list * sp [] type CodeContext = - | Evaluation + | CompilationAndEvaluation | Compilation | Editing @@ -805,7 +803,7 @@ type LoadClosure = LoadClosureRootFileDiagnostics : (PhasedDiagnostic * bool) list } // Used from service.fs, when editing a script file - static member ComputeClosureOfSourceText : CompilationThreadToken * referenceResolver: ReferenceResolver.Resolver * filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) * assumeDotNetFramework : bool -> LoadClosure + static member ComputeClosureOfSourceText : CompilationThreadToken * legacyReferenceResolver: ReferenceResolver.Resolver * defaultFSharpBinariesDir: string * filename: string * source: string * implicitDefines:CodeContext * useSimpleResolution: bool * useFsiAuxLib: bool * lexResourceManager: Lexhelp.LexResourceManager * applyCompilerOptions: (TcConfigBuilder -> unit) * assumeDotNetFramework : bool -> LoadClosure /// Used from fsi.fs and fsc.fs, for #load and command line. The resulting references are then added to a TcConfig. static member ComputeClosureOfSourceFiles : CompilationThreadToken * tcConfig:TcConfig * (string * range) list * implicitDefines:CodeContext * lexResourceManager : Lexhelp.LexResourceManager -> LoadClosure diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index 9786008502..753a85e3e4 100755 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -420,7 +420,10 @@ let SetOptimizeSwitch (tcConfigB : TcConfigBuilder) switch = let SetTailcallSwitch (tcConfigB : TcConfigBuilder) switch = tcConfigB.emitTailcalls <- (switch = OptionSwitch.On) - + +let SetDeterministicSwitch (tcConfigB : TcConfigBuilder) switch = + tcConfigB.deterministic <- (switch = OptionSwitch.On) + let jitoptimizeSwitch (tcConfigB : TcConfigBuilder) switch = tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some (switch = OptionSwitch.On) } @@ -676,6 +679,8 @@ let codeGenerationFlags isFsi (tcConfigB : TcConfigBuilder) = 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())) ] @@ -723,7 +728,7 @@ let codePageFlag (tcConfigB : TcConfigBuilder) = #if PREFERRED_UI_LANG let preferredUiLang (tcConfigB: TcConfigBuilder) = - CompilerOption("preferreduilang", tagString, OptionString (fun s -> tcConfigB.preferredUiLang <- Some(s)), None, Some(FSComp.SR.optsStrongKeyContainer())) + CompilerOption("preferreduilang", tagString, OptionString (fun s -> tcConfigB.preferredUiLang <- Some(s)), None, Some(FSComp.SR.optsPreferredUiLang())) #endif let utf8OutputFlag (tcConfigB: TcConfigBuilder) = @@ -741,8 +746,12 @@ let cliRootFlag (_tcConfigB : TcConfigBuilder) = let SetTargetProfile tcConfigB v = tcConfigB.primaryAssembly <- match v with + // Indicates we assume "mscorlib.dll", i.e .NET Framework, Mono and Profile 47 | "mscorlib" -> PrimaryAssembly.Mscorlib - | "netcore" -> PrimaryAssembly.DotNetCore + // Indicates we assume "System.Runtime.dll", i.e .NET Standard 1.x, .NET Core App 1.x and above, and Profile 7/78/259 + | "netcore" -> PrimaryAssembly.System_Runtime + // Indicates we assume "netstandard.dll", i.e .NET Standard 2.0 and above + | "netstandard" -> PrimaryAssembly.NetStandard | _ -> error(Error(FSComp.SR.optsInvalidTargetProfile(v), rangeCmdArgs)) let advancedFlagsBoth tcConfigB = diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index f1c0d451e3..4c477bc955 100755 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -30,12 +30,10 @@ module internal Microsoft.FSharp.Compiler.ConstraintSolver // //------------------------------------------------------------------------- -open Internal.Utilities open Internal.Utilities.Collections open Microsoft.FSharp.Compiler 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 Microsoft.FSharp.Compiler.Ast @@ -51,7 +49,6 @@ open Microsoft.FSharp.Compiler.Rational 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 @@ -120,6 +117,8 @@ let FreshenMethInfo m (minfo:MethInfo) = type ContextInfo = /// No context was given. | NoContext +/// The type equation comes from an IF expression. +| IfExpression of range /// The type equation comes from an omitted else branch. | OmittedElseBranch of range /// The type equation comes from a type check of the result of an else branch. @@ -128,6 +127,8 @@ type ContextInfo = | RecordFields /// The type equation comes from the verification of a tuple in record fields. | TupleInRecordFields +/// The type equation comes from a list or array constructor +| CollectionElement of bool * range /// The type equation comes from a return in a computation expression. | ReturnInComputationExpression /// The type equation comes from a yield in a computation expression. @@ -136,6 +137,10 @@ type ContextInfo = | RuntimeTypeTest of bool /// The type equation comes from an downcast where a upcast could be used. | DowncastUsedInsteadOfUpcast of bool +/// The type equation comes from a return type of a pattern match clause (not the first clause). +| FollowingPatternMatchClause of range +/// The type equation comes from a pattern match guard. +| PatternMatchGuard of range exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range exception ConstraintSolverInfiniteTypes of ContextInfo * DisplayEnv * TType * TType * range * range @@ -224,19 +229,19 @@ let rec occursCheck g un ty = // Predicates on types //------------------------------------------------------------------------- -let rec isNativeIntegerTy g ty = +let rec isNativeIntegerTy g ty = typeEquivAux EraseMeasures g g.nativeint_ty ty || typeEquivAux EraseMeasures g g.unativeint_ty ty || (isEnumTy g ty && isNativeIntegerTy g (underlyingTypeOfEnumTy g ty)) -let isSignedIntegerTy g ty = +let isSignedIntegerTy g ty = typeEquivAux EraseMeasures g g.sbyte_ty ty || typeEquivAux EraseMeasures g g.int16_ty ty || typeEquivAux EraseMeasures g g.int32_ty ty || typeEquivAux EraseMeasures g g.nativeint_ty ty || typeEquivAux EraseMeasures g g.int64_ty ty -let isUnsignedIntegerTy g ty = +let isUnsignedIntegerTy g ty = typeEquivAux EraseMeasures g g.byte_ty ty || typeEquivAux EraseMeasures g g.uint16_ty ty || typeEquivAux EraseMeasures g g.uint32_ty ty || @@ -770,10 +775,10 @@ and SolveTypEqualsTyp (csenv:ConstraintSolverEnv) ndeep m2 (trace: OptionalTrace match sty1, sty2 with // type vars inside forall-types may be alpha-equivalent - | TType_var tp1, TType_var tp2 when typarEq tp1 tp2 || (aenv.EquivTypars.ContainsKey tp1 && typeEquiv g aenv.EquivTypars.[tp1] ty2) -> CompleteD + | TType_var tp1, TType_var tp2 when typarEq tp1 tp2 || (aenv.EquivTypars.ContainsKey tp1 && typeEquiv g aenv.EquivTypars.[tp1] ty2) -> CompleteD | TType_var tp1, TType_var tp2 when PreferUnifyTypar tp1 tp2 -> SolveTyparEqualsTyp csenv ndeep m2 trace sty1 ty2 - | TType_var tp1, TType_var tp2 when PreferUnifyTypar tp2 tp1 && not csenv.MatchingOnly -> SolveTyparEqualsTyp csenv ndeep m2 trace sty2 ty1 + | TType_var tp1, TType_var tp2 when not csenv.MatchingOnly && PreferUnifyTypar tp2 tp1 -> SolveTyparEqualsTyp csenv ndeep m2 trace sty2 ty1 | TType_var r, _ when (r.Rigidity <> TyparRigidity.Rigid) -> SolveTyparEqualsTyp csenv ndeep m2 trace sty1 ty2 | _, TType_var r when (r.Rigidity <> TyparRigidity.Rigid) && not csenv.MatchingOnly -> SolveTyparEqualsTyp csenv ndeep m2 trace sty2 ty1 @@ -1834,7 +1839,7 @@ and SolveTypRequiresDefaultConstructor (csenv:ConstraintSolverEnv) ndeep m2 trac CompleteD else if GetIntrinsicConstructorInfosOfType csenv.InfoReader m ty - |> List.exists (fun x -> IsMethInfoAccessible amap m AccessibleFromEverywhere x && x.IsNullary) + |> List.exists (fun x -> x.IsNullary && IsMethInfoAccessible amap m AccessibleFromEverywhere x) then match tryDestAppTy g ty with | Some tcref when HasFSharpAttribute g g.attrib_AbstractClassAttribute tcref.Attribs -> @@ -1956,20 +1961,22 @@ and CanMemberSigsMatchUpToCheck // to allow us to report the outer types involved in the constraint and private SolveTypSubsumesTypWithReport (csenv:ConstraintSolverEnv) ndeep m trace cxsln ty1 ty2 = TryD (fun () -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m trace cxsln ty1 ty2) - (fun res -> - match csenv.eContextInfo with - | ContextInfo.RuntimeTypeTest isOperator -> - // test if we can cast other way around - match CollectThenUndo (fun newTrace -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m (OptionalTrace.WithTrace newTrace) cxsln ty2 ty1) with - | OkResult _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,ContextInfo.DowncastUsedInsteadOfUpcast isOperator,m)) - | _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,ContextInfo.NoContext,m)) - | _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,csenv.eContextInfo,m))) + (function + | LocallyAbortOperationThatFailsToResolveOverload -> CompleteD + | res -> + match csenv.eContextInfo with + | ContextInfo.RuntimeTypeTest isOperator -> + // test if we can cast other way around + match CollectThenUndo (fun newTrace -> SolveTypSubsumesTypKeepAbbrevs csenv ndeep m (OptionalTrace.WithTrace newTrace) cxsln ty2 ty1) with + | OkResult _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,ContextInfo.DowncastUsedInsteadOfUpcast isOperator,m)) + | _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,ContextInfo.NoContext,m)) + | _ -> ErrorD (ErrorsFromAddingSubsumptionConstraint(csenv.g,csenv.DisplayEnv,ty1,ty2,res,csenv.eContextInfo,m))) and private SolveTypEqualsTypWithReport (csenv:ConstraintSolverEnv) ndeep m trace cxsln ty1 ty2 = TryD (fun () -> SolveTypEqualsTypKeepAbbrevsWithCxsln csenv ndeep m trace cxsln ty1 ty2) (function - | LocallyAbortOperationThatFailsToResolveOverload -> CompleteD - | res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g,csenv.DisplayEnv,ty1,ty2,res,m))) + | LocallyAbortOperationThatFailsToResolveOverload -> CompleteD + | res -> ErrorD (ErrorFromAddingTypeEquation(csenv.g,csenv.DisplayEnv,ty1,ty2,res,m))) and ArgsMustSubsumeOrConvert (csenv:ConstraintSolverEnv) @@ -1985,8 +1992,7 @@ and ArgsMustSubsumeOrConvert let calledArgTy = AdjustCalledArgType csenv.InfoReader isConstraint calledArg callerArg SolveTypSubsumesTypWithReport csenv ndeep m trace cxsln calledArgTy callerArg.Type ++ (fun () -> - if calledArg.IsParamArray && isArray1DTy g calledArgTy && not (isArray1DTy g callerArg.Type) - then + if calledArg.IsParamArray && isArray1DTy g calledArgTy && not (isArray1DTy g callerArg.Type) then ErrorD(Error(FSComp.SR.csMethodExpectsParams(),m)) else CompleteD) @@ -2363,9 +2369,10 @@ and ResolveOverloading let bestMethods = - applicableMeths |> List.choose (fun candidate -> - if applicableMeths |> List.forall (fun other -> - p13 candidate === p13 other || // REVIEW: change this needless use of pointer equality to be an index comparison + let indexedApplicableMeths = applicableMeths |> List.indexed + indexedApplicableMeths |> List.choose (fun (i,candidate) -> + if indexedApplicableMeths |> List.forall (fun (j,other) -> + i = j || let res = better candidate other //eprintfn "\n-------\nCandidate: %s\nOther: %s\nResult: %d\n" (NicePrint.stringOfMethInfo amap m denv (fst candidate).Method) (NicePrint.stringOfMethInfo amap m denv (fst other).Method) res res > 0) then @@ -2657,7 +2664,7 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait | true, false, 2 -> // If we resolve to an instance field on a struct and we haven't yet taken // the address of the object then go do that - if rfref.Tycon.IsStructOrEnumTycon && not (isByrefTy g (tyOfExpr g argExprs.[0])) then + if rfref.Tycon.IsStructOrEnumTycon && not (isByrefTy g (tyOfExpr g argExprs.[0])) then let h = List.head argExprs let wrap,h' = mkExprAddrOfExpr g true false DefinitelyMutates h None m Some (wrap (mkRecdFieldSetViaExprAddr (h', rfref, tinst, argExprs.[1], m))) @@ -2666,7 +2673,7 @@ let CodegenWitnessThatTypSupportsTraitConstraint tcVal g amap m (traitInfo:Trait | false, true, 0 -> Some (mkStaticRecdFieldGet (rfref, tinst, m)) | false, false, 1 -> - if rfref.Tycon.IsStructOrEnumTycon && isByrefTy g (tyOfExpr g argExprs.[0]) then + if rfref.Tycon.IsStructOrEnumTycon && isByrefTy g (tyOfExpr g argExprs.[0]) then Some (mkRecdFieldGetViaExprAddr (argExprs.[0], rfref, tinst, m)) else Some (mkRecdFieldGet g (argExprs.[0], rfref, tinst, m)) diff --git a/src/fsharp/ConstraintSolver.fsi b/src/fsharp/ConstraintSolver.fsi index fc30e946f5..d4175f98bc 100755 --- a/src/fsharp/ConstraintSolver.fsi +++ b/src/fsharp/ConstraintSolver.fsi @@ -52,6 +52,8 @@ val FreshenMethInfo : range -> MethInfo -> TType list type ContextInfo = /// No context was given. | NoContext +/// The type equation comes from an IF expression. +| IfExpression of range /// The type equation comes from an omitted else branch. | OmittedElseBranch of range /// The type equation comes from a type check of the result of an else branch. @@ -60,6 +62,8 @@ type ContextInfo = | RecordFields /// The type equation comes from the verification of a tuple in record fields. | TupleInRecordFields +/// The type equation comes from a list or array constructor +| CollectionElement of bool * range /// The type equation comes from a return in a computation expression. | ReturnInComputationExpression /// The type equation comes from a yield in a computation expression. @@ -68,6 +72,11 @@ type ContextInfo = | RuntimeTypeTest of bool /// The type equation comes from an downcast where a upcast could be used. | DowncastUsedInsteadOfUpcast of bool +/// The type equation comes from a return type of a pattern match clause (not the first clause). +| FollowingPatternMatchClause of range +/// The type equation comes from a pattern match guard. +| PatternMatchGuard of range + exception ConstraintSolverTupleDiffLengths of DisplayEnv * TType list * TType list * range * range exception ConstraintSolverInfiniteTypes of ContextInfo * DisplayEnv * TType * TType * range * range diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs index b91fcebee5..ac2de895d4 100755 --- a/src/fsharp/ErrorLogger.fs +++ b/src/fsharp/ErrorLogger.fs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.ErrorLogger +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.ErrorLogger +#else +module internal Microsoft.FSharp.Compiler.ErrorLogger +#endif open Internal.Utilities @@ -18,14 +22,18 @@ open System /// Represents the style being used to format errors [] type ErrorStyle = -| DefaultErrors -| EmacsErrors -| TestErrors -| VSErrors -| GccErrors + | DefaultErrors + | EmacsErrors + | TestErrors + | VSErrors + | GccErrors /// Thrown when we want to add some range information to a .NET exception -exception WrappedError of exn * range +exception WrappedError of exn * range with + override this.Message = + match this :> exn with + | WrappedError (exn, _) -> "WrappedError(" + exn.Message + ")" + | _ -> "WrappedError" /// Thrown when immediate, local error recovery is not possible. This indicates /// we've reported an error but need to make a non-local transfer of control. @@ -35,10 +43,11 @@ exception WrappedError of exn * range /// situations (LazyWithContext) we may need to re-report the original error /// when a lazy thunk is re-evaluated. exception ReportedError of exn option with - override this.Message = + override this.Message = + let msg = "The exception has been reported. This internal exception should now be caught at an error recovery point on the stack." match this :> exn with - | ReportedError (Some exn) -> exn.Message - | _ -> "ReportedError" + | ReportedError (Some exn) -> msg + " Original message: " + exn.Message + ")" + | _ -> msg let rec findOriginalException err = match err with @@ -46,17 +55,23 @@ let rec findOriginalException err = | WrappedError(err,_) -> findOriginalException err | _ -> err - type Suggestions = unit -> Set let NoSuggestions : Suggestions = fun () -> Set.empty /// Thrown when we stop processing the F# Interactive entry or #load. -exception StopProcessingExn of exn option +exception StopProcessingExn of exn option with + override this.Message = "Processing of a script fragment has stopped because an exception has been raised" + + override this.ToString() = + match this :> exn with + | StopProcessingExn(Some exn) -> "StopProcessingExn, originally (" + exn.ToString() + ")" + | _ -> "StopProcessingExn" + + let (|StopProcessing|_|) exn = match exn with StopProcessingExn _ -> Some () | _ -> None let StopProcessing<'T> = StopProcessingExn None -(* common error kinds *) exception NumberedError of (int * string) * range with // int is e.g. 191 in FS0191 override this.Message = match this :> exn with @@ -70,26 +85,32 @@ exception Error of (int * string) * range with // int is e.g. 191 in FS0191 / | _ -> "impossible" -exception ErrorWithSuggestions of (int * string) * range * string * Suggestions with // int is e.g. 191 in FS0191 - override this.Message = - match this :> exn with - | ErrorWithSuggestions((_,msg),_,_,_) -> msg +exception InternalError of msg: string * range with + override this.Message = + match this :> exn with + | InternalError(msg,m) -> msg + m.ToString() | _ -> "impossible" -exception InternalError of string * range exception UserCompilerMessage of string * int * range exception LibraryUseOnly of range exception Deprecated of string * range exception Experimental of string * range exception PossibleUnverifiableCode of range -// Range/NoRange Duals exception UnresolvedReferenceNoRange of (*assemblyname*) string exception UnresolvedReferenceError of (*assemblyname*) string * range exception UnresolvedPathReferenceNoRange of (*assemblyname*) string * (*path*) string exception UnresolvedPathReference of (*assemblyname*) string * (*path*) string * range + +exception ErrorWithSuggestions of (int * string) * range * string * Suggestions with // int is e.g. 191 in FS0191 + override this.Message = + match this :> exn with + | ErrorWithSuggestions((_,msg),_,_,_) -> msg + | _ -> "impossible" + + let inline protectAssemblyExploration dflt f = try f() @@ -145,9 +166,9 @@ let QuitProcessExiter = type BuildPhase = | DefaultPhase | Compile - | Parameter | Parse | TypeCheck + | Parameter | Parse | TypeCheck | CodeGen - | Optimize | IlxGen | IlGen | Output + | Optimize | IlxGen | IlGen | Output | Interactive // An error seen during interactive execution /// Literal build phase subcategory strings. @@ -180,12 +201,16 @@ module BuildPhaseSubcategory = [] type PhasedDiagnostic = { Exception:exn; Phase:BuildPhase } + /// Construct a phased error static member Create(exn:exn,phase:BuildPhase) : PhasedDiagnostic = - //System.Diagnostics.Debug.Assert(phase<>BuildPhase.DefaultPhase, sprintf "Compile error seen with no phase to attribute it to.%A %s %s" phase exn.Message exn.StackTrace ) + // FUTURE: renable this assert, which has historically triggered in some compiler service scenarios + // System.Diagnostics.Debug.Assert(phase<>BuildPhase.DefaultPhase, sprintf "Compile error seen with no phase to attribute it to.%A %s %s" phase exn.Message exn.StackTrace ) {Exception = exn; Phase=phase} + member this.DebugDisplay() = sprintf "%s: %s" (this.Subcategory()) this.Exception.Message + /// This is the textual subcategory to display in error and warning messages (shows only under --vserrors): /// /// file1.fs(72): subcategory warning FS0072: This is a warning message @@ -203,6 +228,7 @@ type PhasedDiagnostic = | IlGen -> BuildPhaseSubcategory.IlGen | Output -> BuildPhaseSubcategory.Output | Interactive -> BuildPhaseSubcategory.Interactive + /// Return true if the textual phase given is from the compile part of the build process. /// This set needs to be equal to the set of subcategories that the language service can produce. static member IsSubcategoryOfCompile(subcategory:string) = @@ -230,6 +256,7 @@ type PhasedDiagnostic = // if it came from the build and not the language service. false /// Return true if this phase is one that's known to be part of the 'compile'. This is the initial phase of the entire compilation that + /// the language service knows about. member pe.IsPhaseInCompile() = let isPhaseInCompile = @@ -261,8 +288,10 @@ let DiscardErrorsLogger = let AssertFalseErrorLogger = { new ErrorLogger("AssertFalseErrorLogger") with + // TODO: renable these asserts in the compiler service member x.DiagnosticSink(phasedError,isError) = (* assert false; *) () - member x.ErrorCount = (* assert false; *) 0 } + member x.ErrorCount = (* assert false; *) 0 + } type CapturingErrorLogger(nm) = inherit ErrorLogger(nm) @@ -291,6 +320,7 @@ type internal CompileThreadStatic = static member BuildPhase with get() = match box CompileThreadStatic.buildPhase with + // FUTURE: renable these asserts, which have historically fired in some compiler service scernaios | null -> (* assert false; *) BuildPhase.DefaultPhase | _ -> CompileThreadStatic.buildPhase and set v = CompileThreadStatic.buildPhase <- v @@ -307,9 +337,7 @@ type internal CompileThreadStatic = module ErrorLoggerExtensions = open System.Reflection - // Instruct the exception not to reset itself when thrown again. - // Design Note: This enables the compiler to prompt the user to send mail to fsbugs@microsoft.com, - // by catching the exception, prompting and then propagating the exception with reraise. + /// Instruct the exception not to reset itself when thrown again. let PreserveStackTrace(exn) = try let preserveStackTrace = typeof.GetMethod("InternalPreserveStackTrace", BindingFlags.Instance ||| BindingFlags.NonPublic) @@ -320,7 +348,7 @@ module ErrorLoggerExtensions = () - // Reraise an exception if it is one we want to report to Watson. + /// Reraise an exception if it is one we want to report to Watson. let ReraiseIfWatsonable(exn:exn) = #if FX_REDUCED_EXCEPTIONS ignore exn @@ -333,7 +361,7 @@ module ErrorLoggerExtensions = | :? System.IO.IOException -> () // This covers FileNotFoundException and DirectoryNotFoundException | :? System.UnauthorizedAccessException -> () | Failure _ // This gives reports for compiler INTERNAL ERRORs - | :? System.SystemException -> + | :? System.SystemException -> PreserveStackTrace(exn) raise exn | _ -> () @@ -342,15 +370,24 @@ module ErrorLoggerExtensions = type ErrorLogger with member x.ErrorR exn = + match exn with + | InternalError (s,_) + | Failure s as exn -> System.Diagnostics.Debug.Assert(false,sprintf "Unexpected exception raised in compiler: %s\n%s" s (exn.ToString())) + | _ -> () + match exn with | StopProcessing - | ReportedError _ -> raise exn + | ReportedError _ -> + PreserveStackTrace(exn) + raise exn | _ -> x.DiagnosticSink(PhasedDiagnostic.Create(exn,CompileThreadStatic.BuildPhase), true) member x.Warning exn = match exn with | StopProcessing - | ReportedError _ -> raise exn + | ReportedError _ -> + PreserveStackTrace(exn) + raise exn | _ -> x.DiagnosticSink(PhasedDiagnostic.Create(exn,CompileThreadStatic.BuildPhase), false) member x.Error exn = @@ -371,13 +408,16 @@ module ErrorLoggerExtensions = | :? System.Threading.ThreadAbortException | WrappedError((:? System.Threading.ThreadAbortException),_) -> () #endif | ReportedError _ | WrappedError(ReportedError _,_) -> () - | StopProcessing | WrappedError(StopProcessing,_) -> raise exn + | StopProcessing | WrappedError(StopProcessing,_) -> + PreserveStackTrace(exn) + raise exn | _ -> try x.ErrorR (AttachRange m exn) // may raise exceptions, e.g. an fsi error sink raises StopProcessing. ReraiseIfWatsonable(exn) with | ReportedError _ | WrappedError(ReportedError _,_) -> () + member x.StopProcessingRecovery (exn:exn) (m:range) = // Do standard error recovery. // Additionally ignore/catch StopProcessing. [This is the only catch handler for StopProcessing]. @@ -390,6 +430,7 @@ module ErrorLoggerExtensions = with | StopProcessing | WrappedError(StopProcessing,_) -> () // catch, e.g. raised by DiagnosticSink. | ReportedError _ | WrappedError(ReportedError _,_) -> () // catch, but not expected unless ErrorRecovery is changed. + member x.ErrorRecoveryNoRange (exn:exn) = x.ErrorRecovery exn range0 diff --git a/src/fsharp/ExtensionTyping.fs b/src/fsharp/ExtensionTyping.fs index 9f4e3079a2..13d032323d 100755 --- a/src/fsharp/ExtensionTyping.fs +++ b/src/fsharp/ExtensionTyping.fs @@ -538,11 +538,8 @@ module internal ExtensionTyping = let staticParams = match provider with -#if COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_3_0_0 -#else | :? ITypeProvider2 as itp2 -> itp2.GetStaticParametersForMethod(x) -#endif | _ -> // To allow a type provider to depend only on FSharp.Core 4.3.0.0, it can alternatively implement an appropriate method called GetStaticParametersForMethod let meth = provider.GetType().GetMethod( "GetStaticParametersForMethod", bindingFlags, null, [| typeof |], null) @@ -559,11 +556,8 @@ module internal ExtensionTyping = let mb = match provider with -#if COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_3_0_0 -#else | :? ITypeProvider2 as itp2 -> itp2.ApplyStaticArgumentsForMethod(x, fullNameAfterArguments, staticArgs) -#endif | _ -> // To allow a type provider to depend only on FSharp.Core 4.3.0.0, it can alternatively implement a method called GetStaticParametersForMethod let meth = provider.GetType().GetMethod( "ApplyStaticArgumentsForMethod", bindingFlags, null, [| typeof; typeof; typeof |], null) diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt index 47fcbaa347..4892447a51 100755 --- a/src/fsharp/FSComp.txt +++ b/src/fsharp/FSComp.txt @@ -16,8 +16,14 @@ undefinedNameSuggestionsIntro,"Maybe you want one of the following:" undefinedNameTypeParameter,"The type parameter %s is not defined." undefinedNamePatternDiscriminator,"The pattern discriminator '%s' is not defined." replaceWithSuggestion,"Replace with '%s'" +addIndexerDot,"Add . for indexer access." +listElementHasWrongType,"All elements of a list constructor expression must have the same type. This expression was expected to have type '%s', but here has type '%s'." +arrayElementHasWrongType,"All elements of an array constructor expression must have the same type. This expression was expected to have type '%s', but here has type '%s'." missingElseBranch,"The 'if' expression is missing an 'else' branch. The 'then' branch has type '%s'. Because 'if' is an expression, and not a statement, add an 'else' branch which returns a value of the same type." -elseBranchHasWrongType,"All branches of an 'if' expression must return the same type. This expression was expected to have type '%s' but here has type '%s'." +ifExpression,"The 'if' expression needs to have type '%s' to satisfy context type requirements. It currently has type '%s'." +elseBranchHasWrongType,"All branches of an 'if' expression must have the same type. This expression was expected to have type '%s', but here has type '%s'." +followingPatternMatchClauseHasWrongType,"All branches of a pattern match expression must have the same type. This expression was expected to have type '%s', but here has type '%s'." +patternMatchGuardIsNotBool,"A pattern match guard must be of type 'bool', but this 'when' expression is of type '%s'." commaInsteadOfSemicolonInRecord,"A ';' is used to separate field values in records. Consider replacing ',' with ';'." derefInsteadOfNot,"The '!' operator is used to dereference a ref cell. Consider using 'not expr' here." buildUnexpectedTypeArgs,"The non-generic type '%s' does not expect any type arguments, but here is given %d type argument(s)" @@ -27,7 +33,8 @@ tupleRequiredInAbstractMethod,"\nA tuple type is required for one or more argume 203,buildInvalidWarningNumber,"Invalid warning number '%s'" 204,buildInvalidVersionString,"Invalid version string '%s'" 205,buildInvalidVersionFile,"Invalid version file '%s'" -buildProductName,"F# Compiler for F# %s" +buildProductName,"Microsoft (R) F# Compiler version %s" +buildProductNameCommunity,"F# Compiler for F# %s" 206,buildProblemWithFilename,"Problem with filename '%s': %s" 207,buildNoInputsSpecified,"No inputs specified" 209,buildPdbRequiresDebug,"The '--pdb' option requires the '--debug' option to be used" @@ -37,11 +44,8 @@ buildProductName,"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" -216,buildRequiresCLI2,"The file '%s' is a CLI 1.x version of mscorlib. F# requires CLI version 2.0 or greater." buildCouldNotReadVersionInfoFromMscorlib,"Could not read version from mscorlib.dll" -217,buildMscorlibAndReferencedAssemblyMismatch,"The referenced or default base CLI library 'mscorlib' is binary-incompatible with the referenced library '%s'. Consider recompiling the library or making an explicit reference to a version of this library that matches the CLI version you are using." 218,buildCannotReadAssembly,"Unable to read assembly '%s'" -219,buildMscorLibAndFSharpCoreMismatch,"The referenced or default base CLI library 'mscorlib' is binary-incompatible with the referenced F# core library '%s'. Consider recompiling the library or making an explicit reference to a version of this library that matches the CLI version you are using." 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." 222,buildMultiFileRequiresNamespaceOrModule,"Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration." @@ -258,17 +262,17 @@ chkVariableUsedInInvalidWay,"The variable '%s' is used in an invalid way" 433,chkEntryPointUsage,"A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence." chkUnionCaseCompiledForm,"compiled form of the union case" chkUnionCaseDefaultAugmentation,"default augmentation of the union case" -434,chkPropertySameNameMethod,"Name clash. The property '%s' has the same name as a method in this type." -435,chkGetterSetterDoNotMatchAbstract,"The property '%s' has a getter and a setter that do not match. If one is abstract then the other must be as well." -436,chkPropertySameNameIndexer,"The property '%s' has the same name as another property in this type, but one takes indexer arguments and the other does not. You may be missing an indexer argument to one of your properties." +434,chkPropertySameNameMethod,"The property '%s' has the same name as a method in type '%s'." +435,chkGetterSetterDoNotMatchAbstract,"The property '%s' of type '%s' has a getter and a setter that do not match. If one is abstract then the other must be as well." +436,chkPropertySameNameIndexer,"The property '%s' has the same name as another property in type '%s', but one takes indexer arguments and the other does not. You may be missing an indexer argument to one of your properties." 437,chkCantStoreByrefValue,"A type would store a byref typed value. This is not permitted by Common IL." #See related 1205 chkDuplicateInherittedVirtualMethod -438,chkDuplicateMethod,"Duplicate method. The method '%s' has the same name and signature as another method in this type." -438,chkDuplicateMethodWithSuffix,"Duplicate method. The method '%s' has the same name and signature as another method in this type once tuples, functions, units of measure and/or provided types are erased." -439,chkDuplicateMethodCurried,"The method '%s' has curried arguments but has the same name as another method in this type. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments." +438,chkDuplicateMethod,"Duplicate method. The method '%s' has the same name and signature as another method in type '%s'." +438,chkDuplicateMethodWithSuffix,"Duplicate method. The method '%s' has the same name and signature as another method in type '%s' once tuples, functions, units of measure and/or provided types are erased." +439,chkDuplicateMethodCurried,"The method '%s' has curried arguments but has the same name as another method in type '%s'. Methods with curried arguments cannot be overloaded. Consider using a method taking tupled arguments." 440,chkCurriedMethodsCantHaveOutParams,"Methods with curried arguments cannot declare 'out', 'ParamArray', 'optional', 'ReflectedDefinition', 'byref', 'CallerLineNumber', 'CallerMemberName', or 'CallerFilePath' arguments" -441,chkDuplicateProperty,"Duplicate property. The property '%s' has the same name and signature as another property in this type." -441,chkDuplicatePropertyWithSuffix,"Duplicate property. The property '%s' has the same name and signature as another property in this type once tuples, functions, units of measure and/or provided types are erased." +441,chkDuplicateProperty,"Duplicate property. The property '%s' has the same name and signature as another property in type '%s'." +441,chkDuplicatePropertyWithSuffix,"Duplicate property. The property '%s' has the same name and signature as another property in type '%s' once tuples, functions, units of measure and/or provided types are erased." 442,chkDuplicateMethodInheritedType,"Duplicate method. The abstract method '%s' has the same name and signature as an abstract method in an inherited type." 442,chkDuplicateMethodInheritedTypeWithSuffix,"Duplicate method. The abstract method '%s' has the same name and signature as an abstract method in an inherited type once tuples, functions, units of measure and/or provided types are erased." 443,chkMultipleGenericInterfaceInstantiations,"This type implements the same interface at different generic instantiations '%s' and '%s'. This is not permitted in this version of F#." @@ -358,13 +362,14 @@ csNoOverloadsFound,"No overloads match for method '%s'." csMethodIsOverloaded,"A unique overload for method '%s' could not be determined based on type information prior to this program point. A type annotation may be needed." csCandidates,"Candidates: %s" csSeeAvailableOverloads,"The available overloads are shown below (or in the Error List window)." -512,parsDoCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on 'do' bindings" +512,parsDoCannotHaveVisibilityDeclarations,"Accessibility modifiers are not permitted on 'do' bindings, but '%s' was given." 513,parsEofInHashIf,"End of file in #if section begun at or after here" 514,parsEofInString,"End of file in string begun at or before here" 515,parsEofInVerbatimString,"End of file in verbatim string begun at or before here" 516,parsEofInComment,"End of file in comment begun at or before here" 517,parsEofInStringInComment,"End of file in string embedded in comment begun at or before here" 518,parsEofInVerbatimStringInComment,"End of file in verbatim string embedded in comment begun at or before here" +519,parsEofInIfOcaml,"End of file in IF-OCAML section begun at or before here" 520,parsEofInDirective,"End of file in directive begun at or before here" 521,parsNoHashEndIfFound,"No #endif found for #if or #else" 522,parsAttributesIgnored,"Attributes have been ignored in this construct" @@ -374,14 +379,14 @@ csSeeAvailableOverloads,"The available overloads are shown below (or in the Erro 526,parsOnlyOneWithAugmentationAllowed,"At most one 'with' augmentation is permitted" 527,parsUnexpectedSemicolon,"A semicolon is not expected at this point" 528,parsUnexpectedEndOfFile,"Unexpected end of input" -529,parsUnexpectedVisibilityDeclaration,"Accessibility modifiers are not permitted here" +529,parsUnexpectedVisibilityDeclaration,"Accessibility modifiers are not permitted here, but '%s' was given." 530,parsOnlyHashDirectivesAllowed,"Only '#' compiler directives may occur prior to the first 'namespace' declaration" 531,parsVisibilityDeclarationsShouldComePriorToIdentifier,"Accessibility modifiers should come immediately prior to the identifier naming a construct" 532,parsNamespaceOrModuleNotBoth,"Files should begin with either a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule', but not both. To define a module within a namespace use 'module SomeModule = ...'" 534,parsModuleAbbreviationMustBeSimpleName,"A module abbreviation must be a simple name, not a path" 535,parsIgnoreAttributesOnModuleAbbreviation,"Ignoring attributes on module abbreviation" -536,parsIgnoreAttributesOnModuleAbbreviationAlwaysPrivate,"Ignoring accessibility attribute on module abbreviation. Module abbreviations are always private." -537,parsIgnoreVisibilityOnModuleAbbreviationAlwaysPrivate,"Ignoring visibility attribute on module abbreviation. Module abbreviations are always private." +536,parsIgnoreAttributesOnModuleAbbreviationAlwaysPrivate,"The '%s' accessibility attribute is not allowed on module abbreviation. Module abbreviations are always private." +537,parsIgnoreVisibilityOnModuleAbbreviationAlwaysPrivate,"The '%s' visibility attribute is not allowed on module abbreviation. Module abbreviations are always private." 538,parsUnClosedBlockInHashLight,"Unclosed block" 539,parsUnmatchedBeginOrStruct,"Unmatched 'begin' or 'struct'" 541,parsModuleDefnMustBeSimpleName,"A module name must be a simple name, not a path" @@ -784,7 +789,7 @@ tcTypeAbbreviationHasTypeParametersMissingOnType,"This type abbreviation has one 954,tcTypeDefinitionIsCyclicThroughInheritance,"This type definition involves an immediate cyclic reference through a struct field or inheritance relation" tcReservedSyntaxForAugmentation,"The syntax 'type X with ...' is reserved for augmentations. Types whose representations are hidden but which have members are now declared in signatures using 'type X = ...'. You may also need to add the '[] attribute to the type definition in the signature" 956,tcMembersThatExtendInterfaceMustBePlacedInSeparateModule,"Members that extend interface, delegate or enum types must be placed in a module separate to the definition of the type. This module must either have the AutoOpen attribute or be opened explicitly by client code to bring the extension members into scope." -957,tcDeclaredTypeParametersForExtensionDoNotMatchOriginal,"The declared type parameters for this type extension do not match the declared type parameters on the original type '%s'" +957,tcDeclaredTypeParametersForExtensionDoNotMatchOriginal,"One or more of the declared type parameters for this type extension have a missing or wrong type constraint not matching the original type constraints on '%s'" 959,tcTypeDefinitionsWithImplicitConstructionMustHaveOneInherit,"Type definitions may only have one 'inherit' specification and it must be the first declaration" 960,tcTypeDefinitionsWithImplicitConstructionMustHaveLocalBindingsBeforeMembers,"'let' and 'do' bindings must come before member and interface definitions in type definitions" 961,tcInheritDeclarationMissingArguments,"This 'inherit' declaration specifies the inherited type but no arguments. Consider supplying arguments, e.g. 'inherit BaseType(args)'." @@ -819,7 +824,8 @@ ilDynamicInvocationNotSupported,"Dynamic invocation of %s is not supported" 993,ilDefaultAugmentationAttributeCouldNotBeDecoded,"The DefaultAugmentation attribute could not be decoded" 994,ilReflectedDefinitionsCannotUseSliceOperator,"Reflected definitions cannot contain uses of the prefix splice operator '%%'" 1000,optsProblemWithCodepage,"Problem with codepage '%d': %s" -optsCopyright,"Freely distributed under the Apache 2.0 Open Source License" +optsCopyright,"Copyright (c) Microsoft Corporation. All Rights Reserved." +optsCopyrightCommunity,"Freely distributed under the Apache 2.0 Open Source License" optsNameOfOutputFile,"Name of the output file (Short form: -o)" optsBuildConsole,"Build a console executable" optsBuildWindows,"Build a Windows executable" @@ -850,6 +856,7 @@ optsDebugPM,"Emit debug information (Short form: -g)" optsDebug,"Specify debugging type: full, portable, embedded, pdbonly. ('%s' is the default if no debuggging type specified and enables attaching a debugger to a running program, 'portable' is a cross-platform format, 'embedded' is a cross-platform format embedded into the output file)." optsOptimize,"Enable optimizations (Short form: -O)" optsTailcalls,"Enable or disable tailcalls" +optsDeterministic,"Produce a deterministic assembly (including module version GUID and timestamp)" optsCrossoptimize,"Enable or disable cross-module optimizations" optsWarnaserrorPM,"Report all warnings as errors" optsWarnaserror,"Report specific warnings as errors" @@ -896,12 +903,12 @@ optsDCLOHtmlDoc,"The command-line option '%s' has been deprecated. HTML document optsConsoleColors,"Output warning and error messages in color" optsUseHighEntropyVA,"Enable high-entropy ASLR" optsSubSystemVersion,"Specify subsystem version of this assembly" -optsTargetProfile,"Specify target framework profile of this assembly. Valid values are mscorlib or netcore. Default - mscorlib" +optsTargetProfile,"Specify target framework profile of this assembly. Valid values are mscorlib, netcore or netstandard. Default - mscorlib" optsEmitDebugInfoInQuotations,"Emit debug information in quotations" -optsPreferredUiLang," Specify the preferred output language culture name (e.g. es-ES, ja-JP)" +optsPreferredUiLang,"Specify the preferred output language culture name (e.g. es-ES, ja-JP)" optsNoCopyFsharpCore,"Don't copy FSharp.Core.dll along the produced binaries" 1051,optsInvalidSubSystemVersion,"Invalid version '%s' for '--subsystemversion'. The version must be 4.00 or greater." -1052,optsInvalidTargetProfile,"Invalid value '%s' for '--targetprofile', valid values are 'mscorlib' or 'netcore'." +1052,optsInvalidTargetProfile,"Invalid value '%s' for '--targetprofile', valid values are 'mscorlib', 'netcore' or 'netstandard'." typeInfoFullName,"Full name" # typeInfoType,"type" # typeInfoInherits,"inherits" @@ -1128,6 +1135,8 @@ fscTooManyErrors,"Exiting - too many errors" 2022,pathIsInvalid,"Problem with filename '%s': Illegal characters in path." 2023,fscResxSourceFileDeprecated,"Passing a .resx file (%s) as a source file to the compiler is deprecated. Use resgen.exe to transform the .resx file into a .resources file to pass as a --resource option. If you are using MSBuild, this can be done via an item in the .fsproj project file." 2024,fscStaticLinkingNoProfileMismatches,"Static linking may not be used on an assembly referencing mscorlib (e.g. a .NET Framework assembly) when generating an assembly that references System.Runtime (e.g. a .NET Core or Portable assembly)." +2025,fscAssemblyWildcardAndDeterminism,"An %s specified version '%s', but this value is a wildcard, and you have requested a deterministic build, these are in conflict." +2026,fscDeterministicDebugRequiresPortablePdb,"Determinstic builds only support portable PDBs (--debug:portable or --debug:embedded)" 3000,etIllegalCharactersInNamespaceName,"Character '%s' is not allowed in provided namespace name '%s'" 3001,etNullOrEmptyMemberName,"The provided type '%s' returned a member with a null or empty member name" 3002,etNullMember,"The provided type '%s' returned a null member" @@ -1263,7 +1272,6 @@ typeInfoCallsWord,"Calls" 3151,tcThisValueMayNotBeInlined,"This member, function or value declaration may not be declared 'inline'" 3152,etErasedTypeUsedInGeneration,"The provider '%s' returned a non-generated type '%s' in the context of a set of generated types. Consider adjusting the type provider to only return generated types." 3153,tcUnrecognizedQueryBinaryOperator,"Arguments to query operators may require parentheses, e.g. 'where (x > y)' or 'groupBy (x.Length / 10)'" -3154,invalidPlatformTargetForOldFramework,"The 'anycpu32bitpreferred' platform flag may only be used with .NET Framework versions 4.5 and greater." 3155,crefNoSetOfHole,"A quotation may not involve an assignment to or taking the address of a captured local variable" nicePrintOtherOverloads1,"+ 1 overload" nicePrintOtherOverloadsN,"+ %d overloads" @@ -1406,3 +1414,9 @@ keywordDescriptionTypedQuotation,"Delimits a typed code quotation." keywordDescriptionUntypedQuotation,"Delimits a untyped code quotation." 3216,itemNotFoundDuringDynamicCodeGen,"%s '%s' not found in assembly '%s'. A possible cause may be a version incompatibility. You may need to explicitly reference the correct version of this assembly to allow all referenced components to use the correct version." 3216,itemNotFoundInTypeDuringDynamicCodeGen,"%s '%s' not found in type '%s' from assembly '%s'. A possible cause may be a version incompatibility. You may need to explicitly reference the correct version of this assembly to allow all referenced components to use the correct version." +descriptionWordIs,"is" +notAFunction,"This value is not a function and cannot be applied." +notAFunctionButMaybeIndexerWithName,"This value is not a function and cannot be applied. Did you intend to access the indexer via %s.[index] instead?" +notAFunctionButMaybeIndexer,"This expression is not a function and cannot be applied. Did you intend to access the indexer via expr.[index] instead?" +3217,notAFunctionButMaybeIndexerErrorCode,"" +notAFunctionButMaybeDeclaration,"This value is not a function and cannot be applied. Did you forget to terminate a declaration?" diff --git a/src/fsharp/FSStrings.resx b/src/fsharp/FSStrings.resx index 4175396a78..29df23d229 100755 --- a/src/fsharp/FSStrings.resx +++ b/src/fsharp/FSStrings.resx @@ -138,12 +138,6 @@ The type '{0}' is not compatible with the type '{1}'{2} - - {0} - - - {0} - This expression was expected to have type\n '{1}' \nbut here has type\n '{0}' {2} @@ -186,12 +180,6 @@ The type implements the interface '{0}' but this is not revealed by the signature. You should list the interface in the signature, as the interface will be discoverable via dynamic type casts and/or reflection. - - This value is not a function and cannot be applied. Did you forget to terminate a declaration? - - - This value is not a function and cannot be applied - The type '{0}' expects {1} type argument(s) but is given {2} diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.netcore.fsproj b/src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.netcore.fsproj deleted file mode 100755 index 269df82139..0000000000 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.netcore.fsproj +++ /dev/null @@ -1,36 +0,0 @@ - - - 13.0.0 - netstandard1.6 - Library - $(DefineConstants);DOTNETCORE; - $(NoWarn);44;2003; - true - true - true - FSharp.Compiler.Service.ProjectCracker - FSharp.Compiler.Service.ProjectCracker - - - - ProjectCrackerOptions.fs - - - ProjectCrackerTool.fs - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCracker/paket.references b/src/fsharp/FSharp.Compiler.Service.ProjectCracker/paket.references deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.netcore.fsproj b/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.netcore.fsproj deleted file mode 100755 index 9523b6ce12..0000000000 --- a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.netcore.fsproj +++ /dev/null @@ -1,23 +0,0 @@ - - - netcoreapp1.0 - FSharp.Compiler.Service.ProjectCrackerTool - Exe - $(DefineConstants);DOTNETCORE; - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/paket.references b/src/fsharp/FSharp.Compiler.Service.ProjectCrackerTool/paket.references deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj b/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj deleted file mode 100644 index 8ed464863d..0000000000 --- a/src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj +++ /dev/null @@ -1,771 +0,0 @@ - - - - - Debug - AnyCPU - $(MSBuildProjectDirectory)\..\..\..\ - Library - FSharp.Compiler.Service - $(NoWarn);44;62;9 - {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} - true - v4.5 - 0x06800000 - $(OtherFlags) /warnon:1182 - true - $(OtherFlags) --times - $(NoWarn);69;65;54;61;75 - true - ..\..\..\bin\$(TargetFrameworkVersion) - $(OutputPath)$(AssemblyName).xml - $(DefineConstants);CROSS_PLATFORM_COMPILER - $(DefineConstants);FX_ATLEAST_45 - $(DefineConstants);FX_ATLEAST_40 - $(DefineConstants);BE_SECURITY_TRANSPARENT - $(DefineConstants);TYPE_PROVIDER_SECURITY - $(DefineConstants);EXTENSIBLE_DUMPER - $(DefineConstants);INCLUDE_METADATA_WRITER - $(DefineConstants);COMPILER - $(DefineConstants);ENABLE_MONO_SUPPORT - $(DefineConstants);FX_MSBUILDRESOLVER_RUNTIMELIKE - $(DefineConstants);FX_LCIDFROMCODEPAGE - $(DefineConstants);FX_RESX_RESOURCE_READER - $(DefineConstants);FX_RESIDENT_COMPILER - $(DefineConstants);SHADOW_COPY_REFERENCES - $(DefineConstants);EXTENSIONTYPING - $(DefineConstants);COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0 - $(DefineConstants);COMPILER_SERVICE - $(DefineConstants);NO_STRONG_NAMES - $(DefineConstants);TRACE - 4.4.0.0 - - false - $(OtherFlags) /warnon:1182 - - - $(SolutionDir)packages\FSharp.Compiler.Tools\tools - fsi.exe - fslex.exe - fsyacc.exe - false - - - - DEBUG; $(DefineConstants) - false - $(OtherFlags) --no-jit-optimize --jit-tracking - ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml - AnyCPU - true - - - true - ..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.xml - AnyCPU - true - - - - AssemblyInfo/assemblyinfo.FSharp.Compiler.Service.dll.fs - - - AssemblyInfo/assemblyinfo.shared.fs - - - FSComp.txt - - - FSIstrings.txt - - - FSStrings.resx - - - --module Microsoft.FSharp.Compiler.AbstractIL.Internal.AsciiParser --open Microsoft.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 - pars.fsy - - - Reshaped/reshapedreflection.fs - - - ErrorText/sformat.fsi - - - ErrorText/sformat.fs - - - ErrorText/sr.fsi - - - ErrorText/sr.fs - - - LexYaccRuntime/prim-lexing.fsi - - - LexYaccRuntime/prim-lexing.fs - - - LexYaccRuntime/prim-parsing.fsi - - - LexYaccRuntime/prim-parsing.fs - - - Utilities\ResizeArray.fsi - - - Utilities\ResizeArray.fs - - - Utilities/HashMultiMap.fsi - - - Utilities/HashMultiMap.fs - - - Utilities\EditDistance.fs - - - Utilities/TaggedCollections.fsi - - - Utilities/TaggedCollections.fs - - - Utilities/QueueList.fs - - - Utilities/ildiag.fsi - - - Utilities/ildiag.fs - - - Utilities/illib.fs - - - Utilities/filename.fsi - - - Utilities/filename.fs - - - Utilities/zmap.fsi - - - Utilities/zmap.fs - - - Utilities/zset.fsi - - - Utilities/zset.fs - - - Utilities/bytes.fsi - - - Utilities/bytes.fs - - - Utilities/lib.fs - - - Utilities/InternalCollections.fsi - - - Utilities/InternalCollections.fs - - - Utilities/rational.fsi - - - Utilities/rational.fs - - - ErrorLogging/range.fsi - - - ErrorLogging/range.fs - - - ErrorLogging/ErrorLogger.fs - - - ErrorLogging/ErrorResolutionHints.fs - - - ReferenceResolution/ReferenceResolver.fs - - - --unicode --lexlib Internal.Utilities.Text.Lexing - AbsIL/illex.fsl - - - AbsIL/il.fsi - - - AbsIL/il.fs - - - AbsIL/ilx.fsi - - - AbsIL/ilx.fs - - - AbsIL/ilascii.fsi - - - AbsIL/ilascii.fs - - - AbsIL/ilprint.fsi - - - AbsIL/ilprint.fs - - - AbsIL/ilmorph.fsi - - - AbsIL/ilmorph.fs - - - AbsIL/ilsupp.fsi - - - AbsIL/ilsupp.fs - - - AbsIL/ilpars.fs - - - AbsIL/illex.fs - - - AbsIL/ilbinary.fsi - - - AbsIL/ilbinary.fs - - - AbsIL/ilread.fsi - - - AbsIL/ilread.fs - - - AbsIL/ilwritepdb.fsi - - - AbsIL/ilwritepdb.fs - - - AbsIL/ilwrite.fsi - - - AbsIL/ilwrite.fs - - - AbsIL/ilreflect.fs - - - CompilerLocation/CompilerLocationUtils.fs - - - PrettyNaming/PrettyNaming.fs - - - ILXErase/ilxsettings.fs - - - ILXErase/EraseClosures.fsi - - - ILXErase/EraseClosures.fs - - - ILXErase/EraseUnions.fsi - - - ILXErase/EraseUnions.fs - - - --unicode --lexlib Internal.Utilities.Text.Lexing - ParserAndUntypedAST/lex.fsl - - - --unicode --lexlib Internal.Utilities.Text.Lexing - ParserAndUntypedAST/pplex.fsl - - - --module Microsoft.FSharp.Compiler.PPParser --open Microsoft.FSharp.Compiler --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing - ParserAndUntypedAST/pppars.fsy - - - ParserAndUntypedAST/UnicodeLexing.fsi - - - ParserAndUntypedAST/UnicodeLexing.fs - - - ParserAndUntypedAST/layout.fsi - - - ParserAndUntypedAST/layout.fs - - - ParserAndUntypedAST/ast.fs - - - ParserAndUntypedAST/pppars.fs - - - ParserAndUntypedAST/pars.fs - - - ParserAndUntypedAST/lexhelp.fsi - - - ParserAndUntypedAST/lexhelp.fs - - - ParserAndUntypedAST/pplex.fs - - - ParserAndUntypedAST/lex.fs - - - ParserAndUntypedAST/LexFilter.fs - - - TypedAST/tainted.fsi - - - TypedAST/tainted.fs - - - TypedAST/ExtensionTyping.fsi - - - TypedAST/ExtensionTyping.fs - - - TypedAST/QuotationPickler.fsi - - - TypedAST/QuotationPickler.fs - - - TypedAST/tast.fs - - - TypedAST/TcGlobals.fs - - - TypedAST/TastOps.fsi - - - TypedAST/TastOps.fs - - - TypedAST/TastPickle.fsi - - - TypedAST/TastPickle.fs - - - Logic/import.fsi - - - Logic/import.fs - - - Logic/infos.fs - - - Logic/AccessibilityLogic.fs - - - Logic/AttributeChecking.fs - - - Logic/InfoReader.fs - - - Logic/NicePrint.fs - - - Logic/AugmentWithHashCompare.fsi - - - Logic/AugmentWithHashCompare.fs - - - Logic/NameResolution.fsi - - - Logic/NameResolution.fs - - - Logic/TypeRelations.fs - - - Logic/SignatureConformance.fs - - - Logic/MethodOverrides.fs - - - Logic/MethodCalls.fs - - - Logic/PatternMatchCompilation.fsi - - - Logic/PatternMatchCompilation.fs - - - Logic/ConstraintSolver.fsi - - - Logic/ConstraintSolver.fs - - - Logic/CheckFormatStrings.fsi - - - Logic/CheckFormatStrings.fs - - - Logic/FindUnsolved.fs - - - Logic/QuotationTranslator.fsi - - - Logic/QuotationTranslator.fs - - - Logic/PostInferenceChecks.fsi - - - Logic/PostInferenceChecks.fs - - - Logic/TypeChecker.fsi - - - Logic/TypeChecker.fs - - - Optimize/Optimizer.fsi - - - Optimize/Optimizer.fs - - - Optimize/DetupleArgs.fsi - - - Optimize/DetupleArgs.fs - - - Optimize/InnerLambdasToTopLevelFuncs.fsi - - - Optimize/InnerLambdasToTopLevelFuncs.fs - - - Optimize/LowerCallsAndSeqs.fs - - - Optimize\autobox.fs - - - CodeGen/IlxGen.fsi - - - CodeGen/IlxGen.fs - - - Driver/CompileOps.fsi - - - Driver/CompileOps.fs - - - Driver/CompileOptions.fsi - - - Driver/CompileOptions.fs - - - Driver/fsc.fsi - - - Driver/fsc.fs - - - Service/IncrementalBuild.fsi - - - Service/IncrementalBuild.fs - - - Service/Reactor.fsi - - - Service/Reactor.fs - - - Service/ServiceConstants.fs - - - Service/ServiceDeclarations.fsi - - - Service/ServiceDeclarations.fs - - - Service/Symbols.fsi - - - Service/Symbols.fs - - - Service/Exprs.fsi - - - Service/Exprs.fs - - - Service/ServiceLexing.fsi - - - Service/ServiceLexing.fs - - - Service/ServiceParseTreeWalk.fs - - - Service/ServiceNavigation.fsi - - - Service/ServiceNavigation.fs - - - Service/ServiceParamInfoLocations.fsi - - - Service/ServiceParamInfoLocations.fs - - - Service/ServiceUntypedParse.fsi - - - Service/ServiceUntypedParse.fs - - - Service/reshapedmsbuild.fs - - - Service/SimulatedMSBuildReferenceResolver.fs - - - Service/ServiceAssemblyContent.fsi - - - Service/ServiceAssemblyContent.fs - - - - Service/service.fsi - - - Service/service.fs - - - Service/SimpleServices.fsi - - - Service/SimpleServices.fs - - - Service/fsi.fsi - - - Service/fsi.fs - - - - - - - - - - - - - False - - - - - - - - - - - ..\..\..\packages\Microsoft.DiaSymReader\lib\net20\Microsoft.DiaSymReader.dll - True - True - - - - - - - ..\..\..\packages\Microsoft.DiaSymReader\lib\netstandard1.1\Microsoft.DiaSymReader.dll - True - True - - - - - - - - - ..\..\..\packages\Microsoft.DiaSymReader.PortablePdb\lib\net45\Microsoft.DiaSymReader.PortablePdb.dll - True - True - - - - - - - ..\..\..\packages\Microsoft.DiaSymReader.PortablePdb\lib\netstandard1.1\Microsoft.DiaSymReader.PortablePdb.dll - True - True - - - - - - - - - ..\..\..\packages\System.Buffers\lib\netstandard1.1\System.Buffers.dll - True - True - - - - - - - - - ..\..\..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll - True - True - - - - - - - - - True - - - - - - - - - ..\..\..\packages\System.Linq\lib\netstandard1.6\System.Linq.dll - True - True - - - - - - - - - ..\..\..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll - True - True - - - - - - - - - True - - - - - - - - - ..\..\..\packages\System.Runtime.Handles\ref\netstandard1.3\System.Runtime.Handles.dll - False - True - - - - - - - - - ..\..\..\packages\System.Threading\lib\netstandard1.3\System.Threading.dll - True - True - - - - - \ No newline at end of file diff --git a/src/fsharp/FSharp.Compiler.Service/paket.references b/src/fsharp/FSharp.Compiler.Service/paket.references deleted file mode 100644 index 5cce832ef0..0000000000 --- a/src/fsharp/FSharp.Compiler.Service/paket.references +++ /dev/null @@ -1,4 +0,0 @@ -System.Collections.Immutable -System.Reflection.Metadata -Microsoft.DiaSymReader.PortablePdb -Microsoft.DiaSymReader diff --git a/src/fsharp/FindUnsolved.fs b/src/fsharp/FindUnsolved.fs index 4d2980bed2..05d523f397 100755 --- a/src/fsharp/FindUnsolved.fs +++ b/src/fsharp/FindUnsolved.fs @@ -9,22 +9,12 @@ module internal Microsoft.FSharp.Compiler.FindUnsolved 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.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.Layout -open Microsoft.FSharp.Compiler.AbstractIL.IL open Microsoft.FSharp.Compiler.TypeRelations -open Microsoft.FSharp.Compiler.Infos type env = Nix @@ -175,8 +165,13 @@ and accDiscrim cenv env d = accTypeInst cenv env tys and accAttrib cenv env (Attrib(_,_k,args,props,_,_,_m)) = - args |> List.iter (fun (AttribExpr(e1,_)) -> accExpr cenv env e1) - props |> List.iter (fun (AttribNamedArg(_nm,_ty,_flg,AttribExpr(expr,_))) -> accExpr cenv env expr) + args |> List.iter (fun (AttribExpr(expr1,expr2)) -> + accExpr cenv env expr1 + accExpr cenv env expr2) + props |> List.iter (fun (AttribNamedArg(_nm,ty,_flg,AttribExpr(expr,expr2))) -> + accExpr cenv env expr + accExpr cenv env expr2 + accTy cenv env ty) and accAttribs cenv env attribs = List.iter (accAttrib cenv env) attribs @@ -209,6 +204,7 @@ let accTyconRecdField cenv env _tycon (rfield:RecdField) = let accTycon cenv env (tycon:Tycon) = accAttribs cenv env tycon.Attribs + abstractSlotValsOfTycons [tycon] |> List.iter (accVal cenv env) tycon.AllFieldsArray |> Array.iter (accTyconRecdField cenv env tycon) if tycon.IsUnionTycon then (* This covers finite unions. *) tycon.UnionCasesAsList |> List.iter (fun uc -> diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 8216211e12..64fcbf478a 100755 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -1366,7 +1366,7 @@ type CodeGenBuffer(m:range, // Save the last sequence point away so we can make a decision graph look consistent (i.e. reassert the sequence point at each target) lastSeqPoint <- Some src - // For debug code, emit FeeFee breakpoints for hidden code, see http://blogs.msdn.com/jmstall/archive/2005/06/19/FeeFee_SequencePoints.aspx + // For debug code, emit FeeFee breakpoints for hidden code, see https://blogs.msdn.microsoft.com/jmstall/2005/06/19/line-hidden-and-0xfeefee-sequence-points/ member cgbuf.EmitStartOfHiddenCode() = if mgbuf.cenv.opts.generateDebugSymbols && not mgbuf.cenv.opts.localOptimizationsAreOn then let doc = mgbuf.cenv.g.memoize_file m.FileIndex @@ -2198,12 +2198,12 @@ and GenCoerce cenv cgbuf eenv (e,tgty,m,srcty) sequel = // Do an extra check - should not be needed TypeRelations.TypeFeasiblySubsumesType 0 cenv.g cenv.amap m tgty TypeRelations.NoCoerce srcty then begin - // The .NET IL doesn't always support implict subsumption for interface types, e.g. at stack merge points - // Hence be conservative here and always cast explicitly. if (isInterfaceTy cenv.g tgty) then ( GenExpr cenv cgbuf eenv SPSuppress e Continue let ilToTy = GenType cenv.amap m eenv.tyenv tgty - CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [ I_unbox_any ilToTy ] + // Section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing + // is required, but we still push the coerce'd type on to the code gen buffer. + CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [] GenSequel cenv eenv.cloc cgbuf sequel ) else ( GenExpr cenv cgbuf eenv SPSuppress e sequel @@ -4383,7 +4383,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau | DecisionTreeTest.ArrayLength _ | DecisionTreeTest.IsNull | DecisionTreeTest.Const(Const.Zero) -> - if List.length cases <> 1 || Option.isNone defaultTargetOpt then failwith "internal error: GenDecisionTreeSwitch: DecisionTreeTest.IsInst/isnull/query" + if not (isSingleton cases) || Option.isNone defaultTargetOpt then failwith "internal error: GenDecisionTreeSwitch: DecisionTreeTest.IsInst/isnull/query" let bi = match firstDiscrim with | DecisionTreeTest.Const(Const.Zero) -> @@ -5061,13 +5061,16 @@ and ComputeMethodImplAttribs cenv (_v:Val) attrs = // 0x80 - hasPreserveSigImplFlag // 0x20 - synchronize // (See ECMA 335, Partition II, section 23.1.11 - Flags for methods [MethodImplAttributes]) - let attrs = attrs - |> List.filter (IsMatchingFSharpAttribute cenv.g cenv.g.attrib_MethodImplAttribute >> not) - |> List.filter (IsMatchingFSharpAttributeOpt cenv.g cenv.g.attrib_PreserveSigAttribute >> not) + let attrs = + attrs + |> List.filter (IsMatchingFSharpAttribute cenv.g cenv.g.attrib_MethodImplAttribute >> not) + |> List.filter (IsMatchingFSharpAttributeOpt cenv.g cenv.g.attrib_PreserveSigAttribute >> not) + let hasPreserveSigImplFlag = ((implflags &&& 0x80) <> 0x0) || hasPreserveSigAttr let hasSynchronizedImplFlag = (implflags &&& 0x20) <> 0x0 let hasNoInliningImplFlag = (implflags &&& 0x08) <> 0x0 - hasPreserveSigImplFlag, hasSynchronizedImplFlag, hasNoInliningImplFlag, attrs + let hasAggressiveInliningImplFlag = (implflags &&& 0x0100) <> 0x0 + hasPreserveSigImplFlag, hasSynchronizedImplFlag, hasNoInliningImplFlag, hasAggressiveInliningImplFlag, attrs and GenMethodForBinding cenv cgbuf eenv @@ -5152,7 +5155,7 @@ and GenMethodForBinding | _ -> [],None // check if the hasPreserveSigNamedArg and hasSynchronizedImplFlag implementation flags have been specified - let hasPreserveSigImplFlag, hasSynchronizedImplFlag, hasNoInliningFlag, attrs = ComputeMethodImplAttribs cenv v attrs + let hasPreserveSigImplFlag, hasSynchronizedImplFlag, hasNoInliningFlag, hasAggressiveInliningImplFlag, attrs = ComputeMethodImplAttribs cenv v attrs let securityAttributes,attrs = attrs |> List.partition (fun a -> IsSecurityAttribute cenv.g cenv.amap cenv.casApplied a m) @@ -5183,6 +5186,7 @@ and GenMethodForBinding IsSynchronized = hasSynchronizedImplFlag IsEntryPoint = isExplicitEntryPoint IsNoInline = hasNoInliningFlag + IsAggressiveInline = hasAggressiveInliningImplFlag HasSecurity = mdef.HasSecurity || (securityAttributes.Length > 0) SecurityDecls = secDecls } @@ -6012,7 +6016,7 @@ and GenAbstractBinding cenv eenv tref (vref:ValRef) = let m = vref.Range let memberInfo = Option.get vref.MemberInfo let attribs = vref.Attribs - let hasPreserveSigImplFlag,hasSynchronizedImplFlag,hasNoInliningFlag,attribs = ComputeMethodImplAttribs cenv vref.Deref attribs + let hasPreserveSigImplFlag,hasSynchronizedImplFlag,hasNoInliningFlag,hasAggressiveInliningImplFlag,attribs = ComputeMethodImplAttribs cenv vref.Deref attribs if memberInfo.MemberFlags.IsDispatchSlot && not memberInfo.IsImplemented then let ilAttrs = [ yield! GenAttrs cenv eenv attribs @@ -6033,6 +6037,7 @@ and GenAbstractBinding cenv eenv tref (vref:ValRef) = IsPreserveSig=hasPreserveSigImplFlag IsSynchronized=hasSynchronizedImplFlag IsNoInline=hasNoInliningFlag + IsAggressiveInline=hasAggressiveInliningImplFlag mdKind=match mdef.mdKind with | MethodKind.Virtual vinfo -> MethodKind.Virtual {vinfo with IsFinal=memberInfo.MemberFlags.IsFinal @@ -6808,7 +6813,7 @@ and GenExnDef cenv mgbuf eenv m (exnc:Tycon) = let CodegenAssembly cenv eenv mgbuf fileImpls = - if List.length fileImpls > 0 then + if not (isNil fileImpls) then let a,b = List.frontAndBack fileImpls let eenv = List.fold (GenTopImpl cenv mgbuf None) eenv a let _eenv = GenTopImpl cenv mgbuf cenv.opts.mainMethodInfo eenv b diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index 2aa81ce349..ffcbd54f10 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -4,10 +4,6 @@ /// Select members from a type by name, searching the type hierarchy if needed module internal Microsoft.FSharp.Compiler.InfoReader -open Internal.Utilities - -open Microsoft.FSharp.Compiler.AbstractIL -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 @@ -159,6 +155,17 @@ let GetImmediateIntrinsicPropInfosOfType (optFilter,ad) g amap m typ = let pinfos = pinfos |> List.filter (IsPropInfoAccessible g amap m ad) pinfos +// Checks whether the given type has an indexer property. +let IsIndexerType g amap typ = + isArray1DTy g typ || + isListTy g typ || + match tryDestAppTy g typ with + | Some tcref -> + let _, entityTy = generalizeTyconRef tcref + let props = GetImmediateIntrinsicPropInfosOfType (None, AccessibleFromSomeFSharpCode) g amap range0 entityTy + props |> List.exists (fun x -> x.PropertyName = "Item") + | _ -> false + /// Sets of methods up the hierarchy, ignoring duplicates by name and sig. /// Used to collect sets of virtual methods, protected methods, protected @@ -414,6 +421,7 @@ type InfoReader(g:TcGlobals, amap:Import.ImportMap) = /// Get the declared constructors of any F# type let GetIntrinsicConstructorInfosOfType (infoReader:InfoReader) m ty = + protectAssemblyExploration [] (fun () -> let g = infoReader.g let amap = infoReader.amap if isAppTy g ty then @@ -440,7 +448,8 @@ let GetIntrinsicConstructorInfosOfType (infoReader:InfoReader) m ty = | _ -> None) |> List.map (fun x -> FSMeth(g,ty,x,None)) else [] - + ) + //------------------------------------------------------------------------- // Collecting methods and properties taking into account hiding rules in the hierarchy diff --git a/src/fsharp/InnerLambdasToTopLevelFuncs.fs b/src/fsharp/InnerLambdasToTopLevelFuncs.fs index 308330f81f..ad61f805d9 100755 --- a/src/fsharp/InnerLambdasToTopLevelFuncs.fs +++ b/src/fsharp/InnerLambdasToTopLevelFuncs.fs @@ -42,7 +42,12 @@ let liftTLR = ref false let internalError str = dprintf "Error: %s\n" str;raise (Failure str) module Zmap = - let force k mp (str,soK) = try Zmap.find k mp with e -> dprintf "Zmap.force: %s %s\n" str (soK k); raise e + let force k mp (str,soK) = + try Zmap.find k mp + with e -> + dprintf "Zmap.force: %s %s\n" str (soK k); + PreserveStackTrace(e) + raise e //------------------------------------------------------------------------- // misc @@ -972,7 +977,7 @@ module Pass4_RewriteAssembly = let ConvertBind g (TBind(v,repr,_) as bind) = match v.ValReprInfo with - | None -> v.SetValReprInfo (Some (InferArityOfExprBinding g v repr )) + | None -> v.SetValReprInfo (Some (InferArityOfExprBinding g AllowTypeDirectedDetupling.Yes v repr )) | Some _ -> () bind diff --git a/src/fsharp/InternalCollections.fs b/src/fsharp/InternalCollections.fs index da204620e2..64b746af01 100755 --- a/src/fsharp/InternalCollections.fs +++ b/src/fsharp/InternalCollections.fs @@ -13,7 +13,7 @@ type internal ValueStrength<'T when 'T : not struct> = | Weak of WeakReference<'T> #endif -type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStrongly:int, areSame, ?requiredToKeep, ?onStrongDiscard, ?keepMax: int) = +type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStrongly:int, areSimilar, ?requiredToKeep, ?onStrongDiscard, ?keepMax: int) = /// The list of items stored. Youngest is at the end of the list. /// The choice of order is somewhat arbitrary. If the other way then adding /// items would be O(1) and removing O(N). @@ -39,8 +39,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro // This function returns true if two keys are the same according to the predicate // function passed in. | []->None - | (key',value)::t-> - if areSame(key,key') then Some(key',value) + | (similarKey,value)::t-> + if areSimilar(key,similarKey) then Some(similarKey,value) else Lookup key t Lookup key data @@ -53,18 +53,18 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro /// Promote a particular key value. let Promote (data, key, value) = - (data |> List.filter (fun (key',_)-> not (areSame(key,key')))) @ [ (key, value) ] + (data |> List.filter (fun (similarKey,_)-> not (areSimilar(key,similarKey)))) @ [ (key, value) ] /// Remove a particular key value. let RemoveImpl (data, key) = - let discard,keep = data |> List.partition (fun (key',_)-> areSame(key,key')) + let discard,keep = data |> List.partition (fun (similarKey,_)-> areSimilar(key,similarKey)) keep, discard let TryGetKeyValueImpl(data,key) = match TryPeekKeyValueImpl(data,key) with - | Some(key', value) as result -> + | Some(similarKey, value) as result -> // If the result existed, move it to the end of the list (more likely to keep it) - result,Promote (data,key',value) + result,Promote (data,similarKey,value) | None -> None,data /// Remove weak entries from the list that have been collected. @@ -154,37 +154,42 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro -type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongly, areSame, ?isStillValid : 'Key*'Value->bool, ?areSameForSubsumption, ?requiredToKeep, ?onStrongDiscard, ?keepMax) = +type internal MruCache<'Token, 'Key,'Value when 'Value : not struct>(keepStrongly, areSame, ?isStillValid : 'Key*'Value->bool, ?areSimilar, ?requiredToKeep, ?onStrongDiscard, ?keepMax) = - /// Default behavior of areSameForSubsumption function is areSame. - let areSameForSubsumption = defaultArg areSameForSubsumption areSame + /// Default behavior of areSimilar function is areSame. + let areSimilar = defaultArg areSimilar areSame /// The list of items in the cache. Youngest is at the end of the list. /// The choice of order is somewhat arbitrary. If the other way then adding /// items would be O(1) and removing O(N). - let cache = AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSame=areSameForSubsumption,?onStrongDiscard=onStrongDiscard,?keepMax=keepMax,?requiredToKeep=requiredToKeep) + let cache = AgedLookup<'Token, 'Key,'Value>(keepStrongly=keepStrongly,areSimilar=areSimilar,?onStrongDiscard=onStrongDiscard,?keepMax=keepMax,?requiredToKeep=requiredToKeep) /// Whether or not this result value is still valid. let isStillValid = defaultArg isStillValid (fun _ -> true) + member bc.ContainsSimilarKey(tok, key) = + match cache.TryPeekKeyValue(tok, key) with + | Some(_similarKey, _value)-> true + | None -> false + member bc.TryGetAny(tok, key) = match cache.TryPeekKeyValue(tok, key) with - | Some(key', value)-> - if areSame(key',key) then Some(value) + | Some(similarKey, value)-> + if areSame(similarKey,key) then Some(value) else None | None -> None member bc.TryGet(tok, key) = match cache.TryGetKeyValue(tok, key) with - | Some(key', value) -> - if areSame(key', key) && isStillValid(key,value) then Some value + | Some(similarKey, value) -> + if areSame(similarKey, key) && isStillValid(key,value) then Some value else None | None -> None member bc.Set(tok, key:'Key,value:'Value) = cache.Put(tok, key,value) - member bc.Remove(tok, key) = + member bc.RemoveAnySimilar(tok, key) = cache.Remove(tok, key) member bc.Clear(tok) = diff --git a/src/fsharp/InternalCollections.fsi b/src/fsharp/InternalCollections.fsi index 88abdc302c..1bd77dd9e8 100755 --- a/src/fsharp/InternalCollections.fsi +++ b/src/fsharp/InternalCollections.fsi @@ -4,10 +4,12 @@ namespace Internal.Utilities.Collections /// Simple aging lookup table. When a member is accessed it's /// moved to the top of the list and when there are too many elements - /// the least-recently-accessed element falls of the end. + /// the least-recently-accessed element falls of the end. + /// + /// - areSimilar: Keep at most once association for two similar keys (as given by areSimilar) type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct> = new : keepStrongly:int - * areSame:('Key * 'Key -> bool) + * areSimilar:('Key * 'Key -> bool) * ?requiredToKeep:('Value -> bool) * ?onStrongDiscard : ('Value -> unit) // this may only be set if keepTotal=keepStrongly, i.e. not weak entries * ?keepMax: int @@ -40,25 +42,36 @@ namespace Internal.Utilities.Collections /// threads seeing different live sets of cached items, and may result in the onDiscard action /// being called multiple times. In practice this means the collection is only safe for concurrent /// access if there is no discard action to execute. + /// + /// - areSimilar: Keep at most once association for two similar keys (as given by areSimilar) type internal MruCache<'Token, 'Key,'Value when 'Value : not struct> = new : keepStrongly:int * areSame:('Key * 'Key -> bool) * ?isStillValid:('Key * 'Value -> bool) - * ?areSameForSubsumption:('Key * 'Key -> bool) + * ?areSimilar:('Key * 'Key -> bool) * ?requiredToKeep:('Value -> bool) * ?onDiscard:('Value -> unit) * ?keepMax:int -> MruCache<'Token,'Key,'Value> + /// Clear out the cache. member Clear : 'Token -> unit - /// Get the value for the given key or None if not already available. + + /// Get the similar (subsumable) value for the given key or None if not already available. + member ContainsSimilarKey : 'Token * key:'Key -> bool + + /// Get the value for the given key or None if not still valid. member TryGetAny : 'Token * key:'Key -> 'Value option - /// Get the value for the given key or None if not already available + + /// Get the value for the given key or None, but only if entry is still valid member TryGet : 'Token * key:'Key -> 'Value option + /// Remove the given value from the mru cache. - member Remove : 'Token * key:'Key -> unit + member RemoveAnySimilar : 'Token * key:'Key -> unit + /// Set the given key. member Set : 'Token * key:'Key * value:'Value -> unit + /// Resize member Resize : 'Token * keepStrongly: int * ?keepMax : int -> unit diff --git a/src/fsharp/LegacyHostedCompilerForTesting.fs b/src/fsharp/LegacyHostedCompilerForTesting.fs index 9832ac7281..044f5f6717 100644 --- a/src/fsharp/LegacyHostedCompilerForTesting.fs +++ b/src/fsharp/LegacyHostedCompilerForTesting.fs @@ -3,7 +3,7 @@ // This component is used by the 'fsharpqa' tests for faster in-memory compilation. It should be removed and the // proper compiler service API used instead. -namespace FSharp.Compiler.Hosted +namespace Legacy.FSharp.Compiler.Hosted open System open System.IO @@ -53,7 +53,7 @@ type internal CompilationOutput = { Errors : Diagnostic[] Warnings : Diagnostic[] } -type internal InProcCompiler(referenceResolver) = +type internal InProcCompiler(legacyReferenceResolver) = member this.Compile(argv) = // Explanation: Compilation happens on whichever thread calls this function. @@ -65,7 +65,7 @@ type internal InProcCompiler(referenceResolver) = { new Exiter with member this.Exit n = exitCode := n; raise StopProcessing } try - typecheckAndCompile(ctok, argv, referenceResolver, false, exiter, loggerProvider.Provider) + typecheckAndCompile(ctok, argv, legacyReferenceResolver, false, false, true, exiter, loggerProvider.Provider, None, None) with | StopProcessing -> () | ReportedError _ | WrappedError(ReportedError _,_) -> @@ -76,9 +76,8 @@ type internal InProcCompiler(referenceResolver) = !exitCode = 0, output /// in-proc version of fsc.exe -type internal FscCompiler() = - let referenceResolver = MSBuildReferenceResolver.Resolver - let compiler = InProcCompiler(referenceResolver) +type internal FscCompiler(legacyReferenceResolver) = + let compiler = InProcCompiler(legacyReferenceResolver) let emptyLocation = { @@ -174,7 +173,6 @@ type internal FscCompiler() = (exitCode, lines) module internal CompilerHelpers = - let fscCompiler = FscCompiler() /// splits a provided command line string into argv array /// currently handles quotes, but not escaped quotes @@ -196,7 +194,7 @@ module internal CompilerHelpers = |> Array.ofList /// runs in-proc fsc compilation, returns array consisting of exit code, then compiler output - let fscCompile directory args = + let fscCompile legacyReferenceResolver directory args = // in-proc compiler still prints banner to console, so need this to capture it let origOut = Console.Out let origError = Console.Error @@ -207,7 +205,7 @@ module internal CompilerHelpers = try try Directory.SetCurrentDirectory directory - let (exitCode, output) = fscCompiler.Compile(args) + let (exitCode, output) = FscCompiler(legacyReferenceResolver).Compile(args) let consoleOut = sw.ToString().Split([|'\r'; '\n'|], StringSplitOptions.RemoveEmptyEntries) let consoleError = ew.ToString().Split([|'\r'; '\n'|], StringSplitOptions.RemoveEmptyEntries) exitCode, [| yield! consoleOut; yield! output |], consoleError diff --git a/src/fsharp/MSBuildReferenceResolver.fs b/src/fsharp/MSBuildReferenceResolver.fs index 4b8d8fe932..0c73f8d439 100644 --- a/src/fsharp/MSBuildReferenceResolver.fs +++ b/src/fsharp/MSBuildReferenceResolver.fs @@ -287,11 +287,12 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver let registry = sprintf "{Registry:%s,%s,%s%s}" frameworkRegistryBase targetFrameworkVersion assemblyFoldersSuffix assemblyFoldersConditions - [| // When compiling scripts, for some reason we have always historically put TargetFrameworkDirectory first - // It is unclear why. + [| // When compiling scripts using fsc.exe, for some reason we have always historically put TargetFrameworkDirectory first + // It is unclear why. This is the only place we look at the 'isdifference between ResolutionEnvironment.EditingOrCompilation and ResolutionEnvironment.EditingTime. match resolutionEnvironment with - | CompileTimeLike -> yield "{TargetFrameworkDirectory}" - | DesignTimeLike | RuntimeLike -> () + | ResolutionEnvironment.EditingOrCompilation false -> yield "{TargetFrameworkDirectory}" + | ResolutionEnvironment.EditingOrCompilation true + | ResolutionEnvironment.CompilationAndEvaluation -> () // Quick-resolve straight to filename first if allowRawFileName then @@ -301,8 +302,9 @@ module internal Microsoft.FSharp.Compiler.MSBuildReferenceResolver yield implicitIncludeDir // Usually the project directory match resolutionEnvironment with - | DesignTimeLike | RuntimeLike -> yield "{TargetFrameworkDirectory}" - | CompileTimeLike -> () + | ResolutionEnvironment.EditingOrCompilation true + | ResolutionEnvironment.CompilationAndEvaluation -> yield "{TargetFrameworkDirectory}" + | ResolutionEnvironment.EditingOrCompilation false -> () yield registry yield "{AssemblyFolders}" diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index e07b66e1b1..94f9e398b8 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -144,7 +144,7 @@ let AdjustCalledArgType (infoReader:InfoReader) isConstraint (calledArg: CalledA // If the called method argument is a delegate type, then the caller may provide a function let calledArgTy = let adjustDelegateTy calledTy = - let (SigOfFunctionForDelegate(_,delArgTys,_,fty)) = GetSigOfFunctionForDelegate infoReader calledTy m AccessibleFromSomeFSharpCode + let (SigOfFunctionForDelegate(_,delArgTys,_,fty)) = GetSigOfFunctionForDelegate infoReader calledTy m AccessibleFromSomewhere let delArgTys = if isNil delArgTys then [g.unit_ty] else delArgTys if (fst (stripFunTy g callerArgTy)).Length = delArgTys.Length then fty @@ -286,25 +286,25 @@ type CalledMeth<'T> else None) | _ -> None) - let unassignedNamedItem = + let unassignedNamedItems = namedCallerArgs |> List.filter (fun (CallerNamedArg(nm,_e)) -> fullCalledArgs |> List.forall (fun calledArg -> match calledArg.NameOpt with | Some nm2 -> nm.idText <> nm2.idText | None -> true)) - let attributeAssignedNamedItems,unassignedNamedItem = + let attributeAssignedNamedItems = if isCheckingAttributeCall then - // the assignment of names to properties is substantially for attribute specifications - // permits bindings of names to non-mutable fields and properties, so we do that using the old - // reliable code for this later on. - unassignedNamedItem,[] + // The process for assigning names-->properties is substantially different for attribute specifications + // because it permits the bindings of names to immutable fields. So we use the old + // code for this. + unassignedNamedItems else - [],unassignedNamedItem + [] - let assignedNamedProps,unassignedNamedItem = + let assignedNamedProps,unassignedNamedItems = let returnedObjTy = if minfo.IsConstructor then minfo.EnclosingType else methodRetTy - unassignedNamedItem |> List.splitChoose (fun (CallerNamedArg(id,e) as arg) -> + unassignedNamedItems |> List.splitChoose (fun (CallerNamedArg(id,e) as arg) -> let nm = id.idText let pinfos = GetIntrinsicPropInfoSetsOfType infoReader (Some(nm),ad,AllowMultiIntfInstantiations.Yes) IgnoreOverrides id.idRange returnedObjTy let pinfos = pinfos |> ExcludeHiddenOfPropInfos g infoReader.amap m @@ -347,7 +347,7 @@ type CalledMeth<'T> let argSet = { UnnamedCalledArgs=unnamedCalledArgs; UnnamedCallerArgs=unnamedCallerArgs; ParamArrayCalledArgOpt=paramArrayCalledArgOpt; ParamArrayCallerArgs=paramArrayCallerArgs; AssignedNamedArgs=assignedNamedArgs } - (argSet,assignedNamedProps,unassignedNamedItem,attributeAssignedNamedItems,unnamedCalledOptArgs,unnamedCalledOutArgs)) + (argSet,assignedNamedProps,unassignedNamedItems,attributeAssignedNamedItems,unnamedCalledOptArgs,unnamedCalledOutArgs)) let argSets = argSetInfos |> List.map (fun (x,_,_,_,_,_) -> x) let assignedNamedProps = argSetInfos |> List.collect (fun (_,x,_,_,_,_) -> x) @@ -360,29 +360,45 @@ type CalledMeth<'T> member x.amap = infoReader.amap /// the method we're attempting to call - member x.Method=minfo + member x.Method = minfo + + /// the instantiation of the method we're attempting to call + member x.CalledTyArgs = calledTyArgs + /// the instantiation of the method we're attempting to call - member x.CalledTyArgs=calledTyArgs + member x.CalledTyparInst = + let tps = minfo.FormalMethodTypars + if tps.Length = calledTyArgs.Length then mkTyparInst tps calledTyArgs else [] + /// the formal instantiation of the method we're attempting to call - member x.CallerTyArgs=callerTyArgs + member x.CallerTyArgs = callerTyArgs + /// The types of the actual object arguments, if any - member x.CallerObjArgTys=callerObjArgTys + member x.CallerObjArgTys = callerObjArgTys + /// The argument analysis for each set of curried arguments - member x.ArgSets=argSets + member x.ArgSets = argSets + /// return type - member x.ReturnType=methodRetTy + member x.ReturnType = methodRetTy + /// named setters - member x.AssignedItemSetters=assignedNamedProps + member x.AssignedItemSetters = assignedNamedProps + /// the property related to the method we're attempting to call, if any - member x.AssociatedPropertyInfo=pinfoOpt + member x.AssociatedPropertyInfo = pinfoOpt + /// unassigned args - member x.UnassignedNamedArgs=unassignedNamedItems + member x.UnassignedNamedArgs = unassignedNamedItems + /// args assigned to specify values for attribute fields and properties (these are not necessarily "property sets") - member x.AttributeAssignedNamedArgs=attributeAssignedNamedItems + member x.AttributeAssignedNamedArgs = attributeAssignedNamedItems + /// unnamed called optional args: pass defaults for these - member x.UnnamedCalledOptArgs=unnamedCalledOptArgs + member x.UnnamedCalledOptArgs = unnamedCalledOptArgs + /// unnamed called out args: return these as part of the return tuple - member x.UnnamedCalledOutArgs=unnamedCalledOutArgs + member x.UnnamedCalledOutArgs = unnamedCalledOutArgs static member GetMethod (x:CalledMeth<'T>) = x.Method @@ -476,7 +492,7 @@ let ExamineArgumentForLambdaPropagation (infoReader:InfoReader) (arg: AssignedCa NoInfo // not a function type on the called side - no information else CalledArgMatchesType(adjustedCalledArgTy) // not a lambda on the caller side - push information from caller to called -let ExamineMethodForLambdaPropagation(x:CalledMeth) = +let ExamineMethodForLambdaPropagation (x:CalledMeth) = let unnamedInfo = x.AssignedUnnamedArgs |> List.mapSquared (ExamineArgumentForLambdaPropagation x.infoReader) let namedInfo = x.AssignedNamedArgs |> List.mapSquared (fun arg -> (arg.NamedArgIdOpt.Value, ExamineArgumentForLambdaPropagation x.infoReader arg)) if unnamedInfo |> List.existsSquared (function CallerLambdaHasArgTypes _ -> true | _ -> false) || diff --git a/src/fsharp/MethodOverrides.fs b/src/fsharp/MethodOverrides.fs index b5bf632738..6ad2c83fc1 100644 --- a/src/fsharp/MethodOverrides.fs +++ b/src/fsharp/MethodOverrides.fs @@ -3,27 +3,19 @@ /// Primary logic related to method overrides. module internal Microsoft.FSharp.Compiler.MethodOverrides -open Internal.Utilities -open System.Text - 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.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.PrettyNaming open Microsoft.FSharp.Compiler.Range 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 @@ -69,7 +61,7 @@ module DispatchSlotChecking = match argTys with | [] -> [[(denv.g.unit_ty,ValReprInfo.unnamedTopArg1)]] | _ -> argTys |> List.mapSquared (fun ty -> (ty, ValReprInfo.unnamedTopArg1)) - Layout.bufferL os (NicePrint.layoutMemberSig denv (memberToParentInst,id.idText,mtps, argInfos, retTy)) + Layout.bufferL os (NicePrint.prettyLayoutOfMemberSig denv (memberToParentInst,id.idText,mtps, argInfos, retTy)) /// Print the signature of a MethInfo to a buffer as part of an error message let PrintMethInfoSigToBuffer g amap m denv os minfo = @@ -78,7 +70,7 @@ module DispatchSlotChecking = let retTy = (retTy |> GetFSharpViewOfReturnType g) let argInfos = argTys |> List.mapSquared (fun ty -> (ty, ValReprInfo.unnamedTopArg1)) let nm = minfo.LogicalName - Layout.bufferL os (NicePrint.layoutMemberSig denv (ttpinst,nm,fmtps, argInfos, retTy)) + Layout.bufferL os (NicePrint.prettyLayoutOfMemberSig denv (ttpinst,nm,fmtps, argInfos, retTy)) /// Format the signature of an override as a string as part of an error message let FormatOverride denv d = bufs (fun buf -> PrintOverrideToBuffer denv buf d) @@ -279,7 +271,7 @@ module DispatchSlotChecking = | [ovd] -> if not ovd.IsCompilerGenerated then let item = Item.MethodGroup(ovd.LogicalName,[dispatchSlot],None) - CallNameResolutionSink sink (ovd.Range,nenv,item,item,ItemOccurence.Implemented,denv,AccessorDomain.AccessibleFromSomewhere) + CallNameResolutionSink sink (ovd.Range,nenv,item,item,dispatchSlot.FormalMethodTyparInst,ItemOccurence.Implemented,denv,AccessorDomain.AccessibleFromSomewhere) sink |> ignore () | [] -> @@ -305,12 +297,13 @@ module DispatchSlotChecking = | [] -> noimpl() | [ Override(_,_,_,(mtps,_),argTys,_,_,_) as overrideBy ] -> - let possibleDispatchSlots = + let moreThanOnePossibleDispatchSlot = dispatchSlots |> List.filter (fun (RequiredSlot(dispatchSlot,_)) -> IsNameMatch dispatchSlot overrideBy && IsImplMatch g dispatchSlot overrideBy) - |> List.length + |> isNilOrSingleton + |> not - if possibleDispatchSlots > 1 then + if moreThanOnePossibleDispatchSlot then // Error will be reported below in CheckOverridesAreAllUsedOnce () diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 83d0bcf70f..10aea78fb1 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -1,10 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -//------------------------------------------------------------------------- -// Name environment and name resolution -//------------------------------------------------------------------------- - +/// Name environment and name resolution module internal Microsoft.FSharp.Compiler.NameResolution open Internal.Utilities @@ -22,12 +19,11 @@ 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 // Abstract IL +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.Layout open Microsoft.FSharp.Compiler.PrettyNaming open System.Collections.Generic @@ -139,19 +135,25 @@ type ArgumentContainer = // let (|A|B|) x = if x < 0 then A else B // A and B are reported as results using 'Item.ActivePatternResult' // match () with | A | B -> () // A and B are reported using 'Item.ActivePatternCase' -[] +[] /// Represents an item that results from name resolution type Item = - /// Represents the resolution of a name to an F# value or function. + + /// Represents the resolution of a name to an F# value or function. | Value of ValRef + /// Represents the resolution of a name to an F# union case. | UnionCase of UnionCaseInfo * bool + /// Represents the resolution of a name to an F# active pattern result. | ActivePatternResult of ActivePatternInfo * TType * int * range + /// Represents the resolution of a name to an F# active pattern case within the body of an active pattern. | ActivePatternCase of ActivePatternElemRef + /// Represents the resolution of a name to an F# exception definition. | ExnCase of TyconRef + /// Represents the resolution of a name to an F# record field. | RecdField of RecdFieldInfo @@ -160,38 +162,54 @@ type Item = /// Represents the resolution of a name at the point of its own definition. | NewDef of Ident + /// Represents the resolution of a name to a .NET field | ILField of ILFieldInfo + /// Represents the resolution of a name to an event | Event of EventInfo + /// Represents the resolution of a name to a property | Property of string * PropInfo list + /// Represents the resolution of a name to a group of methods. | MethodGroup of displayName: string * methods: MethInfo list * uninstantiatedMethodOpt: MethInfo option + /// Represents the resolution of a name to a constructor | CtorGroup of string * MethInfo list + /// Represents the resolution of a name to the fake constructor simulated for an interface type. | FakeInterfaceCtor of TType + /// Represents the resolution of a name to a delegate | DelegateCtor of TType + /// Represents the resolution of a name to a group of types | Types of string * TType list + /// CustomOperation(nm, helpText, methInfo) /// /// Used to indicate the availability or resolution of a custom query operation such as 'sortBy' or 'where' in computation expression syntax | CustomOperation of string * (unit -> string option) * MethInfo option + /// Represents the resolution of a name to a custom builder in the F# computation expression syntax | CustomBuilder of string * ValRef + /// Represents the resolution of a name to a type variable | TypeVar of string * Typar + /// Represents the resolution of a name to a module or namespace | ModuleOrNamespaces of Tast.ModuleOrNamespaceRef list + /// Represents the resolution of a name to an operator | ImplicitOp of Ident * TraitConstraintSln option ref + /// Represents the resolution of a name to a named argument | ArgName of Ident * TType * ArgumentContainer option + /// Represents the resolution of a name to a named property setter | SetterArg of Ident * Item + /// Represents the potential resolution of an unqualified name to a type. | UnqualifiedType of TyconRef list @@ -236,6 +254,17 @@ let valRefHash (vref: ValRef) = | VNone -> 0 | VSome v -> LanguagePrimitives.PhysicalHash v +[] +/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at +/// a particular usage point. +type ItemWithInst = + { Item : Item + TyparInst: TyparInst } + +let ItemWithNoInst item = ({ Item = item; TyparInst = emptyTyparInst } : ItemWithInst) + +let (|ItemWithInst|) (x:ItemWithInst) = (x.Item, x.TyparInst) + /// Represents a record field resolution and the information if the usage is deprecated. type FieldResolution = FieldResolution of RecdFieldRef * bool @@ -1197,7 +1226,7 @@ type ItemOccurence = type ITypecheckResultsSink = abstract NotifyEnvWithScope : range * NameResolutionEnv * AccessorDomain -> unit abstract NotifyExprHasType : pos * TType * Tastops.DisplayEnv * NameResolutionEnv * AccessorDomain * range -> unit - abstract NotifyNameResolution : pos * Item * Item * ItemOccurence * Tastops.DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit + abstract NotifyNameResolution : pos * Item * Item * TyparInst * ItemOccurence * Tastops.DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit abstract NotifyFormatSpecifierLocation : range * int -> unit abstract CurrentSource : string option @@ -1364,9 +1393,10 @@ let ItemsAreEffectivelyEqual g orig other = | _ -> false [] -type CapturedNameResolution(p:pos, i:Item, io:ItemOccurence, de:DisplayEnv, nre:NameResolutionEnv, ad:AccessorDomain, m:range) = +type CapturedNameResolution(p:pos, i:Item, tpinst, io:ItemOccurence, de:DisplayEnv, nre:NameResolutionEnv, ad:AccessorDomain, m:range) = member this.Pos = p member this.Item = i + member this.ItemWithInst = ({ Item = i; TyparInst = tpinst } : ItemWithInst) member this.ItemOccurence = io member this.DisplayEnv = de member this.NameResolutionEnv = nre @@ -1391,23 +1421,29 @@ type TcResolutions static member Empty = empty +[] +type TcSymbolUseData = + { Item: Item + ItemOccurence: ItemOccurence + DisplayEnv: DisplayEnv + Range: range } /// Represents container for all name resolutions that were met so far when typechecking some particular file type TcSymbolUses(g, capturedNameResolutions : ResizeArray, formatSpecifierLocations: (range * int)[]) = // Make sure we only capture the information we really need to report symbol uses - let cnrs = [| for cnr in capturedNameResolutions -> (* struct *) (cnr.Item, cnr.ItemOccurence, cnr.DisplayEnv, cnr.Range) |] + let cnrs = [| for cnr in capturedNameResolutions -> { Item=cnr.Item; ItemOccurence=cnr.ItemOccurence; DisplayEnv=cnr.DisplayEnv; Range=cnr.Range } |] let capturedNameResolutions = () do ignore capturedNameResolutions // don't capture this! member this.GetUsesOfSymbol(item) = - [| for ( (* struct *) (cnrItem,occ,denv,m)) in cnrs do - if protectAssemblyExploration false (fun () -> ItemsAreEffectivelyEqual g item cnrItem) then - yield occ, denv, m |] + [| for cnr in cnrs do + if protectAssemblyExploration false (fun () -> ItemsAreEffectivelyEqual g item cnr.Item) then + yield (cnr.ItemOccurence, cnr.DisplayEnv, cnr.Range) |] member this.GetAllUsesOfSymbols() = - [| for ( (* struct *) (cnrItem,occ,denv,m)) in cnrs do - yield (cnrItem, occ, denv, m) |] + [| for cnr in cnrs do + yield (cnr.Item, cnr.ItemOccurence, cnr.DisplayEnv, cnr.Range) |] member this.GetFormatSpecifierLocationsAndArity() = formatSpecifierLocations @@ -1441,7 +1477,7 @@ type TcResultsSinkImpl(g, ?source: string) = if allowedRange m then capturedExprTypings.Add((endPos,ty,denv,nenv,ad,m)) - member sink.NotifyNameResolution(endPos,item,itemMethodGroup,occurenceType,denv,nenv,ad,m,replace) = + member sink.NotifyNameResolution(endPos,item,itemMethodGroup,tpinst,occurenceType,denv,nenv,ad,m,replace) = // Desugaring some F# constructs (notably computation expressions with custom operators) // results in duplication of textual variables. So we ensure we never record two name resolutions // for the same identifier at the same location. @@ -1462,8 +1498,8 @@ type TcResultsSinkImpl(g, ?source: string) = capturedMethodGroupResolutions.RemoveAll(fun cnr -> cnr.Range = m) |> ignore if not alreadyDone then - capturedNameResolutions.Add(CapturedNameResolution(endPos,item,occurenceType,denv,nenv,ad,m)) - capturedMethodGroupResolutions.Add(CapturedNameResolution(endPos,itemMethodGroup,occurenceType,denv,nenv,ad,m)) + capturedNameResolutions.Add(CapturedNameResolution(endPos,item,tpinst,occurenceType,denv,nenv,ad,m)) + capturedMethodGroupResolutions.Add(CapturedNameResolution(endPos,itemMethodGroup,[],occurenceType,denv,nenv,ad,m)) member sink.NotifyFormatSpecifierLocation(m, numArgs) = capturedFormatSpecifierLocations.Add((m, numArgs)) @@ -1498,15 +1534,15 @@ let CallEnvSink (sink:TcResultsSink) (scopem,nenv,ad) = | Some sink -> sink.NotifyEnvWithScope(scopem,nenv,ad) /// Report a specific name resolution at a source range -let CallNameResolutionSink (sink:TcResultsSink) (m:range,nenv,item,itemMethodGroup,occurenceType,denv,ad) = +let CallNameResolutionSink (sink:TcResultsSink) (m:range,nenv,item,itemMethodGroup,tpinst,occurenceType,denv,ad) = match sink.CurrentSink with | None -> () - | Some sink -> sink.NotifyNameResolution(m.End,item,itemMethodGroup,occurenceType,denv,nenv,ad,m,false) + | Some sink -> sink.NotifyNameResolution(m.End,item,itemMethodGroup,tpinst,occurenceType,denv,nenv,ad,m,false) -let CallNameResolutionSinkReplacing (sink:TcResultsSink) (m:range,nenv,item,itemMethodGroup,occurenceType,denv,ad) = +let CallNameResolutionSinkReplacing (sink:TcResultsSink) (m:range,nenv,item,itemMethodGroup,tpinst,occurenceType,denv,ad) = match sink.CurrentSink with | None -> () - | Some sink -> sink.NotifyNameResolution(m.End,item,itemMethodGroup,occurenceType,denv,nenv,ad,m,true) + | Some sink -> sink.NotifyNameResolution(m.End,item,itemMethodGroup,tpinst,occurenceType,denv,nenv,ad,m,true) /// Report a specific expression typing at a source range let CallExprHasTypeSink (sink:TcResultsSink) (m:range,nenv,typ,denv,ad) = @@ -1581,12 +1617,12 @@ let CheckAllTyparsInferrable amap m item = /// System and Console, i.e. the 'entity path' of the resolution. /// /// Each of the resolution routines keeps track of the entity path and -/// ultimately calls ResolutionInfo.SendToSink to record it for +/// ultimately calls ResolutionInfo.Method to record it for /// later use by Visual Studio. type ResolutionInfo = | ResolutionInfo of (*entityPath, reversed*)(range * EntityRef) list * (*warnings/errors*)(ResultTyparChecker -> unit) - static member SendToSink(sink, ncenv: NameResolver, nenv, occ, ad, ResolutionInfo(entityPath,warnings), typarChecker) = + static member SendEntityPathToSink(sink, ncenv: NameResolver, nenv, occ, ad, ResolutionInfo(entityPath,warnings), typarChecker) = entityPath |> List.iter (fun (m,eref:EntityRef) -> CheckEntityAttributes ncenv.g eref m |> CommitOperationResult CheckTyconAccessible ncenv.amap m ad eref |> ignore @@ -1595,7 +1631,7 @@ type ResolutionInfo = Item.ModuleOrNamespaces [eref] else Item.Types(eref.DisplayName,[FreshenTycon ncenv m eref]) - CallNameResolutionSink sink (m,nenv,item,item,occ,nenv.eDisplayEnv,ad)) + CallNameResolutionSink sink (m,nenv,item,item,emptyTyparInst,occ,nenv.eDisplayEnv,ad)) warnings(typarChecker) static member Empty = @@ -2093,7 +2129,7 @@ let ResolveLongIdentInType sink ncenv nenv lookupKind m ad lid findFlag typeName ResolveLongIdentInTypePrim (ncenv:NameResolver) nenv lookupKind ResolutionInfo.Empty 0 m ad lid findFlag typeNameResInfo typ |> AtMostOneResult m |> ForceRaise - ResolutionInfo.SendToSink (sink,ncenv,nenv,ItemOccurence.UseInType,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) + ResolutionInfo.SendEntityPathToSink (sink,ncenv,nenv,ItemOccurence.UseInType,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) item,rest let private ResolveLongIdentInTyconRef (ncenv:NameResolver) nenv lookupKind resInfo depth m ad lid typeNameResInfo tcref = @@ -2284,7 +2320,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) fullyQualified m ad n match AtMostOneResult m search with | Result _ as res -> let resInfo,item,rest = ForceRaise res - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) Some(item,rest) | Exception e -> typeError := Some e; None @@ -2364,7 +2400,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) fullyQualified m ad n raze (UndefinedName(0,FSComp.SR.undefinedNameValueOfConstructor,id,suggestNamesAndTypes)) ForceRaise failingCase - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) item,rest @@ -2483,7 +2519,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv:NameResolver) fullyQualified m ad n let failingCase = raze (UndefinedName(0,FSComp.SR.undefinedNameValueNamespaceTypeOrModule,id,suggestEverythingInScope)) ForceRaise failingCase - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap m item)) item,rest let ResolveExprLongIdent sink (ncenv:NameResolver) m ad nenv typeNameResInfo lid = @@ -2632,7 +2668,7 @@ let rec ResolvePatternLongIdentPrim sink (ncenv:NameResolver) fullyQualified war | Result _ as res -> ForceRaise res | _ -> ForceRaise (AtMostOneResult m (tyconSearch AccessibleFromSomeFSharpCode +++ moduleSearch AccessibleFromSomeFSharpCode)) - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> true)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> true)) if not (isNil rest) then error(Error(FSComp.SR.nrIsNotConstructorOrLiteral(),(List.head rest).idRange)) res @@ -2709,9 +2745,9 @@ let rec ResolveTypeLongIdentInTyconRefPrim (ncenv:NameResolver) (typeNameResInfo /// Resolve a long identifier representing a type name and report the result let ResolveTypeLongIdentInTyconRef sink (ncenv:NameResolver) nenv typeNameResInfo ad m tcref (lid: Ident list) = let resInfo,tcref = ForceRaise (ResolveTypeLongIdentInTyconRefPrim ncenv typeNameResInfo ad ResolutionInfo.Empty PermitDirectReferenceToGeneratedType.No 0 m tcref lid) - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> true)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> true)) let item = Item.Types(tcref.DisplayName,[FreshenTycon ncenv m tcref]) - CallNameResolutionSink sink (rangeOfLid lid,nenv,item,item,ItemOccurence.UseInType,nenv.eDisplayEnv,ad) + CallNameResolutionSink sink (rangeOfLid lid,nenv,item,item,emptyTyparInst,ItemOccurence.UseInType,nenv.eDisplayEnv,ad) tcref /// Create an UndefinedName error with details @@ -2855,9 +2891,9 @@ let ResolveTypeLongIdent sink (ncenv:NameResolver) occurence fullyQualified nenv // Register the result as a name resolution match res with | Result (resInfo,tcref) -> - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.UseInType, ad,resInfo,ResultTyparChecker(fun () -> true)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.UseInType, ad,resInfo,ResultTyparChecker(fun () -> true)) let item = Item.Types(tcref.DisplayName,[FreshenTycon ncenv m tcref]) - CallNameResolutionSink sink (m,nenv,item,item,occurence,nenv.eDisplayEnv,ad) + CallNameResolutionSink sink (m,nenv,item,item,emptyTyparInst,occurence,nenv.eDisplayEnv,ad) | _ -> () res |?> snd @@ -3065,7 +3101,7 @@ let ResolveField sink ncenv nenv ad typ (mp,id) allFields = let checker = ResultTyparChecker(fun () -> true) res |> List.map (fun (resInfo,rfref) -> - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.UseInType,ad,resInfo,checker) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.UseInType,ad,resInfo,checker) rfref) /// Generate a new reference to a record field with a fresh type instantiation @@ -3133,28 +3169,26 @@ let FilterMethodGroups (ncenv:NameResolver) itemRange item staticOnly = Item.MethodGroup(nm, minfos, orig) | item -> item -let NeedsOverloadResolution namedItem = - match namedItem with - | Item.MethodGroup(_,_::_::_,_) - | Item.CtorGroup(_,_::_::_) - | Item.Property(_,_::_::_) -> true - | _ -> false - -/// An adjustment to perform to the name resolution results if overload resolution fails. -/// If overload resolution succeeds, the specific overload resolution is reported. If it fails, the -/// set of possible overloads is reported via this adjustment. -type IfOverloadResolutionFails = IfOverloadResolutionFails of (unit -> unit) +let NeedsWorkAfterResolution namedItem = + match namedItem with + | Item.MethodGroup(_,minfos,_) + | Item.CtorGroup(_,minfos) -> minfos.Length > 1 || minfos |> List.exists (fun minfo -> not (isNil minfo.FormalMethodInst)) + | Item.Property(_,pinfos) -> pinfos.Length > 1 + | Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(_, vref, _)) }) + | Item.Value vref | Item.CustomBuilder (_,vref) -> vref.Typars.Length > 0 + | Item.CustomOperation (_,_,Some minfo) -> not (isNil minfo.FormalMethodInst) + | Item.ActivePatternCase apref -> apref.ActivePatternVal.Typars.Length > 0 + | _ -> false -/// Specifies if overload resolution needs to notify Language Service of overload resolution +/// Specifies additional work to do after an item has been processed further in type checking. [] -type AfterOverloadResolution = +type AfterResolution = + /// Notification is not needed - | DoNothing - /// Notify the sink - | SendToSink of (Item -> unit) * IfOverloadResolutionFails // Overload resolution failure fallback - /// Find override among given overrides and notify the sink. The 'Item' contains the candidate overrides. - | ReplaceWithOverrideAndSendToSink of Item * (Item -> unit) * IfOverloadResolutionFails // Overload resolution failure fallback + | DoNothing + /// Notify the tcSink of a precise resolution. The 'Item' contains the candidate overrides. + | RecordResolution of Item option * (TyparInst -> unit) * (MethInfo * PropInfo option * TyparInst -> unit) * (unit -> unit) /// Resolve a long identifier occurring in an expression position. /// @@ -3163,7 +3197,6 @@ let ResolveLongIdentAsExprAndComputeRange (sink:TcResultsSink) (ncenv:NameResolv let item1,rest = ResolveExprLongIdent sink ncenv wholem ad nenv typeNameResInfo lid let itemRange = ComputeItemRange wholem lid rest - // Record the precise resolution of the field for intellisense let item = FilterMethodGroups ncenv itemRange item1 true match item1,item with @@ -3178,7 +3211,7 @@ let ResolveLongIdentAsExprAndComputeRange (sink:TcResultsSink) (ncenv:NameResolv | head :: ids -> ids |> List.forall (fun id -> id.idRange = head.idRange) - let callSink refinedItem = + let callSink (refinedItem, tpinst) = if not isFakeIdents then let occurence = match item with @@ -3188,17 +3221,28 @@ let ResolveLongIdentAsExprAndComputeRange (sink:TcResultsSink) (ncenv:NameResolv | Item.ActivePatternResult _ -> ItemOccurence.Binding | _ -> ItemOccurence.Use - CallNameResolutionSink sink (itemRange, nenv, refinedItem, item, occurence, nenv.DisplayEnv, ad) - let afterOverloadResolution = + CallNameResolutionSink sink (itemRange, nenv, refinedItem, item, tpinst, occurence, nenv.DisplayEnv, ad) + + let callSinkWithSpecificOverload (minfo: MethInfo, pinfoOpt: PropInfo option, tpinst) = + let refinedItem = + match pinfoOpt with + | None when minfo.IsConstructor -> Item.CtorGroup(minfo.LogicalName,[minfo]) + | None -> Item.MethodGroup(minfo.LogicalName,[minfo],None) + | Some pinfo -> Item.Property(pinfo.PropertyName,[pinfo]) + + callSink (refinedItem, tpinst) + + let afterResolution = match sink.CurrentSink with - | None -> AfterOverloadResolution.DoNothing - | Some _ -> - if NeedsOverloadResolution item then - AfterOverloadResolution.SendToSink(callSink, (fun () -> callSink item) |> IfOverloadResolutionFails) - else - callSink item - AfterOverloadResolution.DoNothing - item, itemRange, rest, afterOverloadResolution + | None -> AfterResolution.DoNothing + | Some _ -> + if NeedsWorkAfterResolution item then + AfterResolution.RecordResolution(None, (fun tpinst -> callSink(item,tpinst)), callSinkWithSpecificOverload, (fun () -> callSink (item, emptyTyparInst))) + else + callSink (item, emptyTyparInst) + AfterResolution.DoNothing + + item, itemRange, rest, afterResolution let (|NonOverridable|_|) namedItem = match namedItem with @@ -3217,35 +3261,47 @@ let ResolveExprDotLongIdentAndComputeRange (sink:TcResultsSink) (ncenv:NameResol resInfo,item,rest,itemRange // "true" resolution let resInfo,item,rest,itemRange = resolveExpr findFlag - ResolutionInfo.SendToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap itemRange item)) + ResolutionInfo.SendEntityPathToSink(sink,ncenv,nenv,ItemOccurence.Use,ad,resInfo,ResultTyparChecker(fun () -> CheckAllTyparsInferrable ncenv.amap itemRange item)) // Record the precise resolution of the field for intellisense/goto definition - let afterOverloadResolution = - match sink.CurrentSink with - | None -> AfterOverloadResolution.DoNothing // do not retypecheck if nobody listens - | Some _ -> - // resolution for goto definition - let unrefinedItem,itemRange,overrides = - match findFlag, item with - | FindMemberFlag.PreferOverrides, _ - | _, NonOverridable() -> item,itemRange,false - | FindMemberFlag.IgnoreOverrides,_ -> - let _,item,_,itemRange = resolveExpr FindMemberFlag.PreferOverrides - item, itemRange,true - let sendToSink refinedItem = - let staticOnly = thisIsActuallyATyAppNotAnExpr - let refinedItem = FilterMethodGroups ncenv itemRange refinedItem staticOnly - let unrefinedItem = FilterMethodGroups ncenv itemRange unrefinedItem staticOnly - CallNameResolutionSink sink (itemRange, nenv, refinedItem, unrefinedItem, ItemOccurence.Use, nenv.DisplayEnv, ad) - match overrides,NeedsOverloadResolution unrefinedItem with - | false, true -> - AfterOverloadResolution.SendToSink(sendToSink, IfOverloadResolutionFails(fun () -> sendToSink unrefinedItem)) - | true, true -> - AfterOverloadResolution.ReplaceWithOverrideAndSendToSink(unrefinedItem,sendToSink, IfOverloadResolutionFails(fun () -> sendToSink unrefinedItem)) - | _ , false -> - sendToSink unrefinedItem - AfterOverloadResolution.DoNothing - item, itemRange, rest, afterOverloadResolution + let afterResolution = + match sink.CurrentSink with + | None -> AfterResolution.DoNothing // do not refine the resolution if nobody listens + | Some _ -> + // resolution for goto definition + let unrefinedItem,itemRange,overrides = + match findFlag, item with + | FindMemberFlag.PreferOverrides, _ + | _, NonOverridable() -> item,itemRange,false + | FindMemberFlag.IgnoreOverrides,_ -> + let _,item,_,itemRange = resolveExpr FindMemberFlag.PreferOverrides + item, itemRange,true + + let callSink (refinedItem, tpinst) = + let staticOnly = thisIsActuallyATyAppNotAnExpr + let refinedItem = FilterMethodGroups ncenv itemRange refinedItem staticOnly + let unrefinedItem = FilterMethodGroups ncenv itemRange unrefinedItem staticOnly + CallNameResolutionSink sink (itemRange, nenv, refinedItem, unrefinedItem, tpinst, ItemOccurence.Use, nenv.DisplayEnv, ad) + + let callSinkWithSpecificOverload (minfo: MethInfo, pinfoOpt: PropInfo option, tpinst) = + let refinedItem = + match pinfoOpt with + | None when minfo.IsConstructor -> Item.CtorGroup(minfo.LogicalName,[minfo]) + | None -> Item.MethodGroup(minfo.LogicalName,[minfo],None) + | Some pinfo -> Item.Property(pinfo.PropertyName,[pinfo]) + + callSink (refinedItem, tpinst) + + match overrides, NeedsWorkAfterResolution unrefinedItem with + | false, true -> + AfterResolution.RecordResolution (None, (fun tpinst -> callSink(item,tpinst)), callSinkWithSpecificOverload, (fun () -> callSink (unrefinedItem, emptyTyparInst))) + | true, true -> + AfterResolution.RecordResolution (Some unrefinedItem, (fun tpinst -> callSink(item,tpinst)), callSinkWithSpecificOverload, (fun () -> callSink (unrefinedItem, emptyTyparInst))) + | _ , false -> + callSink (unrefinedItem, emptyTyparInst) + AfterResolution.DoNothing + + item, itemRange, rest, afterResolution //------------------------------------------------------------------------- @@ -3344,6 +3400,7 @@ type ResolveCompletionTargets = /// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type. let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: ResolveCompletionTargets) m ad statics typ = + protectAssemblyExploration [] <| fun () -> let g = ncenv.g let amap = ncenv.amap @@ -3972,9 +4029,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: | _-> [] modsOrNs @ qualifiedFields -(* Determining if an `Item` is resolvable at point by given `plid`. It's optimized by being lazy and early returning according to the given `Item` *) - -let private ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ (item: Item) : seq = +let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics typ (item: Item) : seq = seq { let g = ncenv.g let amap = ncenv.amap @@ -4143,7 +4198,7 @@ let private ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad stat | _ -> () } -let rec private ResolvePartialLongIdentInTypeForItem (ncenv: NameResolver) nenv m ad statics plid (item: Item) typ = +let rec ResolvePartialLongIdentInTypeForItem (ncenv: NameResolver) nenv m ad statics plid (item: Item) typ = seq { let g = ncenv.g let amap = ncenv.amap @@ -4194,7 +4249,7 @@ let rec private ResolvePartialLongIdentInTypeForItem (ncenv: NameResolver) nenv yield! finfo.FieldType(amap, m) |> ResolvePartialLongIdentInTypeForItem ncenv nenv m ad false rest item } -let rec private ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) nenv m ad (modref: ModuleOrNamespaceRef) plid (item: Item) = +let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) nenv m ad (modref: ModuleOrNamespaceRef) plid (item: Item) = let g = ncenv.g let mty = modref.ModuleOrNamespaceType @@ -4273,7 +4328,7 @@ let rec private ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameRe yield! tcref |> generalizedTyconRef |> ResolvePartialLongIdentInTypeForItem ncenv nenv m ad true rest item } -let rec private PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy f plid (modref: ModuleOrNamespaceRef) = +let rec PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy f plid (modref: ModuleOrNamespaceRef) = let mty = modref.ModuleOrNamespaceType match plid with | [] -> f modref @@ -4283,7 +4338,7 @@ let rec private PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLa PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy f rest (modref.NestedTyconRef mty) | None -> Seq.empty -let private PartialResolveLongIndentAsModuleOrNamespaceThenLazy (nenv:NameResolutionEnv) plid f = +let PartialResolveLongIndentAsModuleOrNamespaceThenLazy (nenv:NameResolutionEnv) plid f = seq { match plid with | id :: rest -> @@ -4295,7 +4350,7 @@ let private PartialResolveLongIndentAsModuleOrNamespaceThenLazy (nenv:NameResolu | [] -> () } -let rec private GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad plid (item: Item) : seq = +let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad plid (item: Item) : seq = seq { let g = ncenv.g @@ -4385,9 +4440,11 @@ let rec private GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolution } let IsItemResolvable (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad plid (item: Item) : bool = + protectAssemblyExploration false <| fun () -> GetCompletionForItem ncenv nenv m ad plid item |> Seq.exists (ItemsAreEffectivelyEqual ncenv.g item) let GetVisibleNamespacesAndModulesAtPoint (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad = + protectAssemblyExploration [] <| fun () -> let ilTyconNames = nenv.TyconsByAccessNames(FullyQualifiedFlag.OpenQualified).Values |> List.choose (fun tyconRef -> if tyconRef.IsILTycon then Some tyconRef.DisplayName else None) diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index d7e02dfe90..b50fc99db7 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -43,37 +43,91 @@ val (|AbbrevOrAppTy|_|) : TType -> TyconRef option [] /// Represents an item that results from name resolution type Item = - // These exist in the "eUnqualifiedItems" List.map in the type environment. - | Value of ValRef - // UnionCaseInfo and temporary flag which is used to show a "use case is deprecated" message - | UnionCase of UnionCaseInfo * bool - | ActivePatternResult of ActivePatternInfo * TType * int * range - | ActivePatternCase of ActivePatternElemRef - | ExnCase of TyconRef - | RecdField of RecdFieldInfo - | NewDef of Ident - | ILField of ILFieldInfo - | Event of EventInfo - | Property of string * PropInfo list - | MethodGroup of displayName: string * methods: MethInfo list * uninstantiatedMethodOpt: MethInfo option - | CtorGroup of string * MethInfo list - | FakeInterfaceCtor of TType - | DelegateCtor of TType - | Types of string * TType list - /// CustomOperation(operationName, operationHelpText, operationImplementation). - /// - /// Used to indicate the availability or resolution of a custom query operation such as 'sortBy' or 'where' in computation expression syntax - | CustomOperation of string * (unit -> string option) * MethInfo option - | CustomBuilder of string * ValRef - | TypeVar of string * Typar - | ModuleOrNamespaces of Tast.ModuleOrNamespaceRef list - /// Represents the resolution of a source identifier to an implicit use of an infix operator (+solution if such available) - | ImplicitOp of Ident * TraitConstraintSln option ref - /// Represents the resolution of a source identifier to a named argument - | ArgName of Ident * TType * ArgumentContainer option - | SetterArg of Ident * Item - | UnqualifiedType of TyconRef list - member DisplayName : string + /// Represents the resolution of a name to an F# value or function. + | Value of ValRef + + /// Represents the resolution of a name to an F# union case. + | UnionCase of UnionCaseInfo * bool + + /// Represents the resolution of a name to an F# active pattern result. + | ActivePatternResult of ActivePatternInfo * TType * int * range + + /// Represents the resolution of a name to an F# active pattern case within the body of an active pattern. + | ActivePatternCase of ActivePatternElemRef + + /// Represents the resolution of a name to an F# exception definition. + | ExnCase of TyconRef + + /// Represents the resolution of a name to an F# record field. + | RecdField of RecdFieldInfo + + // The following are never in the items table but are valid results of binding + // an identifier in different circumstances. + + /// Represents the resolution of a name at the point of its own definition. + | NewDef of Ident + + /// Represents the resolution of a name to a .NET field + | ILField of ILFieldInfo + + /// Represents the resolution of a name to an event + | Event of EventInfo + + /// Represents the resolution of a name to a property + | Property of string * PropInfo list + + /// Represents the resolution of a name to a group of methods. + | MethodGroup of displayName: string * methods: MethInfo list * uninstantiatedMethodOpt: MethInfo option + + /// Represents the resolution of a name to a constructor + | CtorGroup of string * MethInfo list + + /// Represents the resolution of a name to the fake constructor simulated for an interface type. + | FakeInterfaceCtor of TType + + /// Represents the resolution of a name to a delegate + | DelegateCtor of TType + + /// Represents the resolution of a name to a group of types + | Types of string * TType list + + /// CustomOperation(nm, helpText, methInfo) + /// + /// Used to indicate the availability or resolution of a custom query operation such as 'sortBy' or 'where' in computation expression syntax + | CustomOperation of string * (unit -> string option) * MethInfo option + + /// Represents the resolution of a name to a custom builder in the F# computation expression syntax + | CustomBuilder of string * ValRef + + /// Represents the resolution of a name to a type variable + | TypeVar of string * Typar + + /// Represents the resolution of a name to a module or namespace + | ModuleOrNamespaces of Tast.ModuleOrNamespaceRef list + + /// Represents the resolution of a name to an operator + | ImplicitOp of Ident * TraitConstraintSln option ref + + /// Represents the resolution of a name to a named argument + | ArgName of Ident * TType * ArgumentContainer option + + /// Represents the resolution of a name to a named property setter + | SetterArg of Ident * Item + + /// Represents the potential resolution of an unqualified name to a type. + | UnqualifiedType of TyconRef list + + member DisplayName : string + +[] +/// Pairs an Item with a TyparInst showing how generic type variables of the item are instantiated at +/// a particular usage point. +type ItemWithInst = + { Item : Item + TyparInst: TyparInst } + +val (|ItemWithInst|) : ItemWithInst -> Item * TyparInst +val ItemWithNoInst : Item -> ItemWithInst /// Represents a record field resolution and the information if the usage is deprecated. type FieldResolution = FieldResolution of RecdFieldRef * bool @@ -201,6 +255,9 @@ type internal CapturedNameResolution = /// Named item member Item : Item + /// The active instantiation for any generic type parameters + member ItemWithInst: ItemWithInst + /// Information about the occurrence of the symbol member ItemOccurence : ItemOccurence @@ -261,7 +318,7 @@ type ITypecheckResultsSink = abstract NotifyExprHasType : pos * TType * DisplayEnv * NameResolutionEnv * AccessorDomain * range -> unit /// Record that a name resolution occurred at a specific location in the source - abstract NotifyNameResolution : pos * Item * Item * ItemOccurence * DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit + abstract NotifyNameResolution : pos * Item * Item * TyparInst * ItemOccurence * DisplayEnv * NameResolutionEnv * AccessorDomain * range * bool -> unit /// Record that a printf format specifier occurred at a specific location in the source abstract NotifyFormatSpecifierLocation : range * int -> unit @@ -299,10 +356,10 @@ val internal TemporarilySuspendReportingTypecheckResultsToSink : TcResultsSink - val internal CallEnvSink : TcResultsSink -> range * NameResolutionEnv * AccessorDomain -> unit /// Report a specific name resolution at a source range -val internal CallNameResolutionSink : TcResultsSink -> range * NameResolutionEnv * Item * Item * ItemOccurence * DisplayEnv * AccessorDomain -> unit +val internal CallNameResolutionSink : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit /// Report a specific name resolution at a source range, replacing any previous resolutions -val internal CallNameResolutionSinkReplacing : TcResultsSink -> range * NameResolutionEnv * Item * Item * ItemOccurence * DisplayEnv * AccessorDomain -> unit +val internal CallNameResolutionSinkReplacing : TcResultsSink -> range * NameResolutionEnv * Item * Item * TyparInst * ItemOccurence * DisplayEnv * AccessorDomain -> unit /// Report a specific name resolution at a source range val internal CallExprHasTypeSink : TcResultsSink -> range * NameResolutionEnv * TType * DisplayEnv * AccessorDomain -> unit @@ -383,26 +440,28 @@ val internal ResolvePartialLongIdentToClassOrRecdFields : NameResolver -> NameRe /// Return the fields for the given class or record val internal ResolveRecordOrClassFieldsOfType : NameResolver -> range -> AccessorDomain -> TType -> bool -> Item list -/// An adjustment to perform to the name resolution results if overload resolution fails. -/// If overload resolution succeeds, the specific overload resolution is reported. If it fails, the -/// set of possible overloads is reported via this adjustment. -type IfOverloadResolutionFails = IfOverloadResolutionFails of (unit -> unit) - -/// Specifies if overload resolution needs to notify Language Service of overload resolution +/// Specifies extra work to do after overload resolution [] -type AfterOverloadResolution = +type AfterResolution = /// Notification is not needed - | DoNothing - /// Notify the sink - | SendToSink of (Item -> unit) * IfOverloadResolutionFails // overload resolution failure fallback - /// Find override among given overrides and notify the sink. The 'Item' contains the candidate overrides. - | ReplaceWithOverrideAndSendToSink of Item * (Item -> unit) * IfOverloadResolutionFails // overload resolution failure fallback + | DoNothing + + /// Notify the sink of the information needed to complete recording a use of a symbol + /// for the purposes of the language service. One of the callbacks should be called by + /// the checker. + /// + /// The first callback represents a case where we have learned the type + /// instantiation of a generic method or value. + /// + /// The second represents the case where we have resolved overloading and/or + /// a specific override. The 'Item option' contains the candidate overrides. + | RecordResolution of Item option * (TyparInst -> unit) * (MethInfo * PropInfo option * TyparInst -> unit) * (unit -> unit) /// Resolve a long identifier occurring in an expression position. -val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * range * Ident list * AfterOverloadResolution +val internal ResolveLongIdentAsExprAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TypeNameResolutionInfo -> Ident list -> Item * range * Ident list * AfterResolution /// Resolve a long identifier occurring in an expression position, qualified by a type. -val internal ResolveExprDotLongIdentAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TType -> Ident list -> FindMemberFlag -> bool -> Item * range * Ident list * AfterOverloadResolution +val internal ResolveExprDotLongIdentAndComputeRange : TcResultsSink -> NameResolver -> range -> AccessorDomain -> NameResolutionEnv -> TType -> Ident list -> FindMemberFlag -> bool -> Item * range * Ident list * AfterResolution /// A generator of type instantiations used when no more specific type instantiation is known. val FakeInstantiationGenerator : range -> Typar list -> TType list diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index fa202093a1..4095ab0195 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -6,20 +6,16 @@ module internal Microsoft.FSharp.Compiler.NicePrint -open Internal.Utilities open Microsoft.FSharp.Compiler.AbstractIL -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.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.Tastops.DebugPrint open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.Infos @@ -1029,33 +1025,37 @@ module private PrintTypes = (if prefix || not (isNil tpcs) then nmL ^^ angleL (coreL --- tpcsL) else bracketL coreL --- nmL) - let layoutTyparConstraint denv typars = - match layoutConstraintWithInfo denv SimplifyTypes.typeSimplificationInfo0 typars with + let layoutTyparConstraint denv (tp, tpc) = + match layoutConstraintWithInfo denv SimplifyTypes.typeSimplificationInfo0 (tp, tpc) with | h::_ -> h | [] -> emptyL - let layoutPrettifiedTypes denv taus = - let _,ptaus,cxs = PrettyTypes.PrettifyTypesN denv.g taus - let env = SimplifyTypes.CollectInfo true ptaus cxs - List.map (layoutTypeWithInfo denv env) ptaus,layoutConstraintsWithInfo denv env env.postfixConstraints - - let layoutPrettifiedTypesAndConstraints denv argInfos tau cxs = - let env = SimplifyTypes.CollectInfo true (tau:: List.collect (List.map fst) argInfos) cxs - layoutTopType denv env argInfos tau env.postfixConstraints - - let layoutPrettifiedTypeAndConstraints denv argInfos tau = - let _,(argInfos,tau),cxs = PrettyTypes.PrettifyTypesN1 denv.g (argInfos,tau) - layoutPrettifiedTypesAndConstraints denv [argInfos] tau cxs - - let layoutMemberTypeAndConstraints denv argInfos retTy parentTyparTys = - let _,(parentTyparTys,argInfos,retTy),cxs = PrettyTypes.PrettifyTypesNM1 denv.g (parentTyparTys,argInfos,retTy) + let prettyLayoutOfInstAndSig denv (typarInst, tys, retTy) = + let (prettyTyparInst, prettyTys, prettyRetTy), cxs = PrettyTypes.PrettifyInstAndSig denv.g (typarInst, tys, retTy) + let env = SimplifyTypes.CollectInfo true (prettyRetTy :: prettyTys) cxs + let prettyTysL = List.map (layoutTypeWithInfo denv env) prettyTys + let prettyRetTyL = layoutTopType denv env [[]] prettyRetTy [] + prettyTyparInst, (prettyTys, prettyRetTy), (prettyTysL, prettyRetTyL), layoutConstraintsWithInfo denv env env.postfixConstraints + + let prettyLayoutOfTopTypeInfoAux denv prettyArgInfos prettyRetTy cxs = + let env = SimplifyTypes.CollectInfo true (prettyRetTy :: List.collect (List.map fst) prettyArgInfos) cxs + layoutTopType denv env prettyArgInfos prettyRetTy env.postfixConstraints + + // Oddly this is called in multiple places with argInfos=[] and denv.useColonForReturnType=true, as a complex + // way of giving give ": ty" + let prettyLayoutOfUncurriedSig denv typarInst argInfos retTy = + let (prettyTyparInst, prettyArgInfos,prettyRetTy),cxs = PrettyTypes.PrettifyInstAndUncurriedSig denv.g (typarInst, argInfos, retTy) + prettyTyparInst, prettyLayoutOfTopTypeInfoAux denv [prettyArgInfos] prettyRetTy cxs + + let prettyLayoutOfCurriedMemberSig denv typarInst argInfos retTy parentTyparTys = + let (prettyTyparInst, parentTyparTys,argInfos,retTy),cxs = PrettyTypes.PrettifyInstAndCurriedSig denv.g (typarInst, parentTyparTys, argInfos, retTy) // Filter out the parent typars, which don't get shown in the member signature let cxs = cxs |> List.filter (fun (tp,_) -> not (parentTyparTys |> List.exists (fun ty -> match tryDestTyparTy denv.g ty with Some destTypar -> typarEq tp destTypar | None -> false))) - layoutPrettifiedTypesAndConstraints denv argInfos retTy cxs + prettyTyparInst, prettyLayoutOfTopTypeInfoAux denv argInfos retTy cxs // Layout: type spec - class, datatype, record, abbrev - let private layoutMemberTypeCore denv memberToParentInst (methTypars: Typars,argInfos,retTy) = + let private prettyLayoutOfMemberSigCore denv memberToParentInst (typarInst, methTypars: Typars, argInfos, retTy) = let niceMethodTypars, allTyparInst = let methTyparNames = methTypars |> List.mapi (fun i tp -> if (PrettyTypes.NeedsPrettyTyparName tp) then sprintf "a%d" (List.length memberToParentInst + i) else tp.Name) PrettyTypes.NewPrettyTypars memberToParentInst methTypars methTyparNames @@ -1067,32 +1067,34 @@ module private PrintTypes = // aren't chosen as names for displayed variables. let memberParentTypars = List.map fst memberToParentInst let parentTyparTys = List.map (mkTyparTy >> instType allTyparInst) memberParentTypars + let prettyTyparInst, layout = prettyLayoutOfCurriedMemberSig denv typarInst argInfos retTy parentTyparTys - niceMethodTypars,layoutMemberTypeAndConstraints denv argInfos retTy parentTyparTys + prettyTyparInst, niceMethodTypars, layout - let layoutMemberType denv v argInfos retTy = + let prettyLayoutOfMemberType denv v typarInst argInfos retTy = match PartitionValRefTypars denv.g v with | Some(_,_,memberMethodTypars,memberToParentInst,_) -> - layoutMemberTypeCore denv memberToParentInst (memberMethodTypars, argInfos, retTy) + prettyLayoutOfMemberSigCore denv memberToParentInst (typarInst, memberMethodTypars, argInfos, retTy) | None -> - [],layoutPrettifiedTypeAndConstraints denv (List.concat argInfos) retTy + let prettyTyparInst, layout = prettyLayoutOfUncurriedSig denv typarInst (List.concat argInfos) retTy + prettyTyparInst, [], layout - let layoutMemberSig denv (memberToParentInst,nm,methTypars,argInfos,retTy) = - let niceMethodTypars,tauL = layoutMemberTypeCore denv memberToParentInst (methTypars, argInfos, retTy) + let prettyLayoutOfMemberSig denv (memberToParentInst, nm, methTypars, argInfos, retTy) = + let _, niceMethodTypars, tauL = prettyLayoutOfMemberSigCore denv memberToParentInst (emptyTyparInst, methTypars, argInfos, retTy) let nameL = let nameL = DemangleOperatorNameAsLayout tagMember nm let nameL = if denv.showTyparBinding then layoutTyparDecls denv nameL true niceMethodTypars else nameL nameL nameL ^^ wordL (tagPunctuation ":") ^^ tauL - let layoutPrettyType denv typ = - let _,typ,cxs = PrettyTypes.PrettifyTypes1 denv.g typ + let prettyLayoutOfType denv typ = + let typ,cxs = PrettyTypes.PrettifyType denv.g typ let env = SimplifyTypes.CollectInfo true [typ] cxs let cxsL = layoutConstraintsWithInfo denv env env.postfixConstraints layoutTypeWithInfoAndPrec denv env 2 typ --- cxsL - let layoutPrettyTypeNoCx denv typ = - let _,typ,_cxs = PrettyTypes.PrettifyTypes1 denv.g typ + let prettyLayoutOfTypeNoConstraints denv typ = + let typ,_cxs = PrettyTypes.PrettifyType denv.g typ layoutTypeWithInfoAndPrec denv SimplifyTypes.typeSimplificationInfo0 5 typ let layoutAssemblyName _denv (typ: TType) = @@ -1101,7 +1103,7 @@ module private PrintTypes = /// Printing TAST objects module private PrintTastMemberOrVals = open PrintTypes - let private layoutMember denv (v:Val) = + let private prettyLayoutOfMember denv typarInst (v:Val) = let v = mkLocalValRef v let membInfo = Option.get v.MemberInfo let stat = PrintTypes.layoutMemberFlags membInfo.MemberFlags @@ -1121,41 +1123,48 @@ module private PrintTastMemberOrVals = match membInfo.MemberFlags.MemberKind with | MemberKind.Member -> - let niceMethodTypars,tauL = layoutMemberType denv v argInfos rty + let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv v typarInst argInfos rty let nameL = mkNameL niceMethodTypars tagMember v.LogicalName - stat --- (nameL ^^ WordL.colon ^^ tauL) + let resL = stat --- (nameL ^^ WordL.colon ^^ tauL) + prettyTyparInst, resL | MemberKind.ClassConstructor | MemberKind.Constructor -> - let _,tauL = layoutMemberType denv v argInfos rty + let prettyTyparInst, _, tauL = prettyLayoutOfMemberType denv v typarInst argInfos rty let newL = layoutAccessibility denv v.Accessibility WordL.keywordNew - stat ++ newL ^^ wordL (tagPunctuation ":") ^^ tauL - | MemberKind.PropertyGetSet -> stat + let resL = stat ++ newL ^^ wordL (tagPunctuation ":") ^^ tauL + prettyTyparInst, resL + | MemberKind.PropertyGetSet -> + emptyTyparInst, stat | MemberKind.PropertyGet -> if isNil argInfos then // use error recovery because intellisense on an incomplete file will show this errorR(Error(FSComp.SR.tastInvalidFormForPropertyGetter(),v.Id.idRange)) let nameL = mkNameL [] tagProperty v.CoreDisplayName - stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordGet) + let resL = stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordGet) + emptyTyparInst, resL else let argInfos = match argInfos with | [[(ty,_)]] when isUnitTy denv.g ty -> [] | _ -> argInfos - let niceMethodTypars,tauL = layoutMemberType denv v argInfos rty + let prettyTyparInst, niceMethodTypars,tauL = prettyLayoutOfMemberType denv v typarInst argInfos rty let nameL = mkNameL niceMethodTypars tagProperty v.CoreDisplayName - stat --- (nameL ^^ WordL.colon ^^ (if isNil argInfos then tauL else tauL --- (WordL.keywordWith ^^ WordL.keywordGet))) + let resL = stat --- (nameL ^^ WordL.colon ^^ (if isNil argInfos then tauL else tauL --- (WordL.keywordWith ^^ WordL.keywordGet))) + prettyTyparInst, resL | MemberKind.PropertySet -> if argInfos.Length <> 1 || isNil argInfos.Head then // use error recovery because intellisense on an incomplete file will show this errorR(Error(FSComp.SR.tastInvalidFormForPropertySetter(),v.Id.idRange)) let nameL = mkNameL [] tagProperty v.CoreDisplayName - stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordSet) + let resL = stat --- nameL --- (WordL.keywordWith ^^ WordL.keywordSet) + emptyTyparInst, resL else let argInfos,valueInfo = List.frontAndBack argInfos.Head - let niceMethodTypars,tauL = layoutMemberType denv v (if isNil argInfos then [] else [argInfos]) (fst valueInfo) + let prettyTyparInst, niceMethodTypars, tauL = prettyLayoutOfMemberType denv v typarInst (if isNil argInfos then [] else [argInfos]) (fst valueInfo) let nameL = mkNameL niceMethodTypars tagProperty v.CoreDisplayName - stat --- (nameL ^^ wordL (tagPunctuation ":") ^^ (tauL --- (WordL.keywordWith ^^ WordL.keywordSet))) + let resL = stat --- (nameL ^^ wordL (tagPunctuation ":") ^^ (tauL --- (WordL.keywordWith ^^ WordL.keywordSet))) + prettyTyparInst, resL let private layoutNonMemberVal denv (tps,v:Val,tau,cxs) = let env = SimplifyTypes.CollectInfo true [tau] cxs @@ -1188,8 +1197,8 @@ module private PrintTastMemberOrVals = | None -> valAndTypeL | Some rhsL -> (valAndTypeL ++ wordL (tagPunctuation"=")) --- rhsL - let layoutValOrMember denv (v:Val) = - let vL = + let prettyLayoutOfValOrMember denv typarInst (v:Val) = + let prettyTyparInst, vL = match v.MemberInfo with | None -> let tps,tau = v.TypeScheme @@ -1197,27 +1206,26 @@ module private PrintTastMemberOrVals = // adjust the type in case this is the 'this' pointer stored in a reference cell let tau = StripSelfRefCell(denv.g, v.BaseOrThisInfo, tau) - let tprenaming,ptau,cxs = PrettyTypes.PrettifyTypes1 denv.g tau - let ptps = - tps - |> generalizeTypars - // Badly formed code may instantiate rigid declared typars to types, e.g. see bug - // Hence we double check here that the thing is really a type variable - |> List.choose (instType tprenaming >> tryAnyParTy denv.g) - layoutNonMemberVal denv (ptps,v,ptau,cxs) + let (prettyTyparInst, prettyTypars, prettyTauTy),cxs = PrettyTypes.PrettifyInstAndTyparsAndType denv.g (typarInst,tps,tau) + let resL = layoutNonMemberVal denv (prettyTypars,v,prettyTauTy,cxs) + prettyTyparInst, resL | Some _ -> - layoutMember denv v - layoutAttribs denv v.Type TyparKind.Type v.Attribs vL + prettyLayoutOfMember denv typarInst v + prettyTyparInst, layoutAttribs denv v.Type TyparKind.Type v.Attribs vL + + let prettyLayoutOfValOrMemberNoInst denv v = + prettyLayoutOfValOrMember denv emptyTyparInst v |> snd -let layoutMemberSig denv x = x |> PrintTypes.layoutMemberSig denv let layoutTyparConstraint denv x = x |> PrintTypes.layoutTyparConstraint denv -let outputTy denv os x = x |> PrintTypes.layoutType denv |> bufferL os -let layoutTy denv x = x |> PrintTypes.layoutType denv -let outputTypars denv nm os x = x |> PrintTypes.layoutTyparDecls denv (wordL nm) true |> bufferL os -let outputTyconRef denv os x = x |> PrintTypes.layoutTyconRef denv |> bufferL os -let layoutTyconRef denv x = x |> PrintTypes.layoutTyconRef denv +let outputType denv os x = x |> PrintTypes.layoutType denv |> bufferL os +let layoutType denv x = x |> PrintTypes.layoutType denv +let outputTypars denv nm os x = x |> PrintTypes.layoutTyparDecls denv (wordL nm) true |> bufferL os +let outputTyconRef denv os x = x |> PrintTypes.layoutTyconRef denv |> bufferL os +let layoutTyconRef denv x = x |> PrintTypes.layoutTyconRef denv let layoutConst g ty c = PrintTypes.layoutConst g ty c -let layoutPrettifiedTypeAndConstraints denv argInfos tau = PrintTypes.layoutPrettifiedTypeAndConstraints denv argInfos tau + +let prettyLayoutOfMemberSig denv x = x |> PrintTypes.prettyLayoutOfMemberSig denv +let prettyLayoutOfUncurriedSig denv argInfos tau = PrintTypes.prettyLayoutOfUncurriedSig denv argInfos tau //------------------------------------------------------------------------- @@ -1318,18 +1326,15 @@ module InfoMemberPrinting = // Prettify this baby - let prettifyILMethInfo (amap:Import.ImportMap) m (minfo:MethInfo) ilMethInfo = - match ilMethInfo with - | ILMethInfo(_, apparentTy,None, mdef,_) -> - let _,tys,_ = PrettyTypes.PrettifyTypesN amap.g (apparentTy :: minfo.FormalMethodInst) - let apparentTyR,minst = List.headAndTail tys - let minfo = MethInfo.CreateILMeth (amap, m, apparentTyR, mdef) - minfo, minst - | ILMethInfo (_, apparentTy,Some declaringTyconRef,mdef,_) -> - let _,tys,_ = PrettyTypes.PrettifyTypesN amap.g (apparentTy :: minfo.FormalMethodInst) - let apparentTyR,minst = List.headAndTail tys - let minfo = MethInfo.CreateILExtensionMeth(amap, m, apparentTyR, declaringTyconRef, minfo.ExtensionMemberPriorityOption, mdef) - minfo, minst + let prettifyILMethInfo (amap:Import.ImportMap) m (minfo:MethInfo) typarInst ilMethInfo = + let (ILMethInfo(_, apparentTy, dty, mdef, _)) = ilMethInfo + let (prettyTyparInst, prettyTys), _ = PrettyTypes.PrettifyInstAndTypes amap.g (typarInst, (apparentTy :: minfo.FormalMethodInst)) + let prettyApparentTy, prettyFormalMethInst = List.headAndTail prettyTys + let prettyMethInfo = + match dty with + | None -> MethInfo.CreateILMeth (amap, m, prettyApparentTy, mdef) + | Some declaringTyconRef -> MethInfo.CreateILExtensionMeth(amap, m, prettyApparentTy, declaringTyconRef, minfo.ExtensionMemberPriorityOption, mdef) + prettyTyparInst, prettyMethInfo, prettyFormalMethInst /// Format a method to a buffer using "standalone" display style. @@ -1353,24 +1358,28 @@ module InfoMemberPrinting = // // For C# extension members: // ApparentContainer.Method(argName1:argType1, ..., argNameN:argTypeN) : retType - let layoutMethInfoToFreeStyle amap m denv minfo = - match minfo with + let prettyLayoutOfMethInfoFreeStyle (amap: Import.ImportMap) m denv typarInst methInfo = + match methInfo with | DefaultStructCtor(g,_typ) -> - PrintTypes.layoutTyconRef denv (tcrefOfAppTy g minfo.EnclosingType) ^^ wordL (tagPunctuation "()") + let prettyTyparInst, _ = PrettyTypes.PrettifyInst amap.g typarInst + prettyTyparInst, PrintTypes.layoutTyconRef denv (tcrefOfAppTy g methInfo.EnclosingType) ^^ wordL (tagPunctuation "()") | FSMeth(_,_,vref,_) -> - vref.Deref |> PrintTastMemberOrVals.layoutValOrMember { denv with showMemberContainers=true; } + let prettyTyparInst, resL = PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true } typarInst vref.Deref + prettyTyparInst, resL | ILMeth(_,ilminfo,_) -> - let minfo,minst = prettifyILMethInfo amap m minfo ilminfo - layoutMethInfoCSharpStyle amap m denv minfo minst - #if EXTENSIONTYPING + let prettyTyparInst, prettyMethInfo, minst = prettifyILMethInfo amap m methInfo typarInst ilminfo + let resL = layoutMethInfoCSharpStyle amap m denv prettyMethInfo minst + prettyTyparInst, resL +#if EXTENSIONTYPING | ProvidedMeth _ -> - layoutMethInfoCSharpStyle amap m denv minfo minfo.FormalMethodInst + let prettyTyparInst, _ = PrettyTypes.PrettifyInst amap.g typarInst + prettyTyparInst, layoutMethInfoCSharpStyle amap m denv methInfo methInfo.FormalMethodInst #endif - let layoutPropInfoToFreeStyle g amap m denv (pinfo: PropInfo) = + let prettyLayoutOfPropInfoFreeStyle g amap m denv (pinfo: PropInfo) = let rty = pinfo.GetPropertyType(amap,m) let rty = if pinfo.IsIndexer then mkRefTupledTy g (pinfo.GetParamTypes(amap, m)) --> rty else rty - let _, rty, _ = PrettyTypes.PrettifyTypes1 g rty + let rty, _ = PrettyTypes.PrettifyType g rty let tagProp = match pinfo.ArbitraryValRef with | None -> tagProperty @@ -1381,16 +1390,15 @@ module InfoMemberPrinting = SepL.dot ^^ nameL ^^ RightL.colon ^^ - layoutTy denv rty + layoutType denv rty - let formatMethInfoToBufferFreeStyle amap m denv os minfo = - layoutMethInfoToFreeStyle amap m denv minfo |> bufferL os + let formatMethInfoToBufferFreeStyle amap m denv os (minfo: MethInfo) = + let _, resL = prettyLayoutOfMethInfoFreeStyle amap m denv emptyTyparInst minfo + resL |> bufferL os /// Format a method to a layout (actually just containing a string) using "free style" (aka "standalone"). let layoutMethInfoFSharpStyle amap m denv (minfo: MethInfo) = layoutMethInfoFSharpStyleCore amap m denv minfo minfo.FormalMethodInst - //wordL (bufs (fun buf -> formatMethInfoToBufferFSharpStyle amap m denv buf minfo minfo.FormalMethodInst)) - //------------------------------------------------------------------------- @@ -1407,7 +1415,8 @@ module private TastDefinitionPrinting = | Some(_,memberParentTypars,_,_,_) -> memberParentTypars | None -> [] let lhsL = WordL.keywordType ^^ layoutTyparDecls denv nameL tycon.IsPrefixDisplay tps - (lhsL ^^ WordL.keywordWith) @@-- (PrintTastMemberOrVals.layoutValOrMember denv v) + let memberL = PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv v + (lhsL ^^ WordL.keywordWith) @@-- memberL let layoutExtensionMembers denv vs = aboveListL (List.map (layoutExtensionMember denv) vs) @@ -1455,7 +1464,7 @@ module private TastDefinitionPrinting = let breakTypeDefnEqn repr = match repr with | TFSharpObjectRepr _ -> true - | TUnionRepr r -> r.CasesTable.UnionCasesAsList.Length > 1 + | TUnionRepr r -> not (isNilOrSingleton r.CasesTable.UnionCasesAsList) | TRecdRepr _ -> true | TAsmRepr _ | TILObjectRepr _ @@ -1670,9 +1679,9 @@ module private TastDefinitionPrinting = let iimpls = iimpls |> List.filter (fun (_,compgen,_) -> not compgen) // if TTyconInterface, the iimpls should be printed as inherited interfaces let iimplsLs = iimpls |> List.map (fun (ty,_,_) -> wordL (tagKeyword "interface") --- layoutType denv ty) - let adhocCtorsLs = adhoc |> List.filter (fun v -> v.IsConstructor) |> List.map (fun vref -> PrintTastMemberOrVals.layoutValOrMember denv vref.Deref) - let adhocInstanceLs = adhoc |> List.filter (fun v -> not v.IsConstructor && v.IsInstanceMember) |> List.map (fun vref -> PrintTastMemberOrVals.layoutValOrMember denv vref.Deref) - let adhocStaticLs = adhoc |> List.filter (fun v -> not v.IsConstructor && not v.IsInstanceMember) |> List.map (fun vref -> PrintTastMemberOrVals.layoutValOrMember denv vref.Deref) + let adhocCtorsLs = adhoc |> List.filter (fun v -> v.IsConstructor) |> List.map (fun vref -> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv vref.Deref) + let adhocInstanceLs = adhoc |> List.filter (fun v -> not v.IsConstructor && v.IsInstanceMember) |> List.map (fun vref -> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv vref.Deref) + let adhocStaticLs = adhoc |> List.filter (fun v -> not v.IsConstructor && not v.IsInstanceMember) |> List.map (fun vref -> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv vref.Deref) iimplsLs,adhocCtorsLs,adhocInstanceLs,adhocStaticLs let memberLs = memberImplementLs @ memberCtorLs @ memberInstanceLs @ memberStaticLs let addMembersAsWithEnd reprL = @@ -1732,7 +1741,7 @@ module private TastDefinitionPrinting = tycon.MembersOfFSharpTyconSorted |> List.filter (fun v -> isNil (Option.get v.MemberInfo).ImplementedSlotSigs) |> List.filter (fun v -> v.IsDispatchSlot) - |> List.map (fun vref -> PrintTastMemberOrVals.layoutValOrMember denv vref.Deref) + |> List.map (fun vref -> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv vref.Deref) let staticValsLs = tycon.TrueFieldsAsList |> List.filter (fun f -> f.IsStatic) @@ -1840,9 +1849,9 @@ module private InferredSigPrinting = | 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.layoutValOrMember denv) |> aboveListL) @@ + (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.layoutValOrMember 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 @@ -1935,20 +1944,20 @@ let dataExprL denv expr = PrintData.dataExprL denv expr //-------------------------------------------------------------------------- -let outputValOrMember denv os x = x |> PrintTastMemberOrVals.layoutValOrMember denv |> bufferL os -let stringValOrMember denv x = x |> PrintTastMemberOrVals.layoutValOrMember denv |> showL +let outputValOrMember denv os x = x |> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv |> bufferL os +let stringValOrMember denv x = x |> PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv |> showL /// Print members with a qualification showing the type they are contained in -let layoutQualifiedValOrMember denv v = PrintTastMemberOrVals.layoutValOrMember { denv with showMemberContainers=true; } v +let layoutQualifiedValOrMember denv typarInst v = PrintTastMemberOrVals.prettyLayoutOfValOrMember { denv with showMemberContainers=true; } typarInst v let outputQualifiedValOrMember denv os v = outputValOrMember { denv with showMemberContainers=true; } os v let outputQualifiedValSpec denv os v = outputQualifiedValOrMember denv os v -let stringOfQualifiedValOrMember denv v = PrintTastMemberOrVals.layoutValOrMember { denv with showMemberContainers=true; } v |> showL +let stringOfQualifiedValOrMember denv v = PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst { denv with showMemberContainers=true; } v |> showL /// Convert a MethInfo to a string let formatMethInfoToBufferFreeStyle amap m denv buf d = InfoMemberPrinting.formatMethInfoToBufferFreeStyle amap m denv buf d -let layoutMethInfoFreeStyle amap m denv d = InfoMemberPrinting.layoutMethInfoToFreeStyle amap m denv d +let prettyLayoutOfMethInfoFreeStyle amap m denv typarInst minfo = InfoMemberPrinting.prettyLayoutOfMethInfoFreeStyle amap m denv typarInst minfo /// Convert a PropInfo to a string -let layoutPropInfoToFreeStyle g amap m denv d = InfoMemberPrinting.layoutPropInfoToFreeStyle g amap m denv d +let prettyLayoutOfPropInfoFreeStyle g amap m denv d = InfoMemberPrinting.prettyLayoutOfPropInfoFreeStyle g amap m denv d /// Convert a MethInfo to a string let stringOfMethInfo amap m denv d = bufs (fun buf -> InfoMemberPrinting.formatMethInfoToBufferFreeStyle amap m denv buf d) @@ -1970,9 +1979,9 @@ let isGeneratedUnionCaseField pos f = TastDefinitionPrinting.isGeneratedUnio let isGeneratedExceptionField pos f = TastDefinitionPrinting.isGeneratedExceptionField pos f let stringOfTyparConstraint denv tpc = stringOfTyparConstraints denv [tpc] let stringOfTy denv x = x |> PrintTypes.layoutType denv |> showL -let prettyLayoutOfTy denv x = x |> PrintTypes.layoutPrettyType denv -let prettyStringOfTy denv x = x |> PrintTypes.layoutPrettyType denv |> showL -let prettyStringOfTyNoCx denv x = x |> PrintTypes.layoutPrettyTypeNoCx denv |> showL +let prettyLayoutOfType denv x = x |> PrintTypes.prettyLayoutOfType denv +let prettyStringOfTy denv x = x |> PrintTypes.prettyLayoutOfType denv |> showL +let prettyStringOfTyNoCx denv x = x |> PrintTypes.prettyLayoutOfTypeNoConstraints denv |> showL let stringOfRecdField denv x = x |> TastDefinitionPrinting.layoutRecdField false denv |> showL let stringOfUnionCase denv x = x |> TastDefinitionPrinting.layoutUnionCase denv (WordL.bar) |> showL let stringOfExnDef denv x = x |> TastDefinitionPrinting.layoutExnDefn denv |> showL @@ -1981,15 +1990,16 @@ let stringOfFSAttrib denv x = x |> PrintTypes.layoutAttrib denv |> squar let stringOfILAttrib denv x = x |> PrintTypes.layoutILAttrib denv |> squareAngleL |> showL let layoutInferredSigOfModuleExpr showHeader denv infoReader ad m expr = InferredSigPrinting.layoutInferredSigOfModuleExpr showHeader denv infoReader ad m expr -let layoutValOrMember denv v = PrintTastMemberOrVals.layoutValOrMember denv v -let layoutPrettifiedTypes denv taus = PrintTypes.layoutPrettifiedTypes denv taus +let prettyLayoutOfValOrMember denv typarInst v = PrintTastMemberOrVals.prettyLayoutOfValOrMember denv typarInst v +let prettyLayoutOfValOrMemberNoInst denv v = PrintTastMemberOrVals.prettyLayoutOfValOrMemberNoInst denv v +let prettyLayoutOfInstAndSig denv x = PrintTypes.prettyLayoutOfInstAndSig denv x /// Generate text for comparing two types. /// /// If the output text is different without showing constraints and/or imperative type variable /// annotations and/or fully qualifying paths then don't show them! let minimalStringsOfTwoTypes denv t1 t2= - let _renamings,(t1,t2),tpcs = PrettyTypes.PrettifyTypes2 denv.g (t1,t2) + let (t1,t2),tpcs = PrettyTypes.PrettifyTypePair denv.g (t1,t2) // try denv + no type annotations let attempt1 = let denv = { denv with showImperativeTyparAnnotations=false; showConstraintTyparAnnotations=false } @@ -2051,7 +2061,7 @@ let minimalStringsOfTwoValues denv v1 v2= max1,max2 let minimalStringOfType denv ty = - let _, ty, _cxs = PrettyTypes.PrettifyTypes1 denv.g ty + let ty, _cxs = PrettyTypes.PrettifyType denv.g ty let denvMin = { denv with showImperativeTyparAnnotations=false; showConstraintTyparAnnotations=false } showL (PrintTypes.layoutTypeWithInfoAndPrec denvMin SimplifyTypes.typeSimplificationInfo0 2 ty) @@ -2085,7 +2095,7 @@ let rec moduleOrNamespaceTypeLP (topLevel : bool) (denv: DisplayEnv) (mtype : Mo let declSpecs = List.sortWithOrder (Order.orderOn rangeOfDeclSpec rangeOrder) declSpecs let declSpecL = function // only show namespaces / modules at the top level; this is because we've no global namespace - | DVal vspec when not topLevel -> layoutValOrMember denv vspec + | DVal vspec when not topLevel -> prettyLayoutOfValOrMember denv vspec | DTycon tycon when not topLevel -> tyconL denv (wordL "type") tycon | DException tycon when not topLevel -> layoutExnDefn denv tycon | DModul mspec -> moduleOrNamespaceLP false denv mspec diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 14303ea7f4..cf1871bb9b 100755 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -197,10 +197,8 @@ type Summary<'Info> = // Note, this is a different notion of "size" to the one used for inlining heuristics //------------------------------------------------------------------------- -let rec SizeOfValueInfos (arr:_[]) = - let n = arr.Length - let rec go i acc = if i >= n then acc else max acc (SizeOfValueInfo arr.[i]) - go 0 0 +let rec SizeOfValueInfos (arr:_[]) = + if arr.Length <= 0 then 0 else max 0 (SizeOfValueInfo arr.[0]) and SizeOfValueInfo x = match x with @@ -208,9 +206,9 @@ and SizeOfValueInfo x = | ConstValue (_x,_) -> 1 | UnknownValue -> 1 | ValValue (_vr,vinfo) -> SizeOfValueInfo vinfo + 1 - | TupleValue vinfos + | TupleValue vinfos | RecdValue (_,vinfos) - | UnionCaseValue (_,vinfos)-> 1 + SizeOfValueInfos vinfos + | UnionCaseValue (_,vinfos) -> 1 + SizeOfValueInfos vinfos | CurriedLambdaValue(_lambdaId,_arities,_bsize,_expr',_ety) -> 1 | ConstExprValue (_size,_) -> 1 @@ -2922,7 +2920,7 @@ and OptimizeSwitchFallback cenv env (e', einfo, cases,dflt,m) = let info = { info with TotalSize = info.TotalSize + size; FunctionSize = info.FunctionSize + size; } TDSwitch (e',cases',dflt',m),info -and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = +and OptimizeBinding cenv isRec env (TBind(vref,expr,spBind)) = try // The aim here is to stop method splitting for direct-self-tailcalls. We do more than that: if an expression @@ -2930,15 +2928,16 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = // any expression that contains a reference to any value in RVS. // This doesn't prevent splitting for mutually recursive references. See FSharp 1.0 bug 2892. let env = - if isRec then { env with dontSplitVars = env.dontSplitVars.Add v () } + if isRec then { env with dontSplitVars = env.dontSplitVars.Add vref () } else env - let repr',einfo = - let env = if v.IsCompilerGenerated && Option.isSome env.latestBoundId then env else {env with latestBoundId=Some v.Id} - let cenv = if v.InlineInfo = ValInline.PseudoVal then { cenv with optimizing=false} else cenv - let e',einfo = OptimizeLambdas (Some v) cenv env (InferArityOfExprBinding cenv.g v e) e v.Type + let exprOptimized,einfo = + let env = if vref.IsCompilerGenerated && Option.isSome env.latestBoundId then env else {env with latestBoundId=Some vref.Id} + let cenv = if vref.InlineInfo = ValInline.PseudoVal then { cenv with optimizing=false} else cenv + let arityInfo = InferArityOfExprBinding cenv.g AllowTypeDirectedDetupling.No vref expr + let exprOptimized,einfo = OptimizeLambdas (Some vref) cenv env arityInfo expr vref.Type let size = localVarSize - e',{einfo with FunctionSize=einfo.FunctionSize+size; TotalSize = einfo.TotalSize+size} + exprOptimized,{einfo with FunctionSize=einfo.FunctionSize+size; TotalSize = einfo.TotalSize+size} // Trim out optimization information for large lambdas we'll never inline // Trim out optimization information for expressions that call protected members @@ -2962,18 +2961,18 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = | UnionCaseValue (a,b) -> UnionCaseValue (a,Array.map cut b) | UnknownValue | ConstValue _ | ConstExprValue _ -> ivalue | SizeValue(_,a) -> MakeSizedValueInfo (cut a) - let einfo = if v.MustInline then einfo else {einfo with Info = cut einfo.Info } + let einfo = if vref.MustInline then einfo else {einfo with Info = cut einfo.Info } let einfo = - if (not v.MustInline && not (cenv.settings.KeepOptimizationValues())) || + if (not vref.MustInline && not (cenv.settings.KeepOptimizationValues())) || // Bug 4916: do not record inline data for initialization trigger expressions // Note: we can't eliminate these value infos at the file boundaries because that would change initialization // order - IsCompiledAsStaticPropertyWithField cenv.g v || + IsCompiledAsStaticPropertyWithField cenv.g vref || - (v.InlineInfo = ValInline.Never) || + (vref.InlineInfo = ValInline.Never) || // MarshalByRef methods may not be inlined - (match v.ActualParent with + (match vref.ActualParent with | Parent tcref -> match cenv.g.system_MarshalByRefObject_tcref with | None -> false @@ -2982,7 +2981,7 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = if mbrTyconRef.TryDeref.IsSome then // Check if this is a subtype of MarshalByRefObject assert (cenv.g.system_MarshalByRefObject_typ.IsSome) - ExistsSameHeadTypeInHierarchy cenv.g cenv.amap v.Range (generalizedTyconRef tcref) cenv.g.system_MarshalByRefObject_typ.Value + ExistsSameHeadTypeInHierarchy cenv.g cenv.amap vref.Range (generalizedTyconRef tcref) cenv.g.system_MarshalByRefObject_typ.Value else false | ParentNone -> false) || @@ -2990,7 +2989,7 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = // These values are given a special going-over by the optimizer and // ilxgen.fs, hence treat them as if no-inline (when preparing the inline information for // FSharp.Core). - (let nvref = mkLocalValRef v + (let nvref = mkLocalValRef vref cenv.g.compilingFslib && (valRefEq cenv.g nvref cenv.g.seq_vref || valRefEq cenv.g nvref cenv.g.seq_generated_vref || @@ -3011,13 +3010,13 @@ and OptimizeBinding cenv isRec env (TBind(v,e,spBind)) = valRefEq cenv.g nvref cenv.g.generic_hash_inner_vref)) then {einfo with Info=UnknownValue} else einfo - if v.MustInline && IsPartialExprVal einfo.Info then - errorR(InternalError("the mustinline value '"+v.LogicalName+"' was not inferred to have a known value",v.Range)) + if vref.MustInline && IsPartialExprVal einfo.Info then + errorR(InternalError("the mustinline value '"+vref.LogicalName+"' was not inferred to have a known value",vref.Range)) - let env = BindInternalLocalVal cenv v (mkValInfo einfo v) env - (TBind(v,repr',spBind), einfo), env + let env = BindInternalLocalVal cenv vref (mkValInfo einfo vref) env + (TBind(vref,exprOptimized,spBind), einfo), env with exn -> - errorRecovery exn v.Range + errorRecovery exn vref.Range raise (ReportedError (Some exn)) and OptimizeBindings cenv isRec env xs = List.mapFold (OptimizeBinding cenv isRec) env xs diff --git a/src/fsharp/PatternMatchCompilation.fs b/src/fsharp/PatternMatchCompilation.fs index fc3024109e..8a4a51a5de 100755 --- a/src/fsharp/PatternMatchCompilation.fs +++ b/src/fsharp/PatternMatchCompilation.fs @@ -3,7 +3,6 @@ module internal Microsoft.FSharp.Compiler.PatternMatchCompilation open System.Collections.Generic -open Internal.Utilities open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.AbstractIL open Microsoft.FSharp.Compiler.AbstractIL.Internal @@ -14,7 +13,6 @@ open Microsoft.FSharp.Compiler.Ast open Microsoft.FSharp.Compiler.ErrorLogger open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.Tastops -open Microsoft.FSharp.Compiler.Infos open Microsoft.FSharp.Compiler.Tastops.DebugPrint open Microsoft.FSharp.Compiler.PrettyNaming open Microsoft.FSharp.Compiler.TypeRelations diff --git a/src/fsharp/PatternMatchCompilation.fsi b/src/fsharp/PatternMatchCompilation.fsi index b8f7fc3849..2186401f35 100755 --- a/src/fsharp/PatternMatchCompilation.fsi +++ b/src/fsharp/PatternMatchCompilation.fsi @@ -12,7 +12,6 @@ open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Range - /// What should the decision tree contain for any incomplete match? type ActionOnFailure = | ThrowIncompleteMatchException diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index 1760d1da1f..58e0aa2673 100755 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -5,14 +5,12 @@ module internal Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks open System.Collections.Generic -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.AccessibilityLogic open Microsoft.FSharp.Compiler.Ast @@ -22,7 +20,6 @@ open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.Tastops open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Lib -open Microsoft.FSharp.Compiler.Layout open Microsoft.FSharp.Compiler.Infos open Microsoft.FSharp.Compiler.PrettyNaming open Microsoft.FSharp.Compiler.InfoReader @@ -1456,14 +1453,14 @@ let CheckEntityDefn cenv env (tycon:Entity) = if others |> List.exists (checkForDup EraseAll) then if others |> List.exists (checkForDup EraseNone) then - errorR(Error(FSComp.SR.chkDuplicateMethod(nm),m)) + errorR(Error(FSComp.SR.chkDuplicateMethod(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) else - errorR(Error(FSComp.SR.chkDuplicateMethodWithSuffix(nm),m)) + errorR(Error(FSComp.SR.chkDuplicateMethodWithSuffix(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) let numCurriedArgSets = minfo.NumArgs.Length if numCurriedArgSets > 1 && others |> List.exists (fun minfo2 -> not (IsAbstractDefaultPair2 minfo minfo2)) then - errorR(Error(FSComp.SR.chkDuplicateMethodCurried nm,m)) + errorR(Error(FSComp.SR.chkDuplicateMethodCurried(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) if numCurriedArgSets > 1 && (minfo.GetParamDatas(cenv.amap, m, minfo.FormalMethodInst) @@ -1498,15 +1495,18 @@ let CheckEntityDefn cenv env (tycon:Entity) = for pinfo in immediateProps do let nm = pinfo.PropertyName - let m = (match pinfo.ArbitraryValRef with None -> m | Some vref -> vref.DefinitionRange) - if hashOfImmediateMeths.ContainsKey(nm) then - errorR(Error(FSComp.SR.chkPropertySameNameMethod(nm),m)) - let others = getHash hashOfImmediateProps nm + let m = + match pinfo.ArbitraryValRef with + | None -> m + | Some vref -> vref.DefinitionRange + + if hashOfImmediateMeths.ContainsKey nm then + errorR(Error(FSComp.SR.chkPropertySameNameMethod(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) - if pinfo.HasGetter && pinfo.HasSetter then + let others = getHash hashOfImmediateProps nm - if (pinfo.GetterMethod.IsVirtual <> pinfo.SetterMethod.IsVirtual) then - errorR(Error(FSComp.SR.chkGetterSetterDoNotMatchAbstract(nm),m)) + if pinfo.HasGetter && pinfo.HasSetter && pinfo.GetterMethod.IsVirtual <> pinfo.SetterMethod.IsVirtual then + errorR(Error(FSComp.SR.chkGetterSetterDoNotMatchAbstract(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) let checkForDup erasureFlag pinfo2 = // abstract/default pairs of duplicate properties are OK @@ -1518,9 +1518,9 @@ let CheckEntityDefn cenv env (tycon:Entity) = if others |> List.exists (checkForDup EraseAll) then if others |> List.exists (checkForDup EraseNone) then - errorR(Error(FSComp.SR.chkDuplicateProperty(nm) ,m)) + errorR(Error(FSComp.SR.chkDuplicateProperty(nm, NicePrint.minimalStringOfType cenv.denv typ) ,m)) else - errorR(Error(FSComp.SR.chkDuplicatePropertyWithSuffix(nm) ,m)) + errorR(Error(FSComp.SR.chkDuplicatePropertyWithSuffix(nm, NicePrint.minimalStringOfType cenv.denv typ) ,m)) // Check to see if one is an indexer and one is not if ( (pinfo.HasGetter && @@ -1532,7 +1532,7 @@ let CheckEntityDefn cenv env (tycon:Entity) = (let nargs = pinfo.GetParamTypes(cenv.amap,m).Length others |> List.exists (fun pinfo2 -> (isNil(pinfo2.GetParamTypes(cenv.amap,m))) <> (nargs = 0)))) then - errorR(Error(FSComp.SR.chkPropertySameNameIndexer(nm),m)) + errorR(Error(FSComp.SR.chkPropertySameNameIndexer(nm, NicePrint.minimalStringOfType cenv.denv typ),m)) // Check to see if the signatures of the both getter and the setter imply the same property type diff --git a/src/fsharp/PrettyNaming.fs b/src/fsharp/PrettyNaming.fs index 9546f847e5..6a0a08a7c1 100755 --- a/src/fsharp/PrettyNaming.fs +++ b/src/fsharp/PrettyNaming.fs @@ -5,8 +5,12 @@ //-------------------------------------------------------------------------- /// Anything to do with special names of identifiers and other lexical rules -module (*internal*) Microsoft.FSharp.Compiler.PrettyNaming - open Internal.Utilities +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.PrettyNaming +#else +module internal Microsoft.FSharp.Compiler.PrettyNaming +#endif +open Internal.Utilities open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.AbstractIL.Internal open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library diff --git a/src/fsharp/QuotationPickler.fs b/src/fsharp/QuotationPickler.fs index dfd981c2da..fa1cdff5ff 100755 --- a/src/fsharp/QuotationPickler.fs +++ b/src/fsharp/QuotationPickler.fs @@ -1,19 +1,11 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -//------------------------------------------------------------------------- -// Expression and Type Specifications. These are what we save -//------------------------------------------------------------------------- - - module internal Microsoft.FSharp.Compiler.QuotationPickler open System.Text -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 open Microsoft.FSharp.Compiler.Lib @@ -144,9 +136,9 @@ let mkLetRec (ves,body) = let mkRecdMk (n,tys,args) = CombExpr(RecdMkOp n,tys,args) let mkRecdGet ((d1,d2),tyargs,args) = CombExpr(RecdGetOp(d1,d2),tyargs,args) let mkRecdSet ((d1,d2),tyargs,args) = CombExpr(RecdSetOp(d1,d2),tyargs,args) -let mkSum ((d1,d2),tyargs,args) = CombExpr(SumMkOp(d1,d2),tyargs,args) -let mkSumFieldGet ((d1,d2,d3),tyargs,arg) = CombExpr(SumFieldGetOp(d1,d2,d3),tyargs,[arg]) -let mkSumTagTest ((d1,d2),tyargs,arg) = CombExpr(SumTagTestOp(d1,d2),tyargs,[arg]) +let mkUnion ((d1,d2),tyargs,args) = CombExpr(SumMkOp(d1,d2),tyargs,args) +let mkUnionFieldGet ((d1,d2,d3),tyargs,arg) = CombExpr(SumFieldGetOp(d1,d2,d3),tyargs,[arg]) +let mkUnionCaseTagTest ((d1,d2),tyargs,arg) = CombExpr(SumTagTestOp(d1,d2),tyargs,[arg]) let mkTupleGet (ty,n,e) = CombExpr(TupleGetOp n,[ty],[e]) let mkCoerce (ty,arg) = CombExpr(CoerceOp,[ty],[arg]) diff --git a/src/fsharp/QuotationPickler.fsi b/src/fsharp/QuotationPickler.fsi index f6a2957d7d..849d005b7c 100755 --- a/src/fsharp/QuotationPickler.fsi +++ b/src/fsharp/QuotationPickler.fsi @@ -69,9 +69,9 @@ val mkLet : (VarData * ExprData) * ExprData -> ExprData val mkRecdMk : NamedTypeData * TypeData list * ExprData list -> ExprData val mkRecdGet : RecdFieldData * TypeData list * ExprData list -> ExprData val mkRecdSet : RecdFieldData * TypeData list * ExprData list -> ExprData -val mkSum : (NamedTypeData * string) * TypeData list * ExprData list -> ExprData -val mkSumFieldGet : (NamedTypeData * string * int) * TypeData list * ExprData -> ExprData -val mkSumTagTest : (NamedTypeData * string) * TypeData list * ExprData -> ExprData +val mkUnion : (NamedTypeData * string) * TypeData list * ExprData list -> ExprData +val mkUnionFieldGet : (NamedTypeData * string * int) * TypeData list * ExprData -> ExprData +val mkUnionCaseTagTest : (NamedTypeData * string) * TypeData list * ExprData -> ExprData val mkTuple : TypeData * ExprData list -> ExprData val mkTupleGet : TypeData * int * ExprData -> ExprData val mkCoerce : TypeData * ExprData -> ExprData diff --git a/src/fsharp/QuotationTranslator.fs b/src/fsharp/QuotationTranslator.fs index 4a314ee9f3..63973d43c5 100755 --- a/src/fsharp/QuotationTranslator.fs +++ b/src/fsharp/QuotationTranslator.fs @@ -54,8 +54,8 @@ type QuotationGenerationScope = static member Create (g: TcGlobals, amap, scope, isReflectedDefinition) = { g = g - scope=scope - amap=amap + scope = scope + amap = amap referencedTypeDefs = new ResizeArray<_>() referencedTypeDefsTable = new Dictionary<_,_>() typeSplices = new ResizeArray<_>() @@ -90,8 +90,8 @@ type QuotationTranslationEnv = substVals: ValMap } static member Empty = - { vs=ValMap<_>.Empty - nvs=0 + { vs = ValMap<_>.Empty + nvs = 0 tyvs = Map.empty isinstVals = ValMap<_>.Empty substVals = ValMap<_>.Empty } @@ -103,15 +103,16 @@ type QuotationTranslationEnv = member env.BindTypars vs = (env, vs) ||> List.fold (fun env v -> env.BindTypar v) // fold left-to-right because indexes are left-to-right -let BindFormalTypars (env:QuotationTranslationEnv) vs = - { env with tyvs=Map.empty}.BindTypars vs +let BindFormalTypars (env:QuotationTranslationEnv) vs = + { env with tyvs = Map.empty }.BindTypars vs -let BindVal env v = - let idx = env.nvs - { env with vs = env.vs.Add v idx; nvs = env.nvs + 1 } +let BindVal env v = + { env with + vs = env.vs.Add v env.nvs + nvs = env.nvs + 1 } let BindIsInstVal env v (ty,e) = - { env with isinstVals = env.isinstVals.Add v (ty,e) } + { env with isinstVals = env.isinstVals.Add v (ty,e) } let BindSubstVal env v e = { env with substVals = env.substVals.Add v e } @@ -123,13 +124,13 @@ let BindFlatVals env vs = List.fold BindVal env vs // fold left-to-right because exception InvalidQuotedTerm of exn exception IgnoringPartOfQuotedTermWarning of string * Range.range -let wfail e = raise (InvalidQuotedTerm(e)) +let wfail e = raise (InvalidQuotedTerm e) let (|ModuleValueOrMemberUse|_|) g expr = let rec loop expr args = match stripExpr expr with - | Expr.App((InnerExprPat(Expr.Val(vref,vFlags,_) as f)),fty,tyargs,actualArgs,_m) when vref.IsMemberOrModuleBinding -> - Some(vref,vFlags,f,fty,tyargs,actualArgs@args) + | Expr.App((InnerExprPat(Expr.Val(vref,vFlags,_) as f)),fty,tyargs,actualArgs,_m) when vref.IsMemberOrModuleBinding -> + Some(vref,vFlags,f,fty,tyargs,actualArgs @ args) | Expr.App(f,_fty,[],actualArgs,_) -> loop f (actualArgs @ args) | (Expr.Val(vref,vFlags,_m) as f) when (match vref.ActualParent with ParentNone -> false | _ -> true) -> @@ -186,10 +187,12 @@ let rec EmitDebugInfoIfNecessary cenv env m astExpr : QP.ExprData = mkInt cenv.g m m.StartLine mkInt cenv.g m m.StartColumn mkInt cenv.g m m.EndLine - mkInt cenv.g m m.EndColumn; ] + mkInt cenv.g m m.EndColumn ] let attrExpr = mk_tuple cenv.g m - [ mkString cenv.g m "DebugRange"; rangeExpr ] + [ mkString cenv.g m "DebugRange" + rangeExpr ] + let attrExprR = ConvExprCore cenv env attrExpr QP.mkAttributedExpression(astExpr, attrExprR) @@ -221,9 +224,10 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let idx = cenv.exprSplices.Count let ty = tyOfExpr cenv.g expr - match (freeInExpr CollectTyparsAndLocalsNoCaching x0).FreeLocals |> Seq.tryPick (fun v -> if env.vs.ContainsVal v then Some(v) else None) with + match (freeInExpr CollectTyparsAndLocalsNoCaching x0).FreeLocals |> Seq.tryPick (fun v -> if env.vs.ContainsVal v then Some v else None) with | Some v -> errorR(Error(FSComp.SR.crefBoundVarUsedInSplice(v.DisplayName), v.Range)) | None -> () + cenv.exprSplices.Add((x0, m)) let hole = QP.mkHole(ConvType cenv env m ty,idx) (hole, rest) ||> List.fold (fun fR arg -> QP.mkApp (fR,ConvExpr cenv env arg)) @@ -235,8 +239,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let (numEnclTypeArgs,_,isNewObj,valUseFlags,isSelfInit,takesInstanceArg,isPropGet,isPropSet) = GetMemberCallInfo cenv.g (vref,vFlags) - let isMember,tps,curriedArgInfos,retTy = - + let isMember,tps,curriedArgInfos,retTy = match vref.MemberInfo with | Some _ when not vref.IsExtensionMember -> // This is an application of a member method @@ -264,8 +267,8 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. // If so, adjust and try again if curriedArgs.Length < curriedArgInfos.Length || ((List.take curriedArgInfos.Length curriedArgs,curriedArgInfos) ||> List.exists2 (fun arg argInfo -> - (argInfo.Length > (tryDestRefTupleExpr arg).Length))) then - + (argInfo.Length > (tryDestRefTupleExpr arg).Length))) + then if verboseCReflect then dprintfn "vref.DisplayName = %A was under applied" vref.DisplayName // Too few arguments or incorrect tupling? Convert to a lambda and beta-reduce the @@ -278,7 +281,6 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let expr,exprty = AdjustValForExpectedArity cenv.g m vref vFlags topValInfo ConvExpr cenv env (MakeApplicationAndBetaReduce cenv.g (expr,exprty,[tyargs],curriedArgs,m)) else - // Too many arguments? Chop let (curriedArgs:Expr list ),laterArgs = List.chop curriedArgInfos.Length curriedArgs @@ -303,40 +305,40 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let callArgs = (objArgs::untupledCurriedArgs) |> List.concat let parentTyconR = ConvTyconRef cenv vref.TopValActualParent m - let isNewObj = (isNewObj || valUseFlags || isSelfInit) + let isNewObj = isNewObj || valUseFlags || isSelfInit // The signature types are w.r.t. to the formal context let envinner = BindFormalTypars env tps - let argTys = curriedArgInfos |> List.concat |> List.map fst + let argTys = curriedArgInfos |> List.concat |> List.map fst let methArgTypesR = ConvTypes cenv envinner m argTys let methRetTypeR = ConvReturnType cenv envinner m retTy let methName = vref.CompiledName - let numGenericArgs = tyargs.Length-numEnclTypeArgs + let numGenericArgs = tyargs.Length - numEnclTypeArgs ConvObjectModelCall cenv env m (isPropGet,isPropSet,isNewObj,parentTyconR,methArgTypesR,methRetTypeR,methName,tyargs,numGenericArgs,callArgs) else // This is an application of the module value. ConvModuleValueApp cenv env m vref tyargs untupledCurriedArgs match curriedArgs,curriedArgInfos with // static member and module value unit argument elimination - | [arg:Expr],[[]] -> - // we got here if quotation is represents a call with unit argument - // let f () = () - // <@ f @> // => (\arg -> f arg) => arg is Expr.Val - no-effects, first case - // <@ f() @> // Expr.Const(Unit) - no-effects - first case - // <@ f (someFunctionThatReturnsUnit) @> - potential effects - second case - match arg with - | Expr.Val _ - | Expr.Const(Const.Unit,_,_) -> subCall - | _ -> - let argQ = ConvExpr cenv env arg - QP.mkSequential(argQ, subCall) - | _ -> subCall + | [arg:Expr],[[]] -> + // we got here if quotation is represents a call with unit argument + // let f () = () + // <@ f @> // => (\arg -> f arg) => arg is Expr.Val - no-effects, first case + // <@ f() @> // Expr.Const(Unit) - no-effects - first case + // <@ f (someFunctionThatReturnsUnit) @> - potential effects - second case + match arg with + | Expr.Val _ + | Expr.Const(Const.Unit,_,_) -> subCall + | _ -> + let argQ = ConvExpr cenv env arg + QP.mkSequential(argQ, subCall) + | _ -> subCall List.fold (fun fR arg -> QP.mkApp (fR,ConvExpr cenv env arg)) callR laterArgs // Blast type application nodes and expression application nodes apart so values are left with just their type arguments | Expr.App(f,fty,(_ :: _ as tyargs),(_ :: _ as args),m) -> - let rfty = applyForallTy cenv.g fty tyargs + let rfty = applyForallTy cenv.g fty tyargs ConvExpr cenv env (primMkApp (primMkApp (f,fty) tyargs [] m, rfty) [] args m) // Uses of possibly-polymorphic values @@ -352,12 +354,10 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | Expr.Const(c,m,ty) -> ConvConst cenv env m c ty - | Expr.Val(vref,_vFlags,m) -> - + | Expr.Val(vref,_vFlags,m) -> ConvValRef true cenv env m vref [] - | Expr.Let(bind,body,_,_) -> - + | Expr.Let(bind,body,_,_) -> // The binding may be a compiler-generated binding that gets removed in the quotation presentation match ConvLetBind cenv env bind with | None, env -> ConvExpr cenv env body @@ -368,18 +368,18 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let vsR = vs |> List.map (ConvVal cenv env) let env = BindFlatVals env vs let bodyR = ConvExpr cenv env body - let bindsR = List.zip vsR (binds |> List.map (fun b -> b.Expr |> ConvExpr cenv env)) + let bindsR = List.zip vsR (binds |> List.map (fun b -> ConvExpr cenv env b.Expr)) QP.mkLetRec(bindsR,bodyR) | Expr.Lambda(_,_,_,vs,b,_,_) -> let v,b = MultiLambdaToTupledLambda cenv.g vs b let vR = ConvVal cenv env v - let bR = ConvExpr cenv (BindVal env v) b + let bR = ConvExpr cenv (BindVal env v) b QP.mkLambda(vR, bR) | Expr.Quote(ast,_,_,_,ety) -> // F# 2.0-3.1 had a bug with nested 'raw' quotations. F# 4.0 + FSharp.Core 4.4.0.0+ allows us to do the right thing. - if cenv.quotationFormat = QuotationSerializationFormat.FSharp_40_Plus && + if cenv.quotationFormat = QuotationSerializationFormat.FSharp_40_Plus && // Look for a 'raw' quotation tyconRefEq cenv.g (tcrefOfAppTy cenv.g ety) cenv.g.raw_expr_tcr then @@ -414,21 +414,22 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let mkR = ConvUnionCaseRef cenv ucref m let tyargsR = ConvTypes cenv env m tyargs let argsR = ConvExprs cenv env args - QP.mkSum(mkR,tyargsR,argsR) + QP.mkUnion(mkR,tyargsR,argsR) + + | TOp.Tuple tupInfo,tyargs,_ -> let tyR = ConvType cenv env m (mkAnyTupledTy cenv.g tupInfo tyargs) let argsR = ConvExprs cenv env args QP.mkTuple(tyR,argsR) // TODO: propagate to quotations + | TOp.Recd (_,tcref),_,_ -> let rgtypR = ConvTyconRef cenv tcref m let tyargsR = ConvTypes cenv env m tyargs let argsR = ConvExprs cenv env args QP.mkRecdMk(rgtypR,tyargsR,argsR) + | TOp.UnionCaseFieldGet (ucref,n),tyargs,[e] -> - let tyargsR = ConvTypes cenv env m tyargs - let tcR,s = ConvUnionCaseRef cenv ucref m - let projR = (tcR,s,n) - QP.mkSumFieldGet( projR, tyargsR,ConvExpr cenv env e) + ConvUnionFieldGet cenv env m ucref n tyargs e | TOp.ValFieldGetAddr(_rfref),_tyargs,_ -> wfail(Error(FSComp.SR.crefQuotationsCantContainAddressOf(), m)) @@ -440,11 +441,12 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. wfail(Error(FSComp.SR.crefQuotationsCantContainStaticFieldRef(),m)) | TOp.ValFieldGet(rfref),tyargs,args -> - ConvRFieldGet cenv env m rfref tyargs args + ConvClassOrRecdFieldGet cenv env m rfref tyargs args - | TOp.TupleFieldGet(tupInfo,n),tyargs,[e] when not (evalTupInfoIsStruct tupInfo) -> - let tyR = ConvType cenv env m (mkRefTupledTy cenv.g tyargs) - QP.mkTupleGet(tyR, n, ConvExpr cenv env e) + | TOp.TupleFieldGet(tupInfo,n),tyargs,[e] -> + let eR = ConvLValueExpr cenv env e + let tyR = ConvType cenv env m (mkAnyTupledTy cenv.g tupInfo tyargs) + QP.mkTupleGet(tyR, n, eR) | TOp.ILAsm(([ I_ldfld(_,_,fspec) ] | [ I_ldfld(_,_,fspec); AI_nop ] @@ -560,7 +562,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | TOp.ILCall(_,_,_,isNewObj,valUseFlags,isProp,_,ilMethRef,enclTypeArgs,methTypeArgs,_tys),[],callArgs -> let parentTyconR = ConvILTypeRefUnadjusted cenv m ilMethRef.EnclosingTypeRef - let isNewObj = (isNewObj || (match valUseFlags with CtorValUsedAsSuperInit | CtorValUsedAsSelfInit -> true | _ -> false)) + let isNewObj = isNewObj || (match valUseFlags with CtorValUsedAsSuperInit | CtorValUsedAsSelfInit -> true | _ -> false) let methArgTypesR = List.map (ConvILType cenv env m) ilMethRef.ArgTypes let methRetTypeR = ConvILType cenv env m ilMethRef.ReturnType let methName = ilMethRef.Name @@ -568,6 +570,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. let isPropSet = isProp && methName.StartsWith("set_",System.StringComparison.Ordinal) let tyargs = (enclTypeArgs@methTypeArgs) ConvObjectModelCall cenv env m (isPropGet,isPropSet,isNewObj,parentTyconR,methArgTypesR,methRetTypeR,methName,tyargs,methTypeArgs.Length,callArgs) + | TOp.TryFinally _,[_resty],[Expr.Lambda(_,_,_,[_],e1,_,_); Expr.Lambda(_,_,_,[_],e2,_,_)] -> QP.mkTryFinally(ConvExpr cenv env e1,ConvExpr cenv env e2) @@ -580,6 +583,7 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | TOp.Bytes bytes,[],[] -> ConvExpr cenv env (Expr.Op(TOp.Array, [cenv.g.byte_ty], List.ofArray (Array.map (mkByte cenv.g m) bytes), m)) + | TOp.UInt16s arr,[],[] -> ConvExpr cenv env (Expr.Op(TOp.Array, [cenv.g.uint16_ty], List.ofArray (Array.map (mkUInt16 cenv.g m) arr), m)) @@ -595,16 +599,23 @@ and private ConvExprCore cenv (env : QuotationTranslationEnv) (expr: Expr) : QP. | _ -> wfail(InternalError(sprintf "unhandled construct in AST: %A" expr,expr.Range)) -and ConvLdfld cenv env m (fspec: ILFieldSpec) enclTypeArgs args = +and ConvLdfld cenv env m (fspec: ILFieldSpec) enclTypeArgs args = let tyargsR = ConvTypes cenv env m enclTypeArgs let parentTyconR = ConvILTypeRefUnadjusted cenv m fspec.EnclosingTypeRef let argsR = ConvLValueArgs cenv env args QP.mkFieldGet( (parentTyconR, fspec.Name),tyargsR, argsR) -and ConvRFieldGet cenv env m rfref tyargs args = - EmitDebugInfoIfNecessary cenv env m (ConvRFieldGetCore cenv env m rfref tyargs args) +and ConvUnionFieldGet cenv env m ucref n tyargs e = + let tyargsR = ConvTypes cenv env m tyargs + let tcR,s = ConvUnionCaseRef cenv ucref m + let projR = (tcR,s,n) + let eR = ConvLValueExpr cenv env e + QP.mkUnionFieldGet(projR, tyargsR, eR) + +and ConvClassOrRecdFieldGet cenv env m rfref tyargs args = + EmitDebugInfoIfNecessary cenv env m (ConvClassOrRecdFieldGetCore cenv env m rfref tyargs args) -and private ConvRFieldGetCore cenv env m rfref tyargs args = +and private ConvClassOrRecdFieldGetCore cenv env m rfref tyargs args = let tyargsR = ConvTypes cenv env m tyargs let argsR = ConvLValueArgs cenv env args let ((parentTyconR,fldOrPropName) as projR) = ConvRecdFieldRef cenv rfref m @@ -619,6 +630,7 @@ and private ConvRFieldGetCore cenv env m rfref tyargs args = let envinner = BindFormalTypars env tcref.TyparsNoRange let propRetTypeR = ConvType cenv envinner m fspec.FormalType QP.mkPropGet( (parentTyconR, fldOrPropName,propRetTypeR,[]),tyargsR, argsR) + and ConvLetBind cenv env (bind : Binding) = match bind.Expr with // Map for values bound by the @@ -637,6 +649,7 @@ and ConvLetBind cenv env (bind : Binding) = // Remove let unionCase = ... from quotation tree | Expr.Op(TOp.UnionCaseProof _,_,[e],_) -> None, BindSubstVal env bind.Var e + | _ -> let v = bind.Var let vR = ConvVal cenv env v @@ -651,13 +664,15 @@ and ConvLValueArgs cenv env args = and ConvLValueExpr cenv env expr = EmitDebugInfoIfNecessary cenv env expr.Range (ConvLValueExprCore cenv env expr) + // This function has to undo the work of mkExprAddrOfExpr and ConvLValueExprCore cenv env expr = match expr with | Expr.Op(op,tyargs,args,m) -> match op, args, tyargs with | TOp.LValueOp(LGetAddr,vref),_,_ -> ConvValRef false cenv env m vref [] - | TOp.ValFieldGetAddr(rfref),_,_ -> ConvRFieldGet cenv env m rfref tyargs args + | TOp.ValFieldGetAddr(rfref),_,_ -> ConvClassOrRecdFieldGet cenv env m rfref tyargs args + | TOp.UnionCaseFieldGetAddr(ucref,n),[e],_ -> ConvUnionFieldGet cenv env m ucref n tyargs e | TOp.ILAsm([ I_ldflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args | TOp.ILAsm([ I_ldsflda(fspec) ],_rtys),_,_ -> ConvLdfld cenv env m fspec tyargs args | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] -> @@ -674,7 +689,6 @@ and ConvObjectModelCall cenv env m callInfo = EmitDebugInfoIfNecessary cenv env m (ConvObjectModelCallCore cenv env m callInfo) and ConvObjectModelCallCore cenv env m (isPropGet,isPropSet,isNewObj,parentTyconR,methArgTypesR,methRetTypeR,methName,tyargs,numGenericArgs,callArgs) = - let tyargsR = ConvTypes cenv env m tyargs let callArgsR = ConvLValueArgs cenv env callArgs @@ -698,11 +712,12 @@ and ConvObjectModelCallCore cenv env m (isPropGet,isPropSet,isNewObj,parentTycon methArgTypes = methArgTypesR methRetType = methRetTypeR methName = methName - numGenericArgs=numGenericArgs } + numGenericArgs = numGenericArgs } QP.mkMethodCall(methR, tyargsR, callArgsR) and ConvModuleValueApp cenv env m (vref:ValRef) tyargs (args: Expr list list) = EmitDebugInfoIfNecessary cenv env m (ConvModuleValueAppCore cenv env m vref tyargs args) + and ConvModuleValueAppCore cenv env m (vref:ValRef) tyargs (args: Expr list list) = match vref.ActualParent with | ParentNone -> failwith "ConvModuleValueApp" @@ -838,26 +853,32 @@ and ConvDecisionTree cenv env tgs typR x = match dfltOpt with | Some d -> ConvDecisionTree cenv env tgs typR d | None -> wfail(Error(FSComp.SR.crefQuotationsCantContainThisPatternMatch(), m)) + let converted = (csl,acc) ||> List.foldBack (fun (TCase(discrim,dtree)) acc -> + match discrim with | DecisionTreeTest.UnionCase (ucref, tyargs) -> - let e1R = ConvExpr cenv env e1 + let e1R = ConvLValueExpr cenv env e1 let ucR = ConvUnionCaseRef cenv ucref m let tyargsR = ConvTypes cenv env m tyargs - QP.mkCond (QP.mkSumTagTest (ucR, tyargsR, e1R), ConvDecisionTree cenv env tgs typR dtree, acc) + QP.mkCond (QP.mkUnionCaseTagTest (ucR, tyargsR, e1R), ConvDecisionTree cenv env tgs typR dtree, acc) + | DecisionTreeTest.Const (Const.Bool true) -> let e1R = ConvExpr cenv env e1 QP.mkCond (e1R, ConvDecisionTree cenv env tgs typR dtree, acc) + | DecisionTreeTest.Const (Const.Bool false) -> let e1R = ConvExpr cenv env e1 // Note, reverse the branches QP.mkCond (e1R, acc, ConvDecisionTree cenv env tgs typR dtree) + | DecisionTreeTest.Const c -> let ty = tyOfExpr cenv.g e1 let eq = mkCallEqualsOperator cenv.g m ty e1 (Expr.Const (c, m, ty)) let eqR = ConvExpr cenv env eq QP.mkCond (eqR, ConvDecisionTree cenv env tgs typR dtree, acc) + | DecisionTreeTest.IsNull -> // Decompile cached isinst tests match e1 with @@ -872,13 +893,17 @@ and ConvDecisionTree cenv env tgs typR x = let eq = mkCallEqualsOperator cenv.g m ty e1 (Expr.Const (Const.Zero, m, ty)) let eqR = ConvExpr cenv env eq QP.mkCond (eqR, ConvDecisionTree cenv env tgs typR dtree, acc) + | DecisionTreeTest.IsInst (_srcty, tgty) -> let e1R = ConvExpr cenv env e1 QP.mkCond (QP.mkTypeTest (ConvType cenv env m tgty, e1R), ConvDecisionTree cenv env tgs typR dtree, acc) + | DecisionTreeTest.ActivePatternCase _ -> wfail(InternalError( "DecisionTreeTest.ActivePatternCase test in quoted expression",m)) + | DecisionTreeTest.ArrayLength _ -> wfail(Error(FSComp.SR.crefQuotationsCantContainArrayPatternMatching(), m)) ) EmitDebugInfoIfNecessary cenv env m converted + | TDSuccess (args,n) -> let (TTarget(vars,rhs,_)) = tgs.[n] // TAST stores pattern bindings in reverse order for some reason diff --git a/src/fsharp/ReferenceResolver.fs b/src/fsharp/ReferenceResolver.fs index 049f24a744..ac64390c94 100644 --- a/src/fsharp/ReferenceResolver.fs +++ b/src/fsharp/ReferenceResolver.fs @@ -2,17 +2,20 @@ namespace Microsoft.FSharp.Compiler +#if COMPILER_PUBLIC_API +module public ReferenceResolver = +#else module internal ReferenceResolver = +#endif - exception ResolutionFailure + exception internal ResolutionFailure + [] type ResolutionEnvironment = - /// Indicates a script or source being compiled - | CompileTimeLike - /// Indicates a script or source being interpreted - | RuntimeLike - /// Indicates a script or source being edited - | DesignTimeLike + /// Indicates a script or source being edited or compiled. Uses reference assemblies (not implementation assemblies). + | EditingOrCompilation of isEditing: bool + /// Indicates a script or source being dynamically compiled and executed. Uses implementation assemblies. + | CompilationAndEvaluation type ResolvedFile = { /// Item specification. diff --git a/src/fsharp/SignatureConformance.fs b/src/fsharp/SignatureConformance.fs index a70d56f1b4..d999b5f490 100644 --- a/src/fsharp/SignatureConformance.fs +++ b/src/fsharp/SignatureConformance.fs @@ -4,29 +4,18 @@ /// constraint solving and method overload resolution. module internal Microsoft.FSharp.Compiler.SignatureConformance -open Internal.Utilities open System.Text 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.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.AbstractIL.IL open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.Infos -open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.NameResolution -open Microsoft.FSharp.Compiler.TypeRelations #if EXTENSIONTYPING open Microsoft.FSharp.Compiler.ExtensionTyping diff --git a/src/fsharp/SimulatedMSBuildReferenceResolver.fs b/src/fsharp/SimulatedMSBuildReferenceResolver.fs index 3fbcf906f4..ac69e1028b 100644 --- a/src/fsharp/SimulatedMSBuildReferenceResolver.fs +++ b/src/fsharp/SimulatedMSBuildReferenceResolver.fs @@ -16,9 +16,19 @@ open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library let internal SimulatedMSBuildResolver = { new Resolver with - member __.HighestInstalledNetFrameworkVersion() = "v4.5" + member x.HighestInstalledNetFrameworkVersion() = + let root = x.DotNetFrameworkReferenceAssembliesRootDirectory + if Directory.Exists(Path.Combine(root,"v4.7")) then "v4.7" + elif Directory.Exists(Path.Combine(root,"v4.6.2")) then "v4.6.2" + elif Directory.Exists(Path.Combine(root,"v4.6.1")) then "v4.6.1" + elif Directory.Exists(Path.Combine(root,"v4.6")) then "v4.6" + elif Directory.Exists(Path.Combine(root,"v4.5.1")) then "v4.5.1" + elif Directory.Exists(Path.Combine(root,"v4.5")) then "v4.5" + elif Directory.Exists(Path.Combine(root,"v4.0")) then "v4.0" + else "v4.5" + member __.DotNetFrameworkReferenceAssembliesRootDirectory = -#if RESHAPED_MSBUILD +#if FX_RESHAPED_MSBUILD "" #else if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then @@ -34,7 +44,7 @@ let internal SimulatedMSBuildResolver = member __.Resolve(resolutionEnvironment, references, targetFrameworkVersion, targetFrameworkDirectories, targetProcessorArchitecture, fsharpCoreDir, explicitIncludeDirs, implicitIncludeDir, logMessage, logWarningOrError) = -#if !RESHAPED_MSBUILD +#if !FX_RESHAPED_MSBUILD let registrySearchPaths() = [ let registryKey = @"Software\Microsoft\.NetFramework"; use key = Registry.LocalMachine.OpenSubKey(registryKey) @@ -69,7 +79,7 @@ let internal SimulatedMSBuildResolver = yield! explicitIncludeDirs yield fsharpCoreDir yield implicitIncludeDir -#if !RESHAPED_MSBUILD +#if !FX_RESHAPED_MSBUILD if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then yield! registrySearchPaths() #endif @@ -90,7 +100,7 @@ let internal SimulatedMSBuildResolver = success r with e -> logWarningOrError false "SR001" (e.ToString()) -#if !RESHAPED_MSBUILD +#if !FX_RESHAPED_MSBUILD // For this one we need to get the version search exactly right, without doing a load try if not found && r.StartsWith("FSharp.Core, Version=") && Environment.OSVersion.Platform = PlatformID.Win32NT then @@ -121,7 +131,7 @@ let internal SimulatedMSBuildResolver = success trialPath with e -> logWarningOrError false "SR001" (e.ToString()) -#if !RESHAPED_MSBUILD +#if !FX_RESHAPED_MSBUILD try // Seach the GAC on Windows if not found && not isFileName && Environment.OSVersion.Platform = PlatformID.Win32NT then @@ -165,10 +175,8 @@ let internal SimulatedMSBuildResolver = results.ToArray() } -let internal GetBestAvailableResolver(msbuildEnabled: bool) = -#if RESHAPED_MSBUILD - ignore msbuildEnabled -#else +let internal GetBestAvailableResolver() = +#if !FX_RESHAPED_MSBUILD let tryMSBuild v = // 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 @@ -177,7 +185,7 @@ let internal GetBestAvailableResolver(msbuildEnabled: bool) = 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 - match (if msbuildEnabled then tryMSBuild "12" else None) with + match tryMSBuild "12" with | Some r -> r | None -> #endif @@ -200,7 +208,7 @@ let fscoreDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() let resolve s = - SimulatedMSBuildResolver.Resolve(ResolutionEnvironment.CompileTimeLike,[| 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 91c53bc05c..41f37d0096 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -33,6 +33,7 @@ open Microsoft.FSharp.Compiler.ExtensionTyping [] type TyparMap<'T> = | TPMap of StampMap<'T> + member tm.Item with get (v: Typar) = let (TPMap m) = tm @@ -373,6 +374,7 @@ let instTyparConstraints tpinst x = if isNil tpinst then x else remapTyparConstr let instSlotSig tpinst ss = remapSlotSig (fun _ -> []) (mkInstRemap tpinst) ss let copySlotSig ss = remapSlotSig (fun _ -> []) Remap.Empty ss + let mkTyparToTyparRenaming tpsOrig tps = let tinst = generalizeTypars tps mkTyparInst tpsOrig tinst,tinst @@ -715,6 +717,8 @@ let isUnionTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> t let isReprHiddenTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> tcr.IsHiddenReprTycon | _ -> false) let isFSharpObjModelTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> tcr.IsFSharpObjectModelTycon | _ -> false) let isRecdTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> tcr.IsRecordTycon | _ -> false) +let isFSharpStructOrEnumTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> tcr.IsFSharpStructOrEnumTycon | _ -> false) +let isFSharpEnumTy g ty = ty |> stripTyEqns g |> (function TType_app(tcr,_) -> tcr.IsFSharpEnumTycon | _ -> false) let isTyparTy g ty = ty |> stripTyEqns g |> (function TType_var _ -> true | _ -> false) let isAnyParTy g ty = ty |> stripTyEqns g |> (function TType_var _ -> true | TType_measure unt -> isUnitParMeasure g unt | _ -> false) let isMeasureTy g ty = ty |> stripTyEqns g |> (function TType_measure _ -> true | _ -> false) @@ -735,7 +739,6 @@ let tryAnyParTy g ty = ty |> stripTyEqns g |> (function TType_var v -> Some v let (|AppTy|_|) g ty = ty |> stripTyEqns g |> (function TType_app(tcref,tinst) -> Some (tcref,tinst) | _ -> None) let (|RefTupleTy|_|) g ty = ty |> stripTyEqns g |> (function TType_tuple(tupInfo,tys) when not (evalTupInfoIsStruct tupInfo) -> Some tys | _ -> None) let (|FunTy|_|) g ty = ty |> stripTyEqns g |> (function TType_fun(dty, rty) -> Some (dty, rty) | _ -> None) -let tyconOfAppTy g ty = (tcrefOfAppTy g ty).Deref let tryNiceEntityRefOfTy ty = let ty = stripTyparEqnsAux false ty @@ -1070,13 +1073,13 @@ let mkCond spBind spTarget m ty e1 e2 e3 = primMkCond spBind spTarget spTarget let exprForValRef m vref = Expr.Val(vref,NormalValUse,m) let exprForVal m v = exprForValRef m (mkLocalValRef v) -let gen_mk_local m s ty mut compgen = +let mkLocalAux m s ty mut compgen = let thisv = NewVal(s,m,None,ty,mut,compgen,None,taccessPublic,ValNotInRecScope,None,NormalVal,[],ValInline.Optional,XmlDoc.Empty,false,false,false,false,false,false,None,ParentNone) thisv,exprForVal m thisv -let mkLocal m s ty = gen_mk_local m s ty Immutable false -let mkCompGenLocal m s ty = gen_mk_local m s ty Immutable true -let mkMutableCompGenLocal m s ty = gen_mk_local m s ty Mutable true +let mkLocal m s ty = mkLocalAux m s ty Immutable false +let mkCompGenLocal m s ty = mkLocalAux m s ty Immutable true +let mkMutableCompGenLocal m s ty = mkLocalAux m s ty Mutable true // Type gives return type. For type-lambdas this is the formal return type. @@ -1624,10 +1627,17 @@ let isStructOrEnumTyconTy g ty = | Some tcref -> tcref.Deref.IsStructOrEnumTycon | _ -> false -let isStructRecordOrUnionTyconTy g ty = isAppTy g ty && (tyconOfAppTy g ty).IsStructRecordOrUnionTycon - -let isStructTy g ty = isStructOrEnumTyconTy g ty || isStructTupleTy g ty +let isStructRecordOrUnionTyconTy g ty = + match tryDestAppTy g ty with + | Some tcref -> tcref.Deref.IsStructRecordOrUnionTycon + | _ -> false +let isStructTy g ty = + match tryDestAppTy g ty with + | Some tcref -> + let tycon = tcref.Deref + tycon.IsStructRecordOrUnionTycon || tycon.IsStructOrEnumTycon + | _ -> false let isRefTy g ty = not (isStructOrEnumTyconTy g ty) && @@ -2300,8 +2310,8 @@ module PrettyTypes = choose tps (0,0) [] - let PrettifyTypes g foldTys mapTys tys = - let ftps = foldTys (accFreeInTypeLeftToRight g true false) emptyFreeTyparsLeftToRight tys + let PrettifyThings g foldTys mapTys things = + let ftps = foldTys (accFreeInTypeLeftToRight g true false) emptyFreeTyparsLeftToRight things let ftps = List.rev ftps let rec computeKeep (keep: Typars) change (tps: Typars) = match tps with @@ -2325,23 +2335,78 @@ module PrettyTypes = match t with | TType_forall (_,tau) -> tau | _ -> t - let tys = mapTys getTauStayTau tys + let tauThings = mapTys getTauStayTau things - let prettyTypars = mapTys (instType renaming) tys + let prettyThings = mapTys (instType renaming) tauThings // niceTypars |> List.iter (fun tp -> dprintf "nice typar: %d\n" (stamp_of_typar tp)); * let tpconstraints = niceTypars |> List.collect (fun tpnice -> List.map (fun tpc -> tpnice,tpc) tpnice.Constraints) - renaming, - prettyTypars, - tpconstraints - - let PrettifyTypes1 g x = PrettifyTypes g (fun f -> f) (fun f -> f) x - let PrettifyTypes2 g x = PrettifyTypes g (fun f -> foldPair (f,f)) (fun f -> mapPair (f,f)) x - let PrettifyTypesN g x = PrettifyTypes g List.fold List.map x - let PrettifyTypesNN g x = PrettifyTypes g (fun f -> List.fold (List.fold f)) List.mapSquared x - let PrettifyTypesNN1 g x = PrettifyTypes g (fun f -> foldPair (List.fold (List.fold f),f)) (fun f -> mapPair (List.mapSquared f,f)) x - let PrettifyTypesN1 g (x:UncurriedArgInfos * TType) = PrettifyTypes g (fun f -> foldPair (List.fold (fold1Of2 f), f)) (fun f -> mapPair (List.map (map1Of2 f),f)) x - let PrettifyTypesNM1 g (x:TType list * CurriedArgInfos * TType) = PrettifyTypes g (fun f -> foldTriple (List.fold f, List.fold (List.fold (fold1Of2 f)),f)) (fun f -> mapTriple (List.map f, List.mapSquared (map1Of2 f), f)) x + prettyThings, tpconstraints + + let PrettifyType g x = PrettifyThings g id id x + let PrettifyTypePair g x = PrettifyThings g (fun f -> foldPair (f,f)) (fun f -> mapPair (f,f)) x + let PrettifyTypes g x = PrettifyThings g List.fold List.map x + let PrettifyCurriedTypes g x = PrettifyThings g (fun f -> List.fold (List.fold f)) List.mapSquared x + let PrettifyCurriedSigTypes g x = PrettifyThings g (fun f -> foldPair (List.fold (List.fold f),f)) (fun f -> mapPair (List.mapSquared f,f)) x + + // Badly formed code may instantiate rigid declared typars to types. + // Hence we double check here that the thing is really a type variable + let safeDestAnyParTy orig g ty = match tryAnyParTy g ty with None -> orig | Some x -> x + let tee f x = f x x + + let foldUnurriedArgInfos f z (x: UncurriedArgInfos) = List.fold (fold1Of2 f) z x + let mapUnurriedArgInfos f (x: UncurriedArgInfos) = List.map (map1Of2 f) x + + let foldTypar f z (x: Typar) = foldOn mkTyparTy f z x + let mapTypar g f (x: Typar) : Typar = (mkTyparTy >> f >> safeDestAnyParTy x g) x + + let foldTypars f z (x: Typars) = List.fold (foldTypar f) z x + let mapTypars g f (x: Typars) : Typars = List.map (mapTypar g f) x + + let foldTyparInst f z (x: TyparInst) = List.fold (foldPair (foldTypar f, f)) z x + let mapTyparInst g f (x: TyparInst) : TyparInst = List.map (mapPair (mapTypar g f, f)) x + + let PrettifyInstAndTyparsAndType g x = + PrettifyThings g + (fun f -> foldTriple (foldTyparInst f, foldTypars f, f)) + (fun f-> mapTriple (mapTyparInst g f, mapTypars g f, f)) + x + + let PrettifyInstAndUncurriedSig g (x: TyparInst * UncurriedArgInfos * TType) = + PrettifyThings g + (fun f -> foldTriple (foldTyparInst f, foldUnurriedArgInfos f, f)) + (fun f -> mapTriple (mapTyparInst g f, List.map (map1Of2 f),f)) + x + + let PrettifyInstAndCurriedSig g (x: TyparInst * TTypes * CurriedArgInfos * TType) = + PrettifyThings g + (fun f -> foldQuadruple (foldTyparInst f, List.fold f, List.fold (List.fold (fold1Of2 f)),f)) + (fun f -> mapQuadruple (mapTyparInst g f, List.map f, List.mapSquared (map1Of2 f), f)) + x + + let PrettifyInstAndSig g x = + PrettifyThings g + (fun f -> foldTriple (foldTyparInst f, List.fold f, f)) + (fun f -> mapTriple (mapTyparInst g f, List.map f, f) ) + x + + let PrettifyInstAndTypes g x = + PrettifyThings g + (fun f -> foldPair (foldTyparInst f, List.fold f)) + (fun f -> mapPair (mapTyparInst g f, List.map f)) + x + + let PrettifyInstAndType g x = + PrettifyThings g + (fun f -> foldPair (foldTyparInst f, f)) + (fun f -> mapPair (mapTyparInst g f, f)) + x + + let PrettifyInst g x = + PrettifyThings g + (fun f -> foldTyparInst f) + (fun f -> mapTyparInst g f) + x module SimplifyTypes = @@ -2655,18 +2720,17 @@ let isILAttrib (tref:ILTypeRef) (attr: ILAttribute) = // These linear iterations cost us a fair bit when there are lots of attributes // on imported types. However this is fairly rare and can also be solved by caching the // results of attribute lookups in the TAST -let HasILAttribute tref (attrs: ILAttributes) = List.exists (isILAttrib tref) attrs.AsList +let HasILAttribute tref (attrs: ILAttributes) = Array.exists (isILAttrib tref) attrs.AsArray -let HasILAttributeByName tname (attrs: ILAttributes) = List.exists (isILAttribByName ([],tname)) attrs.AsList +let HasILAttributeByName tname (attrs: ILAttributes) = Array.exists (isILAttribByName ([],tname)) attrs.AsArray let TryDecodeILAttribute (g:TcGlobals) tref (attrs: ILAttributes) = - attrs.AsList |> List.tryPick(fun x -> if isILAttrib tref x then Some(decodeILAttribData g.ilg x) else None) + attrs.AsArray |> Array.tryPick (fun x -> if isILAttrib tref x then Some(decodeILAttribData g.ilg x) else None) // This one is done by name to ensure the compiler doesn't take a dependency on dereferencing a type that only exists in .NET 3.5 let ILThingHasExtensionAttribute (attrs : ILAttributes) = - attrs.AsList - |> List.exists (fun attr -> - attr.Method.EnclosingType.TypeSpec.Name = "System.Runtime.CompilerServices.ExtensionAttribute") + attrs.AsArray + |> Array.exists (fun attr -> attr.Method.EnclosingType.TypeSpec.Name = "System.Runtime.CompilerServices.ExtensionAttribute") // F# view of attributes (these get converted to AbsIL attributes in ilxgen) let IsMatchingFSharpAttribute g (AttribInfo(_,tcref)) (Attrib(tcref2,_,_,_,_,_,_)) = tyconRefEq g tcref tcref2 @@ -3286,7 +3350,7 @@ module DebugPrint = begin | argtys -> (prefixL ^^ nmL ^^ wordL(tagText "of")) --- layoutUnionCaseArgTypes argtys let layoutUnionCases ucases = - let prefixL = if List.length ucases > 1 then wordL(tagText "|") else emptyL + let prefixL = if not (isNilOrSingleton ucases) then wordL(tagText "|") else emptyL List.map (ucaseL prefixL) ucases let layoutRecdField (fld:RecdField) = @@ -3972,80 +4036,10 @@ let inline accFreeTyvars (opts:FreeVarOptions) f v acc = if ftyvs === ftyvs' then acc else { acc with FreeTyvars = ftyvs' } -#if FREEVARS_IN_TYPES_ANALYSIS -type CheckCachability<'key,'acc>(name,f: FreeVarOptions -> 'key -> 'acc -> bool * 'acc) = - let dict = System.Collections.Generic.Dictionary<'key,int>(HashIdentity.Reference) - let idem = System.Collections.Generic.Dictionary<'key,int>(HashIdentity.Reference) - let closed = System.Collections.Generic.Dictionary<'key,int>(HashIdentity.Reference) - let mutable saved = 0 - do System.AppDomain.CurrentDomain.ProcessExit.Add(fun _ -> - let hist = dict |> Seq.groupBy (fun (KeyValue(k,v)) -> v) |> Seq.map (fun (n,els) -> (n,Seq.length els)) |> Seq.sortBy (fun (n,_) -> n) - let total = hist |> Seq.sumBy (fun (nhits,nels) -> nels) - let totalHits = hist |> Seq.sumBy (fun (nhits,nels) -> nhits * nels) - printfn "*** %s saved %d hits (%g%%) ***" name saved (float saved / float (saved + totalHits) * 100.0) - printfn "*** %s had %d hits total, possible saving %d ***" name totalHits (totalHits - total) - //for (nhits,nels) in hist do - // printfn "%s, %g%% els for %g%% hits had %d hits" name (float nels / float total * 100.0) (float (nels * nhits) / float totalHits * 100.0) nhits - - let hist = idem |> Seq.groupBy (fun (KeyValue(k,v)) -> v) |> Seq.map (fun (n,els) -> (n,Seq.length els)) |> Seq.sortBy (fun (n,_) -> n) - let total = hist |> Seq.sumBy (fun (nhits,nels) -> nels) - let totalHits = hist |> Seq.sumBy (fun (nhits,nels) -> nhits * nels) - printfn "*** %s had %d idempotent hits total, possible saving %d ***" name totalHits (totalHits - total) - //for (nhits,nels) in hist do - // printfn "%s, %g%% els for %g%% hits had %d idempotent hits" name (float nels / float total * 100.0) (float (nels * nhits) / float totalHits * 100.0) nhits - - let hist = closed |> Seq.groupBy (fun (KeyValue(k,v)) -> v) |> Seq.map (fun (n,els) -> (n,Seq.length els)) |> Seq.sortBy (fun (n,_) -> n) - let total = hist |> Seq.sumBy (fun (nhits,nels) -> nels) - let totalHits = hist |> Seq.sumBy (fun (nhits,nels) -> nhits * nels) - printfn "*** %s had %d closed hits total, possible saving %d ***" name totalHits (totalHits - total) - ) - - member cache.Apply(opts,key,acc) = - if not opts.collectInTypes then - saved <- saved + 1 - acc - else - let cls,res = f opts key acc - if opts.canCache then - if dict.ContainsKey key then - dict.[key] <- dict.[key] + 1 - else - dict.[key] <- 1 - if res === acc then - if idem.ContainsKey key then - idem.[key] <- idem.[key] + 1 - else - idem.[key] <- 1 - if cls then - if closed.ContainsKey key then - closed.[key] <- closed.[key] + 1 - else - closed.[key] <- 1 - res - - - //member cache.OnExit() = - -let accFreeVarsInTy_cache = CheckCachability("accFreeVarsInTy", (fun opts ty fvs -> (freeInType opts ty === emptyFreeTyvars), accFreeTyvars opts (accFreeInType opts) ty fvs)) -let accFreevarsInValCache = CheckCachability("accFreevarsInVal", (fun opts v fvs -> (freeInVal opts v === emptyFreeTyvars), accFreeTyvars opts (accFreeInVal opts) v fvs)) -let accFreeVarsInTys_cache = CheckCachability("accFreeVarsInTys", (fun opts tys fvs -> (freeInTypes opts tys === emptyFreeTyvars), accFreeTyvars opts (accFreeInTypes opts) tys fvs)) -let accFreevarsInTyconCache = CheckCachability("accFreevarsInTycon", (fun opts tys fvs -> false,accFreeTyvars opts (accFreeTycon opts) tys fvs)) - -let accFreeVarsInTy opts ty fvs = accFreeVarsInTy_cache.Apply(opts,ty,fvs) -let accFreeVarsInTys opts tys fvs = - if isNil tys then fvs else accFreeVarsInTys_cache.Apply(opts,tys,fvs) -let accFreevarsInTycon opts (tcr:TyconRef) acc = - match tcr.IsLocalRef with - | true -> accFreevarsInTyconCache.Apply(opts,tcr,acc) - | _ -> acc -let accFreevarsInVal opts v fvs = accFreevarsInValCache.Apply(opts,v,fvs) -#else - let accFreeVarsInTy opts ty acc = accFreeTyvars opts accFreeInType ty acc let accFreeVarsInTys opts tys acc = if isNil tys then acc else accFreeTyvars opts accFreeInTypes tys acc let accFreevarsInTycon opts tcref acc = accFreeTyvars opts accFreeTycon tcref acc let accFreevarsInVal opts v acc = accFreeTyvars opts accFreeInVal v acc -#endif let accFreeVarsInTraitSln opts tys acc = accFreeTyvars opts accFreeInTraitSln tys acc @@ -4391,9 +4385,12 @@ let stripTopLambda (e,ty) = let vs,body,rty = stripLambda (taue,tauty) tps,vs,body,rty +[] +type AllowTypeDirectedDetupling = Yes | No + // This is used to infer arities of expressions // i.e. base the chosen arity on the syntactic expression shape and type of arguments -let InferArityOfExpr g ty partialArgAttribsL retAttribs e = +let InferArityOfExpr g allowTypeDirectedDetupling ty partialArgAttribsL retAttribs e = let rec stripLambda_notypes e = match e with | Expr.Lambda (_,_,_,vs,b,_,_) -> @@ -4416,7 +4413,12 @@ let InferArityOfExpr g ty partialArgAttribsL retAttribs e = let curriedArgInfos = (List.zip vsl dtys) |> List.mapi (fun i (vs,ty) -> let partialAttribs = if i < partialArgAttribsL.Length then partialArgAttribsL.[i] else [] - let tys = if (i = 0 && isUnitTy g ty) then [] else tryDestRefTupleTy g ty + let tys = + match allowTypeDirectedDetupling with + | AllowTypeDirectedDetupling.No -> [ty] + | AllowTypeDirectedDetupling.Yes -> + if (i = 0 && isUnitTy g ty) then [] + else tryDestRefTupleTy g ty let ids = if vs.Length = tys.Length then vs |> List.map (fun v -> Some v.Id) else tys |> List.map (fun _ -> None) @@ -4427,10 +4429,10 @@ let InferArityOfExpr g ty partialArgAttribsL retAttribs e = let retInfo : ArgReprInfo = { Attribs = retAttribs; Name = None } ValReprInfo (ValReprInfo.InferTyparInfo tps, curriedArgInfos, retInfo) -let InferArityOfExprBinding g (v:Val) e = +let InferArityOfExprBinding g allowTypeDirectedDetupling (v:Val) e = match v.ValReprInfo with | Some info -> info - | None -> InferArityOfExpr g v.Type [] [] e + | None -> InferArityOfExpr g allowTypeDirectedDetupling v.Type [] [] e //------------------------------------------------------------------------- // Check if constraints are satisfied that allow us to use more optimized @@ -4439,7 +4441,6 @@ let InferArityOfExprBinding g (v:Val) e = let underlyingTypeOfEnumTy (g: TcGlobals) typ = assert(isEnumTy g typ) - let tycon = tyconOfAppTy g typ match metadataOfTy g typ with #if EXTENSIONTYPING | ProvidedTypeMetadata info -> info.UnderlyingTypeOfEnum() @@ -4462,7 +4463,8 @@ let underlyingTypeOfEnumTy (g: TcGlobals) typ = | "System.Char" -> g.char_ty | "System.Boolean" -> g.bool_ty | _ -> g.int32_ty - | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> + | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> + let tycon = (tcrefOfAppTy g typ).Deref match tycon.GetFieldByName "value__" with | Some rf -> rf.FormalType | None -> error(InternalError("no 'value__' field found for enumeration type "^tycon.LogicalName,tycon.Range)) @@ -5688,10 +5690,10 @@ let mkArray (argty, args, m) = Expr.Op(TOp.Array, [argty],args,m) //--------------------------------------------------------------------------- let rec IterateRecursiveFixups g (selfv : Val option) rvs ((access : Expr),set) exprToFix = - let exprToFix = stripExpr exprToFix - match exprToFix with - | Expr.Const _ -> () - | Expr.Op (TOp.Tuple tupInfo,argtys,args,m) when not (evalTupInfoIsStruct tupInfo) -> + let exprToFix = stripExpr exprToFix + match exprToFix with + | Expr.Const _ -> () + | Expr.Op (TOp.Tuple tupInfo,argtys,args,m) when not (evalTupInfoIsStruct tupInfo) -> args |> List.iteri (fun n -> IterateRecursiveFixups g None rvs (mkTupleFieldGet g (tupInfo,access,argtys,n,m), @@ -5700,7 +5702,7 @@ let rec IterateRecursiveFixups g (selfv : Val option) rvs ((access : Expr),set) errorR(Error(FSComp.SR.tastRecursiveValuesMayNotBeInConstructionOfTuple(),m)); e))) - | Expr.Op (TOp.UnionCase (c),tinst,args,m) -> + | Expr.Op (TOp.UnionCase (c),tinst,args,m) -> args |> List.iteri (fun n -> IterateRecursiveFixups g None rvs (mkUnionCaseFieldGetUnprovenViaExprAddr (access,c,tinst,n,m), @@ -5711,7 +5713,7 @@ let rec IterateRecursiveFixups g (selfv : Val option) rvs ((access : Expr),set) errorR(Error(FSComp.SR.tastRecursiveValuesMayNotAppearInConstructionOfType(tcref.LogicalName),m)); mkUnionCaseFieldSet (access,c,tinst,n,e,m)))) - | Expr.Op (TOp.Recd (_,tcref),tinst,args,m) -> + | Expr.Op (TOp.Recd (_,tcref),tinst,args,m) -> (tcref.TrueInstanceFieldsAsRefList, args) ||> List.iter2 (fun fref arg -> let fspec = fref.RecdField IterateRecursiveFixups g None rvs @@ -5721,13 +5723,13 @@ let rec IterateRecursiveFixups g (selfv : Val option) rvs ((access : Expr),set) if not fspec.IsMutable && not (entityRefInThisAssembly g.compilingFslib tcref) then errorR(Error(FSComp.SR.tastRecursiveValuesMayNotBeAssignedToNonMutableField(fspec.rfield_id.idText, tcref.LogicalName),m)); mkRecdFieldSetViaExprAddr (access,fref,tinst,e,m))) arg ) - | Expr.Val _ - | Expr.Lambda _ - | Expr.Obj _ - | Expr.TyChoose _ - | Expr.TyLambda _ -> - rvs selfv access set exprToFix - | _ -> () + | Expr.Val _ + | Expr.Lambda _ + | Expr.Obj _ + | Expr.TyChoose _ + | Expr.TyLambda _ -> + rvs selfv access set exprToFix + | _ -> () @@ -6948,8 +6950,8 @@ let LinearizeTopMatchAux g parent (spBind,m,tree,targets,m2,ty) = vs |> List.mapi (fun i v -> let ty = v.Type let rhs = etaExpandTypeLambda g m v.Typars (itemsProj vtys i tmpe, ty) - (* update the arity of the value *) - v.SetValReprInfo (Some (InferArityOfExpr g ty [] [] rhs)) + // update the arity of the value + v.SetValReprInfo (Some (InferArityOfExpr g AllowTypeDirectedDetupling.Yes ty [] [] rhs)) mkInvisibleBind v rhs) in (* vi = proj tmp *) mkCompGenLet m tmp (primMkMatch (spBind,m,tree,targets,m2,tmpTy)) (* note, probably retyped match, but note, result still has same type *) @@ -7070,7 +7072,7 @@ let XmlDocSigOfVal g path (v:Val) = | MemberKind.PropertyGetSet | MemberKind.PropertySet | MemberKind.PropertyGet -> "P:",v.PropertyName - let path = prependPath path v.TopValActualParent.CompiledName + let path = if v.HasTopValActualParent then prependPath path v.TopValActualParent.CompiledName else path let parentTypars,methTypars = match PartitionValTypars g v with | Some(_,memberParentTypars,memberMethodTypars,_,_) -> memberParentTypars,memberMethodTypars @@ -7162,9 +7164,10 @@ let TypeNullIsExtraValue g m ty = // Putting AllowNullLiteralAttribute(true) on an F# type means 'null' can be used with that type isAppTy g ty && TryFindTyconRefBoolAttribute g m g.attrib_AllowNullLiteralAttribute (tcrefOfAppTy g ty) = Some(true) -let TypeNullIsTrueValue g ty = - (isAppTy g ty && IsUnionTypeWithNullAsTrueValue g (tyconOfAppTy g ty)) || - (isUnitTy g ty) +let TypeNullIsTrueValue g ty = + (match tryDestAppTy g ty with + | Some tcref -> IsUnionTypeWithNullAsTrueValue g tcref.Deref + | _ -> false) || (isUnitTy g ty) let TypeNullNotLiked g m ty = not (TypeNullIsExtraValue g m ty) @@ -7202,16 +7205,17 @@ let (|SpecialComparableHeadType|_|) g ty = if isAnyTupleTy g ty then let _tupInfo, elemTys = destAnyTupleTy g ty Some elemTys - elif isAppTy g ty then - let tcref,tinst = destAppTy g ty - if isArrayTyconRef g tcref || - tyconRefEq g tcref g.system_UIntPtr_tcref || - tyconRefEq g tcref g.system_IntPtr_tcref then - Some tinst - else - None else - None + match ty with + | AppTy g (tcref,tinst) -> + if isArrayTyconRef g tcref || + tyconRefEq g tcref g.system_UIntPtr_tcref || + tyconRefEq g tcref g.system_IntPtr_tcref then + Some tinst + else + None + | _ -> + None let (|SpecialEquatableHeadType|_|) g ty = (|SpecialComparableHeadType|_|) g ty let (|SpecialNotEquatableHeadType|_|) g ty = @@ -7401,7 +7405,7 @@ let mkChoiceTy (g:TcGlobals) m tinst = match List.length tinst with | 0 -> g.unit_ty | 1 -> List.head tinst - | _ -> mkAppTy (mkChoiceTyconRef g m (List.length tinst)) tinst + | length -> mkAppTy (mkChoiceTyconRef g m length) tinst let mkChoiceCaseRef g m n i = mkUnionCaseRef (mkChoiceTyconRef g m n) ("Choice"+string (i+1)+"Of"+string n) @@ -7948,7 +7952,7 @@ let rec mkCompiledTuple g isStruct (argtys,args,m) = elif n < maxTuple then (mkCompiledTupleTyconRef g isStruct n, argtys, args, m) else let argtysA,argtysB = List.splitAfter goodTupleFields argtys - let argsA,argsB = List.splitAfter (goodTupleFields) args + let argsA,argsB = List.splitAfter goodTupleFields args let ty8, v8 = match argtysB,argsB with | [ty8],[arg8] -> @@ -8031,8 +8035,8 @@ let (|CompiledForEachExpr|_|) g expr = enumerableVar.IsCompilerGenerated && enumeratorVar.IsCompilerGenerated && (let fvs = (freeInExpr CollectLocals bodyExpr) - not (Zset.contains enumerableVar fvs.FreeLocals) && - not (Zset.contains enumeratorVar fvs.FreeLocals)) -> + not (Zset.contains enumerableVar fvs.FreeLocals) && + not (Zset.contains enumeratorVar fvs.FreeLocals)) -> // Extract useful ranges let mEnumExpr = enumerableExpr.Range @@ -8138,11 +8142,9 @@ let DetectAndOptimizeForExpression g option expr = // Used to remove Expr.Link for inner expressions in pattern matches let (|InnerExprPat|) expr = stripExpr expr -//------------------------------------------------------------------------- -// One of the transformations performed by the compiler -// is to eliminate variables of static type "unit". These are -// utility functions related to this. -//------------------------------------------------------------------------- +/// One of the transformations performed by the compiler +/// is to eliminate variables of static type "unit". These is a +/// utility function related to this. let BindUnitVars g (mvs:Val list, paramInfos:ArgReprInfo list, body) = match mvs,paramInfos with diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index 8ed6784102..ff7907cace 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -414,6 +414,8 @@ val isUnionTy : TcGlobals -> TType -> bool val isReprHiddenTy : TcGlobals -> TType -> bool val isFSharpObjModelTy : TcGlobals -> TType -> bool val isRecdTy : TcGlobals -> TType -> bool +val isFSharpStructOrEnumTy : TcGlobals -> TType -> bool +val isFSharpEnumTy : TcGlobals -> TType -> bool val isTyparTy : TcGlobals -> TType -> bool val isAnyParTy : TcGlobals -> TType -> bool val tryAnyParTy : TcGlobals -> TType -> Typar option @@ -427,7 +429,6 @@ val isProvenUnionCaseTy : TType -> bool val isAppTy : TcGlobals -> TType -> bool val destAppTy : TcGlobals -> TType -> TyconRef * TypeInst val tcrefOfAppTy : TcGlobals -> TType -> TyconRef -val tyconOfAppTy : TcGlobals -> TType -> Tycon val tryDestAppTy : TcGlobals -> TType -> TyconRef option val tryDestTyparTy : TcGlobals -> TType -> Typar option val tryDestFunTy : TcGlobals -> TType -> (TType * TType) option @@ -613,13 +614,18 @@ module PrettyTypes = val NeedsPrettyTyparName : Typar -> bool val NewPrettyTypars : TyparInst -> Typars -> string list -> Typars * TyparInst val PrettyTyparNames : (Typar -> bool) -> string list -> Typars -> string list - val PrettifyTypes1 : TcGlobals -> TType -> TyparInst * TType * TyparConstraintsWithTypars - val PrettifyTypes2 : TcGlobals -> TType * TType -> TyparInst * (TType * TType) * TyparConstraintsWithTypars - val PrettifyTypesN : TcGlobals -> TType list -> TyparInst * TType list * TyparConstraintsWithTypars - val PrettifyTypesNN : TcGlobals -> TType list list -> TyparInst * TType list list * TyparConstraintsWithTypars - val PrettifyTypesNN1 : TcGlobals -> TType list list * TType -> TyparInst * (TType list list * TType) * TyparConstraintsWithTypars - val PrettifyTypesN1 : TcGlobals -> UncurriedArgInfos * TType -> TyparInst * (UncurriedArgInfos * TType) * TyparConstraintsWithTypars - val PrettifyTypesNM1 : TcGlobals -> TType list * CurriedArgInfos * TType -> TyparInst * (TType list * CurriedArgInfos * TType) * TyparConstraintsWithTypars + val PrettifyType : TcGlobals -> TType -> TType * TyparConstraintsWithTypars + val PrettifyInstAndTyparsAndType : TcGlobals -> TyparInst * Typars * TType -> (TyparInst * Typars * TType) * TyparConstraintsWithTypars + val PrettifyTypePair : TcGlobals -> TType * TType -> (TType * TType) * TyparConstraintsWithTypars + val PrettifyTypes : TcGlobals -> TTypes -> TTypes * TyparConstraintsWithTypars + val PrettifyInst : TcGlobals -> TyparInst -> TyparInst * TyparConstraintsWithTypars + val PrettifyInstAndType : TcGlobals -> TyparInst * TType -> (TyparInst * TType) * TyparConstraintsWithTypars + val PrettifyInstAndTypes : TcGlobals -> TyparInst * TTypes -> (TyparInst * TTypes) * TyparConstraintsWithTypars + val PrettifyInstAndSig : TcGlobals -> TyparInst * TTypes * TType -> (TyparInst * TTypes * TType) * TyparConstraintsWithTypars + val PrettifyCurriedTypes : TcGlobals -> TType list list -> TType list list * TyparConstraintsWithTypars + val PrettifyCurriedSigTypes : TcGlobals -> TType list list * TType -> (TType list list * TType) * TyparConstraintsWithTypars + val PrettifyInstAndUncurriedSig : TcGlobals -> TyparInst * UncurriedArgInfos * TType -> (TyparInst * UncurriedArgInfos * TType) * TyparConstraintsWithTypars + val PrettifyInstAndCurriedSig : TcGlobals -> TyparInst * TTypes * CurriedArgInfos * TType -> (TyparInst * TTypes * CurriedArgInfos * TType) * TyparConstraintsWithTypars [] type DisplayEnv = @@ -734,9 +740,12 @@ val tyOfExpr : TcGlobals -> Expr -> TType // Top expressions to implement top types //------------------------------------------------------------------------- +[] +type AllowTypeDirectedDetupling = Yes | No + val stripTopLambda : Expr * TType -> Typars * Val list list * Expr * TType -val InferArityOfExpr : TcGlobals -> TType -> Attribs list list -> Attribs -> Expr -> ValReprInfo -val InferArityOfExprBinding : TcGlobals -> Val -> Expr -> ValReprInfo +val InferArityOfExpr : TcGlobals -> AllowTypeDirectedDetupling -> TType -> Attribs list list -> Attribs -> Expr -> ValReprInfo +val InferArityOfExprBinding : TcGlobals -> AllowTypeDirectedDetupling -> Val -> Expr -> ValReprInfo //------------------------------------------------------------------------- // Copy expressions and types diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index 05a1120d65..336a10268a 100755 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -11,7 +11,6 @@ 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.AbstractIL.Extensions.ILX.Types open Microsoft.FSharp.Compiler.Tastops open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.Lib.Bits @@ -90,7 +89,6 @@ type InputTable<'T> = let new_itbl n r = { itbl_name=n; itbl_rows=r } -#if INCLUDE_METADATA_WRITER [] type NodeOutTable<'Data,'Node> = { NodeStamp : ('Node -> Stamp) @@ -126,8 +124,6 @@ type WriterState = ofile : string; } let pfailwith st str = ffailwith st.ofile str - -#endif [] type NodeInTable<'Data,'Node> = @@ -163,8 +159,6 @@ let ufailwith st str = ffailwith st.ifile str // Basic pickle/unpickle operations //--------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER - type 'T pickler = 'T -> WriterState -> unit let p_byte b st = st.os.EmitIntAsByte b @@ -239,8 +233,6 @@ let inline p_tup15 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 (a,b,c,d, 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) -#endif - let u_byte st = int (st.is.ReadByte()) type unpickler<'T> = ReaderState -> 'T @@ -375,7 +367,6 @@ let inline u_tup17 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 (s // exception Nope // ctxt is for debugging -#if INCLUDE_METADATA_WRITER let p_osgn_ref (_ctxt:string) (outMap : NodeOutTable<_,_>) x st = let idx = outMap.Table.FindOrAdd (outMap.NodeStamp x) //if ((idx = 0) && outMap.Name = "otycons") then @@ -387,7 +378,6 @@ let p_osgn_decl (outMap : NodeOutTable<_,_>) p x st = let idx = outMap.Table.FindOrAdd stamp //dprintf "decl %d#%d in table %s has name %s\n" idx (outMap.NodeStamp x) outMap.Name (outMap.NodeName x); p_tup2 p_int p (idx,outMap.Deref x) st -#endif let u_osgn_ref (inMap: NodeInTable<_,_>) st = let n = u_int st @@ -416,7 +406,6 @@ let lookup_uniq st tbl n = // between internal representations relatively easily //------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER let p_array f (x: 'T[]) st = p_int x.Length st; for i = 0 to x.Length-1 do @@ -482,9 +471,6 @@ let p_hole () = let h = ref (None : 'T pickler option) (fun f -> h := Some f),(fun x st -> match !h with Some f -> f x st | None -> pfailwith st "p_hole: unfilled hole") - -#endif - let u_array f st = let n = u_int st let res = Array.zeroCreate n @@ -585,12 +571,10 @@ let u_strings = u_list u_string let u_ints = u_list u_int -#if INCLUDE_METADATA_WRITER let p_encoded_string = p_prim_string let p_string s st = p_int (encode_string st.ostrings s) st let p_strings = p_list p_string let p_ints = p_list p_int -#endif // CCU References // A huge number of these occur in pickled F# data, so make them unique @@ -603,13 +587,11 @@ let u_encoded_ccuref st = | n -> ufailwith st ("u_encoded_ccuref: found number " + string n) let u_ccuref st = lookup_uniq st st.iccus (u_int st) -#if INCLUDE_METADATA_WRITER let p_encoded_ccuref x st = p_byte 0 st // leave a dummy tag to make room for future encodings of ccurefs p_prim_string x st let p_ccuref s st = p_int (encode_ccuref st.occus s) st -#endif // References to public items in this module // A huge number of these occur in pickled F# data, so make them unique @@ -618,11 +600,9 @@ let lookup_pubpath st pubpathTab x = lookup_uniq st pubpathTab x let u_encoded_pubpath = u_array u_int let u_pubpath st = lookup_uniq st st.ipubpaths (u_int st) -#if INCLUDE_METADATA_WRITER let encode_pubpath stringTab pubpathTab (PubPath(a)) = encode_uniq pubpathTab (Array.map (encode_string stringTab) a) let p_encoded_pubpath = p_array p_int let p_pubpath x st = p_int (encode_pubpath st.ostrings st.opubpaths x) st -#endif // References to other modules // A huge number of these occur in pickled F# data, so make them unique @@ -631,7 +611,6 @@ let lookup_nleref st nlerefTab x = lookup_uniq st nlerefTab x let u_encoded_nleref = u_tup2 u_int (u_array u_int) let u_nleref st = lookup_uniq st st.inlerefs (u_int st) -#if INCLUDE_METADATA_WRITER let encode_nleref ccuTab stringTab nlerefTab thisCcu (nleref: NonLocalEntityRef) = #if EXTENSIONTYPING // Remap references to statically-linked Entity nodes in provider-generated entities to point to the current assembly. @@ -650,7 +629,6 @@ let encode_nleref ccuTab stringTab nlerefTab thisCcu (nleref: NonLocalEntityRef) encode_uniq nlerefTab (encode_ccuref ccuTab a, Array.map (encode_string stringTab) b) let p_encoded_nleref = p_tup2 p_int (p_array p_int) let p_nleref x st = p_int (encode_nleref st.occus st.ostrings st.onlerefs st.oscope x) st -#endif // Simple types are types like "int", represented as TType(Ref_nonlocal(...,"int"),[]). // A huge number of these occur in pickled F# data, so make them unique. @@ -658,14 +636,11 @@ let decode_simpletyp st _ccuTab _stringTab nlerefTab a = TType_app(ERefNonLocal let lookup_simpletyp st simpletypTab x = lookup_uniq st simpletypTab x let u_encoded_simpletyp st = u_int st let u_simpletyp st = lookup_uniq st st.isimpletyps (u_int st) -#if INCLUDE_METADATA_WRITER let encode_simpletyp ccuTab stringTab nlerefTab simpletypTab thisCcu a = encode_uniq simpletypTab (encode_nleref ccuTab stringTab nlerefTab thisCcu a) let p_encoded_simpletyp x st = p_int x st let p_simpletyp x st = p_int (encode_simpletyp st.occus st.ostrings st.onlerefs st.osimpletyps st.oscope x) st -#endif type sizes = int * int * int -#if INCLUDE_METADATA_WRITER let pickleObjWithDanglingCcus file g scope p x = let ccuNameTab,(sizes: sizes),stringTab,pubpathTab,nlerefTab,simpletypTab,phase1bytes = let st1 = @@ -715,8 +690,6 @@ let pickleObjWithDanglingCcus file g scope p x = st2.os.Close() phase2bytes -#endif - let check (ilscope:ILScopeRef) (inMap : NodeInTable<_,_>) = for i = 0 to inMap.Count - 1 do let n = inMap.Get i @@ -788,7 +761,6 @@ let unpickleObjWithDanglingCcus file ilscope (iILModule:ILModuleDef option) u (p // Pickle/unpickle for Abstract IL data, up to IL instructions //--------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER let p_ILPublicKey x st = match x with | PublicKey b -> p_byte 0 st; p_bytes b st @@ -807,7 +779,6 @@ let p_ILScopeRef x st = | ILScopeRef.Local -> p_byte 0 st | ILScopeRef.Module mref -> p_byte 1 st; p_ILModuleRef mref st | ILScopeRef.Assembly aref -> p_byte 2 st; p_ILAssemblyRef aref st -#endif let u_ILPublicKey st = let tag = u_byte st @@ -844,7 +815,6 @@ let u_ILScopeRef st = let res = rescopeILScopeRef st.iilscope res res -#if INCLUDE_METADATA_WRITER let p_ILHasThis x st = p_byte (match x with | ILThisConvention.Instance -> 0 @@ -883,7 +853,6 @@ and p_ILCallSig x st = p_tup3 p_ILCallConv p_ILTypes p_ILType (x.CallingConv,x.A and p_ILTypeRef (x:ILTypeRef) st = p_tup3 p_ILScopeRef p_strings p_string (x.Scope,x.Enclosing,x.Name) st and p_ILTypeSpec (a:ILTypeSpec) st = p_tup2 p_ILTypeRef p_ILTypes (a.TypeRef,a.GenericArgs) st -#endif let u_ILBasicCallConv st = match u_byte st with @@ -925,7 +894,6 @@ and u_ILCallSig = u_wrap (fun (a,b,c) -> {CallingConv=a; ArgTypes=b; ReturnType= and u_ILTypeSpec st = let a,b = u_tup2 u_ILTypeRef u_ILTypes st in ILTypeSpec.Create(a,b) -#if INCLUDE_METADATA_WRITER let p_ILMethodRef (x: ILMethodRef) st = p_tup6 p_ILTypeRef p_ILCallConv p_int p_string p_ILTypes p_ILType (x.EnclosingTypeRef,x.CallingConv,x.GenericArity,x.Name,x.ArgTypes,x.ReturnType) st let p_ILFieldRef (x: ILFieldRef) st = p_tup3 p_ILTypeRef p_string p_ILType (x.EnclosingTypeRef, x.Name, x.Type) st @@ -954,8 +922,6 @@ let p_ILBasicType x st = let p_ILVolatility x st = p_int (match x with Volatile -> 0 | Nonvolatile -> 1) st let p_ILReadonly x st = p_int (match x with ReadonlyAddress -> 0 | NormalAddress -> 1) st -#endif - let u_ILMethodRef st = let x1,x2,x3,x4,x5,x6 = u_tup6 u_ILTypeRef u_ILCallConv u_int u_string u_ILTypes u_ILType st ILMethodRef.Create(x1,x2,x4,x3,x5,x6) @@ -1147,8 +1113,6 @@ let decode_tab = List.iter (fun (icode,mk) -> add_instr (icode,(fun _ -> mk))) simple_instrs; tab -#if INCLUDE_METADATA_WRITER - let p_ILInstr x st = match x with | si when isNoArgInstr si -> p_byte (encode_instr si) st @@ -1186,7 +1150,6 @@ let p_ILInstr x st = | I_initobj c -> p_byte itag_initobj st; p_ILType c st | I_cpobj c -> p_byte itag_cpobj st; p_ILType c st | i -> pfailwith st (sprintf "the IL instruction '%+A' cannot be emitted" i) -#endif let u_ILInstr st = let n = u_byte st @@ -1198,25 +1161,21 @@ let u_ILInstr st = // Pickle/unpickle for F# types and module signatures //--------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER // TODO: remove all pickling of maps let p_Map pk pv = p_wrap Map.toList (p_list (p_tup2 pk pv)) let p_qlist pv = p_wrap QueueList.toList (p_list pv) let p_namemap p = p_Map p_string p -#endif // TODO: remove all pickling of maps let u_Map uk uv = u_wrap Map.ofList (u_list (u_tup2 uk uv)) let u_qlist uv = u_wrap QueueList.ofList (u_list uv) let u_namemap u = u_Map u_string u -#if INCLUDE_METADATA_WRITER let p_pos (x: pos) st = p_tup2 p_int p_int (x.Line,x.Column) st let p_range (x: range) st = p_tup3 p_string p_pos p_pos (x.FileName, x.Start, x.End) st let p_dummy_range : range pickler = fun _x _st -> () let p_ident (x: Ident) st = p_tup2 p_string p_range (x.idText,x.idRange) st let p_xmldoc (XmlDoc x) st = p_array p_string x st -#endif let u_pos st = let a = u_int st in let b = u_int st in mkPos a b let u_range st = let a = u_string st in let b = u_pos st in let c = u_pos st in mkRange a b c @@ -1227,7 +1186,6 @@ let u_ident st = let a = u_string st in let b = u_range st in ident(a,b) let u_xmldoc st = XmlDoc (u_array u_string st) -#if INCLUDE_METADATA_WRITER let p_local_item_ref ctxt tab st = p_osgn_ref ctxt tab st let p_tcref ctxt (x:EntityRef) st = @@ -1239,8 +1197,6 @@ let p_ucref (UCRef(a,b)) st = p_tup2 (p_tcref "ucref") p_string (a,b) st let p_rfref (RFRef(a,b)) st = p_tup2 (p_tcref "rfref") p_string (a,b) st let p_tpref x st = p_local_item_ref "typar" st.otypars x st -#endif - let u_local_item_ref tab st = u_osgn_ref tab st let u_tcref st = @@ -1256,8 +1212,6 @@ let u_rfref st = let a,b = u_tup2 u_tcref u_string st in RFRef(a,b) let u_tpref st = u_local_item_ref st.itypars st - -#if INCLUDE_METADATA_WRITER // forward reference let fill_p_typ,p_typ = p_hole() let p_typs = (p_list p_typ) @@ -1281,7 +1235,6 @@ let rec p_vref ctxt x st = | VRefNonLocal x -> p_byte 1 st; p_nonlocal_val_ref x st let p_vrefs ctxt = p_list (p_vref ctxt) -#endif let fill_u_typ,u_typ = u_hole() let u_typs = (u_list u_typ) @@ -1306,9 +1259,6 @@ let u_vref st = let u_vrefs = u_list u_vref - - -#if INCLUDE_METADATA_WRITER let p_kind x st = p_byte (match x with | TyparKind.Type -> 0 @@ -1322,8 +1272,6 @@ let p_member_kind x st = | MemberKind.Constructor -> 3 | MemberKind.ClassConstructor -> 4 | MemberKind.PropertyGetSet -> pfailwith st "pickling: MemberKind.PropertyGetSet only expected in parse trees") st -#endif - let u_kind st = match u_byte st with @@ -1340,7 +1288,6 @@ let u_member_kind st = | 4 -> MemberKind.ClassConstructor | _ -> ufailwith st "u_member_kind" -#if INCLUDE_METADATA_WRITER let p_MemberFlags x st = p_tup6 p_bool p_bool p_bool p_bool p_bool p_member_kind (x.IsInstance, @@ -1349,7 +1296,6 @@ let p_MemberFlags x st = x.IsOverrideOrExplicitImpl, x.IsFinal, x.MemberKind) st -#endif let u_MemberFlags st = let x2,_x3UnusedBoolInFormat,x4,x5,x6,x7 = u_tup6 u_bool u_bool u_bool u_bool u_bool u_member_kind st { IsInstance=x2; @@ -1359,7 +1305,6 @@ let u_MemberFlags st = MemberKind=x7} let fill_u_Expr_hole,u_expr_fwd = u_hole() -#if INCLUDE_METADATA_WRITER let fill_p_Expr_hole,p_expr_fwd = p_hole() let p_trait_sln sln st = @@ -1377,7 +1322,6 @@ let p_trait_sln sln st = let p_trait (TTrait(a,b,c,d,e,f)) st = p_tup6 p_typs p_string p_MemberFlags p_typs (p_option p_typ) (p_option p_trait_sln) (a,b,c,d,e,!f) st -#endif // We have to store trait solutions since they can occur in optimization data let u_trait_sln st = @@ -1402,7 +1346,6 @@ let u_trait st = let a,b,c,d,e,f = u_tup6 u_typs u_string u_MemberFlags u_typs (u_option u_typ) (u_option u_trait_sln) st TTrait (a,b,c,d,e,ref f) -#if INCLUDE_METADATA_WRITER let p_rational q st = p_int32 (GetNumerator q) st; p_int32 (GetDenominator q) st @@ -1457,8 +1400,6 @@ let rec p_normalized_measure unt st = // See https://github.com/Microsoft/visualfsharp/issues/69 let p_measure_expr unt st = p_normalized_measure (normalizeMeasure st.oglobals unt) st -#endif - let u_rational st = let a,b = u_tup2 u_int32 u_int32 st in DivRational (intToRational a) (intToRational b) @@ -1473,7 +1414,6 @@ let rec u_measure_expr st = | 5 -> let a = u_measure_expr st in let b = u_rational st in Measure.RationalPower (a,b) | _ -> ufailwith st "u_measure_expr" -#if INCLUDE_METADATA_WRITER let p_typar_constraint x st = match x with | TyparConstraint.CoercesTo (a,_) -> p_byte 0 st; p_typ a st @@ -1490,7 +1430,6 @@ let p_typar_constraint x st = | TyparConstraint.SupportsEquality _ -> p_byte 11 st | TyparConstraint.IsUnmanaged _ -> p_byte 12 st let p_typar_constraints = (p_list p_typar_constraint) -#endif let u_typar_constraint st = let tag = u_byte st @@ -1514,7 +1453,6 @@ let u_typar_constraint st = let u_typar_constraints = (u_list_revi u_typar_constraint) -#if INCLUDE_METADATA_WRITER let p_typar_spec_data (x:Typar) st = p_tup5 p_ident @@ -1531,7 +1469,6 @@ let p_typar_spec (x:Typar) st = p_osgn_decl st.otypars p_typar_spec_data x st let p_typar_specs = (p_list p_typar_spec) -#endif let u_typar_spec_data st = let a,c,d,e,g = u_tup5 u_ident u_attribs u_int64 u_typar_constraints u_xmldoc st @@ -1550,8 +1487,6 @@ let u_typar_spec st = let u_typar_specs = (u_list u_typar_spec) - -#if INCLUDE_METADATA_WRITER let _ = fill_p_typ (fun ty st -> let ty = stripTyparEqns ty match ty with @@ -1568,8 +1503,6 @@ let _ = fill_p_typ (fun ty st -> | TType_measure unt -> p_byte 6 st; p_measure_expr unt st | TType_ucase (uc,tinst) -> p_byte 7 st; p_tup2 p_ucref p_typs (uc,tinst) st) -#endif - let _ = fill_u_typ (fun st -> let tag = u_byte st match tag with @@ -1585,13 +1518,11 @@ let _ = fill_u_typ (fun st -> | _ -> ufailwith st "u_typ") -#if INCLUDE_METADATA_WRITER let fill_p_binds,p_binds = p_hole() let fill_p_targets,p_targets = p_hole() let fill_p_Exprs,p_Exprs = p_hole() let fill_p_constraints,p_constraints = p_hole() let fill_p_Vals,p_Vals = p_hole() -#endif let fill_u_binds,u_binds = u_hole() let fill_u_targets,u_targets = u_hole() @@ -1599,7 +1530,6 @@ let fill_u_Exprs,u_Exprs = u_hole() let fill_u_constraints,u_constraints = u_hole() let fill_u_Vals,u_Vals = u_hole() -#if INCLUDE_METADATA_WRITER let p_ArgReprInfo (x:ArgReprInfo) st = p_attribs x.Attribs st; p_option p_ident x.Name st @@ -1612,7 +1542,6 @@ let p_ValReprInfo (ValReprInfo (a,args,ret)) st = p_list p_TyparReprInfo a st; p_list (p_list p_ArgReprInfo) args st; p_ArgReprInfo ret st -#endif let u_ArgReprInfo st = let a = u_attribs st @@ -1632,7 +1561,6 @@ let u_ValReprInfo st = let c = u_ArgReprInfo st ValReprInfo (a,b,c) -#if INCLUDE_METADATA_WRITER let p_ranges x st = p_option (p_tup2 p_range p_range) x st @@ -1645,8 +1573,6 @@ let p_istype x st = let p_cpath (CompPath(a,b)) st = p_tup2 p_ILScopeRef (p_list (p_tup2 p_string p_istype)) (a,b) st -#endif - let u_ranges st = u_option (u_tup2 u_range u_range) st let u_istype st = @@ -1661,7 +1587,6 @@ let u_cpath st = let a,b = u_tup2 u_ILScopeRef (u_list (u_tup2 u_string u_istyp let rec dummy x = x -#if INCLUDE_METADATA_WRITER and p_tycon_repr x st = // The leading "p_byte 1" and "p_byte 0" come from the F# 2.0 format, which used an option value at this point. match x with @@ -1858,9 +1783,6 @@ and p_modul_typ (x: ModuleOrNamespaceType) st = (x.ModuleOrNamespaceKind,x.AllValsAndMembers,x.AllEntities) st -#endif - - and u_tycon_repr st = let tag1 = u_byte st match tag1 with @@ -2167,7 +2089,6 @@ and u_modul_typ st = // Pickle/unpickle for F# expressions (for optimization data) //--------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER and p_const x st = match x with | Const.Bool x -> p_byte 0 st; p_bool x st @@ -2188,7 +2109,6 @@ and p_const x st = | Const.Unit -> p_byte 15 st | Const.Zero -> p_byte 16 st | Const.Decimal s -> p_byte 17 st; p_array p_int32 (System.Decimal.GetBits(s)) st -#endif and u_const st = let tag = u_byte st @@ -2214,7 +2134,6 @@ and u_const st = | _ -> ufailwith st "u_const" -#if INCLUDE_METADATA_WRITER and p_dtree x st = match x with | TDSwitch (a,b,c,d) -> p_byte 0 st; p_tup4 p_expr (p_list p_dtree_case) (p_option p_dtree) p_dummy_range (a,b,c,d) st @@ -2243,8 +2162,6 @@ and p_recdInfo x st = | RecdExpr -> () | RecdExprIsObjInit -> pfailwith st "explicit object constructors can't be inlined and should not have optimization information" - -#endif and u_dtree st = let tag = u_byte st match tag with @@ -2278,7 +2195,6 @@ and u_lval_op_kind st = | _ -> ufailwith st "uval_op_kind" -#if INCLUDE_METADATA_WRITER and p_op x st = match x with | TOp.UnionCase c -> p_byte 0 st; p_ucref c st @@ -2322,7 +2238,6 @@ and p_op x st = // Note tag byte 29 is taken for struct tuples, see above // Note tag byte 30 is taken for struct tuples, see above | TOp.Goto _ | TOp.Label _ | TOp.Return -> failwith "unexpected backend construct in pickled TAST" -#endif and u_op st = let tag = u_byte st @@ -2390,7 +2305,6 @@ and u_op st = TOp.TupleFieldGet (tupInfoStruct, a) | _ -> ufailwith st "u_op" -#if INCLUDE_METADATA_WRITER and p_expr expr st = match expr with | Expr.Link e -> p_expr !e st @@ -2408,7 +2322,6 @@ and p_expr expr st = | Expr.StaticOptimization(a,b,c,d) -> p_byte 11 st; p_tup4 p_constraints p_expr p_expr p_dummy_range (a,b,c,d) st | Expr.TyChoose (a,b,c) -> p_byte 12 st; p_tup3 p_typar_specs p_expr p_dummy_range (a,b,c) st | Expr.Quote(ast,_,_,m,ty) -> p_byte 13 st; p_tup3 p_expr p_dummy_range p_typ (ast,m,ty) st -#endif and u_expr st = let tag = u_byte st @@ -2485,7 +2398,6 @@ and u_expr st = Expr.Quote (b,ref None,false,c,d) // isFromQueryExpression=false | _ -> ufailwith st "u_expr" -#if INCLUDE_METADATA_WRITER and p_static_optimization_constraint x st = match x with | TTyconEqualsTycon (a,b) -> p_byte 0 st; p_tup2 p_typ p_typ (a,b) st @@ -2497,7 +2409,6 @@ and p_method (TObjExprMethod (a,b,c,d,e,f)) st = p_tup6 p_slotsig p_attribs p_ty and p_methods x st = p_list p_method x st and p_intf x st = p_tup2 p_typ p_methods x st and p_intfs x st = p_list p_intf x st -#endif and u_static_optimization_constraint st = let tag = u_byte st @@ -2524,7 +2435,6 @@ and u_intf st = u_tup2 u_typ u_methods st and u_intfs st = u_list u_intf st -#if INCLUDE_METADATA_WRITER let _ = fill_p_binds (p_List p_bind) let _ = fill_p_targets (p_array p_target) let _ = fill_p_constraints (p_list p_static_optimization_constraint) @@ -2533,7 +2443,6 @@ let _ = fill_p_Expr_hole p_expr let _ = fill_p_Exprs (p_List p_expr) let _ = fill_p_attribs (p_list p_attrib) let _ = fill_p_Vals (p_list p_Val) -#endif let _ = fill_u_binds (u_List u_bind) let _ = fill_u_targets (u_array u_target) @@ -2547,11 +2456,9 @@ let _ = fill_u_Vals (u_list u_Val) // Pickle/unpickle F# interface data //--------------------------------------------------------------------------- -#if INCLUDE_METADATA_WRITER let pickleModuleOrNamespace mspec st = p_tycon_spec mspec st let pickleCcuInfo minfo st = p_tup4 pickleModuleOrNamespace p_string p_bool (p_space 3) (minfo.mspec, minfo.compileTimeWorkingDir, minfo.usesQuotations,()) st -#endif let unpickleModuleOrNamespace st = u_tycon_spec st diff --git a/src/fsharp/TastPickle.fsi b/src/fsharp/TastPickle.fsi index e8dc0ddbd9..ec4acc1c0f 100644 --- a/src/fsharp/TastPickle.fsi +++ b/src/fsharp/TastPickle.fsi @@ -24,7 +24,6 @@ type PickledDataWithReferences<'RawData> = /// Like Fixup but loader may return None, in which case there is no fixup. member OptionalFixup: (CcuReference -> CcuThunk option) -> 'RawData -#if INCLUDE_METADATA_WRITER /// The type of state written to by picklers type WriterState @@ -84,7 +83,6 @@ val internal pickleCcuInfo : pickler /// Serialize an arbitrary object using the given pickler val pickleObjWithDanglingCcus : string -> TcGlobals -> scope:CcuThunk -> pickler<'T> -> 'T -> byte[] -#endif /// The type of state unpicklers read from type ReaderState diff --git a/src/fsharp/TcGlobals.fs b/src/fsharp/TcGlobals.fs index 9c5a5ec530..c1f0655523 100755 --- a/src/fsharp/TcGlobals.fs +++ b/src/fsharp/TcGlobals.fs @@ -13,14 +13,11 @@ 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 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.ErrorLogger -open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.PrettyNaming @@ -161,7 +158,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d mlCompatibility: bool, isInteractive:bool, // The helper to find system types amongst referenced DLLs tryFindSysTypeCcu, - emitDebugInfoInQuotations: bool, usesMscorlib: bool, noDebugData: bool) = + emitDebugInfoInQuotations: bool, noDebugData: bool) = let vara = NewRigidTypar "a" envRange let varb = NewRigidTypar "b" envRange @@ -676,54 +673,52 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d let addFieldNeverAttrs (fdef:ILFieldDef) = {fdef with CustomAttrs = addNeverAttrs fdef.CustomAttrs} let mkDebuggerTypeProxyAttribute (ty : ILType) = mkILCustomAttribute ilg (findSysILTypeRef tname_DebuggerTypeProxyAttribute, [ilg.typ_Type], [ILAttribElem.TypeRef (Some ty.TypeRef)], []) + let entries1 = + [| "Int32" , v_int_tcr + "IntPtr" , v_nativeint_tcr + "UIntPtr" , v_unativeint_tcr + "Int16" , v_int16_tcr + "Int64" , v_int64_tcr + "UInt16" , v_uint16_tcr + "UInt32" , v_uint32_tcr + "UInt64" , v_uint64_tcr + "SByte" , v_sbyte_tcr + "Decimal" , v_decimal_tcr + "Byte" , v_byte_tcr + "Boolean" , v_bool_tcr + "String" , v_string_tcr + "Object" , v_obj_tcr + "Exception", v_exn_tcr + "Char" , v_char_tcr + "Double" , v_float_tcr + "Single" , v_float32_tcr |] + |> Array.map (fun (nm, tcr) -> + let ty = mkNonGenericTy tcr + nm, findSysTyconRef sys nm, (fun _ -> ty)) + + let entries2 = + [| + "FSharpFunc`2" , v_fastFunc_tcr , (fun tinst -> mkFunTy (List.item 0 tinst) (List.item 1 tinst)) + "Tuple`2" , v_ref_tuple2_tcr , decodeTupleTy tupInfoRef + "Tuple`3" , v_ref_tuple3_tcr , decodeTupleTy tupInfoRef + "Tuple`4" , v_ref_tuple4_tcr , decodeTupleTy tupInfoRef + "Tuple`5" , v_ref_tuple5_tcr , decodeTupleTy tupInfoRef + "Tuple`6" , v_ref_tuple6_tcr , decodeTupleTy tupInfoRef + "Tuple`7" , v_ref_tuple7_tcr , decodeTupleTy tupInfoRef + "Tuple`8" , v_ref_tuple8_tcr , decodeTupleTy tupInfoRef + "ValueTuple`2" , v_struct_tuple2_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`3" , v_struct_tuple3_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`4" , v_struct_tuple4_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`5" , v_struct_tuple5_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`6" , v_struct_tuple6_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`7" , v_struct_tuple7_tcr , decodeTupleTy tupInfoStruct + "ValueTuple`8" , v_struct_tuple8_tcr , decodeTupleTy tupInfoStruct |] + // Build a map that uses the "canonical" F# type names and TyconRef's for these // in preference to the .NET type names. Doing this normalization is a fairly performance critical // piece of code as it is frequently invoked in the process of converting .NET metadata to F# internal // compiler data structures (see import.fs). - let betterTyconRefMap = - begin - let entries1 = - [| "Int32" , v_int_tcr - "IntPtr" , v_nativeint_tcr - "UIntPtr" , v_unativeint_tcr - "Int16" , v_int16_tcr - "Int64" , v_int64_tcr - "UInt16" , v_uint16_tcr - "UInt32" , v_uint32_tcr - "UInt64" , v_uint64_tcr - "SByte" , v_sbyte_tcr - "Decimal" , v_decimal_tcr - "Byte" , v_byte_tcr - "Boolean" , v_bool_tcr - "String" , v_string_tcr - "Object" , v_obj_tcr - "Exception", v_exn_tcr - "Char" , v_char_tcr - "Double" , v_float_tcr - "Single" , v_float32_tcr |] - |> Array.map (fun (nm, tcr) -> - let ty = mkNonGenericTy tcr - nm, findSysTyconRef sys nm, (fun _ -> ty)) - - let entries2 = - [| - "FSharpFunc`2" , v_fastFunc_tcr , (fun tinst -> mkFunTy (List.item 0 tinst) (List.item 1 tinst)) - "Tuple`2" , v_ref_tuple2_tcr , decodeTupleTy tupInfoRef - "Tuple`3" , v_ref_tuple3_tcr , decodeTupleTy tupInfoRef - "Tuple`4" , v_ref_tuple4_tcr , decodeTupleTy tupInfoRef - "Tuple`5" , v_ref_tuple5_tcr , decodeTupleTy tupInfoRef - "Tuple`6" , v_ref_tuple6_tcr , decodeTupleTy tupInfoRef - "Tuple`7" , v_ref_tuple7_tcr , decodeTupleTy tupInfoRef - "Tuple`8" , v_ref_tuple8_tcr , decodeTupleTy tupInfoRef - "ValueTuple`2" , v_struct_tuple2_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`3" , v_struct_tuple3_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`4" , v_struct_tuple4_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`5" , v_struct_tuple5_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`6" , v_struct_tuple6_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`7" , v_struct_tuple7_tcr , decodeTupleTy tupInfoStruct - "ValueTuple`8" , v_struct_tuple8_tcr , decodeTupleTy tupInfoStruct |] - - let entries = Array.append entries1 entries2 + let buildTyconMapper (entries: (string * TyconRef * _)[]) = if compilingFslib then // This map is for use when building FSharp.Core.dll. The backing Tycon's may not yet exist for // the TyconRef's we have in our hands, hence we can't dereference them to find their stamps. @@ -762,8 +757,10 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d let key = tcref2.Stamp if dict.ContainsKey key then Some(dict.[key] tinst) else None) - end - + + let betterTyconRefMapper = buildTyconMapper (Array.append entries1 entries2) + + let decodeTyconRefMapper = buildTyconMapper entries2 override x.ToString() = "" member __.ilg=ilg @@ -938,6 +935,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member val tcref_System_Collections_IEqualityComparer = findSysTyconRef sysCollections "IEqualityComparer" member val tcref_System_Collections_Generic_IEqualityComparer = findSysTyconRef sysGenerics "IEqualityComparer`1" member val tcref_System_Collections_Generic_Dictionary = findSysTyconRef sysGenerics "Dictionary`2" + member val tcref_System_Collections_Generic_IDictionary = findSysTyconRef sysGenerics "IDictionary`2" member val tcref_System_IComparable = findSysTyconRef sys "IComparable" member val tcref_System_IStructuralComparable = findSysTyconRef sysCollections "IStructuralComparable" @@ -946,7 +944,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member val tcref_LanguagePrimitives = mk_MFCore_tcref fslibCcu "LanguagePrimitives" - + member val tcref_System_Collections_Generic_List = findSysTyconRef sysGenerics "List`1" member val tcref_System_Collections_Generic_IList = findSysTyconRef sysGenerics "IList`1" member val tcref_System_Collections_Generic_IReadOnlyList = findSysTyconRef sysGenerics "IReadOnlyList`1" member val tcref_System_Collections_Generic_ICollection = findSysTyconRef sysGenerics "ICollection`1" @@ -1054,7 +1052,8 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member val attrib_SecuritySafeCriticalAttribute = findSysAttrib "System.Security.SecuritySafeCriticalAttribute" member val attrib_ComponentModelEditorBrowsableAttribute = findSysAttrib "System.ComponentModel.EditorBrowsableAttribute" - member __.better_tcref_map = betterTyconRefMap + member __.betterTyconRefMap = betterTyconRefMapper + member __.decodeTyconRefMap = decodeTyconRefMapper member __.new_decimal_info = v_new_decimal_info member __.seq_info = v_seq_info member val seq_vref = (ValRefForIntrinsic v_seq_info) @@ -1236,7 +1235,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d member __.suppressed_types = v_suppressed_types /// Are we assuming all code gen is for F# interactive, with no static linking member __.isInteractive=isInteractive - member __.usesMscorlib = usesMscorlib member __.FindSysTyconRef path nm = findSysTyconRef path nm member __.TryFindSysTyconRef path nm = tryFindSysTyconRef path nm diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 595eab9dfa..9ca319dfbf 100755 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -71,6 +71,7 @@ let mkUnitDelayLambda (g: TcGlobals) m e = exception BakedInMemberConstraintName of string * range exception FunctionExpected of DisplayEnv * TType * range exception NotAFunction of DisplayEnv * TType * range * range +exception NotAFunctionButIndexer of DisplayEnv * TType * string option * range * range exception Recursion of DisplayEnv * Ident * TType * TType * range exception RecursiveUseCheckedAtRuntime of DisplayEnv * ValRef * range exception LetRecEvaluatedOutOfOrder of DisplayEnv * ValRef * ValRef * range @@ -493,7 +494,7 @@ let AddModuleAbbreviationAndReport tcSink scopem id modrefs env = ModifyNameResEnv (fun nenv -> AddModuleAbbrevToNameEnv id nenv modrefs) env CallEnvSink tcSink (scopem,env.NameEnv,env.eAccessRights) let item = Item.ModuleOrNamespaces modrefs - CallNameResolutionSink tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) env let AddLocalSubModule g amap m env (modul:ModuleOrNamespace) = @@ -515,7 +516,7 @@ let AddDeclaredTypars check typars env = let env = ModifyNameResEnv (fun nenv -> AddDeclaredTyparsToNameEnv check nenv typars) env RegisterDeclaredTypars typars env -/// Compilation environment for typechecking a compilation unit. Contains the +/// Compilation environment for typechecking a single file in an assembly. Contains the /// F# and .NET modules loaded from disk, the search path, a table indicating /// how to List.map F# modules to assembly names, and some nasty globals /// related to type inference. These are: @@ -533,6 +534,9 @@ type cenv = /// Checks to run after all inference is complete. mutable postInferenceChecks: ResizeArray unit> + /// Set to true if this file causes the creation of generated provided types. + mutable createsGeneratedProvidedTypes: bool + /// Are we in a script? if so relax the reporting of discarded-expression warnings at the top level isScript: bool @@ -572,6 +576,7 @@ type cenv = amap = amap recUses = ValMultiMap<_>.Empty postInferenceChecks = ResizeArray() + createsGeneratedProvidedTypes = false topCcu = topCcu isScript = isScript css = ConstraintSolverState.New(g,amap,infoReader,tcVal) @@ -701,7 +706,7 @@ let UnifyRefTupleType contextInfo cenv denv m ty ps = let ptys = if isRefTupleTy cenv.g ty then let ptys = destRefTupleTy cenv.g ty - if (List.length ps) = (List.length ptys) then ptys + if List.length ps = List.length ptys then ptys else NewInferenceTypes ps else NewInferenceTypes ps @@ -719,7 +724,7 @@ let UnifyStructTupleType contextInfo cenv denv m ty ps = let ptys = if isStructTupleTy cenv.g ty then let ptys = destStructTupleTy cenv.g ty - if (List.length ps) = (List.length ptys) then ptys + if List.length ps = List.length ptys then ptys else NewInferenceTypes ps else NewInferenceTypes ps AddCxTypeEqualsType contextInfo denv cenv.css m ty (TType_tuple (tupInfoStruct, ptys)) @@ -818,72 +823,18 @@ module AttributeTargets = let Top = AttributeTargets.Assembly ||| AttributeTargets.Module ||| AttributeTargets.Method -let SettersOfPropInfos (pinfos:PropInfo list) = pinfos |> List.choose (fun pinfo -> if pinfo.HasSetter then Some(pinfo.SetterMethod,Some pinfo) else None) -let GettersOfPropInfos (pinfos:PropInfo list) = pinfos |> List.choose (fun pinfo -> if pinfo.HasGetter then Some(pinfo.GetterMethod,Some pinfo) else None) - -// Specifies if overload resolution needs to notify Language Service of overload resolution result. -// In contrast with similar types in nameres, this type is in terms of infos instead of items. -// Convertors from Items to infos for methods and properties are provided. -[] -type AfterTcOverloadResolution = - // Notification is not needed - | DoNothing - // Notify the tcSink - | SendToSink of ((MethInfo * PropInfo option) -> unit) * IfOverloadResolutionFails - // Find override among given overrides and notify the tcSink - // The list contains candidate overrides. - | ReplaceWithOverrideAndSendToSink of (MethInfo * PropInfo option) list * ((MethInfo * PropInfo option) -> unit) * IfOverloadResolutionFails - - static member ForMethods afterOverloadResolution = - match afterOverloadResolution with - | AfterOverloadResolution.DoNothing -> - AfterTcOverloadResolution.DoNothing - | AfterOverloadResolution.SendToSink(callSink,fallback) -> - AfterTcOverloadResolution.SendToSink ((fun (minfo,_) -> Item.MethodGroup(minfo.LogicalName,[minfo],None) |> callSink), fallback) - | AfterOverloadResolution.ReplaceWithOverrideAndSendToSink (Item.MethodGroup(_,overridenMinfos,_orig), callSink,fallback) -> - AfterTcOverloadResolution.ReplaceWithOverrideAndSendToSink - ((overridenMinfos |> List.map (fun minfo -> minfo,None)),(fun (minfo,_) -> Item.MethodGroup(minfo.LogicalName,[minfo],None) |> callSink),fallback) - | _ -> error(InternalError("Name resolution does not match overriden for method groups", range0)) - - static member ForProperties name gettersOrSetters afterOverloadResolution = - let sendPropertyToSink callSink = - fun (_,pinfoOpt) -> - match pinfoOpt with - | Some pinfo -> Item.Property(name,[pinfo]) |> callSink - | _ -> () - - match afterOverloadResolution with - | AfterOverloadResolution.DoNothing -> AfterTcOverloadResolution.DoNothing - | AfterOverloadResolution.SendToSink(callSink,fallback) -> AfterTcOverloadResolution.SendToSink(sendPropertyToSink callSink,fallback) - | AfterOverloadResolution.ReplaceWithOverrideAndSendToSink (Item.Property(_,pinfos),callSink,fallback) -> - AfterTcOverloadResolution.ReplaceWithOverrideAndSendToSink(gettersOrSetters pinfos, sendPropertyToSink callSink,fallback) - | AfterOverloadResolution.ReplaceWithOverrideAndSendToSink (_,_,_) -> - error(InternalError("Name resolution does not match overriden for properties",range0)) - - static member ForConstructors afterOverloadResolution = - match afterOverloadResolution with - | AfterOverloadResolution.DoNothing -> - AfterTcOverloadResolution.DoNothing - | AfterOverloadResolution.SendToSink(callSink,fallback) -> - AfterTcOverloadResolution.SendToSink ((fun (minfo,_) -> Item.CtorGroup(minfo.LogicalName,[minfo]) |> callSink), fallback) - | _ -> error(InternalError("Name resolution does not match overriden for constructor groups", range0)) - - static member ForNewConstructors tcSink (env:TcEnv) mObjTy methodName minfos = - let sendToSink refinedMinfos = - CallNameResolutionSink tcSink (mObjTy,env.NameEnv,Item.CtorGroup(methodName,refinedMinfos),Item.CtorGroup(methodName,minfos),ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) - match minfos with - | [] -> AfterTcOverloadResolution.DoNothing - | [_] -> - sendToSink minfos - AfterTcOverloadResolution.DoNothing - | _ -> - AfterTcOverloadResolution.SendToSink ((fun (minfo,_) -> sendToSink [minfo]), (fun () -> sendToSink minfos) |> IfOverloadResolutionFails) - - member this.OnOverloadResolutionFailure() = - match this with - | AfterTcOverloadResolution.DoNothing -> () - | AfterTcOverloadResolution.SendToSink(_,IfOverloadResolutionFails f) -> f() - | AfterTcOverloadResolution.ReplaceWithOverrideAndSendToSink(_,_,IfOverloadResolutionFails f) -> f() +let ForNewConstructors tcSink (env:TcEnv) mObjTy methodName meths = + let origItem = Item.CtorGroup(methodName,meths) + let callSink (item, minst) = CallNameResolutionSink tcSink (mObjTy,env.NameEnv,item,origItem,minst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + let sendToSink minst refinedMeths = callSink (Item.CtorGroup(methodName,refinedMeths),minst) + match meths with + | [] -> + AfterResolution.DoNothing + | [_] -> + sendToSink emptyTyparInst meths + AfterResolution.DoNothing + | _ -> + AfterResolution.RecordResolution (None, (fun tpinst -> callSink (origItem,tpinst)), (fun (minfo,_,minst) -> sendToSink minst [minfo]), (fun () -> callSink (origItem,emptyTyparInst))) /// Typecheck rational constant terms in units-of-measure exponents @@ -1094,7 +1045,7 @@ let MakeMemberDataAndMangledNameForMemberVal(g,tcref,isExtrinsic,attrs,optImplSl if n<>3 && opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonTripleArgument(name,n),m)) if not (isNil otherArgs) then warning(Error(FSComp.SR.memberOperatorDefinitionWithCurriedArguments(name),m)) - if IsMangledOpName id.idText && isExtrinsic then + if isExtrinsic && IsMangledOpName id.idText then warning(Error(FSComp.SR.tcMemberOperatorDefinitionInExtrinsic(),id.idRange)) ValMemberInfoTransient(memberInfo,logicalName,compiledName) @@ -1325,7 +1276,7 @@ let PublishModuleDefn cenv env mspec = if intoFslibCcu then mty else mty.AddEntity mspec) let item = Item.ModuleOrNamespaces([mkLocalModRef mspec]) - CallNameResolutionSink cenv.tcSink (mspec.Range,env.NameEnv,item,item,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mspec.Range,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) let PublishTypeDefn cenv env tycon = UpdateAccModuleOrNamespaceType cenv env (fun _ mty -> @@ -1550,7 +1501,7 @@ let MakeAndPublishVal cenv env (altActualParent,inSig,declKind,vrec,(ValScheme(i 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,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) + 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) = @@ -1583,7 +1534,7 @@ let MakeSafeInitField (g: TcGlobals) env m isStatic = // Make the "delayed reference" boolean value recording the safe initialization of a type in a hierarchy where there is a HasSelfReferentialConstructor let ComputeInstanceSafeInitInfo cenv env m thisTy = if InstanceMembersNeedSafeInitCheck cenv m thisTy then - let rfield = MakeSafeInitField cenv.g env m false + let rfield = MakeSafeInitField cenv.g env m false let tcref = tcrefOfAppTy cenv.g thisTy SafeInitField (mkRecdFieldRef tcref rfield.Name, rfield) else @@ -1625,7 +1576,7 @@ let AdjustAndForgetUsesOfRecValue cenv (vrefTgt: ValRef) (valScheme : ValScheme) // Keep any values for explicit type arguments let fixedUpExpr = let vrefFlags,tyargs0 = - match !fixupPoint with + match fixupPoint.Value with | Expr.App(Expr.Val (_,vrefFlags,_),_,tyargs0,[],_) -> vrefFlags,tyargs0 | Expr.Val(_,vrefFlags,_) -> vrefFlags,[] | _ -> @@ -1634,7 +1585,7 @@ let AdjustAndForgetUsesOfRecValue cenv (vrefTgt: ValRef) (valScheme : ValScheme) let ityargs = generalizeTypars (List.drop (List.length tyargs0) generalizedTypars) primMkApp (Expr.Val (vrefTgt,vrefFlags,m),fty) (tyargs0 @ ityargs) [] m - fixupPoint := fixedUpExpr) + fixupPoint.Value <- fixedUpExpr) vrefTgt.Deref.SetValRec ValNotInRecScope cenv.recUses <- cenv.recUses.Remove vrefTgt.Deref @@ -1811,7 +1762,7 @@ let CombineSyntacticAndInferredArities g declKind rhsExpr prelimScheme = else let (ValReprInfo (_,curriedArgInfosFromExpression,_)) = - InferArityOfExpr g (GeneralizedTypeForTypeScheme typeScheme) argAttribs retAttribs rhsExpr + InferArityOfExpr g AllowTypeDirectedDetupling.Yes (GeneralizedTypeForTypeScheme typeScheme) argAttribs retAttribs rhsExpr // Choose between the syntactic arity and the expression-inferred arity // If the syntax specifies an eliminated unit arg, then use that @@ -1881,9 +1832,9 @@ let MakeAndPublishSimpleVals cenv env m names mergeNamesInOneNameresEnv = let sink = { new ITypecheckResultsSink with member this.NotifyEnvWithScope(_, _, _) = () // ignore EnvWithScope reports - member this.NotifyNameResolution(pos, a, b, occurence, denv, nenv, ad, m, replacing) = + member this.NotifyNameResolution(pos, item, itemGroup, itemTyparInst, occurence, denv, nenv, ad, m, replacing) = if not m.IsSynthetic then - nameResolutions.Add(pos, a, b, occurence, denv, nenv, ad, m, replacing) + nameResolutions.Add(pos, item, itemGroup, itemTyparInst, occurence, denv, nenv, ad, m, replacing) member this.NotifyExprHasType(_, _, _, _, _, _) = assert false // no expr typings in MakeSimpleVals member this.NotifyFormatSpecifierLocation(_, _) = () member this.CurrentSource = None } @@ -1892,11 +1843,11 @@ let MakeAndPublishSimpleVals cenv env m names mergeNamesInOneNameresEnv = MakeSimpleVals cenv env names if nameResolutions.Count <> 0 then - let (_, _, _, _, _, _, ad, m1, _replacing) = nameResolutions.[0] + let (_, _, _, _, _, _, _, ad, m1, _replacing) = nameResolutions.[0] // mergedNameEnv - name resolution env that contains all names // mergedRange - union of ranges of names let mergedNameEnv, mergedRange = - ((env.NameEnv, m1), nameResolutions) ||> Seq.fold (fun (nenv, merged) (_pos, item, _b, _occurence, _denv, _nenv, _ad, m, _) -> + ((env.NameEnv, m1), nameResolutions) ||> Seq.fold (fun (nenv, merged) (_, item, _, _, _, _, _, _, m, _) -> // MakeAndPublishVal creates only Item.Value let item = match item with Item.Value(item) -> item | _ -> failwith "impossible" (AddFakeNamedValRefToNameEnv item.DisplayName nenv item), (unionRanges m merged) @@ -1904,8 +1855,8 @@ let MakeAndPublishSimpleVals cenv env m names mergeNamesInOneNameresEnv = // send notification about mergedNameEnv CallEnvSink cenv.tcSink (mergedRange, mergedNameEnv, ad) // call CallNameResolutionSink for all captured name resolutions using mergedNameEnv - for (_, item, b, occurence, denv, _nenv, ad, m, _replacing) in nameResolutions do - CallNameResolutionSink cenv.tcSink (m, mergedNameEnv, item, b, occurence, denv, ad) + for (_, item, itemGroup, itemTyparInst, occurence, denv, _nenv, ad, m, _replacing) in nameResolutions do + CallNameResolutionSink cenv.tcSink (m, mergedNameEnv, item, itemGroup, itemTyparInst, occurence, denv, ad) values,vspecMap @@ -1931,12 +1882,12 @@ let FreshenTyconRef m rigid (tcref:TyconRef) declaredTyconTypars = let FreshenPossibleForallTy g m rigid ty = let tpsorig,tau = tryDestForallTy g ty if isNil tpsorig then - [],[],tau + [],[],[],tau else // tps may be have been equated to other tps in equi-recursive type inference and units-of-measure type inference. Normalize them here let tpsorig = NormalizeDeclaredTyparsForEquiRecursiveInference g tpsorig let tps,renaming,tinst = CopyAndFixupTypars m rigid tpsorig - tps,tinst,instType renaming tau + tpsorig,tps,tinst,instType renaming tau let infoOfTyconRef m (tcref:TyconRef) = let tps,renaming,tinst = FreshenTypeInst m (tcref.Typars m) @@ -2018,7 +1969,7 @@ let BuildFieldMap cenv env isPartial ty flds m = // Record the precise resolution of the field for intellisense let item = FreshenRecdFieldRef cenv.nameResolver m fref2 - CallNameResolutionSink cenv.tcSink ((snd fld).idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink ((snd fld).idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,ad) CheckRecdFieldAccessible cenv.amap m env.eAccessRights fref2 |> ignore CheckFSharpAttributes cenv.g fref2.PropertyAttribs m |> CommitOperationResult @@ -2080,8 +2031,9 @@ let TcUnionCaseOrExnField cenv (env: TcEnv) ty1 m c n funcs = | (Item.UnionCase _ | Item.ExnCase _) as item -> ApplyUnionCaseOrExn funcs m cenv env ty1 item | _ -> error(Error(FSComp.SR.tcUnknownUnion(),m)) - if n >= List.length argtys then - error (UnionCaseWrongNumberOfArgs(env.DisplayEnv,List.length argtys,n,m)) + let argstysLength = List.length argtys + if n >= argstysLength then + error (UnionCaseWrongNumberOfArgs(env.DisplayEnv,argstysLength,n,m)) let ty2 = List.item n argtys mkf,ty2 @@ -2112,24 +2064,16 @@ type GeneralizeConstrainedTyparOptions = module GeneralizationHelpers = let ComputeUngeneralizableTypars env = - // This is just a List.fold. Unfolded here to enable better profiling - let rec loop acc (items: UngeneralizableItem list) = - match items with - | [] -> acc - | item::rest -> - let acc = - if item.WillNeverHaveFreeTypars then - acc - else - let ftps = item.GetFreeTyvars().FreeTypars - if ftps.IsEmpty then - acc - else - // These union operations are a performance sore point - unionFreeTypars ftps acc - loop acc rest + let acc = Collections.Generic.List() + for item in env.eUngeneralizableItems do + if not item.WillNeverHaveFreeTypars then + let ftps = item.GetFreeTyvars().FreeTypars + if not ftps.IsEmpty then + for ftp in ftps do + acc.Add(ftp) + + Zset.Create(typarOrder, acc) - loop emptyFreeTypars env.eUngeneralizableItems let ComputeUnabstractableTycons env = let acc_in_free_item acc (item: UngeneralizableItem) = @@ -2176,9 +2120,11 @@ module GeneralizationHelpers = && List.forall (IsGeneralizableValue g) args | Expr.LetRec(binds,body,_,_) -> + binds |> List.forall (fun b -> not b.Var.IsMutable) && binds |> List.forall (fun b -> IsGeneralizableValue g b.Expr) && IsGeneralizableValue g body | Expr.Let(bind,body,_,_) -> + not bind.Var.IsMutable && IsGeneralizableValue g bind.Expr && IsGeneralizableValue g body @@ -2575,8 +2521,8 @@ module BindingNormalization = (match memberFlagsOpt with | None -> false | Some memberFlags -> - not (memberFlags.MemberKind = MemberKind.Constructor) && - not (memberFlags.MemberKind = MemberKind.ClassConstructor)) -> + memberFlags.MemberKind <> MemberKind.Constructor && + memberFlags.MemberKind <> MemberKind.ClassConstructor) -> NormalizeStaticMemberBinding cenv (Option.get memberFlagsOpt) valSynData id vis inferredTyparDecls [] m rhsExpr | SynPat.Typed(pat',x,y) -> @@ -2689,7 +2635,7 @@ let FreshenObjectArgType cenv m rigid tcref isExtrinsic declaredTyconTypars = #endif // Struct members have a byref 'this' type (unless they are extrinsic extension members) let thisTy = - if tcref.IsStructOrEnumTycon && not isExtrinsic then + if not isExtrinsic && tcref.IsStructOrEnumTycon then mkByrefTy cenv.g objTy else objTy @@ -2752,99 +2698,105 @@ let TcValEarlyGeneralizationConsistencyCheck cenv (env:TcEnv) (v:Val, vrec, tins /// | CtorValUsedAsSuperInit "inherit Panel()" /// | CtorValUsedAsSelfInit "new() = new OwnType(3)" /// | VSlotDirectCall "base.OnClick(eventArgs)" -let TcVal checkAttributes cenv env tpenv (vref:ValRef) optInst m = - let v = vref.Deref - let vrec = v.RecursiveValInfo - v.SetHasBeenReferenced() - CheckValAccessible m env.eAccessRights vref - if checkAttributes then - CheckValAttributes cenv.g vref m |> CommitOperationResult - let vty = vref.Type - // byref-typed values get dereferenced - if isByrefTy cenv.g vty then - let isSpecial = true - mkAddrGet m vref, isSpecial, destByrefTy cenv.g vty, [], tpenv - else - match v.LiteralValue with - | Some c -> - // Literal values go to constants - let isSpecial = true - // The value may still be generic, e.g. - // [] - // let Null = null - let _,tinst,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty - Expr.Const(c,m,tau),isSpecial,tau,tinst,tpenv - - | None -> - // References to 'this' in classes get dereferenced from their implicit reference cell and poked - if v.BaseOrThisInfo = CtorThisVal && isRefCellTy cenv.g vty then - let exprForVal = exprForValRef m vref - //if AreWithinCtorPreConstruct env then - // warning(SelfRefObjCtor(AreWithinImplicitCtor env, m)) - - let ty = destRefCellTy cenv.g vty +let TcVal checkAttributes cenv env tpenv (vref:ValRef) optInst optAfterResolution m = + let (tpsorig,_, _, _, tinst, _) as res = + let v = vref.Deref + let vrec = v.RecursiveValInfo + v.SetHasBeenReferenced() + CheckValAccessible m env.eAccessRights vref + if checkAttributes then + CheckValAttributes cenv.g vref m |> CommitOperationResult + let vty = vref.Type + // byref-typed values get dereferenced + if isByrefTy cenv.g vty then + let isSpecial = true + [], mkAddrGet m vref, isSpecial, destByrefTy cenv.g vty, [], tpenv + else + match v.LiteralValue with + | Some c -> + // Literal values go to constants let isSpecial = true - mkCallCheckThis cenv.g m ty (mkRefCellGet cenv.g m ty exprForVal), isSpecial, ty, [], tpenv - else - // Instantiate the value - let vrefFlags,tinst,tau,tpenv = - // Have we got an explicit instantiation? - match optInst with - // No explicit instantiation (the normal case) - | None -> - if HasFSharpAttribute cenv.g cenv.g.attrib_RequiresExplicitTypeArgumentsAttribute v.Attribs then - errorR(Error(FSComp.SR.tcFunctionRequiresExplicitTypeArguments(v.DisplayName),m)) - - match vrec with - | ValInRecScope false -> - let tps,tau = vref.TypeScheme - let tinst = tps |> List.map mkTyparTy - NormalValUse,tinst,tau,tpenv - | ValInRecScope true - | ValNotInRecScope -> - let _,tinst,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty - NormalValUse,tinst,tau,tpenv + // The value may still be generic, e.g. + // [] + // let Null = null + let tpsorig,_,tinst,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty + tpsorig, Expr.Const(c,m,tau),isSpecial,tau,tinst,tpenv - // If we have got an explicit instantiation then use that - | Some(vrefFlags,checkTys) -> - let checkInst (tinst:TypeInst) = - if not v.IsMember && not v.PermitsExplicitTypeInstantiation && tinst.Length > 0 && v.Typars.Length > 0 then - warning(Error(FSComp.SR.tcDoesNotAllowExplicitTypeArguments(v.DisplayName),m)) + | None -> + // References to 'this' in classes get dereferenced from their implicit reference cell and poked + if v.BaseOrThisInfo = CtorThisVal && isRefCellTy cenv.g vty then + let exprForVal = exprForValRef m vref + //if AreWithinCtorPreConstruct env then + // warning(SelfRefObjCtor(AreWithinImplicitCtor env, m)) + + let ty = destRefCellTy cenv.g vty + let isSpecial = true + [], mkCallCheckThis cenv.g m ty (mkRefCellGet cenv.g m ty exprForVal), isSpecial, ty, [], tpenv + else + // Instantiate the value + let tpsorig,vrefFlags,tinst,tau,tpenv = + // Have we got an explicit instantiation? + match optInst with + // No explicit instantiation (the normal case) + | None -> + if HasFSharpAttribute cenv.g cenv.g.attrib_RequiresExplicitTypeArgumentsAttribute v.Attribs then + errorR(Error(FSComp.SR.tcFunctionRequiresExplicitTypeArguments(v.DisplayName),m)) + match vrec with | ValInRecScope false -> let tpsorig,tau = vref.TypeScheme - let (tinst:TypeInst),tpenv = checkTys tpenv (tpsorig |> List.map (fun tp -> tp.Kind)) - checkInst tinst - if tpsorig.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tpsorig.Length, tinst.Length),m)) - let tau2 = instType (mkTyparInst tpsorig tinst) tau - (tpsorig, tinst) ||> List.iter2 (fun tp ty -> - try UnifyTypes cenv env m (mkTyparTy tp) ty - with _ -> error (Recursion(env.DisplayEnv,v.Id,tau2,tau,m))) - vrefFlags,tinst,tau2,tpenv + let tinst = tpsorig |> List.map mkTyparTy + tpsorig,NormalValUse,tinst,tau,tpenv | ValInRecScope true | ValNotInRecScope -> - let tps,tptys,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty - //dprintfn "After Freshen: tau = %s" (Layout.showL (typeL tau)) - let (tinst:TypeInst),tpenv = checkTys tpenv (tps |> List.map (fun tp -> tp.Kind)) - checkInst tinst - //dprintfn "After Check: tau = %s" (Layout.showL (typeL tau)) - if tptys.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tps.Length, tinst.Length),m)) - List.iter2 (UnifyTypes cenv env m) tptys tinst - TcValEarlyGeneralizationConsistencyCheck cenv env (v, vrec, tinst, vty, tau, m) - - //dprintfn "After Unify: tau = %s" (Layout.showL (typeL tau)) - vrefFlags,tinst,tau,tpenv + let tpsorig,_,tinst,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty + tpsorig,NormalValUse,tinst,tau,tpenv + + // If we have got an explicit instantiation then use that + | Some(vrefFlags,checkTys) -> + let checkInst (tinst:TypeInst) = + if not v.IsMember && not v.PermitsExplicitTypeInstantiation && tinst.Length > 0 && v.Typars.Length > 0 then + warning(Error(FSComp.SR.tcDoesNotAllowExplicitTypeArguments(v.DisplayName),m)) + match vrec with + | ValInRecScope false -> + let tpsorig,tau = vref.TypeScheme + let (tinst:TypeInst),tpenv = checkTys tpenv (tpsorig |> List.map (fun tp -> tp.Kind)) + checkInst tinst + if tpsorig.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tpsorig.Length, tinst.Length),m)) + let tau2 = instType (mkTyparInst tpsorig tinst) tau + (tpsorig, tinst) ||> List.iter2 (fun tp ty -> + try UnifyTypes cenv env m (mkTyparTy tp) ty + with _ -> error (Recursion(env.DisplayEnv,v.Id,tau2,tau,m))) + tpsorig,vrefFlags,tinst,tau2,tpenv + | ValInRecScope true + | ValNotInRecScope -> + let tpsorig,tps,tptys,tau = FreshenPossibleForallTy cenv.g m TyparRigidity.Flexible vty + //dprintfn "After Freshen: tau = %s" (Layout.showL (typeL tau)) + let (tinst:TypeInst),tpenv = checkTys tpenv (tps |> List.map (fun tp -> tp.Kind)) + checkInst tinst + //dprintfn "After Check: tau = %s" (Layout.showL (typeL tau)) + if tptys.Length <> tinst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tps.Length, tinst.Length),m)) + List.iter2 (UnifyTypes cenv env m) tptys tinst + TcValEarlyGeneralizationConsistencyCheck cenv env (v, vrec, tinst, vty, tau, m) + + //dprintfn "After Unify: tau = %s" (Layout.showL (typeL tau)) + tpsorig,vrefFlags,tinst,tau,tpenv - let exprForVal = Expr.Val (vref,vrefFlags,m) - let exprForVal = mkTyAppExpr m (exprForVal,vty) tinst - let isSpecial = - (match vrefFlags with NormalValUse | PossibleConstrainedCall _ -> false | _ -> true) || - valRefEq cenv.g vref cenv.g.splice_expr_vref || - valRefEq cenv.g vref cenv.g.splice_raw_expr_vref + let exprForVal = Expr.Val (vref,vrefFlags,m) + let exprForVal = mkTyAppExpr m (exprForVal,vty) tinst + let isSpecial = + (match vrefFlags with NormalValUse | PossibleConstrainedCall _ -> false | _ -> true) || + valRefEq cenv.g vref cenv.g.splice_expr_vref || + valRefEq cenv.g vref cenv.g.splice_raw_expr_vref - let exprForVal = RecordUseOfRecValue cenv vrec vref exprForVal m + let exprForVal = RecordUseOfRecValue cenv vrec vref exprForVal m - exprForVal, isSpecial, tau, tinst, tpenv + tpsorig, exprForVal, isSpecial, tau, tinst, tpenv + + match optAfterResolution with + | Some (AfterResolution.RecordResolution(_, callSink, _, _)) -> callSink (mkTyparInst tpsorig tinst) + | Some AfterResolution.DoNothing | None -> () + res /// simplified version of TcVal used in calls to BuildMethodCall (typrelns.fs) /// this function is used on typechecking step for making calls to provided methods and on optimization step (for the same purpose). @@ -2857,13 +2809,13 @@ let LightweightTcValForUsingInBuildMethodCall g (vref:ValRef) vrefFlags (vrefTyp else match v.LiteralValue with | Some c -> - let _,_,tau = FreshenPossibleForallTy g m TyparRigidity.Flexible vty + let _,_,_,tau = FreshenPossibleForallTy g m TyparRigidity.Flexible vty Expr.Const(c,m,tau),tau | None -> // Instantiate the value let tau = // If we have got an explicit instantiation then use that - let tps,tptys,tau = FreshenPossibleForallTy g m TyparRigidity.Flexible vty + let _,tps,tptys,tau = FreshenPossibleForallTy g m TyparRigidity.Flexible vty if tptys.Length <> vrefTypeInst.Length then error(Error(FSComp.SR.tcTypeParameterArityMismatch(tps.Length, vrefTypeInst.Length),m)); instType (mkTyparInst tps vrefTypeInst) tau @@ -3036,7 +2988,7 @@ let BuildPossiblyConditionalMethodCall cenv env isMutable m isProp minfo valUseF | _ -> #endif let tcVal valref valUse ttypes m = - let a,_, b, _, _ = TcVal true cenv env emptyUnscopedTyparEnv valref (Some (valUse, (fun x _ -> ttypes, x))) m + let _, a, _, b, _, _ = TcVal true cenv env emptyUnscopedTyparEnv valref (Some (valUse, (fun x _ -> ttypes, x))) None m a, b BuildMethodCall tcVal cenv.g cenv.amap isMutable m isProp minfo valUseFlags minst objArgs args @@ -3379,7 +3331,9 @@ let AnalyzeArbitraryExprAsEnumerable cenv (env: TcEnv) localAlloc m exprty expr if (AddCxTypeMustSubsumeTypeUndoIfFailed env.DisplayEnv cenv.css m ty exprty) then match tryType (mkCoerceExpr(expr,ty,expr.Range,exprty),ty) with | Result res -> Some res - | Exception e -> raise e + | Exception e -> + PreserveStackTrace(e) + raise e else None // Next try to typecheck the thing as a sequence @@ -3393,6 +3347,7 @@ let AnalyzeArbitraryExprAsEnumerable cenv (env: TcEnv) localAlloc m exprty expr match probe ienumerable with | Some res -> res | None -> + PreserveStackTrace(e) raise e @@ -3861,12 +3816,12 @@ let EliminateInitializationGraphs let fty = (g.unit_ty --> ty) let flazy,felazy = Tastops.mkCompGenLocal m v.LogicalName fty let frhs = mkUnitDelayLambda g m e - if mustHaveArity then flazy.SetValReprInfo (Some(InferArityOfExpr g fty [] [] frhs)) + if mustHaveArity then flazy.SetValReprInfo (Some(InferArityOfExpr g AllowTypeDirectedDetupling.Yes fty [] [] frhs)) let vlazy,velazy = Tastops.mkCompGenLocal m v.LogicalName vty let vrhs = (mkLazyDelayed g m ty felazy) - if mustHaveArity then vlazy.SetValReprInfo (Some(InferArityOfExpr g vty [] [] vrhs)) + if mustHaveArity then vlazy.SetValReprInfo (Some(InferArityOfExpr g AllowTypeDirectedDetupling.Yes vty [] [] vrhs)) fixupPoints |> List.iter (fun (fp,_) -> fp := mkLazyForce g (!fp).Range ty velazy) [mkInvisibleBind flazy frhs; mkInvisibleBind vlazy vrhs], @@ -4285,7 +4240,7 @@ and TcPseudoMemberSpec cenv newOk env synTypes tpenv memSpfn m = let logicalCompiledName = ComputeLogicalName id memberFlags let item = Item.ArgName (id, memberConstraintTy, None) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) TTrait(tys,logicalCompiledName,memberFlags,argtys,returnTy, ref None),tpenv | _ -> error(Error(FSComp.SR.tcInvalidConstraint(),m)) @@ -4446,7 +4401,7 @@ and TcTyparOrMeasurePar optKind cenv (env:TcEnv) newOk tpenv (Typar(id,_,_) as t | Some TyparKind.Type, TyparKind.Measure -> error (Error(FSComp.SR.tcExpectedTypeParameter(), id.idRange)); res, tpenv | _, _ -> let item = Item.TypeVar(id.idText, res) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) // record the ' as well for tokenization // CallNameResolutionSink cenv.tcSink (tp.Range.StartRange,env.NameEnv,item,item,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) res, tpenv @@ -4480,7 +4435,7 @@ and TcTyparOrMeasurePar optKind cenv (env:TcEnv) newOk tpenv (Typar(id,_,_) as t // The kind defaults to Type let tp' = NewTypar ((match optKind with None -> TyparKind.Type | Some kind -> kind), TyparRigidity.WarnIfNotRigid,tp,false,TyparDynamicReq.Yes,[],false,false) let item = Item.TypeVar(id.idText, tp') - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) tp',AddUnscopedTypar key tp' tpenv and TcTypar cenv env newOk tpenv tp = @@ -4499,7 +4454,7 @@ and TcTyparDecl cenv env (TyparDecl(synAttrs,(Typar(id,_,_) as stp))) = | None -> () let item = Item.TypeVar(id.idText, tp) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.UseInType,env.DisplayEnv,env.eAccessRights) tp @@ -4558,10 +4513,11 @@ and TcTypeOrMeasure optKind cenv newOk checkCxs occ env (tpenv:SyntacticUnscoped | SynType.LongIdentApp (ltyp,LongIdentWithDots(longId,_),_,args,_commas,_,m) -> let ad = env.eAccessRights let ltyp,tpenv = TcType cenv newOk checkCxs occ env tpenv ltyp - if not (isAppTy cenv.g ltyp) then error(Error(FSComp.SR.tcTypeHasNoNestedTypes(),m)) - let tcref,tinst = destAppTy cenv.g ltyp - let tcref = ResolveTypeLongIdentInTyconRef cenv.tcSink cenv.nameResolver env.eNameResEnv (TypeNameResolutionInfo.ResolveToTypeRefs (TypeNameResolutionStaticArgsInfo.FromTyArgs args.Length)) ad m tcref longId - TcTypeApp cenv newOk checkCxs occ env tpenv m tcref tinst args + match ltyp with + | AppTy cenv.g (tcref,tinst) -> + let tcref = ResolveTypeLongIdentInTyconRef cenv.tcSink cenv.nameResolver env.eNameResEnv (TypeNameResolutionInfo.ResolveToTypeRefs (TypeNameResolutionStaticArgsInfo.FromTyArgs args.Length)) ad m tcref longId + TcTypeApp cenv newOk checkCxs occ env tpenv m tcref tinst args + | _ -> error(Error(FSComp.SR.tcTypeHasNoNestedTypes(),m)) | SynType.Tuple(args,m) -> let isMeasure = match optKind with Some TyparKind.Measure -> true | None -> List.exists (fun (isquot,_) -> isquot) args | _ -> false @@ -4729,7 +4685,7 @@ and TcStaticConstantParameter cenv (env:TcEnv) tpenv kind (v:SynType) idOpt cont match idOpt with | Some id -> let item = Item.ArgName (id, ttype, Some container) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) | _ -> () match v with @@ -4907,31 +4863,44 @@ and TcProvidedTypeApp cenv env tpenv tcref args m = /// Note that the generic type may be a nested generic type List.ListEnumerator. /// In this case, 'args' is only the instantiation of the suffix type arguments, and pathTypeArgs gives /// the prefix of type arguments. -and TcTypeApp cenv newOk checkCxs occ env tpenv m tcref pathTypeArgs (args: SynType list) = +and TcTypeApp cenv newOk checkCxs occ env tpenv m tcref pathTypeArgs (synArgTys: SynType list) = CheckTyconAccessible cenv.amap m env.eAccessRights tcref |> ignore CheckEntityAttributes cenv.g tcref m |> CommitOperationResult #if EXTENSIONTYPING // Provided types are (currently) always non-generic. Their names may include mangled // static parameters, which are passed by the provider. - if tcref.Deref.IsProvided then TcProvidedTypeApp cenv env tpenv tcref args m else + if tcref.Deref.IsProvided then TcProvidedTypeApp cenv env tpenv tcref synArgTys m else #endif let tps,_,tinst,_ = infoOfTyconRef m tcref + // If we're not checking constraints, i.e. when we first assert the super/interfaces of a type definition, then just // clear the constraint lists of the freshly generated type variables. A little ugly but fairly localized. if checkCxs = NoCheckCxs then tps |> List.iter (fun tp -> tp.typar_constraints <- []) - if tinst.Length <> pathTypeArgs.Length + args.Length then - error (TyconBadArgs(env.DisplayEnv,tcref,pathTypeArgs.Length + args.Length,m)) - let args',tpenv = + if tinst.Length <> pathTypeArgs.Length + synArgTys.Length then + error (TyconBadArgs(env.DisplayEnv,tcref,pathTypeArgs.Length + synArgTys.Length,m)) + + let argTys,tpenv = // Get the suffix of typars - let tpsForArgs = List.drop (tps.Length - args.Length) tps + let tpsForArgs = List.drop (tps.Length - synArgTys.Length) tps let kindsForArgs = tpsForArgs |> List.map (fun tp -> tp.Kind) - TcTypesOrMeasures (Some kindsForArgs) cenv newOk checkCxs occ env tpenv args m - let args' = pathTypeArgs @ args' + TcTypesOrMeasures (Some kindsForArgs) cenv newOk checkCxs occ env tpenv synArgTys m + + // Add the types of the enclosing class for a nested type + let actualArgTys = pathTypeArgs @ argTys + if checkCxs = CheckCxs then - List.iter2 (UnifyTypes cenv env m) tinst args' - mkAppTy tcref args', tpenv + List.iter2 (UnifyTypes cenv env m) tinst actualArgTys + + // Try to decode System.Tuple --> F~ tuple types etc. + let ty = + let decode = if cenv.g.compilingFslib then None else cenv.g.decodeTyconRefMap tcref actualArgTys + match decode with + | Some res -> res + | None -> mkAppTy tcref actualArgTys + + ty, tpenv and TcTypeOrMeasureAndRecover optKind cenv newOk checkCxs occ env tpenv ty = try TcTypeOrMeasure optKind cenv newOk checkCxs occ env tpenv ty @@ -4959,13 +4928,13 @@ and TcNestedTypeApplication cenv newOk checkCxs occ env tpenv mWholeTypeApp typ and TryAdjustHiddenVarNameToCompGenName cenv env (id:Ident) altNameRefCellOpt = - match altNameRefCellOpt with - | Some ({contents = Undecided altId } as altNameRefCell) -> - match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver AllIdsOK false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] with - | Item.NewDef _ -> None // the name is not in scope as a pattern identifier (e.g. union case), so do not use the alternate ID - | _ -> altNameRefCell := Decided altId; Some altId // the name is in scope as a pattern identifier, so use the alternate ID - | Some ({contents = Decided altId }) -> Some altId - | None -> None + match altNameRefCellOpt with + | Some ({contents = Undecided altId } as altNameRefCell) -> + match ResolvePatternLongIdent cenv.tcSink cenv.nameResolver AllIdsOK false id.idRange env.eAccessRights env.eNameResEnv TypeNameResolutionInfo.Default [id] with + | Item.NewDef _ -> None // the name is not in scope as a pattern identifier (e.g. union case), so do not use the alternate ID + | _ -> altNameRefCell := Decided altId; Some altId // the name is in scope as a pattern identifier, so use the alternate ID + | Some ({contents = Decided altId }) -> Some altId + | None -> None /// Bind the patterns used in a lambda. Not clear why we don't use TcPat. and TcSimplePat optArgsOK checkCxs cenv ty env (tpenv,names,takenNames) p = @@ -4975,9 +4944,10 @@ and TcSimplePat optArgsOK checkCxs cenv ty env (tpenv,names,takenNames) p = match TryAdjustHiddenVarNameToCompGenName cenv env id altNameRefCellOpt with | Some altId -> TcSimplePat optArgsOK checkCxs cenv ty env (tpenv,names,takenNames) (SynSimplePat.Id (altId,None,compgen,isMemberThis,isOpt,m) ) | None -> - - if isOpt && not optArgsOK then errorR(Error(FSComp.SR.tcOptionalArgsOnlyOnMembers(),m)) if isOpt then + if not optArgsOK then + errorR(Error(FSComp.SR.tcOptionalArgsOnlyOnMembers(),m)) + let tyarg = NewInferenceType () UnifyTypes cenv env m ty (mkOptionTy cenv.g tyarg) @@ -5086,7 +5056,7 @@ and TcPatBindingName cenv env id ty isMemberThis vis1 topValData (inlineFlag,dec // For non-left-most paths, we register the name resolutions here if not isLeftMost && not vspec.IsCompilerGenerated && not (String.hasPrefix vspec.LogicalName "_") then let item = Item.Value(mkLocalValRef vspec) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) PBind(vspec,typeScheme)), names,takenNames @@ -5200,7 +5170,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat | Item.ActivePatternCase(APElemRef(apinfo,vref,idx)) as item -> let args = match args with SynConstructorArgs.Pats args -> args | _ -> error(Error(FSComp.SR.tcNamedActivePattern(apinfo.ActiveTags.[idx]),m)) // TOTAL/PARTIAL ACTIVE PATTERNS - let vexp, _, _, tinst, _ = TcVal true cenv env tpenv vref None m + let _, vexp, _, _, tinst, _ = TcVal true cenv env tpenv vref None None m let vexp = MakeApplicableExprWithFlex cenv env vexp let vexpty = vexp.Type @@ -5261,7 +5231,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat let activePatIdentity = if isNil activePatArgsAsSynExprs then Some (vref, tinst) else None (fun values -> // Report information about the 'active recognizer' occurrence to IDE - CallNameResolutionSink cenv.tcSink (rangeOfLid longId,env.NameEnv,item,item,ItemOccurence.Pattern,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (rangeOfLid longId,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Pattern,env.DisplayEnv,env.eAccessRights) TPat_query((activePatExpr, activePatResTys, activePatIdentity, idx, apinfo), arg' values, m)), (tpenv,names,takenNames) @@ -5298,7 +5268,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat | Item.ExnCase tref -> Some(ArgumentContainer.Type(tref)) | _ -> None let argItem = Item.ArgName (argNames.[idx], argtys.[idx], argContainerOpt) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,argItem,argItem,ItemOccurence.Pattern,env.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,argItem,argItem,emptyTyparInst,ItemOccurence.Pattern,env.DisplayEnv,ad) | _ -> error(Error(FSComp.SR.tcUnionCaseFieldCannotBeUsedMoreThanOnce(id.idText), id.idRange)) for i = 0 to nargtys - 1 do @@ -5326,7 +5296,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat let args',acc = TcPatterns warnOnUpper cenv env vFlags (tpenv,names,takenNames) argtys args (fun values -> // Report information about the case occurrence to IDE - CallNameResolutionSink cenv.tcSink (rangeOfLid longId,env.NameEnv,item,item,ItemOccurence.Pattern,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (rangeOfLid longId,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Pattern,env.DisplayEnv,env.eAccessRights) mkf m (List.map (fun f -> f values) args')), acc | Item.ILField finfo -> @@ -5353,14 +5323,16 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv,names,takenNames) ty pat checkNoArgsForLiteral() UnifyTypes cenv env m ty rfinfo.FieldType let item = Item.RecdField(rfinfo) - CallNameResolutionSink cenv.tcSink (m,env.NameEnv,item,item,ItemOccurence.Pattern,env.DisplayEnv,env.AccessRights) + // FUTURE: can we do better than emptyTyparInst here, in order to display instantiations + // of type variables in the quick info provided in the IDE. + CallNameResolutionSink cenv.tcSink (m,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Pattern,env.DisplayEnv,env.AccessRights) (fun _ -> TPat_const (lit,m)),(tpenv,names,takenNames) | Item.Value vref -> match vref.LiteralValue with | None -> error (Error(FSComp.SR.tcNonLiteralCannotBeUsedInPattern(), m)) | Some lit -> - let (_, _, vexpty, _, _) = TcVal true cenv env tpenv vref None m + let _, _, _, vexpty, _, _ = TcVal true cenv env tpenv vref None None m CheckValAccessible m env.eAccessRights vref CheckFSharpAttributes cenv.g vref.Attribs m |> CommitOperationResult checkNoArgsForLiteral() @@ -5608,15 +5580,16 @@ and TcExprThen cenv overallTy env tpenv synExpr delayed = PropagateThenTcDelayed cenv overallTy env tpenv synExpr.Range (MakeApplicableExprNoFlex cenv expr) exprty ExprAtomicFlag.NonAtomic delayed and TcExprs cenv env m tpenv flexes argtys args = - if (List.length args <> List.length argtys) then error(Error(FSComp.SR.tcExpressionCountMisMatch((List.length argtys), (List.length args)),m)) + if List.length args <> List.length argtys then error(Error(FSComp.SR.tcExpressionCountMisMatch((List.length argtys), (List.length args)),m)) (tpenv, List.zip3 flexes argtys args) ||> List.mapFold (fun tpenv (flex,ty,e) -> TcExprFlex cenv flex ty env tpenv e) -and CheckSuperInit cenv objTy m = - // Check the type is not abstract - if isAppTy cenv.g objTy && (let tcref = tcrefOfAppTy cenv.g objTy in isAbstractTycon tcref.Deref) then - errorR(Error(FSComp.SR.tcAbstractTypeCannotBeInstantiated(),m)) - +and CheckSuperInit cenv objTy m = + // Check the type is not abstract + match tryDestAppTy cenv.g objTy with + | Some tcref when isAbstractTycon tcref.Deref -> + errorR(Error(FSComp.SR.tcAbstractTypeCannotBeInstantiated(),m)) + | _ -> () //------------------------------------------------------------------------- // TcExprUndelayed @@ -5765,7 +5738,15 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) = // Always allow subsumption if a nominal type is known prior to type checking any arguments let flex = not (isTyparTy cenv.g argty) - let args',tpenv = List.mapFold (TcExprFlex cenv flex argty env) tpenv args + let first = ref true + let getInitEnv m = + if !first then + first := false + env + else + { env with eContextInfo = ContextInfo.CollectionElement (isArray,m) } + + let args',tpenv = List.mapFold (fun tpenv (x:SynExpr) -> TcExprFlex cenv flex argty (getInitEnv x.Range) tpenv x) tpenv args let expr = if isArray then Expr.Op(TOp.Array, [argty],args',m) @@ -5800,7 +5781,7 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) = // notify name resolution sink about loop variable let item = Item.Value(mkLocalValRef idv) - CallNameResolutionSink cenv.tcSink (idv.Range, env.NameEnv, item, item, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights) + CallNameResolutionSink cenv.tcSink (idv.Range, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights) let bodyExpr,tpenv = TcStmt cenv envinner tpenv body mkFastForLoop cenv.g (spBind,m,idv,startExpr,dir,finishExpr,bodyExpr), tpenv @@ -5922,12 +5903,19 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) = | SynExpr.IfThenElse (e1,e2,e3opt,spIfToThen,isRecovery,mIfToThen,m) -> let e1',tpenv = TcExprThatCantBeCtorBody cenv cenv.g.bool_ty env tpenv e1 let e2',tpenv = + let env = + match env.eContextInfo with + | ContextInfo.ElseBranchResult _ -> { env with eContextInfo = ContextInfo.ElseBranchResult e2.Range } + | _ -> + match e3opt with + | None -> { env with eContextInfo = ContextInfo.OmittedElseBranch e2.Range } + | _ -> { env with eContextInfo = ContextInfo.IfExpression e2.Range } + if not isRecovery && Option.isNone e3opt then - let env = { env with eContextInfo = ContextInfo.OmittedElseBranch e2.Range} UnifyTypes cenv env m cenv.g.unit_ty overallTy - TcExprThatCanBeCtorBody cenv overallTy env tpenv e2 - else - TcExprThatCanBeCtorBody cenv overallTy env tpenv e2 + + TcExprThatCanBeCtorBody cenv overallTy env tpenv e2 + let e3',sp2,tpenv = match e3opt with | None -> @@ -5936,6 +5924,7 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) = let env = { env with eContextInfo = ContextInfo.ElseBranchResult e3.Range } let e3',tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv e3 e3',SequencePointAtTarget,tpenv + primMkCond spIfToThen SequencePointAtTarget sp2 m overallTy e1' e2' e3', tpenv // This is for internal use in the libraries only @@ -6229,18 +6218,18 @@ and TcCtorCall isNaked cenv env tpenv overallTy objTy mObjTyOpt item superInit a if not (superInit || AreWithinCtorShape env) then CheckSuperInit cenv objTy mWholeCall - let afterTcOverloadResolution = + let afterResolution = match mObjTyOpt,afterTcOverloadResolutionOpt with - | _,Some action -> action - | Some mObjTy,None -> AfterTcOverloadResolution.ForNewConstructors cenv.tcSink env mObjTy methodName minfos - | None, _ -> AfterTcOverloadResolution.DoNothing + | _,Some action -> action + | Some mObjTy,None -> ForNewConstructors cenv.tcSink env mObjTy methodName minfos + | None, _ -> AfterResolution.DoNothing - TcMethodApplicationThen cenv env overallTy (Some objTy) tpenv None [] mWholeCall mItem methodName ad PossiblyMutates false meths afterTcOverloadResolution isSuperInit args ExprAtomicFlag.NonAtomic delayed + TcMethodApplicationThen cenv env overallTy (Some objTy) tpenv None [] mWholeCall mItem methodName ad PossiblyMutates false meths afterResolution isSuperInit args ExprAtomicFlag.NonAtomic delayed | Item.DelegateCtor typ, [arg] -> // Re-record the name resolution since we now know it's a constructor call match mObjTyOpt with - | Some mObjTy -> CallNameResolutionSink cenv.tcSink (mObjTy,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + | Some mObjTy -> CallNameResolutionSink cenv.tcSink (mObjTy,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) | None -> () TcNewDelegateThen cenv objTy env tpenv mItem mWholeCall typ arg ExprAtomicFlag.NonAtomic delayed @@ -6254,9 +6243,8 @@ and TcCtorCall isNaked cenv env tpenv overallTy objTy mObjTyOpt item superInit a // Check a record construction expression and TcRecordConstruction cenv overallTy env tpenv optOrigExpr objTy fldsList m = - let tcref = tcrefOfAppTy cenv.g objTy + let tcref,tinst = destAppTy cenv.g objTy let tycon = tcref.Deref - let tinst = argsOfAppTy cenv.g objTy UnifyTypes cenv env m overallTy objTy // Types with implicit constructors can't use record or object syntax: all constructions must go through the implicit constructor @@ -6449,7 +6437,7 @@ and TcObjectExprBinding cenv (env: TcEnv) implty tpenv (absSlotInfo,bind) = bindingRhs,logicalMethId,memberFlags | SynPat.InstanceMember(thisId,memberId,_,_,_),Some memberFlags -> - CheckMemberFlags cenv.g None NewSlotsOK OverridesOK memberFlags mBinding + CheckMemberFlags None NewSlotsOK OverridesOK memberFlags mBinding let bindingRhs = PushOnePatternToRhs cenv true (mkSynThisPatVar thisId) bindingRhs let logicalMethId = ident (ComputeLogicalName memberId memberFlags,memberId.idRange) bindingRhs,logicalMethId,memberFlags @@ -6628,10 +6616,10 @@ and TcObjectExpr cenv overallTy env tpenv (synObjTy,argopt,binds,extraImpls,mNew match item,argopt with | Item.CtorGroup(methodName,minfos),Some (arg,baseIdOpt) -> let meths = minfos |> List.map (fun minfo -> minfo,None) - let afterTcOverloadResolution = AfterTcOverloadResolution.ForNewConstructors cenv.tcSink env synObjTy.Range methodName minfos + let afterResolution = ForNewConstructors cenv.tcSink env synObjTy.Range methodName minfos let ad = env.eAccessRights - let expr,tpenv = TcMethodApplicationThen cenv env objTy None tpenv None [] mWholeExpr mObjTy methodName ad PossiblyMutates false meths afterTcOverloadResolution CtorValUsedAsSuperInit [arg] ExprAtomicFlag.Atomic [] + let expr,tpenv = TcMethodApplicationThen cenv env objTy None tpenv None [] mWholeExpr mObjTy methodName ad PossiblyMutates false meths afterResolution CtorValUsedAsSuperInit [arg] ExprAtomicFlag.Atomic [] // The 'base' value is always bound let baseIdOpt = (match baseIdOpt with None -> Some(ident("base",mObjTy)) | Some id -> Some(id)) expr,baseIdOpt,tpenv @@ -6752,7 +6740,7 @@ and TcConstExpr cenv overallTy env m tpenv c = | SynConst.UserNum (s,suffix) -> let expr = - let modName = ("NumericLiteral" + suffix) + let modName = "NumericLiteral" + suffix let ad = env.eAccessRights match ResolveLongIndentAsModuleOrNamespace ResultCollectionSettings.AtMostOneResult cenv.amap m OpenQualified env.eNameResEnv ad [ident (modName,m)] with | Result [] @@ -6760,21 +6748,25 @@ and TcConstExpr cenv overallTy env m tpenv c = | Result ((_,mref,_) :: _) -> let expr = try - let i32 = int32 s - if i32 = 0 then SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromZero",SynExpr.Const(SynConst.Unit,m),m) - elif i32 = 1 then SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromOne",SynExpr.Const(SynConst.Unit,m),m) - else SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt32",SynExpr.Const(SynConst.Int32 i32,m),m) + match int32 s with + | 0 -> SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromZero",SynExpr.Const(SynConst.Unit,m),m) + | 1 -> SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromOne",SynExpr.Const(SynConst.Unit,m),m) + | i32 -> SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt32",SynExpr.Const(SynConst.Int32 i32,m),m) with _ -> - try - let i64 = int64 s - SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt64",SynExpr.Const(SynConst.Int64 i64,m),m) - with _ -> - SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromString",SynExpr.Const(SynConst.String (s,m),m),m) - let ccu = ccuOfTyconRef mref - if Option.isSome ccu && ccuEq ccu.Value cenv.g.fslibCcu && suffix = "I" then - SynExpr.Typed(expr,SynType.LongIdent(LongIdentWithDots(pathToSynLid m ["System";"Numerics";"BigInteger"],[])),m) - else + try + let i64 = int64 s + SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt64",SynExpr.Const(SynConst.Int64 i64,m),m) + with _ -> + SynExpr.App(ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromString",SynExpr.Const(SynConst.String (s,m),m),m) + + if suffix <> "I" then expr + else + match ccuOfTyconRef mref with + | Some ccu when ccuEq ccu cenv.g.fslibCcu -> + SynExpr.Typed(expr,SynType.LongIdent(LongIdentWithDots(pathToSynLid m ["System";"Numerics";"BigInteger"],[])),m) + | _ -> + expr TcExpr cenv overallTy env tpenv expr @@ -6818,6 +6810,8 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, optOrigExpr, flds, mWholeExpr let oldv,oldve = mkCompGenLocal mWholeExpr "inputRecord" overallTy Some (olde,oldv,oldve), tpenv + let hasOrigExpr = Option.isSome optOrigExpr + let fldsList = let flds = [ @@ -6830,15 +6824,20 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, optOrigExpr, flds, mWholeExpr yield (List.frontAndBack lidwd.Lid, v) ] + match flds with | [] -> [] | _ -> - let tcref,_,fldsList = BuildFieldMap cenv env (Option.isSome optOrigExpr) overallTy flds mWholeExpr + let tcref,_,fldsList = BuildFieldMap cenv env hasOrigExpr overallTy flds mWholeExpr let _,_,_,gtyp = infoOfTyconRef mWholeExpr tcref - UnifyTypes cenv env mWholeExpr overallTy gtyp - fldsList + UnifyTypes cenv env mWholeExpr overallTy gtyp - if Option.isSome optOrigExpr && not (isRecdTy cenv.g overallTy) then + [ for n, v in fldsList do + match v with + | Some v -> yield n, v + | None -> () ] + + if hasOrigExpr && not (isRecdTy cenv.g overallTy) then errorR(Error(FSComp.SR.tcExpressionFormRequiresRecordTypes(),mWholeExpr)) if requiresCtor || haveCtor then @@ -6849,9 +6848,7 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, optOrigExpr, flds, mWholeExpr errorR(Error(FSComp.SR.tcObjectConstructionExpressionCanOnlyImplementConstructorsInObjectModelTypes(),mWholeExpr)) else if isNil flds then - let errorInfo = - if Option.isSome optOrigExpr then FSComp.SR.tcEmptyCopyAndUpdateRecordInvalid() - else FSComp.SR.tcEmptyRecordInvalid() + let errorInfo = if hasOrigExpr then FSComp.SR.tcEmptyCopyAndUpdateRecordInvalid() else FSComp.SR.tcEmptyRecordInvalid() error(Error(errorInfo,mWholeExpr)) if isFSharpObjModelTy cenv.g overallTy then errorR(Error(FSComp.SR.tcTypeIsNotARecordTypeNeedConstructor(),mWholeExpr)) @@ -6873,9 +6870,7 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, optOrigExpr, flds, mWholeExpr errorR(InternalError("Unexpected failure in getting super type",mWholeExpr)) None,tpenv - let expr,tpenv = - let fldsList = fldsList |> List.choose (fun (n, v) -> if v.IsSome then Some (n, v.Value) else None) - TcRecordConstruction cenv overallTy env tpenv optOrigExpr overallTy fldsList mWholeExpr + let expr,tpenv = TcRecordConstruction cenv overallTy env tpenv optOrigExpr overallTy fldsList mWholeExpr let expr = match superTy with @@ -7040,7 +7035,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv match interpExpr with | Expr.Val(vf,_,m) -> let item = Item.CustomBuilder (vf.DisplayName, vf) - CallNameResolutionSink cenv.tcSink (m,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (m,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) valRefEq cenv.g vf cenv.g.query_value_vref | _ -> false @@ -7247,7 +7242,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv match e with | SynExpr.App(_,_,SynExpr.App(_,_,e1,SingleIdent opName,_), e2, _) when opName.idText = customOperationJoinConditionWord nm -> let item = Item.CustomOperation (opName.idText, (fun () -> None), None) - CallNameResolutionSink cenv.tcSink (opName.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (opName.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) Some (e1,e2) | _ -> None @@ -7266,7 +7261,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv | IntoSuffix (x,intoWordRange,intoPat) -> // record the "into" as a custom operation for colorization let item = Item.CustomOperation ("into", (fun () -> None), None) - CallNameResolutionSink cenv.tcSink (intoWordRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (intoWordRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) (x,intoPat,alreadyGivenError) | _ -> if not alreadyGivenError then @@ -7400,7 +7395,7 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv match optInto with | Some (intoWordRange,optInfo) -> let item = Item.CustomOperation ("into", (fun () -> None), None) - CallNameResolutionSink cenv.tcSink (intoWordRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (intoWordRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) Some optInfo | None -> None @@ -7532,7 +7527,10 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv // Record the resolution of the custom operation for posterity let item = Item.CustomOperation (opName, (fun () -> customOpUsageText nm), Some methInfo) - CallNameResolutionSink cenv.tcSink (nm.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + + // FUTURE: consider whether we can do better than emptyTyparInst here, in order to display instantiations + // of type variables in the quick info provided in the IDE. + CallNameResolutionSink cenv.tcSink (nm.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) let mkJoinExpr keySelector1 keySelector2 innerPat e = let mSynthetic = mOpCore.MakeSynthetic() @@ -7723,7 +7721,10 @@ and TcComputationExpression cenv env overallTy mWhole interpExpr builderTy tpenv // Record the resolution of the custom operation for posterity let item = Item.CustomOperation (opName, (fun () -> customOpUsageText nm), Some methInfo) - CallNameResolutionSink cenv.tcSink (nm.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + + // FUTURE: consider whether we can do better than emptyTyparInst here, in order to display instantiations + // of type variables in the quick info provided in the IDE. + CallNameResolutionSink cenv.tcSink (nm.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) if isLikeZip || isLikeJoin || isLikeGroupJoin then errorR(Error(FSComp.SR.tcBinaryOperatorRequiresBody(nm.idText, Option.get (customOpUsageText nm)),nm.idRange)) @@ -8258,12 +8259,23 @@ and Propagate cenv overallTy env tpenv (expr: ApplicableExpr) exprty delayed = propagate delayedList' mExprAndArg resultTy | None -> let mArg = arg.Range - match arg with + match arg with | SynExpr.CompExpr _ -> () - | _ -> + | SynExpr.ArrayOrListOfSeqExpr (false,_,_) -> // 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed - error (NotAFunction(denv,overallTy,mExpr,mArg)) + if IsIndexerType cenv.g cenv.amap expr.Type then + match expr.Expr with + | Expr.Val (d,_,_) -> + error (NotAFunctionButIndexer(denv,overallTy,Some d.DisplayName,mExpr,mArg)) + | _ -> + error (NotAFunctionButIndexer(denv,overallTy,None,mExpr,mArg)) + else + error (NotAFunction(denv,overallTy,mExpr,mArg)) + | _ -> + // 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body + RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed + error (NotAFunction(denv,overallTy,mExpr,mArg)) propagate delayed expr.Range exprty @@ -8381,7 +8393,7 @@ and TcLongIdentThen cenv overallTy env tpenv (LongIdentWithDots(longId,_)) delay // Typecheck "item+projections" //------------------------------------------------------------------------- *) // mItem is the textual range covered by the long identifiers that make up the item -and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution) delayed = +and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterResolution) delayed = let delayed = delayRest rest mItem delayed let ad = env.eAccessRights match item with @@ -8459,7 +8471,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution | Item.ExnCase tref -> Some(ArgumentContainer.Type(tref)) | _ -> None let argItem = Item.ArgName (argNames.[i], argtys.[i], argContainerOpt) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,argItem,argItem,ItemOccurence.Use,env.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,argItem,argItem,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,ad) else error(Error(FSComp.SR.tcUnionCaseFieldCannotBeUsedMoreThanOnce(id.idText), id.idRange)) currentIndex <- SEEN_NAMED_ARGUMENT | None -> @@ -8538,14 +8550,14 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution // Report information about the whole expression including type arguments to VS let item = Item.Types(nm, [typ]) - CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) TcItemThen cenv overallTy env tpenv (ResolveExprDotLongIdentAndComputeRange cenv.tcSink cenv.nameResolver (unionRanges mExprAndTypeArgs mLongId) ad env.eNameResEnv typ longId IgnoreOverrides true) otherDelayed | ((DelayedTypeApp(tyargs, _mTypeArgs, mExprAndTypeArgs))::_delayed') -> // A case where we have an incomplete name e.g. 'Foo.' - we still want to report it to VS! let typ,_ = TcNestedTypeApplication cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv mExprAndTypeArgs typ tyargs let item = Item.Types(nm, [typ]) - CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) // Same error as in the following case error(Error(FSComp.SR.tcInvalidUseOfTypeName(),mItem)) @@ -8559,10 +8571,9 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution | Item.MethodGroup (methodName,minfos,_) -> // Static method calls Type.Foo(arg1,...,argn) let meths = List.map (fun minfo -> minfo,None) minfos - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForMethods match delayed with | (DelayedApp (atomicFlag, arg, mExprAndArg)::otherDelayed) -> - TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndArg mItem methodName ad NeverMutates false meths afterTcOverloadResolution NormalValUse [arg] atomicFlag otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndArg mItem methodName ad NeverMutates false meths afterResolution NormalValUse [arg] atomicFlag otherDelayed | (DelayedTypeApp(tys, mTypeArgs, mExprAndTypeArgs) :: otherDelayed) -> @@ -8572,45 +8583,47 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution // Replace the resolution including the static parameters, plus the extra information about the original method info let item = Item.MethodGroup(methodName, [minfoAfterStaticArguments], Some minfos.[0]) - CallNameResolutionSinkReplacing cenv.tcSink (mItem, env.NameEnv, item, item, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) + CallNameResolutionSinkReplacing cenv.tcSink (mItem, env.NameEnv, item, item, [], ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) match otherDelayed with | DelayedApp(atomicFlag, arg, mExprAndArg) :: otherDelayed -> - TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndArg mItem methodName ad NeverMutates false [(minfoAfterStaticArguments, None)] afterTcOverloadResolution NormalValUse [arg] atomicFlag otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndArg mItem methodName ad NeverMutates false [(minfoAfterStaticArguments, None)] afterResolution NormalValUse [arg] atomicFlag otherDelayed | _ -> - TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndTypeArgs mItem methodName ad NeverMutates false [(minfoAfterStaticArguments, None)] afterTcOverloadResolution NormalValUse [] ExprAtomicFlag.Atomic otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv None [] mExprAndTypeArgs mItem methodName ad NeverMutates false [(minfoAfterStaticArguments, None)] afterResolution NormalValUse [] ExprAtomicFlag.Atomic otherDelayed | None -> #endif let tyargs,tpenv = TcTypesOrMeasures None cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv tys mTypeArgs - // NOTE: This doesn't take instantiation into account - CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item (* ! *), item, ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + // FUTURE: can we do better than emptyTyparInst here, in order to display instantiations + // of type variables in the quick info provided in the IDE? But note we haven't yet even checked if the + // number of type arguments is correct... + CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + match otherDelayed with | DelayedApp(atomicFlag, arg, mExprAndArg) :: otherDelayed -> - TcMethodApplicationThen cenv env overallTy None tpenv (Some tyargs) [] mExprAndArg mItem methodName ad NeverMutates false meths afterTcOverloadResolution NormalValUse [arg] atomicFlag otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv (Some tyargs) [] mExprAndArg mItem methodName ad NeverMutates false meths afterResolution NormalValUse [arg] atomicFlag otherDelayed | _ -> - TcMethodApplicationThen cenv env overallTy None tpenv (Some tyargs) [] mExprAndTypeArgs mItem methodName ad NeverMutates false meths afterTcOverloadResolution NormalValUse [] ExprAtomicFlag.Atomic otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv (Some tyargs) [] mExprAndTypeArgs mItem methodName ad NeverMutates false meths afterResolution NormalValUse [] ExprAtomicFlag.Atomic otherDelayed | _ -> #if EXTENSIONTYPING if not minfos.IsEmpty && minfos.[0].ProvidedStaticParameterInfo.IsSome then error(Error(FSComp.SR.etMissingStaticArgumentsToMethod(),mItem)) #endif - TcMethodApplicationThen cenv env overallTy None tpenv None [] mItem mItem methodName ad NeverMutates false meths afterTcOverloadResolution NormalValUse [] ExprAtomicFlag.Atomic delayed + TcMethodApplicationThen cenv env overallTy None tpenv None [] mItem mItem methodName ad NeverMutates false meths afterResolution NormalValUse [] ExprAtomicFlag.Atomic delayed | Item.CtorGroup(nm,minfos) -> let objTy = match minfos with | (minfo :: _) -> minfo.EnclosingType | [] -> error(Error(FSComp.SR.tcTypeHasNoAccessibleConstructor(),mItem)) - let afterTcOverloadResolution = AfterTcOverloadResolution.ForConstructors afterOverloadResolution match delayed with | ((DelayedApp (_, arg, mExprAndArg))::otherDelayed) -> CallExprHasTypeSink cenv.tcSink (mExprAndArg, env.NameEnv,objTy, env.DisplayEnv, env.eAccessRights) - TcCtorCall true cenv env tpenv overallTy objTy (Some mItem) item false [arg] mExprAndArg otherDelayed (Some afterTcOverloadResolution) + TcCtorCall true cenv env tpenv overallTy objTy (Some mItem) item false [arg] mExprAndArg otherDelayed (Some afterResolution) | ((DelayedTypeApp(tyargs, _mTypeArgs, mExprAndTypeArgs))::(DelayedApp (_, arg, mExprAndArg))::otherDelayed) -> @@ -8631,7 +8644,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution item, minfos minfosAfterTyArgs |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.EnclosingType objTyAfterTyArgs) - TcCtorCall true cenv env tpenv overallTy objTyAfterTyArgs (Some mExprAndTypeArgs) itemAfterTyArgs false [arg] mExprAndArg otherDelayed (Some afterTcOverloadResolution) + TcCtorCall true cenv env tpenv overallTy objTyAfterTyArgs (Some mExprAndTypeArgs) itemAfterTyArgs false [arg] mExprAndArg otherDelayed (Some afterResolution) | ((DelayedTypeApp(tyargs, _mTypeArgs, mExprAndTypeArgs))::otherDelayed) -> @@ -8639,14 +8652,14 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution // A case where we have an incomplete name e.g. 'Foo.' - we still want to report it to VS! let resolvedItem = Item.Types(nm, [objTy]) - CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,resolvedItem,resolvedItem,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mExprAndTypeArgs,env.NameEnv,resolvedItem,resolvedItem,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) minfos |> List.iter (fun minfo -> UnifyTypes cenv env mExprAndTypeArgs minfo.EnclosingType objTy) - TcCtorCall true cenv env tpenv overallTy objTy (Some mExprAndTypeArgs) item false [] mExprAndTypeArgs otherDelayed (Some afterTcOverloadResolution) + TcCtorCall true cenv env tpenv overallTy objTy (Some mExprAndTypeArgs) item false [] mExprAndTypeArgs otherDelayed (Some afterResolution) | _ -> - TcCtorCall true cenv env tpenv overallTy objTy (Some mItem) item false [] mItem delayed (Some afterTcOverloadResolution) + TcCtorCall true cenv env tpenv overallTy objTy (Some mItem) item false [] mItem delayed (Some afterResolution) | Item.FakeInterfaceCtor _ -> error(Error(FSComp.SR.tcInvalidUseOfInterfaceType(),mItem)) @@ -8775,7 +8788,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution // Report information about the whole expression including type arguments to VS let item = Item.DelegateCtor typ - CallNameResolutionSink cenv.tcSink (mItemAndTypeArgs,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (mItemAndTypeArgs,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,env.eAccessRights) TcNewDelegateThen cenv overallTy env tpenv mItem mItemAndArg typ arg atomicFlag otherDelayed | _ -> error(Error(FSComp.SR.tcInvalidUseOfDelegate(),mItem)) @@ -8814,21 +8827,17 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution // - it isn't a CtorValUsedAsSelfInit // - it isn't a VSlotDirectCall (uses of base values do not take type arguments let checkTys tpenv kinds = TcTypesOrMeasures (Some kinds) cenv NewTyparsOK CheckCxs ItemOccurence.UseInType env tpenv tys mItem - let (vexp, isSpecial, _, _, tpenv) = TcVal true cenv env tpenv vref (Some (NormalValUse, checkTys)) mItem - let vexp = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) - // type of the expression (e.g. For the source text "sizeof" vexpty will be the TAST type for int32) - let vexpty = vexp.Type - + let _, vexp, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref (Some (NormalValUse, checkTys)) (Some afterResolution) mItem + let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) // We need to eventually record the type resolution for an expression, but this is done // inside PropagateThenTcDelayed, so we don't have to explicitly call 'CallExprHasTypeSink' here - PropagateThenTcDelayed cenv overallTy env tpenv mExprAndTypeArgs vexp vexpty ExprAtomicFlag.Atomic otherDelayed + PropagateThenTcDelayed cenv overallTy env tpenv mExprAndTypeArgs vexpFlex vexpFlex.Type ExprAtomicFlag.Atomic otherDelayed // Value get | _ -> - let (vexp, isSpecial, _, _, tpenv) = TcVal true cenv env tpenv vref None mItem - let vexp = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) - let vexpty = vexp.Type - PropagateThenTcDelayed cenv overallTy env tpenv mItem vexp vexpty ExprAtomicFlag.Atomic delayed + let _, vexp, isSpecial, _, _, tpenv = TcVal true cenv env tpenv vref None (Some afterResolution) mItem + let vexpFlex = (if isSpecial then MakeApplicableExprNoFlex cenv vexp else MakeApplicableExprWithFlex cenv env vexp) + PropagateThenTcDelayed cenv overallTy env tpenv mItem vexpFlex vexpFlex.Type ExprAtomicFlag.Atomic delayed | Item.Property (nm,pinfos) -> if isNil pinfos then error (InternalError ("Unexpected error: empty property list",mItem)) @@ -8848,16 +8857,14 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution UnifyTypes cenv env mStmt overallTy cenv.g.unit_ty let meths = pinfos |> SettersOfPropInfos if isNil meths then error (Error (FSComp.SR.tcPropertyCannotBeSet1 nm,mItem)) - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForProperties nm SettersOfPropInfos // Note: static calls never mutate a struct object argument - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mStmt mItem nm ad NeverMutates true meths afterTcOverloadResolution NormalValUse (args@[e2]) ExprAtomicFlag.NonAtomic otherDelayed + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mStmt mItem nm ad NeverMutates true meths afterResolution NormalValUse (args@[e2]) ExprAtomicFlag.NonAtomic otherDelayed | _ -> // Static Property Get (possibly indexer) let meths = pinfos |> GettersOfPropInfos - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForProperties nm GettersOfPropInfos if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable(nm),mItem)) // Note: static calls never mutate a struct object argument - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mItem mItem nm ad NeverMutates true meths afterTcOverloadResolution NormalValUse args ExprAtomicFlag.Atomic delayed + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mItem mItem nm ad NeverMutates true meths afterResolution NormalValUse args ExprAtomicFlag.Atomic delayed | Item.ILField finfo -> @@ -8975,15 +8982,13 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela if isTyparTy cenv.g objExprTy then GeneralizationHelpers.CanonicalizePartialInferenceProblem (cenv,env.DisplayEnv,mExprAndLongId) (freeInTypeLeftToRight cenv.g false objExprTy) - let item,mItem,rest,afterOverloadResolution = ResolveExprDotLongIdentAndComputeRange cenv.tcSink cenv.nameResolver mExprAndLongId ad env.eNameResEnv objExprTy longId findFlag false + let item,mItem,rest,afterResolution = ResolveExprDotLongIdentAndComputeRange cenv.tcSink cenv.nameResolver mExprAndLongId ad env.eNameResEnv objExprTy longId findFlag false let mExprAndItem = unionRanges mObjExpr mItem let delayed = delayRest rest mExprAndItem delayed match item with | Item.MethodGroup (methodName,minfos,_) -> let atomicFlag,tyargsOpt,args,delayed,tpenv = GetSynMemberApplicationArgs delayed tpenv - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForMethods - // We pass PossiblyMutates here because these may actually mutate a value type object // To get better warnings we special case some of the few known mutate-a-struct method names let mutates = (if methodName = "MoveNext" || methodName = "GetNextArg" then DefinitelyMutates else PossiblyMutates) @@ -8993,9 +8998,9 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela | Some minfoAfterStaticArguments -> // Replace the resolution including the static parameters, plus the extra information about the original method info let item = Item.MethodGroup(methodName, [minfoAfterStaticArguments], Some minfos.[0]) - CallNameResolutionSinkReplacing cenv.tcSink (mExprAndItem,env.NameEnv, item, item, ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) + CallNameResolutionSinkReplacing cenv.tcSink (mExprAndItem,env.NameEnv, item, item, [], ItemOccurence.Use, env.DisplayEnv, env.eAccessRights) - TcMethodApplicationThen cenv env overallTy None tpenv None objArgs mExprAndItem mItem methodName ad mutates false [(minfoAfterStaticArguments, None)] afterTcOverloadResolution NormalValUse args atomicFlag delayed + TcMethodApplicationThen cenv env overallTy None tpenv None objArgs mExprAndItem mItem methodName ad mutates false [(minfoAfterStaticArguments, None)] afterResolution NormalValUse args atomicFlag delayed | None -> if not minfos.IsEmpty && minfos.[0].ProvidedStaticParameterInfo.IsSome then error(Error(FSComp.SR.etMissingStaticArgumentsToMethod(),mItem)) @@ -9004,7 +9009,7 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela let tyargsOpt,tpenv = TcMemberTyArgsOpt cenv env tpenv tyargsOpt let meths = minfos |> List.map (fun minfo -> minfo,None) - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem methodName ad mutates false meths afterTcOverloadResolution NormalValUse args atomicFlag delayed + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem methodName ad mutates false meths afterResolution NormalValUse args atomicFlag delayed | Item.Property (nm,pinfos) -> // Instance property @@ -9027,15 +9032,13 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela UnifyTypes cenv env mStmt overallTy cenv.g.unit_ty let meths = SettersOfPropInfos pinfos if isNil meths then error (Error (FSComp.SR.tcPropertyCannotBeSet1 nm,mItem)) - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForProperties nm SettersOfPropInfos let mut = (if isStructTy cenv.g (tyOfExpr cenv.g objExpr) then DefinitelyMutates else PossiblyMutates) - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mStmt mItem nm ad mut true meths afterTcOverloadResolution NormalValUse (args @ [e2]) atomicFlag [] + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mStmt mItem nm ad mut true meths afterResolution NormalValUse (args @ [e2]) atomicFlag [] | _ -> // Instance property getter let meths = GettersOfPropInfos pinfos if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable(nm),mItem)) - let afterTcOverloadResolution = afterOverloadResolution |> AfterTcOverloadResolution.ForProperties nm GettersOfPropInfos - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem nm ad PossiblyMutates true meths afterTcOverloadResolution NormalValUse args atomicFlag delayed + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem nm ad PossiblyMutates true meths afterResolution NormalValUse args atomicFlag delayed | Item.RecdField rfinfo -> // Get or set instance F# field or literal @@ -9151,7 +9154,7 @@ and TcMethodApplicationThen mut // what do we know/assume about whether this method will mutate or not? isProp // is this a property call? Used for better error messages and passed to BuildMethodCall meths // the set of methods we may be calling - afterTcOverloadResolution // do we need to notify sink after overload resolution + afterResolution // do we need to notify sink after overload resolution isSuperInit // is this a special invocation, e.g. a super-class constructor call. Passed through to BuildMethodCall args // the _syntactic_ method arguments, not yet type checked. atomicFlag // is the expression atomic or not? @@ -9167,7 +9170,7 @@ and TcMethodApplicationThen // Call the helper below to do the real checking let (expr,attributeAssignedNamedItems,delayed),tpenv = - TcMethodApplication false cenv env tpenv callerTyArgs objArgs mWholeExpr mItem methodName objTyOpt ad mut isProp meths afterTcOverloadResolution isSuperInit args exprTy delayed + TcMethodApplication false cenv env tpenv callerTyArgs objArgs mWholeExpr mItem methodName objTyOpt ad mut isProp meths afterResolution isSuperInit args exprTy delayed // Give errors if some things couldn't be assigned if not (isNil attributeAssignedNamedItems) then @@ -9193,7 +9196,7 @@ and GetNewInferenceTypeForMethodArg cenv env tpenv x = /// Method calls, property lookups, attribute constructions etc. get checked through here and TcMethodApplication - checkingAttributeCall + isCheckingAttributeCall cenv env tpenv @@ -9207,7 +9210,7 @@ and TcMethodApplication mut isProp calledMethsAndProps - afterTcOverloadResolution + afterResolution isSuperInit curriedCallerArgs exprTy @@ -9399,7 +9402,7 @@ and TcMethodApplication match tyargsOpt with | Some tyargs -> minfo.AdjustUserTypeInstForFSharpStyleIndexedExtensionMembers(tyargs) | None -> minst - CalledMeth(cenv.infoReader,Some(env.NameEnv),checkingAttributeCall, FreshenMethInfo, mMethExpr,ad,minfo,minst,callerTyArgs,pinfoOpt,callerObjArgTys,callerArgs,usesParamArrayConversion,true,objTyOpt) + CalledMeth(cenv.infoReader,Some(env.NameEnv),isCheckingAttributeCall, FreshenMethInfo, mMethExpr,ad,minfo,minst,callerTyArgs,pinfoOpt,callerObjArgTys,callerArgs,usesParamArrayConversion,true,objTyOpt) let preArgumentTypeCheckingCalledMethGroup = [ for (minfo,pinfoOpt) in candidateMethsAndProps do @@ -9411,9 +9414,14 @@ and TcMethodApplication let uniquelyResolved = let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css mMethExpr denv let res = UnifyUniqueOverloading csenv callerArgCounts methodName ad preArgumentTypeCheckingCalledMethGroup returnTy + match res with - | ErrorResult _ -> afterTcOverloadResolution.OnOverloadResolutionFailure() + | ErrorResult _ -> + match afterResolution with + | AfterResolution.DoNothing -> () + | AfterResolution.RecordResolution(_, _, _, onFailure) -> onFailure() | _ -> () + res |> CommitOperationResult uniquelyResolved,preArgumentTypeCheckingCalledMethGroup @@ -9493,7 +9501,7 @@ and TcMethodApplication match tyargsOpt with | Some tyargs -> minfo.AdjustUserTypeInstForFSharpStyleIndexedExtensionMembers(tyargs) | None -> minst - CalledMeth(cenv.infoReader,Some(env.NameEnv),checkingAttributeCall,FreshenMethInfo, mMethExpr,ad,minfo,minst,callerTyArgs,pinfoOpt,callerObjArgTys,callerArgs,usesParamArrayConversion,true,objTyOpt)) + CalledMeth(cenv.infoReader,Some(env.NameEnv),isCheckingAttributeCall,FreshenMethInfo, mMethExpr,ad,minfo,minst,callerTyArgs,pinfoOpt,callerObjArgTys,callerArgs,usesParamArrayConversion,true,objTyOpt)) let callerArgCounts = (unnamedCurriedCallerArgs.Length, namedCurriedCallerArgs.Length) let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css mMethExpr denv @@ -9508,29 +9516,42 @@ and TcMethodApplication let result, errors = ResolveOverloading csenv NoTrace methodName 0 None callerArgCounts ad postArgumentTypeCheckingCalledMethGroup true (Some returnTy) - match afterTcOverloadResolution with - | AfterTcOverloadResolution.DoNothing -> () - | AfterTcOverloadResolution.SendToSink(callSink,_) -> - match result with - | Some result -> - (result.Method,result.AssociatedPropertyInfo) |> callSink - | None -> - afterTcOverloadResolution.OnOverloadResolutionFailure() - | AfterTcOverloadResolution.ReplaceWithOverrideAndSendToSink(overriding, callSink,_) -> - match result with - | Some result -> - if result.Method.IsVirtual then - let resultMinfo = result.Method - let overridingInfo = - overriding - |> List.tryFind (fun (minfo,_) -> minfo.IsVirtual && MethInfosEquivByNameAndSig EraseNone true cenv.g cenv.amap range0 resultMinfo minfo) - match overridingInfo with - | Some r -> r |> callSink - | None -> (result.Method,result.AssociatedPropertyInfo) |> callSink - else - (result.Method,result.AssociatedPropertyInfo) |> callSink - | None -> - afterTcOverloadResolution.OnOverloadResolutionFailure() + match afterResolution, result with + | AfterResolution.DoNothing, _ -> () + + // Record the precise override resolution + | AfterResolution.RecordResolution(Some unrefinedItem, _, callSink, _), Some result + when result.Method.IsVirtual -> + + let overriding = + match unrefinedItem with + | Item.MethodGroup(_,overridenMeths,_) -> overridenMeths |> List.map (fun minfo -> minfo,None) + | Item.Property(_,pinfos) -> + if result.Method.LogicalName.StartsWith ("set_") then + SettersOfPropInfos pinfos + else + GettersOfPropInfos pinfos + | _ -> [] + + let overridingInfo = + overriding + |> List.tryFind (fun (minfo,_) -> minfo.IsVirtual && MethInfosEquivByNameAndSig EraseNone true cenv.g cenv.amap range0 result.Method minfo) + + match overridingInfo with + | Some (minfo,pinfoOpt) -> + let tps = minfo.FormalMethodTypars + let tyargs = result.CalledTyArgs + let tpinst = if tps.Length = tyargs.Length then mkTyparInst tps tyargs else [] + (minfo, pinfoOpt, tpinst) |> callSink + | None -> + (result.Method, result.AssociatedPropertyInfo, result.CalledTyparInst) |> callSink + + // Record the precise overload resolution and the type instantiation + | AfterResolution.RecordResolution(_, _, callSink, _), Some result -> + (result.Method, result.AssociatedPropertyInfo, result.CalledTyparInst) |> callSink + + | AfterResolution.RecordResolution(_, _, _, onFailure), None -> + onFailure() // Raise the errors from the constraint solving @@ -9575,7 +9596,7 @@ and TcMethodApplication // on the first type argument. if HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_Dictionary finalCalledMethInfo.EnclosingType && finalCalledMethInfo.IsConstructor && - not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CallerTyArgs) + not (finalCalledMethInfo.GetParamDatas(cenv.amap, mItem, finalCalledMeth.CalledTyArgs) |> List.existsSquared (fun (ParamData(_,_,_,_,_,_,ty)) -> HasHeadType cenv.g cenv.g.tcref_System_Collections_Generic_IEqualityComparer ty)) then @@ -9618,13 +9639,13 @@ and TcMethodApplication elif isDelegateTy cenv.g calledArgTy && isFunTy cenv.g callerArgTy then CoerceFromFSharpFuncToDelegate cenv.g cenv.amap cenv.infoReader ad callerArgTy m callerArgExpr calledArgTy - elif isLinqExpressionTy cenv.g calledArgTy && isDelegateTy cenv.g (destLinqExpressionTy cenv.g calledArgTy) && isFunTy cenv.g callerArgTy then + elif isLinqExpressionTy cenv.g calledArgTy && isDelegateTy cenv.g (destLinqExpressionTy cenv.g calledArgTy) && isFunTy cenv.g callerArgTy then let delegateTy = destLinqExpressionTy cenv.g calledArgTy let expr = CoerceFromFSharpFuncToDelegate cenv.g cenv.amap cenv.infoReader ad callerArgTy m callerArgExpr delegateTy mkCallQuoteToLinqLambdaExpression cenv.g m delegateTy (Expr.Quote(expr, ref None, false, m, mkQuotedExprTy cenv.g delegateTy)) // auto conversions to quotations (to match auto conversions to LINQ expressions) - elif reflArgInfo.AutoQuote && isQuotedExprTy cenv.g calledArgTy && not (isQuotedExprTy cenv.g callerArgTy) then + elif reflArgInfo.AutoQuote && isQuotedExprTy cenv.g calledArgTy && not (isQuotedExprTy cenv.g callerArgTy) then match reflArgInfo with | ReflectedArgInfo.Quote true -> mkCallLiftValueWithDefn cenv.g m calledArgTy callerArgExpr @@ -9834,7 +9855,7 @@ and TcMethodApplication | None -> () | Some id -> let item = Item.ArgName (defaultArg assignedArg.CalledArg.NameOpt id, assignedArg.CalledArg.CalledArgumentType, Some(ArgumentContainer.Method(finalCalledMethInfo))) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,ad)) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,ad)) let allArgsCoerced = List.map coerce allArgs @@ -9856,6 +9877,7 @@ and TcMethodApplication // Handle post-hoc property assignments let expr = + if isCheckingAttributeCall then expr else if isNil finalAssignedItemSetters then expr else // This holds the result of the call let objv,objExpr = mkMutableCompGenLocal mMethExpr "returnVal" exprty // mutable in case it's a struct @@ -9892,7 +9914,7 @@ and TcMethodApplication // Record the resolution for the Language Service let item = Item.SetterArg (id, defnItem) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Use,env.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,ad) mkCompGenSequential m acc action) @@ -9932,7 +9954,7 @@ and TcMethodApplication and TcUnnamedMethodArgs cenv env lambdaPropagationInfo tpenv args = List.mapiFoldSquared (TcUnnamedMethodArg cenv env) (lambdaPropagationInfo,tpenv) args -and TcUnnamedMethodArg cenv env (lambdaPropagationInfo,tpenv) (i,j,CallerArg(argTy,mArg,isOpt,argExpr)) = +and TcUnnamedMethodArg cenv env (lambdaPropagationInfo,tpenv) (i,j,CallerArg(argTy,mArg,isOpt,argExpr)) = // Try to find the lambda propagation info for the corresponding unnamed argument at this position let lambdaPropagationInfoForArg = [| for (unnamedInfo,_) in lambdaPropagationInfo -> @@ -9959,14 +9981,14 @@ and TcMethodArg cenv env (lambdaPropagationInfo,tpenv) (lambdaPropagationInfoF // Apply the F# 3.1 rule for extracting information for lambdas // // Before we check the argument, check to see if we can propagate info from a called lambda expression into the arguments of a received lambda - begin - if lambdaPropagationInfoForArg.Length > 0 then - let allOverloadsAreFuncOrMismatchForThisArg = - lambdaPropagationInfoForArg |> Array.forall (function ArgDoesNotMatch | CallerLambdaHasArgTypes _ -> true | NoInfo | CalledArgMatchesType _ -> false) - - if allOverloadsAreFuncOrMismatchForThisArg then - let overloadsWhichAreFuncAtThisPosition = lambdaPropagationInfoForArg |> Array.choose (function CallerLambdaHasArgTypes r -> Some (List.toArray r) | _ -> None) - if overloadsWhichAreFuncAtThisPosition.Length > 0 then + if lambdaPropagationInfoForArg.Length > 0 then + let allOverloadsAreNotCalledArgMatchesForThisArg = + lambdaPropagationInfoForArg + |> Array.forall (function ArgDoesNotMatch | CallerLambdaHasArgTypes _ | NoInfo -> true | CalledArgMatchesType _ -> false) + + if allOverloadsAreNotCalledArgMatchesForThisArg then + let overloadsWhichAreFuncAtThisPosition = lambdaPropagationInfoForArg |> Array.choose (function CallerLambdaHasArgTypes r -> Some (List.toArray r) | _ -> None) + if overloadsWhichAreFuncAtThisPosition.Length > 0 then let minFuncArity = overloadsWhichAreFuncAtThisPosition |> Array.minBy Array.length |> Array.length let prefixOfLambdaArgsForEachOverload = overloadsWhichAreFuncAtThisPosition |> Array.map (Array.take minFuncArity) @@ -9979,7 +10001,7 @@ and TcMethodArg cenv env (lambdaPropagationInfo,tpenv) (lambdaPropagationInfoF if lambdaVarNum < numLambdaVars then let col = [ for row in prefixOfLambdaArgsForEachOverload -> row.[lambdaVarNum] ] // Check if all the rows give the same argument type - if col |> ListSet.setify (typeEquiv cenv.g) |> List.length |> ((=) 1) then + if col |> ListSet.setify (typeEquiv cenv.g) |> isSingleton then let calledLambdaArgTy = col.[0] // Force the caller to be a function type. match UnifyFunctionTypeUndoIfFailed cenv env.DisplayEnv mArg callerLambdaTy with @@ -9988,7 +10010,6 @@ and TcMethodArg cenv env (lambdaPropagationInfo,tpenv) (lambdaPropagationInfoF loop callerLambdaRangeTy (lambdaVarNum + 1) | None -> () loop argTy 0 - end let e',tpenv = TcExpr cenv argTy env tpenv argExpr @@ -10034,7 +10055,7 @@ and bindLetRec (binds:Bindings) m e = /// Check for duplicate bindings in simple recursive patterns and CheckRecursiveBindingIds binds = - let hashOfBinds = new Dictionary() + let hashOfBinds = new HashSet() for (SynBinding.Binding(_,_,_,_,_,_,_,b,_,_,m,_)) in binds do let nm = @@ -10042,10 +10063,8 @@ and CheckRecursiveBindingIds binds = | SynPat.Named(_,id,_,_,_) -> id.idText | SynPat.LongIdent(LongIdentWithDots([id],_),_,_,_,_,_) -> id.idText | _ -> "" - if nm <> "" then - if hashOfBinds.ContainsKey(nm) then - error(Duplicate("value",nm,m)) - else hashOfBinds.[nm] <- b + if nm <> "" && not (hashOfBinds.Add nm) then + error(Duplicate("value",nm,m)) /// Process a sequence of sequentials mixed with iterated lets "let ... in let ... in ..." in a tail recursive way /// This avoids stack overflow on really large "let" and "letrec" lists @@ -10086,15 +10105,24 @@ and TcMatchPattern cenv inputTy env tpenv (pat:SynPat,optWhenExpr) = let m = pat.Range let patf',(tpenv,names,_) = TcPat WarnOnUpperCase cenv env None (ValInline.Optional,permitInferTypars,noArgOrRetAttribs,false,None,false) (tpenv,Map.empty,Set.empty) inputTy pat let envinner,values,vspecMap = MakeAndPublishSimpleVals cenv env m names false - let optWhenExpr',tpenv = Option.mapFold (TcExpr cenv cenv.g.bool_ty envinner) tpenv optWhenExpr + let optWhenExpr',tpenv = + match optWhenExpr with + | Some whenExpr -> + let guardEnv = { envinner with eContextInfo = ContextInfo.PatternMatchGuard whenExpr.Range } + let whenExpr',tpenv = TcExpr cenv cenv.g.bool_ty guardEnv tpenv whenExpr + Some whenExpr',tpenv + | None -> None,tpenv patf' (TcPatPhase2Input (values, true)),optWhenExpr', NameMap.range vspecMap,envinner,tpenv and TcMatchClauses cenv inputTy resultTy env tpenv clauses = - List.mapFold (TcMatchClause cenv inputTy resultTy env) tpenv clauses + let first = ref true + let isFirst() = if !first then first := false; true else false + List.mapFold (fun clause -> TcMatchClause cenv inputTy resultTy env (isFirst()) clause) tpenv clauses -and TcMatchClause cenv inputTy resultTy env tpenv (Clause(pat,optWhenExpr,e,patm,spTgt)) = +and TcMatchClause cenv inputTy resultTy env isFirst tpenv (Clause(pat,optWhenExpr,e,patm,spTgt)) = let pat',optWhenExpr',vspecs,envinner,tpenv = TcMatchPattern cenv inputTy env tpenv (pat,optWhenExpr) - let e',tpenv = TcExprThatCanBeCtorBody cenv resultTy envinner tpenv e + let resultEnv = if isFirst then envinner else { envinner with eContextInfo = ContextInfo.FollowingPatternMatchClause e.Range } + let e',tpenv = TcExprThatCanBeCtorBody cenv resultTy resultEnv tpenv e TClause(pat',optWhenExpr',TTarget(vspecs, e',spTgt),patm),tpenv and TcStaticOptimizationConstraint cenv env tpenv c = @@ -10258,15 +10286,15 @@ and TcNormalizedBinding declKind (cenv:cenv) env tpenv overallTy safeThisValOpt if (not isMutable || isThreadStatic) then errorR(Error(FSComp.SR.tcVolatileFieldsMustBeMutable(),mBinding)) - if isFixed then - if declKind <> ExpressionBinding || isInline || isMutable then - errorR(Error(FSComp.SR.tcFixedNotAllowed(),mBinding)) + if isFixed && (declKind <> ExpressionBinding || isInline || isMutable) then + errorR(Error(FSComp.SR.tcFixedNotAllowed(),mBinding)) - if HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute valAttribs then - if not declKind.CanBeDllImport || (match memberFlagsOpt with Some memberFlags -> memberFlags.IsInstance | _ -> false) then - errorR(Error(FSComp.SR.tcDllImportNotAllowed(),mBinding)) + if (not declKind.CanBeDllImport || (match memberFlagsOpt with Some memberFlags -> memberFlags.IsInstance | _ -> false)) && + HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute valAttribs + then + errorR(Error(FSComp.SR.tcDllImportNotAllowed(),mBinding)) - if HasFSharpAttribute cenv.g cenv.g.attrib_ConditionalAttribute valAttribs && Option.isNone memberFlagsOpt then + if Option.isNone memberFlagsOpt && HasFSharpAttribute cenv.g cenv.g.attrib_ConditionalAttribute valAttribs then errorR(Error(FSComp.SR.tcConditionalAttributeRequiresMembers(),mBinding)) if HasFSharpAttribute cenv.g cenv.g.attrib_EntryPointAttribute valAttribs then @@ -10318,7 +10346,7 @@ and TcNormalizedBinding declKind (cenv:cenv) env tpenv overallTy safeThisValOpt apinfo.ActiveTagsWithRanges |> List.iteri (fun i (_tag,tagRange) -> let item = Item.ActivePatternResult(apinfo, cenv.g.unit_ty, i, tagRange) - CallNameResolutionSink cenv.tcSink (tagRange,env.NameEnv,item,item,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights)) + CallNameResolutionSink cenv.tcSink (tagRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights)) ModifyNameResEnv (fun nenv -> AddActivePatternResultTagsToNameEnv apinfo nenv ty m) envinner | None -> @@ -10360,14 +10388,16 @@ and TcNormalizedBinding declKind (cenv:cenv) env tpenv overallTy safeThisValOpt // Check other attributes let hasLiteralAttr,konst = TcLiteral cenv overallExprTy env tpenv (valAttribs,rhsExpr) - if hasLiteralAttr && isThreadStatic then - errorR(Error(FSComp.SR.tcIllegalAttributesForLiteral(),mBinding)) - if hasLiteralAttr && isMutable then - errorR(Error(FSComp.SR.tcLiteralCannotBeMutable(),mBinding)) - if hasLiteralAttr && isInline then - errorR(Error(FSComp.SR.tcLiteralCannotBeInline(),mBinding)) - if hasLiteralAttr && not (isNil declaredTypars) then - errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(),mBinding)) + + if hasLiteralAttr then + if isThreadStatic then + errorR(Error(FSComp.SR.tcIllegalAttributesForLiteral(),mBinding)) + if isMutable then + errorR(Error(FSComp.SR.tcLiteralCannotBeMutable(),mBinding)) + if isInline then + errorR(Error(FSComp.SR.tcLiteralCannotBeInline(),mBinding)) + if not (isNil declaredTypars) then + errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(),mBinding)) CheckedBindingInfo(inlineFlag,valAttribs,doc,tcPatPhase2,flex,nameToPrelimValSchemeMap,rhsExprChecked,argAndRetAttribs,overallPatTy,mBinding,spBind,compgen,konst,isFixed),tpenv @@ -10421,7 +10451,7 @@ and TcNonRecursiveBinding declKind cenv env tpenv ty b = //------------------------------------------------------------------------ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) = - let (LongIdentWithDots(tycon,_))= synAttr.TypeName + let (LongIdentWithDots(tycon,_)) = synAttr.TypeName let arg = synAttr.ArgExpr let targetIndicator = synAttr.Target let isAppliedToGetterOrSetter = synAttr.AppliesToGetterAndSetter @@ -10444,7 +10474,7 @@ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) = let ad = env.eAccessRights - if not (IsTypeAccessible cenv.g cenv.amap mAttr ad ty) then errorR(Error(FSComp.SR.tcTypeIsInaccessible(),mAttr)) + if not (IsTypeAccessible cenv.g cenv.amap mAttr ad ty) then errorR(Error(FSComp.SR.tcTypeIsInaccessible(),mAttr)) let tcref = tcrefOfAppTy cenv.g ty @@ -10519,9 +10549,9 @@ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) = match item with | Item.CtorGroup(methodName,minfos) -> let meths = minfos |> List.map (fun minfo -> minfo,None) - let afterTcOverloadResolution = AfterTcOverloadResolution.ForNewConstructors cenv.tcSink env tyid.idRange methodName minfos - let (expr,namedCallerArgs,_),_ = - TcMethodApplication true cenv env tpenv None [] mAttr mAttr methodName None ad PossiblyMutates false meths afterTcOverloadResolution NormalValUse [arg] (NewInferenceType ()) [] + let afterResolution = ForNewConstructors cenv.tcSink env tyid.idRange methodName minfos + let (expr,attributeAssignedNamedItems,_),_ = + TcMethodApplication true cenv env tpenv None [] mAttr mAttr methodName None ad PossiblyMutates false meths afterResolution NormalValUse [arg] (NewInferenceType ()) [] UnifyTypes cenv env mAttr ty (tyOfExpr cenv.g expr) @@ -10529,9 +10559,9 @@ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) = AttribExpr(e,EvalLiteralExprOrAttribArg cenv.g e) let namedAttribArgMap = - namedCallerArgs |> List.map (fun (CallerNamedArg(id,CallerArg(argtyv,m,isOpt,expr))) -> + attributeAssignedNamedItems |> List.map (fun (CallerNamedArg(id,CallerArg(argtyv,m,isOpt,callerArgExpr))) -> if isOpt then error(Error(FSComp.SR.tcOptionalArgumentsCannotBeUsedInCustomAttribute(),m)) - let m = expr.Range + let m = callerArgExpr.Range let setterItem, _ = ResolveLongIdentInType cenv.tcSink cenv.nameResolver env.NameEnv LookupKind.Expr m ad [id] IgnoreOverrides TypeNameResolutionInfo.Default ty let nm, isProp, argty = match setterItem with @@ -10553,11 +10583,11 @@ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) = errorR(Error(FSComp.SR.tcPropertyOrFieldNotFoundInAttribute(),m)) id.idText,false,cenv.g.unit_ty let propNameItem = Item.SetterArg(id, setterItem) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,propNameItem,propNameItem,ItemOccurence.Use,env.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,propNameItem,propNameItem,emptyTyparInst,ItemOccurence.Use,env.DisplayEnv,ad) AddCxTypeMustSubsumeType ContextInfo.NoContext env.DisplayEnv cenv.css m NoTrace argty argtyv - AttribNamedArg(nm,argty,isProp,mkAttribExpr expr)) + AttribNamedArg(nm,argty,isProp,mkAttribExpr callerArgExpr)) match expr with | Expr.Op(TOp.ILCall(_,_,valu,_,_,_,_,ilMethRef,[],[],_rtys),[],args,m) -> @@ -10691,7 +10721,7 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (binds,bindsm,scope // type checker that anything related to binding module-level values is marked with an // val_repr_info, val_actual_parent and is_topbind if (DeclKind.MustHaveArity declKind) then - AdjustValToTopVal tmp altActualParent (InferArityOfExprBinding cenv.g tmp rhsExpr) + AdjustValToTopVal tmp altActualParent (InferArityOfExprBinding cenv.g AllowTypeDirectedDetupling.Yes tmp rhsExpr) tmp,pat' let mkRhsBind (bodyExpr,bodyExprTy) = @@ -10739,7 +10769,7 @@ and TcLetBindings cenv env containerInfo declKind tpenv (binds,bindsm,scopem) = let binds = stripLets [] expr binds,env,tpenv -and CheckMemberFlags _g optIntfSlotTy newslotsOK overridesOK memberFlags m = +and CheckMemberFlags optIntfSlotTy newslotsOK overridesOK memberFlags m = if newslotsOK = NoNewSlots && memberFlags.IsDispatchSlot then errorR(Error(FSComp.SR.tcAbstractMembersIllegalInAugmentation(),m)) if overridesOK = ErrorOnOverrides && memberFlags.MemberKind = MemberKind.Constructor then @@ -10817,7 +10847,7 @@ and ApplyAbstractSlotInference (cenv:cenv) (envinner:TcEnv) (bindingTy,m,synTypa | slots -> match dispatchSlotsArityMatch with - | meths when meths |> makeUniqueBySig |> List.length = 1 -> meths + | meths when meths |> makeUniqueBySig |> isSingleton -> meths | [] -> let details = slots @@ -10958,11 +10988,10 @@ and AnalyzeRecursiveStaticMemberOrValDecl (cenv, envinner: TcEnv, tpenv, declKin | (Some(MemberOrValContainerInfo(tcref, optIntfSlotTy, baseValOpt, _safeInitInfo, declaredTyconTypars)),Some memberFlags) -> assert (Option.isNone optIntfSlotTy) - CheckMemberFlags cenv.g None newslotsOK overridesOK memberFlags id.idRange + CheckMemberFlags None newslotsOK overridesOK memberFlags id.idRange CheckForNonAbstractInterface declKind tcref memberFlags id.idRange - if tcref.Deref.IsExceptionDecl && - (memberFlags.MemberKind = MemberKind.Constructor) then + if memberFlags.MemberKind = MemberKind.Constructor && tcref.Deref.IsExceptionDecl then error(Error(FSComp.SR.tcConstructorsDisallowedInExceptionAugmentation(),id.idRange)) let isExtrinsic = (declKind = ExtrinsicExtensionBinding) @@ -11021,7 +11050,7 @@ and AnalyzeRecursiveInstanceMemberDecl (cenv,envinner: TcEnv, tpenv, declKind, s // Normal instance members. | Some(MemberOrValContainerInfo(tcref, optIntfSlotTy, baseValOpt, _safeInitInfo, declaredTyconTypars)), Some memberFlags -> - CheckMemberFlags cenv.g optIntfSlotTy newslotsOK overridesOK memberFlags mBinding + CheckMemberFlags optIntfSlotTy newslotsOK overridesOK memberFlags mBinding if Option.isSome vis && memberFlags.IsOverrideOrExplicitImpl then errorR(Error(FSComp.SR.tcOverridesCannotHaveVisibilityDeclarations(),memberId.idRange)) @@ -11183,7 +11212,7 @@ and AnalyzeAndMakeAndPublishRecursiveValue overridesOK isGeneratedEventVal cenv match toolIdOpt with | Some tid when not tid.idRange.IsSynthetic && tid.idRange <> bindingId.idRange -> let item = Item.Value (mkLocalValRef vspec) - CallNameResolutionSink cenv.tcSink (tid.idRange,env.NameEnv,item,item,ItemOccurence.RelatedText,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (tid.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.RelatedText,env.DisplayEnv,env.eAccessRights) | _ -> () @@ -11787,7 +11816,7 @@ exception NotUpperCaseConstructor of range let CheckNamespaceModuleOrTypeName (g:TcGlobals) (id:Ident) = // type names '[]' etc. are used in fslib - if not g.compilingFslib && id.idText.IndexOfAny(IllegalCharactersInTypeAndNamespaceNames) <> -1 then + if not g.compilingFslib && id.idText.IndexOfAny(IllegalCharactersInTypeAndNamespaceNames) <> -1 then errorR(Error(FSComp.SR.tcInvalidNamespaceModuleTypeUnionName(),id.idRange)) let CheckDuplicates (idf : _ -> Ident) k elems = @@ -11795,7 +11824,7 @@ let CheckDuplicates (idf : _ -> Ident) k elems = elems |> List.iteri (fun j uc2 -> let id1 = (idf uc1) let id2 = (idf uc2) - if j > i && id1.idText = id2.idText then + if j > i && id1.idText = id2.idText then errorR (Duplicate(k,id1.idText,id1.idRange)))) elems @@ -11828,7 +11857,7 @@ module TcRecdUnionAndEnumDeclarations = begin if isVolatile then error(Error(FSComp.SR.tcVolatileOnlyOnClassLetBindings(),m)) - if isIncrClass && (not zeroInit || not isMutable) then errorR(Error(FSComp.SR.tcUninitializedValFieldsMustBeMutable(),m)) + if isIncrClass && (not zeroInit || not isMutable) then errorR(Error(FSComp.SR.tcUninitializedValFieldsMustBeMutable(),m)) if isStatic && (not zeroInit || not isMutable || vis <> Some SynAccess.Private ) then errorR(Error(FSComp.SR.tcStaticValFieldsMustBeMutableAndPrivate(),m)) let konst = if zeroInit then Some Const.Zero else None let rfspec = MakeRecdFieldSpec cenv env parent (isStatic,konst,ty',attrsForProperty,attrsForField,id,isMutable,isVolatile,xmldoc,vis,m) @@ -11847,7 +11876,7 @@ module TcRecdUnionAndEnumDeclarations = begin | None -> () | Some id -> let item = Item.ArgName(id, f.FormalType, None) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Binding,env.DisplayEnv,env.AccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Binding,env.DisplayEnv,env.AccessRights) f @@ -12233,7 +12262,7 @@ module IncrClassChecking = if isUnitTy cenv.g v.Type then false else - let arity = InferArityOfExprBinding cenv.g v bind.Expr + let arity = InferArityOfExprBinding cenv.g AllowTypeDirectedDetupling.Yes v bind.Expr not arity.HasNoArgs && not v.IsMutable @@ -12271,7 +12300,7 @@ module IncrClassChecking = warning (Error(FSComp.SR.chkUnusedValue(v.DisplayName), v.Range)) let repr = - match InferArityOfExprBinding g v bind.Expr with + match InferArityOfExprBinding g AllowTypeDirectedDetupling.Yes v bind.Expr with | arity when arity.HasNoArgs || v.IsMutable -> // all mutable variables are forced into fields, since they may escape into closures within the implicit constructor // e.g. @@ -12344,6 +12373,11 @@ module IncrClassChecking = member localRep.IsValWithRepresentation (v:Val) = localRep.ValsWithRepresentation.Contains(v) + member localRep.IsValRepresentedAsLocalVar (v:Val) = + match localRep.LookupRepr v with + | InVar false -> true + | _ -> false + /// Make the elaborated expression that represents a use of a /// a "let v = ..." class binding member localRep.MakeValueLookup thisValOpt tinst safeStaticInitInfo v tyargs m = @@ -12782,14 +12816,14 @@ module IncrClassChecking = // (c) rely on the fact that there are no 'let' bindings prior to the inherits expr. let inheritsExpr = match ctorInfo.InstanceCtorSafeThisValOpt with - | None -> - inheritsExpr - | Some v -> + | Some v when not (reps.IsValRepresentedAsLocalVar (v)) -> // Rewrite the expression to convert it to a load of a field if needed. // We are allowed to load fields from our own object even though we haven't called // the super class constructor yet. let ldexpr = reps.FixupIncrClassExprPhase2C (Some(thisVal)) safeStaticInitInfo thisTyInst (exprForVal m v) mkInvisibleLet m v ldexpr inheritsExpr + | _ -> + inheritsExpr let spAtSuperInit = (if inheritsIsVisible then SequencePointsAtSeq else SuppressSequencePointOnExprOfSequential) mkSequential spAtSuperInit m inheritsExpr ctorBody @@ -12987,7 +13021,7 @@ module MutRecBindingChecking = | TyparKind.Measure,false -> error(Error(FSComp.SR.tcMeasureDeclarationsRequireStaticMembers(), m)) | _ -> () - if tcref.IsStructOrEnumTycon && not isStatic then + if not isStatic && tcref.IsStructOrEnumTycon then let allDo = letBinds |> List.forall (function (Binding(_,DoBinding,_,_,_,_,_,_,_,_,_,_)) -> true | _ -> false) // Code for potential future design change to allow functions-compiled-as-members in structs if allDo then @@ -13031,8 +13065,8 @@ module MutRecBindingChecking = [ Phase2AOpen (mp,m) ], innerState #endif - | _ -> - error(InternalError("Unexpected definition",m))) + | definition -> + error(InternalError(sprintf "Unexpected definition %A" definition,m))) // If no constructor call, insert Phase2AIncrClassCtorJustAfterSuperInit at start let defnAs = @@ -13204,9 +13238,8 @@ module MutRecBindingChecking = let envNonRec = (envNonRec,binds) ||> List.fold (fun acc bind -> AddLocalValPrimitive bind.Var acc) // Check to see that local bindings and members don't have the same name and check some other adhoc conditions - for bind in binds do - - if HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute bind.Var.Attribs && not isStatic then + for bind in binds do + if not isStatic && HasFSharpAttributeOpt cenv.g cenv.g.attrib_DllImportAttribute bind.Var.Attribs then errorR(Error(FSComp.SR.tcDllImportNotAllowed(),bind.Var.Range)) let nm = bind.Var.DisplayName @@ -13360,8 +13393,7 @@ module MutRecBindingChecking = // ... // and some others in prim-types.fs // - // REVIEW: consider also turning them off for FSharp.Compiler: && cenv.topCcu.AssemblyName <> "FSharp.Compiler" and more - // generally allowing an optimization switch to turn off these checks + // REVIEW: consider allowing an optimization switch to turn off these checks let needsSafeStaticInit = not cenv.g.compilingFslib @@ -13790,9 +13822,10 @@ let TcMutRecDefns_Phase2 cenv envInitial bindsm scopem mutRecNSInfo (envMutRec: module AddAugmentationDeclarations = let tcaugHasNominalInterface g (tcaug: TyconAugmentation) tcref = tcaug.tcaug_interfaces |> List.exists (fun (x,_,_) -> - isAppTy g x && tyconRefEq g (tcrefOfAppTy g x) tcref) + match tryDestAppTy g x with + | Some tcref2 when tyconRefEq g tcref2 tcref -> true + | _ -> false) - let AddGenericCompareDeclarations cenv (env: TcEnv) (scSet:Set) (tycon:Tycon) = if AugmentWithHashCompare.TyconIsCandidateForAugmentationWithCompare cenv.g tycon && scSet.Contains tycon.Stamp then let tcref = mkLocalTyconRef tycon @@ -13960,8 +13993,8 @@ module TyconConstraintInference = // Otherwise it's a nominal type | _ -> - if isAppTy g ty then - let tcref,tinst = destAppTy g ty + match ty with + | AppTy g (tcref,tinst) -> // Check the basic requirement - IComparable/IStructuralComparable or assumed-comparable (if initialAssumedTycons.Contains tcref.Stamp then assumedTycons.Contains tcref.Stamp @@ -13978,7 +14011,7 @@ module TyconConstraintInference = checkIfFieldTypeSupportsComparison tycon ty else true) - else + | _ -> false let newSet = @@ -14083,8 +14116,8 @@ module TyconConstraintInference = false | _ -> // Check the basic requirement - any types except those eliminated - if isAppTy g ty then - let tcref,tinst = destAppTy g ty + match ty with + | AppTy g (tcref,tinst) -> (if initialAssumedTycons.Contains tcref.Stamp then assumedTycons.Contains tcref.Stamp elif AugmentWithHashCompare.TyconIsCandidateForAugmentationWithEquals g tcref.Deref then @@ -14101,7 +14134,7 @@ module TyconConstraintInference = checkIfFieldTypeSupportsEquality tycon ty else true) - else + | _ -> false let newSet = @@ -14213,8 +14246,8 @@ module TcExceptionDeclarations = match ResolveExprLongIdent cenv.tcSink cenv.nameResolver m ad env.eNameResEnv TypeNameResolutionInfo.Default longId with | Item.ExnCase exnc, [] -> CheckTyconAccessible cenv.amap m env.eAccessRights exnc |> ignore - if List.length args' <> 0 then - errorR (Error(FSComp.SR.tcExceptionAbbreviationsShouldNotHaveArgumentList(),m)) + if not (isNil args') then + errorR (Error(FSComp.SR.tcExceptionAbbreviationsShouldNotHaveArgumentList(),m)) TExnAbbrevRepr exnc | Item.CtorGroup(_,meths) , [] -> // REVIEW: check this really is an exception type @@ -14243,7 +14276,7 @@ module TcExceptionDeclarations = exnc.entity_exn_info <- repr let item = Item.ExnCase(mkLocalTyconRef exnc) - CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) + CallNameResolutionSink cenv.tcSink (id.idRange,env.NameEnv,item,item,emptyTyparInst,ItemOccurence.Binding,env.DisplayEnv,env.eAccessRights) args' let private TcExnDefnCore cenv env parent synExnDefnRepr = @@ -14429,7 +14462,32 @@ module EstablishTypeDefinitionCores = | _ -> () ] |> set - let TcTyconDefnCore_Phase1A_BuildInitialModule cenv envInitial parent typeNames compInfo compDecls = + let TypeNamesInNonMutRecDecls defs = + [ for def in defs do + match def with + | SynModuleDecl.Types (typeSpecs,_) -> + for (TypeDefn(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,_,_)) in typeSpecs do + if isNil typars then + match trepr with + | SynTypeDefnRepr.ObjectModel(TyconAugmentation,_,_) -> () + | _ -> yield (List.last ids).idText + | _ -> () ] + |> set + + // Collect the type names so we can implicitly add the compilation suffix to module names + let TypeNamesInNonMutRecSigDecls defs = + [ for def in defs do + match def with + | SynModuleSigDecl.Types (typeSpecs,_) -> + for (TypeDefnSig(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,extraMembers,_)) in typeSpecs do + if isNil typars then + match trepr with + | SynTypeDefnSigRepr.Simple((SynTypeDefnSimpleRepr.None _),_) when not (isNil extraMembers) -> () + | _ -> yield (List.last ids).idText + | _ -> () ] + |> set + + let TcTyconDefnCore_Phase1A_BuildInitialModule cenv envInitial parent typeNames compInfo decls = let (ComponentInfo(attribs,_parms, _constraints,longPath,xml,_,vis,im)) = compInfo let id = ComputeModuleName longPath let modAttrs = TcAttributes cenv envInitial AttributeTargets.ModuleDecl attribs @@ -14446,8 +14504,8 @@ module EstablishTypeDefinitionCores = let envForDecls, mtypeAcc = MakeInnerEnv envInitial id modKind let mspec = NewModuleOrNamespace (Some envInitial.eCompPath) vis id (xml.ToXmlDoc()) modAttrs (MaybeLazy.Strict (NewEmptyModuleOrNamespaceType modKind)) let innerParent = Parent (mkLocalModRef mspec) - let typeNames = TypeNamesInMutRecDecls compDecls - MutRecDefnsPhase2DataForModule (mtypeAcc, mspec), (innerParent, typeNames, envForDecls) + let innerTypeNames = TypeNamesInMutRecDecls decls + MutRecDefnsPhase2DataForModule (mtypeAcc, mspec), (innerParent, innerTypeNames, envForDecls) /// Establish 'type C < T1... TN > = ...' including /// - computing the mangled name for C @@ -14676,6 +14734,8 @@ module EstablishTypeDefinitionCores = let nm = theRootTypeWithRemapping.PUntaint((fun st -> st.FullName),m) error(Error(FSComp.SR.etErasedTypeUsedInGeneration(desig,nm),m)) + cenv.createsGeneratedProvidedTypes <- true + // In compiled code, all types in the set of generated types end up being both generated and relocated, unless relocation is suppressed let isForcedSuppressRelocate = theRootTypeWithRemapping.PUntaint((fun st -> st.IsSuppressRelocate),m) if isForcedSuppressRelocate && canAccessFromEverywhere tycon.Accessibility && not cenv.isScript then @@ -14975,7 +15035,7 @@ module EstablishTypeDefinitionCores = let hasMeasureableAttr = HasFSharpAttribute cenv.g cenv.g.attrib_MeasureableAttribute attrs let hasCLIMutable = HasFSharpAttribute cenv.g cenv.g.attrib_CLIMutableAttribute attrs - let hasStructLayoutAttr = HasFSharpAttribute cenv.g cenv.g.attrib_StructLayoutAttribute attrs + let structLayoutAttr = TryFindFSharpInt32Attribute cenv.g cenv.g.attrib_StructLayoutAttribute attrs let hasAllowNullLiteralAttr = TryFindFSharpBoolAttribute cenv.g cenv.g.attrib_AllowNullLiteralAttribute attrs = Some(true) if hasAbstractAttr then @@ -14996,13 +15056,17 @@ module EstablishTypeDefinitionCores = let structLayoutAttributeCheck(allowed) = - if hasStructLayoutAttr then + let explicitKind = int32 System.Runtime.InteropServices.LayoutKind.Explicit + match structLayoutAttr with + | Some kind -> if allowed then - warning(PossibleUnverifiableCode(m)) + if kind = explicitKind then + warning(PossibleUnverifiableCode(m)) elif thisTyconRef.Typars(m).Length > 0 then errorR (Error(FSComp.SR.tcGenericTypesCannotHaveStructLayout(),m)) else errorR (Error(FSComp.SR.tcOnlyStructsCanHaveStructLayout(),m)) + | None -> () let hiddenReprChecks(hasRepr) = structLayoutAttributeCheck(false) @@ -15041,7 +15105,7 @@ module EstablishTypeDefinitionCores = let nenv' = AddFakeNameToNameEnv fspec.Name nenv (Item.RecdField info) // Name resolution gives better info for tooltips let item = FreshenRecdFieldRef cenv.nameResolver m (thisTyconRef.MakeNestedRecdFieldRef fspec) - CallNameResolutionSink cenv.tcSink (fspec.Range,nenv,item,item,ItemOccurence.Binding,envinner.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (fspec.Range,nenv,item,item,emptyTyparInst,ItemOccurence.Binding,envinner.DisplayEnv,ad) // Environment is needed for completions CallEnvSink cenv.tcSink (fspec.Range, nenv', ad) @@ -15054,7 +15118,7 @@ module EstablishTypeDefinitionCores = let nenv' = AddFakeNameToNameEnv unionCase.Id.idText nenv (Item.UnionCase(info,false)) // Report to both - as in previous function let item = Item.UnionCase(info,false) - CallNameResolutionSink cenv.tcSink (unionCase.Range,nenv,item,item,ItemOccurence.Binding,envinner.DisplayEnv,ad) + CallNameResolutionSink cenv.tcSink (unionCase.Range,nenv,item,item,emptyTyparInst,ItemOccurence.Binding,envinner.DisplayEnv,ad) CallEnvSink cenv.tcSink (unionCase.Id.idRange, nenv', ad) let typeRepr, baseValOpt, safeInitInfo = @@ -15247,7 +15311,7 @@ module EstablishTypeDefinitionCores = let (ValSpfn(_, _, _, _, _valSynData, _, _, _, _,_, m)) = valSpfn - CheckMemberFlags cenv.g None NewSlotsOK OverridesOK memberFlags m + CheckMemberFlags None NewSlotsOK OverridesOK memberFlags m let slots = fst (TcAndPublishValSpec (cenv,envinner,containerInfo,ModuleOrMemberBinding,Some memberFlags,tpenv,valSpfn)) // Multiple slots may be returned, e.g. for @@ -15407,10 +15471,11 @@ module EstablishTypeDefinitionCores = then (tycon,tycon2)::acc else acc // note: all edges added are (tycon,_) - let insertEdgeToType ty acc = - if isAppTy cenv.g ty then // guard against possible earlier failure - insertEdgeToTycon (tyconOfAppTy cenv.g ty) acc - else + let insertEdgeToType ty acc = + match tryDestAppTy cenv.g ty with + | Some tcref -> + insertEdgeToTycon tcref.Deref acc + | None -> acc // collect edges from an a struct field (which is struct-contained in tycon) @@ -15510,14 +15575,14 @@ module EstablishTypeDefinitionCores = | _ -> ()) - let TcMutRecDefns_Phase1 mkLetInfo cenv envInitial parent inSig tpenv m scopem mutRecNSInfo (mutRecDefns:MutRecShapes) = + let TcMutRecDefns_Phase1 mkLetInfo cenv envInitial parent typeNames inSig tpenv m scopem mutRecNSInfo (mutRecDefns:MutRecShapes) = // Phase1A - build Entity for type definitions, exception definitions and module definitions. // Also for abbreviations of any of these. Augmentations are skipped in this phase. let withEntities = mutRecDefns |> MutRecShapes.mapWithParent - (parent, TypeNamesInMutRecDecls mutRecDefns, envInitial) + (parent, typeNames, envInitial) // Build the initial entity for each module definition (fun (innerParent, typeNames, envForDecls) compInfo decls -> TcTyconDefnCore_Phase1A_BuildInitialModule cenv envForDecls innerParent typeNames compInfo decls) @@ -15668,7 +15733,7 @@ module TcDeclarations = /// Given a type definition, compute whether its members form an extension of an existing type, and if so if it is an /// intrinsic or extrinsic extension - let private ComputeTyconDeclKind tyconOpt isAtOriginalTyconDefn cenv envForDecls inSig m (typars:SynTyparDecl list) cs longPath = + let private ComputeTyconDeclKind tyconOpt isAtOriginalTyconDefn cenv envForDecls inSig m (synTypars:SynTyparDecl list) synTyparCxs longPath = let ad = envForDecls.eAccessRights let tcref = @@ -15676,14 +15741,14 @@ module TcDeclarations = | Some tycon when isAtOriginalTyconDefn -> // This records a name resolution of the type at the location - let resInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs typars.Length + let resInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs synTypars.Length ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.Binding OpenQualified envForDecls.eNameResEnv ad longPath resInfo PermitDirectReferenceToGeneratedType.No |> ignore mkLocalTyconRef tycon | _ -> - let resInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs typars.Length + let resInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs synTypars.Length match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.Binding OpenQualified envForDecls.eNameResEnv ad longPath resInfo PermitDirectReferenceToGeneratedType.No with | Result res -> res | res when inSig && longPath.Length = 1 -> @@ -15715,20 +15780,26 @@ module TcDeclarations = // There is a special case we allow when compiling FSharp.Core.dll which permits interface implementations across namespace fragments (cenv.g.compilingFslib && tcref.LogicalName.StartsWith("Tuple`")) + let nReqTypars = reqTypars.Length + + let declaredTypars = TcTyparDecls cenv envForDecls synTypars + let envForTycon = AddDeclaredTypars CheckForDuplicateTypars declaredTypars envForDecls + let _tpenv = TcTyparConstraints cenv NoNewTypars CheckCxs ItemOccurence.UseInType envForTycon emptyUnscopedTyparEnv synTyparCxs + declaredTypars |> List.iter (SetTyparRigid cenv.g envForDecls.DisplayEnv m) + if isInSameModuleOrNamespace && not isInterfaceOrDelegateOrEnum then + // For historical reasons we only give a warning for incorrect type parameters on intrinsic extensions + if nReqTypars <> synTypars.Length then + warning(Error(FSComp.SR.tcDeclaredTypeParametersForExtensionDoNotMatchOriginal(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) + if not (typarsAEquiv cenv.g TypeEquivEnv.Empty reqTypars declaredTypars) then + warning(Error(FSComp.SR.tcDeclaredTypeParametersForExtensionDoNotMatchOriginal(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) + // Note we return 'reqTypars' for intrinsic extensions since we may only have given warnings IntrinsicExtensionBinding, reqTypars else if isInSameModuleOrNamespace && isInterfaceOrDelegateOrEnum then errorR(Error(FSComp.SR.tcMembersThatExtendInterfaceMustBePlacedInSeparateModule(),tcref.Range)) - let nReqTypars = reqTypars.Length - if nReqTypars <> typars.Length then - // not recoverable + if nReqTypars <> synTypars.Length then error(Error(FSComp.SR.tcDeclaredTypeParametersForExtensionDoNotMatchOriginal(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) - - let declaredTypars = TcTyparDecls cenv envForDecls typars - let envForTycon = AddDeclaredTypars CheckForDuplicateTypars declaredTypars envForDecls - let _tpenv = TcTyparConstraints cenv NoNewTypars CheckCxs ItemOccurence.UseInType envForTycon emptyUnscopedTyparEnv cs - declaredTypars |> List.iter (SetTyparRigid cenv.g envForDecls.DisplayEnv m) if not (typarsAEquiv cenv.g TypeEquivEnv.Empty reqTypars declaredTypars) then errorR(Error(FSComp.SR.tcDeclaredTypeParametersForExtensionDoNotMatchOriginal(tcref.DisplayNameWithStaticParametersAndUnderscoreTypars), m)) ExtrinsicExtensionBinding, declaredTypars @@ -15748,7 +15819,7 @@ module TcDeclarations = let private isField = function SynMemberDefn.ValField (_,_) -> true | _ -> false let private isTycon = function SynMemberDefn.NestedType _ -> true | _ -> false - let private allFalse ps x = List.fold (fun acc p -> acc && not (p x)) true ps + let private allFalse ps x = List.forall (fun p -> not (p x)) ps /// Check the ordering on the bindings and members in a class construction // Accepted forms: @@ -15976,7 +16047,7 @@ module TcDeclarations = //------------------------------------------------------------------------- /// Bind a collection of mutually recursive definitions in an implementation file - let TcMutRecDefinitions cenv envInitial parent tpenv m scopem mutRecNSInfo (mutRecDefns: MutRecDefnsInitialData) = + let TcMutRecDefinitions cenv envInitial parent typeNames tpenv m scopem mutRecNSInfo (mutRecDefns: MutRecDefnsInitialData) = // Split the definitions into "core representations" and "members". The code to process core representations // is shared between processing of signature files and implementation files. @@ -15986,7 +16057,7 @@ module TcDeclarations = let tycons, envMutRecPrelim, mutRecDefnsAfterCore = EstablishTypeDefinitionCores.TcMutRecDefns_Phase1 (fun containerInfo synBinds -> [ for synBind in synBinds -> RecDefnBindingInfo(containerInfo,NoNewSlots,ModuleOrMemberBinding,synBind) ]) - cenv envInitial parent false tpenv m scopem mutRecNSInfo mutRecDefnsAfterSplit + cenv envInitial parent typeNames false tpenv m scopem mutRecNSInfo mutRecDefnsAfterSplit // Package up the phase two information for processing members. let mutRecDefnsAfterPrep = @@ -16071,7 +16142,7 @@ module TcDeclarations = let preEstablishedHasDefaultCtor = members |> List.exists (function | SynMemberSig.Member (valSpfn,memberFlags,_) -> - memberFlags.MemberKind=MemberKind.Constructor && + memberFlags.MemberKind=MemberKind.Constructor && // REVIEW: This is a syntactic approximation (match valSpfn.SynType, valSpfn.SynInfo.ArgInfos with | SynType.Fun (SynType.LongIdent (LongIdentWithDots([id],_)), _, _), [[_]] when id.idText = "unit" -> true @@ -16127,9 +16198,9 @@ module TcDeclarations = /// Bind a collection of mutually recursive declarations in a signature file - let TcMutRecSignatureDecls cenv envInitial parent tpenv m scopem mutRecNSInfo (mutRecSigs:MutRecSigsInitialData) = + let TcMutRecSignatureDecls cenv envInitial parent typeNames tpenv m scopem mutRecNSInfo (mutRecSigs:MutRecSigsInitialData) = let mutRecSigsAfterSplit = mutRecSigs |> MutRecShapes.mapTycons SplitTyconSignature - let _tycons, envMutRec, mutRecDefnsAfterCore = EstablishTypeDefinitionCores.TcMutRecDefns_Phase1 (fun containerInfo valDecl -> (containerInfo, valDecl)) cenv envInitial parent true tpenv m scopem mutRecNSInfo mutRecSigsAfterSplit + let _tycons, envMutRec, mutRecDefnsAfterCore = EstablishTypeDefinitionCores.TcMutRecDefns_Phase1 (fun containerInfo valDecl -> (containerInfo, valDecl)) cenv envInitial parent typeNames true tpenv m scopem mutRecNSInfo mutRecSigsAfterSplit // Updates the types of the modules to contain the contents so far, which now includes values and members MutRecBindingChecking.TcMutRecDefns_UpdateModuleContents mutRecNSInfo mutRecDefnsAfterCore @@ -16168,7 +16239,7 @@ let rec TcSignatureElementNonMutRec cenv parent typeNames endm (env: TcEnv) synS | SynModuleSigDecl.Types (typeSpecs,m) -> let scopem = unionRanges m endm let mutRecDefns = typeSpecs |> List.map MutRecShape.Tycon - let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent emptyUnscopedTyparEnv m scopem None mutRecDefns + let env = TcDeclarations.TcMutRecSignatureDecls cenv env parent typeNames emptyUnscopedTyparEnv m scopem None mutRecDefns return env | SynModuleSigDecl.Open (mp,m) -> @@ -16191,7 +16262,8 @@ let rec TcSignatureElementNonMutRec cenv parent typeNames endm (env: TcEnv) synS if isRec then // Treat 'module rec M = ...' as a single mutually recursive definition group 'module M = ...' let modDecl = SynModuleSigDecl.NestedModule(compInfo,false,mdefs,m) - return! TcSignatureElementsMutRec cenv parent endm None env [modDecl] + + return! TcSignatureElementsMutRec cenv parent typeNames endm None env [modDecl] else let id = ComputeModuleName longPath let vis,_ = ComputeAccessAndCompPath env None im vis None parent @@ -16218,10 +16290,13 @@ let rec TcSignatureElementNonMutRec cenv parent typeNames endm (env: TcEnv) synS let ad = env.eAccessRights let mvvs = ForceRaise (ResolveLongIndentAsModuleOrNamespace ResultCollectionSettings.AllResults cenv.amap m OpenQualified env.eNameResEnv ad p) let scopem = unionRanges m endm - let modrefs = mvvs |> List.map p23 - if modrefs.Length > 0 && modrefs |> List.forall (fun modref -> modref.IsNamespace) then - errorR(Error(FSComp.SR.tcModuleAbbreviationForNamespace(fullDisplayTextOfModRef (List.head modrefs)),m)) - let modrefs = modrefs |> List.filter (fun modref -> not modref.IsNamespace) + let unfilteredModrefs = mvvs |> List.map p23 + + let modrefs = unfilteredModrefs |> List.filter (fun modref -> not modref.IsNamespace) + + if unfilteredModrefs.Length > 0 && List.isEmpty modrefs then + errorR(Error(FSComp.SR.tcModuleAbbreviationForNamespace(fullDisplayTextOfModRef (List.head unfilteredModrefs)),m)) + modrefs |> List.iter (fun modref -> CheckEntityAttributes cenv.g modref m |> CommitOperationResult) let env = @@ -16298,32 +16373,21 @@ and TcSignatureElements cenv parent endm env xml mutRecNSInfo defs = if cenv.compilingCanonicalFslibModuleType then ensureCcuHasModuleOrNamespaceAtPath cenv.topCcu env.ePath env.eCompPath (xml.ToXmlDoc()) + let typeNames = EstablishTypeDefinitionCores.TypeNamesInNonMutRecSigDecls defs match mutRecNSInfo with | Some _ -> - return! TcSignatureElementsMutRec cenv parent endm mutRecNSInfo env defs + return! TcSignatureElementsMutRec cenv parent typeNames endm mutRecNSInfo env defs | None -> - return! TcSignatureElementsNonMutRec cenv parent endm env defs + return! TcSignatureElementsNonMutRec cenv parent typeNames endm env defs } -and TcSignatureElementsNonMutRec cenv parent endm env defs = +and TcSignatureElementsNonMutRec cenv parent typeNames endm env defs = eventually { - // Collect the type names so we can implicitly add the compilation suffix to module names - let typeNames = - [ for def in defs do - match def with - | SynModuleSigDecl.Types (typeSpecs,_) -> - for (TypeDefnSig(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,extraMembers,_)) in typeSpecs do - if isNil typars then - match trepr with - | SynTypeDefnSigRepr.Simple((SynTypeDefnSimpleRepr.None _),_) when not (isNil extraMembers) -> () - | _ -> yield (List.last ids).idText - | _ -> () ] - |> set return! Eventually.fold (TcSignatureElementNonMutRec cenv parent typeNames endm) env defs } -and TcSignatureElementsMutRec cenv parent endm mutRecNSInfo envInitial (defs: SynModuleSigDecl list) = +and TcSignatureElementsMutRec cenv parent typeNames endm mutRecNSInfo envInitial (defs: SynModuleSigDecl list) = eventually { let m = match defs with [] -> endm | _ -> defs |> List.map (fun d -> d.Range) |> List.reduce unionRanges let scopem = (defs, endm) ||> List.foldBack (fun h m -> unionRanges h.Range m) @@ -16371,7 +16435,7 @@ and TcSignatureElementsMutRec cenv parent endm mutRecNSInfo envInitial (defs: Sy |> fst loop (match parent with ParentNone -> true | Parent _ -> false) defs - return TcDeclarations.TcMutRecSignatureDecls cenv envInitial parent emptyUnscopedTyparEnv m scopem mutRecNSInfo mutRecDefns + return TcDeclarations.TcMutRecSignatureDecls cenv envInitial parent typeNames emptyUnscopedTyparEnv m scopem mutRecNSInfo mutRecDefns } @@ -16457,7 +16521,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv:cenv) parent typeNames scopem | SynModuleDecl.Types (typeDefs,m) -> let scopem = unionRanges m scopem let mutRecDefns = typeDefs |> List.map MutRecShape.Tycon - let mutRecDefnsChecked,envAfter = TcDeclarations.TcMutRecDefinitions cenv env parent tpenv m scopem None mutRecDefns + let mutRecDefnsChecked,envAfter = TcDeclarations.TcMutRecDefinitions cenv env parent typeNames tpenv m scopem None mutRecDefns // Check the non-escaping condition as we build the expression on the way back up let exprfWithEscapeCheck e = TcMutRecDefnsEscapeCheck mutRecDefnsChecked env @@ -16503,7 +16567,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv:cenv) parent typeNames scopem if isRec then assert (not isContinuingModule) let modDecl = SynModuleDecl.NestedModule(compInfo, false, mdefs, isContinuingModule, m) - return! TcModuleOrNamespaceElementsMutRec cenv parent m env None [modDecl] + return! TcModuleOrNamespaceElementsMutRec cenv parent typeNames m env None [modDecl] else let (ComponentInfo(attribs,_parms, _constraints,longPath,xml,_,vis,im)) = compInfo let id = ComputeModuleName longPath @@ -16575,8 +16639,6 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv:cenv) parent typeNames scopem let mtypNS = !(envNS.eModuleOrNamespaceTypeAccumulator) let mtypRoot, mspecNSOpt = BuildRootModuleType enclosingNamespacePath envNS.eCompPath mtypNS - // TODO: test 'namespace rec global' - // For 'namespace rec' and 'module rec' we add the thing being defined let envNS = if isRec then AddLocalRootModuleOrNamespace cenv.tcSink cenv.g cenv.amap m envNS mtypRoot else envNS let nsInfo = Some (mspecNSOpt, envNS.eModuleOrNamespaceTypeAccumulator) @@ -16632,7 +16694,7 @@ and TcModuleOrNamespaceElementsNonMutRec cenv parent typeNames endm (defsSoFar, } /// The mutually recursive case for a sequence of declarations (and nested modules) -and TcModuleOrNamespaceElementsMutRec cenv parent endm envInitial mutRecNSInfo (defs: SynModuleDecl list) = +and TcModuleOrNamespaceElementsMutRec cenv parent typeNames endm envInitial mutRecNSInfo (defs: SynModuleDecl list) = eventually { let m = match defs with [] -> endm | _ -> defs |> List.map (fun d -> d.Range) |> List.reduce unionRanges @@ -16691,7 +16753,7 @@ and TcModuleOrNamespaceElementsMutRec cenv parent endm envInitial mutRecNSInfo ( loop (match parent with ParentNone -> true | Parent _ -> false) [] defs let tpenv = emptyUnscopedTyparEnv - let mutRecDefnsChecked,envAfter = TcDeclarations.TcMutRecDefinitions cenv envInitial parent tpenv m scopem mutRecNSInfo mutRecDefns + let mutRecDefnsChecked,envAfter = TcDeclarations.TcMutRecDefinitions cenv envInitial parent typeNames tpenv m scopem mutRecNSInfo mutRecDefns // Check the assembly attributes let attrs, _ = TcAttributesWithPossibleTargets false cenv envAfter AttributeTargets.Top synAttrs @@ -16728,26 +16790,17 @@ and TcModuleOrNamespaceElements cenv parent endm env xml mutRecNSInfo defs = if cenv.compilingCanonicalFslibModuleType then ensureCcuHasModuleOrNamespaceAtPath cenv.topCcu env.ePath env.eCompPath (xml.ToXmlDoc()) + // Collect the type names so we can implicitly add the compilation suffix to module names + let typeNames = EstablishTypeDefinitionCores.TypeNamesInNonMutRecDecls defs + match mutRecNSInfo with | Some _ -> - let! (exprf, topAttrsNew), _, envAtEnd = TcModuleOrNamespaceElementsMutRec cenv parent endm env mutRecNSInfo defs + let! (exprf, topAttrsNew), _, envAtEnd = TcModuleOrNamespaceElementsMutRec cenv parent typeNames endm env mutRecNSInfo defs // Apply the functions for each declaration to build the overall expression-builder let mexpr = TMDefs(exprf []) return (mexpr, topAttrsNew, envAtEnd) | None -> - // Collect the type names so we can implicitly add the compilation suffix to module names - let typeNames = - [ for def in defs do - match def with - | SynModuleDecl.Types (typeSpecs,_) -> - for (TypeDefn(ComponentInfo(_,typars,_,ids,_,_,_,_),trepr,_,_)) in typeSpecs do - if isNil typars then - match trepr with - | SynTypeDefnRepr.ObjectModel(TyconAugmentation,_,_) -> () - | _ -> yield (List.last ids).idText - | _ -> () ] - |> set let! compiledDefs, envAtEnd = TcModuleOrNamespaceElementsNonMutRec cenv parent typeNames endm ([], env, env) defs @@ -16847,7 +16900,7 @@ let ApplyDefaults cenv g denvAtEnd m mexpr extraAttribs = match tpc with | TyparConstraint.DefaultsTo(priority2,ty2,m) when priority2 = priority -> let ty1 = mkTyparTy tp - if not tp.IsSolved && not (typeEquiv cenv.g ty1 ty2) then + if not tp.IsSolved && not (typeEquiv cenv.g ty1 ty2) then let csenv = MakeConstraintSolverEnv ContextInfo.NoContext cenv.css m denvAtEnd TryD (fun () -> ConstraintSolver.SolveTyparEqualsTyp csenv 0 m NoTrace ty1 ty2) (fun e -> solveTypAsError cenv denvAtEnd m ty1 @@ -17002,14 +17055,14 @@ let TypeCheckOneImplFile conditionallySuppressErrorReporting (checkForErrors()) (fun () -> try let reportErrors = not (checkForErrors()) - Microsoft.FSharp.Compiler.PostTypeCheckSemanticChecks.CheckTopImpl (g,cenv.amap,reportErrors,cenv.infoReader,env.eInternalsVisibleCompPaths,cenv.topCcu,envAtEnd.DisplayEnv, implFileExprAfterSig,extraAttribs,isLastCompiland) + PostTypeCheckSemanticChecks.CheckTopImpl (g,cenv.amap,reportErrors,cenv.infoReader,env.eInternalsVisibleCompPaths,cenv.topCcu,envAtEnd.DisplayEnv, implFileExprAfterSig,extraAttribs,isLastCompiland) with e -> errorRecovery e m false) - let implFile = TImplFile(qualNameOfFile,scopedPragmas, implFileExprAfterSig, hasExplicitEntryPoint,isScript) + let implFile = TImplFile(qualNameOfFile, scopedPragmas, implFileExprAfterSig, hasExplicitEntryPoint, isScript) - return (topAttrs,implFile,envAtEnd) + return (topAttrs,implFile,envAtEnd,cenv.createsGeneratedProvidedTypes) } @@ -17029,5 +17082,5 @@ let TypeCheckOneSigFile (g,niceNameGen,amap,topCcu,checkForErrors,conditionalDe try sigFileType |> IterTyconsOfModuleOrNamespaceType (FinalTypeDefinitionChecksAtEndOfInferenceScope(cenv.infoReader, tcEnv.NameEnv, cenv.tcSink, false, tcEnv.DisplayEnv)) with e -> errorRecovery e qualNameOfFile.Range - return (tcEnv,tcEnv,sigFileType) + return (tcEnv,sigFileType,cenv.createsGeneratedProvidedTypes) } diff --git a/src/fsharp/TypeChecker.fsi b/src/fsharp/TypeChecker.fsi index ef860c4bc0..c9e803b8fb 100644 --- a/src/fsharp/TypeChecker.fsi +++ b/src/fsharp/TypeChecker.fsi @@ -48,13 +48,13 @@ val TypeCheckOneImplFile : -> TcEnv -> Tast.ModuleOrNamespaceType option -> ParsedImplFileInput - -> Eventually + -> Eventually val TypeCheckOneSigFile : TcGlobals * NiceNameGenerator * ImportMap * CcuThunk * (unit -> bool) * ConditionalDefines * NameResolution.TcResultsSink -> TcEnv -> ParsedSigFileInput - -> Eventually + -> Eventually //------------------------------------------------------------------------- // Some of the exceptions arising from type checking. These should be moved to @@ -64,6 +64,7 @@ val TypeCheckOneSigFile : exception BakedInMemberConstraintName of string * range exception FunctionExpected of DisplayEnv * TType * range exception NotAFunction of DisplayEnv * TType * range * range +exception NotAFunctionButIndexer of DisplayEnv * TType * string option * range * range exception Recursion of DisplayEnv * Ast.Ident * TType * TType * range exception RecursiveUseCheckedAtRuntime of DisplayEnv * ValRef * range exception LetRecEvaluatedOutOfOrder of DisplayEnv * ValRef * ValRef * range diff --git a/src/fsharp/TypeRelations.fs b/src/fsharp/TypeRelations.fs index 486a1f2315..da7ccae5f9 100755 --- a/src/fsharp/TypeRelations.fs +++ b/src/fsharp/TypeRelations.fs @@ -4,28 +4,16 @@ /// constraint solving and method overload resolution. module internal Microsoft.FSharp.Compiler.TypeRelations -open Internal.Utilities -open System.Text - 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.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.AbstractIL.IL -open Microsoft.FSharp.Compiler.Lib open Microsoft.FSharp.Compiler.Infos open Microsoft.FSharp.Compiler.PrettyNaming -open Microsoft.FSharp.Compiler.AccessibilityLogic -open Microsoft.FSharp.Compiler.NameResolution //------------------------------------------------------------------------- // a :> b without coercion based on finalized (no type variable) types @@ -285,7 +273,7 @@ let IteratedAdjustArityOfLambda g amap topValInfo e = let tps,ctorThisValOpt,baseValOpt,vsl,body,bodyty = destTopLambda g amap topValInfo (e, tyOfExpr g e) let arities = topValInfo.AritiesOfArgs if arities.Length <> vsl.Length then - errorR(InternalError(sprintf "IteratedAdjustArityOfLambda, List.length arities = %d, List.length vsl = %d" (List.length arities) (List.length vsl), body.Range)) + errorR(InternalError(sprintf "IteratedAdjustArityOfLambda, List.length arities = %d, List.length vsl = %d" arities.Length vsl.Length, body.Range)) let vsl,body = IteratedAdjustArityOfLambdaBody g arities vsl body tps,ctorThisValOpt,baseValOpt,vsl,body,bodyty diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index 8c747a26b0..367f953f39 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.Ast +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.Ast +#else +module internal Microsoft.FSharp.Compiler.Ast +#endif open System.Collections.Generic open Internal.Utilities @@ -532,7 +536,7 @@ and | ForEach of forSeqPoint:SequencePointInfoForForLoop * seqExprOnly:SeqExprOnly * isFromSource:bool * pat:SynPat * enumExpr:SynExpr * bodyExpr:SynExpr * range:range /// F# syntax: [ expr ], [| expr |] - | ArrayOrListOfSeqExpr of isList:bool * expr:SynExpr * range:range + | ArrayOrListOfSeqExpr of isArray:bool * expr:SynExpr * range:range /// CompExpr(isArrayOrList, isNotNakedRefCell, expr) /// @@ -2119,6 +2123,7 @@ type LexerWhitespaceContinuation = | StringInComment of ifdef:LexerIfdefStackEntries * int * range:range | VerbatimStringInComment of ifdef:LexerIfdefStackEntries * int * range:range | TripleQuoteStringInComment of ifdef:LexerIfdefStackEntries * int * range:range + | MLOnly of ifdef:LexerIfdefStackEntries * range:range | EndLine of LexerEndlineContinuation member x.LexerIfdefStack = @@ -2132,7 +2137,8 @@ type LexerWhitespaceContinuation = | LexCont.TripleQuoteString (ifdef=ifd) | LexCont.StringInComment (ifdef=ifd) | LexCont.VerbatimStringInComment (ifdef=ifd) - | LexCont.TripleQuoteStringInComment (ifdef=ifd) -> ifd + | LexCont.TripleQuoteStringInComment (ifdef=ifd) + | LexCont.MLOnly (ifdef=ifd) -> ifd | LexCont.EndLine endl -> endl.LexerIfdefStack and LexCont = LexerWhitespaceContinuation diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index a8809f75ca..4f13c65b14 100755 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -86,15 +86,12 @@ type ErrorLoggerUpToMaxErrors(tcConfigB: TcConfigBuilder, exiter: Exiter, nameFo errors <- errors + 1 - match err.Exception with - | InternalError _ - | Failure _ - | :? KeyNotFoundException -> - match tcConfigB.simulateException with - | Some _ -> () // Don't show an assert for simulateException case so that unittests can run without an assert dialog. - | None -> Debug.Assert(false, sprintf "Bug seen in compiler: %s" (err.ToString())) - | _ -> - () + match err.Exception, tcConfigB.simulateException with + | InternalError (msg, _), None + | Failure msg, None -> Debug.Assert(false, sprintf "Bug in compiler: %s\n%s" msg (err.Exception.ToString())) + | :? KeyNotFoundException, None -> Debug.Assert(false, sprintf "Lookup exception in compiler: %s" (err.Exception.ToString())) + | _ -> () + elif ReportWarning (tcConfigB.globalWarnLevel, tcConfigB.specificWarnOff, tcConfigB.specificWarnOn) err then x.HandleIssue(tcConfigB, err, isError) @@ -247,11 +244,14 @@ let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder, setProcessThreadLocals, ParseCompilerOptions (collect, GetCoreFscCompilerOptions tcConfigB, List.tail (PostProcessCompilerArgs abbrevArgs argv)) if not (tcConfigB.portablePDB || tcConfigB.embeddedPDB) then - if tcConfigB.embedAllSource || (tcConfigB.embedSourceList |> List.length <> 0) then + if tcConfigB.embedAllSource || (tcConfigB.embedSourceList |> isNil |> not) then error(Error(FSComp.SR.optsEmbeddedSourceRequirePortablePDBs(), rangeCmdArgs)) if not (String.IsNullOrEmpty(tcConfigB.sourceLink)) then error(Error(FSComp.SR.optsSourceLinkRequirePortablePDBs(), rangeCmdArgs)) + if tcConfigB.deterministic && tcConfigB.debuginfo && (tcConfigB.portablePDB = false) then + error(Error(FSComp.SR.fscDeterministicDebugRequiresPortablePdb(), rangeCmdArgs)) + let inputFiles = List.rev !inputFilesRef // Check if we have a codepage from the console @@ -424,20 +424,7 @@ module XmlDocWriter = fprintfn os "" -//---------------------------------------------------------------------------- -// DefaultFSharpBinariesDir -//---------------------------------------------------------------------------- - -let DefaultFSharpBinariesDir = -#if FX_NO_APP_DOMAINS - System.AppContext.BaseDirectory -#else - let exeName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName) - Filename.directoryName exeName -#endif - -let outpath outfile extn = - String.concat "." (["out"; Filename.chopExtension (Filename.fileNameOfPath outfile); extn]) +let DefaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(FSharpEnvironment.tryCurrentDomain()).Value //---------------------------------------------------------------------------- // GenerateInterfaceData, EncodeInterfaceData @@ -720,9 +707,11 @@ module AttributeHelpers = None // Try to find an AssemblyVersion attribute - let TryFindVersionAttribute g attrib attribName attribs = + let TryFindVersionAttribute g attrib attribName attribs deterministic = match TryFindStringAttribute g attrib attribs with | Some versionString -> + if deterministic && versionString.Contains("*") then + errorR(Error(FSComp.SR.fscAssemblyWildcardAndDeterminism(attribName, versionString), Range.rangeStartup)) try Some (IL.parseILVersion versionString) with e -> warning(Error(FSComp.SR.fscBadAssemblyVersion(attribName, versionString), Range.rangeStartup)) @@ -774,9 +763,9 @@ module MainModuleBuilder = CustomAttrs = mkILCustomAttrs List.empty }) |> Seq.toList - let createSystemNumericsExportList (tcGlobals: TcGlobals) (tcImports:TcImports) = + let createSystemNumericsExportList (tcConfig: TcConfig) (tcImports:TcImports) = let refNumericsDllName = - if tcGlobals.usesMscorlib then "System.Numerics" + if (tcConfig.primaryAssembly.Name = "mscorlib") then "System.Numerics" else "System.Runtime.Numerics" let numericsAssemblyRef = match tcImports.GetImportedAssemblies() |> List.tryFind(fun a -> a.FSharpViewOfMetadata.AssemblyName = refNumericsDllName) with @@ -855,7 +844,7 @@ module MainModuleBuilder = let exportedTypesList = if (tcConfig.compilingFslib && tcConfig.compilingFslib40) then (List.append (createMscorlibExportList tcGlobals) - (if tcConfig.compilingFslibNoBigInt then [] else (createSystemNumericsExportList tcGlobals tcImports)) + (if tcConfig.compilingFslibNoBigInt then [] else (createSystemNumericsExportList tcConfig tcImports)) ) else [] @@ -1632,7 +1621,7 @@ let CopyFSharpCore(outFile: string, referencedDlls: AssemblyReference list) = [] type Args<'T> = Args of 'T -let main0(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMemory:bool, exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) = +let main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinariesInMemory:bool, defaultCopyFSharpCore: bool, exiter:Exiter, errorLoggerProvider : ErrorLoggerProvider, disposables : DisposablesTracker) = // See Bug 735819 let lcidFromCodePage = @@ -1648,12 +1637,14 @@ let main0(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMem let directoryBuildingFrom = Directory.GetCurrentDirectory() let setProcessThreadLocals tcConfigB = -#if COMPILER_SERVICE tcConfigB.openBinariesInMemory <- openBinariesInMemory -#endif #if PREFERRED_UI_LANG match tcConfigB.preferredUiLang with +#if FX_RESHAPED_GLOBALIZATION | Some s -> System.Globalization.CultureInfo.CurrentUICulture <- new System.Globalization.CultureInfo(s) +#else + | Some s -> Thread.CurrentThread.CurrentUICulture <- new System.Globalization.CultureInfo(s) +#endif | None -> () #else match tcConfigB.lcid with @@ -1670,7 +1661,7 @@ let main0(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMem let optimizeForMemory = false // optimizeForMemory - fsc.exe can use as much memory as it likes to try to compile as fast as possible - let tcConfigB = TcConfigBuilder.CreateNew(referenceResolver, DefaultFSharpBinariesDir, optimizeForMemory, directoryBuildingFrom, isInteractive=false, isInvalidationSupported=false) + let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, DefaultFSharpBinariesDir, optimizeForMemory, directoryBuildingFrom, isInteractive=false, isInvalidationSupported=false, defaultCopyFSharpCore=defaultCopyFSharpCore) // Preset: --optimize+ -g --tailcalls+ (see 4505) SetOptimizeSwitch tcConfigB OptionSwitch.On SetDebugSwitch tcConfigB None OptionSwitch.Off @@ -1828,7 +1819,7 @@ let main1(Args (ctok, tcGlobals, tcImports: TcImports, frameworkTcImports, gener // Try to find an AssemblyVersion attribute let assemVerFromAttrib = - match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" "AssemblyVersionAttribute" topAttrs.assemblyAttrs with + match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" "AssemblyVersionAttribute" topAttrs.assemblyAttrs tcConfig.deterministic with | Some v -> match tcConfig.version with | VersionNone -> Some v @@ -1858,10 +1849,9 @@ let main1(Args (ctok, tcGlobals, tcImports: TcImports, frameworkTcImports, gener // set up typecheck for given AST without parsing any command line parameters -let main1OfAst (ctok, referenceResolver, openBinariesInMemory, assemblyName, target, outfile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider: ErrorLoggerProvider, inputs : ParsedInput list) = +let main1OfAst (ctok, legacyReferenceResolver, openBinariesInMemory, assemblyName, target, outfile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider: ErrorLoggerProvider, inputs : ParsedInput list) = - let defaultFSharpBinariesDir = Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(None).Value - let tcConfigB = TcConfigBuilder.CreateNew(referenceResolver, defaultFSharpBinariesDir, (*optimizeForMemory*) false, Directory.GetCurrentDirectory(), isInteractive=false, isInvalidationSupported=false) + let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, DefaultFSharpBinariesDir, (*optimizeForMemory*) false, Directory.GetCurrentDirectory(), isInteractive=false, isInvalidationSupported=false, defaultCopyFSharpCore=false) tcConfigB.openBinariesInMemory <- openBinariesInMemory tcConfigB.framework <- not noframework // Preset: --optimize+ -g --tailcalls+ (see 4505) @@ -1915,7 +1905,7 @@ let main1OfAst (ctok, referenceResolver, openBinariesInMemory, assemblyName, tar // Try to find an AssemblyVersion attribute let assemVerFromAttrib = - match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" "AssemblyVersionAttribute" topAttrs.assemblyAttrs with + match AttributeHelpers.TryFindVersionAttribute tcGlobals "System.Reflection.AssemblyVersionAttribute" "AssemblyVersionAttribute" topAttrs.assemblyAttrs tcConfig.deterministic with | Some v -> match tcConfig.version with | VersionNone -> Some v @@ -1984,7 +1974,7 @@ let main2b (tcImportsCapture,dynamicAssemblyCreator) (Args (ctok, tcConfig: TcCo // Check if System.SerializableAttribute exists in mscorlib.dll, // so that make sure the compiler only emits "serializable" bit into IL metadata when it is available. // Note that SerializableAttribute may be relocated in the future but now resides in mscorlib. - let codegenResults = GenerateIlxCode (IlReflectBackend, Option.isSome dynamicAssemblyCreator, false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator) + let codegenResults = GenerateIlxCode ((if Option.isSome dynamicAssemblyCreator then IlReflectBackend else IlWriteBackend), Option.isSome dynamicAssemblyCreator, false, tcConfig, topAttrs, optimizedImpls, generatedCcu.AssemblyName, ilxGenerator) let casApplied = new Dictionary() let securityAttrs, topAssemblyAttrs = topAttrs.assemblyAttrs |> List.partition (fun a -> TypeChecker.IsSecurityAttribute tcGlobals (tcImports.GetImportMap()) casApplied a rangeStartup) // remove any security attributes from the top-level assembly attribute list @@ -2035,6 +2025,7 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, errorLogger: ErrorLogger { ilg = tcGlobals.ilg pdbfile=pdbfile emitTailcalls = tcConfig.emitTailcalls + deterministic = tcConfig.deterministic showTimes = tcConfig.showTimes portablePDB = tcConfig.portablePDB embeddedPDB = tcConfig.embeddedPDB @@ -2064,12 +2055,12 @@ let main4 dynamicAssemblyCreator (Args (ctok, tcConfig, errorLogger: ErrorLogger //----------------------------------------------------------------------------- /// Entry point typecheckAndCompile -let typecheckAndCompile (ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMemory, exiter:Exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = +let typecheckAndCompile (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinariesInMemory, defaultCopyFSharpCore, exiter:Exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = use d = new DisposablesTracker() use e = new SaveAndRestoreConsoleEncoding() - main0(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMemory, exiter, errorLoggerProvider, d) + main0(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinariesInMemory, defaultCopyFSharpCore, exiter, errorLoggerProvider, d) |> main1 |> main2a |> main2b (tcImportsCapture,dynamicAssemblyCreator) @@ -2077,14 +2068,14 @@ let typecheckAndCompile (ctok, argv, referenceResolver, bannerAlreadyPrinted, op |> main4 dynamicAssemblyCreator -let compileOfAst (ctok, referenceResolver, openBinariesInMemory, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs, tcImportsCapture, dynamicAssemblyCreator) = - main1OfAst (ctok, referenceResolver, openBinariesInMemory, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs) +let compileOfAst (ctok, legacyReferenceResolver, openBinariesInMemory, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs, tcImportsCapture, dynamicAssemblyCreator) = + main1OfAst (ctok, legacyReferenceResolver, openBinariesInMemory, assemblyName, target, outFile, pdbFile, dllReferences, noframework, exiter, errorLoggerProvider, inputs) |> main2a |> main2b (tcImportsCapture, dynamicAssemblyCreator) |> main3 |> main4 dynamicAssemblyCreator -let mainCompile (ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMemory, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = +let mainCompile (ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinariesInMemory, defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) = //System.Runtime.GCSettings.LatencyMode <- System.Runtime.GCLatencyMode.Batch - typecheckAndCompile(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMemory, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) + typecheckAndCompile(ctok, argv, legacyReferenceResolver, bannerAlreadyPrinted, openBinariesInMemory, defaultCopyFSharpCore, exiter, errorLoggerProvider, tcImportsCapture, dynamicAssemblyCreator) diff --git a/src/fsharp/fsc.fsi b/src/fsharp/fsc.fsi index 5fdc1c5fa1..d6c115d10d 100755 --- a/src/fsharp/fsc.fsi +++ b/src/fsharp/fsc.fsi @@ -32,9 +32,10 @@ val internal ProcessCommandLineFlags : TcConfigBuilder * setProcessThreadLocals: val typecheckAndCompile : ctok: CompilationThreadToken * argv : string[] * - referenceResolver: ReferenceResolver.Resolver * + legacyReferenceResolver: ReferenceResolver.Resolver * bannerAlreadyPrinted : bool * openBinariesInMemory: bool * + defaultCopyFSharpCore: bool * exiter : Exiter * loggerProvider: ErrorLoggerProvider * tcImportsCapture: (TcImports -> unit) option * @@ -44,9 +45,10 @@ val typecheckAndCompile : val mainCompile : ctok: CompilationThreadToken * argv: string[] * - referenceResolver: ReferenceResolver.Resolver * + legacyReferenceResolver: ReferenceResolver.Resolver * bannerAlreadyPrinted: bool * openBinariesInMemory: bool * + defaultCopyFSharpCore: bool * exiter: Exiter * loggerProvider: ErrorLoggerProvider * tcImportsCapture: (TcImports -> unit) option * @@ -55,7 +57,7 @@ val mainCompile : val compileOfAst : ctok: CompilationThreadToken * - referenceResolver: ReferenceResolver.Resolver * + legacyReferenceResolver: ReferenceResolver.Resolver * openBinariesInMemory: bool * assemblyName:string * target:CompilerTarget * @@ -78,9 +80,14 @@ type InProcErrorLoggerProvider = member CapturedWarnings : Diagnostic[] member CapturedErrors : Diagnostic[] +/// The default ErrorLogger implementation, reporting messages to the Console up to the maxerrors maximum +type ConsoleLoggerProvider = + new : unit -> ConsoleLoggerProvider + inherit ErrorLoggerProvider +// For unit testing module internal MainModuleBuilder = - val fileVersion: warn: (exn -> unit) -> findStringAttr: (string -> string option) -> assemblyVersion: AbstractIL.IL.ILVersionInfo -> AbstractIL.IL.ILVersionInfo - val productVersion: warn: (exn -> unit) -> findStringAttr: (string -> string option) -> fileVersion: AbstractIL.IL.ILVersionInfo -> string - val productVersionToILVersionInfo: string -> AbstractIL.IL.ILVersionInfo + val fileVersion: warn: (exn -> unit) -> findStringAttr: (string -> string option) -> assemblyVersion: ILVersionInfo -> ILVersionInfo + val productVersion: warn: (exn -> unit) -> findStringAttr: (string -> string option) -> fileVersion: ILVersionInfo -> string + val productVersionToILVersionInfo: string -> ILVersionInfo diff --git a/src/fsharp/fscmain.fs b/src/fsharp/fscmain.fs new file mode 100644 index 0000000000..3322c5a653 --- /dev/null +++ b/src/fsharp/fscmain.fs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +module internal Microsoft.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.AbstractIL.IL // runningOnMono +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 Internal.Utilities + +#if FX_RESHAPED_REFLECTION +open Microsoft.FSharp.Core.ReflectionAdapters +#endif + +#if !FX_NO_DEFAULT_DEPENDENCY_TYPE +[] +#endif +do () + + +module Driver = + let main argv = + + let ctok = AssumeCompilationThreadWithoutEvidence () + + // Check for --pause as the very first step so that a compiler can be attached here. + if argv |> Array.exists (fun x -> x = "/pause" || x = "--pause") then + System.Console.WriteLine("Press return to continue...") + System.Console.ReadLine() |> ignore + + let quitProcessExiter = + { new Exiter with + member x.Exit(n) = + try + exit n + with _ -> + () + failwithf "%s" <| FSComp.SR.elSysEnvExitDidntExit() + } + + mainCompile (ctok, argv, MSBuildReferenceResolver.Resolver, (*bannerAlreadyPrinted*)false, (*openBinariesInMemory*)false, (*defaultCopyFSharpCore*)true, quitProcessExiter, ConsoleLoggerProvider(), None, None) + 0 + +[] +let main(argv) = + System.Runtime.GCSettings.LatencyMode <- System.Runtime.GCLatencyMode.Batch + use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter + +#if !FX_NO_HEAPTERMINATION + if not runningOnMono then Lib.UnmanagedProcessExecutionOptions.EnableHeapTerminationOnCorruption() (* SDL recommendation *) + Lib.UnmanagedProcessExecutionOptions.EnableHeapTerminationOnCorruption() (* SDL recommendation *) +#endif + + try + Driver.main(Array.append [| "fsc.exe" |] argv) + with e -> + errorRecovery e Microsoft.FSharp.Compiler.Range.range0 + 1 diff --git a/src/fsharp/fsi/FSIstrings.txt b/src/fsharp/fsi/FSIstrings.txt index cd8ce84a6e..d02cfeb79c 100755 --- a/src/fsharp/fsi/FSIstrings.txt +++ b/src/fsharp/fsi/FSIstrings.txt @@ -49,5 +49,6 @@ fsiTurnedTimingOff,"--> Timing now off" fsiUnexpectedThreadAbortException,"- Unexpected ThreadAbortException (Ctrl-C) during event handling: Trying to restart..." fsiFailedToResolveAssembly,"Failed to resolve assembly '%s'" fsiBindingSessionTo,"Binding session to '%s'..." -fsiProductName,"F# Interactive for F# %s" +fsiProductName,"Microsoft (R) F# Interactive version %s" +fsiProductNameCommunity,"F# Interactive for F# %s" shadowCopyReferences,"Prevents references from being locked by the F# Interactive process" diff --git a/src/fsharp/fsi/Fsi.BuildFromSource.fsproj b/src/fsharp/fsi/Fsi.BuildFromSource.fsproj new file mode 100644 index 0000000000..ef00d06efb --- /dev/null +++ b/src/fsharp/fsi/Fsi.BuildFromSource.fsproj @@ -0,0 +1,50 @@ + + + + + + Exe + netcoreapp1.0 + .exe + fsi + $(NoWarn);45;55;62;75;1204 + true + $(DefineConstants);BUILD_FROM_SOURCE;COMPILER;EXTENSIONTYPING + fsi.res + $(OtherFlags) --warnon:1182 --maxerrors:20 --extraoptimizationloops:1 + + + + + + assemblyinfo.fsi.exe.fs + + + + console.fs + + + fsimain.fs + + + PreserveNewest + fsi.exe.config + + + + + + + + + + + + + + + + + + + diff --git a/src/fsharp/fsi/Fsi.fsproj b/src/fsharp/fsi/Fsi.fsproj new file mode 100644 index 0000000000..b05a002924 --- /dev/null +++ b/src/fsharp/fsi/Fsi.fsproj @@ -0,0 +1,96 @@ + + + + + $(MSBuildProjectDirectory)\..\.. + + + + Debug + + x86 + AnyCPU + {d0e98c0d-490b-4c61-9329-0862f6e87645} + Exe + $(NoWarn);62 + fsi + 0x0A000000 + EXTENSIONTYPING;$(DefineConstants) + COMPILER;$(DefineConstants) + FSI_SHADOW_COPY_REFERENCES;$(DefineConstants) + FSI_SERVER;$(DefineConstants) + true + $(OtherFlags) --warnon:1182 + fsi.res + v4.6 + + + + $(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).exe.lcl + $(FSharpSourcesRoot)\..\loc\lci\$(AssemblyName).exe.lci + false + false + + + + + assemblyinfo.fsi.exe.fs + + + + console.fs + + + fsimain.fs + + + PreserveNewest + fsi.exe.config + + + + + + + + + + + + + + + + + + + + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + FSharp.Compiler.Private + + + {DED3BBD7-53F4-428A-8C9F-27968E768605} + FSharp.Core + + + + + FSharp.Compiler.Server.Shared + {d5870cf0-ed51-4cbc-b3d7-6f56da84ac06} + True + + + + + + + + Microsoft + StrongName + + + + \ No newline at end of file diff --git a/src/fsharp/fsi/fsi.exe.config b/src/fsharp/fsi/fsi.exe.config new file mode 100644 index 0000000000..61ea7d7f6e --- /dev/null +++ b/src/fsharp/fsi/fsi.exe.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 11f00564e1..47bb64a18d 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.Interactive.Shell +module Microsoft.FSharp.Compiler.Interactive.Shell #nowarn "55" @@ -18,6 +18,7 @@ open System.IO 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 @@ -47,26 +48,16 @@ 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 Internal.Utilities open Internal.Utilities.Collections open Internal.Utilities.StructuredFormat -type FormatOptions = Internal.Utilities.StructuredFormat.FormatOptions - -//---------------------------------------------------------------------------- -// Hardbinding dependencies should we NGEN fsi.exe -//---------------------------------------------------------------------------- - #if FX_RESHAPED_REFLECTION open Microsoft.FSharp.Core.ReflectionAdapters #endif -open System.Runtime.CompilerServices -#if !FX_NO_DEFAULT_DEPENDENCY_TYPE -[] do () -[] do () -#endif //---------------------------------------------------------------------------- // For the FSI as a service methods... @@ -237,7 +228,7 @@ type EvaluationEventArgs(fsivalue : FsiValue option, symbolUse : FSharpSymbolUse [] /// User-configurable information that changes how F# Interactive operates, stored in the 'fsi' object /// and accessible via the programming model -type public FsiEvaluationSessionHostConfig () = +type FsiEvaluationSessionHostConfig () = let evaluationEvent = new Event () /// Called by the evaluation session to ask the host for parameters to format text for output abstract FormatProvider: System.IFormatProvider @@ -271,20 +262,20 @@ type public FsiEvaluationSessionHostConfig () = /// A "console" gets used if /// --readline- is specified (the default on Windows + .NET); and /// not --fsi-server (which should always be combined with --readline-); and - /// OptionalConsoleReadLine() returns a Some + /// GetOptionalConsoleReadLine() returns a Some /// /// "Peekahead" occurs if --peekahead- is not specified (i.e. it is the default): /// - If a console is being used then /// - a prompt is printed early /// - a background thread is created - /// - the OptionalConsoleReadLine() callback is used to read the first line + /// - the GetOptionalConsoleReadLine() callback is used to read the first line /// - Otherwise call inReader.Peek() /// /// Further lines are read as follows: - /// - If a console is being used then use OptionalConsoleReadLine() + /// - If a console is being used then use GetOptionalConsoleReadLine() /// - Otherwise use inReader.ReadLine() - abstract OptionalConsoleReadLine : (unit -> string) option + abstract GetOptionalConsoleReadLine : probeToSeeIfConsoleWorks: bool -> (unit -> string) option /// The evaluation session calls this at an appropriate point in the startup phase if the --fsi-server parameter was given abstract StartServer : fsiServerName:string -> unit @@ -482,10 +473,11 @@ type internal FsiValuePrinter(fsi: FsiEvaluationSessionHostConfig, g: TcGlobals, let lay = valuePrinter.PrintValue (FsiValuePrinterMode.PrintExpr, opts, obj, objTy) if isEmptyL lay then None else Some lay // suppress empty layout let denv = { denv with suppressMutableKeyword = true } // suppress 'mutable' in 'val mutable it = ...' - let fullL = if Option.isNone rhsL || isEmptyL rhsL.Value then - NicePrint.layoutValOrMember denv vref (* the rhs was suppressed by the printer, so no value to print *) - else - (NicePrint.layoutValOrMember denv vref ++ wordL (TaggedTextOps.tagText "=")) --- rhsL.Value + let fullL = + if Option.isNone rhsL || isEmptyL rhsL.Value then + NicePrint.prettyLayoutOfValOrMemberNoInst denv vref (* the rhs was suppressed by the printer, so no value to print *) + else + (NicePrint.prettyLayoutOfValOrMemberNoInst denv vref ++ wordL (TaggedTextOps.tagText "=")) --- rhsL.Value Utilities.colorPrintL outWriter opts fullL @@ -533,6 +525,7 @@ type internal FsiStdinSyphon(errorWriter: TextWriter) = writeViaBufferWithEnvironmentNewLines errorWriter (OutputDiagnosticContext " " syphon.GetLine) err; writeViaBufferWithEnvironmentNewLines errorWriter (OutputDiagnostic (tcConfig.implicitIncludeDir,tcConfig.showFullPaths,tcConfig.flatErrors,tcConfig.errorStyle,isError)) err; errorWriter.WriteLine() + errorWriter.WriteLine() errorWriter.Flush())) @@ -577,7 +570,9 @@ type internal ErrorLoggerThatStopsOnFirstError(tcConfigB:TcConfigBuilder, fsiStd fsiConsoleOutput.Error.WriteLine() writeViaBufferWithEnvironmentNewLines fsiConsoleOutput.Error (OutputDiagnosticContext " " fsiStdinSyphon.GetLine) err writeViaBufferWithEnvironmentNewLines fsiConsoleOutput.Error (OutputDiagnostic (tcConfigB.implicitIncludeDir,tcConfigB.showFullPaths,tcConfigB.flatErrors,tcConfigB.errorStyle,isError)) err - fsiConsoleOutput.Error.WriteLine("\n")) + fsiConsoleOutput.Error.WriteLine() + fsiConsoleOutput.Error.WriteLine() + fsiConsoleOutput.Error.Flush()) override x.ErrorCount = errorCount @@ -614,8 +609,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s // Mono on Win32 doesn't implement correct console processing not (runningOnMono && System.Environment.OSVersion.Platform = System.PlatformID.Win32NT) #endif -// In the cross-platform edition of F#, 'gui' support is currently off by default - let mutable gui = not runningOnMono // override via "--gui", on by default + let mutable gui = not runningOnMono // override via "--gui", on by default except when on Mono #if DEBUG let mutable showILCode = false // show modul il code #endif @@ -631,6 +625,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s let mutable fsiLCID = None // internal options + let mutable probeToSeeIfConsoleWorks = true let mutable peekAheadOnConsoleToPermitTyping = true let isInteractiveServer() = fsiServerName <> "" @@ -696,10 +691,12 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s PrivateOptions( [ // Private options, related to diagnostics around console probing + CompilerOption("probeconsole","", OptionSwitch (fun flag -> probeToSeeIfConsoleWorks <- flag=OptionSwitch.On), None, None); // "Probe to see if Console looks functional"); + CompilerOption("peekahead","", OptionSwitch (fun flag -> peekAheadOnConsoleToPermitTyping <- flag=OptionSwitch.On), None, None); // "Probe to see if Console looks functional"); // Disables interaction (to be used by libraries embedding FSI only!) - CompilerOption("noninteractive","", OptionUnit (fun () -> interact <- false), None, None); + CompilerOption("noninteractive","", OptionUnit (fun () -> interact <- false), None, None); // "Deprecated, use --exec instead" ]) ] @@ -727,9 +724,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s (* Renamed --readline and --no-readline to --tabcompletion:+|- *) CompilerOption("readline", tagNone, OptionSwitch(fun flag -> enableConsoleKeyProcessing <- (flag = OptionSwitch.On)), None, Some(FSIstrings.SR.fsiReadline())); CompilerOption("quotations-debug", tagNone, OptionSwitch(fun switch -> tcConfigB.emitDebugInfoInQuotations <- switch = OptionSwitch.On),None, Some(FSIstrings.SR.fsiEmitDebugInfoInQuotations())); -#if FSI_SHADOW_COPY_REFERENCES CompilerOption("shadowcopyreferences", tagNone, OptionSwitch(fun flag -> tcConfigB.shadowCopyReferences <- flag = OptionSwitch.On), None, Some(FSIstrings.SR.shadowCopyReferences())); -#endif ]); ] @@ -802,6 +797,7 @@ type internal FsiCommandLineOptions(fsi: FsiEvaluationSessionHostConfig, argv: s member __.FsiServerOutputCodePage = fsiServerOutputCodePage member __.FsiLCID with get() = fsiLCID and set v = fsiLCID <- v member __.IsInteractiveServer = isInteractiveServer() + member __.ProbeToSeeIfConsoleWorks = probeToSeeIfConsoleWorks member __.EnableConsoleKeyProcessing = enableConsoleKeyProcessing member __.Interact = interact @@ -889,7 +885,7 @@ type internal FsiConsoleInput(fsi: FsiEvaluationSessionHostConfig, fsiOptions: F // The "console.fs" code does a limited form of "TAB-completion". // Currently, it turns on if it looks like we have a console. if fsiOptions.EnableConsoleKeyProcessing then - fsi.OptionalConsoleReadLine + fsi.GetOptionalConsoleReadLine(fsiOptions.ProbeToSeeIfConsoleWorks) else None @@ -1078,17 +1074,12 @@ type internal FsiDynamicCompiler // Explicitly register the resources with the QuotationPickler module // We would save them as resources into the dynamic assembly but there is missing // functionality System.Reflection for dynamic modules that means they can't be read back out -#if COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0 let cenv = { ilg = ilGlobals ; generatePdb = generateDebugInfo; resolveAssemblyRef=resolveAssemblyRef; tryFindSysILTypeRef=tcGlobals.TryFindSysILTypeRef } for (referencedTypeDefs, bytes) in codegenResults.quotationResourceInfo do let referencedTypes = [| for tref in referencedTypeDefs do yield ILRuntimeWriter.LookupTypeRef cenv emEnv tref |] Microsoft.FSharp.Quotations.Expr.RegisterReflectedDefinitions (assemblyBuilder, fragName, bytes, referencedTypes); -#else - for (_referencedTypeDefs, bytes) in codegenResults.quotationResourceInfo do - Microsoft.FSharp.Quotations.Expr.RegisterReflectedDefinitions (assemblyBuilder, fragName, bytes); -#endif ReportTime tcConfig "Run Bindings"; @@ -1169,7 +1160,7 @@ type internal FsiDynamicCompiler let newState = { istate with tcState = tcState.NextStateAfterIncrementalFragment(tcEnvAtEndOfLastInput) } // Find all new declarations the EvaluationListener - begin + try let contents = FSharpAssemblyContents(tcGlobals, tcState.Ccu, tcImports, declaredImpls) let contentFile = contents.ImplementationFiles.[0] // Skip the "FSI_NNNN" @@ -1201,7 +1192,7 @@ type internal FsiDynamicCompiler // Top level 'do' bindings are not reported as incremental declarations () | _ -> () - end + with _ -> () newState @@ -1301,7 +1292,7 @@ type internal FsiDynamicCompiler let sourceFiles = sourceFiles |> List.map (fun nm -> tcConfig.ResolveSourceFile(m, nm, tcConfig.implicitIncludeDir),m) // Close the #load graph on each file and gather the inputs from the scripts. - let closure = LoadClosure.ComputeClosureOfSourceFiles(ctok, TcConfig.Create(tcConfigB,validate=false), sourceFiles, CodeContext.Evaluation,lexResourceManager=lexResourceManager) + let closure = LoadClosure.ComputeClosureOfSourceFiles(ctok, TcConfig.Create(tcConfigB,validate=false), sourceFiles, CodeContext.CompilationAndEvaluation, lexResourceManager=lexResourceManager) // Intent "[Loading %s]\n" (String.concat "\n and " sourceFiles) fsiConsoleOutput.uprintf "[%s " (FSIstrings.SR.fsiLoadingFilesPrefixText()) @@ -1602,10 +1593,10 @@ module internal MagicAssemblyResolution = // It is an explicit user trust decision to load an assembly with #r. Scripts are not run automatically (for example, by double-clicking in explorer). // We considered setting loadFromRemoteSources in fsi.exe.config but this would transitively confer unsafe loading to the code in the referenced // assemblies. Better to let those assemblies decide for themselves which is safer. -#if FX_ATLEAST_40 - Assembly.UnsafeLoadFrom(path) -#else +#if FSI_TODO_NETCORE Assembly.LoadFrom(path) +#else + Assembly.UnsafeLoadFrom(path) #endif let Install(tcConfigB, tcImports: TcImports, fsiDynamicCompiler: FsiDynamicCompiler, fsiConsoleOutput: FsiConsoleOutput) = @@ -1826,14 +1817,11 @@ type internal FsiInteractionProcessor lexResourceManager : LexResourceManager, initialInteractiveState) = -#if FSI_SHADOW_COPY_REFERENCES let referencedAssemblies = Dictionary() -#endif let mutable currState = initialInteractiveState let event = Control.Event() let setCurrState s = currState <- s; event.Trigger() - //let mutable queueAgent = None let runCodeOnEventLoop errorLogger f istate = try @@ -1921,7 +1909,6 @@ type internal FsiInteractionProcessor let resolutions,istate = fsiDynamicCompiler.EvalRequireReference(ctok, istate, m, path) resolutions |> List.iter (fun ar -> let format = -#if FSI_SHADOW_COPY_REFERENCES if tcConfig.shadowCopyReferences then let resolvedPath = ar.resolvedPath.ToUpperInvariant() let fileTime = File.GetLastWriteTimeUtc(resolvedPath) @@ -1934,7 +1921,6 @@ type internal FsiInteractionProcessor | _ -> FSIstrings.SR.fsiDidAHashr(ar.resolvedPath) else -#endif FSIstrings.SR.fsiDidAHashrWithLockWarning(ar.resolvedPath) fsiConsoleOutput.uprintnfnn "%s" format) istate,Completed None @@ -2357,10 +2343,10 @@ type internal FsiInteractionProcessor let names = names |> List.filter (fun name -> name.StartsWith(stem,StringComparison.Ordinal)) names - member __.ParseAndCheckInteraction (ctok, referenceResolver, checker, istate, text:string) = + member __.ParseAndCheckInteraction (ctok, legacyReferenceResolver, checker, istate, text:string) = let tcConfig = TcConfig.Create(tcConfigB,validate=false) - let fsiInteractiveChecker = FsiInteractiveChecker(referenceResolver, checker, tcConfig, istate.tcGlobals, istate.tcImports, istate.tcState) + let fsiInteractiveChecker = FsiInteractiveChecker(legacyReferenceResolver, checker, tcConfig, istate.tcGlobals, istate.tcImports, istate.tcState) fsiInteractiveChecker.ParseAndCheckInteraction(ctok, text) @@ -2419,7 +2405,7 @@ let internal DriveFsiEventLoop (fsi: FsiEvaluationSessionHostConfig, fsiConsoleO /// The primary type, representing a full F# Interactive session, reading from the given /// text input, writing to the given text output and error writers. -type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, msbuildEnabled: bool) = +type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], inReader:TextReader, outWriter:TextWriter, errorWriter: TextWriter, fsiCollectible: bool, legacyReferenceResolver: ReferenceResolver.Resolver option) = #if !FX_NO_HEAPTERMINATION do if not runningOnMono then Lib.UnmanagedProcessExecutionOptions.EnableHeapTerminationOnCorruption() (* SDL recommendation *) @@ -2464,38 +2450,22 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i //---------------------------------------------------------------------------- let currentDirectory = Directory.GetCurrentDirectory() - let defaultFSharpBinariesDir = -#if FX_RESHAPED_REFLECTION - System.AppContext.BaseDirectory -#else - System.AppDomain.CurrentDomain.BaseDirectory -#endif - - // When used as part of FCS we cannot assume the current process is fsi.exe - // So we try to fallback to the default compiler dir. - let defaultFSharpBinariesDir = - let safeExists f = (try File.Exists(f) with _ -> false) - let containsRequiredFiles = - [ "FSharp.Core.dll"; "FSharp.Core.sigdata"; "FSharp.Core.optdata" ] - |> Seq.map (fun file -> Path.Combine(defaultFSharpBinariesDir, file)) - |> Seq.forall safeExists - if containsRequiredFiles then defaultFSharpBinariesDir - else Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(None).Value - - let referenceResolver = SimulatedMSBuildReferenceResolver.GetBestAvailableResolver(msbuildEnabled) - let tcConfigB = - TcConfigBuilder.CreateNew(referenceResolver, - defaultFSharpBinariesDir, - true, // long running: optimizeForMemory - currentDirectory,isInteractive=true, - isInvalidationSupported=false) + + let defaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(FSharpEnvironment.tryCurrentDomain()).Value + + let legacyReferenceResolver = + match legacyReferenceResolver with + | None -> SimulatedMSBuildReferenceResolver.GetBestAvailableResolver() + | Some rr -> rr + + let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir=defaultFSharpBinariesDir, optimizeForMemory=true, implicitIncludeDir=currentDirectory, isInteractive=true, isInvalidationSupported=false, defaultCopyFSharpCore=false) let tcConfigP = TcConfigProvider.BasedOnMutableBuilder(tcConfigB) - do tcConfigB.resolutionEnvironment <- ReferenceResolver.RuntimeLike // See Bug 3608 + do tcConfigB.resolutionEnvironment <- ResolutionEnvironment.CompilationAndEvaluation // See Bug 3608 do tcConfigB.useFsiAuxLib <- fsi.UseFsiAuxLib #if FSI_TODO_NETCORE - // "RuntimeLike" assembly resolution for F# Interactive is not yet properly figured out on .NET Core - do tcConfigB.resolutionEnvironment <- ReferenceResolver.DesignTimeLike + // "CompilationAndEvaluation" assembly resolution for F# Interactive is not yet properly figured out on .NET Core + do tcConfigB.resolutionEnvironment <- ResolutionEnvironment.EditingOrCompilation false do tcConfigB.useSimpleResolution <- true do SetTargetProfile tcConfigB "netcore" // always assume System.Runtime codegen //do SetTargetProfile tcConfigB "privatecorelib" // always assume System.Private.CoreLib codegen @@ -2506,7 +2476,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i do SetDebugSwitch tcConfigB (Some "pdbonly") OptionSwitch.On do SetTailcallSwitch tcConfigB OptionSwitch.On -#if FX_ATLEAST_40 +#if !FSI_TODO_NETCORE // set platform depending on whether the current process is a 64-bit process. // BUG 429882 : FsiAnyCPU.exe issues warnings (x64 v MSIL) when referencing 64-bit assemblies do tcConfigB.platform <- if IntPtr.Size = 8 then Some AMD64 else Some X86 @@ -2566,7 +2536,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i /// The single, global interactive checker that can be safely used in conjunction with other operations /// on the FsiEvaluationSession. - let checker = FSharpChecker.Create(msbuildEnabled=msbuildEnabled) + let checker = FSharpChecker.Create(legacyReferenceResolver=legacyReferenceResolver) let (tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolvedReferences) = try @@ -2631,7 +2601,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i | Choice2Of2 None -> Choice2Of2 (System.Exception "Operation could not be completed due to earlier error") | Choice2Of2 (Some userExn) -> Choice2Of2 userExn - userRes, FsiInteractiveChecker.CreateErrorInfos (tcConfig, true, scriptFile, errs) + userRes, ErrorHelpers.CreateErrorInfos (tcConfig, true, scriptFile, errs) let dummyScriptFileName = "input.fsx" @@ -2650,7 +2620,9 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i member x.ParseAndCheckInteraction(code) = let ctok = AssumeCompilationThreadWithoutEvidence () - fsiInteractionProcessor.ParseAndCheckInteraction (ctok, referenceResolver, checker.ReactorOps, fsiInteractionProcessor.CurrentState, code) + fsiInteractionProcessor.ParseAndCheckInteraction (ctok, legacyReferenceResolver, checker.ReactorOps, fsiInteractionProcessor.CurrentState, code) + + member x.InteractiveChecker = checker member x.CurrentPartialAssemblySignature = fsiDynamicCompiler.CurrentPartialAssemblySignature (fsiInteractionProcessor.CurrentState) @@ -2734,7 +2706,6 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i member x.PartialAssemblySignatureUpdated = fsiInteractionProcessor.PartialAssemblySignatureUpdated - member x.InteractiveChecker = checker member x.FormatValue(obj:obj, objTy) = fsiDynamicCompiler.FormatValue(obj, objTy) @@ -2873,14 +2844,12 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i GC.KeepAlive fsiInterruptController.EventHandlers - static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?msbuildEnabled) = - new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, defaultArg msbuildEnabled true) + static member Create(fsiConfig, argv, inReader, outWriter, errorWriter, ?collectible, ?legacyReferenceResolver) = + new FsiEvaluationSession(fsiConfig, argv, inReader, outWriter, errorWriter, defaultArg collectible false, legacyReferenceResolver) static member GetDefaultConfiguration(fsiObj:obj) = FsiEvaluationSession.GetDefaultConfiguration(fsiObj, true) - static member GetDefaultConfiguration(fsiObj:obj, useFsiAuxLib) = - - + static member GetDefaultConfiguration(fsiObj:obj, useFsiAuxLib: bool) = // We want to avoid modifying FSharp.Compiler.Interactive.Settings to avoid republishing that DLL. // So we access these via reflection { // Connect the configuration through to the 'fsi' object from FSharp.Compiler.Interactive.Settings @@ -2901,7 +2870,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i member __.EventLoopInvoke(f : unit -> 'T) = callInstanceMethod1 (getInstanceProperty fsiObj "EventLoop") [|typeof<'T>|] "Invoke" f member __.EventLoopScheduleRestart() = callInstanceMethod0 (getInstanceProperty fsiObj "EventLoop") [||] "ScheduleRestart" member __.UseFsiAuxLib = useFsiAuxLib - member __.OptionalConsoleReadLine = None } + member __.GetOptionalConsoleReadLine(_probe) = None } //------------------------------------------------------------------------------- @@ -2914,6 +2883,9 @@ module Settings = abstract Invoke : (unit -> 'T) -> 'T abstract ScheduleRestart : unit -> unit + // fsi.fs in FSHarp.Compiler.Sevice.dll avoids a hard dependency on FSharp.Compiler.Interactive.Settings.dll + // by providing an optional reimplementation of the functionality + // An implementation of IEventLoop suitable for the command-line console [] type internal SimpleEventLoop() = @@ -2930,12 +2902,12 @@ module Settings = let mutable restart = false interface IEventLoop with member x.Run() = - running <- true; + running <- true let rec run() = match waitSignal2 runSignal exitSignal with | 0 -> queue |> List.iter (fun f -> result <- try Some(f()) with _ -> None); - setSignal doneSignal; + setSignal doneSignal run() | 1 -> running <- false; @@ -2943,19 +2915,19 @@ module Settings = | _ -> run() run(); member x.Invoke(f : unit -> 'T) : 'T = - queue <- [f >> box]; - setSignal runSignal; + queue <- [f >> box] + setSignal runSignal waitSignal doneSignal result.Value |> unbox member x.ScheduleRestart() = if running then - restart <- true; + restart <- true setSignal exitSignal interface System.IDisposable with member x.Dispose() = - runSignal.Dispose(); - exitSignal.Dispose(); - doneSignal.Dispose(); + runSignal.Dispose() + exitSignal.Dispose() + doneSignal.Dispose() @@ -2975,26 +2947,26 @@ module Settings = let mutable showProperties = true let mutable addedPrinters = [] - member self.FloatingPointFormat with get() = fpfmt and set v = fpfmt <- v - member self.FormatProvider with get() = fp and set v = fp <- v - member self.PrintWidth with get() = printWidth and set v = printWidth <- v - member self.PrintDepth with get() = printDepth and set v = printDepth <- v - member self.PrintLength with get() = printLength and set v = printLength <- v - member self.PrintSize with get() = printSize and set v = printSize <- v - member self.ShowDeclarationValues with get() = showDeclarationValues and set v = showDeclarationValues <- v - member self.ShowProperties with get() = showProperties and set v = showProperties <- v - member self.ShowIEnumerable with get() = showIEnumerable and set v = showIEnumerable <- v - member self.ShowIDictionary with get() = showIDictionary and set v = showIDictionary <- v - member self.AddedPrinters with get() = addedPrinters and set v = addedPrinters <- v - member self.CommandLineArgs with get() = args and set v = args <- v - member self.AddPrinter(printer : 'T -> string) = + member __.FloatingPointFormat with get() = fpfmt and set v = fpfmt <- v + member __.FormatProvider with get() = fp and set v = fp <- v + member __.PrintWidth with get() = printWidth and set v = printWidth <- v + member __.PrintDepth with get() = printDepth and set v = printDepth <- v + member __.PrintLength with get() = printLength and set v = printLength <- v + member __.PrintSize with get() = printSize and set v = printSize <- v + member __.ShowDeclarationValues with get() = showDeclarationValues and set v = showDeclarationValues <- v + member __.ShowProperties with get() = showProperties and set v = showProperties <- v + member __.ShowIEnumerable with get() = showIEnumerable and set v = showIEnumerable <- v + member __.ShowIDictionary with get() = showIDictionary and set v = showIDictionary <- v + member __.AddedPrinters with get() = addedPrinters and set v = addedPrinters <- v + member __.CommandLineArgs with get() = args and set v = args <- v + member __.AddPrinter(printer : 'T -> string) = addedPrinters <- Choice1Of2 (typeof<'T>, (fun (x:obj) -> printer (unbox x))) :: addedPrinters - member self.EventLoop + member __.EventLoop with get () = evLoop and set (x:IEventLoop) = evLoop.ScheduleRestart(); evLoop <- x - member self.AddPrintTransformer(printer : 'T -> obj) = + member __.AddPrintTransformer(printer : 'T -> obj) = addedPrinters <- Choice2Of2 (typeof<'T>, (fun (x:obj) -> printer (unbox x))) :: addedPrinters let fsi = InteractiveSettings() diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index 3cd5d5efe8..b07f3a61ca 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -1,16 +1,11 @@ -//---------------------------------------------------------------------------- -// Copyright (c) 2002-2012 Microsoft Corporation. -// -// This source code is subject to terms and conditions of the Apache License, Version 2.0. A -// copy of the license can be found in the License.html file at the root of this distribution. -// By using this source code in any fashion, you are agreeing to be bound -// by the terms of the Apache License, Version 2.0. -// -// You must not remove this notice, or any other, from this software. -//---------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module Microsoft.FSharp.Compiler.Interactive.Shell +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.Interactive.Shell +#else +module internal Microsoft.FSharp.Compiler.Interactive.Shell +#endif open System.IO open Microsoft.FSharp.Compiler @@ -23,21 +18,27 @@ type FsiValue = member ReflectionValue : obj /// The type of the value, from the point of view of the .NET type system member ReflectionType : System.Type +#if COMPILER_API /// The type of the value, from the point of view of the F# type system member FSharpType : FSharpType +#endif [] type EvaluationEventArgs = inherit System.EventArgs - //new : unit -> CompilerOutputStream + /// The display name of the symbol defined member Name : string + /// The value of the symbol defined, if any member FsiValue : FsiValue option + /// The FSharpSymbolUse for the symbol defined member SymbolUse : FSharpSymbolUse + /// The symbol defined member Symbol : FSharpSymbol + /// The details of the expression defined member ImplementationDeclaration : FSharpImplementationFileDeclaration @@ -67,6 +68,7 @@ type public FsiEvaluationSessionHostConfig = /// The evaluation session calls this to report the preferred view of the command line arguments after /// stripping things like "/use:file.fsx", "-r:Foo.dll" etc. abstract ReportUserCommandLineArgs : string [] -> unit + /// Hook for listening for evaluation bindings member OnEvaluation : IEvent @@ -88,7 +90,7 @@ type public FsiEvaluationSessionHostConfig = ///   /// - abstract OptionalConsoleReadLine : (unit -> string) option + abstract GetOptionalConsoleReadLine : probeToSeeIfConsoleWorks: bool -> (unit -> string) option /// The evaluation session calls this at an appropriate point in the startup phase if the --fsi-server parameter was given abstract StartServer : fsiServerName:string -> unit @@ -124,7 +126,7 @@ type FsiEvaluationSession = /// Read input from the given reader /// Write output to the given writer /// Optionally make the dynamic assmbly for the session collectible - static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?msbuildEnabled: bool -> FsiEvaluationSession + static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?legacyReferenceResolver: ReferenceResolver.Resolver -> FsiEvaluationSession /// A host calls this to request an interrupt on the evaluation thread. member Interrupt : unit -> unit @@ -256,7 +258,6 @@ type FsiEvaluationSession = static member GetDefaultConfiguration: unit -> FsiEvaluationSessionHostConfig - /// A default implementation of the 'fsi' object, used by GetDefaultConfiguration() module Settings = /// An event loop used by the currently executing F# Interactive session to execute code diff --git a/src/fsharp/fsi/fsiAnyCpu.exe.config b/src/fsharp/fsi/fsiAnyCpu.exe.config new file mode 100644 index 0000000000..494cb3e584 --- /dev/null +++ b/src/fsharp/fsi/fsiAnyCpu.exe.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/fsharp/fsi/fsimain.fs b/src/fsharp/fsi/fsimain.fs new file mode 100644 index 0000000000..0eab9c4581 --- /dev/null +++ b/src/fsharp/fsi/fsimain.fs @@ -0,0 +1,339 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + + +// This file provides the actual entry point for fsi.exe. +// +// Configure the F# Interactive Session to +// 1. use a WinForms event loop (introduces a System.Windows.Forms.dll dependency) +// 2. provide a remoting connection for the use of editor-hosted sessions (introduces a System.Remoting dependency) +// 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 + +open System +open System.Globalization +open System.IO +open System.Reflection +open System.Threading +open System.Runtime.CompilerServices +#if !FX_NO_WINFORMS +open System.Windows.Forms +#endif + +open Microsoft.FSharp.Compiler +open Microsoft.FSharp.Compiler.Lib +open Microsoft.FSharp.Compiler.Interactive.Shell +open Microsoft.FSharp.Compiler.Interactive +open Microsoft.FSharp.Compiler.Interactive.Shell.Settings + +#if FX_RESHAPED_REFLECTION +open Microsoft.FSharp.Core.ReflectionAdapters +#endif + +#nowarn "55" +#nowarn "40" // let rec on value 'fsiConfig' + + + +// Hardbinding dependencies should we NGEN fsi.exe +#if !FX_NO_DEFAULT_DEPENDENCY_TYPE +[] do () +[] do () +#endif + +// Standard attributes +[] +[] +do() + + +/// Set the current ui culture for the current thread. +#if FX_LCIDFROMCODEPAGE +let internal SetCurrentUICultureForThread (lcid : int option) = + let culture = Thread.CurrentThread.CurrentUICulture + match lcid with + | Some n -> Thread.CurrentThread.CurrentUICulture <- new CultureInfo(n) + | None -> () + { new IDisposable with member x.Dispose() = Thread.CurrentThread.CurrentUICulture <- culture } +#endif + +let callStaticMethod (ty:Type) name args = + ty.InvokeMember(name, (BindingFlags.InvokeMethod ||| BindingFlags.Static ||| BindingFlags.Public ||| BindingFlags.NonPublic), null, null, Array.ofList args,Globalization.CultureInfo.InvariantCulture) + +#if !FX_NO_WINFORMS +///Use a dummy to access protected member +type internal DummyForm() = + inherit Form() + member x.DoCreateHandle() = x.CreateHandle() + /// Creating the dummy form object can crash on Mono Mac, and then prints a nasty background + /// error during finalization of the half-initialized object... + override x.Finalize() = () + +/// This is the event loop implementation for winforms +type WinFormsEventLoop() = + let mainForm = new DummyForm() + do mainForm.DoCreateHandle() + let mutable lcid = None + // Set the default thread exception handler + let restart = ref false + member __.LCID with get () = lcid and set v = lcid <- v + interface IEventLoop with + member x.Run() = + restart := false + Application.Run() + !restart + member x.Invoke (f: unit -> 'T) : 'T = + if not mainForm.InvokeRequired then + f() + else + + // Workaround: Mono's Control.Invoke returns a null result. Hence avoid the problem by + // transferring the resulting state using a mutable location. + let mainFormInvokeResultHolder = ref None + + // Actually, Mono's Control.Invoke isn't even blocking (or wasn't on 1.1.15)! So use a signal to indicate completion. + // Indeed, we should probably do this anyway with a timeout so we can report progress from + // the GUI thread. + use doneSignal = new AutoResetEvent(false) + + + // BLOCKING: This blocks the stdin-reader thread until the + // form invocation has completed. NOTE: does not block on Mono, or did not on 1.1.15 + mainForm.Invoke(new MethodInvoker(fun () -> + try + // When we get called back, someone may jack our culture + // So we must reset our UI culture every time +#if FX_LCIDFROMCODEPAGE + use _scope = SetCurrentUICultureForThread lcid +#else + ignore lcid +#endif + mainFormInvokeResultHolder := Some(f ()) + finally + doneSignal.Set() |> ignore)) |> ignore + + //if !progress then fprintfn outWriter "RunCodeOnWinFormsMainThread: Waiting for completion signal...." + while not (doneSignal.WaitOne(new TimeSpan(0,0,1),true)) do + () // if !progress then fprintf outWriter "." outWriter.Flush() + + //if !progress then fprintfn outWriter "RunCodeOnWinFormsMainThread: Got completion signal, res = %b" (Option.isSome !mainFormInvokeResultHolder) + !mainFormInvokeResultHolder |> Option.get + + member x.ScheduleRestart() = restart := true; Application.Exit() + +/// Try to set the unhandled exception mode of System.Windows.Forms +let internal TrySetUnhandledExceptionMode() = + let i = ref 0 // stop inlining + try + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException) + with _ -> + decr i;() + +#endif + +/// Starts the remoting server to handle interrupt reuests from a host tool. +let StartServer (fsiSession : FsiEvaluationSession) (fsiServerName) = +#if FSI_SERVER + let server = + {new Server.Shared.FSharpInteractiveServer() with + member this.Interrupt() = + //printf "FSI-SERVER: received CTRL-C request...\n" + try + fsiSession.Interrupt() + with e -> + // Final sanity check! - catch all exns - but not expected + assert false + () + } + + Server.Shared.FSharpInteractiveServer.StartServer(fsiServerName,server) +#else + ignore (fsiSession, fsiServerName) +#endif + +//---------------------------------------------------------------------------- +// GUI runCodeOnMainThread +//---------------------------------------------------------------------------- + +let evaluateSession(argv: string[]) = +#if DEBUG + if argv |> Array.exists (fun x -> x = "/pause" || x = "--pause") then + Console.WriteLine("Press any key to continue...") + Console.ReadKey() |> ignore +#endif + +#if !FX_REDUCED_CONSOLE + // When VFSI is running, set the input/output encoding to UTF8. + // Otherwise, unicode gets lost during redirection. + // It is required only under Net4.5 or above (with unicode console feature). + if argv |> Array.exists (fun x -> x.Contains "fsi-server") then + Console.InputEncoding <- System.Text.Encoding.UTF8 + Console.OutputEncoding <- System.Text.Encoding.UTF8 +#else + ignore argv +#endif + + try + // Create the console reader + let console = new Microsoft.FSharp.Compiler.Interactive.ReadLineConsole() + + // Define the function we pass to the FsiEvaluationSession + let getConsoleReadLine (probeToSeeIfConsoleWorks) = + let consoleIsOperational = + if probeToSeeIfConsoleWorks then + //if progress then fprintfn outWriter "probing to see if console works..." + try + // Probe to see if the console looks functional on this version of .NET + let _ = Console.KeyAvailable + let _ = Console.ForegroundColor + let _ = Console.CursorLeft <- Console.CursorLeft + true + with _ -> + //if progress then fprintfn outWriter "probe failed, we have no console..." + false + else true + if consoleIsOperational then + Some (fun () -> console.ReadLine()) + else + None + +//#if USE_FSharp_Compiler_Interactive_Settings + let fsiObjOpt = + let defaultFSharpBinariesDir = +#if FX_RESHAPED_REFLECTION + System.AppContext.BaseDirectory +#else + System.AppDomain.CurrentDomain.BaseDirectory +#endif + // We use LoadFrom to make sure we get the copy of this assembly from the right load context + let fsiAssemblyPath = Path.Combine(defaultFSharpBinariesDir,"FSharp.Compiler.Interactive.Settings.dll") + let fsiAssembly = Assembly.LoadFrom(fsiAssemblyPath) + 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" + Some (callStaticMethod fsiTy "get_fsi" [ ]) + + let fsiConfig0 = + match fsiObjOpt with + | None -> FsiEvaluationSession.GetDefaultConfiguration() + | Some fsiObj -> FsiEvaluationSession.GetDefaultConfiguration(fsiObj, true) + +//fsiSession.LCID +#if !FX_NO_WINFORMS + // Create the WinForms event loop + let fsiWinFormsLoop = + lazy + try Some (WinFormsEventLoop()) + with e -> + printfn "Your system doesn't seem to support WinForms correctly. You will" + printfn "need to set fsi.EventLoop use GUI windows from F# Interactive." + printfn "You can set different event loops for MonoMac, Gtk#, WinForms and other" + printfn "UI toolkits. Drop the --gui argument if no event loop is required." + None +#endif + + // Update the configuration to include 'StartServer', WinFormsEventLoop and 'GetOptionalConsoleReadLine()' + let rec fsiConfig = + { new FsiEvaluationSessionHostConfig () with + member __.FormatProvider = fsiConfig0.FormatProvider + member __.FloatingPointFormat = fsiConfig0.FloatingPointFormat + member __.AddedPrinters = fsiConfig0.AddedPrinters + member __.ShowDeclarationValues = fsiConfig0.ShowDeclarationValues + member __.ShowIEnumerable = fsiConfig0.ShowIEnumerable + member __.ShowProperties = fsiConfig0.ShowProperties + member __.PrintSize = fsiConfig0.PrintSize + member __.PrintDepth = fsiConfig0.PrintDepth + member __.PrintWidth = fsiConfig0.PrintWidth + member __.PrintLength = fsiConfig0.PrintLength + member __.ReportUserCommandLineArgs args = fsiConfig0.ReportUserCommandLineArgs args + member __.EventLoopRun() = +#if !FX_NO_WINFORMS + match fsiWinFormsLoop.Value with + | Some l -> (l :> IEventLoop).Run() + | _ -> +#endif + fsiConfig0.EventLoopRun() + member __.EventLoopInvoke(f) = +#if !FX_NO_WINFORMS + match fsiWinFormsLoop.Value with + | Some l -> (l :> IEventLoop).Invoke(f) + | _ -> +#endif + fsiConfig0.EventLoopInvoke(f) + member __.EventLoopScheduleRestart() = +#if !FX_NO_WINFORMS + match fsiWinFormsLoop.Value with + | Some l -> (l :> IEventLoop).ScheduleRestart() + | _ -> +#endif + fsiConfig0.EventLoopScheduleRestart() + + member __.UseFsiAuxLib = fsiConfig0.UseFsiAuxLib + + member __.StartServer(fsiServerName) = StartServer fsiSession fsiServerName + + // Connect the configuration through to the 'fsi' Event loop + member __.GetOptionalConsoleReadLine(probe) = getConsoleReadLine(probe) } + + // Create the console + and fsiSession = FsiEvaluationSession.Create (fsiConfig, argv, Console.In, Console.Out, Console.Error, collectible=false, legacyReferenceResolver=MSBuildReferenceResolver.Resolver) + + +#if !FX_NO_WINFORMS + // Configure some remaining parameters of the GUI support + if fsiSession.IsGui then + try + Application.EnableVisualStyles() + with _ -> + () + + // Route GUI application exceptions to the exception handlers + Application.add_ThreadException(new ThreadExceptionEventHandler(fun _ args -> fsiSession.ReportUnhandledException args.Exception)); + + let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e-> false + if not runningOnMono then + try + TrySetUnhandledExceptionMode() + with _ -> + () + + fsiWinFormsLoop.Value |> Option.iter (fun l -> l.LCID <- fsiSession.LCID) +#endif + + // Setup the completion function for intellisense in the console + console.SetCompletionFunction(fun (s1,s2) -> fsiSession.GetCompletions (match s1 with | Some s -> s + "." + s2 | None -> s2)) + + // Start the session + fsiSession.Run() + 0 + with + | Microsoft.FSharp.Compiler.ErrorLogger.StopProcessingExn _ -> 1 + | Microsoft.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 +[] +[] +#if !FX_NO_LOADER_OPTIMIZATION +[] +#endif +let MainMain argv = + ignore argv + let argv = System.Environment.GetCommandLineArgs() + use e = new SaveAndRestoreConsoleEncoding() + +#if FSI_SHADOW_COPY_REFERENCES + let isShadowCopy x = (x = "/shadowcopyreferences" || x = "--shadowcopyreferences" || x = "/shadowcopyreferences+" || x = "--shadowcopyreferences+") + if AppDomain.CurrentDomain.IsDefaultAppDomain() && argv |> Array.exists isShadowCopy then + let setupInformation = AppDomain.CurrentDomain.SetupInformation + setupInformation.ShadowCopyFiles <- "true" + let helper = AppDomain.CreateDomain("FSI_Domain", null, setupInformation) + helper.ExecuteAssemblyByName(Assembly.GetExecutingAssembly().GetName()) + else + evaluateSession(argv) +#else + evaluateSession(argv) +#endif diff --git a/src/fsharp/fsi/project.json b/src/fsharp/fsi/project.json new file mode 100644 index 0000000000..8c336a3e67 --- /dev/null +++ b/src/fsharp/fsi/project.json @@ -0,0 +1,30 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0", + "NETStandard.Library": "1.6.1", + "System.Diagnostics.Process": "4.3.0", + "System.Linq.Expressions": "4.3.0", + "System.Reflection.Emit": "4.3.0", + "System.Reflection.TypeExtensions": "4.3.0", + "System.Runtime.Loader": "4.3.0", + "System.Threading.Thread": "4.3.0", + "System.Reflection.Metadata": "1.4.2" + }, + "runtimes": { + "win7-x86": { }, + "win7-x64": { }, + "osx.10.11-x64": { }, + "ubuntu.14.04-x64": { } + }, + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.1.0" + } + }, + "imports": [ "netstandard1.6", "portable-net45+win8+wp8+wpa81" ] + } + } +} diff --git a/src/fsharp/fsiAnyCpu/FsiAnyCPU.fsproj b/src/fsharp/fsiAnyCpu/FsiAnyCPU.fsproj new file mode 100644 index 0000000000..af6c1ce4b9 --- /dev/null +++ b/src/fsharp/fsiAnyCpu/FsiAnyCPU.fsproj @@ -0,0 +1,82 @@ + + + + + $(MSBuildProjectDirectory)\..\.. + + + + Debug + AnyCPU + {8b3e283d-b5fe-4055-9d80-7e3a32f3967b} + Exe + $(NoWarn);62 + fsiAnyCpu + 0x0A000000 + EXTENSIONTYPING;$(DefineConstants) + COMPILER;$(DefineConstants) + FSI_SHADOW_COPY_REFERENCES;$(DefineConstants) + FSI_SERVER;$(DefineConstants) + true + $(OtherFlags) --warnon:1182 + ..\fsi\fsi.res + v4.6 + + + + $(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).exe.lcl + $(FSharpSourcesRoot)\..\loc\lci\$(AssemblyName).exe.lci + false + false + + + + + assemblyinfo.fsi.exe.fs + + + console.fs + + + fsimain.fs + + + PreserveNewest + fsiAnyCpu.exe.config + + + + + + + + + + + + + FSharp.Compiler.Server.Shared + {d5870cf0-ed51-4cbc-b3d7-6f56da84ac06} + True + + + {2E4D67B4-522D-4CF7-97E4-BA940F0B18F3} + FSharp.Compiler.Private + + + {DED3BBD7-53F4-428A-8C9F-27968E768605} + FSharp.Core + + + + + + + + + Microsoft + StrongName + + + + \ No newline at end of file diff --git a/src/fsharp/import.fs b/src/fsharp/import.fs index 8b0a8534a8..06458f3276 100755 --- a/src/fsharp/import.fs +++ b/src/fsharp/import.fs @@ -151,7 +151,7 @@ let CanImportILTypeRef (env:ImportMap) m (tref:ILTypeRef) = /// Prefer the F# abbreviation for some built-in types, e.g. 'string' rather than /// 'System.String', since we prefer the F# abbreviation to the .NET equivalents. let ImportTyconRefApp (env:ImportMap) tcref tyargs = - match env.g.better_tcref_map tcref tyargs with + match env.g.betterTyconRefMap tcref tyargs with | Some res -> res | None -> TType_app (tcref,tyargs) diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index f80a84cb4e..85d749dfe0 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -87,6 +87,11 @@ let GetSuperTypeOfType g amap m typ = Some g.obj_ty elif isStructTupleTy g typ then Some g.obj_ty + elif isFSharpStructOrEnumTy g typ then + if isFSharpEnumTy g typ then + Some(g.system_Enum_typ) + else + Some (g.system_Value_typ) elif isRecdTy g typ || isUnionTy g typ then Some g.obj_ty else @@ -456,11 +461,19 @@ let private CombineMethInsts ttps mtps tinst minst = (mkTyparInst ttps tinst @ m /// Work out the instantiation relevant to interpret the backing metadata for a member. /// -/// The 'minst' is the instantiation of any generic method type parameters (this instantiation is -/// not included in the MethInfo objects, but carried separately). -let private GetInstantiationForMemberVal g isCSharpExt (typ,vref,minst) = +/// The 'methTyArgs' is the instantiation of any generic method type parameters (this instantiation is +/// not included in the MethInfo objects, but carried separately). +let private GetInstantiationForMemberVal g isCSharpExt (typ, vref, methTyArgs: TypeInst) = let memberParentTypars,memberMethodTypars,_retTy,parentTyArgs = AnalyzeTypeOfMemberVal isCSharpExt g (typ,vref) - CombineMethInsts memberParentTypars memberMethodTypars parentTyArgs minst + /// In some recursive inference cases involving constraints this may need to be + /// fixed up - we allow uniform generic recursion but nothing else. + /// See https://github.com/Microsoft/visualfsharp/issues/3038#issuecomment-309429410 + let methTyArgsFixedUp = + if methTyArgs.Length < memberMethodTypars.Length then + methTyArgs @ (List.skip methTyArgs.Length memberMethodTypars |> generalizeTypars) + else + methTyArgs + CombineMethInsts memberParentTypars memberMethodTypars parentTyArgs methTyArgsFixedUp /// Work out the instantiation relevant to interpret the backing metadata for a property. let private GetInstantiationForPropertyVal g (typ,vref) = @@ -788,6 +801,8 @@ type ILMethInfo = /// Get info about the arguments of the IL method. If this is an C#-style extension method then /// drop the object argument. + /// + /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetParamNamesAndTypes(amap,m,minst) = x.ParamMetadata |> List.map (fun p -> ParamNameAndType(Option.map (mkSynId m) p.Name, ImportILTypeFromMetadata amap m x.MetadataScope x.DeclaringTypeInst minst p.Type) ) @@ -872,7 +887,7 @@ type MethInfo = member x.DeclaringEntityRef = match x with | ILMeth(_,ilminfo,_) when x.IsExtensionMember -> ilminfo.DeclaringTyconRef - | FSMeth(_,_,vref,_) when x.IsExtensionMember -> vref.TopValActualParent + | FSMeth(_,_,vref,_) when x.IsExtensionMember && vref.HasTopValActualParent -> vref.TopValActualParent | _ -> tcrefOfAppTy x.TcGlobals x.EnclosingType /// Get the information about provided static parameters, if any @@ -978,6 +993,8 @@ type MethInfo = /// Get the formal generic method parameters for the method as a list of variable types. member x.FormalMethodInst = generalizeTypars x.FormalMethodTypars + member x.FormalMethodTyparInst = mkTyparInst x.FormalMethodTypars x.FormalMethodInst + /// Get the XML documentation associated with the method member x.XmlDoc = match x with @@ -1689,7 +1706,7 @@ type RecdFieldInfo = type UnionCaseInfo = | UnionCaseInfo of TypeInst * Tast.UnionCaseRef - /// Get the generic instantiation of the declaring type of the union case + /// Get the list of types for the instantiation of the type parameters of the declaring type of the union case member x.TypeInst = let (UnionCaseInfo(tinst,_)) = x in tinst /// Get a reference to the F# metadata for the uninstantiated union case @@ -1706,6 +1723,10 @@ type UnionCaseInfo = /// Get the name of the union case member x.Name = x.UnionCase.DisplayName + + /// Get the instantiation of the type parameters of the declaring type of the union case + member x.GetTyparInst(m) = mkTyparInst (x.TyconRef.Typars(m)) x.TypeInst + override x.ToString() = x.TyconRef.ToString() + "::" + x.Name @@ -1755,16 +1776,22 @@ type ILPropInfo = (x.HasSetter && x.SetterMethod(g).IsNewSlot) /// Get the names and types of the indexer arguments associated with the IL property. + /// + /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetParamNamesAndTypes(amap,m) = let (ILPropInfo (tinfo,pdef)) = x pdef.Args |> List.map (fun ty -> ParamNameAndType(None, ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] ty) ) /// Get the types of the indexer arguments associated with the IL property. + /// + /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetParamTypes(amap,m) = let (ILPropInfo (tinfo,pdef)) = x pdef.Args |> List.map (fun ty -> ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] ty) /// Get the return type of the IL property. + /// + /// Any type parameters of the enclosing type are instantiated in the type returned. member x.GetPropertyType (amap,m) = let (ILPropInfo (tinfo,pdef)) = x ImportILTypeFromMetadata amap m tinfo.ILScopeRef tinfo.TypeInst [] pdef.Type @@ -2008,6 +2035,8 @@ type PropInfo = /// Get the names and types of the indexer parameters associated with the property + /// + /// If the property is in a generic type, then the type parameters are instantiated in the types returned. member x.GetParamNamesAndTypes(amap,m) = match x with | ILProp (_,ilpinfo) -> ilpinfo.GetParamNamesAndTypes(amap,m) @@ -2358,3 +2387,7 @@ let PropInfosEquivByNameAndSig erasureFlag g amap m (pinfo:PropInfo) (pinfo2:Pro let retTy = pinfo.GetPropertyType(amap,m) let retTy2 = pinfo2.GetPropertyType(amap,m) typeEquivAux erasureFlag g retTy retTy2 + +let SettersOfPropInfos (pinfos:PropInfo list) = pinfos |> List.choose (fun pinfo -> if pinfo.HasSetter then Some(pinfo.SetterMethod,Some pinfo) else None) +let GettersOfPropInfos (pinfos:PropInfo list) = pinfos |> List.choose (fun pinfo -> if pinfo.HasGetter then Some(pinfo.GetterMethod,Some pinfo) else None) + diff --git a/src/fsharp/layout.fs b/src/fsharp/layout.fs index 91854975eb..3ed5dd52c5 100755 --- a/src/fsharp/layout.fs +++ b/src/fsharp/layout.fs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (* internal *) Microsoft.FSharp.Compiler.Layout +module Microsoft.FSharp.Compiler.Layout open System open System.Collections.Generic @@ -10,9 +10,15 @@ open Microsoft.FSharp.Core.Printf #nowarn "62" // This construct is for ML compatibility. +#if COMPILER_PUBLIC_API type layout = Internal.Utilities.StructuredFormat.Layout type LayoutTag = Internal.Utilities.StructuredFormat.LayoutTag type TaggedText = Internal.Utilities.StructuredFormat.TaggedText +#else +type internal layout = Internal.Utilities.StructuredFormat.Layout +type internal LayoutTag = Internal.Utilities.StructuredFormat.LayoutTag +type internal TaggedText = Internal.Utilities.StructuredFormat.TaggedText +#endif type NavigableTaggedText(taggedText: TaggedText, range: Range.range) = member val Range = range diff --git a/src/fsharp/layout.fsi b/src/fsharp/layout.fsi index ea73374a05..34029f280b 100755 --- a/src/fsharp/layout.fsi +++ b/src/fsharp/layout.fsi @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (* internal *) Microsoft.FSharp.Compiler.Layout +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.Layout +#else +module internal Microsoft.FSharp.Compiler.Layout +#endif open System.Text open System.Collections.Generic diff --git a/src/fsharp/lex.fsl b/src/fsharp/lex.fsl index b3f651e91e..688f4efdb6 100755 --- a/src/fsharp/lex.fsl +++ b/src/fsharp/lex.fsl @@ -416,6 +416,14 @@ rule token args skip = parse { match unicodeGraphLong (lexemeTrimBoth lexbuf 3 1) with | SingleChar(c) -> CHAR (char c) | _ -> fail args lexbuf (FSComp.SR.lexThisUnicodeOnlyInStringLiterals()) (CHAR (char 0)) } + | "(*IF-FSHARP" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + | "(*F#" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + | "ENDIF-FSHARP*)" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + | "F#*)" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } | "(*)" { LPAREN_STAR_RPAREN } @@ -424,6 +432,10 @@ rule token args skip = parse { let m = lexbuf.LexemeRange if not skip then (COMMENT (LexCont.Comment(!args.ifdefStack,1,m))) else comment (1,m,args) skip lexbuf } + | "(*IF-CAML*)" | "(*IF-OCAML*)" + { let m = lexbuf.LexemeRange + if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf } + | '"' { let buf,fin,m = startString args lexbuf if not skip then (STRING_TEXT (LexCont.String(!args.ifdefStack,m))) else string (buf,fin,m,args) skip lexbuf } @@ -508,7 +520,8 @@ rule token args skip = parse let line,file = parseLeadingDirective 1 // Construct the new position - lexbuf.EndPos <- pos.ApplyLineDirective((match file with Some f -> fileIndexOfFile f | None -> pos.FileIndex), line) + if args.applyLineDirectives then + lexbuf.EndPos <- pos.ApplyLineDirective((match file with Some f -> fileIndexOfFile f | None -> pos.FileIndex), line) token args skip lexbuf else @@ -1038,3 +1051,24 @@ and tripleQuoteStringInComment n m args skip = parse | surrogateChar surrogateChar | _ { if not skip then (COMMENT (LexCont.TripleQuoteStringInComment(!args.ifdefStack,n,m))) else tripleQuoteStringInComment n m args skip lexbuf } + + +and mlOnly m args skip = parse + | "\"" + { let buf = ByteBuffer.Create 100 + let m2 = lexbuf.LexemeRange + let _ = string (buf,defaultStringFinisher,m2,args) skip lexbuf + if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf } + | newline + { newline lexbuf; if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf } + | "(*ENDIF-CAML*)" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + | "(*ENDIF-OCAML*)" + { if not skip then (COMMENT (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + | [^ '(' '"' '\n' '\r' ]+ + { if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf } + | eof + { EOF (LexCont.MLOnly(!args.ifdefStack,m)) } + | surrogateChar surrogateChar + | _ + { if not skip then (COMMENT (LexCont.MLOnly(!args.ifdefStack,m))) else mlOnly m args skip lexbuf } diff --git a/src/fsharp/lexhelp.fs b/src/fsharp/lexhelp.fs index c8282991c1..f0f1b53a58 100755 --- a/src/fsharp/lexhelp.fs +++ b/src/fsharp/lexhelp.fs @@ -55,7 +55,8 @@ type lexargs = ifdefStack: LexerIfdefStack resourceManager: LexResourceManager lightSyntaxStatus : LightSyntaxStatus - errorLogger: ErrorLogger } + errorLogger: ErrorLogger + applyLineDirectives: bool } /// possible results of lexing a long unicode escape sequence in a string literal, e.g. "\UDEADBEEF" type LongUnicodeLexResult = @@ -68,7 +69,8 @@ let mkLexargs (_filename,defines,lightSyntaxStatus,resourceManager,ifdefStack,er ifdefStack= ifdefStack lightSyntaxStatus=lightSyntaxStatus resourceManager=resourceManager - errorLogger=errorLogger } + errorLogger=errorLogger + applyLineDirectives=true } /// Register the lexbuf and call the given function let reusingLexbufForParsing lexbuf f = diff --git a/src/fsharp/lexhelp.fsi b/src/fsharp/lexhelp.fsi index 54ecd74531..d85f4ab044 100755 --- a/src/fsharp/lexhelp.fsi +++ b/src/fsharp/lexhelp.fsi @@ -28,11 +28,12 @@ type LexResourceManager = new : unit -> LexResourceManager type lexargs = - { defines: string list; - ifdefStack: LexerIfdefStack; - resourceManager: LexResourceManager; - lightSyntaxStatus: LightSyntaxStatus; - errorLogger: ErrorLogger} + { defines: string list + ifdefStack: LexerIfdefStack + resourceManager: LexResourceManager + lightSyntaxStatus : LightSyntaxStatus + errorLogger: ErrorLogger + applyLineDirectives: bool } type LongUnicodeLexResult = | SurrogatePair of uint16 * uint16 diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index ab34fbc04a..a0e5ecd00b 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -254,8 +254,10 @@ let map6Of6 f (a1,a2,a3,a4,a5,a6) = (a1,a2,a3,a4,a5,f a6) let foldPair (f1,f2) acc (a1,a2) = f2 (f1 acc a1) a2 let fold1Of2 f1 acc (a1,_a2) = f1 acc a1 let foldTriple (f1,f2,f3) acc (a1,a2,a3) = f3 (f2 (f1 acc a1) a2) a3 +let foldQuadruple (f1,f2,f3,f4) acc (a1,a2,a3,a4) = f4 (f3 (f2 (f1 acc a1) a2) a3) a4 let mapPair (f1,f2) (a1,a2) = (f1 a1, f2 a2) let mapTriple (f1,f2,f3) (a1,a2,a3) = (f1 a1, f2 a2, f3 a3) +let mapQuadruple (f1,f2,f3,f4) (a1,a2,a3,a4) = (f1 a1, f2 a2, f3 a3, f4 a4) let fmap2Of2 f z (a1,a2) = let z,a2 = f z a2 in z,(a1,a2) module List = @@ -387,37 +389,6 @@ let inline cacheOptRef cache f = res -// There is a bug in .NET Framework v2.0.52727 DD#153959 that very occasionally hits F# code. -// It is related to recursive class loading in multi-assembly NGEN scenarios. The bug has been fixed but -// not yet deployed. -// The bug manifests itself as an ExecutionEngine failure or fast-fail process exit which comes -// and goes depending on whether components are NGEN'd or not, e.g. 'ngen install FSharp.Compiler.dll' -// One workaround for the bug is to break NGEN loading and fixups into smaller fragments. Roughly speaking, the NGEN -// loading process works by doing delayed fixups of references in NGEN code. This happens on a per-method basis. -// e.g. one manifestation is that a 'print' before calling a method like LexFilter.create gets -// displayed but the corresponding 'print' in the body of that function doesn't get displayed. In between, the NGEN -// image loader is performing a whole bunch of fixups of the NGEN code for the body of that method, and also for -// bodies of methods referred to by that method. That second bit is very important: the fixup causing the crash may -// be a couple of steps down the dependency chain. -// -// One way to break work into smaller chunks is to put delays in the call chains, i.e. insert extra stack frames. That's -// what the function 'delayInsertedToWorkaroundKnownNgenBug' is for. If you get this problem, try inserting -// delayInsertedToWorkaroundKnownNgenBug "Delay1" (fun () -> ...) -// at the top of the function that doesn't seem to be being called correctly. This will help you isolate out the problem -// and may make the problem go away altogether. Enable the 'print' commands in that function too. - -let delayInsertedToWorkaroundKnownNgenBug s f = - (* Some random code to prevent inlining of this function *) - let res = ref 10 - for i = 0 to 2 do - res := !res + String.length s - done - if verbose then printf "------------------------executing NGEN bug delay '%s', calling 'f' --------------\n" s - let res = f() - if verbose then printf "------------------------exiting NGEN bug delay '%s' --------------\n" s - res - - #if DUMPER type Dumper(x:obj) = [] diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index d039453a54..8708869370 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -53,7 +53,9 @@ let mkUnderscoreRecdField m = LongIdentWithDots([ident("_", m)], []), false let mkRecdField lidwd = lidwd, true let mkSynDoBinding (vis,strict,expr,m) = - if Option.isSome vis then errorR(Error(FSComp.SR.parsDoCannotHaveVisibilityDeclarations(),m)); + match vis with + | Some vis -> errorR(Error(FSComp.SR.parsDoCannotHaveVisibilityDeclarations (vis.ToString()),m)) + | None -> () Binding (None, (if strict then DoBinding else StandaloneExpression), false,false,[],PreXmlDoc.Empty,SynInfo.emptySynValData, @@ -94,6 +96,7 @@ let checkEndOfFileError t = | LexCont.StringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInStringInComment()) | LexCont.VerbatimStringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInVerbatimStringInComment()) | LexCont.TripleQuoteStringInComment (_,_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInTripleQuoteStringInComment()) + | LexCont.MLOnly (_,m) -> reportParseErrorAt m (FSComp.SR.parsEofInIfOcaml()) | LexCont.EndLine(LexerEndlineContinuation.Skip(_,_,m)) -> reportParseErrorAt m (FSComp.SR.parsEofInDirective()) | LexCont.EndLine(LexerEndlineContinuation.Token(stack)) | LexCont.Token(stack) -> @@ -546,7 +549,9 @@ interactiveDefns: /* An expression as part of one interaction in F# Interactive */ interactiveExpr: | opt_attributes opt_declVisibility declExpr - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(),rhs parseState 3)) + { match $2 with + | Some vis -> errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(vis.ToString()),rhs parseState 3)) + | _ -> () let attrDecls = if not (isNil $1) then [ SynModuleDecl.Attributes ($1, rangeOfNonNilAttrs $1) ] else [] in attrDecls @ [ mkSynDoDecl($3)] } @@ -730,14 +735,15 @@ moduleSpfn: { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) let isRec, path, xml, vis = $3 if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec()) - if List.length path <> 1 then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) - if List.length $1 <> 0 then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation()) - if Option.isSome vis then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreVisibilityOnModuleAbbreviationAlwaysPrivate()) - SynModuleSigDecl.ModuleAbbrev(List.head path,$5,rhs2 parseState 3 5) } + if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) + if not (isNil $1) then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation()) + match vis with + | Some vis -> raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreVisibilityOnModuleAbbreviationAlwaysPrivate(vis.ToString())) + | _ -> SynModuleSigDecl.ModuleAbbrev(List.head path,$5,rhs2 parseState 3 5) } | opt_attributes opt_declVisibility moduleIntro colonOrEquals moduleSpecBlock { let isRec, path, xml, vis = $3 - if List.length path <> 1 then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleDefnMustBeSimpleName()) + if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleDefnMustBeSimpleName()) if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec()) let info = ComponentInfo($1,[],[],path,xml,false,vis,rhs parseState 3) if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) @@ -1131,17 +1137,23 @@ moduleDefnsOrExprPossiblyEmpty: /* A naked expression is only allowed at the start of a module/file, or straight after a topSeparators */ moduleDefnsOrExpr: | opt_attributes opt_declVisibility declExpr topSeparators moduleDefnsOrExpr - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(),rhs parseState 3)) + { match $2 with + | Some vis -> errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(vis.ToString()),rhs parseState 3)) + | _ -> () let attrDecls = if not (isNil $1) then [ SynModuleDecl.Attributes ($1, rangeOfNonNilAttrs $1) ] else [] attrDecls @ mkSynDoDecl ($3) :: $5 } | opt_attributes opt_declVisibility declExpr topSeparators - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(),rhs parseState 3)) + { match $2 with + | Some vis -> errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(vis.ToString()),rhs parseState 3)) + | _ -> () let attrDecls = if not (isNil $1) then [ SynModuleDecl.Attributes ($1, rangeOfNonNilAttrs $1) ] else [] attrDecls @ [ mkSynDoDecl($3) ] } | opt_attributes opt_declVisibility declExpr - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(),rhs parseState 3)) + { match $2 with + | Some vis -> errorR(Error(FSComp.SR.parsUnexpectedVisibilityDeclaration(vis.ToString()),rhs parseState 3)) + | _ -> () let attrDecls = if not (isNil $1) then [ SynModuleDecl.Attributes ($1, rangeOfNonNilAttrs $1) ] else [] attrDecls @ [ mkSynDoDecl($3) ] } @@ -1227,12 +1239,14 @@ moduleDefn: | Choice1Of2 eqn -> if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) if isRec then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsInvalidUseOfRec()) - if List.length path <> 1 then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) - if List.length $1 <> 0 then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation()) - if Option.isSome vis then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviationAlwaysPrivate()) + if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) + if not (isNil $1) then raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviation()) + match vis with + | Some vis -> raiseParseErrorAt (rhs parseState 1) (FSComp.SR.parsIgnoreAttributesOnModuleAbbreviationAlwaysPrivate(vis.ToString())) + | _ -> () [ SynModuleDecl.ModuleAbbrev(List.head path,eqn,(rhs parseState 3, eqn) ||> unionRangeWithListBy (fun id -> id.idRange) ) ] | Choice2Of2 def -> - if List.length path <> 1 then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) + if not (isSingleton path) then raiseParseErrorAt (rhs parseState 3) (FSComp.SR.parsModuleAbbreviationMustBeSimpleName()) let info = ComponentInfo(attribs,[],[],path,xml,false,vis,rhs parseState 3) [ SynModuleDecl.NestedModule(info, isRec, def, false,(rhs2 parseState 3 4, def) ||> unionRangeWithListBy (fun d -> d.Range) ) ] } @@ -1693,7 +1707,10 @@ memberCore: let memFlags = memFlagsBuilder memberKind let valSynInfo = - let adjustValueArg valueArg = if List.length valueArg = 1 then valueArg else SynInfo.unnamedTopArg + let adjustValueArg valueArg = + match valueArg with + | [_] -> valueArg + | _ -> SynInfo.unnamedTopArg match memberKind, valSynInfo, memFlags.IsInstance with | MemberKind.PropertyGet,SynValInfo ([],_ret), false @@ -2362,9 +2379,9 @@ defnBindings: BindingSetPreAttrs(mLetKwd,isRec,isUse, (fun attrs vis -> // apply the builder - let binds = localBindingsBuilder attrs vis mLetKwd - if not isRec && List.length binds > 1 then - reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) + let binds = localBindingsBuilder attrs vis mLetKwd + if not isRec && not (isNilOrSingleton binds) then + reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [],binds), bindingSetRange) } @@ -2401,10 +2418,10 @@ hardwhiteLetBindings: // the first binding swallow any attributes prior to the 'let' BindingSetPreAttrs(mLetKwd,isRec,isUse, - (fun attrs vis -> - let binds = localBindingsBuilder attrs vis mLetKwd - if not isRec && List.length binds > 1 then - reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) + (fun attrs vis -> + let binds = localBindingsBuilder attrs vis mLetKwd + if not isRec && not (isNilOrSingleton binds) then + reportParseErrorAt mLetKwd (FSComp.SR.parsLetAndForNonRecBindings()) [],binds), bindingSetRange), (unionRanges mLetKwd bindingSetRange) } @@ -2810,7 +2827,7 @@ atomicPattern: { SynPat.OptionalVal($2,lhs parseState) } | atomicPatternLongIdent %prec prec_atompat_pathop { let vis,lidwd = $1 - if List.length lidwd.Lid > 1 || (let c = (List.head lidwd.Lid).idText.[0] in Char.IsUpper(c) && not (Char.IsLower c)) + if not (isNilOrSingleton lidwd.Lid) || (let c = (List.head lidwd.Lid).idText.[0] in Char.IsUpper(c) && not (Char.IsLower c)) then mkSynPatMaybeVar lidwd vis (lhs parseState) else mkSynPatVar vis (List.head lidwd.Lid) } | constant diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 932bab94f1..fe027d9416 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. /// Anything to do with special names of identifiers and other lexical rules -module (*internal*) Microsoft.FSharp.Compiler.Range +module Microsoft.FSharp.Compiler.Range open System.IO open System.Collections.Generic diff --git a/src/fsharp/range.fsi b/src/fsharp/range.fsi index 4b0a34fdf8..b43d6c7c60 100755 --- a/src/fsharp/range.fsi +++ b/src/fsharp/range.fsi @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -module (*internal*) Microsoft.FSharp.Compiler.Range +#if COMPILER_PUBLIC_API +module public Microsoft.FSharp.Compiler.Range +#else +module internal Microsoft.FSharp.Compiler.Range +#endif open System.Text open System.Collections.Generic diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs new file mode 100644 index 0000000000..ee213b07f2 --- /dev/null +++ b/src/fsharp/symbols/Exprs.fs @@ -0,0 +1,1146 @@ +// Copyright (c) Microsoft Corpration, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. 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.TcGlobals +open Microsoft.FSharp.Compiler.Tastops +open Microsoft.FSharp.Compiler.QuotationTranslator +open Microsoft.FSharp.Compiler.TypeRelations +open Internal.Utilities + +[] +module ExprTranslationImpl = + + let nonNil x = not (List.isEmpty x) + + type ExprTranslationEnv = + { //Map from Val to binding index + vs: ValMap; + //Map from typar stamps to binding index + tyvs: StampMap; + // Map for values bound by the + // 'let v = isinst e in .... if nonnull v then ...v .... ' + // construct arising out the compilation of pattern matching. We decode these back to the form + // 'if istype v then ...unbox v .... ' + isinstVals: ValMap + substVals: ValMap } + + static member Empty = + { vs=ValMap<_>.Empty; + tyvs = Map.empty ; + isinstVals = ValMap<_>.Empty + substVals = ValMap<_>.Empty } + + member env.BindTypar (v:Typar, gp) = + { env with tyvs = env.tyvs.Add(v.Stamp,gp ) } + + member env.BindTypars vs = + (env, vs) ||> List.fold (fun env v -> env.BindTypar v) // fold left-to-right because indexes are left-to-right + + member env.BindVal v = + { env with vs = env.vs.Add v () } + + member env.BindIsInstVal v (ty,e) = + { env with isinstVals = env.isinstVals.Add v (ty,e) } + + 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) + + exception IgnoringPartOfQuotedTermWarning of string * Range.range + + let wfail (msg,m:range) = failwith (msg + sprintf " at %s" (m.ToString())) + + +/// The core tree of data produced by converting F# compiler TAST expressions into the form which we make available through the compiler API +/// through active patterns. +type E = + | Value of FSharpMemberOrFunctionOrValue + | ThisValue of FSharpType + | BaseValue of FSharpType + | Application of FSharpExpr * FSharpType list * FSharpExpr list + | Lambda of FSharpMemberOrFunctionOrValue * FSharpExpr + | TypeLambda of FSharpGenericParameter list * FSharpExpr + | Quote of FSharpExpr + | IfThenElse of FSharpExpr * FSharpExpr * FSharpExpr + | DecisionTree of FSharpExpr * (FSharpMemberOrFunctionOrValue list * FSharpExpr) list + | DecisionTreeSuccess of int * FSharpExpr list + | Call of FSharpExpr option * FSharpMemberOrFunctionOrValue * FSharpType list * FSharpType list * FSharpExpr list + | NewObject of FSharpMemberOrFunctionOrValue * FSharpType list * FSharpExpr list + | LetRec of ( FSharpMemberOrFunctionOrValue * FSharpExpr) list * FSharpExpr + | Let of (FSharpMemberOrFunctionOrValue * FSharpExpr) * FSharpExpr + | NewRecord of FSharpType * FSharpExpr list + | ObjectExpr of FSharpType * FSharpExpr * FSharpObjectExprOverride list * (FSharpType * FSharpObjectExprOverride list) list + | FSharpFieldGet of FSharpExpr option * FSharpType * FSharpField + | FSharpFieldSet of FSharpExpr option * FSharpType * FSharpField * FSharpExpr + | NewUnionCase of FSharpType * FSharpUnionCase * FSharpExpr list + | UnionCaseGet of FSharpExpr * FSharpType * FSharpUnionCase * FSharpField + | UnionCaseSet of FSharpExpr * FSharpType * FSharpUnionCase * FSharpField * FSharpExpr + | UnionCaseTag of FSharpExpr * FSharpType + | UnionCaseTest of FSharpExpr * FSharpType * FSharpUnionCase + | TraitCall of FSharpType list * string * Ast.MemberFlags * FSharpType list * FSharpType list * FSharpExpr list + | NewTuple of FSharpType * FSharpExpr list + | TupleGet of FSharpType * int * FSharpExpr + | Coerce of FSharpType * FSharpExpr + | NewArray of FSharpType * FSharpExpr list + | TypeTest of FSharpType * FSharpExpr + | AddressSet of FSharpExpr * FSharpExpr + | ValueSet of FSharpMemberOrFunctionOrValue * FSharpExpr + | Unused + | DefaultValue of FSharpType + | Const of obj * FSharpType + | AddressOf of FSharpExpr + | Sequential of FSharpExpr * FSharpExpr + | FastIntegerForLoop of FSharpExpr * FSharpExpr * FSharpExpr * bool + | WhileLoop of FSharpExpr * FSharpExpr + | TryFinally of FSharpExpr * FSharpExpr + | TryWith of FSharpExpr * FSharpMemberOrFunctionOrValue * FSharpExpr * FSharpMemberOrFunctionOrValue * FSharpExpr + | NewDelegate of FSharpType * FSharpExpr + | ILFieldGet of FSharpExpr option * FSharpType * string + | ILFieldSet of FSharpExpr option * FSharpType * string * FSharpExpr + | ILAsm of string * FSharpType list * FSharpExpr list + +/// Used to represent the information at an object expression member +and [] FSharpObjectExprOverride(sgn: FSharpAbstractSignature, gps: FSharpGenericParameter list, args:FSharpMemberOrFunctionOrValue list list, body: FSharpExpr) = + member __.Signature = sgn + member __.GenericParameters = gps + member __.CurriedParameterGroups = args + member __.Body = body + +/// The type of expressions provided through the compiler API. +and [] FSharpExpr (cenv, f: (unit -> FSharpExpr) option, e: E, m:range, ty) = + + member x.Range = m + member x.Type = FSharpType(cenv, ty) + member x.cenv = cenv + member x.E = match f with None -> e | Some f -> f().E + override x.ToString() = sprintf "%+A" x.E + + member x.ImmediateSubExpressions = + match x.E with + | E.Value _v -> [] + | E.Const (_constValue, _ty) -> [] + | E.TypeLambda (_v, body) -> [body] + | E.Lambda (_v, body) -> [body] + | E.Application (f, _tyargs, arg) -> f :: arg + | E.IfThenElse (e1, e2, e3) -> [e1;e2;e3] + | E.Let ((_bindingVar, bindingExpr), b) -> [bindingExpr;b] + | E.LetRec (ves, b) -> (List.map snd ves) @ [b] + | E.NewRecord (_recordType, es) -> es + | E.NewUnionCase (_unionType, _unionCase, es) -> es + | E.NewTuple (_tupleType, es) -> es + | E.TupleGet (_tupleType, _itemIndex, tupleExpr) -> [tupleExpr] + | E.Call (objOpt, _b, _c, _d, es) -> (match objOpt with None -> es | Some x -> x::es) + | E.NewObject (_a, _b, c) -> c + | E.FSharpFieldGet (objOpt, _b, _c) -> (match objOpt with None -> [] | Some x -> [x]) + | E.FSharpFieldSet (objOpt, _b, _c, d) -> (match objOpt with None -> [d] | Some x -> [x;d]) + | E.UnionCaseGet (obj, _b, _c, _d) -> [obj] + | E.UnionCaseTag (obj, _b) -> [obj] + | E.UnionCaseTest (obj, _b, _c) -> [obj] + | E.NewArray (_ty, elems) -> elems + | E.Coerce (_ty, b) -> [b] + | E.Quote (a) -> [a] + | E.TypeTest (_ty, b) -> [b] + | E.Sequential (a, b) -> [a;b] + | E.FastIntegerForLoop (a, b, c, _dir) -> [a;b;c] + | E.WhileLoop (guard, body) -> [guard; body] + | E.TryFinally (body, b) -> [body; b] + | E.TryWith (body, _b, _c, _d, handler) -> [body; handler] + | E.NewDelegate (_ty, body) -> [body] + | E.DefaultValue (_ty) -> [] + | E.AddressSet (lvalueExpr, rvalueExpr) -> [lvalueExpr; rvalueExpr] + | E.ValueSet (_v, rvalueExpr) -> [rvalueExpr] + | E.AddressOf (lvalueExpr) -> [lvalueExpr] + | E.ThisValue (_ty) -> [] + | E.BaseValue (_ty) -> [] + | E.ILAsm (_code, _tyargs, argExprs) -> argExprs + | E.ILFieldGet (objOpt, _ty, _fieldName) -> (match objOpt with None -> [] | Some x -> [x]) + | E.ILFieldSet (objOpt, _ty, _fieldName, d) -> (match objOpt with None -> [d] | Some x -> [x;d]) + | E.ObjectExpr (_ty, basecall, overrides, interfaceImpls) -> + [ yield basecall; + for m in overrides do yield m.Body + for (_, ms) in interfaceImpls do for m in ms do yield m.Body ] + | E.DecisionTree (inputExpr, targetCases) -> + [ yield inputExpr; + for (_targetVars, targetExpr) in targetCases do yield targetExpr ] + | E.DecisionTreeSuccess (_targetNumber, targetArgs) -> targetArgs + | E.UnionCaseSet (obj, _unionType, _unionCase, _unionField, valueExpr) -> [ yield obj; yield valueExpr ] + | E.TraitCall (_sourceTypes, _traitName, _memberFlags, _paramTypes, _retTypes, args) -> args + | E.Unused -> [] // unexpected + + +/// The implementation of the conversion operation +module FSharpExprConvert = + + let IsStaticInitializationField (rfref: RecdFieldRef) = + rfref.RecdField.IsCompilerGenerated && + rfref.RecdField.IsStatic && + rfref.RecdField.IsMutable && + rfref.RecdField.Name.StartsWith "init" + + // Match "if [AI_clt](init@41,6) then IntrinsicFunctions.FailStaticInit () else ()" + let (|StaticInitializationCheck|_|) e = + match e with + | Expr.Match (_,_,TDSwitch(Expr.Op(TOp.ILAsm ([ AI_clt ],_),_,[Expr.Op(TOp.ValFieldGet rfref,_,_,_) ;_],_),_,_,_),_,_,_) when IsStaticInitializationField rfref -> Some () + | _ -> None + + // Match "init@41 <- 6" + let (|StaticInitializationCount|_|) e = + match e with + | Expr.Op(TOp.ValFieldSet rfref,_,_,_) when IsStaticInitializationField rfref -> Some () + | _ -> None + + let ConvType cenv typ = FSharpType(cenv, typ) + let ConvTypes cenv typs = List.map (ConvType cenv) typs + let ConvILTypeRefApp (cenv:Impl.cenv) m tref tyargs = + let tcref = Import.ImportILTypeRef cenv.amap m tref + ConvType cenv (mkAppTy tcref tyargs) + + let ConvUnionCaseRef cenv (ucref:UnionCaseRef) = FSharpUnionCase(cenv, ucref) + let ConvRecdFieldRef cenv (rfref:RecdFieldRef) = FSharpField(cenv,rfref ) + + let rec exprOfExprAddr (cenv:Impl.cenv) expr = + match expr with + | Expr.Op(op,tyargs,args,m) -> + match op, args, tyargs with + | TOp.LValueOp(LGetAddr,vref),_,_ -> exprForValRef m vref + | TOp.ValFieldGetAddr(rfref),[],_ -> mkStaticRecdFieldGet(rfref,tyargs,m) + | TOp.ValFieldGetAddr(rfref),[arg],_ -> mkRecdFieldGetViaExprAddr(exprOfExprAddr cenv arg,rfref,tyargs,m) + | TOp.UnionCaseFieldGetAddr(uref,n),[arg],_ -> mkUnionCaseFieldGetProvenViaExprAddr(exprOfExprAddr cenv arg,uref,tyargs,n,m) + | TOp.ILAsm([ I_ldflda(fspec) ],rtys),[arg],_ -> mkAsmExpr([ mkNormalLdfld(fspec) ],tyargs, [exprOfExprAddr cenv arg], rtys, m) + | TOp.ILAsm([ I_ldsflda(fspec) ],rtys),_,_ -> mkAsmExpr([ mkNormalLdsfld(fspec) ],tyargs, args, rtys, m) + | TOp.ILAsm(([ I_ldelema(_ro,_isNativePtr,shape,_tyarg) ] ),_), (arr::idxs), [elemty] -> + match shape.Rank, idxs with + | 1, [idx1] -> mkCallArrayGet cenv.g m elemty arr idx1 + | 2, [idx1; idx2] -> mkCallArray2DGet cenv.g m elemty arr idx1 idx2 + | 3, [idx1; idx2; idx3] -> mkCallArray3DGet cenv.g m elemty arr idx1 idx2 idx3 + | 4, [idx1; idx2; idx3; idx4] -> mkCallArray4DGet cenv.g m elemty arr idx1 idx2 idx3 idx4 + | _ -> expr + | _ -> expr + | _ -> expr + + + let Mk cenv m ty e = FSharpExpr(cenv, None, e, m, ty) + + let Mk2 cenv (orig:Expr) e = FSharpExpr(cenv, None, e, orig.Range, tyOfExpr cenv.g orig) + + let rec ConvLValueExpr (cenv:Impl.cenv) env expr = ConvExpr cenv env (exprOfExprAddr cenv expr) + + and ConvExpr cenv env expr = + Mk2 cenv expr (ConvExprPrim cenv env expr) + + and ConvExprLinear cenv env expr contf = + ConvExprPrimLinear cenv env expr (fun exprR -> contf (Mk2 cenv expr exprR)) + + // Tail recursive function to process the subset of expressions considered "linear" + and ConvExprPrimLinear cenv env expr contf = + + match expr with + // Large lists + | Expr.Op(TOp.UnionCase ucref,tyargs,[e1;e2],_) -> + let mkR = ConvUnionCaseRef cenv ucref + let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) + let e1R = ConvExpr cenv env e1 + // tail recursive + ConvExprLinear cenv env e2 (contf << (fun e2R -> E.NewUnionCase(typR, mkR, [e1R; e2R]) )) + + // Large sequences of let bindings + | Expr.Let (bind,body,_,_) -> + match ConvLetBind cenv env bind with + | None, env -> ConvExprPrimLinear cenv env body contf + | Some(bindR),env -> + // tail recursive + ConvExprLinear cenv env body (contf << (fun bodyR -> E.Let(bindR,bodyR))) + + // Remove initialization checks + // Remove static initialization counter updates + // Remove static initialization counter checks + // + // Put in ConvExprPrimLinear because of the overlap with Expr.Sequential below + // + // TODO: allow clients to see static initialization checks if they want to + | Expr.Sequential(ObjectInitializationCheck cenv.g, x1, NormalSeq, _, _) + | Expr.Sequential (StaticInitializationCount,x1,NormalSeq,_,_) + | Expr.Sequential (StaticInitializationCheck,x1,NormalSeq,_,_) -> + ConvExprPrim cenv env x1 |> contf + + // Large sequences of sequential code + | Expr.Sequential (e1,e2,NormalSeq,_,_) -> + let e1R = ConvExpr cenv env e1 + // tail recursive + ConvExprLinear cenv env e2 (contf << (fun e2R -> E.Sequential(e1R, e2R))) + + | Expr.Sequential (x0,x1,ThenDoSeq,_,_) -> E.Sequential(ConvExpr cenv env x0, ConvExpr cenv env x1) + + | ModuleValueOrMemberUse cenv.g (vref,vFlags,_f,_fty,tyargs,curriedArgs) when (nonNil tyargs || nonNil curriedArgs) && vref.IsMemberOrModuleBinding -> + ConvModuleValueOrMemberUseLinear cenv env (expr,vref,vFlags,tyargs,curriedArgs) contf + + | Expr.Match (_spBind,m,dtree,tgs,_,retTy) -> + let dtreeR = ConvDecisionTree cenv env retTy dtree m + // tailcall + ConvTargetsLinear cenv env (List.ofArray tgs) (contf << fun (targetsR: _ list) -> + let (|E|) (x:FSharpExpr) = x.E + + // If the match is really an "if-then-else" then return it as such. + match dtreeR with + | E(E.IfThenElse(a,E(E.DecisionTreeSuccess(0,[])), E(E.DecisionTreeSuccess(1,[])))) -> E.IfThenElse(a,snd targetsR.[0],snd targetsR.[1]) + | _ -> E.DecisionTree(dtreeR,targetsR)) + + | _ -> + ConvExprPrim cenv env expr |> contf + + + /// A nasty function copied from creflect.fs. Made nastier by taking a continuation to process the + /// arguments to the call in a tail-recursive fashion. + and ConvModuleValueOrMemberUseLinear (cenv:Impl.cenv) env (expr:Expr,vref,vFlags,tyargs,curriedArgs) contf = + let m = expr.Range + + let (numEnclTypeArgs,_,isNewObj,_valUseFlags,_isSelfInit,takesInstanceArg,_isPropGet,_isPropSet) = + GetMemberCallInfo cenv.g (vref,vFlags) + + let isMember,curriedArgInfos = + + match vref.MemberInfo with + | Some _ when not vref.IsExtensionMember -> + // This is an application of a member method + // We only count one argument block for these. + let _tps,curriedArgInfos,_,_ = GetTypeOfMemberInFSharpForm cenv.g vref + true,curriedArgInfos + | _ -> + // This is an application of a module value or extension member + let arities = arityOfVal vref.Deref + let _tps,curriedArgInfos,_,_ = GetTopValTypeInFSharpForm cenv.g arities vref.Type m + false,curriedArgInfos + + // Compute the object arguments as they appear in a compiled call + // Strip off the object argument, if any. The curriedArgInfos are already adjusted to compiled member form + let objArgs,curriedArgs = + match takesInstanceArg,curriedArgs with + | false,curriedArgs -> [],curriedArgs + | true,(objArg::curriedArgs) -> [objArg],curriedArgs + | true,[] -> failwith ("warning: unexpected missing object argument when generating quotation for call to F# object member "+vref.LogicalName) + + // Check to see if there aren't enough arguments or if there is a tuple-arity mismatch + // If so, adjust and try again + if curriedArgs.Length < curriedArgInfos.Length || + ((List.take curriedArgInfos.Length curriedArgs,curriedArgInfos) ||> List.exists2 (fun arg argInfo -> (argInfo.Length > (tryDestRefTupleExpr arg).Length))) then + + // Too few arguments or incorrect tupling? Convert to a lambda and beta-reduce the + // partially applied arguments to 'let' bindings + let topValInfo = + match vref.ValReprInfo with + | None -> failwith ("no arity information found for F# value "+vref.LogicalName) + | Some a -> a + + let expr,exprty = AdjustValForExpectedArity cenv.g m vref vFlags topValInfo + let splitCallExpr = MakeApplicationAndBetaReduce cenv.g (expr,exprty,[tyargs],curriedArgs,m) + // tailcall + ConvExprPrimLinear cenv env splitCallExpr contf + + else + let curriedArgs,laterArgs = List.chop curriedArgInfos.Length curriedArgs + + // detuple the args + let untupledCurriedArgs = + (curriedArgs,curriedArgInfos) ||> List.map2 (fun arg curriedArgInfo -> + let numUntupledArgs = curriedArgInfo.Length + (if numUntupledArgs = 0 then [] + elif numUntupledArgs = 1 then [arg] + else tryDestRefTupleExpr arg)) + + let contf2 = + match laterArgs with + | [] -> contf + | _ -> (fun subCallR -> (subCallR, laterArgs) ||> List.fold (fun fR arg -> E.Application (Mk2 cenv arg fR,[],[ConvExpr cenv env arg])) |> contf) + + if isMember then + let callArgs = (objArgs::untupledCurriedArgs) |> List.concat + let enclTyArgs, methTyArgs = List.splitAfter numEnclTypeArgs tyargs + // tailcall + ConvObjectModelCallLinear cenv env (isNewObj, FSharpMemberOrFunctionOrValue(cenv,vref), enclTyArgs, methTyArgs, callArgs) contf2 + else + let v = FSharpMemberOrFunctionOrValue(cenv, vref) + // tailcall + ConvObjectModelCallLinear cenv env (false, v, [], tyargs, List.concat untupledCurriedArgs) contf2 + + and ConvExprPrim (cenv:Impl.cenv) (env:ExprTranslationEnv) expr = + // Eliminate integer 'for' loops + let expr = DetectAndOptimizeForExpression cenv.g OptimizeIntRangesOnly expr + + // Eliminate subsumption coercions for functions. This must be done post-typechecking because we need + // complete inference types. + let expr = NormalizeAndAdjustPossibleSubsumptionExprs cenv.g expr + + // Remove TExpr_ref nodes + let expr = stripExpr expr + + match expr with + + // Uses of possibly-polymorphic values which were not polymorphic in the end + | Expr.App(InnerExprPat(Expr.Val _ as ve),_fty,[],[],_) -> + ConvExprPrim cenv env ve + + // These cases are the start of a "linear" sequence where we use tail recursion to allow use to + // deal with large expressions. + | Expr.Op(TOp.UnionCase _,_,[_;_],_) // big lists + | Expr.Let _ // big linear sequences of 'let' + | Expr.Match _ // big linear sequences of 'match ... -> ....' + | Expr.Sequential _ -> + ConvExprPrimLinear cenv env expr (fun e -> e) + + | ModuleValueOrMemberUse cenv.g (vref,vFlags,_f,_fty,tyargs,curriedArgs) when (* (nonNil tyargs || nonNil curriedArgs) && *) vref.IsMemberOrModuleBinding -> + // Process applications of top-level values in a tail-recursive way + ConvModuleValueOrMemberUseLinear cenv env (expr,vref,vFlags,tyargs,curriedArgs) (fun e -> e) + + | Expr.Val(vref,_vFlags,m) -> + ConvValRef cenv env m vref + + // Simple applications + | Expr.App(f,_fty,tyargs,args,_m) -> + E.Application (ConvExpr cenv env f, ConvTypes cenv tyargs, ConvExprs cenv env args) + + | Expr.Const(c,m,ty) -> + ConvConst cenv env m c ty + + | Expr.LetRec(binds,body,_,_) -> + let vs = valsOfBinds binds + let vsR = vs |> List.map (ConvVal cenv) + let env = env.BindVals vs + let bodyR = ConvExpr cenv env body + let bindsR = List.zip vsR (binds |> List.map (fun b -> b.Expr |> ConvExpr cenv env)) + E.LetRec(bindsR,bodyR) + + | Expr.Lambda(_,_,_,vs,b,_,_) -> + let v,b = MultiLambdaToTupledLambda cenv.g vs b + let vR = ConvVal cenv v + let bR = ConvExpr cenv (env.BindVal v) b + E.Lambda(vR, bR) + + | Expr.Quote(ast,_,_,_,_) -> + E.Quote(ConvExpr cenv env ast) + + | Expr.TyLambda (_,tps,b,_,_) -> + let gps = [ for tp in tps -> FSharpGenericParameter(cenv,tp) ] + let env = env.BindTypars (Seq.zip tps gps |> Seq.toList) + E.TypeLambda(gps, ConvExpr cenv env b) + + | Expr.Obj (_,typ,_,_,[TObjExprMethod(TSlotSig(_,ctyp, _,_,_,_),_,tps,[tmvs],e,_) as tmethod],_,m) when isDelegateTy cenv.g typ -> + let f = mkLambdas m tps tmvs (e,GetFSharpViewOfReturnType cenv.g (returnTyOfMethod cenv.g tmethod)) + let fR = ConvExpr cenv env f + let tyargR = ConvType cenv ctyp + E.NewDelegate(tyargR, fR) + + | Expr.StaticOptimization (_,_,x,_) -> + ConvExprPrim cenv env x + + | Expr.TyChoose _ -> + ConvExprPrim cenv env (ChooseTyparSolutionsForFreeChoiceTypars cenv.g cenv.amap expr) + + | Expr.Obj (_lambdaId,typ,_basev,basecall,overrides, iimpls,_m) -> + let basecallR = ConvExpr cenv env basecall + let ConvertMethods methods = + [ for (TObjExprMethod(slotsig,_,tps,tmvs,body,_)) in methods -> + let vslR = List.map (List.map (ConvVal cenv)) tmvs + let sgn = FSharpAbstractSignature(cenv, slotsig) + let tpsR = [ for tp in tps -> FSharpGenericParameter(cenv,tp) ] + let env = ExprTranslationEnv.Empty.BindTypars (Seq.zip tps tpsR |> Seq.toList) + let env = env.BindCurriedVals tmvs + let bodyR = ConvExpr cenv env body + FSharpObjectExprOverride(sgn, tpsR, vslR, bodyR) ] + let overridesR = ConvertMethods overrides + let iimplsR = List.map (fun (ty,impls) -> ConvType cenv ty, ConvertMethods impls) iimpls + + E.ObjectExpr(ConvType cenv typ, basecallR, overridesR, iimplsR) + + | Expr.Op(op,tyargs,args,m) -> + match op,tyargs,args with + | TOp.UnionCase ucref,_,_ -> + let mkR = ConvUnionCaseRef cenv ucref + let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) + let argsR = ConvExprs cenv env args + E.NewUnionCase(typR, mkR, argsR) + + | TOp.Tuple tupInfo,tyargs,_ -> + let tyR = ConvType cenv (mkAnyTupledTy cenv.g tupInfo tyargs) + let argsR = ConvExprs cenv env args + E.NewTuple(tyR, argsR) + + | TOp.Recd (_,tcref),_,_ -> + let typR = ConvType cenv (mkAppTy tcref tyargs) + let argsR = ConvExprs cenv env args + E.NewRecord(typR, argsR) + + | TOp.UnionCaseFieldGet (ucref,n),tyargs,[e1] -> + let mkR = ConvUnionCaseRef cenv ucref + let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) + let projR = FSharpField(cenv, ucref, n) + E.UnionCaseGet(ConvExpr cenv env e1, typR, mkR, projR) + + | TOp.UnionCaseFieldSet (ucref,n),tyargs,[e1;e2] -> + let mkR = ConvUnionCaseRef cenv ucref + let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) + let projR = FSharpField(cenv, ucref, n) + E.UnionCaseSet(ConvExpr cenv env e1, typR, mkR, projR, ConvExpr cenv env e2) + + | TOp.UnionCaseFieldGetAddr (_ucref,_n),_tyargs,_ -> + E.AddressOf(ConvLValueExpr cenv env expr) + + | TOp.ValFieldGetAddr(_rfref),_tyargs,_ -> + E.AddressOf(ConvLValueExpr cenv env expr) + + | TOp.ValFieldGet(rfref),tyargs,[] -> + let projR = ConvRecdFieldRef cenv rfref + let typR = ConvType cenv (mkAppTy rfref.TyconRef tyargs) + E.FSharpFieldGet(None, typR, projR) + + | TOp.ValFieldGet(rfref),tyargs,[obj] -> + let objR = ConvLValueExpr cenv env obj + let projR = ConvRecdFieldRef cenv rfref + let typR = ConvType cenv (mkAppTy rfref.TyconRef tyargs) + E.FSharpFieldGet(Some objR, typR, projR) + + | TOp.TupleFieldGet(tupInfo,n),tyargs,[e] -> + let tyR = ConvType cenv (mkAnyTupledTy cenv.g tupInfo tyargs) + E.TupleGet(tyR, n, ConvExpr cenv env e) + + | TOp.ILAsm([ I_ldfld(_,_,fspec) ],_), enclTypeArgs, [obj] -> + let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let objR = ConvLValueExpr cenv env obj + E.ILFieldGet(Some objR, typR, fspec.Name) + + | TOp.ILAsm(( [ I_ldsfld (_,fspec) ] | [ I_ldsfld (_,fspec); AI_nop ]),_),enclTypeArgs,[] -> + let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + E.ILFieldGet(None, typR, fspec.Name) + + | TOp.ILAsm([ I_stfld(_,_,fspec) ],_),enclTypeArgs,[obj;arg] -> + let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let objR = ConvLValueExpr cenv env obj + let argR = ConvExpr cenv env arg + E.ILFieldSet(Some objR, typR, fspec.Name, argR) + + | TOp.ILAsm([ I_stsfld(_,fspec) ],_),enclTypeArgs,[arg] -> + let typR = ConvILTypeRefApp cenv m fspec.EnclosingTypeRef enclTypeArgs + let argR = ConvExpr cenv env arg + E.ILFieldSet(None, typR, fspec.Name, argR) + + + | TOp.ILAsm([ AI_ceq ],_),_,[arg1;arg2] -> + let ty = tyOfExpr cenv.g arg1 + let eq = mkCallEqualsOperator cenv.g m ty arg1 arg2 + ConvExprPrim cenv env eq + + | TOp.ILAsm([ I_throw ],_),_,[arg1] -> + let raiseExpr = mkCallRaise cenv.g m (tyOfExpr cenv.g expr) arg1 + ConvExprPrim cenv env raiseExpr + + | TOp.ILAsm(il,_),tyargs,args -> + E.ILAsm(sprintf "%+A" il, ConvTypes cenv tyargs, ConvExprs cenv env args) + + | TOp.ExnConstr tcref,tyargs,args -> + E.NewRecord(ConvType cenv (mkAppTy tcref tyargs), ConvExprs cenv env args) + + | TOp.ValFieldSet rfref, _tinst,[obj;arg] -> + let objR = ConvLValueExpr cenv env obj + let argR = ConvExpr cenv env arg + let typR = ConvType cenv (mkAppTy rfref.TyconRef tyargs) + let projR = ConvRecdFieldRef cenv rfref + E.FSharpFieldSet(Some objR, typR, projR, argR) + + | TOp.ValFieldSet rfref, _tinst,[arg] -> + let argR = ConvExpr cenv env arg + let typR = ConvType cenv (mkAppTy rfref.TyconRef tyargs) + let projR = ConvRecdFieldRef cenv rfref + E.FSharpFieldSet(None, typR, projR, argR) + + | TOp.ExnFieldGet(tcref,i),[],[obj] -> + let exnc = stripExnEqns tcref + let fspec = exnc.TrueInstanceFieldsAsList.[i] + let fref = mkRecdFieldRef tcref fspec.Name + let typR = ConvType cenv (mkAppTy tcref tyargs) + let objR = ConvExpr cenv env (mkCoerceExpr (obj, mkAppTy tcref [], m, cenv.g.exn_ty)) + E.FSharpFieldGet(Some objR, typR, ConvRecdFieldRef cenv fref) + + | TOp.ExnFieldSet(tcref,i),[],[obj;e2] -> + let exnc = stripExnEqns tcref + let fspec = exnc.TrueInstanceFieldsAsList.[i] + let fref = mkRecdFieldRef tcref fspec.Name + let typR = ConvType cenv (mkAppTy tcref tyargs) + let objR = ConvExpr cenv env (mkCoerceExpr (obj, mkAppTy tcref [], m, cenv.g.exn_ty)) + E.FSharpFieldSet(Some objR, typR, ConvRecdFieldRef cenv fref, ConvExpr cenv env e2) + + | TOp.Coerce,[tgtTy;srcTy],[x] -> + if typeEquiv cenv.g tgtTy srcTy then + ConvExprPrim cenv env x + else + E.Coerce(ConvType cenv tgtTy,ConvExpr cenv env x) + + | TOp.Reraise,[toTy],[] -> + // rebuild reraise() and Convert + mkReraiseLibCall cenv.g toTy m |> ConvExprPrim cenv env + + | TOp.LValueOp(LGetAddr,vref),[],[] -> + E.AddressOf(ConvExpr cenv env (exprForValRef m vref)) + + | TOp.LValueOp(LByrefSet,vref),[],[e] -> + E.AddressSet(ConvExpr cenv env (exprForValRef m vref), ConvExpr cenv env e) + + | TOp.LValueOp(LSet,vref),[],[e] -> + E.ValueSet(FSharpMemberOrFunctionOrValue(cenv, vref), ConvExpr cenv env e) + + | TOp.LValueOp(LByrefGet,vref),[],[] -> + ConvValRef cenv env m vref + + | TOp.Array,[ty],xa -> + E.NewArray(ConvType cenv ty,ConvExprs cenv env xa) + + | TOp.While _,[],[Expr.Lambda(_,_,_,[_],test,_,_);Expr.Lambda(_,_,_,[_],body,_,_)] -> + E.WhileLoop(ConvExpr cenv env test, ConvExpr cenv env body) + + | TOp.For(_, (FSharpForLoopUp |FSharpForLoopDown as dir) ), [], [Expr.Lambda(_,_,_,[_], lim0,_,_); Expr.Lambda(_,_,_,[_], SimpleArrayLoopUpperBound, lm,_); SimpleArrayLoopBody cenv.g (arr, elemTy, body)] -> + let lim1 = + let len = mkCallArrayLength cenv.g lm elemTy arr // Array.length arr + mkCallSubtractionOperator cenv.g lm cenv.g.int32_ty len (Expr.Const(Const.Int32 1, m, cenv.g.int32_ty)) // len - 1 + E.FastIntegerForLoop(ConvExpr cenv env lim0, ConvExpr cenv env lim1, ConvExpr cenv env body, (dir = FSharpForLoopUp)) + + | TOp.For(_,dir),[],[Expr.Lambda(_,_,_,[_],lim0,_,_);Expr.Lambda(_,_,_,[_],lim1,_,_);body] -> + match dir with + | FSharpForLoopUp -> E.FastIntegerForLoop(ConvExpr cenv env lim0,ConvExpr cenv env lim1, ConvExpr cenv env body,true) + | FSharpForLoopDown -> E.FastIntegerForLoop(ConvExpr cenv env lim0,ConvExpr cenv env lim1, ConvExpr cenv env body,false) + | _ -> failwith "unexpected for-loop form" + + | TOp.ILCall(_,_,_,isNewObj,valUseFlags,_isProp,_,ilMethRef,enclTypeArgs,methTypeArgs,_tys),[],callArgs -> + ConvILCall cenv env (isNewObj, valUseFlags, ilMethRef, enclTypeArgs, methTypeArgs, callArgs, m) + + | TOp.TryFinally _,[_resty],[Expr.Lambda(_,_,_,[_],e1,_,_); Expr.Lambda(_,_,_,[_],e2,_,_)] -> + E.TryFinally(ConvExpr cenv env e1,ConvExpr cenv env e2) + + | TOp.TryCatch _,[_resty],[Expr.Lambda(_,_,_,[_],e1,_,_); Expr.Lambda(_,_,_,[vf],ef,_,_); Expr.Lambda(_,_,_,[vh],eh,_,_)] -> + let vfR = ConvVal cenv vf + let envf = env.BindVal vf + let vhR = ConvVal cenv vh + let envh = env.BindVal vh + E.TryWith(ConvExpr cenv env e1,vfR,ConvExpr cenv envf ef,vhR,ConvExpr cenv envh eh) + + | TOp.Bytes bytes,[],[] -> E.Const(box bytes, ConvType cenv (tyOfExpr cenv.g expr)) + + | TOp.UInt16s arr,[],[] -> E.Const(box arr, ConvType cenv (tyOfExpr cenv.g expr)) + + | TOp.UnionCaseProof _,_,[e] -> ConvExprPrim cenv env e // Note: we erase the union case proof conversions when converting to quotations + | TOp.UnionCaseTagGet tycr,tyargs,[arg1] -> + let typR = ConvType cenv (mkAppTy tycr tyargs) + E.UnionCaseTag(ConvExpr cenv env arg1, typR) + + | TOp.TraitCall (TTrait(tys,nm,memFlags,argtys,_rty,_colution)),_,_ -> + let tysR = ConvTypes cenv tys + let tyargsR = ConvTypes cenv tyargs + let argtysR = ConvTypes cenv argtys + let argsR = ConvExprs cenv env args + E.TraitCall(tysR, nm, memFlags, argtysR, tyargsR, argsR) + + | TOp.RefAddrGet,[ty],[e] -> + let replExpr = mkRecdFieldGetAddrViaExprAddr(e, mkRefCellContentsRef cenv.g, [ty],m) + ConvExprPrim cenv env replExpr + + | _ -> wfail (sprintf "unhandled construct in AST", m) + | _ -> + wfail (sprintf "unhandled construct in AST", expr.Range) + + + and ConvLetBind cenv env (bind : Binding) = + match bind.Expr with + // Map for values bound by the + // 'let v = isinst e in .... if nonnull v then ...v .... ' + // construct arising out the compilation of pattern matching. We decode these back to the form + // 'if istype e then ...unbox e .... ' + // It's bit annoying that pattern matching does this tranformation. Like all premature optimization we pay a + // cost here to undo it. + | Expr.Op(TOp.ILAsm([ I_isinst _ ],_),[ty],[e],_) -> + None, env.BindIsInstVal bind.Var (ty,e) + + // Remove let = from quotation tree + | Expr.Val _ when bind.Var.IsCompilerGenerated -> + None, env.BindSubstVal bind.Var bind.Expr + + // Remove let = () from quotation tree + | Expr.Const(Const.Unit,_,_) when bind.Var.IsCompilerGenerated -> + None, env.BindSubstVal bind.Var bind.Expr + + // Remove let unionCase = ... from quotation tree + | Expr.Op(TOp.UnionCaseProof _,_,[e],_) -> + None, env.BindSubstVal bind.Var e + + | _ -> + let v = bind.Var + let vR = ConvVal cenv v + let rhsR = ConvExpr cenv env bind.Expr + let envinner = env.BindVal v + Some(vR,rhsR),envinner + + and ConvILCall (cenv:Impl.cenv) env (isNewObj, valUseFlags, ilMethRef, enclTypeArgs, methTypeArgs, callArgs, m) = + let isNewObj = (isNewObj || (match valUseFlags with CtorValUsedAsSuperInit | CtorValUsedAsSelfInit -> true | _ -> false)) + let methName = ilMethRef.Name + let isPropGet = methName.StartsWith("get_",System.StringComparison.Ordinal) + let isPropSet = methName.StartsWith("set_",System.StringComparison.Ordinal) + let isProp = isPropGet || isPropSet + + let tcref, subClass = + // this does not matter currently, type checking fails to resolve it when a TP references a union case subclass + try + // if the type is an union case class, lookup will fail + Import.ImportILTypeRef cenv.amap m ilMethRef.EnclosingTypeRef, None + with _ -> + let e = ilMethRef.EnclosingTypeRef + let parent = ILTypeRef.Create(e.Scope, e.Enclosing.Tail, e.Enclosing.Head) + Import.ImportILTypeRef cenv.amap m parent, Some e.Name + + let enclosingType = generalizedTyconRef tcref + + let makeCall minfo = + ConvObjectModelCallLinear cenv env (isNewObj, minfo, enclTypeArgs, methTypeArgs, callArgs) id + + let makeFSCall isMember (vr: ValRef) = + let memOrVal = + if isMember then + let minfo = MethInfo.FSMeth(cenv.g, enclosingType, vr, None) + FSharpMemberOrFunctionOrValue(cenv, minfo) + else + FSharpMemberOrFunctionOrValue(cenv, vr) + makeCall memOrVal + + // takes a possibly fake ValRef and tries to resolve it to an F# expression + let makeFSExpr isMember (vr: ValRef) = + let nlr = vr.nlr + let enclosingEntity = + try + nlr.EnclosingEntity.Deref + with _ -> + failwithf "Failed to resolve type '%s'" (nlr.EnclosingEntity.CompiledName) + let ccu = nlr.EnclosingEntity.nlr.Ccu + let vName = nlr.ItemKey.PartialKey.LogicalName // this is actually compiled name + let findByName = + enclosingEntity.MembersOfFSharpTyconSorted |> List.filter (fun v -> v.CompiledName = vName) + match findByName with + | [v] -> + makeFSCall isMember v + | [] -> + let typR = ConvType cenv (mkAppTy tcref enclTypeArgs) + if enclosingEntity.IsModuleOrNamespace then + let findModuleMemberByName = + enclosingEntity.ModuleOrNamespaceType.AllValsAndMembers + |> Seq.filter (fun v -> + v.CompiledName = vName && + match v.ActualParent with + | Parent p -> p.PublicPath = enclosingEntity.PublicPath + | _ -> false + ) |> List.ofSeq + match findModuleMemberByName with + | [v] -> + let vr = VRefLocal v + makeFSCall isMember vr + | [] -> + let isPropGet = vName.StartsWith("get_", System.StringComparison.Ordinal) + let isPropSet = vName.StartsWith("set_", System.StringComparison.Ordinal) + if isPropGet || isPropSet then + let name = PrettyNaming.ChopPropertyName vName + let findByName = + enclosingEntity.ModuleOrNamespaceType.AllValsAndMembers + |> Seq.filter (fun v -> v.CompiledName = name) + |> List.ofSeq + match findByName with + | [ v ] -> + let m = FSharpMemberOrFunctionOrValue(cenv, VRefLocal v) + if isPropGet then + E.Value m + else + let valR = ConvExpr cenv env callArgs.Head + E.ValueSet (m, valR) + | _ -> failwith "Failed to resolve module value unambigously" + else + failwith "Failed to resolve module member" + | _ -> + failwith "Failed to resolve overloaded module member" + elif enclosingEntity.IsRecordTycon then + if isProp then + let name = PrettyNaming.ChopPropertyName vName + let projR = ConvRecdFieldRef cenv (RFRef(tcref, name)) + let objR = ConvLValueExpr cenv env callArgs.Head + if isPropGet then + E.FSharpFieldGet(Some objR, typR, projR) + else + let valR = ConvExpr cenv env callArgs.Tail.Head + E.FSharpFieldSet(Some objR, typR, projR, valR) + elif vName = ".ctor" then + let argsR = ConvExprs cenv env callArgs + E.NewRecord(typR, argsR) + else + failwith "Failed to recognize record type member" + elif enclosingEntity.IsUnionTycon then + if vName = "GetTag" || vName = "get_Tag" then + let objR = ConvExpr cenv env callArgs.Head + E.UnionCaseTag(objR, typR) + elif vName.StartsWith("New") then + let name = vName.Substring(3) + let mkR = ConvUnionCaseRef cenv (UCRef(tcref, name)) + let argsR = ConvExprs cenv env callArgs + E.NewUnionCase(typR, mkR, argsR) + elif vName.StartsWith("Is") then + let name = vName.Substring(2) + let mkR = ConvUnionCaseRef cenv (UCRef(tcref, name)) + let objR = ConvExpr cenv env callArgs.Head + E.UnionCaseTest(objR, typR, mkR) + else + match subClass with + | Some name -> + let ucref = UCRef(tcref, name) + let mkR = ConvUnionCaseRef cenv ucref + let objR = ConvLValueExpr cenv env callArgs.Head + let projR = FSharpField(cenv, ucref, ucref.Index) + E.UnionCaseGet(objR, typR, mkR, projR) + | _ -> + failwith "Failed to recognize union type member" + else + let names = enclosingEntity.MembersOfFSharpTyconSorted |> List.map (fun v -> v.CompiledName) |> String.concat ", " + failwithf "Member '%s' not found in type %s, found: %s" vName enclosingEntity.DisplayName names + | _ -> // member is overloaded + match nlr.ItemKey.TypeForLinkage with + | None -> failwith "Type of signature could not be resolved" + | Some keyTy -> + let findBySig = + findByName |> List.tryFind (fun v -> ccu.MemberSignatureEquality(keyTy,v.Type)) + match findBySig with + | Some v -> + makeFSCall isMember v + | _ -> + failwith "Failed to recognize F# member" + + // First try to resolve it to IL metadata + let try1 = + if tcref.IsILTycon then + try + let mdef = resolveILMethodRefWithRescope unscopeILType tcref.ILTyconRawMetadata ilMethRef + let minfo = MethInfo.CreateILMeth(cenv.amap, m, enclosingType, mdef) + FSharpMemberOrFunctionOrValue(cenv, minfo) |> makeCall |> Some + with _ -> + None + else + None + + // Otherwise try to bind it to an F# symbol + match try1 with + | Some res -> res + | None -> + try + // Try to bind the call to an F# method call + let memberParentName = if tcref.IsModuleOrNamespace then None else Some tcref.LogicalName + // this logical name is not correct in the presence of CompiledName + let logicalName = ilMethRef.Name + let isMember = memberParentName.IsSome + if isMember then + match ilMethRef.Name, ilMethRef.EnclosingTypeRef.Name with + | "Invoke", "Microsoft.FSharp.Core.FSharpFunc`2" -> + let objR = ConvLValueExpr cenv env callArgs.Head + let argR = ConvExpr cenv env callArgs.Tail.Head + let typR = ConvType cenv enclTypeArgs.Head + E.Application(objR, [typR], [argR]) + | _ -> + let isCtor = (ilMethRef.Name = ".ctor") + let isStatic = isCtor || ilMethRef.CallingConv.IsStatic + let scoref = ilMethRef.EnclosingTypeRef.Scope + let typars1 = tcref.Typars(m) + let typars2 = [ 1 .. ilMethRef.GenericArity ] |> List.map (fun _ -> NewRigidTypar "T" m) + let tinst1 = typars1 |> generalizeTypars + let tinst2 = typars2 |> generalizeTypars + // TODO: this will not work for curried methods in F# classes. + // This is difficult to solve as the information in the ILMethodRef + // is not sufficient to resolve to a symbol unambiguously in these cases. + let argtys = [ ilMethRef.ArgTypes |> List.map (ImportILTypeFromMetadata cenv.amap m scoref tinst1 tinst2) ] + let rty = + match ImportReturnTypeFromMetaData cenv.amap m ilMethRef.ReturnType scoref tinst1 tinst2 with + | None -> if isCtor then enclosingType else cenv.g.unit_ty + | Some ty -> ty + + let linkageType = + let ty = mkIteratedFunTy (List.map (mkRefTupledTy cenv.g) argtys) rty + let ty = if isStatic then ty else mkFunTy enclosingType ty + tryMkForallTy (typars1 @ typars2) ty + + let argCount = List.sum (List.map List.length argtys) + (if isStatic then 0 else 1) + let key = ValLinkageFullKey({ MemberParentMangledName=memberParentName; MemberIsOverride=false; LogicalName=logicalName; TotalArgCount= argCount },Some linkageType) + + let (PubPath p) = tcref.PublicPath.Value + let enclosingNonLocalRef = mkNonLocalEntityRef tcref.nlr.Ccu p + let vref = mkNonLocalValRef enclosingNonLocalRef key + makeFSExpr isMember vref + + else + let key = ValLinkageFullKey({ MemberParentMangledName=memberParentName; MemberIsOverride=false; LogicalName=logicalName; TotalArgCount= 0 },None) + let vref = mkNonLocalValRef tcref.nlr key + makeFSExpr isMember vref + + with e -> + failwithf "An IL call to '%s' could not be resolved: %s" (ilMethRef.ToString()) e.Message + + and ConvObjectModelCallLinear cenv env (isNewObj, v:FSharpMemberOrFunctionOrValue, enclTyArgs, methTyArgs,callArgs) contf = + let enclTyArgsR = ConvTypes cenv enclTyArgs + let methTyArgsR = ConvTypes cenv methTyArgs + let obj, callArgs = + if v.IsInstanceMember then + match callArgs with + | obj :: rest -> Some obj, rest + | _ -> failwith (sprintf "unexpected shape of arguments: %A" callArgs) + else + None, callArgs + let objR = Option.map (ConvLValueExpr cenv env) obj + // tailcall + ConvExprsLinear cenv env callArgs (contf << fun callArgsR -> + if isNewObj then + E.NewObject(v, enclTyArgsR, callArgsR) + else + E.Call(objR, v, enclTyArgsR, methTyArgsR, callArgsR)) + + + and ConvExprs cenv env args = List.map (ConvExpr cenv env) args + + // Process a list of expressions in a tail-recursive way. Identical to "ConvExprs" but the result is eventually passed to contf. + and ConvExprsLinear cenv env args contf = + match args with + | [] -> contf [] + | [arg] -> ConvExprLinear cenv env arg (fun argR -> contf [argR]) + | arg::rest -> ConvExprLinear cenv env arg (fun argR -> ConvExprsLinear cenv env rest (fun restR -> contf (argR :: restR))) + + and ConvTargetsLinear cenv env tgs contf = + match tgs with + | [] -> contf [] + | TTarget(vars,rhs,_)::rest -> + let varsR = (List.rev vars) |> List.map (ConvVal cenv) + ConvExprLinear cenv env rhs (fun targetR -> + ConvTargetsLinear cenv env rest (fun restR -> + contf ((varsR, targetR) :: restR))) + + and ConvValRef cenv env m (vref:ValRef) = + let v = vref.Deref + if env.isinstVals.ContainsVal v then + let (ty,e) = env.isinstVals.[v] + ConvExprPrim cenv env (mkCallUnbox cenv.g m ty e) + elif env.substVals.ContainsVal v then + let e = env.substVals.[v] + ConvExprPrim cenv env e + elif v.BaseOrThisInfo = CtorThisVal then + E.ThisValue(ConvType cenv v.Type) + elif v.BaseOrThisInfo = BaseVal then + E.BaseValue(ConvType cenv v.Type) + else + E.Value(FSharpMemberOrFunctionOrValue(cenv, vref)) + + and ConvVal cenv (v:Val) = + let vref = mkLocalValRef v + FSharpMemberOrFunctionOrValue(cenv, vref) + + and ConvConst cenv env m c ty = + match TryEliminateDesugaredConstants cenv.g m c with + | Some e -> ConvExprPrim cenv env e + | None -> + let tyR = ConvType cenv ty + match c with + | Const.Bool i -> E.Const(box i, tyR) + | Const.SByte i -> E.Const(box i, tyR) + | Const.Byte i -> E.Const(box i, tyR) + | Const.Int16 i -> E.Const(box i, tyR) + | Const.UInt16 i -> E.Const(box i, tyR) + | Const.Int32 i -> E.Const(box i, tyR) + | Const.UInt32 i -> E.Const(box i, tyR) + | Const.Int64 i -> E.Const(box i, tyR) + | Const.IntPtr i -> E.Const(box (nativeint i), tyR) + | Const.UInt64 i -> E.Const(box i, tyR) + | Const.UIntPtr i -> E.Const(box (unativeint i), tyR) + | Const.Double i -> E.Const(box i, tyR) + | Const.Single i -> E.Const(box i, tyR) + | Const.String i -> E.Const(box i, tyR) + | Const.Char i -> E.Const(box i, tyR) + | Const.Unit -> E.Const(box (), tyR) + | Const.Zero -> E.DefaultValue (ConvType cenv ty) + | _ -> + wfail("FSharp.Compiler.Service cannot yet return this kind of constant", m) + + and ConvDecisionTree cenv env dtreeRetTy x m = + ConvDecisionTreePrim cenv env dtreeRetTy x |> Mk cenv m dtreeRetTy + + and ConvDecisionTreePrim cenv env dtreeRetTy x = + match x with + | TDSwitch(e1,csl,dfltOpt,m) -> + let acc = + match dfltOpt with + | Some d -> ConvDecisionTreePrim cenv env dtreeRetTy d + | None -> wfail( "FSharp.Compiler.Service cannot yet return this kind of pattern match", m) + (csl,acc) ||> List.foldBack (fun (TCase(discrim,dtree)) acc -> + let acc = acc |> Mk cenv m dtreeRetTy + match discrim with + | DecisionTreeTest.UnionCase (ucref, tyargs) -> + let objR = ConvExpr cenv env e1 + let ucR = ConvUnionCaseRef cenv ucref + let utypR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) + E.IfThenElse (E.UnionCaseTest (objR, utypR, ucR) |> Mk cenv m cenv.g.bool_ty, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + | DecisionTreeTest.Const (Const.Bool true) -> + let e1R = ConvExpr cenv env e1 + E.IfThenElse (e1R, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + | DecisionTreeTest.Const (Const.Bool false) -> + let e1R = ConvExpr cenv env e1 + // Note, reverse the branches + E.IfThenElse (e1R, acc, ConvDecisionTree cenv env dtreeRetTy dtree m) + | DecisionTreeTest.Const c -> + let ty = tyOfExpr cenv.g e1 + let eq = mkCallEqualsOperator cenv.g m ty e1 (Expr.Const (c, m, ty)) + let eqR = ConvExpr cenv env eq + E.IfThenElse (eqR, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + | DecisionTreeTest.IsNull -> + // Decompile cached isinst tests + match e1 with + | Expr.Val(vref,_,_) when env.isinstVals.ContainsVal vref.Deref -> + let (ty,e) = env.isinstVals.[vref.Deref] + let tyR = ConvType cenv ty + let eR = ConvExpr cenv env e + // note: reverse the branches - a null test is a failure of an isinst test + E.IfThenElse (E.TypeTest (tyR,eR) |> Mk cenv m cenv.g.bool_ty, acc, ConvDecisionTree cenv env dtreeRetTy dtree m) + | _ -> + let ty = tyOfExpr cenv.g e1 + let eq = mkCallEqualsOperator cenv.g m ty e1 (Expr.Const (Const.Zero, m, ty)) + let eqR = ConvExpr cenv env eq + E.IfThenElse (eqR, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + | DecisionTreeTest.IsInst (_srcty, tgty) -> + let e1R = ConvExpr cenv env e1 + E.IfThenElse (E.TypeTest (ConvType cenv tgty, e1R) |> Mk cenv m cenv.g.bool_ty, ConvDecisionTree cenv env dtreeRetTy dtree m, acc) + | DecisionTreeTest.ActivePatternCase _ -> wfail("unexpected Test.ActivePatternCase test in quoted expression",m) + | DecisionTreeTest.ArrayLength _ -> wfail("FSharp.Compiler.Service cannot yet return array pattern matching", m)) + + | TDSuccess (args,n) -> + // TAST stores pattern bindings in reverse order for some reason + // Reverse them here to give a good presentation to the user + let args = List.rev args + let argsR = ConvExprs cenv env args + E.DecisionTreeSuccess(n, argsR) + + | TDBind(bind,rest) -> + // The binding may be a compiler-generated binding that gets removed in the quotation presentation + match ConvLetBind cenv env bind with + | None, env -> ConvDecisionTreePrim cenv env dtreeRetTy rest + | Some(bindR),env -> E.Let(bindR,ConvDecisionTree cenv env dtreeRetTy rest bind.Var.Range) + + /// Wrap the conversion in a function to make it on-demand. Any pattern matching on the FSharpExpr will + /// force the evaluation of the entire conversion process eagerly. + let ConvExprOnDemand cenv env expr = + FSharpExpr(cenv, Some(fun () -> ConvExpr cenv env expr), E.Unused, expr.Range, tyOfExpr cenv.g expr) + + + +/// The contents of the F# assembly as provided through the compiler API +type FSharpAssemblyContents(cenv: Impl.cenv, mimpls: TypedImplFile list) = + + new (g, thisCcu, tcImports, mimpls) = FSharpAssemblyContents(Impl.cenv(g,thisCcu,tcImports), mimpls) + + member __.ImplementationFiles = + [ for mimpl in mimpls -> FSharpImplementationFileContents(cenv, mimpl)] + +and FSharpImplementationFileDeclaration = + | Entity of FSharpEntity * FSharpImplementationFileDeclaration list + | MemberOrFunctionOrValue of FSharpMemberOrFunctionOrValue * FSharpMemberOrFunctionOrValue list list * FSharpExpr + | InitAction of FSharpExpr + +and FSharpImplementationFileContents(cenv, mimpl) = + let (TImplFile(qname,_pragmas,ModuleOrNamespaceExprWithSig(_mty,mdef,_),hasExplicitEntryPoint,isScript)) = mimpl + let rec getDecls2 (ModuleOrNamespaceExprWithSig(_mty,def,_m)) = getDecls def + and getBind (bind: Binding) = + let v = bind.Var + assert v.IsCompiledAsTopLevel + let topValInfo = InferArityOfExprBinding cenv.g AllowTypeDirectedDetupling.Yes v bind.Expr + let tps,_ctorThisValOpt,_baseValOpt,vsl,body,_bodyty = IteratedAdjustArityOfLambda cenv.g cenv.amap topValInfo bind.Expr + let v = FSharpMemberOrFunctionOrValue(cenv, mkLocalValRef v) + let gps = v.GenericParameters + let vslR = List.map (List.map (FSharpExprConvert.ConvVal cenv)) vsl + let env = ExprTranslationEnv.Empty.BindTypars (Seq.zip tps gps |> Seq.toList) + let env = env.BindCurriedVals vsl + let e = FSharpExprConvert.ConvExprOnDemand cenv env body + FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(v, vslR, e) + + and getDecls mdef = + match mdef with + | TMDefRec(_isRec,tycons,mbinds,_m) -> + [ for tycon in tycons do + let entity = FSharpEntity(cenv, mkLocalEntityRef tycon) + yield FSharpImplementationFileDeclaration.Entity(entity, []) + for mbind in mbinds do + match mbind with + | ModuleOrNamespaceBinding.Module(mspec, def) -> + let entity = FSharpEntity(cenv, mkLocalEntityRef mspec) + yield FSharpImplementationFileDeclaration.Entity (entity, getDecls def) + | ModuleOrNamespaceBinding.Binding(bind) -> + yield getBind bind ] + | TMAbstract(mexpr) -> getDecls2 mexpr + | TMDefLet(bind,_m) -> + [ yield getBind bind ] + | TMDefDo(expr,_m) -> + [ let expr = FSharpExprConvert.ConvExprOnDemand cenv ExprTranslationEnv.Empty expr + yield FSharpImplementationFileDeclaration.InitAction(expr) ] + | TMDefs(mdefs) -> + [ for mdef in mdefs do yield! getDecls mdef ] + + member __.QualifiedName = qname.Text + member __.FileName = qname.Range.FileName + member __.Declarations = getDecls mdef + member __.HasExplicitEntryPoint = hasExplicitEntryPoint + member __.IsScript = isScript + + +module BasicPatterns = + let (|Value|_|) (e:FSharpExpr) = match e.E with E.Value (v) -> Some (v) | _ -> None + let (|Const|_|) (e:FSharpExpr) = match e.E with E.Const (v,ty) -> Some (v,ty) | _ -> None + let (|TypeLambda|_|) (e:FSharpExpr) = match e.E with E.TypeLambda (v,e) -> Some (v,e) | _ -> None + let (|Lambda|_|) (e:FSharpExpr) = match e.E with E.Lambda (v,e) -> Some (v,e) | _ -> None + let (|Application|_|) (e:FSharpExpr) = match e.E with E.Application (f,tys,e) -> Some (f,tys,e) | _ -> None + let (|IfThenElse|_|) (e:FSharpExpr) = match e.E with E.IfThenElse (e1,e2,e3) -> Some (e1,e2,e3) | _ -> None + 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 (|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 (|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 + let (|UnionCaseTest|_|) (e:FSharpExpr) = match e.E with E.UnionCaseTest (a,b,c) -> Some (a,b,c) | _ -> None + let (|NewArray|_|) (e:FSharpExpr) = match e.E with E.NewArray (a,b) -> Some (a,b) | _ -> None + let (|Coerce|_|) (e:FSharpExpr) = match e.E with E.Coerce (a,b) -> Some (a,b) | _ -> None + let (|Quote|_|) (e:FSharpExpr) = match e.E with E.Quote (a) -> Some (a) | _ -> None + let (|TypeTest|_|) (e:FSharpExpr) = match e.E with E.TypeTest (a,b) -> Some (a,b) | _ -> None + let (|Sequential|_|) (e:FSharpExpr) = match e.E with E.Sequential (a,b) -> Some (a,b) | _ -> None + let (|FastIntegerForLoop|_|) (e:FSharpExpr) = match e.E with E.FastIntegerForLoop (a,b,c,d) -> Some (a,b,c,d) | _ -> None + let (|WhileLoop|_|) (e:FSharpExpr) = match e.E with E.WhileLoop (a,b) -> Some (a,b) | _ -> None + let (|TryFinally|_|) (e:FSharpExpr) = match e.E with E.TryFinally (a,b) -> Some (a,b) | _ -> None + let (|TryWith|_|) (e:FSharpExpr) = match e.E with E.TryWith (a,b,c,d,e) -> Some (a,b,c,d,e) | _ -> None + let (|NewDelegate|_|) (e:FSharpExpr) = match e.E with E.NewDelegate (ty,e) -> Some (ty,e) | _ -> None + let (|DefaultValue|_|) (e:FSharpExpr) = match e.E with E.DefaultValue (ty) -> Some (ty) | _ -> None + let (|AddressSet|_|) (e:FSharpExpr) = match e.E with E.AddressSet (a,b) -> Some (a,b) | _ -> None + let (|ValueSet|_|) (e:FSharpExpr) = match e.E with E.ValueSet (a,b) -> Some (a,b) | _ -> None + let (|AddressOf|_|) (e:FSharpExpr) = match e.E with E.AddressOf (a) -> Some (a) | _ -> None + let (|ThisValue|_|) (e:FSharpExpr) = match e.E with E.ThisValue (a) -> Some (a) | _ -> None + let (|BaseValue|_|) (e:FSharpExpr) = match e.E with E.BaseValue (a) -> Some (a) | _ -> None + let (|ILAsm|_|) (e:FSharpExpr) = match e.E with E.ILAsm (a,b,c) -> Some (a,b,c) | _ -> None + let (|ILFieldGet|_|) (e:FSharpExpr) = match e.E with E.ILFieldGet (a,b,c) -> Some (a,b,c) | _ -> None + let (|ILFieldSet|_|) (e:FSharpExpr) = match e.E with E.ILFieldSet (a,b,c,d) -> Some (a,b,c,d) | _ -> None + let (|ObjectExpr|_|) (e:FSharpExpr) = match e.E with E.ObjectExpr (a,b,c,d) -> Some (a,b,c,d) | _ -> None + let (|DecisionTree|_|) (e:FSharpExpr) = match e.E with E.DecisionTree (a,b) -> Some (a,b) | _ -> None + let (|DecisionTreeSuccess|_|) (e:FSharpExpr) = match e.E with E.DecisionTreeSuccess (a,b) -> Some (a,b) | _ -> None + let (|UnionCaseSet|_|) (e:FSharpExpr) = match e.E with E.UnionCaseSet (a,b,c,d,e) -> Some (a,b,c,d,e) | _ -> None + let (|TraitCall|_|) (e:FSharpExpr) = match e.E with E.TraitCall (a,b,c,d,e,f) -> Some (a,b,c,d,e,f) | _ -> None + diff --git a/src/fsharp/symbols/Exprs.fsi b/src/fsharp/symbols/Exprs.fsi new file mode 100644 index 0000000000..70e1550816 --- /dev/null +++ b/src/fsharp/symbols/Exprs.fsi @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corpration, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp.Compiler.SourceCodeServices + +open System.Collections.Generic +open Microsoft.FSharp.Compiler +open Microsoft.FSharp.Compiler.TcGlobals +open Microsoft.FSharp.Compiler.Tast +open Microsoft.FSharp.Compiler.Range +open Microsoft.FSharp.Compiler.CompileOps + + +/// Represents the definitional contents of an assembly, as seen by the F# language +#if COMPILER_PUBLIC_API +type public FSharpAssemblyContents = +#else +type internal FSharpAssemblyContents = +#endif + + internal new : tcGlobals: TcGlobals * thisCcu: CcuThunk * tcImports: TcImports * mimpls: TypedImplFile list -> FSharpAssemblyContents + + /// The contents of the implementation files in the assembly + member ImplementationFiles: FSharpImplementationFileContents list + +/// Represents the definitional contents of a single file or fragment in an assembly, as seen by the F# language +#if COMPILER_PUBLIC_API +and [] FSharpImplementationFileContents = +#else +and [] internal FSharpImplementationFileContents = +#endif + + /// The qualified name acts to fully-qualify module specifications and implementations + member QualifiedName: string + + /// Get the system path of the implementation file + member FileName: string + + /// Get the declarations that make up this implementation file + member Declarations : FSharpImplementationFileDeclaration list + + /// Indicates if the implementation file is a script + member IsScript: bool + + /// Indicates if the implementation file has an explicit entry point + member HasExplicitEntryPoint: bool + +/// Represents a declaration in an implementation file, as seen by the F# language +#if COMPILER_PUBLIC_API +and FSharpImplementationFileDeclaration = +#else +and internal FSharpImplementationFileDeclaration = +#endif +/// Represents the declaration of a type + | Entity of FSharpEntity * FSharpImplementationFileDeclaration list + /// Represents the declaration of a member, function or value, including the parameters and body of the member + | MemberOrFunctionOrValue of FSharpMemberOrFunctionOrValue * FSharpMemberOrFunctionOrValue list list * FSharpExpr + /// Represents the declaration of a static initialization action + | InitAction of FSharpExpr + +/// Represents a checked and reduced expression, as seen by the F# language. The active patterns +/// in 'FSharp.Compiler.SourceCodeServices' can be used to analyze information about the expression. +/// +/// Pattern matching is reduced to decision trees and conditional tests. Some other +/// constructs may be represented in reduced form. +#if COMPILER_PUBLIC_API +and [] FSharpExpr = +#else +and [] internal FSharpExpr = +#endif + /// The range of the expression + member Range : range + + /// The type of the expression + member Type : FSharpType + + /// The immediate sub-expressions of the expression. + member ImmediateSubExpressions : FSharpExpr list + +/// Represents a checked method in an object expression, as seen by the F# language. +#if COMPILER_PUBLIC_API +and [] FSharpObjectExprOverride = +#else +and [] internal FSharpObjectExprOverride = +#endif + /// The signature of the implemented abstract slot + member Signature : FSharpAbstractSignature + + /// The generic parameters of the method + member GenericParameters : FSharpGenericParameter list + + /// The parameters of the method + member CurriedParameterGroups : FSharpMemberOrFunctionOrValue list list + + /// The expression that forms the body of the method + member Body : FSharpExpr + +/// A collection of active patterns to analyze expressions +#if COMPILER_PUBLIC_API +module BasicPatterns = +#else +module internal BasicPatterns = +#endif + + /// Matches expressions which are uses of values + val (|Value|_|) : FSharpExpr -> FSharpMemberOrFunctionOrValue option + + /// Matches expressions which are the application of function values + val (|Application|_|) : FSharpExpr -> (FSharpExpr * FSharpType list * FSharpExpr list) option + + /// Matches expressions which are type abstractions + val (|TypeLambda|_|) : FSharpExpr -> (FSharpGenericParameter list * FSharpExpr) option + + /// Matches expressions with a decision expression, each branch of which ends in DecisionTreeSuccess pasing control and values to one of the targets. + val (|DecisionTree|_|) : FSharpExpr -> (FSharpExpr * (FSharpMemberOrFunctionOrValue list * FSharpExpr) list) option + + /// Special expressions at the end of a conditional decision structure in the decision expression node of a DecisionTree . + /// The given expressions are passed as values to the decision tree target. + val (|DecisionTreeSuccess|_|) : FSharpExpr -> (int * FSharpExpr list) option + + /// Matches expressions which are lambda abstractions + val (|Lambda|_|) : FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) option + + /// Matches expressions which are conditionals + val (|IfThenElse|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr) option + + /// Matches expressions which are let definitions + val (|Let|_|) : FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr) * FSharpExpr) option + + /// Matches expressions which are calls to members or module-defined functions. When calling curried functions and members the + /// arguments are collapsed to a single collection of arguments, as done in the compiled version of these. + val (|Call|_|) : FSharpExpr -> (FSharpExpr option * FSharpMemberOrFunctionOrValue * FSharpType list * FSharpType list * FSharpExpr list) option + + /// Matches expressions which are calls to object constructors + val (|NewObject|_|) : FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpType list * FSharpExpr list) option + + /// Matches expressions which are uses of the 'this' value + val (|ThisValue|_|) : FSharpExpr -> FSharpType option + + /// Matches expressions which are uses of the 'base' value + val (|BaseValue|_|) : FSharpExpr -> FSharpType option + + /// Matches expressions which are quotation literals + val (|Quote|_|) : FSharpExpr -> FSharpExpr option + + /// Matches expressions which are let-rec definitions + val (|LetRec|_|) : FSharpExpr -> ((FSharpMemberOrFunctionOrValue * FSharpExpr) list * FSharpExpr) option + + /// Matches record expressions + val (|NewRecord|_|) : FSharpExpr -> (FSharpType * FSharpExpr list) option + + /// Matches expressions which get a field from a record or class + val (|FSharpFieldGet|_|) : FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField) option + + /// Matches expressions which set a field in a record or class + val (|FSharpFieldSet|_|) : FSharpExpr -> (FSharpExpr option * FSharpType * FSharpField * FSharpExpr) option + + /// Matches expressions which create an object corresponding to a union case + val (|NewUnionCase|_|) : FSharpExpr -> (FSharpType * FSharpUnionCase * FSharpExpr list) option + + /// Matches expressions which get a field from a union case + val (|UnionCaseGet|_|) : FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField) option + + /// Matches expressions which set a field from a union case (only used in FSharp.Core itself) + val (|UnionCaseSet|_|) : FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase * FSharpField * FSharpExpr) option + + /// Matches expressions which gets the tag for a union case + val (|UnionCaseTag|_|) : FSharpExpr -> (FSharpExpr * FSharpType) option + + /// Matches expressions which test if an expression corresponds to a particular union case + val (|UnionCaseTest|_|) : FSharpExpr -> (FSharpExpr * FSharpType * FSharpUnionCase) option + + /// Matches tuple expressions + val (|NewTuple|_|) : FSharpExpr -> (FSharpType * FSharpExpr list) option + + /// Matches expressions which get a value from a tuple + val (|TupleGet|_|) : FSharpExpr -> (FSharpType * int * FSharpExpr) option + + /// Matches expressions which coerce the type of a value + val (|Coerce|_|) : FSharpExpr -> (FSharpType * FSharpExpr) option + + /// Matches array expressions + val (|NewArray|_|) : FSharpExpr -> (FSharpType * FSharpExpr list) option + + /// Matches expressions which test the runtime type of a value + val (|TypeTest|_|) : FSharpExpr -> (FSharpType * FSharpExpr) option + + /// Matches expressions which set the contents of an address + val (|AddressSet|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr) option + + /// Matches expressions which set the contents of a mutable variable + val (|ValueSet|_|) : FSharpExpr -> (FSharpMemberOrFunctionOrValue * FSharpExpr) option + + /// Matches default-value expressions, including null expressions + val (|DefaultValue|_|) : FSharpExpr -> FSharpType option + + /// Matches constant expressions, including signed and unsigned integers, strings, characters, booleans, arrays + /// of bytes and arrays of unit16. + val (|Const|_|) : FSharpExpr -> (obj * FSharpType) option + + /// Matches expressions which take the address of a location + val (|AddressOf|_|) : FSharpExpr -> FSharpExpr option + + /// Matches sequential expressions + val (|Sequential|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr) option + + /// Matches fast-integer loops (up or down) + val (|FastIntegerForLoop|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr * FSharpExpr * bool) option + + /// Matches while loops + val (|WhileLoop|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr) option + + /// Matches try/finally expressions + val (|TryFinally|_|) : FSharpExpr -> (FSharpExpr * FSharpExpr) option + + /// Matches try/with expressions + val (|TryWith|_|) : FSharpExpr -> (FSharpExpr * FSharpMemberOrFunctionOrValue * FSharpExpr * FSharpMemberOrFunctionOrValue * FSharpExpr) option + + /// Matches expressions which create an instance of a delegate type + val (|NewDelegate|_|) : FSharpExpr -> (FSharpType * FSharpExpr) option + + /// Matches expressions which are IL assembly code + val (|ILAsm|_|) : FSharpExpr -> (string * FSharpType list * FSharpExpr list) option + + /// Matches expressions which fetch a field from a .NET type + val (|ILFieldGet|_|) : FSharpExpr -> (FSharpExpr option * FSharpType * string) option + + /// Matches expressions which set a field in a .NET type + val (|ILFieldSet|_|) : FSharpExpr -> (FSharpExpr option * FSharpType * string * FSharpExpr) option + + /// Matches object expressions, returning the base type, the base call, the overrides and the interface implementations + val (|ObjectExpr|_|) : FSharpExpr -> (FSharpType * FSharpExpr * FSharpObjectExprOverride list * (FSharpType * FSharpObjectExprOverride list) list) option + + /// Matches expressions for an unresolved call to a trait + val (|TraitCall|_|) : FSharpExpr -> (FSharpType list * string * Ast.MemberFlags * FSharpType list * FSharpType list * FSharpExpr list) option + diff --git a/src/fsharp/vs/ServiceDeclarations.fs b/src/fsharp/symbols/SymbolHelpers.fs similarity index 56% rename from src/fsharp/vs/ServiceDeclarations.fs rename to src/fsharp/symbols/SymbolHelpers.fs index 20188e72b6..d8f5e9c42c 100644 --- a/src/fsharp/vs/ServiceDeclarations.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -31,25 +31,182 @@ open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.Infos open Microsoft.FSharp.Compiler.NameResolution open Microsoft.FSharp.Compiler.InfoReader - -type Layout = layout +open Microsoft.FSharp.Compiler.ErrorLogger +open Microsoft.FSharp.Compiler.CompileOps module EnvMisc2 = let maxMembers = GetEnvInteger "FCS_MaxMembersInQuickInfo" 10 - /// dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. - /// This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. - let dataTipSpinWaitTime = GetEnvInteger "FCS_ToolTipSpinWaitTime" 300 +//---------------------------------------------------------------------------- +// Object model for diagnostics + +[] +type FSharpErrorSeverity = + | Warning + | Error + +type FSharpErrorInfo(fileName, s:pos, e:pos, severity: FSharpErrorSeverity, message: string, subcategory: string, errorNum: int) = + member __.StartLine = Line.toZ s.Line + member __.StartLineAlternate = s.Line + member __.EndLine = Line.toZ e.Line + member __.EndLineAlternate = e.Line + member __.StartColumn = s.Column + member __.EndColumn = e.Column + member __.Severity = severity + member __.Message = message + member __.Subcategory = subcategory + member __.FileName = fileName + member __.ErrorNumber = errorNum + member __.WithStart(newStart) = FSharpErrorInfo(fileName, newStart, e, severity, message, subcategory, errorNum) + member __.WithEnd(newEnd) = FSharpErrorInfo(fileName, s, newEnd, severity, message, subcategory, errorNum) + override __.ToString()= sprintf "%s (%d,%d)-(%d,%d) %s %s %s" fileName (int s.Line) (s.Column + 1) (int e.Line) (e.Column + 1) subcategory (if severity=FSharpErrorSeverity.Warning then "warning" else "error") message + + /// Decompose a warning or error into parts: position, severity, message, error number + static member CreateFromException(exn, isError, trim:bool, fallbackRange:range) = + let m = match GetRangeOfDiagnostic exn with Some m -> m | None -> fallbackRange + let e = if trim then m.Start else m.End + let msg = bufs (fun buf -> OutputPhasedDiagnostic buf exn false) + let errorNum = GetDiagnosticNumber exn + FSharpErrorInfo(m.FileName, m.Start, e, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning), msg, exn.Subcategory(), errorNum) + + /// Decompose a warning or error into parts: position, severity, message, error number + static member CreateFromExceptionAndAdjustEof(exn, isError, trim:bool, fallbackRange:range, (linesCount:int, lastLength:int)) = + let r = FSharpErrorInfo.CreateFromException(exn,isError,trim,fallbackRange) + + // Adjust to make sure that errors reported at Eof are shown at the linesCount + let startline, schange = min (r.StartLineAlternate, false) (linesCount, true) + let endline, echange = min (r.EndLineAlternate, false) (linesCount, true) + + if not (schange || echange) then r + else + let r = if schange then r.WithStart(mkPos startline lastLength) else r + if echange then r.WithEnd(mkPos endline (1 + lastLength)) else r + + +/// Use to reset error and warning handlers +[] +type ErrorScope() = + let mutable errors = [] + let mutable firstError = None + let unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.TypeCheck + let unwindEL = + PushErrorLoggerPhaseUntilUnwind (fun _oldLogger -> + { new ErrorLogger("ErrorScope") with + member x.DiagnosticSink(exn, isError) = + let err = FSharpErrorInfo.CreateFromException(exn,isError,false,range.Zero) + errors <- err :: errors + if isError && firstError.IsNone then + firstError <- Some err.Message + member x.ErrorCount = errors.Length }) + + member x.Errors = errors |> List.filter (fun error -> error.Severity = FSharpErrorSeverity.Error) + member x.Warnings = errors |> List.filter (fun error -> error.Severity = FSharpErrorSeverity.Warning) + member x.Diagnostics = errors + member x.TryGetFirstErrorText() = + match x.Errors with + | error :: _ -> Some error.Message + | [] -> None + + interface IDisposable with + member d.Dispose() = + unwindEL.Dispose() (* unwind pushes when ErrorScope disposes *) + unwindBP.Dispose() + + member x.FirstError with get() = firstError and set v = firstError <- v + + /// Used at entry points to FSharp.Compiler.Service (service.fsi) which manipulate symbols and + /// perform other operations which might expose us to either bona-fide F# error messages such + /// "missing assembly" (for incomplete assembly reference sets), or, if there is a compiler bug, + /// may hit internal compiler failures. + /// + /// In some calling cases, we get a chance to report the error as part of user text. For example + /// if there is a "msising assembly" error while formatting the text of the description of an + /// autocomplete, then the error message is shown in replacement of the text (rather than crashing Visual + /// Studio, or swallowing the exception completely) + static member Protect<'a> (m:range) (f:unit->'a) (err:string->'a): 'a = + use errorScope = new ErrorScope() + let res = + try + Some (f()) + with e -> + // Here we only call errorRecovery to save the error message for later use by TryGetFirstErrorText. + try + errorRecovery e m + with _ -> + // If error recovery fails, then we have an internal compiler error. In this case, we show the whole stack + // in the extra message, should the extra message be used. + errorScope.FirstError <- Some (e.ToString()) + None + match res with + | Some res -> res + | None -> + match errorScope.TryGetFirstErrorText() with + | Some text -> err text + | None -> err "" + +/// An error logger that capture errors, filtering them according to warning levels etc. +type internal CompilationErrorLogger (debugName:string, tcConfig:TcConfig) = + inherit ErrorLogger("CompilationErrorLogger("+debugName+")") + + let mutable errorCount = 0 + let diagnostics = new ResizeArray<_>() + + override x.DiagnosticSink(exn, isError) = + if isError || ReportWarningAsError (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn, tcConfig.specificWarnAsError, tcConfig.specificWarnAsWarn, tcConfig.globalWarnAsError) exn then + diagnostics.Add(exn, isError) + errorCount <- errorCount + 1 + else if ReportWarning (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn) exn then + diagnostics.Add(exn, isError) + + override x.ErrorCount = errorCount + + member x.GetErrors() = + [ for (e,isError) in diagnostics -> e, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning) ] + + +/// This represents the global state established as each task function runs as part of the build. +/// +/// Use to reset error and warning handlers. +type CompilationGlobalsScope(errorLogger:ErrorLogger, phase: BuildPhase) = + let unwindEL = PushErrorLoggerPhaseUntilUnwind(fun _ -> errorLogger) + let unwindBP = PushThreadBuildPhaseUntilUnwind phase + // Return the disposable object that cleans up + interface IDisposable with + member d.Dispose() = + unwindBP.Dispose() + unwindEL.Dispose() + +module ErrorHelpers = + let ReportError (tcConfig:TcConfig, allErrors, mainInputFileName, fileInfo, (exn, sev)) = + [ let isError = (sev = FSharpErrorSeverity.Error) || ReportWarningAsError (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn, tcConfig.specificWarnAsError, tcConfig.specificWarnAsWarn, tcConfig.globalWarnAsError) exn + if (isError || ReportWarning (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn) exn) then + let oneError trim exn = + [ // We use the first line of the file as a fallbackRange for reporting unexpected errors. + // Not ideal, but it's hard to see what else to do. + let fallbackRange = rangeN mainInputFileName 1 + let ei = FSharpErrorInfo.CreateFromExceptionAndAdjustEof (exn, isError, trim, fallbackRange, fileInfo) + if allErrors || (ei.FileName=mainInputFileName) || (ei.FileName=Microsoft.FSharp.Compiler.TcGlobals.DummyFileNameForRangesWithoutASpecificLocation) then + yield ei ] + + let mainError,relatedErrors = SplitRelatedDiagnostics exn + yield! oneError false mainError + for e in relatedErrors do + yield! oneError true e ] + + let CreateErrorInfos (tcConfig:TcConfig, allErrors, mainInputFileName, errors) = + let fileInfo = (Int32.MaxValue, Int32.MaxValue) + [| for (exn,isError) in errors do + yield! ReportError (tcConfig, allErrors, mainInputFileName, fileInfo, (exn, isError)) |] + //---------------------------------------------------------------------------- -// Display characteristics of typechecking items -//-------------------------------------------------------------------------- +// Object model for tooltips and helpers for their generation from items -/// Interface that defines methods for comparing objects using partial equality relation -type IPartialEqualityComparer<'T> = - inherit IEqualityComparer<'T> - /// Can the specified object be tested for equality? - abstract InEqualityRelation : 'T -> bool +#if COMPILER_PUBLIC_API +type Layout = Internal.Utilities.StructuredFormat.Layout +#else +type internal Layout = Internal.Utilities.StructuredFormat.Layout +#endif /// Describe a comment as either a block of text or a file+signature reference into an intellidoc file. [] @@ -58,45 +215,74 @@ type FSharpXmlDoc = | Text of string | XmlDocFileSignature of (*File and Signature*) string * string +/// A single data tip display element +[] +type FSharpToolTipElementData<'T> = + { MainDescription: 'T + XmlDoc: FSharpXmlDoc + /// typar insantiation text, to go after xml + TypeMapping: 'T list + Remarks: 'T option + ParamName : string option } + static member Create(layout:'T,xml,?typeMapping,?paramName,?remarks) = + { MainDescription=layout; XmlDoc=xml; TypeMapping=defaultArg typeMapping []; ParamName=paramName; Remarks=remarks } + /// A single data tip display element [] type FSharpToolTipElement<'T> = | None - /// A single type, method, etc with comment. - | Single of (* text *) 'T * FSharpXmlDoc - /// A single parameter, with the parameter name. - | SingleParameter of (* text *) 'T * FSharpXmlDoc * string - /// For example, a method overload group. - | Group of ((* text *) 'T * FSharpXmlDoc) list + + /// A single type, method, etc with comment. May represent a method overload group. + | Group of FSharpToolTipElementData<'T> list + /// An error occurred formatting this element | CompositionError of string + static member Single(layout,xml,?typeMapping,?paramName,?remarks) = + Group [ FSharpToolTipElementData<'T>.Create(layout,xml,?typeMapping=typeMapping,?paramName=paramName,?remarks=remarks) ] + /// A single data tip display element with where text is expressed as string +#if COMPILER_PUBLIC_API type FSharpToolTipElement = FSharpToolTipElement +#else +type internal FSharpToolTipElement = FSharpToolTipElement +#endif + /// A single data tip display element with where text is expressed as +#if COMPILER_PUBLIC_API type FSharpStructuredToolTipElement = FSharpToolTipElement +#else +type internal FSharpStructuredToolTipElement = FSharpToolTipElement +#endif /// Information for building a data tip box. -// -// Note: this type does not hold any handles to compiler data structure. type FSharpToolTipText<'T> = /// A list of data tip elements to display. | FSharpToolTipText of FSharpToolTipElement<'T> list -// specialization that stores data as strings +#if COMPILER_PUBLIC_API type FSharpToolTipText = FSharpToolTipText -// specialization that stores data as type FSharpStructuredToolTipText = FSharpToolTipText +#else +type internal FSharpToolTipText = FSharpToolTipText +type internal FSharpStructuredToolTipText = FSharpToolTipText +#endif module Tooltips = let ToFSharpToolTipElement tooltip = match tooltip with - | FSharpStructuredToolTipElement.None -> FSharpToolTipElement.None - | FSharpStructuredToolTipElement.Single(text, doc) -> FSharpToolTipElement.Single(showL text, doc) - | FSharpStructuredToolTipElement.SingleParameter(t, doc, name) -> FSharpToolTipElement.SingleParameter(showL t, doc, name) - | FSharpStructuredToolTipElement.Group(l) -> FSharpToolTipElement.Group(l |> List.map(fun (text, doc) -> showL text, doc)) - | FSharpStructuredToolTipElement.CompositionError(text) -> FSharpToolTipElement.CompositionError(text) + | FSharpStructuredToolTipElement.None -> + FSharpToolTipElement.None + | FSharpStructuredToolTipElement.Group(l) -> + FSharpToolTipElement.Group(l |> List.map(fun x -> + { MainDescription=showL x.MainDescription + XmlDoc=x.XmlDoc + TypeMapping=List.map showL x.TypeMapping + ParamName=x.ParamName + Remarks= Option.map showL x.Remarks })) + | FSharpStructuredToolTipElement.CompositionError(text) -> + FSharpToolTipElement.CompositionError(text) let ToFSharpToolTipText (FSharpStructuredToolTipText.FSharpToolTipText(text)) = FSharpToolTipText(List.map ToFSharpToolTipElement text) @@ -117,27 +303,28 @@ type UnresolvedSymbol = Namespace: string[] } type CompletionItem = - { Item: Item + { ItemWithInst: ItemWithInst Kind: CompletionItemKind IsOwnMember: bool MinorPriority: int Type: TyconRef option Unresolved: UnresolvedSymbol option } + member x.Item = x.ItemWithInst.Item + [] -module internal ItemDescriptionsImpl = +module internal SymbolHelpers = let isFunction g typ = let _,tau = tryDestForallTy g typ isFunTy g tau - let OutputFullName isDecl ppF fnF r = - // Only display full names in quick info, not declaration text - if not isDecl then + let OutputFullName isListItem ppF fnF r = + // Only display full names in quick info, not declaration lists or method lists + if not isListItem then match ppF r with | None -> emptyL - | Some _ -> - sepL (tagLineBreak "\n\n") ^^ wordL (tagText (FSComp.SR.typeInfoFullName())) ^^ RightL.colon ^^ (fnF r) + | Some _ -> wordL (tagText (FSComp.SR.typeInfoFullName())) ^^ RightL.colon ^^ (fnF r) else emptyL let rangeOfValRef preferFlag (vref:ValRef) = @@ -207,11 +394,12 @@ module internal ItemDescriptionsImpl = | Item.SetterArg (_,item) -> rangeOfItem g preferFlag item | Item.ArgName (id,_, _) -> Some id.idRange | Item.CustomOperation (_,_,implOpt) -> implOpt |> Option.bind (rangeOfMethInfo g preferFlag) + | Item.ImplicitOp (_, {contents = Some(TraitConstraintSln.FSMethSln(_, vref, _))}) -> Some vref.Range | Item.ImplicitOp _ -> None - | Item.NewDef id -> Some id.idRange | Item.UnqualifiedType tcrefs -> tcrefs |> List.tryPick (rangeOfEntityRef preferFlag >> Some) | Item.DelegateCtor typ | Item.FakeInterfaceCtor typ -> typ |> tryNiceEntityRefOfTy |> Option.map (rangeOfEntityRef preferFlag) + | Item.NewDef _ -> None // Provided type definitions do not have a useful F# CCU for the purposes of goto-definition. let computeCcuOfTyconRef (tcref:TyconRef) = @@ -331,7 +519,7 @@ module internal ItemDescriptionsImpl = let GetXmlDocSigOfScopedValRef g (tcref:TyconRef) (vref:ValRef) = let ccuFileName = libFileOfEntityRef tcref let v = vref.Deref - if v.XmlDocSig = "" then + if v.XmlDocSig = "" && v.HasTopValActualParent then v.XmlDocSig <- XmlDocSigOfVal g (buildAccessPath vref.TopValActualParent.CompilationPathOpt) v Some (ccuFileName, v.XmlDocSig) @@ -382,7 +570,7 @@ module internal ItemDescriptionsImpl = if not vref.IsLocalRef then let ccuFileName = vref.nlr.Ccu.FileName let v = vref.Deref - if v.XmlDocSig = "" then + if v.XmlDocSig = "" && v.HasTopValActualParent then v.XmlDocSig <- XmlDocSigOfVal g vref.TopValActualParent.CompiledRepresentationForNamedType.Name v Some (ccuFileName, v.XmlDocSig) else @@ -475,40 +663,31 @@ module internal ItemDescriptionsImpl = let GetXmlCommentForMethInfoItem infoReader m d (minfo: MethInfo) = GetXmlCommentForItemAux (if minfo.HasDirectXmlComment then Some minfo.XmlDoc else None) infoReader m d - /// Output a method info - let FormatOverloadsToList (infoReader:InfoReader) m denv d minfos : FSharpStructuredToolTipElement = - let layoutOne minfo = - let layout = NicePrint.layoutMethInfoFreeStyle infoReader.amap m denv minfo - //let text = bufs (fun os -> NicePrint.formatMethInfoToBufferFreeStyle infoReader.amap m denv os minfo) - let xml = GetXmlCommentForMethInfoItem infoReader m d minfo - layout,xml + let FormatTyparMapping denv (prettyTyparInst: TyparInst) = + [ for (tp,ty) in prettyTyparInst -> + wordL (tagTypeParameter ("'" + tp.DisplayName)) ^^ wordL (tagText (FSComp.SR.descriptionWordIs())) ^^ NicePrint.layoutType denv ty ] + /// Generate the structured tooltip for a method info + let FormatOverloadsToList (infoReader:InfoReader) m denv (item: ItemWithInst) minfos : FSharpStructuredToolTipElement = ToolTipFault |> Option.iter (fun msg -> let exn = Error((0,msg),range.Zero) let ph = PhasedDiagnostic.Create(exn, BuildPhase.TypeCheck) simulateError ph) + + let layouts = + [ for minfo in minfos -> + let prettyTyparInst, layout = NicePrint.prettyLayoutOfMethInfoFreeStyle infoReader.amap m denv item.TyparInst minfo + let xml = GetXmlCommentForMethInfoItem infoReader m item.Item minfo + let tpsL = FormatTyparMapping denv prettyTyparInst + FSharpToolTipElementData<_>.Create(layout, xml, tpsL) ] - FSharpStructuredToolTipElement.Group(minfos |> List.map layoutOne) + FSharpStructuredToolTipElement.Group(layouts) - let pubpath_of_vref (v:ValRef) = v.PublicPath - let pubpath_of_tcref (x:TyconRef) = x.PublicPath + let pubpathOfValRef (v:ValRef) = v.PublicPath + let pubpathOfTyconRef (x:TyconRef) = x.PublicPath - // Wrapper type for use by the 'partialDistinctBy' function - [] - type WrapType<'T> = Wrap of 'T - - // Like Seq.distinctBy but only filters out duplicates for some of the elements - let partialDistinctBy (per:IPartialEqualityComparer<_>) seq = - // Wrap a Wrap _ around all keys in case the key type is itself a type using null as a representation - let dict = Dictionary,obj>(per) - seq |> List.filter (fun v -> - let v = Wrap(v) - if (per.InEqualityRelation(v)) then - if dict.ContainsKey(v) then false else (dict.[v] <- null; true) - else true) - let (|ItemWhereTypIsPreferred|_|) item = match item with | Item.DelegateCtor ty @@ -525,23 +704,23 @@ module internal ItemDescriptionsImpl = { new IPartialEqualityComparer<_> with member x.InEqualityRelation item = match item with - | Wrap(Item.Types(_,[_])) -> true - | Wrap(Item.ILField(ILFieldInfo _)) -> true - | Wrap(Item.RecdField _) -> true - | Wrap(Item.SetterArg _) -> true - | Wrap(Item.TypeVar _) -> true - | Wrap(Item.CustomOperation _) -> true - | Wrap(Item.ModuleOrNamespaces(_ :: _)) -> true - | Wrap(Item.MethodGroup _) -> true - | Wrap(Item.Value _ | Item.CustomBuilder _) -> true - | Wrap(Item.ActivePatternCase _) -> true - | Wrap(Item.DelegateCtor _) -> true - | Wrap(Item.UnionCase _) -> true - | Wrap(Item.ExnCase _) -> true - | Wrap(Item.Event _) -> true - | Wrap(Item.Property _) -> true - | Wrap(Item.CtorGroup _) -> true - | Wrap(Item.UnqualifiedType _) -> true + | Item.Types(_,[_]) -> true + | Item.ILField(ILFieldInfo _) -> true + | Item.RecdField _ -> true + | Item.SetterArg _ -> true + | Item.TypeVar _ -> true + | Item.CustomOperation _ -> true + | Item.ModuleOrNamespaces(_ :: _) -> true + | Item.MethodGroup _ -> true + | Item.Value _ | Item.CustomBuilder _ -> true + | Item.ActivePatternCase _ -> true + | Item.DelegateCtor _ -> true + | Item.UnionCase _ -> true + | Item.ExnCase _ -> true + | Item.Event _ -> true + | Item.Property _ -> true + | Item.CtorGroup _ -> true + | Item.UnqualifiedType _ -> true | _ -> false member x.Equals(item1, item2) = @@ -551,44 +730,51 @@ module internal ItemDescriptionsImpl = let equalTypes(ty1, ty2) = if isAppTy g ty1 && isAppTy g ty2 then tyconRefEq g (tcrefOfAppTy g ty1) (tcrefOfAppTy g ty2) else typeEquiv g ty1 ty2 + + ItemsAreEffectivelyEqual g item1 item2 || + + // Much of this logic is already covered by 'ItemsAreEffectivelyEqual' match item1,item2 with - | Wrap(Item.DelegateCtor(ty1)), Wrap(Item.DelegateCtor(ty2)) -> equalTypes(ty1, ty2) - | Wrap(Item.Types(dn1,[ty1])), Wrap(Item.Types(dn2,[ty2])) -> + | Item.DelegateCtor(ty1), Item.DelegateCtor(ty2) -> equalTypes(ty1, ty2) + | Item.Types(dn1,[ty1]), Item.Types(dn2,[ty2]) -> // Bug 4403: We need to compare names as well, because 'int' and 'Int32' are physically the same type, but we want to show both dn1 = dn2 && equalTypes(ty1, ty2) // Prefer a type to a DefaultStructCtor, a DelegateCtor and a FakeInterfaceCtor - | Wrap(ItemWhereTypIsPreferred(ty1)), Wrap(ItemWhereTypIsPreferred(ty2)) -> equalTypes(ty1, ty2) + | ItemWhereTypIsPreferred(ty1), ItemWhereTypIsPreferred(ty2) -> equalTypes(ty1, ty2) - | Wrap(Item.ExnCase(tcref1)), Wrap(Item.ExnCase(tcref2)) -> tyconRefEq g tcref1 tcref2 - | Wrap(Item.ILField(ILFieldInfo(_, fld1))), Wrap(Item.ILField(ILFieldInfo(_, fld2))) -> + | Item.ExnCase(tcref1), Item.ExnCase(tcref2) -> tyconRefEq g tcref1 tcref2 + | Item.ILField(ILFieldInfo(_, fld1)), Item.ILField(ILFieldInfo(_, fld2)) -> fld1 === fld2 // reference equality on the object identity of the AbstractIL metadata blobs for the fields - | Wrap(Item.CustomOperation (_,_,Some minfo1)), Wrap(Item.CustomOperation (_,_,Some minfo2)) -> + | Item.CustomOperation (_,_,Some minfo1), Item.CustomOperation (_,_,Some minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2 - | Wrap(Item.TypeVar (nm1,tp1)), Wrap(Item.TypeVar (nm2,tp2)) -> + | Item.TypeVar (nm1,tp1), Item.TypeVar (nm2,tp2) -> (nm1 = nm2) && typarRefEq tp1 tp2 - | Wrap(Item.ModuleOrNamespaces(modref1 :: _)), Wrap(Item.ModuleOrNamespaces(modref2 :: _)) -> fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef modref2 - | Wrap(Item.SetterArg(id1,_)), Wrap(Item.SetterArg(id2,_)) -> (id1.idRange, id1.idText) = (id2.idRange, id2.idText) - | Wrap(Item.MethodGroup(_, meths1,_)), Wrap(Item.MethodGroup(_, meths2,_)) -> + | Item.ModuleOrNamespaces(modref1 :: _), Item.ModuleOrNamespaces(modref2 :: _) -> fullDisplayTextOfModRef modref1 = fullDisplayTextOfModRef modref2 + | Item.SetterArg(id1,_), Item.SetterArg(id2,_) -> (id1.idRange, id1.idText) = (id2.idRange, id2.idText) + | Item.MethodGroup(_, meths1,_), Item.MethodGroup(_, meths2,_) -> Seq.zip meths1 meths2 |> Seq.forall (fun (minfo1, minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2) - | Wrap(Item.Value vref1 | Item.CustomBuilder (_,vref1)), Wrap(Item.Value vref2 | Item.CustomBuilder (_,vref2)) -> valRefEq g vref1 vref2 - | Wrap(Item.ActivePatternCase(APElemRef(_apinfo1, vref1, idx1))), Wrap(Item.ActivePatternCase(APElemRef(_apinfo2, vref2, idx2))) -> + | (Item.Value vref1 | Item.CustomBuilder (_,vref1)), (Item.Value vref2 | Item.CustomBuilder (_,vref2)) -> + valRefEq g vref1 vref2 + | Item.ActivePatternCase(APElemRef(_apinfo1, vref1, idx1)), Item.ActivePatternCase(APElemRef(_apinfo2, vref2, idx2)) -> idx1 = idx2 && valRefEq g vref1 vref2 - | Wrap(Item.UnionCase(UnionCaseInfo(_, ur1),_)), Wrap(Item.UnionCase(UnionCaseInfo(_, ur2),_)) -> g.unionCaseRefEq ur1 ur2 - | Wrap(Item.RecdField(RecdFieldInfo(_, RFRef(tcref1, n1)))), Wrap(Item.RecdField(RecdFieldInfo(_, RFRef(tcref2, n2)))) -> + | Item.UnionCase(UnionCaseInfo(_, ur1),_), Item.UnionCase(UnionCaseInfo(_, ur2),_) -> + g.unionCaseRefEq ur1 ur2 + | Item.RecdField(RecdFieldInfo(_, RFRef(tcref1, n1))), Item.RecdField(RecdFieldInfo(_, RFRef(tcref2, n2))) -> (tyconRefEq g tcref1 tcref2) && (n1 = n2) // there is no direct function as in the previous case - | Wrap(Item.Property(_, pi1s)), Wrap(Item.Property(_, pi2s)) -> + | Item.Property(_, pi1s), Item.Property(_, pi2s) -> List.zip pi1s pi2s |> List.forall(fun (pi1, pi2) -> PropInfo.PropInfosUseIdenticalDefinitions pi1 pi2) - | Wrap(Item.Event(evt1)), Wrap(Item.Event(evt2)) -> EventInfo.EventInfosUseIdenticalDefintions evt1 evt2 - | Wrap(Item.CtorGroup(_, meths1)), Wrap(Item.CtorGroup(_, meths2)) -> + | Item.Event(evt1), Item.Event(evt2) -> + EventInfo.EventInfosUseIdenticalDefintions evt1 evt2 + | Item.CtorGroup(_, meths1), Item.CtorGroup(_, meths2) -> List.zip meths1 meths2 |> List.forall (fun (minfo1, minfo2) -> MethInfo.MethInfosUseIdenticalDefinitions minfo1 minfo2) - | Wrap(Item.UnqualifiedType(tcRefs1)), Wrap(Item.UnqualifiedType(tcRefs2)) -> + | Item.UnqualifiedType(tcRefs1), Item.UnqualifiedType(tcRefs2) -> List.zip tcRefs1 tcRefs2 |> List.forall (fun (tcRef1, tcRef2) -> tyconRefEq g tcRef1 tcRef2) - | Wrap(Item.Types(_,[TType.TType_app(tcRef1,_)])), Wrap(Item.UnqualifiedType([tcRef2])) -> tyconRefEq g tcRef1 tcRef2 - | Wrap(Item.UnqualifiedType([tcRef1])), Wrap(Item.Types(_,[TType.TType_app(tcRef2,_)])) -> tyconRefEq g tcRef1 tcRef2 + | Item.Types(_,[TType.TType_app(tcRef1,_)]), Item.UnqualifiedType([tcRef2]) -> tyconRefEq g tcRef1 tcRef2 + | Item.UnqualifiedType([tcRef1]), Item.Types(_,[TType.TType_app(tcRef2,_)]) -> tyconRefEq g tcRef1 tcRef2 | _ -> false) member x.GetHashCode item = @@ -596,63 +782,59 @@ module internal ItemDescriptionsImpl = // In this case just bail out and use a random hash code protectAssemblyExploration 1027 (fun () -> match item with - | Wrap(ItemWhereTypIsPreferred ty) -> + | ItemWhereTypIsPreferred ty -> if isAppTy g ty then hash (tcrefOfAppTy g ty).Stamp else 1010 - | Wrap(Item.ILField(ILFieldInfo(_, fld))) -> + | Item.ILField(ILFieldInfo(_, fld)) -> System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode fld // hash on the object identity of the AbstractIL metadata blob for the field - | Wrap(Item.TypeVar (nm,_tp)) -> hash nm - | Wrap(Item.CustomOperation (_,_,Some minfo)) -> minfo.ComputeHashCode() - | Wrap(Item.CustomOperation (_,_,None)) -> 1 - | Wrap(Item.ModuleOrNamespaces(modref :: _)) -> hash (fullDisplayTextOfModRef modref) - | Wrap(Item.SetterArg(id,_)) -> hash (id.idRange, id.idText) - | Wrap(Item.MethodGroup(_, meths,_)) -> meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0 - | Wrap(Item.CtorGroup(name, meths)) -> name.GetHashCode() + (meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0) - | Wrap(Item.Value vref | Item.CustomBuilder (_,vref)) -> hash vref.LogicalName - | Wrap(Item.ActivePatternCase(APElemRef(_apinfo, vref, idx))) -> hash (vref.LogicalName, idx) - | Wrap(Item.ExnCase(tcref)) -> hash tcref.Stamp - | Wrap(Item.UnionCase(UnionCaseInfo(_, UCRef(tcref, n)),_)) -> hash(tcref.Stamp, n) - | Wrap(Item.RecdField(RecdFieldInfo(_, RFRef(tcref, n)))) -> hash(tcref.Stamp, n) - | Wrap(Item.Event evt) -> evt.ComputeHashCode() - | Wrap(Item.Property(_name, pis)) -> hash (pis |> List.map (fun pi -> pi.ComputeHashCode())) - | Wrap(Item.UnqualifiedType(tcRef :: _)) -> hash tcRef.Stamp + | Item.TypeVar (nm,_tp) -> hash nm + | Item.CustomOperation (_,_,Some minfo) -> minfo.ComputeHashCode() + | Item.CustomOperation (_,_,None) -> 1 + | Item.ModuleOrNamespaces(modref :: _) -> hash (fullDisplayTextOfModRef modref) + | Item.SetterArg(id,_) -> hash (id.idRange, id.idText) + | Item.MethodGroup(_, meths,_) -> meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0 + | Item.CtorGroup(name, meths) -> name.GetHashCode() + (meths |> List.fold (fun st a -> st + a.ComputeHashCode()) 0) + | (Item.Value vref | Item.CustomBuilder (_,vref)) -> hash vref.LogicalName + | Item.ActivePatternCase(APElemRef(_apinfo, vref, idx)) -> hash (vref.LogicalName, idx) + | Item.ExnCase(tcref) -> hash tcref.Stamp + | Item.UnionCase(UnionCaseInfo(_, UCRef(tcref, n)),_) -> hash(tcref.Stamp, n) + | Item.RecdField(RecdFieldInfo(_, RFRef(tcref, n))) -> hash(tcref.Stamp, n) + | Item.Event evt -> evt.ComputeHashCode() + | Item.Property(_name, pis) -> hash (pis |> List.map (fun pi -> pi.ComputeHashCode())) + | Item.UnqualifiedType(tcref :: _) -> hash tcref.Stamp | _ -> failwith "unreachable") } let CompletionItemDisplayPartialEquality g = let itemComparer = ItemDisplayPartialEquality g - { new IPartialEqualityComparer> with - member x.InEqualityRelation (Wrap item) = itemComparer.InEqualityRelation (Wrap item.Item) - member x.Equals(Wrap item1, Wrap item2) = itemComparer.Equals(Wrap item1.Item, Wrap item2.Item) - member x.GetHashCode (Wrap item) = itemComparer.GetHashCode(Wrap item.Item) } + { new IPartialEqualityComparer with + member x.InEqualityRelation item = itemComparer.InEqualityRelation item.Item + member x.Equals(item1, item2) = itemComparer.Equals(item1.Item, item2.Item) + member x.GetHashCode (item) = itemComparer.GetHashCode(item.Item) } let ItemWithTypeDisplayPartialEquality g = let itemComparer = ItemDisplayPartialEquality g - { new IPartialEqualityComparer> with - member x.InEqualityRelation (Wrap (item, _)) = itemComparer.InEqualityRelation (Wrap item) - member x.Equals(Wrap (item1, _), Wrap (item2, _)) = itemComparer.Equals(Wrap item1, Wrap item2) - member x.GetHashCode (Wrap (item, _)) = itemComparer.GetHashCode(Wrap item) } + { new IPartialEqualityComparer with + member x.InEqualityRelation ((item, _)) = itemComparer.InEqualityRelation item + member x.Equals((item1, _), (item2, _)) = itemComparer.Equals(item1, item2) + member x.GetHashCode ((item, _)) = itemComparer.GetHashCode(item) } // Remove items containing the same module references let RemoveDuplicateModuleRefs modrefs = - modrefs |> partialDistinctBy - { new IPartialEqualityComparer> with + modrefs |> IPartialEqualityComparer.partialDistinctBy + { new IPartialEqualityComparer with member x.InEqualityRelation _ = true - member x.Equals(Wrap(item1), Wrap(item2)) = (fullDisplayTextOfModRef item1 = fullDisplayTextOfModRef item2) - member x.GetHashCode(Wrap(item)) = hash item.Stamp } + member x.Equals(item1, item2) = (fullDisplayTextOfModRef item1 = fullDisplayTextOfModRef item2) + member x.GetHashCode(item) = hash item.Stamp } /// Remove all duplicate items - let RemoveDuplicateItems g items = - items |> partialDistinctBy (ItemDisplayPartialEquality g) - - /// Remove all duplicate items - let RemoveDuplicateItemsWithType g (items: (Item * TType option) list) = - items |> partialDistinctBy (ItemWithTypeDisplayPartialEquality g) + let RemoveDuplicateItems g (items: ItemWithInst list) = + items |> IPartialEqualityComparer.partialDistinctBy (IPartialEqualityComparer.On (fun item -> item.Item) (ItemDisplayPartialEquality g)) /// Remove all duplicate items let RemoveDuplicateCompletionItems g items = - items |> partialDistinctBy (CompletionItemDisplayPartialEquality g) + items |> IPartialEqualityComparer.partialDistinctBy (CompletionItemDisplayPartialEquality g) let IsExplicitlySuppressed (g: TcGlobals) (item: Item) = // This may explore assemblies that are not in the reference set. @@ -673,18 +855,14 @@ module internal ItemDescriptionsImpl = | _ -> false) /// Filter types that are explicitly suppressed from the IntelliSense (such as uppercase "FSharpList", "Option", etc.) - let RemoveExplicitlySuppressed (g: TcGlobals) (items: Item list) = - items |> List.filter (fun item -> not (IsExplicitlySuppressed g item)) + let RemoveExplicitlySuppressed (g: TcGlobals) (items: ItemWithInst list) = + items |> List.filter (fun item -> not (IsExplicitlySuppressed g item.Item)) /// Filter types that are explicitly suppressed from the IntelliSense (such as uppercase "FSharpList", "Option", etc.) let RemoveExplicitlySuppressedCompletionItems (g: TcGlobals) (items: CompletionItem list) = items |> List.filter (fun item -> not (IsExplicitlySuppressed g item.Item)) - /// Filter types that are explicitly suppressed from the IntelliSense (such as uppercase "FSharpList", "Option", etc.) - let RemoveExplicitlySuppressedItemsWithType (g: TcGlobals) (items: (Item * TType option) list) = - items |> List.filter (fun (item, _) -> not (IsExplicitlySuppressed g item)) - - let SimplerDisplayEnv denv _isDecl = + let SimplerDisplayEnv denv = { denv with suppressInlineKeyword=true; shortConstraints=true; showConstraintTyparAnnotations=false; @@ -733,48 +911,48 @@ module internal ItemDescriptionsImpl = | Item.Property(_,[]) -> "" /// Output a the description of a language item - let rec GetXmlCommentForItem (infoReader:InfoReader) m d = + let rec GetXmlCommentForItem (infoReader:InfoReader) m item = let g = infoReader.g - match d with + match item with | Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(_, vref, _)) }) -> GetXmlCommentForItem infoReader m (Item.Value vref) | Item.Value vref | Item.CustomBuilder (_,vref) -> - GetXmlCommentForItemAux (if valRefInThisAssembly g.compilingFslib vref then Some vref.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if valRefInThisAssembly g.compilingFslib vref then Some vref.XmlDoc else None) infoReader m item | Item.UnionCase(ucinfo,_) -> - GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib ucinfo.TyconRef then Some ucinfo.UnionCase .XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib ucinfo.TyconRef then Some ucinfo.UnionCase .XmlDoc else None) infoReader m item | Item.ActivePatternCase apref -> - GetXmlCommentForItemAux (Some apref.ActivePatternVal.XmlDoc) infoReader m d + GetXmlCommentForItemAux (Some apref.ActivePatternVal.XmlDoc) infoReader m item | Item.ExnCase ecref -> - GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib ecref then Some ecref.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib ecref then Some ecref.XmlDoc else None) infoReader m item | Item.RecdField rfinfo -> - GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib rfinfo.TyconRef then Some rfinfo.RecdField.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib rfinfo.TyconRef then Some rfinfo.RecdField.XmlDoc else None) infoReader m item | Item.Event einfo -> - GetXmlCommentForItemAux (if einfo.HasDirectXmlComment then Some einfo.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if einfo.HasDirectXmlComment then Some einfo.XmlDoc else None) infoReader m item | Item.Property(_,pinfos) -> let pinfo = pinfos.Head - GetXmlCommentForItemAux (if pinfo.HasDirectXmlComment then Some pinfo.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if pinfo.HasDirectXmlComment then Some pinfo.XmlDoc else None) infoReader m item | Item.CustomOperation (_,_,Some minfo) | Item.CtorGroup(_,minfo :: _) | Item.MethodGroup(_,minfo :: _,_) -> - GetXmlCommentForMethInfoItem infoReader m d minfo + GetXmlCommentForMethInfoItem infoReader m item minfo | Item.Types(_,((TType_app(tcref,_)):: _)) -> - GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib tcref then Some tcref.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if tyconRefUsesLocalXmlDoc g.compilingFslib tcref then Some tcref.XmlDoc else None) infoReader m item | Item.ModuleOrNamespaces((modref :: _) as modrefs) -> let definiteNamespace = modrefs |> List.forall (fun modref -> modref.IsNamespace) if not definiteNamespace then - GetXmlCommentForItemAux (if entityRefInThisAssembly g.compilingFslib modref then Some modref.XmlDoc else None) infoReader m d + GetXmlCommentForItemAux (if entityRefInThisAssembly g.compilingFslib modref then Some modref.XmlDoc else None) infoReader m item else - GetXmlCommentForItemAux None infoReader m d + GetXmlCommentForItemAux None infoReader m item | Item.ArgName (_, _, argContainer) -> let xmldoc = @@ -786,7 +964,7 @@ module internal ItemDescriptionsImpl = | Some(ArgumentContainer.UnionCase(ucinfo)) -> if (tyconRefUsesLocalXmlDoc g.compilingFslib ucinfo.TyconRef) then Some ucinfo.UnionCase.XmlDoc else None | _ -> None - GetXmlCommentForItemAux xmldoc infoReader m d + GetXmlCommentForItemAux xmldoc infoReader m item | Item.SetterArg (_, item) -> GetXmlCommentForItem infoReader m item @@ -798,35 +976,35 @@ module internal ItemDescriptionsImpl = | Item.FakeInterfaceCtor _ | Item.DelegateCtor _ | _ -> - GetXmlCommentForItemAux None infoReader m d + GetXmlCommentForItemAux None infoReader m item - let IsAttribute (infoReader: InfoReader) d = + let IsAttribute (infoReader: InfoReader) item = try let g = infoReader.g let amap = infoReader.amap - match d with + match item with | Item.Types(_,((TType_app(tcref,_)):: _)) -> let ty = generalizedTyconRef tcref Infos.ExistsHeadTypeInEntireHierarchy g amap range0 ty g.tcref_System_Attribute | _ -> false with _ -> false - /// Output the description of a language item - let rec FormatItemDescriptionToToolTipElement isDecl (infoReader:InfoReader) m denv d = + /// Output the quick info information of a language item + let rec FormatItemDescriptionToToolTipElement isListItem (infoReader:InfoReader) m denv (item: ItemWithInst) = let g = infoReader.g let amap = infoReader.amap - let denv = SimplerDisplayEnv denv isDecl - let xml = GetXmlCommentForItem infoReader m d - match d with + let denv = SimplerDisplayEnv denv + let xml = GetXmlCommentForItem infoReader m item.Item + match item.Item with | Item.ImplicitOp(_, { contents = Some(TraitConstraintSln.FSMethSln(_, vref, _)) }) -> // operator with solution - FormatItemDescriptionToToolTipElement isDecl infoReader m denv (Item.Value vref) - | Item.Value vref | Item.CustomBuilder (_,vref) -> - let layout = - NicePrint.layoutQualifiedValOrMember denv vref.Deref ^^ - OutputFullName isDecl pubpath_of_vref fullDisplayTextOfValRefAsLayout vref + FormatItemDescriptionToToolTipElement isListItem infoReader m denv { item with Item = Item.Value vref } - FSharpStructuredToolTipElement.Single(layout, xml) + | Item.Value vref | Item.CustomBuilder (_,vref) -> + let prettyTyparInst, resL = NicePrint.layoutQualifiedValOrMember denv item.TyparInst vref.Deref + let remarks = OutputFullName isListItem pubpathOfValRef fullDisplayTextOfValRefAsLayout vref + let tpsL = FormatTyparMapping denv prettyTyparInst + FSharpStructuredToolTipElement.Single(resL, xml, tpsL, remarks=remarks) // Union tags (constructors) | Item.UnionCase(ucinfo,_) -> @@ -840,8 +1018,8 @@ module internal ItemDescriptionsImpl = wordL (tagUnionCase (DecompileOpName uc.Id.idText) |> mkNav uc.DefinitionRange) ^^ RightL.colon ^^ (if List.isEmpty recd then emptyL else NicePrint.layoutUnionCases denv recd ^^ WordL.arrow) ^^ - NicePrint.layoutTy denv rty - FSharpStructuredToolTipElement.Single(layout, xml) + NicePrint.layoutType denv rty + FSharpStructuredToolTipElement.Single (layout, xml) // Active pattern tag inside the declaration (result) | Item.ActivePatternResult(apinfo, ty, idx, _) -> @@ -850,54 +1028,56 @@ module internal ItemDescriptionsImpl = wordL (tagText ((FSComp.SR.typeInfoActivePatternResult()))) ^^ wordL (tagActivePatternResult (List.item idx items) |> mkNav apinfo.Range) ^^ RightL.colon ^^ - NicePrint.layoutTy denv ty - FSharpStructuredToolTipElement.Single(layout, xml) + NicePrint.layoutType denv ty + FSharpStructuredToolTipElement.Single (layout, xml) // Active pattern tags | Item.ActivePatternCase apref -> let v = apref.ActivePatternVal // Format the type parameters to get e.g. ('a -> 'a) rather than ('?1234 -> '?1234) - let _,tau = v.TypeScheme + let tau = v.TauType // REVIEW: use _cxs here - let _, ptau, _cxs = PrettyTypes.PrettifyTypes1 denv.g tau + let (prettyTyparInst,ptau), _cxs = PrettyTypes.PrettifyInstAndType denv.g (item.TyparInst, tau) + let remarks = OutputFullName isListItem pubpathOfValRef fullDisplayTextOfValRefAsLayout v let layout = wordL (tagText (FSComp.SR.typeInfoActiveRecognizer())) ^^ wordL (tagActivePatternCase apref.Name |> mkNav v.DefinitionRange) ^^ RightL.colon ^^ - NicePrint.layoutTy denv ptau ^^ - OutputFullName isDecl pubpath_of_vref fullDisplayTextOfValRefAsLayout v - FSharpStructuredToolTipElement.Single(layout, xml) + NicePrint.layoutType denv ptau + + let tpsL = FormatTyparMapping denv prettyTyparInst + + FSharpStructuredToolTipElement.Single (layout, xml, tpsL, remarks=remarks) // F# exception names | Item.ExnCase ecref -> - let layout = - NicePrint.layoutExnDef denv ecref.Deref ^^ - OutputFullName isDecl pubpath_of_tcref fullDisplayTextOfExnRefAsLayout ecref - FSharpStructuredToolTipElement.Single(layout, xml) + let layout = NicePrint.layoutExnDef denv ecref.Deref + let remarks= OutputFullName isListItem pubpathOfTyconRef fullDisplayTextOfExnRefAsLayout ecref + FSharpStructuredToolTipElement.Single (layout, xml, remarks=remarks) // F# record field names | Item.RecdField rfinfo -> let rfield = rfinfo.RecdField - let _, ty, _cxs = PrettyTypes.PrettifyTypes1 g rfinfo.FieldType + let ty, _cxs = PrettyTypes.PrettifyType g rfinfo.FieldType let layout = NicePrint.layoutTyconRef denv rfinfo.TyconRef ^^ SepL.dot ^^ wordL (tagRecordField (DecompileOpName rfield.Name) |> mkNav rfield.DefinitionRange) ^^ RightL.colon ^^ - NicePrint.layoutTy denv ty ^^ + NicePrint.layoutType denv ty ^^ ( match rfinfo.LiteralValue with | None -> emptyL | Some lit -> try WordL.equals ^^ NicePrint.layoutConst denv.g ty lit with _ -> emptyL ) - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) // Not used | Item.NewDef id -> let layout = wordL (tagText (FSComp.SR.typeInfoPatternVariable())) ^^ wordL (tagUnknownEntity id.idText) - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) // .NET fields | Item.ILField finfo -> @@ -906,6 +1086,8 @@ module internal ItemDescriptionsImpl = NicePrint.layoutILTypeRef denv finfo.ILTypeRef ^^ SepL.dot ^^ wordL (tagField finfo.FieldName) ^^ + RightL.colon ^^ + NicePrint.layoutType denv (finfo.FieldType(amap, m)) ^^ ( match finfo.LiteralValue with | None -> emptyL @@ -913,25 +1095,25 @@ module internal ItemDescriptionsImpl = WordL.equals ^^ try NicePrint.layoutConst denv.g (finfo.FieldType(infoReader.amap, m)) (TypeChecker.TcFieldInit m v) with _ -> emptyL ) - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) // .NET events | Item.Event einfo -> let rty = PropTypOfEventInfo infoReader m AccessibleFromSomewhere einfo - let _,rty, _cxs = PrettyTypes.PrettifyTypes1 g rty + let rty, _cxs = PrettyTypes.PrettifyType g rty let layout = wordL (tagText (FSComp.SR.typeInfoEvent())) ^^ NicePrint.layoutTyconRef denv (tcrefOfAppTy g einfo.EnclosingType) ^^ SepL.dot ^^ wordL (tagEvent einfo.EventName) ^^ RightL.colon ^^ - NicePrint.layoutTy denv rty - FSharpStructuredToolTipElement.Single(layout, xml) + NicePrint.layoutType denv rty + FSharpStructuredToolTipElement.Single (layout, xml) // F# and .NET properties | Item.Property(_, pinfo :: _) -> - let layout = NicePrint.layoutPropInfoToFreeStyle g amap m denv pinfo - FSharpStructuredToolTipElement.Single(layout, xml) + let layout = NicePrint.prettyLayoutOfPropInfoFreeStyle g amap m denv pinfo + FSharpStructuredToolTipElement.Single (layout, xml) // Custom operations in queries | Item.CustomOperation (customOpName,usageText,Some minfo) -> @@ -947,8 +1129,8 @@ module internal ItemDescriptionsImpl = | Some t -> wordL (tagText t) | None -> let argTys = ParamNameAndTypesOfUnaryCustomOperation g minfo |> List.map (fun (ParamNameAndType(_,ty)) -> ty) - let _, argTys, _ = PrettyTypes.PrettifyTypesN g argTys - wordL (tagMethod customOpName) ^^ sepListL SepL.space (List.map (fun ty -> LeftL.leftParen ^^ NicePrint.layoutTy denv ty ^^ SepL.rightParen) argTys) + let argTys, _ = PrettyTypes.PrettifyTypes g argTys + wordL (tagMethod customOpName) ^^ sepListL SepL.space (List.map (fun ty -> LeftL.leftParen ^^ NicePrint.layoutType denv ty ^^ SepL.rightParen) argTys) ) ^^ SepL.lineBreak ^^ SepL.lineBreak ^^ wordL (tagText (FSComp.SR.typeInfoCallsWord())) ^^ @@ -956,12 +1138,12 @@ module internal ItemDescriptionsImpl = SepL.dot ^^ wordL (tagMethod minfo.DisplayName) - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) // F# constructors and methods | Item.CtorGroup(_,minfos) | Item.MethodGroup(_,minfos,_) -> - FormatOverloadsToList infoReader m denv d minfos + FormatOverloadsToList infoReader m denv item minfos // The 'fake' zero-argument constructors of .NET interfaces. // This ideally should never appear in intellisense, but we do get here in repros like: @@ -969,18 +1151,18 @@ module internal ItemDescriptionsImpl = // type II = IFoo // remove 'type II = ' and quickly hover over IFoo before it gets squiggled for 'invalid use of interface type' // and in that case we'll just show the interface type name. | Item.FakeInterfaceCtor typ -> - let _, typ, _ = PrettyTypes.PrettifyTypes1 g typ + let typ, _ = PrettyTypes.PrettifyType g typ let layout = NicePrint.layoutTyconRef denv (tcrefOfAppTy g typ) FSharpStructuredToolTipElement.Single(layout, xml) // The 'fake' representation of constructors of .NET delegate types | Item.DelegateCtor delty -> - let _, delty, _cxs = PrettyTypes.PrettifyTypes1 g delty + let delty, _cxs = PrettyTypes.PrettifyType g delty let (SigOfFunctionForDelegate(_, _, _, fty)) = GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomewhere let layout = NicePrint.layoutTyconRef denv (tcrefOfAppTy g delty) ^^ LeftL.leftParen ^^ - NicePrint.layoutTy denv fty ^^ + NicePrint.layoutType denv fty ^^ RightL.rightParen FSharpStructuredToolTipElement.Single(layout, xml) @@ -988,10 +1170,9 @@ module internal ItemDescriptionsImpl = | Item.Types(_,((TType_app(tcref,_)):: _)) | Item.UnqualifiedType (tcref :: _) -> let denv = { denv with shortTypeNames = true } - let layout = - NicePrint.layoutTycon denv infoReader AccessibleFromSomewhere m (* width *) tcref.Deref ^^ - OutputFullName isDecl pubpath_of_tcref fullDisplayTextOfTyconRefAsLayout tcref - FSharpStructuredToolTipElement.Single(layout, xml) + let layout = NicePrint.layoutTycon denv infoReader AccessibleFromSomewhere m (* width *) tcref.Deref + let remarks = OutputFullName isListItem pubpathOfTyconRef fullDisplayTextOfTyconRefAsLayout tcref + FSharpStructuredToolTipElement.Single (layout, xml, remarks=remarks) // F# Modules and namespaces | Item.ModuleOrNamespaces((modref :: _) as modrefs) -> @@ -1030,102 +1211,85 @@ module internal ItemDescriptionsImpl = else emptyL ) - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) else - FSharpStructuredToolTipElement.Single(layout, xml) + FSharpStructuredToolTipElement.Single (layout, xml) // Named parameters | Item.ArgName (id, argTy, _) -> - let _, argTy, _ = PrettyTypes.PrettifyTypes1 g argTy + let argTy, _ = PrettyTypes.PrettifyType g argTy let layout = wordL (tagText (FSComp.SR.typeInfoArgument())) ^^ wordL (tagParameter id.idText) ^^ RightL.colon ^^ - NicePrint.layoutTy denv argTy - FSharpStructuredToolTipElement.SingleParameter(layout, xml, id.idText) + NicePrint.layoutType denv argTy + FSharpStructuredToolTipElement.Single (layout, xml, paramName = id.idText) | Item.SetterArg (_, item) -> - FormatItemDescriptionToToolTipElement isDecl infoReader m denv item + FormatItemDescriptionToToolTipElement isListItem infoReader m denv (ItemWithNoInst item) | _ -> FSharpStructuredToolTipElement.None +#if EXTENSIONTYPING - // Format the return type of an item - let rec FormatItemReturnTypeAsLayout (infoReader:InfoReader) m denv d = - let isDecl = false - let g = infoReader.g - let amap = infoReader.amap - let denv = {SimplerDisplayEnv denv isDecl with useColonForReturnType=true} - match d with - | Item.Value vref | Item.CustomBuilder (_,vref) -> - let _, tau = vref.TypeScheme - (* Note: prettify BEFORE we strip to make sure params look the same as types *) - if isFunTy g tau then - let dtau,rtau = destFunTy g tau - let ptausL,tpcsL = NicePrint.layoutPrettifiedTypes denv [dtau;rtau] - let _,prtauL = List.frontAndBack ptausL - RightL.colon ^^ prtauL ^^ SepL.space ^^ tpcsL - else - NicePrint.layoutPrettifiedTypeAndConstraints denv [] tau - | Item.UnionCase(ucinfo,_) -> - let rty = generalizedTyconRef ucinfo.TyconRef - NicePrint.layoutTy denv rty - | Item.ActivePatternCase(apref) -> - let v = apref.ActivePatternVal - let _, tau = v.TypeScheme - let _, res = stripFunTy g tau - let apinfo = Option.get (TryGetActivePatternInfo v) - let apnames = apinfo.Names - let aparity = apnames.Length - - let rty = if aparity <= 1 then res else List.item apref.CaseIndex (argsOfAppTy g res) - NicePrint.layoutTy denv rty - | Item.ExnCase _ -> - NicePrint.layoutPrettifiedTypeAndConstraints denv [] g.exn_ty - | Item.RecdField(rfinfo) -> - NicePrint.layoutPrettifiedTypeAndConstraints denv [] rfinfo.FieldType - | Item.ILField(finfo) -> - NicePrint.layoutPrettifiedTypeAndConstraints denv [] (finfo.FieldType(amap,m)) - | Item.Event(einfo) -> - NicePrint.layoutPrettifiedTypeAndConstraints denv [] (PropTypOfEventInfo infoReader m AccessibleFromSomewhere einfo) - | Item.Property(_,pinfos) -> - let pinfo = List.head pinfos - let rty = pinfo.GetPropertyType(amap,m) - NicePrint.layoutPrettifiedTypeAndConstraints denv [] rty - | Item.CustomOperation (_,_,Some minfo) - | Item.MethodGroup(_,(minfo :: _),_) - | Item.CtorGroup(_,(minfo :: _)) -> - let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) - NicePrint.layoutPrettifiedTypeAndConstraints denv [] rty - | Item.FakeInterfaceCtor typ - | Item.DelegateCtor typ -> - NicePrint.layoutPrettifiedTypeAndConstraints denv [] typ - | Item.TypeVar _ -> emptyL - - | _ -> emptyL - - let rec GetF1Keyword d : string option = - let rec unwindTypeAbbrev (tcref : TyconRef) = - match tcref.TypeAbbrev with - | None -> Some tcref - | Some typ -> - match typ with - | TType_app(tcref, _) -> unwindTypeAbbrev tcref - | _ -> None - - let getKeywordForValRef (vref : ValRef) = - let v = vref.Deref - if v.IsModuleBinding then - let tyconRef = v.TopValActualParent - let paramsString = - match v.Typars with - | [] -> "" - | l -> "``"+(List.length l).ToString() - - sprintf "%s.%s%s" (tyconRef |> ticksAndArgCountTextOfTyconRef) v.CompiledName paramsString |> Some - else - None + /// Determine if an item is a provided type + let (|ItemIsProvidedType|_|) g item = + match item with + | Item.Types(_name,tys) -> + match tys with + | [AppTy g (tyconRef,_typeInst)] -> + if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then + Some tyconRef + else + None + | _ -> None + | _ -> None + + /// Determine if an item is a provided type that has static parameters + let (|ItemIsProvidedTypeWithStaticArguments|_|) m g item = + match item with + | Item.Types(_name,tys) -> + match tys with + | [AppTy g (tyconRef,_typeInst)] -> + if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then + let typeBeforeArguments = + match tyconRef.TypeReprInfo with + | TProvidedTypeExtensionPoint info -> info.ProvidedType + | _ -> failwith "unreachable" + let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments,provider) -> typeBeforeArguments.GetStaticParameters(provider)), range=m) + let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters",m) + Some staticParameters + else + None + | _ -> None + | _ -> None + + + let (|ItemIsProvidedMethodWithStaticArguments|_|) item = + match item with + // Prefer the static parameters from the uninstantiated method info + | Item.MethodGroup(_,_,Some minfo) -> + match minfo.ProvidedStaticParameterInfo with + | Some (_,staticParameters) -> Some staticParameters + | _ -> None + | Item.MethodGroup(_,[minfo],_) -> + match minfo.ProvidedStaticParameterInfo with + | Some (_,staticParameters) -> Some staticParameters + | _ -> None + | _ -> None + + /// Determine if an item has static arguments + let (|ItemIsWithStaticArguments|_|) m g item = + match item with + | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> Some staticParameters + | ItemIsProvidedMethodWithStaticArguments staticParameters -> Some staticParameters + | _ -> None + +#endif + + /// Get the "F1 Keyword" associated with an item, for looking up documentatio help indexes on the web + let rec GetF1Keyword g item = let getKeywordForMethInfo (minfo : MethInfo) = match minfo with @@ -1147,9 +1311,22 @@ module internal ItemDescriptionsImpl = | ProvidedMeth _ -> None #endif - match d with - | Item.Value vref | Item.CustomBuilder (_,vref) -> getKeywordForValRef vref - | Item.ActivePatternCase apref -> apref.ActivePatternVal |> getKeywordForValRef + match item with + | Item.Value vref | Item.CustomBuilder (_,vref) -> + let v = vref.Deref + if v.IsModuleBinding && v.HasTopValActualParent then + let tyconRef = v.TopValActualParent + let paramsString = + match v.Typars with + | [] -> "" + | l -> "``"+(List.length l).ToString() + + sprintf "%s.%s%s" (tyconRef |> ticksAndArgCountTextOfTyconRef) v.CompiledName paramsString |> Some + else + None + + | Item.ActivePatternCase apref -> + GetF1Keyword g (Item.Value apref.ActivePatternVal) | Item.UnionCase(ucinfo,_) -> (ucinfo.TyconRef |> ticksAndArgCountTextOfTyconRef)+"."+ucinfo.Name |> Some @@ -1164,12 +1341,15 @@ module internal ItemDescriptionsImpl = #if EXTENSIONTYPING | ProvidedField _ -> None #endif - | Item.Types(_,((TType_app(tcref,_)) :: _)) - | Item.DelegateCtor(TType_app(tcref,_)) - | Item.FakeInterfaceCtor(TType_app(tcref,_)) + | Item.Types(_,((AppTy g (tcref,_)) :: _)) + | Item.DelegateCtor(AppTy g (tcref,_)) + | Item.FakeInterfaceCtor(AppTy g (tcref,_)) | Item.UnqualifiedType (tcref::_) | Item.ExnCase tcref -> - unwindTypeAbbrev tcref |> Option.map ticksAndArgCountTextOfTyconRef + // strip off any abbreviation + match generalizedTyconRef tcref with + | AppTy g (tcref, _) -> Some (ticksAndArgCountTextOfTyconRef tcref) + | _ -> None // Pathological cases of the above | Item.Types _ @@ -1226,10 +1406,9 @@ module internal ItemDescriptionsImpl = | FSEvent(_,pinfo,_,_) -> match pinfo.ArbitraryValRef with | Some vref -> - // per spec, extension members in F1 keywords are qualified with definition class + // per spec, members in F1 keywords are qualified with definition class match vref.ActualParent with - | Parent tcref -> - (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some + | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef)+"."+vref.PropertyName|> Some | ParentNone -> None | None -> None #if EXTENSIONTYPING @@ -1239,10 +1418,8 @@ module internal ItemDescriptionsImpl = match minfos with | [] -> None | FSMeth(_, _, vref, _) :: _ -> - // per spec, extension members in F1 keywords are qualified with definition class match vref.ActualParent with - | Parent tcref -> - (tcref |> ticksAndArgCountTextOfTyconRef) + ".#ctor"|> Some + | Parent tcref -> (tcref |> ticksAndArgCountTextOfTyconRef) + ".#ctor"|> Some | ParentNone -> None | (ILMeth (_,minfo,_)) :: _ -> let tcref = minfo.DeclaringTyconRef @@ -1256,7 +1433,7 @@ module internal ItemDescriptionsImpl = | Item.CustomOperation (_,_,Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_,_,Some minfo) -> getKeywordForMethInfo minfo | Item.MethodGroup(_,minfo :: _,_) -> getKeywordForMethInfo minfo - | Item.SetterArg (_, propOrField) -> GetF1Keyword propOrField + | Item.SetterArg (_, propOrField) -> GetF1Keyword g propOrField | Item.MethodGroup(_,[],_) | Item.CustomOperation (_,_,None) // "into" | Item.NewDef _ // "let x$yz = ..." - no keyword @@ -1266,350 +1443,35 @@ module internal ItemDescriptionsImpl = | Item.ActivePatternResult _ // "let (|Foo|Bar|) = .. Fo$o ..." - no keyword -> None - let FormatStructuredDescriptionOfItem isDecl (infoReader:InfoReader) m denv d : FSharpStructuredToolTipElement = + + /// Format the structured version of a tooltip for an item + let FormatStructuredDescriptionOfItem isListItem infoReader m denv item = ErrorScope.Protect m - (fun () -> FormatItemDescriptionToToolTipElement isDecl infoReader m denv d) + (fun () -> FormatItemDescriptionToToolTipElement isListItem infoReader m denv item) (fun err -> FSharpStructuredToolTipElement.CompositionError(err)) - let FormatDescriptionOfItem isDecl infoReader m denv d = - FormatStructuredDescriptionOfItem isDecl infoReader m denv d - |> Tooltips.ToFSharpToolTipElement - - let FormatStructuredReturnTypeOfItem (infoReader:InfoReader) m denv d = - ErrorScope.Protect m (fun () -> FormatItemReturnTypeAsLayout infoReader m denv d) (fun err -> wordL (tagText err)) - - let FormatReturnTypeOfItem (infoReader:InfoReader) m denv d = - FormatStructuredReturnTypeOfItem infoReader m denv d - |> showL - - // Compute the index of the VS glyph shown with an item in the Intellisense menu - let GlyphOfItem(denv, item) : FSharpGlyph = - /// Find the glyph for the given representation. - let reprToGlyph repr = - match repr with - | TFSharpObjectRepr om -> - match om.fsobjmodel_kind with - | TTyconClass -> FSharpGlyph.Class - | TTyconInterface -> FSharpGlyph.Interface - | TTyconStruct -> FSharpGlyph.Struct - | TTyconDelegate _ -> FSharpGlyph.Delegate - | TTyconEnum _ -> FSharpGlyph.Enum - | TRecdRepr _ -> FSharpGlyph.Type - | TUnionRepr _ -> FSharpGlyph.Union - | TILObjectRepr (TILObjectReprData (_,_,td)) -> - match td.tdKind with - | ILTypeDefKind.Class -> FSharpGlyph.Class - | ILTypeDefKind.ValueType -> FSharpGlyph.Struct - | ILTypeDefKind.Interface -> FSharpGlyph.Interface - | ILTypeDefKind.Enum -> FSharpGlyph.Enum - | ILTypeDefKind.Delegate -> FSharpGlyph.Delegate - | TAsmRepr _ -> FSharpGlyph.Typedef - | TMeasureableRepr _-> FSharpGlyph.Typedef + /// Get rid of groups of overloads an replace them with single items. + let FlattenItems g (m: range) item = + match item with + | Item.MethodGroup(nm,minfos,orig) -> minfos |> List.map (fun minfo -> Item.MethodGroup(nm,[minfo],orig)) + | Item.CtorGroup(nm,cinfos) -> cinfos |> List.map (fun minfo -> Item.CtorGroup(nm,[minfo])) + | Item.FakeInterfaceCtor _ + | Item.DelegateCtor _ -> [item] + | Item.NewDef _ + | Item.ILField _ -> [] + | Item.Event _ -> [] + | Item.RecdField(rfinfo) -> if isFunction g rfinfo.FieldType then [item] else [] + | Item.Value v -> if isFunction g v.Type then [item] else [] + | Item.UnionCase(ucr,_) -> if not ucr.UnionCase.IsNullary then [item] else [] + | Item.ExnCase(ecr) -> if isNil (recdFieldsOfExnDefRef ecr) then [] else [item] + | Item.Property(_,pinfos) -> + let pinfo = List.head pinfos + if pinfo.IsIndexer then [item] else [] #if EXTENSIONTYPING - | TProvidedTypeExtensionPoint _-> FSharpGlyph.Typedef - | TProvidedNamespaceExtensionPoint _-> FSharpGlyph.Typedef + | ItemIsWithStaticArguments m g _ -> [item] // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them #endif - | TNoRepr -> FSharpGlyph.Class - - /// Find the glyph for the given type representation. - let typeToGlyph typ = - if isAppTy denv.g typ then - let tcref = tcrefOfAppTy denv.g typ - tcref.TypeReprInfo |> reprToGlyph - elif isStructTupleTy denv.g typ then FSharpGlyph.Struct - elif isRefTupleTy denv.g typ then FSharpGlyph.Class - elif isFunction denv.g typ then FSharpGlyph.Delegate - elif isTyparTy denv.g typ then FSharpGlyph.Struct - else FSharpGlyph.Typedef - - // This may explore assemblies that are not in the reference set, - // e.g. for type abbreviations to types not in the reference set. - // In this case just use GlyphMajor.Class. - protectAssemblyExploration FSharpGlyph.Class (fun () -> - match item with - | Item.Value(vref) | Item.CustomBuilder (_,vref) -> - if isFunction denv.g vref.Type then FSharpGlyph.Method - elif vref.LiteralValue.IsSome then FSharpGlyph.Constant - else FSharpGlyph.Variable - | Item.Types(_,typ::_) -> typeToGlyph (stripTyEqns denv.g typ) - | Item.UnionCase _ - | Item.ActivePatternCase _ -> FSharpGlyph.EnumMember - | Item.ExnCase _ -> FSharpGlyph.Exception - | Item.RecdField _ -> FSharpGlyph.Field - | Item.ILField _ -> FSharpGlyph.Field - | Item.Event _ -> FSharpGlyph.Event - | Item.Property _ -> FSharpGlyph.Property - | Item.CtorGroup _ - | Item.DelegateCtor _ - | Item.FakeInterfaceCtor _ - | Item.CustomOperation _ -> FSharpGlyph.Method - | Item.MethodGroup (_, minfos, _) when minfos |> List.forall (fun minfo -> minfo.IsExtensionMember) -> FSharpGlyph.ExtensionMethod - | Item.MethodGroup _ -> FSharpGlyph.Method - | Item.TypeVar _ - | Item.Types _ -> FSharpGlyph.Class - | Item.UnqualifiedType (tcref :: _) -> - if tcref.IsEnumTycon || tcref.IsILEnumTycon then FSharpGlyph.Enum - elif tcref.IsExceptionDecl then FSharpGlyph.Exception - elif tcref.IsFSharpDelegateTycon then FSharpGlyph.Delegate - elif tcref.IsFSharpInterfaceTycon then FSharpGlyph.Interface - elif tcref.IsFSharpStructOrEnumTycon then FSharpGlyph.Struct - elif tcref.IsModule then FSharpGlyph.Module - elif tcref.IsNamespace then FSharpGlyph.NameSpace - elif tcref.IsUnionTycon then FSharpGlyph.Union - elif tcref.IsILTycon then - let (TILObjectReprData (_, _, tydef)) = tcref.ILTyconInfo - if tydef.IsInterface then FSharpGlyph.Interface - elif tydef.IsDelegate then FSharpGlyph.Delegate - elif tydef.IsEnum then FSharpGlyph.Enum - elif tydef.IsStructOrEnum then FSharpGlyph.Struct - else FSharpGlyph.Class - else FSharpGlyph.Class - | Item.ModuleOrNamespaces(modref::_) -> - if modref.IsNamespace then FSharpGlyph.NameSpace else FSharpGlyph.Module - | Item.ArgName _ -> FSharpGlyph.Variable - | Item.SetterArg _ -> FSharpGlyph.Variable - | _ -> FSharpGlyph.Error) - -type FSharpAccessibility internal (a:Accessibility, ?isProtected) = - let isProtected = defaultArg isProtected false - - let isInternalCompPath x = - match x with - | CompPath(ILScopeRef.Local,[]) -> true - | _ -> false - - let (|Public|Internal|Private|) (TAccess p) = - match p with - | [] -> Public - | _ when List.forall isInternalCompPath p -> Internal - | _ -> Private - - member __.IsPublic = not isProtected && match a with Public -> true | _ -> false - - member __.IsPrivate = not isProtected && match a with Private -> true | _ -> false - - member __.IsInternal = not isProtected && match a with Internal -> true | _ -> false - - member __.IsProtected = isProtected - - member internal __.Contents = a - - override x.ToString() = - let (TAccess paths) = a - let mangledTextOfCompPath (CompPath(scoref,path)) = getNameOfScopeRef scoref + "/" + textOfPath (List.map fst path) - String.concat ";" (List.map mangledTextOfCompPath paths) - -/// An intellisense declaration -[] -type FSharpDeclarationListItem(name: string, nameInCode: string, fullName: string, glyph: FSharpGlyph, info, accessibility: FSharpAccessibility option, - kind: CompletionItemKind, isOwnMember: bool, priority: int, isResolved: bool, namespaceToOpen: string option) = - - let mutable descriptionTextHolder: FSharpToolTipText<_> option = None - let mutable task = null - - member decl.Name = name - member decl.NameInCode = nameInCode - - member decl.StructuredDescriptionTextAsync = - match info with - | Choice1Of2 (items: CompletionItem list, infoReader, m, denv, reactor:IReactorOperations, checkAlive) -> - // reactor causes the lambda to execute on the background compiler thread, through the Reactor - reactor.EnqueueAndAwaitOpAsync ("StructuredDescriptionTextAsync", fun ctok -> - RequireCompilationThread ctok - // This is where we do some work which may touch TAST data structures owned by the IncrementalBuilder - infoReader, item etc. - // It is written to be robust to a disposal of an IncrementalBuilder, in which case it will just return the empty string. - // It is best to think of this as a "weak reference" to the IncrementalBuilder, i.e. this code is written to be robust to its - // disposal. Yes, you are right to scratch your head here, but this is ok. - cancellable.Return( - if checkAlive() then FSharpToolTipText(items |> List.map (fun x -> ItemDescriptionsImpl.FormatStructuredDescriptionOfItem true infoReader m denv x.Item)) - else FSharpToolTipText [ FSharpStructuredToolTipElement.Single(wordL (tagText (FSComp.SR.descriptionUnavailable())), FSharpXmlDoc.None) ])) - | Choice2Of2 result -> - async.Return result - - member decl.DescriptionTextAsync = - decl.StructuredDescriptionTextAsync - |> Tooltips.Map Tooltips.ToFSharpToolTipText - - member decl.StructuredDescriptionText = - ErrorScope.Protect Range.range0 - (fun () -> - match descriptionTextHolder with - | Some descriptionText -> descriptionText - | None -> - match info with - | Choice1Of2 _ -> - // The dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. - // This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. - if isNull task then - // kick off the actual (non-cooperative) work - task <- System.Threading.Tasks.Task.Factory.StartNew(fun() -> - let text = decl.StructuredDescriptionTextAsync |> Async.RunSynchronously - descriptionTextHolder <- Some text) - - // The dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. - // This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. - task.Wait EnvMisc2.dataTipSpinWaitTime |> ignore - match descriptionTextHolder with - | Some text -> text - | None -> FSharpToolTipText [ FSharpStructuredToolTipElement.Single(wordL (tagText (FSComp.SR.loadingDescription())), FSharpXmlDoc.None) ] - - | Choice2Of2 result -> - result - ) - (fun err -> FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) - member decl.DescriptionText = decl.StructuredDescriptionText |> Tooltips.ToFSharpToolTipText - member decl.Glyph = glyph - member decl.Accessibility = accessibility - member decl.Kind = kind - member decl.IsOwnMember = isOwnMember - member decl.MinorPriority = priority - member decl.FullName = fullName - member decl.IsResolved = isResolved - member decl.NamespaceToOpen = namespaceToOpen - -/// A table of declarations for Intellisense completion -[] -type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForType: bool, isError: bool) = - member self.Items = declarations - member self.IsForType = isForType - member self.IsError = isError + | Item.CustomOperation(_name, _helpText, _minfo) -> [item] + | Item.TypeVar _ -> [] + | Item.CustomBuilder _ -> [] + | _ -> [] - // Make a 'Declarations' object for a set of selected items - static member Create(infoReader:InfoReader, m, denv, getAccessibility, items: CompletionItem list, reactor, currentNamespaceOrModule: string[] option, isAttributeApplicationContext: bool, checkAlive) = - let g = infoReader.g - let isForType = items |> List.exists (fun x -> x.Type.IsSome) - let items = items |> ItemDescriptionsImpl.RemoveExplicitlySuppressedCompletionItems g - - let tyconRefOptEq tref1 tref2 = - match tref1 with - | Some tref1 -> tyconRefEq g tref1 tref2 - | None -> false - - // Adjust items priority. Sort by name. For things with the same name, - // - show types with fewer generic parameters first - // - show types before over other related items - they usually have very useful XmlDocs - let _, _, items = - items - |> List.map (fun x -> - match x.Item with - | Item.Types (_,(TType_app(tcref,_) :: _)) -> { x with MinorPriority = 1 + tcref.TyparsNoRange.Length } - // Put delegate ctors after types, sorted by #typars. RemoveDuplicateItems will remove FakeInterfaceCtor and DelegateCtor if an earlier type is also reported with this name - | Item.FakeInterfaceCtor (TType_app(tcref,_)) - | Item.DelegateCtor (TType_app(tcref,_)) -> { x with MinorPriority = 1000 + tcref.TyparsNoRange.Length } - // Put type ctors after types, sorted by #typars. RemoveDuplicateItems will remove DefaultStructCtors if a type is also reported with this name - | Item.CtorGroup (_, (cinfo :: _)) -> { x with MinorPriority = 1000 + 10 * (tcrefOfAppTy g cinfo.EnclosingType).TyparsNoRange.Length } - | Item.MethodGroup(_, minfo :: _, _) -> { x with IsOwnMember = tyconRefOptEq x.Type minfo.DeclaringEntityRef } - | Item.Property(_, pinfo :: _) -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g pinfo.EnclosingType) } - | Item.ILField finfo -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g finfo.EnclosingType) } - | _ -> x) - |> List.sortBy (fun x -> x.MinorPriority) - |> List.fold (fun (prevRealPrior, prevNormalizedPrior, acc) x -> - if x.MinorPriority = prevRealPrior then - prevRealPrior, prevNormalizedPrior, x :: acc - else - let normalizedPrior = prevNormalizedPrior + 1 - x.MinorPriority, normalizedPrior, { x with MinorPriority = normalizedPrior } :: acc - ) (0, 0, []) - - if verbose then dprintf "service.ml: mkDecls: %d found groups after filtering\n" (List.length items); - - // Group by full name for unresolved items and by display name for resolved ones. - let items = - items - |> List.rev - // Prefer items from file check results to ones from referenced assemblies via GetAssemblyContent ("all entities") - |> List.sortBy (fun x -> x.Unresolved.IsSome) - // Remove all duplicates. We've put the types first, so this removes the DelegateCtor and DefaultStructCtor's. - |> RemoveDuplicateCompletionItems g - |> List.groupBy (fun x -> - match x.Unresolved with - | Some u -> - match u.Namespace with - | [||] -> u.DisplayName - | ns -> (ns |> String.concat ".") + "." + u.DisplayName - | None -> x.Item.DisplayName) - |> List.map (fun (_, items) -> - let item = items.Head - match item.Unresolved with - | Some u -> u.DisplayName - | None -> item.Item.DisplayName - , items) - - // Filter out operators (and list) - let items = - // Check whether this item looks like an operator. - let isOperatorItem(name, item) = - match item |> List.map (fun x -> x.Item) with - | [Item.Value _] - | [Item.MethodGroup _ ] -> IsOperatorName name - | [Item.UnionCase _] -> IsOperatorName name - | _ -> false - let isFSharpList name = (name = "[]") // list shows up as a Type and a UnionCase, only such entity with a symbolic name, but want to filter out of intellisense - items |> List.filter (fun (displayName, items) -> not (isOperatorItem(displayName, items)) && not (isFSharpList displayName)) - - let decls = - items - |> List.map (fun (displayName, itemsWithSameFullName) -> - match itemsWithSameFullName with - | [] -> failwith "Unexpected empty bag" - | _ -> - let items = - match itemsWithSameFullName |> List.partition (fun x -> x.Unresolved.IsNone) with - | [], unresolved -> unresolved - // if there are resolvable items, throw out unresolved to prevent duplicates like `Set` and `FSharp.Collections.Set`. - | resolved, _ -> resolved - - let item = items.Head - let glyph = ItemDescriptionsImpl.GlyphOfItem(denv, item.Item) - - let name, nameInCode = - if displayName.StartsWith "( " && displayName.EndsWith " )" then - let cleanName = displayName.[2..displayName.Length - 3] - cleanName, - if IsOperatorName displayName then cleanName else "``" + cleanName + "``" - else - displayName, - match item.Unresolved with - | Some _ -> displayName - | None -> Lexhelp.Keywords.QuoteIdentifierIfNeeded displayName - - let isAttribute = ItemDescriptionsImpl.IsAttribute infoReader item.Item - - let cutAttributeSuffix (name: string) = - if isAttributeApplicationContext && isAttribute && name <> "Attribute" && name.EndsWith "Attribute" then - name.[0..name.Length - "Attribute".Length - 1] - else name - - let name = cutAttributeSuffix name - let nameInCode = cutAttributeSuffix nameInCode - let fullName = ItemDescriptionsImpl.FullNameOfItem g item.Item - - let namespaceToOpen = - item.Unresolved - |> Option.map (fun x -> x.Namespace) - |> Option.bind (fun ns -> - if ns |> Array.startsWith [|"Microsoft"; "FSharp"|] then None - else Some ns) - |> Option.map (fun ns -> - match currentNamespaceOrModule with - | Some currentNs -> - if ns |> Array.startsWith currentNs then - ns.[currentNs.Length..] - else ns - | None -> ns) - |> Option.bind (function - | [||] -> None - | ns -> Some (ns |> String.concat ".")) - - FSharpDeclarationListItem( - name, nameInCode, fullName, glyph, Choice1Of2 (items, infoReader, m, denv, reactor, checkAlive), getAccessibility item.Item, - item.Kind, item.IsOwnMember, item.MinorPriority, item.Unresolved.IsNone, namespaceToOpen)) - - new FSharpDeclarationListInfo(Array.ofList decls, isForType, false) - - static member Error msg = - new FSharpDeclarationListInfo( - [| FSharpDeclarationListItem("", "", "", FSharpGlyph.Error, Choice2Of2 (FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError msg]), - None, CompletionItemKind.Other, false, 0, false, None) |], false, true) - - static member Empty = FSharpDeclarationListInfo([| |], false, false) diff --git a/src/fsharp/symbols/SymbolHelpers.fsi b/src/fsharp/symbols/SymbolHelpers.fsi new file mode 100755 index 0000000000..faa07e1299 --- /dev/null +++ b/src/fsharp/symbols/SymbolHelpers.fsi @@ -0,0 +1,252 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +//---------------------------------------------------------------------------- +// Helpers for quick info and information about items +//---------------------------------------------------------------------------- + +namespace Microsoft.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.CompileOps +open Microsoft.FSharp.Compiler.Tastops +open Microsoft.FSharp.Compiler.ErrorLogger + +//---------------------------------------------------------------------------- +// Object model for diagnostics + + +[] +#if COMPILER_PUBLIC_API +type FSharpErrorSeverity = +#else +type internal FSharpErrorSeverity = +#endif +| Warning + | Error + +[] +#if COMPILER_PUBLIC_API +type FSharpErrorInfo = +#else +type internal FSharpErrorInfo = +#endif + member FileName: string + member StartLineAlternate:int + member EndLineAlternate:int + member StartColumn:int + member EndColumn:int + member Severity:FSharpErrorSeverity + member Message:string + member Subcategory:string + member ErrorNumber:int + static member internal CreateFromExceptionAndAdjustEof : PhasedDiagnostic * isError: bool * trim: bool * range * lastPosInFile:(int*int) -> FSharpErrorInfo + static member internal CreateFromException : PhasedDiagnostic * isError: bool * trim: bool * range -> FSharpErrorInfo + +//---------------------------------------------------------------------------- +// Object model for quick info + +/// Describe a comment as either a block of text or a file+signature reference into an intellidoc file. +// +// Note: instances of this type do not hold any references to any compiler resources. +[] +#if COMPILER_PUBLIC_API +type FSharpXmlDoc = +#else +type internal FSharpXmlDoc = +#endif + /// No documentation is available + | None + + /// The text for documentation + | Text of string + + /// Indicates that the text for the documentation can be found in a .xml documentation file, using the given signature key + | XmlDocFileSignature of (*File:*) string * (*Signature:*)string + +#if COMPILER_PUBLIC_API +type Layout = Internal.Utilities.StructuredFormat.Layout +#else +type internal Layout = Internal.Utilities.StructuredFormat.Layout +#endif + +/// A single data tip display element +[] +#if COMPILER_PUBLIC_API +type FSharpToolTipElementData<'T> = +#else +type internal FSharpToolTipElementData<'T> = +#endif + { MainDescription: 'T + XmlDoc: FSharpXmlDoc + /// typar insantiation text, to go after xml + TypeMapping: 'T list + /// Extra text, goes at the end + Remarks: 'T option + /// Parameter name + ParamName : string option } + +/// A single tool tip display element +// +// Note: instances of this type do not hold any references to any compiler resources. +[] +#if COMPILER_PUBLIC_API +type FSharpToolTipElement<'T> = +#else +type internal FSharpToolTipElement<'T> = +#endif + | None + + /// A single type, method, etc with comment. May represent a method overload group. + | Group of FSharpToolTipElementData<'T> list + + /// An error occurred formatting this element + | CompositionError of string + static member Single : 'T * FSharpXmlDoc * ?typeMapping: 'T list * ?paramName: string * ?remarks : 'T -> FSharpToolTipElement<'T> + +/// A single data tip display element with where text is expressed as string +#if COMPILER_PUBLIC_API +type FSharpToolTipElement = FSharpToolTipElement +#else +type internal FSharpToolTipElement = FSharpToolTipElement +#endif + + +/// A single data tip display element with where text is expressed as +#if COMPILER_PUBLIC_API +type FSharpStructuredToolTipElement = FSharpToolTipElement +#else +type internal FSharpStructuredToolTipElement = FSharpToolTipElement +#endif + +/// Information for building a tool tip box. +// +// Note: instances of this type do not hold any references to any compiler resources. +#if COMPILER_PUBLIC_API +type FSharpToolTipText<'T> = +#else +type internal FSharpToolTipText<'T> = +#endif + /// A list of data tip elements to display. + | FSharpToolTipText of FSharpToolTipElement<'T> list + +#if COMPILER_PUBLIC_API +type FSharpToolTipText = FSharpToolTipText +type FSharpStructuredToolTipText = FSharpToolTipText +#else +type internal FSharpToolTipText = FSharpToolTipText +type internal FSharpStructuredToolTipText = FSharpToolTipText +#endif + +//---------------------------------------------------------------------------- +// Object model for completion list entries (one of several in the API...) + + +[] +#if COMPILER_PUBLIC_API +type CompletionItemKind = +#else +type internal CompletionItemKind = +#endif + | Field + | Property + | Method of isExtension : bool + | Event + | Argument + | Other + +type internal UnresolvedSymbol = + { DisplayName: string + Namespace: string[] } + +type internal CompletionItem = + { ItemWithInst: ItemWithInst + Kind: CompletionItemKind + IsOwnMember: bool + MinorPriority: int + Type: TyconRef option + Unresolved: UnresolvedSymbol option } + member Item : Item + +#if COMPILER_PUBLIC_API +module Tooltips = +#else +module internal Tooltips = +#endif + val ToFSharpToolTipElement: FSharpStructuredToolTipElement -> FSharpToolTipElement + val ToFSharpToolTipText: FSharpStructuredToolTipText -> FSharpToolTipText + val Map: f: ('T1 -> 'T2) -> a: Async<'T1> -> Async<'T2> + +// Implementation details used by other code in the compiler +module internal SymbolHelpers = + val isFunction : TcGlobals -> TType -> bool + val ParamNameAndTypesOfUnaryCustomOperation : TcGlobals -> MethInfo -> ParamNameAndType list + + val GetXmlDocSigOfEntityRef : InfoReader -> range -> EntityRef -> (string option * string) option + val GetXmlDocSigOfScopedValRef : TcGlobals -> TyconRef -> ValRef -> (string option * string) option + val GetXmlDocSigOfILFieldInfo : InfoReader -> range -> ILFieldInfo -> (string option * string) option + val GetXmlDocSigOfRecdFieldInfo : RecdFieldInfo -> (string option * string) option + val GetXmlDocSigOfUnionCaseInfo : UnionCaseInfo -> (string option * string) option + val GetXmlDocSigOfMethInfo : InfoReader -> range -> MethInfo -> (string option * string) option + val GetXmlDocSigOfValRef : TcGlobals -> ValRef -> (string option * string) option + val GetXmlDocSigOfProp : InfoReader -> range -> PropInfo -> (string option * string) option + val GetXmlDocSigOfEvent : InfoReader -> range -> EventInfo -> (string option * string) option + val GetXmlCommentForItem : InfoReader -> range -> Item -> FSharpXmlDoc + val FormatStructuredDescriptionOfItem : isDecl:bool -> InfoReader -> range -> DisplayEnv -> ItemWithInst -> FSharpStructuredToolTipElement + val RemoveDuplicateItems : TcGlobals -> ItemWithInst list -> ItemWithInst list + val RemoveExplicitlySuppressed : TcGlobals -> ItemWithInst list -> ItemWithInst list + val RemoveDuplicateCompletionItems : TcGlobals -> CompletionItem list -> CompletionItem list + val RemoveExplicitlySuppressedCompletionItems : TcGlobals -> CompletionItem list -> CompletionItem list + val GetF1Keyword : TcGlobals -> Item -> string option + val rangeOfItem : TcGlobals -> bool option -> Item -> range option + val fileNameOfItem : TcGlobals -> string option -> range -> Item -> string + val FullNameOfItem : TcGlobals -> Item -> string + val ccuOfItem : TcGlobals -> Item -> CcuThunk option + val mutable ToolTipFault : string option + val IsAttribute : InfoReader -> Item -> bool + val IsExplicitlySuppressed : TcGlobals -> Item -> bool + val FlattenItems : TcGlobals -> range -> Item -> Item list +#if EXTENSIONTYPING + val (|ItemIsProvidedType|_|) : TcGlobals -> Item -> TyconRef option + val (|ItemIsWithStaticArguments|_|): range -> TcGlobals -> Item -> Tainted[] option + val (|ItemIsProvidedTypeWithStaticArguments|_|): range -> TcGlobals -> Item -> Tainted[] option +#endif + val SimplerDisplayEnv : DisplayEnv -> DisplayEnv + +//---------------------------------------------------------------------------- +// Internal only + +// Implementation details used by other code in the compiler +[] +type internal ErrorScope = + interface IDisposable + new : unit -> ErrorScope + member Diagnostics : FSharpErrorInfo list + static member Protect<'a> : range -> (unit->'a) -> (string->'a) -> 'a + +/// An error logger that capture errors, filtering them according to warning levels etc. +type internal CompilationErrorLogger = + inherit ErrorLogger + + /// Create the error logger + new : debugName:string * tcConfig:TcConfig -> CompilationErrorLogger + + /// Get the captured errors + member GetErrors : unit -> (PhasedDiagnostic * FSharpErrorSeverity) list + +/// This represents the global state established as each task function runs as part of the build. +/// +/// Use to reset error and warning handlers. +type internal CompilationGlobalsScope = + new : ErrorLogger * BuildPhase -> CompilationGlobalsScope + interface IDisposable + +module internal ErrorHelpers = + val ReportError: TcConfig * allErrors: bool * mainInputFileName: string * fileInfo: (int * int) * (PhasedDiagnostic * FSharpErrorSeverity) -> FSharpErrorInfo list + val CreateErrorInfos: TcConfig * allErrors: bool * mainInputFileName: string * seq<(PhasedDiagnostic * FSharpErrorSeverity)> -> FSharpErrorInfo[] diff --git a/src/fsharp/vs/Symbols.fs b/src/fsharp/symbols/Symbols.fs similarity index 92% rename from src/fsharp/vs/Symbols.fs rename to src/fsharp/symbols/Symbols.fs index 90335e966a..8c5ef851d9 100755 --- a/src/fsharp/vs/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -21,6 +21,35 @@ open Microsoft.FSharp.Compiler.Tastops open Microsoft.FSharp.Compiler.PrettyNaming open Internal.Utilities +type FSharpAccessibility(a:Accessibility, ?isProtected) = + let isProtected = defaultArg isProtected false + + let isInternalCompPath x = + match x with + | CompPath(ILScopeRef.Local,[]) -> true + | _ -> false + + let (|Public|Internal|Private|) (TAccess p) = + match p with + | [] -> Public + | _ when List.forall isInternalCompPath p -> Internal + | _ -> Private + + member __.IsPublic = not isProtected && match a with Public -> true | _ -> false + + member __.IsPrivate = not isProtected && match a with Private -> true | _ -> false + + member __.IsInternal = not isProtected && match a with Internal -> true | _ -> false + + member __.IsProtected = isProtected + + member internal __.Contents = a + + override __.ToString() = + let (TAccess paths) = a + let mangledTextOfCompPath (CompPath(scoref,path)) = getNameOfScopeRef scoref + "/" + textOfPath (List.map fst path) + String.concat ";" (List.map mangledTextOfCompPath paths) + [] module Impl = let protect f = @@ -99,11 +128,11 @@ module Impl = /// Convert an IL type definition accessibility into an F# accessibility let getApproxFSharpAccessibilityOfEntity (entity: EntityRef) = match metadataOfTycon entity.Deref with - #if EXTENSIONTYPING +#if EXTENSIONTYPING | ProvidedTypeMetadata _info -> // This is an approximation - for generative type providers some type definitions can be private. taccessPublic - #endif +#endif | ILTypeMetadata (TILObjectReprData(_,_,td)) -> match td.Access with @@ -149,7 +178,7 @@ module Impl = member __.tcImports = tcImports let getXmlDocSigForEntity (cenv: cenv) (ent:EntityRef)= - match ItemDescriptionsImpl.GetXmlDocSigOfEntityRef cenv.infoReader ent.Range ent with + match SymbolHelpers.GetXmlDocSigOfEntityRef cenv.infoReader ent.Range ent with | Some (_, docsig) -> docsig | _ -> "" @@ -162,20 +191,20 @@ type FSharpDisplayContext(denv: TcGlobals -> DisplayEnv) = type FSharpSymbol(cenv:cenv, item: (unit -> Item), access: (FSharpSymbol -> CcuThunk -> AccessorDomain -> bool)) = member x.Assembly = - let ccu = defaultArg (ItemDescriptionsImpl.ccuOfItem cenv.g x.Item) cenv.thisCcu + let ccu = defaultArg (SymbolHelpers.ccuOfItem cenv.g x.Item) cenv.thisCcu FSharpAssembly(cenv, ccu) member x.IsAccessible(rights: FSharpAccessibilityRights) = access x rights.ThisCcu rights.Contents - member x.IsExplicitlySuppressed = ItemDescriptionsImpl.IsExplicitlySuppressed cenv.g x.Item + member x.IsExplicitlySuppressed = SymbolHelpers.IsExplicitlySuppressed cenv.g x.Item - member x.FullName = ItemDescriptionsImpl.FullNameOfItem cenv.g x.Item + member x.FullName = SymbolHelpers.FullNameOfItem cenv.g x.Item - member x.DeclarationLocation = ItemDescriptionsImpl.rangeOfItem cenv.g None x.Item + member x.DeclarationLocation = SymbolHelpers.rangeOfItem cenv.g None x.Item - member x.ImplementationLocation = ItemDescriptionsImpl.rangeOfItem cenv.g (Some(false)) x.Item + member x.ImplementationLocation = SymbolHelpers.rangeOfItem cenv.g (Some(false)) x.Item - member x.SignatureLocation = ItemDescriptionsImpl.rangeOfItem cenv.g (Some(true)) x.Item + member x.SignatureLocation = SymbolHelpers.rangeOfItem cenv.g (Some(true)) x.Item member x.IsEffectivelySameAs(y:FSharpSymbol) = x.Equals(y) || ItemsAreEffectivelyEqual cenv.g x.Item y.Item @@ -220,6 +249,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = let isResolved() = not (isUnresolved()) let checkIsResolved() = checkEntityIsResolved entity + let isDefinedInFSharpCore() = + match ccuOfTyconRef entity with + | None -> false + | Some ccu -> ccuEq ccu cenv.g.fslibCcu + member __.Entity = entity member __.LogicalName = @@ -254,11 +288,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member x.QualifiedName = checkIsResolved() let fail() = invalidOp (sprintf "the type '%s' does not have a qualified name" x.LogicalName) - #if EXTENSIONTYPING +#if EXTENSIONTYPING if entity.IsTypeAbbrev || entity.IsProvidedErasedTycon || entity.IsNamespace then fail() #else if entity.IsTypeAbbrev || entity.IsNamespace then fail() - #endif +#endif match entity.CompiledRepresentation with | CompiledTypeRepr.ILAsmNamed(tref,_,_) -> tref.QualifiedName | CompiledTypeRepr.ILAsmOpen _ -> fail() @@ -271,11 +305,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member x.TryFullName = if isUnresolved() then None - #if EXTENSIONTYPING +#if EXTENSIONTYPING elif entity.IsTypeAbbrev || entity.IsProvidedErasedTycon then None #else elif entity.IsTypeAbbrev then None - #endif +#endif elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName else match entity.CompiledRepresentation with @@ -332,9 +366,9 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member __.IsClass = isResolved() && match metadataOfTycon entity.Deref with - #if EXTENSIONTYPING +#if EXTENSIONTYPING | ProvidedTypeMetadata info -> info.IsClass - #endif +#endif | ILTypeMetadata (TILObjectReprData(_,_,td)) -> (td.tdKind = ILTypeDefKind.Class) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.Deref.IsFSharpClassTycon @@ -353,9 +387,9 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member __.IsDelegate = isResolved() && match metadataOfTycon entity.Deref with - #if EXTENSIONTYPING +#if EXTENSIONTYPING | ProvidedTypeMetadata info -> info.IsDelegate () - #endif +#endif | ILTypeMetadata (TILObjectReprData(_,_,td)) -> (td.tdKind = ILTypeDefKind.Delegate) | FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.IsFSharpDelegateTycon @@ -405,24 +439,28 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member x.DeclaredInterfaces = if isUnresolved() then makeReadOnlyCollection [] else - [ for ty in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 (generalizedTyconRef entity) do - yield FSharpType(cenv, ty) ] + ErrorLogger.protectAssemblyExploration [] (fun () -> + [ for ty in GetImmediateInterfacesOfType SkipUnrefInterfaces.Yes cenv.g cenv.amap range0 (generalizedTyconRef entity) do + yield FSharpType(cenv, ty) ]) |> makeReadOnlyCollection member x.AllInterfaces = if isUnresolved() then makeReadOnlyCollection [] else - [ for ty in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes (generalizedTyconRef entity) do - yield FSharpType(cenv, ty) ] + ErrorLogger.protectAssemblyExploration [] (fun () -> + [ for ty in AllInterfacesOfType cenv.g cenv.amap range0 AllowMultiIntfInstantiations.Yes (generalizedTyconRef entity) do + yield FSharpType(cenv, ty) ]) |> makeReadOnlyCollection member x.IsAttributeType = if isUnresolved() then false else let ty = generalizedTyconRef entity + ErrorLogger.protectAssemblyExploration false <| fun () -> Infos.ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_Attribute member x.IsDisposableType = if isUnresolved() then false else let ty = generalizedTyconRef entity + ErrorLogger.protectAssemblyExploration false <| fun () -> Infos.ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_IDisposable member x.BaseType = @@ -443,7 +481,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = let createMember (minfo : MethInfo) = if minfo.IsConstructor then FSharpMemberOrFunctionOrValue(cenv, C minfo, Item.CtorGroup (minfo.DisplayName, [minfo])) else FSharpMemberOrFunctionOrValue(cenv, M minfo, Item.MethodGroup (minfo.DisplayName, [minfo], None)) - if x.IsFSharpAbbreviation then + if x.IsFSharpAbbreviation then () elif x.IsFSharp then // For F# code we emit methods members in declaration order @@ -492,14 +530,14 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member x.StaticParameters = match entity.TypeReprInfo with - #if EXTENSIONTYPING +#if EXTENSIONTYPING | TProvidedTypeExtensionPoint info -> let m = x.DeclarationLocation let typeBeforeArguments = info.ProvidedType let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments,provider) -> typeBeforeArguments.GetStaticParameters(provider)), range=m) let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m) [| for p in staticParameters -> FSharpStaticParameter(cenv, p, m) |] - #endif +#endif | _ -> [| |] |> makeReadOnlyCollection @@ -551,16 +589,35 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) = member __.AllCompilationPaths = checkIsResolved() - let (CompilationPath.CompPath(_, parts)) = entity.CompilationPath - ([], parts) ||> List.fold (fun res (part, kind) -> - let parts = - match kind with - | ModuleOrNamespaceKind.FSharpModuleWithSuffix -> - [part; part.[..part.Length - 7]] - | _ -> [part] - - parts |> List.collect (fun part -> - res |> List.map (fun path -> path + "." + part))) + let (CompPath(_, parts)) = entity.CompilationPath + let partsList = + [ yield parts + match parts with + | ("Microsoft", ModuleOrNamespaceKind.Namespace) :: rest when isDefinedInFSharpCore() -> yield rest + | _ -> ()] + + let mapEachCurrentPath (paths: string list list) path = + match paths with + | [] -> [[path]] + | _ -> paths |> List.map (fun x -> path :: x) + + let walkParts (parts: (string * ModuleOrNamespaceKind) list) = //: string list list = + let rec loop (currentPaths: string list list) parts = + match parts with + | [] -> currentPaths + | (name: string, kind) :: rest -> + match kind with + | ModuleOrNamespaceKind.FSharpModuleWithSuffix -> + [ yield! loop (mapEachCurrentPath currentPaths name) rest + yield! loop (mapEachCurrentPath currentPaths (name.[..name.Length - 7])) rest ] + | _ -> + loop (mapEachCurrentPath currentPaths name) rest + loop [] parts |> List.map (List.rev >> String.concat ".") + + let res = + [ for parts in partsList do + yield! walkParts parts ] + res override x.Equals(other : obj) = box x === other || @@ -618,7 +675,7 @@ and FSharpUnionCase(cenv, v: UnionCaseRef) = member __.XmlDocSig = checkIsResolved() let unionCase = UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange,v) - match ItemDescriptionsImpl.GetXmlDocSigOfUnionCaseInfo unionCase with + match SymbolHelpers.GetXmlDocSigOfUnionCaseInfo unionCase with | Some (_, docsig) -> docsig | _ -> "" @@ -744,12 +801,12 @@ and FSharpField(cenv: cenv, d: FSharpFieldData) = match d with | RecdOrClass v -> let recd = RecdFieldInfo(generalizeTypars v.TyconRef.TyparsNoRange,v) - ItemDescriptionsImpl.GetXmlDocSigOfRecdFieldInfo recd + SymbolHelpers.GetXmlDocSigOfRecdFieldInfo recd | Union (v,_) -> let unionCase = UnionCaseInfo(generalizeTypars v.TyconRef.TyparsNoRange,v) - ItemDescriptionsImpl.GetXmlDocSigOfUnionCaseInfo unionCase + SymbolHelpers.GetXmlDocSigOfUnionCaseInfo unionCase | ILField (_,f) -> - ItemDescriptionsImpl.GetXmlDocSigOfILFieldInfo cenv.infoReader range0 f + SymbolHelpers.GetXmlDocSigOfILFieldInfo cenv.infoReader range0 f match xmlsig with | Some (_, docsig) -> docsig | _ -> "" @@ -855,7 +912,7 @@ and FSharpActivePatternCase(cenv, apinfo: PrettyNaming.ActivePatternInfo, typ, n member __.XmlDocSig = let xmlsig = match valOpt with - | Some valref -> ItemDescriptionsImpl.GetXmlDocSigOfValRef cenv.g valref + | Some valref -> SymbolHelpers.GetXmlDocSigOfValRef cenv.g valref | None -> None match xmlsig with | Some (_, docsig) -> docsig @@ -1101,6 +1158,7 @@ and FSharpInlineAnnotation = | AlwaysInline | OptionalInline | NeverInline + | AggressiveInline and FSharpMemberOrValData = | E of EventInfo @@ -1284,13 +1342,13 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = member __.EnclosingEntity = checkIsResolved() match d with - | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) - | P m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) - | M m | C m -> FSharpEntity(cenv, m.DeclaringEntityRef) + | E m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) |> Some + | P m -> FSharpEntity(cenv, tcrefOfAppTy cenv.g m.EnclosingType) |> Some + | M m | C m -> FSharpEntity(cenv, m.DeclaringEntityRef) |> Some | V v -> match v.ActualParent with - | ParentNone -> invalidOp "the value or member doesn't have an enclosing entity" - | Parent p -> FSharpEntity(cenv, p) + | ParentNone -> None + | Parent p -> FSharpEntity(cenv, p) |> Some member __.IsCompilerGenerated = if isUnresolved() then false else @@ -1520,23 +1578,23 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match d with | E e -> let range = defaultArg __.DeclarationLocationOpt range0 - match ItemDescriptionsImpl.GetXmlDocSigOfEvent cenv.infoReader range e with + match SymbolHelpers.GetXmlDocSigOfEvent cenv.infoReader range e with | Some (_, docsig) -> docsig | _ -> "" | P p -> let range = defaultArg __.DeclarationLocationOpt range0 - match ItemDescriptionsImpl.GetXmlDocSigOfProp cenv.infoReader range p with + match SymbolHelpers.GetXmlDocSigOfProp cenv.infoReader range p with | Some (_, docsig) -> docsig | _ -> "" | M m | C m -> let range = defaultArg __.DeclarationLocationOpt range0 - match ItemDescriptionsImpl.GetXmlDocSigOfMethInfo cenv.infoReader range m with + match SymbolHelpers.GetXmlDocSigOfMethInfo cenv.infoReader range m with | Some (_, docsig) -> docsig | _ -> "" | V v -> match v.ActualParent with | Parent entityRef -> - match ItemDescriptionsImpl.GetXmlDocSigOfScopedValRef cenv.g entityRef v with + match SymbolHelpers.GetXmlDocSigOfScopedValRef cenv.g entityRef v with | Some (_, docsig) -> docsig | _ -> "" | ParentNone -> "" @@ -1699,7 +1757,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match e with | ILEvent (_,x) -> let ilAccess = AccessibilityLogic.GetILAccessOfILEventInfo x - getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Entity ilAccess + getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess | _ -> taccessPublic FSharpAccessibility(access) @@ -1710,7 +1768,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match p with | ILProp (_,x) -> let ilAccess = AccessibilityLogic.GetILAccessOfILPropInfo x - getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Entity ilAccess + getApproxFSharpAccessibilityOfMember this.EnclosingEntity.Value.Entity ilAccess | _ -> taccessPublic FSharpAccessibility(access) @@ -1910,8 +1968,8 @@ and FSharpType(cenv, typ:TType) = "type " + NicePrint.prettyStringOfTyNoCx (DisplayEnv.Empty(cenv.g)) typ static member Prettify(typ: FSharpType) = - let t = PrettyTypes.PrettifyTypes1 typ.cenv.g typ.V |> p23 - typ.AdjustType t + let ty = PrettyTypes.PrettifyType typ.cenv.g typ.V |> fst + typ.AdjustType ty static member Prettify(typs: IList) = let xs = typs |> List.ofSeq @@ -1919,12 +1977,12 @@ and FSharpType(cenv, typ:TType) = | [] -> [] | h :: _ -> let cenv = h.cenv - let prettyTyps = PrettyTypes.PrettifyTypesN cenv.g [ for t in xs -> t.V ] |> p23 + let prettyTyps = PrettyTypes.PrettifyTypes cenv.g [ for t in xs -> t.V ] |> fst (xs, prettyTyps) ||> List.map2 (fun p pty -> p.AdjustType(pty)) |> makeReadOnlyCollection static member Prettify(parameter: FSharpParameter) = - let prettyTyp = parameter.V |> PrettyTypes.PrettifyTypes1 parameter.cenv.g |> p23 + let prettyTyp = parameter.V |> PrettyTypes.PrettifyType parameter.cenv.g |> fst parameter.AdjustType(prettyTyp) static member Prettify(parameters: IList) = @@ -1933,7 +1991,7 @@ and FSharpType(cenv, typ:TType) = | [] -> [] | h :: _ -> let cenv = h.cenv - let prettyTyps = parameters |> List.map (fun p -> p.V) |> PrettyTypes.PrettifyTypesN cenv.g |> p23 + let prettyTyps = parameters |> List.map (fun p -> p.V) |> PrettyTypes.PrettifyTypes cenv.g |> fst (parameters, prettyTyps) ||> List.map2 (fun p pty -> p.AdjustType(pty)) |> makeReadOnlyCollection @@ -1944,14 +2002,14 @@ and FSharpType(cenv, typ:TType) = | None -> xs | Some h -> let cenv = h.cenv - let prettyTyps = xs |> List.mapSquared (fun p -> p.V) |> PrettyTypes.PrettifyTypesNN cenv.g |> p23 + let prettyTyps = xs |> List.mapSquared (fun p -> p.V) |> PrettyTypes.PrettifyCurriedTypes cenv.g |> fst (xs, prettyTyps) ||> List.map2 (List.map2 (fun p pty -> p.AdjustType(pty))) |> List.map makeReadOnlyCollection |> makeReadOnlyCollection static member Prettify(parameters: IList>, returnParameter: FSharpParameter) = let xs = parameters |> List.ofSeq |> List.map List.ofSeq let cenv = returnParameter.cenv - let prettyTyps, prettyRetTy = xs |> List.mapSquared (fun p -> p.V) |> (fun tys -> PrettyTypes.PrettifyTypesNN1 cenv.g (tys,returnParameter.V) )|> p23 + let prettyTyps, prettyRetTy = xs |> List.mapSquared (fun p -> p.V) |> (fun tys -> PrettyTypes.PrettifyCurriedSigTypes cenv.g (tys,returnParameter.V) )|> fst let ps = (xs, prettyTyps) ||> List.map2 (List.map2 (fun p pty -> p.AdjustType(pty))) |> List.map makeReadOnlyCollection |> makeReadOnlyCollection ps, returnParameter.AdjustType(prettyRetTy) @@ -2089,6 +2147,18 @@ and FSharpAssemblySignature private (cenv, topAttribs: TypeChecker.TopAttribs op tA.assemblyAttrs |> List.map (fun a -> FSharpAttribute(cenv, AttribInfo.FSAttribInfo(cenv.g, a))) |> makeReadOnlyCollection + member __.FindEntityByPath path = + let inline findNested name = function + | Some (e : Entity) when e.IsModuleOrNamespace -> + e.ModuleOrNamespaceType.AllEntitiesByCompiledAndLogicalMangledNames.TryFind name + | _ -> None + + match path with + | hd :: tl -> + List.fold (fun a x -> findNested x a) (mtyp.AllEntitiesByCompiledAndLogicalMangledNames.TryFind hd) tl + |> Option.map (fun e -> FSharpEntity(cenv, rescopeEntity optViewedCcu e)) + | _ -> None + override x.ToString() = "" and FSharpAssembly internal (cenv, ccu: CcuThunk) = @@ -2188,3 +2258,26 @@ type FSharpSymbol with | :? FSharpUnionCase as x -> Some x.Accessibility | :? FSharpMemberFunctionOrValue as x -> Some x.Accessibility | _ -> None + +[] +type FSharpSymbolUse(g:TcGlobals, denv: DisplayEnv, symbol:FSharpSymbol, itemOcc, range: range) = + member __.Symbol = symbol + member __.DisplayContext = FSharpDisplayContext(fun _ -> denv) + member x.IsDefinition = x.IsFromDefinition + member __.IsFromDefinition = (match itemOcc with ItemOccurence.Binding -> true | _ -> false) + member __.IsFromPattern = (match itemOcc with ItemOccurence.Pattern -> true | _ -> false) + member __.IsFromType = (match itemOcc with ItemOccurence.UseInType -> true | _ -> false) + member __.IsFromAttribute = (match itemOcc with ItemOccurence.UseInAttribute -> true | _ -> false) + member __.IsFromDispatchSlotImplementation = (match itemOcc with ItemOccurence.Implemented -> true | _ -> false) + member __.IsFromComputationExpression = + match symbol.Item, itemOcc with + // 'seq' in 'seq { ... }' gets colored as keywords + | (Item.Value vref), ItemOccurence.Use when valRefEq g g.seq_vref vref -> true + // custom builders, custom operations get colored as keywords + | (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use -> true + | _ -> false + + member __.FileName = range.FileName + member __.Range = Range.toZ range + member __.RangeAlternate = range + diff --git a/src/fsharp/vs/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi similarity index 87% rename from src/fsharp/vs/Symbols.fsi rename to src/fsharp/symbols/Symbols.fsi index bb72e81875..752c322a55 100644 --- a/src/fsharp/vs/Symbols.fsi +++ b/src/fsharp/symbols/Symbols.fsi @@ -18,19 +18,46 @@ open Microsoft.FSharp.Compiler.CompileOps open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.TcGlobals +open Microsoft.FSharp.Compiler.NameResolution +// Implementation details used by other code in the compiler module internal Impl = type internal cenv = new : TcGlobals * thisCcu:CcuThunk * tcImports: TcImports -> cenv member amap: Import.ImportMap member g: TcGlobals +/// Indicates the accessibility of a symbol, as seen by the F# language +#if COMPILER_PUBLIC_API +type FSharpAccessibility = +#else +type internal FSharpAccessibility = +#endif + internal new: Accessibility * ?isProtected: bool -> FSharpAccessibility + + /// Indicates the symbol has public accessibility + member IsPublic : bool + + /// Indicates the symbol has private accessibility + member IsPrivate : bool + + /// Indicates the symbol has internal accessibility + member IsInternal : bool + + /// The underlying Accessibility + member internal Contents : Accessibility + + /// Represents the information needed to format types and other information in a style /// suitable for use in F# source text at a particular source location. /// /// Acquired via GetDisplayEnvAtLocationAlternate and similar methods. May be passed /// to the Format method on FSharpType and other methods. +#if COMPILER_PUBLIC_API type [] FSharpDisplayContext = +#else +type [] internal FSharpDisplayContext = +#endif internal new : denv: (TcGlobals -> Tastops.DisplayEnv) -> FSharpDisplayContext static member Empty: FSharpDisplayContext @@ -39,7 +66,11 @@ type [] FSharpDisplayContext = /// The subtype of the symbol may reveal further information and can be one of FSharpEntity, FSharpUnionCase /// FSharpField, FSharpGenericParameter, FSharpStaticParameter, FSharpMemberOrFunctionOrValue, FSharpParameter, /// or FSharpActivePatternCase. +#if COMPILER_PUBLIC_API type [] FSharpSymbol = +#else +type [] internal FSharpSymbol = +#endif /// Internal use only. static member internal Create : g:TcGlobals * thisCcu: CcuThunk * tcImports: TcImports * item:NameResolution.Item -> FSharpSymbol @@ -79,7 +110,11 @@ type [] FSharpSymbol = static member GetAccessibility : FSharpSymbol -> FSharpAccessibility option /// Represents an assembly as seen by the F# language +#if COMPILER_PUBLIC_API and [] FSharpAssembly = +#else +and [] internal FSharpAssembly = +#endif internal new : tcGlobals: TcGlobals * tcImports: TcImports * ccu: CcuThunk -> FSharpAssembly @@ -103,7 +138,11 @@ and [] FSharpAssembly = #endif /// Represents an inferred signature of part of an assembly as seen by the F# language +#if COMPILER_PUBLIC_API and [] FSharpAssemblySignature = +#else +and [] internal FSharpAssemblySignature = +#endif internal new : tcGlobals: TcGlobals * thisCcu: CcuThunk * tcImports: TcImports * topAttribs: TypeChecker.TopAttribs option * contents: ModuleOrNamespaceType -> FSharpAssemblySignature @@ -112,11 +151,18 @@ and [] FSharpAssemblySignature = /// Get the declared attributes for the assembly. /// Only available when parsing an entire project. - member Attributes: IList + member Attributes: IList + + /// Find entity using compiled names + member FindEntityByPath: string list -> FSharpEntity option /// A subtype of FSharpSymbol that represents a type definition or module as seen by the F# language +#if COMPILER_PUBLIC_API and [] FSharpEntity = +#else +and [] internal FSharpEntity = +#endif inherit FSharpSymbol internal new : Impl.cenv * EntityRef -> FSharpEntity @@ -258,6 +304,7 @@ and [] FSharpEntity = /// Get the properties, events and methods of a type definitions, or the functions and values of a module member MembersFunctionsAndValues : IList + [] member MembersOrValues : IList @@ -292,7 +339,11 @@ and [] FSharpEntity = member AllCompilationPaths : string list /// Represents a delegate signature in an F# symbol +#if COMPILER_PUBLIC_API and [] FSharpDelegateSignature = +#else +and [] internal FSharpDelegateSignature = +#endif /// Get the argument types of the delegate signature member DelegateArguments : IList @@ -300,7 +351,11 @@ and [] FSharpDelegateSignature = member DelegateReturnType : FSharpType /// Represents a parameter in an abstract method of a class or interface +#if COMPILER_PUBLIC_API and [] FSharpAbstractParameter = +#else +and [] internal FSharpAbstractParameter = +#endif /// The optional name of the parameter member Name : string option @@ -321,7 +376,11 @@ and [] FSharpAbstractParameter = member Attributes : IList /// Represents the signature of an abstract slot of a class or interface +#if COMPILER_PUBLIC_API and [] FSharpAbstractSignature = +#else +and [] internal FSharpAbstractSignature = +#endif internal new : Impl.cenv * SlotSig -> FSharpAbstractSignature /// Get the arguments of the abstract slot @@ -343,7 +402,11 @@ and [] FSharpAbstractSignature = member DeclaringType : FSharpType /// A subtype of FSharpSymbol that represents a union case as seen by the F# language +#if COMPILER_PUBLIC_API and [] FSharpUnionCase = +#else +and [] internal FSharpUnionCase = +#endif inherit FSharpSymbol internal new : Impl.cenv * UnionCaseRef -> FSharpUnionCase @@ -378,11 +441,13 @@ and [] FSharpUnionCase = member IsUnresolved : bool -/// Renamed to FSharpField -and [] FSharpRecordField = FSharpField /// A subtype of FSharpSymbol that represents a record or union case field as seen by the F# language +#if COMPILER_PUBLIC_API and [] FSharpField = +#else +and [] internal FSharpField = +#endif inherit FSharpSymbol internal new : Impl.cenv * RecdFieldRef -> FSharpField @@ -440,12 +505,20 @@ and [] FSharpField = member IsUnresolved : bool /// Represents the rights of a compilation to access symbols +#if COMPILER_PUBLIC_API and [] FSharpAccessibilityRights = +#else +and [] internal FSharpAccessibilityRights = +#endif internal new : CcuThunk * AccessorDomain -> FSharpAccessibilityRights member internal Contents : AccessorDomain /// A subtype of FSharpSymbol that represents a generic parameter for an FSharpSymbol +#if COMPILER_PUBLIC_API and [] FSharpGenericParameter = +#else +and [] internal FSharpGenericParameter = +#endif inherit FSharpSymbol internal new : Impl.cenv * Typar -> FSharpGenericParameter @@ -473,9 +546,15 @@ and [] FSharpGenericParameter = /// Get the declared or inferred constraints for the type parameter member Constraints: IList + + #if EXTENSIONTYPING /// A subtype of FSharpSymbol that represents a static parameter to an F# type provider +#if COMPILER_PUBLIC_API and [] FSharpStaticParameter = +#else +and [] internal FSharpStaticParameter = +#endif inherit FSharpSymbol @@ -499,8 +578,11 @@ and [] FSharpStaticParameter = #endif /// Represents further information about a member constraint on a generic type parameter -and [] - FSharpGenericParameterMemberConstraint = +#if COMPILER_PUBLIC_API +and [] FSharpGenericParameterMemberConstraint = +#else +and [] internal FSharpGenericParameterMemberConstraint = +#endif /// Get the types that may be used to satisfy the constraint member MemberSources : IList @@ -518,8 +600,11 @@ and [] member MemberReturnType : FSharpType /// Represents further information about a delegate constraint on a generic type parameter -and [] - FSharpGenericParameterDelegateConstraint = +#if COMPILER_PUBLIC_API +and [] FSharpGenericParameterDelegateConstraint = +#else +and [] internal FSharpGenericParameterDelegateConstraint = +#endif /// Get the tupled argument type required by the constraint member DelegateTupledArgumentType : FSharpType @@ -528,8 +613,11 @@ and [] member DelegateReturnType : FSharpType /// Represents further information about a 'defaults to' constraint on a generic type parameter -and [] - FSharpGenericParameterDefaultsToConstraint = +#if COMPILER_PUBLIC_API +and [] FSharpGenericParameterDefaultsToConstraint = +#else +and [] internal FSharpGenericParameterDefaultsToConstraint = +#endif /// Get the priority off the 'defaults to' constraint member DefaultsToPriority : int @@ -538,8 +626,11 @@ and [] member DefaultsToTarget : FSharpType /// Represents a constraint on a generic type parameter -and [] - FSharpGenericParameterConstraint = +#if COMPILER_PUBLIC_API +and [] FSharpGenericParameterConstraint = +#else +and [] internal FSharpGenericParameterConstraint = +#endif /// Indicates a constraint that a type is a subtype of the given type member IsCoercesToConstraint : bool @@ -598,23 +689,28 @@ and [] member DelegateConstraintData : FSharpGenericParameterDelegateConstraint +#if COMPILER_PUBLIC_API and [] FSharpInlineAnnotation = - /// Indictes the value is inlined and compiled code for the function does not exist +#else +and [] internal FSharpInlineAnnotation = +#endif + /// Indicates the value is inlined and compiled code for the function does not exist | PseudoValue - /// Indictes the value is inlined but compiled code for the function still exists, e.g. to satisfy interfaces on objects, but that it is also always inlined + /// Indicates the value is inlined but compiled code for the function still exists, e.g. to satisfy interfaces on objects, but that it is also always inlined | AlwaysInline - /// Indictes the value is optionally inlined + /// Indicates the value is optionally inlined | OptionalInline - /// Indictes the value is never inlined - | NeverInline - -/// Renamed to FSharpMemberOrFunctionOrValue -and [] FSharpMemberOrVal = FSharpMemberOrFunctionOrValue -/// Renamed to FSharpMemberOrFunctionOrValue -and [] FSharpMemberFunctionOrValue = FSharpMemberOrFunctionOrValue + /// Indicates the value is never inlined + | NeverInline + /// Indicates the value is aggressively inlined by the .NET runtime + | AggressiveInline /// A subtype of F# symbol that represents an F# method, property, event, function or value, including extension members. +#if COMPILER_PUBLIC_API and [] FSharpMemberOrFunctionOrValue = +#else +and [] internal FSharpMemberOrFunctionOrValue = +#endif inherit FSharpSymbol internal new : Impl.cenv * ValRef -> FSharpMemberOrFunctionOrValue @@ -624,7 +720,7 @@ and [] FSharpMemberOrFunctionOrValue = member IsUnresolved : bool /// Get the enclosing entity for the definition - member EnclosingEntity : FSharpEntity + member EnclosingEntity : FSharpEntity option /// Get the declaration location of the member, function or value member DeclarationLocation: range @@ -798,7 +894,11 @@ and [] FSharpMemberOrFunctionOrValue = /// A subtype of FSharpSymbol that represents a parameter +#if COMPILER_PUBLIC_API and [] FSharpParameter = +#else +and [] internal FSharpParameter = +#endif inherit FSharpSymbol /// The optional name of the parameter @@ -824,7 +924,12 @@ and [] FSharpParameter = /// A subtype of FSharpSymbol that represents a single case within an active pattern +#if COMPILER_PUBLIC_API and [] FSharpActivePatternCase = +#else +and [] internal FSharpActivePatternCase = +#endif + inherit FSharpSymbol /// The name of the active pattern case @@ -843,7 +948,11 @@ and [] FSharpActivePatternCase = member XmlDocSig: string /// Represents all cases within an active pattern +#if COMPILER_PUBLIC_API and [] FSharpActivePatternGroup = +#else +and [] internal FSharpActivePatternGroup = +#endif /// The names of the active pattern cases member Names: IList @@ -856,7 +965,11 @@ and [] FSharpActivePatternGroup = /// Try to get the enclosing entity of the active pattern member EnclosingEntity : FSharpEntity option +#if COMPILER_PUBLIC_API and [] FSharpType = +#else +and [] internal FSharpType = +#endif /// Internal use only. Create a ground type. internal new : g:TcGlobals * thisCcu: CcuThunk * tcImports: TcImports * typ:TType -> FSharpType internal new : Impl.cenv * typ:TType -> FSharpType @@ -940,8 +1053,12 @@ and [] FSharpType = /// Represents a custom attribute attached to F# source code or a compiler .NET component +#if COMPILER_PUBLIC_API and [] FSharpAttribute = - +#else +and [] internal FSharpAttribute = +#endif + /// The type of the attribute member AttributeType : FSharpEntity @@ -959,3 +1076,44 @@ and [] FSharpAttribute = +/// Represents the use of an F# symbol from F# source code +[] +#if COMPILER_PUBLIC_API +type FSharpSymbolUse = +#else +type internal FSharpSymbolUse = +#endif + // For internal use only + internal new : g:TcGlobals * denv: Tastops.DisplayEnv * symbol:FSharpSymbol * itemOcc:ItemOccurence * range: range -> FSharpSymbolUse + + /// The symbol referenced + member Symbol : FSharpSymbol + + /// The display context active at the point where the symbol is used. Can be passed to FSharpType.Format + /// and other methods to format items in a way that is suitable for a specific source code location. + member DisplayContext : FSharpDisplayContext + + /// Indicates if the reference is a definition for the symbol, either in a signature or implementation + member IsFromDefinition : bool + + /// Indicates if the reference is in a pattern + member IsFromPattern : bool + + /// Indicates if the reference is in a syntactic type + member IsFromType : bool + + /// Indicates if the reference is in an attribute + member IsFromAttribute : bool + + /// Indicates if the reference is via the member being implemented in a class or object expression + member IsFromDispatchSlotImplementation : bool + + /// Indicates if the reference is either a builder or a custom operation in a computation expression + member IsFromComputationExpression : bool + + /// The file name the reference occurs in + member FileName: string + + /// The range of text representing the reference to the symbol + member RangeAlternate: range + diff --git a/src/fsharp/tainted.fsi b/src/fsharp/tainted.fsi index 5e00f95b31..acba335957 100755 --- a/src/fsharp/tainted.fsi +++ b/src/fsharp/tainted.fsi @@ -17,15 +17,22 @@ type internal TypeProviderError = /// creates new instance of TypeProviderError that represents one error new : (int * string) * string * range -> TypeProviderError + /// creates new instance of TypeProviderError that represents collection of errors new : int * string * range * seq -> TypeProviderError + member Number : int + member Range : range + member ContextualErrorMessage : string + /// creates new instance of TypeProviderError with specified type\method names member WithContext : string * string -> TypeProviderError + /// creates new instance of TypeProviderError based on current instance information(message) member MapText : (string -> int * string) * string * range -> TypeProviderError + /// provides uniform way to process aggregated errors member Iter : (TypeProviderError -> unit) -> unit @@ -87,14 +94,18 @@ type internal Tainted<'T> = [] module internal Tainted = + /// Test whether the tainted value is null val (|Null|_|) : Tainted<'T> -> unit option when 'T : null + /// Test whether the tainted value equals given value. /// Failure in call to equality operation will be blamed on type provider of first operand val Eq : Tainted<'T> -> 'T -> bool when 'T : equality + /// Test whether the tainted value equals given value. Type providers are ignored (equal tainted values produced by different type providers are equal) /// Failure in call to equality operation will be blamed on type provider of first operand val EqTainted : Tainted<'T> -> Tainted<'T> -> bool when 'T : equality and 'T : not struct + /// Compute the hash value for the tainted value val GetHashCodeTainted : Tainted<'T> -> int when 'T : equality diff --git a/src/fsharp/tast.fs b/src/fsharp/tast.fs index 9e4ba56c5a..a224fb705f 100755 --- a/src/fsharp/tast.fs +++ b/src/fsharp/tast.fs @@ -14,7 +14,6 @@ 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.AbstractIL.Extensions.ILX.Types open Microsoft.FSharp.Compiler @@ -34,8 +33,10 @@ open Microsoft.FSharp.Core.CompilerServices /// Unique name generator for stamps attached to lambdas and object expressions type Unique = int64 + //++GLOBAL MUTABLE STATE (concurrency-safe) let newUnique = let i = ref 0L in fun () -> System.Threading.Interlocked.Increment(i) + type Stamp = int64 /// Unique name generator for stamps attached to to val_specs, tycon_specs etc. @@ -2420,6 +2421,11 @@ and [] match x.ActualParent with | Parent tcref -> tcref | ParentNone -> error(InternalError("TopValActualParent: does not have a parent",x.Range)) + + member x.HasTopValActualParent = + match x.ActualParent with + | Parent _ -> true + | ParentNone -> false /// Get the apparent parent entity for a member member x.MemberApparentParent : TyconRef = @@ -3369,6 +3375,9 @@ and /// is declared. member x.TopValActualParent = x.Deref.TopValActualParent + // Can be false for members after error recovery + member x.HasTopValActualParent = x.Deref.HasTopValActualParent + /// Get the apparent parent entity for a member member x.MemberApparentParent = x.Deref.MemberApparentParent @@ -3723,20 +3732,25 @@ and CcuThunk = /// Fixup a CCU to have the given contents member x.Fixup(avail:CcuThunk) = + match box x.target with - | null -> - assert (avail.AssemblyName = x.AssemblyName) - x.target <- - (match box avail.target with - | null -> error(Failure("internal error: ccu thunk '"+avail.name+"' not fixed up!")) - | _ -> avail.target) - | _ -> errorR(Failure("internal error: the ccu thunk for assembly "+x.AssemblyName+" not delayed!")) + | null -> () + | _ -> + // In the IDE we tolerate a double-fixup of FSHarp.Core when editing the FSharp.Core project itself + if x.AssemblyName <> "FSharp.Core" then + errorR(Failure("internal error: Fixup: the ccu thunk for assembly "+x.AssemblyName+" not delayed!")) + + assert (avail.AssemblyName = x.AssemblyName) + x.target <- + match box avail.target with + | null -> error(Failure("internal error: ccu thunk '"+avail.name+"' not fixed up!")) + | _ -> avail.target /// Fixup a CCU to record it as "orphaned", i.e. not available member x.FixupOrphaned() = match box x.target with | null -> x.orphanfixup<-true - | _ -> errorR(Failure("internal error: the ccu thunk for assembly "+x.AssemblyName+" not delayed!")) + | _ -> errorR(Failure("internal error: FixupOrphaned: the ccu thunk for assembly "+x.AssemblyName+" not delayed!")) /// Try to resolve a path into the CCU by referencing the .NET/CLI type forwarder table of the CCU member ccu.TryForward(nlpath:string[],item:string) : EntityRef option = diff --git a/src/fsharp/vs/ExternalSymbol.fs b/src/fsharp/vs/ExternalSymbol.fs new file mode 100644 index 0000000000..11aad06d14 --- /dev/null +++ b/src/fsharp/vs/ExternalSymbol.fs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp.Compiler.SourceCodeServices + +open FSharp.Reflection +open Microsoft.FSharp.Compiler.AbstractIL.IL +open System.Diagnostics + +module private Option = + + let ofOptionList (xs : 'a option list) : 'a list option = + + if xs |> List.forall Option.isSome then + xs |> List.map Option.get |> Some + else + None + +/// Represents a type in an external (non F#) assembly. +[] +type ExternalType = + /// Type defined in non-F# assembly. + | Type of fullName: string * genericArgs: ExternalType list + /// Array of type that is defined in non-F# assembly. + | Array of inner: ExternalType + /// Pointer defined in non-F# assembly. + | Pointer of inner: ExternalType + /// Type variable defined in non-F# assembly. + | TypeVar of typeName: string + override this.ToString() = + match this with + | Type (name, genericArgs) -> + match genericArgs with + | [] -> "" + | args -> + args + |> List.map (sprintf "%O") + |> String.concat ", " + |> sprintf "<%s>" + |> sprintf "%s%s" name + | Array inner -> sprintf "%O[]" inner + | Pointer inner -> sprintf "&%O" inner + | TypeVar name -> sprintf "'%s" name + +module ExternalType = + let rec internal tryOfILType (typeVarNames: string array) (ilType: ILType) = + + match ilType with + | ILType.Array (_, inner) -> + tryOfILType typeVarNames inner |> Option.map ExternalType.Array + | ILType.Boxed tyspec + | ILType.Value tyspec -> + tyspec.GenericArgs + |> List.map (tryOfILType typeVarNames) + |> Option.ofOptionList + |> Option.map (fun genericArgs -> ExternalType.Type (tyspec.FullName, genericArgs)) + | ILType.Ptr inner -> + tryOfILType typeVarNames inner |> Option.map ExternalType.Pointer + | ILType.TypeVar ordinal -> + typeVarNames + |> Array.tryItem (int ordinal) + |> Option.map (fun typeVarName -> ExternalType.TypeVar typeVarName) + | _ -> + None + +[] +type ParamTypeSymbol = + | Param of ExternalType + | Byref of ExternalType + override this.ToString () = + match this with + | Param t -> t.ToString() + | Byref t -> sprintf "ref %O" t + +module ParamTypeSymbol = + let rec internal tryOfILType (typeVarNames : string array) = + function + | ILType.Byref inner -> ExternalType.tryOfILType typeVarNames inner |> Option.map ParamTypeSymbol.Byref + | ilType -> ExternalType.tryOfILType typeVarNames ilType |> Option.map ParamTypeSymbol.Param + + let internal tryOfILTypes typeVarNames ilTypes = + ilTypes |> List.map (tryOfILType typeVarNames) |> Option.ofOptionList + +[] +[] +type ExternalSymbol = + | Type of fullName: string + | Constructor of typeName: string * args: ParamTypeSymbol list + | Method of typeName: string * name: string * paramSyms: ParamTypeSymbol list * genericArity: int + | Field of typeName: string * name: string + | Event of typeName: string * name: string + | Property of typeName: string * name: string + override this.ToString () = + match this with + | Type fullName -> fullName + | Constructor (typeName, args) -> + args + |> List.map (sprintf "%O") + |> String.concat ", " + |> sprintf "%s..ctor(%s)" typeName + | Method (typeName, name, args, genericArity) -> + let genericAritySuffix = + if genericArity > 0 then sprintf "`%d" genericArity + else "" + + args + |> List.map (sprintf "%O") + |> String.concat ", " + |> sprintf "%s.%s%s(%s)" typeName name genericAritySuffix + | Field (typeName, name) + | Event (typeName, name) + | Property (typeName, name) -> + sprintf "%s.%s" typeName name + + member internal this.ToDebuggerDisplay () = + let caseInfo, _ = FSharpValue.GetUnionFields(this, typeof) + sprintf "%s %O" caseInfo.Name this diff --git a/src/fsharp/vs/ExternalSymbol.fsi b/src/fsharp/vs/ExternalSymbol.fsi new file mode 100644 index 0000000000..7f65141abd --- /dev/null +++ b/src/fsharp/vs/ExternalSymbol.fsi @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.FSharp.Compiler.SourceCodeServices + +open FSharp.Reflection +open Microsoft.FSharp.Compiler.AbstractIL.IL + +/// Represents a type in an external (non F#) assembly. +[] +type ExternalType = + /// Type defined in non-F# assembly. + | Type of fullName: string * genericArgs: ExternalType list + /// Array of type that is defined in non-F# assembly. + | Array of inner: ExternalType + /// Pointer defined in non-F# assembly. + | Pointer of inner: ExternalType + /// Type variable defined in non-F# assembly. + | TypeVar of typeName: string + override ToString : unit -> string + +module ExternalType = + val internal tryOfILType : string array -> ILType -> ExternalType option + + +/// Represents the type of a single method parameter +[] +type ParamTypeSymbol = + | Param of ExternalType + | Byref of ExternalType + override ToString : unit -> string + +module ParamTypeSymbol = + val internal tryOfILType : string array -> ILType -> ParamTypeSymbol option + val internal tryOfILTypes : string array -> ILType list -> ParamTypeSymbol list option + + +/// Represents a symbol in an external (non F#) assembly +[] +type ExternalSymbol = + | Type of fullName: string + | Constructor of typeName: string * args: ParamTypeSymbol list + | Method of typeName: string * name: string * paramSyms: ParamTypeSymbol list * genericArity: int + | Field of typeName: string * name: string + | Event of typeName: string * name: string + | Property of typeName: string * name: string + override ToString : unit -> string + member internal ToDebuggerDisplay : unit -> string \ No newline at end of file diff --git a/src/fsharp/vs/IncrementalBuild.fs b/src/fsharp/vs/IncrementalBuild.fs index d3e4431ff0..aacd2e17b6 100755 --- a/src/fsharp/vs/IncrementalBuild.fs +++ b/src/fsharp/vs/IncrementalBuild.fs @@ -23,6 +23,7 @@ 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 Internal.Utilities open Internal.Utilities.Collections @@ -952,7 +953,6 @@ module internal IncrementalBuild = Demultiplex taskname (fun _ctok x -> cancellable.Return x) input let VectorInput(node:Vector<'T>, values: 'T list) = (node.Name, values.Length, List.map box values) - let ScalaInput(node:Scalar<'T>, value: 'T) = (node.Name, box value) /// Declare build outputs and bind them to real values. type BuildDescriptionScope() = @@ -968,100 +968,6 @@ module internal IncrementalBuild = ToBound(ToBuild outputs,inputs) -[] -type FSharpErrorSeverity = - | Warning - | Error - -type FSharpErrorInfo(fileName, s:pos, e:pos, severity: FSharpErrorSeverity, message: string, subcategory: string, errorNum: int) = - member __.StartLine = Line.toZ s.Line - member __.StartLineAlternate = s.Line - member __.EndLine = Line.toZ e.Line - member __.EndLineAlternate = e.Line - member __.StartColumn = s.Column - member __.EndColumn = e.Column - member __.Severity = severity - member __.Message = message - member __.Subcategory = subcategory - member __.FileName = fileName - member __.ErrorNumber = errorNum - member __.WithStart(newStart) = FSharpErrorInfo(fileName, newStart, e, severity, message, subcategory, errorNum) - member __.WithEnd(newEnd) = FSharpErrorInfo(fileName, s, newEnd, severity, message, subcategory, errorNum) - override __.ToString()= sprintf "%s (%d,%d)-(%d,%d) %s %s %s" fileName (int s.Line) (s.Column + 1) (int e.Line) (e.Column + 1) subcategory (if severity=FSharpErrorSeverity.Warning then "warning" else "error") message - - /// Decompose a warning or error into parts: position, severity, message, error number - static member (*internal*) CreateFromException(exn, isError, trim:bool, fallbackRange:range) = - let m = match GetRangeOfDiagnostic exn with Some m -> m | None -> fallbackRange - let e = if trim then m.Start else m.End - let msg = bufs (fun buf -> OutputPhasedDiagnostic buf exn false) - let errorNum = GetDiagnosticNumber exn - FSharpErrorInfo(m.FileName, m.Start, e, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning), msg, exn.Subcategory(), errorNum) - - /// Decompose a warning or error into parts: position, severity, message, error number - static member internal CreateFromExceptionAndAdjustEof(exn, isError, trim:bool, fallbackRange:range, (linesCount:int, lastLength:int)) = - let r = FSharpErrorInfo.CreateFromException(exn,isError,trim,fallbackRange) - - // Adjust to make sure that errors reported at Eof are shown at the linesCount - let startline, schange = min (r.StartLineAlternate, false) (linesCount, true) - let endline, echange = min (r.EndLineAlternate, false) (linesCount, true) - - if not (schange || echange) then r - else - let r = if schange then r.WithStart(mkPos startline lastLength) else r - if echange then r.WithEnd(mkPos endline (1 + lastLength)) else r - - -/// Use to reset error and warning handlers -[] -type ErrorScope() = - let mutable errors = [] - static let mutable mostRecentError = None - let unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.TypeCheck - let unwindEL = - PushErrorLoggerPhaseUntilUnwind (fun _oldLogger -> - { new ErrorLogger("ErrorScope") with - member x.DiagnosticSink(exn, isError) = - let err = FSharpErrorInfo.CreateFromException(exn,isError,false,range.Zero) - errors <- err :: errors - if isError then - mostRecentError <- Some err - member x.ErrorCount = errors.Length }) - - member x.Errors = errors |> List.filter (fun error -> error.Severity = FSharpErrorSeverity.Error) - member x.Warnings = errors |> List.filter (fun error -> error.Severity = FSharpErrorSeverity.Warning) - member x.Diagnostics = errors - member x.TryGetFirstErrorText() = - match x.Errors with - | error :: _ -> Some error.Message - | [] -> None - - interface IDisposable with - member d.Dispose() = - unwindEL.Dispose() (* unwind pushes when ErrorScope disposes *) - unwindBP.Dispose() - - static member MostRecentError = mostRecentError - - static member Protect<'a> (m:range) (f:unit->'a) (err:string->'a): 'a = - use errorScope = new ErrorScope() - let res = - try - Some (f()) - with e -> errorRecovery e m; None - match res with - | Some res ->res - | None -> - match errorScope.TryGetFirstErrorText() with - | Some text -> err text - | None -> err "" - - static member ProtectWithDefault m f dflt = - ErrorScope.Protect m f (fun _ -> dflt) - - static member ProtectAndDiscard m f = - ErrorScope.Protect m f (fun _ -> ()) - - // Record the most recent IncrementalBuilder events, so we can more easily unittest/debug the @@ -1131,7 +1037,7 @@ type FrameworkImportsCacheKey = (*resolvedpath*)string list * string * (*TargetF type FrameworkImportsCache(keepStrongly) = // Mutable collection protected via CompilationThreadToken - let frameworkTcImportsCache = AgedLookup(keepStrongly, areSame=(fun (x,y) -> x = y)) + let frameworkTcImportsCache = AgedLookup(keepStrongly, areSimilar=(fun (x,y) -> x = y)) member __.Downsize(ctok) = frameworkTcImportsCache.Resize(ctok, keepStrongly=0) member __.Clear(ctok) = frameworkTcImportsCache.Clear(ctok) @@ -1169,38 +1075,6 @@ type FrameworkImportsCache(keepStrongly) = return tcGlobals,frameworkTcImports,nonFrameworkResolutions,unresolved } -/// An error logger that capture errors, filtering them according to warning levels etc. -type internal CompilationErrorLogger (debugName:string, tcConfig:TcConfig) = - inherit ErrorLogger("CompilationErrorLogger("+debugName+")") - - let mutable errorCount = 0 - let diagnostics = new ResizeArray<_>() - - override x.DiagnosticSink(exn, isError) = - if isError || ReportWarningAsError (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn, tcConfig.specificWarnAsError, tcConfig.specificWarnAsWarn, tcConfig.globalWarnAsError) exn then - diagnostics.Add(exn, isError) - errorCount <- errorCount + 1 - else if ReportWarning (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn) exn then - diagnostics.Add(exn, isError) - - override x.ErrorCount = errorCount - - member x.GetErrors() = - [ for (e,isError) in diagnostics -> e, (if isError then FSharpErrorSeverity.Error else FSharpErrorSeverity.Warning) ] - - -/// This represents the global state established as each task function runs as part of the build. -/// -/// Use to reset error and warning handlers. -type CompilationGlobalsScope(errorLogger:ErrorLogger, phase: BuildPhase) = - let unwindEL = PushErrorLoggerPhaseUntilUnwind(fun _ -> errorLogger) - let unwindBP = PushThreadBuildPhaseUntilUnwind phase - // Return the disposable object that cleans up - interface IDisposable with - member d.Dispose() = - unwindBP.Dispose() - unwindEL.Dispose() - //------------------------------------------------------------------------------------ // Rules for reactive building. @@ -1568,7 +1442,7 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs // 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) - if hasTypeProviderAssemblyAttrib then + if tcState.CreatesGeneratedProvidedTypes || hasTypeProviderAssemblyAttrib then None else Some (RawFSharpAssemblyDataBackedByLanguageService (tcConfig,tcGlobals,tcState,outfile,topAttrs,assemblyName,ilAssemRef) :> IRawFSharpAssemblyData) @@ -1628,6 +1502,8 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs // END OF BUILD DESCRIPTION // --------------------------------------------------------------------------------------------- + do IncrementalBuilderEventTesting.MRU.Add(IncrementalBuilderEventTesting.IBECreated) + let buildInputs = [ BuildInput.VectorInput (fileNamesNode, sourceFiles) BuildInput.VectorInput (referencedAssembliesNode, nonFrameworkAssemblyInputs) ] @@ -1686,7 +1562,7 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs return true } - member builder.GetCheckResultsBeforeFileInProjectIfReady (filename): PartialCheckResults option = + member builder.GetCheckResultsBeforeFileInProjectEvenIfStale (filename): PartialCheckResults option = let slotOfFile = builder.GetSlotOfFileName filename let result = match slotOfFile with @@ -1800,11 +1676,11 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs #endif } - member __.ProjectFileNames = sourceFiles |> List.map (fun (_,f,_) -> f) + 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, referenceResolver, frameworkTcImportsCache: FrameworkImportsCache, loadClosureOpt:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, keepAssemblyContents, keepAllBackgroundResolutions, maxTimeShareMilliseconds) = + static member TryCreateBackgroundBuilderForProjectOptions (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, frameworkTcImportsCache: FrameworkImportsCache, loadClosureOpt:LoadClosure option, sourceFiles:string list, commandLineArgs:string list, projectReferences, projectDirectory, useScriptResolutionRules, keepAssemblyContents, keepAllBackgroundResolutions, maxTimeShareMilliseconds) = cancellable { // Trap and report warnings and errors from creation. @@ -1819,26 +1695,21 @@ type IncrementalBuilder(tcGlobals,frameworkTcImports, nonFrameworkAssemblyInputs /// Create a type-check configuration let tcConfigB, sourceFilesNew = - let defaultFSharpBinariesDir = Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(None).Value // see also fsc.fs:runFromCommandLineToImportingAssemblies(), as there are many similarities to where the PS creates a tcConfigB - let tcConfigB = - TcConfigBuilder.CreateNew(referenceResolver, defaultFSharpBinariesDir, implicitIncludeDir=projectDirectory, - optimizeForMemory=true, isInteractive=false, isInvalidationSupported=true) + let tcConfigB = TcConfigBuilder.CreateNew(legacyReferenceResolver, defaultFSharpBinariesDir, implicitIncludeDir=projectDirectory, optimizeForMemory=true, isInteractive=false, isInvalidationSupported=true, defaultCopyFSharpCore=false) // The following uses more memory but means we don't take read-exclusions on the DLLs we reference // Could detect well-known assemblies--ie System.dll--and open them with read-locks tcConfigB.openBinariesInMemory <- true - tcConfigB.resolutionEnvironment - <- if useScriptResolutionRules - then ReferenceResolver.DesignTimeLike - else ReferenceResolver.CompileTimeLike + + tcConfigB.resolutionEnvironment <- (ReferenceResolver.ResolutionEnvironment.EditingOrCompilation true) tcConfigB.conditionalCompilationDefines <- let define = if useScriptResolutionRules then "INTERACTIVE" else "COMPILED" define::tcConfigB.conditionalCompilationDefines tcConfigB.projectReferences <- projectReferences -#if TODO_REWORK_ASSEMBLY_LOAD +#if COMPILER_SERVICE_ASSUMES_DOTNETCORE_COMPILATION tcConfigB.useSimpleResolution <- true // turn off msbuild resolution #endif // Apply command-line arguments and collect more source files if they are in the arguments diff --git a/src/fsharp/vs/IncrementalBuild.fsi b/src/fsharp/vs/IncrementalBuild.fsi index 078eb5ef3d..2af0354aeb 100755 --- a/src/fsharp/vs/IncrementalBuild.fsi +++ b/src/fsharp/vs/IncrementalBuild.fsi @@ -14,36 +14,7 @@ open Microsoft.FSharp.Compiler.TcGlobals open Microsoft.FSharp.Compiler.CompileOps open Microsoft.FSharp.Compiler.NameResolution open Microsoft.FSharp.Compiler.Tast - - -[] -type (*internal*) FSharpErrorSeverity = - | Warning - | Error - -[] -type (*internal*) FSharpErrorInfo = - member FileName: string - member StartLineAlternate:int - member EndLineAlternate:int - member StartColumn:int - member EndColumn:int - member Severity:FSharpErrorSeverity - member Message:string - member Subcategory:string - member ErrorNumber:int - static member internal CreateFromExceptionAndAdjustEof : PhasedDiagnostic * isError: bool * trim: bool * range * lastPosInFile:(int*int) -> FSharpErrorInfo - static member internal CreateFromException : PhasedDiagnostic * isError: bool * trim: bool * range -> FSharpErrorInfo - -// Implementation details used by other code in the compiler -[] -type internal ErrorScope = - interface IDisposable - new : unit -> ErrorScope - member Diagnostics : FSharpErrorInfo list - static member Protect<'a> : range -> (unit->'a) -> (string->'a) -> 'a - static member ProtectWithDefault<'a> : range -> (unit -> 'a) -> 'a -> 'a - static member ProtectAndDiscard : range -> (unit -> unit) -> unit +open Microsoft.FSharp.Compiler.SourceCodeServices /// Lookup the global static cache for building the FrameworkTcImports type internal FrameworkImportsCache = @@ -63,16 +34,6 @@ module internal IncrementalBuilderEventTesting = val GetMostRecentIncrementalBuildEvents : int -> IBEvent list val GetCurrentIncrementalBuildEventNum : unit -> int -/// An error logger that capture errors, filtering them according to warning levels etc. -type internal CompilationErrorLogger = - inherit ErrorLogger - - /// Create the error logger - new : debugName:string * tcConfig:TcConfig -> CompilationErrorLogger - - /// Get the captured errors - member GetErrors : unit -> (PhasedDiagnostic * FSharpErrorSeverity) list - /// Represents the state in the incremental graph associated with checking a file type internal PartialCheckResults = { /// This field is None if a major unrecovered error occurred when preparing the initial state @@ -104,10 +65,6 @@ type internal PartialCheckResults = [] type internal IncrementalBuilder = - /// Increment the usage count on the IncrementalBuilder by 1. This initial usage count is 0. The returns an IDisposable which will - /// decrement the usage count on the entire build by 1 and dispose if it is no longer used by anyone. - member IncrementUsageCount : unit -> IDisposable - /// Check if the builder is not disposed member IsAlive : bool @@ -115,7 +72,7 @@ type internal IncrementalBuilder = member TcConfig : TcConfig /// The full set of source files including those from options - member ProjectFileNames : string list + member SourceFiles : string list /// Raised just before a file is type-checked, to invalidate the state of the file in VS and force VS to request a new direct typecheck of the file. /// The incremental builder also typechecks the file (error and intellisense results from the background builder are not @@ -149,7 +106,7 @@ type internal IncrementalBuilder = /// This is a very quick operation. /// /// This is safe for use from non-compiler threads but the objects returned must in many cases be accessed only from the compiler thread. - member GetCheckResultsBeforeFileInProjectIfReady: filename:string -> PartialCheckResults option + member GetCheckResultsBeforeFileInProjectEvenIfStale: filename:string -> PartialCheckResults option /// Get the preceding typecheck state of a slot, but only if it is up-to-date w.r.t. /// the timestamps on files and referenced DLLs prior to this one. Return None if the result is not available. @@ -190,9 +147,13 @@ type internal IncrementalBuilder = /// This may be a marginally long-running operation (parses are relatively quick, only one file needs to be parsed) member GetParseResultsForFile : CompilationThreadToken * filename:string -> Cancellable - static member TryCreateBackgroundBuilderForProjectOptions : CompilationThreadToken * ReferenceResolver.Resolver * FrameworkImportsCache * scriptClosureOptions:LoadClosure option * sourceFiles:string list * commandLineArgs:string list * projectReferences: IProjectReference list * projectDirectory:string * useScriptResolutionRules:bool * keepAssemblyContents: bool * keepAllBackgroundResolutions: bool * maxTimeShareMilliseconds: int64 -> Cancellable + static member TryCreateBackgroundBuilderForProjectOptions : CompilationThreadToken * ReferenceResolver.Resolver * defaultFSharpBinariesDir: string * FrameworkImportsCache * scriptClosureOptions:LoadClosure option * sourceFiles:string list * commandLineArgs:string list * projectReferences: IProjectReference list * projectDirectory:string * useScriptResolutionRules:bool * keepAssemblyContents: bool * keepAllBackgroundResolutions: bool * maxTimeShareMilliseconds: int64 -> Cancellable + /// Increment the usage count on the IncrementalBuilder by 1. This initial usage count is 0 so immediately after creation + /// a call to KeepBuilderAlive should be made. The returns an IDisposable which will + /// decrement the usage count and dispose if the usage count goes to zero static member KeepBuilderAlive : IncrementalBuilder option -> IDisposable + member IsBeingKeptAliveApartFromCacheEntry : bool /// Generalized Incremental Builder. This is exposed only for unittesting purposes. @@ -284,9 +245,3 @@ module internal IncrementalBuild = /// Set the concrete inputs for this build. member GetInitialPartialBuild : vectorinputs: BuildInput list -> PartialBuild -/// This represents the global state established as each task function runs as part of the build. -/// -/// Use to reset error and warning handlers. -type internal CompilationGlobalsScope = - new : ErrorLogger * BuildPhase -> CompilationGlobalsScope - interface IDisposable diff --git a/src/fsharp/vs/Reactor.fs b/src/fsharp/vs/Reactor.fs index b97b083dd9..87c9c5fa44 100755 --- a/src/fsharp/vs/Reactor.fs +++ b/src/fsharp/vs/Reactor.fs @@ -13,15 +13,15 @@ open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library /// Represents the capability to schedule work in the compiler service operations queue for the compilation thread type internal IReactorOperations = - abstract EnqueueAndAwaitOpAsync : string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> - abstract EnqueueOp: string * (CompilationThreadToken -> unit) -> unit + abstract EnqueueAndAwaitOpAsync : userOpName:string * opName:string * opArg:string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> + abstract EnqueueOp: userOpName:string * opName:string * opArg:string * (CompilationThreadToken -> unit) -> unit [] type internal ReactorCommands = /// Kick off a build. - | SetBackgroundOp of (CompilationThreadToken -> bool) option + | SetBackgroundOp of ( (* userOpName: *) string * (* opName: *) string * (* opArg: *) string * (CompilationThreadToken -> CancellationToken -> bool)) option /// Do some work not synchronized in the mailbox. - | Op of string * CancellationToken * (CompilationThreadToken -> unit) * (unit -> unit) + | Op of userOpName: string * opName: string * opArg: string * CancellationToken * (CompilationThreadToken -> unit) * (unit -> unit) /// Finish the background building | WaitForBackgroundOpCompletion of AsyncReplyChannel /// Finish all the queued ops @@ -31,7 +31,7 @@ type internal ReactorCommands = /// There is one global Reactor for the entire language service, no matter how many projects or files /// are open. type Reactor() = - static let pauseBeforeBackgroundWorkDefault = GetEnvInteger "FCS_PauseBeforeBackgroundWorkMilliseconds" 1000 + static let pauseBeforeBackgroundWorkDefault = GetEnvInteger "FCS_PauseBeforeBackgroundWorkMilliseconds" 10 static let theReactor = Reactor() let mutable pauseBeforeBackgroundWork = pauseBeforeBackgroundWorkDefault @@ -39,13 +39,14 @@ type Reactor() = // so that when the reactor picks up a thread from the threadpool we can set the culture let culture = new CultureInfo(CultureInfo.CurrentUICulture.Name) + let mutable bgOpCts = new CancellationTokenSource() /// Mailbox dispatch function. let builder = MailboxProcessor<_>.Start <| fun inbox -> // Async workflow which receives messages and dispatches to worker functions. let rec loop (bgOpOpt, onComplete, bg) = - async { Trace.TraceInformation("Reactor: receiving..., remaining {0}, mem {1}, gc2 {2}", inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) + async { //Trace.TraceInformation("Reactor: receiving..., remaining {0}", inbox.CurrentQueueLength) // Explanation: The reactor thread acts as the compilation thread in hosted scenarios let ctok = AssumeCompilationThreadWithoutEvidence() @@ -59,7 +60,11 @@ type Reactor() = | _, Some _ -> return! inbox.TryReceive(0) | Some _, _ -> - let timeout = (if bg then 0 else pauseBeforeBackgroundWork) + let timeout = + if bg then 0 + else + Trace.TraceInformation("Reactor: {0:n3} pausing {1} milliseconds", DateTime.Now.TimeOfDay.TotalSeconds, pauseBeforeBackgroundWork) + pauseBeforeBackgroundWork return! inbox.TryReceive(timeout) } #if FX_RESHAPED_GLOBALIZATION CultureInfo.CurrentUICulture <- culture @@ -68,44 +73,60 @@ type Reactor() = #endif match msg with | Some (SetBackgroundOp bgOpOpt) -> - Trace.TraceInformation("Reactor: --> set background op, remaining {0}, mem {1}, gc2 {2}", inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) + //Trace.TraceInformation("Reactor: --> set background op, remaining {0}", inbox.CurrentQueueLength) return! loop (bgOpOpt, onComplete, false) - | Some (Op (desc, ct, op, ccont)) -> + + | Some (Op (userOpName, opName, opArg, ct, op, ccont)) -> if ct.IsCancellationRequested then ccont() else - Trace.TraceInformation("Reactor: --> {0}, remaining {1}, mem {2}, gc2 {3}", desc, inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) + Trace.TraceInformation("Reactor: {0:n3} --> {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, inbox.CurrentQueueLength) let time = Stopwatch() time.Start() op ctok time.Stop() let span = time.Elapsed //if span.TotalMilliseconds > 100.0 then - Trace.TraceInformation("Reactor: <-- {0}, remaining {1}, took {2}ms", desc, inbox.CurrentQueueLength, span.TotalMilliseconds) + let taken = span.TotalMilliseconds + let msg = (if taken > 10000.0 then "BAD-OP: >10s " elif taken > 3000.0 then "BAD-OP: >3s " elif taken > 1000.0 then "BAD-OP: > 1s " elif taken > 500.0 then "BAD-OP: >0.5s " else "") + Trace.TraceInformation("Reactor: {0:n3} {1}<-- {2}.{3}, took {4} ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, userOpName, opName, span.TotalMilliseconds) return! loop (bgOpOpt, onComplete, false) | Some (WaitForBackgroundOpCompletion channel) -> - Trace.TraceInformation("Reactor: --> wait for background (debug only), remaining {0}, mem {1}, gc2 {2}", inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) match bgOpOpt with | None -> () - | Some bgOp -> - while bgOp ctok do + | Some (bgUserOpName, bgOpName, bgOpArg, bgOp) -> + Trace.TraceInformation("Reactor: {0:n3} --> wait for background {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg, inbox.CurrentQueueLength) + bgOpCts.Dispose() + bgOpCts <- new CancellationTokenSource() + while not bgOpCts.IsCancellationRequested && bgOp ctok bgOpCts.Token do () + + if bgOpCts.IsCancellationRequested then + Trace.TraceInformation("FCS: <-- wait for background was cancelled {0}.{1}", bgUserOpName, bgOpName) + channel.Reply(()) return! loop (None, onComplete, false) + | Some (CompleteAllQueuedOps channel) -> - Trace.TraceInformation("Reactor: --> stop background work and complete all queued ops, remaining {0}, mem {1}, gc2 {2}", inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) + Trace.TraceInformation("Reactor: {0:n3} --> stop background work and complete all queued ops, remaining {1}", DateTime.Now.TimeOfDay.TotalSeconds, inbox.CurrentQueueLength) return! loop (None, Some channel, false) + | None -> match bgOpOpt, onComplete with | _, Some onComplete -> onComplete.Reply() - | Some bgOp, None -> - Trace.TraceInformation("Reactor: --> background step, remaining {0}, mem {1}, gc2 {2}", inbox.CurrentQueueLength, GC.GetTotalMemory(false)/1000000L, GC.CollectionCount(2)) + | Some (bgUserOpName, bgOpName, bgOpArg, bgOp), None -> + Trace.TraceInformation("Reactor: {0:n3} --> background step {1}.{2} ({3})", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg) let time = Stopwatch() time.Start() - let res = bgOp ctok + bgOpCts.Dispose() + bgOpCts <- new CancellationTokenSource() + let res = bgOp ctok bgOpCts.Token + if bgOpCts.IsCancellationRequested then + Trace.TraceInformation("FCS: <-- background step {0}.{1}, was cancelled", bgUserOpName, bgOpName) time.Stop() - let span = time.Elapsed + let taken = time.Elapsed.TotalMilliseconds //if span.TotalMilliseconds > 100.0 then - Trace.TraceInformation("Reactor: <-- background step, remaining {0}, took {1}ms", inbox.CurrentQueueLength, span.TotalMilliseconds) - return! loop ((if res then Some bgOp else None), onComplete, true) + let msg = (if taken > 10000.0 then "BAD-BG-SLICE: >10s " elif taken > 3000.0 then "BAD-BG-SLICE: >3s " elif taken > 1000.0 then "BAD-BG-SLICE: > 1s " else "") + Trace.TraceInformation("Reactor: {0:n3} {1}<-- background step, took {2}ms", DateTime.Now.TimeOfDay.TotalSeconds, msg, taken) + return! loop ((if res then bgOpOpt else None), onComplete, true) | None, None -> failwith "unreachable, should have used inbox.Receive" } async { @@ -117,36 +138,41 @@ type Reactor() = } // [Foreground Mailbox Accessors] ----------------------------------------------------------- - member r.SetBackgroundOp(build) = - Trace.TraceInformation("Reactor: enqueue start background, length {0}", builder.CurrentQueueLength) - builder.Post(SetBackgroundOp build) + member r.SetBackgroundOp(bgOpOpt) = + Trace.TraceInformation("Reactor: {0:n3} enqueue start background, length {1}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) + bgOpCts.Cancel() + builder.Post(SetBackgroundOp bgOpOpt) + + member r.CancelBackgroundOp() = + Trace.TraceInformation("FCS: trying to cancel any active background work") + bgOpCts.Cancel() - member r.EnqueueOp(desc, op) = - Trace.TraceInformation("Reactor: enqueue {0}, length {1}", desc, builder.CurrentQueueLength) - builder.Post(Op(desc, CancellationToken.None, op, (fun () -> ()))) + member r.EnqueueOp(userOpName, opName, opArg, op) = + Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, builder.CurrentQueueLength) + builder.Post(Op(userOpName, opName, opArg, CancellationToken.None, op, (fun () -> ()))) - member r.EnqueueOpPrim(desc, ct, op, ccont) = - Trace.TraceInformation("Reactor: enqueue {0}, length {1}", desc, builder.CurrentQueueLength) - builder.Post(Op(desc, ct, op, ccont)) + member r.EnqueueOpPrim(userOpName, opName, opArg, ct, op, ccont) = + Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, builder.CurrentQueueLength) + builder.Post(Op(userOpName, opName, opArg, ct, op, ccont)) member r.CurrentQueueLength = builder.CurrentQueueLength // This is for testing only member r.WaitForBackgroundOpCompletion() = - Trace.TraceInformation("Reactor: enqueue wait for background, length {0}", builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue wait for background, length {0}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) builder.PostAndReply WaitForBackgroundOpCompletion // This is for testing only member r.CompleteAllQueuedOps() = - Trace.TraceInformation("Reactor: enqueue wait for all ops, length {0}", builder.CurrentQueueLength) + Trace.TraceInformation("Reactor: {0:n3} enqueue wait for all ops, length {0}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength) builder.PostAndReply CompleteAllQueuedOps - member r.EnqueueAndAwaitOpAsync (desc, f) = + member r.EnqueueAndAwaitOpAsync (userOpName, opName, opArg, f) = async { let! ct = Async.CancellationToken let resultCell = AsyncUtil.AsyncResultCell<_>() - r.EnqueueOpPrim(desc, ct, + r.EnqueueOpPrim(userOpName, opName, opArg, ct, op=(fun ctok -> let result = try diff --git a/src/fsharp/vs/Reactor.fsi b/src/fsharp/vs/Reactor.fsi index 4311238962..eadec3144b 100755 --- a/src/fsharp/vs/Reactor.fsi +++ b/src/fsharp/vs/Reactor.fsi @@ -10,10 +10,10 @@ open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library type internal IReactorOperations = /// Put the operation in the queue, and return an async handle to its result. - abstract EnqueueAndAwaitOpAsync : description: string * action: (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> + abstract EnqueueAndAwaitOpAsync : userOpName:string * opName:string * opArg:string * action: (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> /// Enqueue an operation and return immediately. - abstract EnqueueOp: description: string * action: (CompilationThreadToken -> unit) -> unit + abstract EnqueueOp: userOpName:string * opName:string * opArg:string * action: (CompilationThreadToken -> unit) -> unit /// Reactor is intended for long-running but interruptible operations, interleaved /// with one-off asynchronous operations. @@ -26,7 +26,10 @@ type internal Reactor = /// Set the background building function, which is called repeatedly /// until it returns 'false'. If None then no background operation is used. - member SetBackgroundOp : build:(CompilationThreadToken -> bool) option -> unit + member SetBackgroundOp : ( (* userOpName:*) string * (* opName: *) string * (* opArg: *) string * (CompilationThreadToken -> CancellationToken -> bool)) option -> unit + + /// Cancel any work being don by the background building function. + member CancelBackgroundOp : unit -> unit /// Block until the current implicit background build is complete. Unit test only. member WaitForBackgroundOpCompletion : unit -> unit @@ -35,17 +38,17 @@ type internal Reactor = member CompleteAllQueuedOps : unit -> unit /// Enqueue an uncancellable operation and return immediately. - member EnqueueOp : description: string * op:(CompilationThreadToken -> unit) -> unit + member EnqueueOp : userOpName:string * opName: string * opArg: string * op:(CompilationThreadToken -> unit) -> unit /// For debug purposes member CurrentQueueLength : int /// Put the operation in the queue, and return an async handle to its result. - member EnqueueAndAwaitOpAsync : description: string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> + member EnqueueAndAwaitOpAsync : userOpName:string * opName:string * opArg:string * (CompilationThreadToken -> Cancellable<'T>) -> Async<'T> /// The timespan in milliseconds before background work begins after the operations queue is empty member PauseBeforeBackgroundWork : int with get, set - /// Get the reactor for FSharp.Compiler.dll + /// Get the reactor static member Singleton : Reactor diff --git a/src/fsharp/vs/ServiceAssemblyContent.fs b/src/fsharp/vs/ServiceAssemblyContent.fs index 008106818e..c83e7588b2 100644 --- a/src/fsharp/vs/ServiceAssemblyContent.fs +++ b/src/fsharp/vs/ServiceAssemblyContent.fs @@ -88,7 +88,7 @@ module Extensions = member x.TryGetFullCompiledOperatorNameIdents() : Idents option = // For operator ++ displayName is ( ++ ) compiledName is op_PlusPlus if isOperator x.DisplayName && x.DisplayName <> x.CompiledName then - Option.attempt (fun _ -> x.EnclosingEntity) + x.EnclosingEntity |> Option.bind (fun e -> e.TryGetFullName()) |> Option.map (fun enclosingEntityFullName -> Array.append (enclosingEntityFullName.Split '.') [| x.CompiledName |]) diff --git a/src/fsharp/vs/ServiceAssemblyContent.fsi b/src/fsharp/vs/ServiceAssemblyContent.fsi index cc549283d9..c9135afa3a 100644 --- a/src/fsharp/vs/ServiceAssemblyContent.fsi +++ b/src/fsharp/vs/ServiceAssemblyContent.fsi @@ -10,36 +10,69 @@ open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.Range /// Assembly content type. +#if COMPILER_PUBLIC_API type AssemblyContentType = - /// Public assembly content only. +#else +type internal AssemblyContentType = +#endif +/// Public assembly content only. | Public /// All assembly content. | Full /// Short identifier, i.e. an identifier that contains no dots. +#if COMPILER_PUBLIC_API type ShortIdent = string +#else +type internal ShortIdent = string +#endif /// An array of `ShortIdent`. +#if COMPILER_PUBLIC_API type Idents = ShortIdent[] +#else +type internal Idents = ShortIdent[] +#endif /// `ShortIdent` with a flag indicating if it's resolved in some scope. -type MaybeUnresolvedIdent = { Ident: ShortIdent; Resolved: bool } +#if COMPILER_PUBLIC_API +type MaybeUnresolvedIdent = +#else +type internal MaybeUnresolvedIdent = +#endif + { Ident: ShortIdent; Resolved: bool } /// Array of `MaybeUnresolvedIdent`. +#if COMPILER_PUBLIC_API type MaybeUnresolvedIdents = MaybeUnresolvedIdent[] +#else +type internal MaybeUnresolvedIdents = MaybeUnresolvedIdent[] +#endif /// Entity lookup type. [] +#if COMPILER_PUBLIC_API type LookupType = +#else +type internal LookupType = +#endif | Fuzzy | Precise /// Assembly path. +#if COMPILER_PUBLIC_API type AssemblyPath = string +#else +type internal AssemblyPath = string +#endif /// Represents type, module, member, function or value in a compiled assembly. [] +#if COMPILER_PUBLIC_API type AssemblySymbol = +#else +type internal AssemblySymbol = +#endif { /// Full entity name as it's seen in compiled code (raw FSharpEntity.FullName, FSharpValueOrFunction.FullName). FullName: string /// Entity name parts with removed module suffixes (Ns.M1Module.M2Module.M3.entity -> Ns.M1.M2.M3.entity) @@ -69,14 +102,22 @@ type internal AssemblyContentCacheEntry = /// Assembly content cache. [] +#if COMPILER_PUBLIC_API type IAssemblyContentCache = +#else +type internal IAssemblyContentCache = +#endif /// Try get an assembly cached content. abstract TryGet: AssemblyPath -> AssemblyContentCacheEntry option /// Store an assembly content. abstract Set: AssemblyPath -> AssemblyContentCacheEntry -> unit /// Thread safe wrapper over `IAssemblyContentCache`. +#if COMPILER_PUBLIC_API type EntityCache = +#else +type internal EntityCache = +#endif interface IAssemblyContentCache new : unit -> EntityCache /// Clears the cache. @@ -85,10 +126,18 @@ type EntityCache = member Locking : (IAssemblyContentCache -> 'T) -> 'T /// Lond identifier (i.e. it may contain dots). +#if COMPILER_PUBLIC_API type StringLongIdent = string +#else +type internal StringLongIdent = string +#endif /// Helper data structure representing a symbol, sutable for implementing unresolved identifiers resolution code fixes. +#if COMPILER_PUBLIC_API type Entity = +#else +type internal Entity = +#endif { /// Full name, relative to the current scope. FullRelativeName: StringLongIdent /// Ident parts needed to append to the current ident to make it resolvable in current scope. @@ -101,7 +150,11 @@ type Entity = LastIdent: string } /// Provides assembly content. +#if COMPILER_PUBLIC_API module AssemblyContentProvider = +#else +module internal AssemblyContentProvider = +#endif /// Given a `FSharpAssemblySignature`, returns assembly content. val getAssemblySignatureContent : AssemblyContentType -> FSharpAssemblySignature -> AssemblySymbol list @@ -114,7 +167,11 @@ module AssemblyContentProvider = -> AssemblySymbol list /// Kind of lexical scope. +#if COMPILER_PUBLIC_API type ScopeKind = +#else +type internal ScopeKind = +#endif | Namespace | TopModule | NestedModule @@ -122,19 +179,31 @@ type ScopeKind = | HashDirective /// Insert open namespace context. +#if COMPILER_PUBLIC_API type InsertContext = +#else +type internal InsertContext = +#endif { /// Current scope kind. ScopeKind: ScopeKind /// Current position (F# compiler line number). Pos: pos } /// Where open statements should be added. +#if COMPILER_PUBLIC_API +type OpenStatementInsertionPoint = +#else type internal OpenStatementInsertionPoint = +#endif | TopLevel | Nearest /// Parse AST helpers. +#if COMPILER_PUBLIC_API module ParsedInput = +#else +module internal ParsedInput = +#endif /// Returns `InsertContext` based on current position and symbol idents. val tryFindInsertionContext : @@ -153,7 +222,11 @@ module ParsedInput = val adjustInsertionPoint : getLineStr: (int -> string) -> ctx: InsertContext -> pos [] +#if COMPILER_PUBLIC_API module Extensions = +#else +module internal Extensions = +#endif type FSharpEntity with /// Safe version of `FullName`. member TryGetFullName : unit -> string option diff --git a/src/fsharp/vs/ServiceDeclarationLists.fs b/src/fsharp/vs/ServiceDeclarationLists.fs new file mode 100644 index 0000000000..4b91886da8 --- /dev/null +++ b/src/fsharp/vs/ServiceDeclarationLists.fs @@ -0,0 +1,795 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +//---------------------------------------------------------------------------- +// Open up the compiler as an incremental service for parsing, +// type checking and intellisense-like environment-reporting. +//-------------------------------------------------------------------------- + +namespace Microsoft.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.IL +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 + +[] +module EnvMisc3 = + /// dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. + /// This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. + let dataTipSpinWaitTime = GetEnvInteger "FCS_ToolTipSpinWaitTime" 300 + + +[] +type FSharpMethodGroupItemParameter(name: string, canonicalTypeTextForSorting: string, display: layout, isOptional: bool) = + member __.ParameterName = name + member __.CanonicalTypeTextForSorting = canonicalTypeTextForSorting + member __.StructuredDisplay = display + member __.Display = showL display + member __.IsOptional = isOptional + +[] +module internal DescriptionListsImpl = + + let isFunction g typ = + let _,tau = tryDestForallTy g typ + isFunTy g tau + + let printCanonicalizedTypeName g (denv:DisplayEnv) tau = + // get rid of F# abbreviations and such + let strippedType = stripTyEqnsWrtErasure EraseAll g tau + // pretend no namespaces are open + let denv = denv.SetOpenPaths([]) + // now printing will see a .NET-like canonical representation, that is good for sorting overloads into a reasonable order (see bug 94520) + NicePrint.stringOfTy denv strippedType + + let PrettyParamOfRecdField g denv (f: RecdField) = + FSharpMethodGroupItemParameter( + name = f.Name, + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv f.FormalType, + // Note: the instantiation of any type parameters is currently incorporated directly into the type + // rather than being returned separately. + display = NicePrint.prettyLayoutOfType denv f.FormalType, + isOptional=false) + + let PrettyParamOfUnionCaseField g denv isGenerated (i: int) (f: RecdField) = + let initial = PrettyParamOfRecdField g denv f + let display = + if isGenerated i f then + initial.StructuredDisplay + else + // TODO: in this case ucinst is ignored - it gives the instantiation of the type parameters of + // the union type containing this case. + NicePrint.layoutOfParamData denv (ParamData(false, false, NotOptional, NoCallerInfo, Some f.Id, ReflectedArgInfo.None, f.FormalType)) + FSharpMethodGroupItemParameter( + name=initial.ParameterName, + canonicalTypeTextForSorting=initial.CanonicalTypeTextForSorting, + display=display, + isOptional=false) + + let ParamOfParamData g denv (ParamData(_isParamArrayArg, _isOutArg, optArgInfo, _callerInfoInfo, nmOpt, _reflArgInfo, pty) as paramData) = + FSharpMethodGroupItemParameter( + name = (match nmOpt with None -> "" | Some pn -> pn.idText), + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv pty, + display = NicePrint.layoutOfParamData denv paramData, + isOptional=optArgInfo.IsOptional) + + // TODO this code is similar to NicePrint.fs:formatParamDataToBuffer, refactor or figure out why different? + let PrettyParamsOfParamDatas g denv typarInst (paramDatas:ParamData list) rty = + let paramInfo,paramTypes = + paramDatas + |> List.map (fun (ParamData(isParamArrayArg, _isOutArg, optArgInfo, _callerInfoInfo, nmOpt, _reflArgInfo, pty)) -> + let isOptArg = optArgInfo.IsOptional + match nmOpt, isOptArg, tryDestOptionTy denv.g pty with + // Layout an optional argument + | Some id, true, ptyOpt -> + let nm = id.idText + // detect parameter type, if ptyOpt is None - this is .NET style optional argument + let pty = defaultArg ptyOpt pty + (nm, isOptArg, SepL.questionMark ^^ (wordL (TaggedTextOps.tagParameter nm))), pty + // Layout an unnamed argument + | None, _,_ -> + ("", isOptArg, emptyL), pty + // Layout a named argument + | Some id,_,_ -> + let nm = id.idText + let prefix = + if isParamArrayArg then + NicePrint.PrintUtilities.layoutBuiltinAttribute denv denv.g.attrib_ParamArrayAttribute ^^ + wordL (TaggedTextOps.tagParameter nm) ^^ + RightL.colon + //sprintf "%s %s: " (NicePrint.PrintUtilities.layoutBuiltinAttribute denv denv.g.attrib_ParamArrayAttribute |> showL) nm + else + wordL (TaggedTextOps.tagParameter nm) ^^ + RightL.colon + //sprintf "%s: " nm + (nm,isOptArg, prefix),pty) + |> List.unzip + + // Prettify everything + let prettyTyparInst, (prettyParamTys, _prettyRetTy), (prettyParamTysL, prettyRetTyL), prettyConstraintsL = + NicePrint.prettyLayoutOfInstAndSig denv (typarInst, paramTypes, rty) + + // Remake the params using the prettified versions + let prettyParams = + (paramInfo,prettyParamTys,prettyParamTysL) |||> List.map3 (fun (nm,isOptArg,paramPrefix) tau tyL -> + FSharpMethodGroupItemParameter( + name = nm, + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, + display = paramPrefix ^^ tyL, + isOptional=isOptArg + )) + + prettyTyparInst, prettyParams, prettyRetTyL, prettyConstraintsL + + let PrettyParamsOfTypes g denv typarInst paramTys retTy = + + // Prettify everything + let prettyTyparInst, (prettyParamTys, _prettyRetTy), (prettyParamTysL, prettyRetTyL), prettyConstraintsL = + NicePrint.prettyLayoutOfInstAndSig denv (typarInst, paramTys, retTy) + + // Remake the params using the prettified versions + let parameters = + (prettyParamTys,prettyParamTysL) + ||> List.zip + |> List.map (fun (tau, tyL) -> + FSharpMethodGroupItemParameter( + name = "", + canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, + display = tyL, + isOptional=false + )) + + // Return the results + prettyTyparInst, parameters, prettyRetTyL, prettyConstraintsL + + +#if EXTENSIONTYPING + + /// Get the set of static parameters associated with an item + let StaticParamsOfItem (infoReader:InfoReader) m denv item = + let amap = infoReader.amap + let g = infoReader.g + match item with + | SymbolHelpers.ItemIsWithStaticArguments m g staticParameters -> + staticParameters + |> Array.map (fun sp -> + let typ = Import.ImportProvidedType amap m (sp.PApply((fun x -> x.ParameterType),m)) + let spKind = NicePrint.prettyLayoutOfType denv typ + let spName = sp.PUntaint((fun sp -> sp.Name), m) + let spOpt = sp.PUntaint((fun sp -> sp.IsOptional), m) + FSharpMethodGroupItemParameter( + name = spName, + canonicalTypeTextForSorting = showL spKind, + display = (if spOpt then SepL.questionMark else emptyL) ^^ wordL (TaggedTextOps.tagParameter spName) ^^ RightL.colon ^^ spKind, + //display = sprintf "%s%s: %s" (if spOpt then "?" else "") spName spKind, + isOptional=spOpt)) + | _ -> [| |] +#endif + + /// Get all the information about parameters and "prettify" the types by choosing nice type variable + /// names. This is similar to the other variations on "show me an item" code. This version is + /// is used when presenting groups of methods (see FSharpMethodGroup). It is possible these different + /// versions could be better unified. + let rec PrettyParamsAndReturnTypeOfItem (infoReader:InfoReader) m denv (item: ItemWithInst) = + let amap = infoReader.amap + let g = infoReader.g + let denv = { SymbolHelpers.SimplerDisplayEnv denv with useColonForReturnType=true} + match item.Item with + | Item.Value vref -> + let getPrettyParamsOfTypes() = + let tau = vref.TauType + match tryDestFunTy denv.g tau with + | Some(arg,rtau) -> + let args = tryDestRefTupleTy denv.g arg + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfTypes g denv item.TyparInst args rtau + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + | None -> + let _prettyTyparInst, prettyTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] tau + [], prettyTyL + + match vref.ValReprInfo with + | None -> + // ValReprInfo = None i.e. in let bindings defined in types or in local functions + // in this case use old approach and return only information about types + getPrettyParamsOfTypes () + + | Some valRefInfo -> + // ValReprInfo will exist for top-level syntactic functions + // per spec: binding is considered to define a syntactic function if it is either a function or its immediate right-hand-side is a anonymous function + let (_, argInfos, lastRetTy, _) = GetTopValTypeInFSharpForm g valRefInfo vref.Type m + match argInfos with + | [] -> + // handles cases like 'let foo = List.map' + getPrettyParamsOfTypes() + | firstCurriedArgInfo::_ -> + // result 'paramDatas' collection corresponds to the first argument of curried function + // i.e. let func (a : int) (b : int) = a + b + // paramDatas will contain information about a and retTy will be: int -> int + // This is good enough as we don't provide ways to display info for the second curried argument + let firstCurriedParamDatas = + firstCurriedArgInfo + |> List.map ParamNameAndType.FromArgInfo + |> List.map (fun (ParamNameAndType(nmOpt, pty)) -> ParamData(false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None, pty)) + + // Adjust the return type so it only strips the first argument + let curriedRetTy = + match tryDestFunTy denv.g vref.TauType with + | Some(_,rtau) -> rtau + | None -> lastRetTy + + let _prettyTyparInst, prettyFirstCurriedParams, prettyCurriedRetTyL, prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInst firstCurriedParamDatas curriedRetTy + + let prettyCurriedRetTyL = prettyCurriedRetTyL ^^ SepL.space ^^ prettyConstraintsL + + prettyFirstCurriedParams, prettyCurriedRetTyL + + | Item.UnionCase(ucinfo,_) -> + let prettyParams = + match ucinfo.UnionCase.RecdFields with + | [f] -> [PrettyParamOfUnionCaseField g denv NicePrint.isGeneratedUnionCaseField -1 f] + | fs -> fs |> List.mapi (PrettyParamOfUnionCaseField g denv NicePrint.isGeneratedUnionCaseField) + let rty = generalizedTyconRef ucinfo.TyconRef + let rtyL = NicePrint.layoutType denv rty + prettyParams, rtyL + + | Item.ActivePatternCase(apref) -> + let v = apref.ActivePatternVal + let tau = v.TauType + let args, resTy = stripFunTy denv.g tau + + let apinfo = Option.get (TryGetActivePatternInfo v) + let aparity = apinfo.Names.Length + + let rty = if aparity <= 1 then resTy else (argsOfAppTy g resTy).[apref.CaseIndex] + + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfTypes g denv item.TyparInst args rty + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + + | Item.ExnCase ecref -> + let prettyParams = ecref |> recdFieldsOfExnDefRef |> List.mapi (PrettyParamOfUnionCaseField g denv NicePrint.isGeneratedExceptionField) + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] g.exn_ty + prettyParams, prettyRetTyL + + | Item.RecdField rfinfo -> + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] rfinfo.FieldType + [], prettyRetTyL + + | Item.ILField finfo -> + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] (finfo.FieldType(amap,m)) + [], prettyRetTyL + + | Item.Event einfo -> + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] (PropTypOfEventInfo infoReader m AccessibleFromSomewhere einfo) + [], prettyRetTyL + + | Item.Property(_,pinfo :: _) -> + let paramDatas = pinfo.GetParamDatas(amap,m) + let rty = pinfo.GetPropertyType(amap,m) + + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInst paramDatas rty + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + + | Item.CtorGroup(_,(minfo :: _)) + | Item.MethodGroup(_,(minfo :: _),_) -> + let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head + let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInst paramDatas rty + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + + | Item.CustomBuilder (_,vref) -> + PrettyParamsAndReturnTypeOfItem infoReader m denv { item with Item = Item.Value vref } + + | Item.TypeVar _ -> + [], emptyL + + | Item.CustomOperation (_,usageText, Some minfo) -> + match usageText() with + | None -> + let argNamesAndTys = SymbolHelpers.ParamNameAndTypesOfUnaryCustomOperation g minfo + let argTys, _ = PrettyTypes.PrettifyTypes g (argNamesAndTys |> List.map (fun (ParamNameAndType(_,ty)) -> ty)) + let paramDatas = (argNamesAndTys, argTys) ||> List.map2 (fun (ParamNameAndType(nmOpt, _)) argTy -> ParamData(false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None,argTy)) + let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInst paramDatas rty + + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + + | Some _ -> + let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] rty + [], prettyRetTyL // no parameter data available for binary operators like 'zip', 'join' and 'groupJoin' since they use bespoke syntax + + | Item.FakeInterfaceCtor typ -> + let _prettyTyparInst, prettyRetTyL = NicePrint.prettyLayoutOfUncurriedSig denv item.TyparInst [] typ + [], prettyRetTyL + + | Item.DelegateCtor delty -> + let (SigOfFunctionForDelegate(_, _, _, fty)) = GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomewhere + + // No need to pass more generic type information in here since the instanitations have already been applied + let _prettyTyparInst, prettyParams, prettyRetTyL, _prettyConstraintsL = PrettyParamsOfParamDatas g denv item.TyparInst [ParamData(false, false, NotOptional, NoCallerInfo, None, ReflectedArgInfo.None, fty)] delty + + // FUTURE: prettyTyparInst is the pretty version of the known instantiations of type parameters in the output. It could be returned + // for display as part of the method group + prettyParams, prettyRetTyL + + | _ -> + [], emptyL + + + /// Compute the index of the VS glyph shown with an item in the Intellisense menu + let GlyphOfItem(denv, item) : FSharpGlyph = + /// Find the glyph for the given representation. + let reprToGlyph repr = + match repr with + | TFSharpObjectRepr om -> + match om.fsobjmodel_kind with + | TTyconClass -> FSharpGlyph.Class + | TTyconInterface -> FSharpGlyph.Interface + | TTyconStruct -> FSharpGlyph.Struct + | TTyconDelegate _ -> FSharpGlyph.Delegate + | TTyconEnum _ -> FSharpGlyph.Enum + | TRecdRepr _ -> FSharpGlyph.Type + | TUnionRepr _ -> FSharpGlyph.Union + | TILObjectRepr (TILObjectReprData (_,_,td)) -> + match td.tdKind with + | ILTypeDefKind.Class -> FSharpGlyph.Class + | ILTypeDefKind.ValueType -> FSharpGlyph.Struct + | ILTypeDefKind.Interface -> FSharpGlyph.Interface + | ILTypeDefKind.Enum -> FSharpGlyph.Enum + | ILTypeDefKind.Delegate -> FSharpGlyph.Delegate + | TAsmRepr _ -> FSharpGlyph.Typedef + | TMeasureableRepr _-> FSharpGlyph.Typedef +#if EXTENSIONTYPING + | TProvidedTypeExtensionPoint _-> FSharpGlyph.Typedef + | TProvidedNamespaceExtensionPoint _-> FSharpGlyph.Typedef +#endif + | TNoRepr -> FSharpGlyph.Class + + /// Find the glyph for the given type representation. + let typeToGlyph typ = + if isAppTy denv.g typ then + let tcref = tcrefOfAppTy denv.g typ + tcref.TypeReprInfo |> reprToGlyph + elif isStructTupleTy denv.g typ then FSharpGlyph.Struct + elif isRefTupleTy denv.g typ then FSharpGlyph.Class + elif isFunction denv.g typ then FSharpGlyph.Delegate + elif isTyparTy denv.g typ then FSharpGlyph.Struct + else FSharpGlyph.Typedef + + // This may explore assemblies that are not in the reference set, + // e.g. for type abbreviations to types not in the reference set. + // In this case just use GlyphMajor.Class. + protectAssemblyExploration FSharpGlyph.Class (fun () -> + match item with + | Item.Value(vref) | Item.CustomBuilder (_,vref) -> + if isFunction denv.g vref.Type then FSharpGlyph.Method + elif vref.LiteralValue.IsSome then FSharpGlyph.Constant + else FSharpGlyph.Variable + | Item.Types(_,typ::_) -> typeToGlyph (stripTyEqns denv.g typ) + | Item.UnionCase _ + | Item.ActivePatternCase _ -> FSharpGlyph.EnumMember + | Item.ExnCase _ -> FSharpGlyph.Exception + | Item.RecdField _ -> FSharpGlyph.Field + | Item.ILField _ -> FSharpGlyph.Field + | Item.Event _ -> FSharpGlyph.Event + | Item.Property _ -> FSharpGlyph.Property + | Item.CtorGroup _ + | Item.DelegateCtor _ + | Item.FakeInterfaceCtor _ + | Item.CustomOperation _ -> FSharpGlyph.Method + | Item.MethodGroup (_, minfos, _) when minfos |> List.forall (fun minfo -> minfo.IsExtensionMember) -> FSharpGlyph.ExtensionMethod + | Item.MethodGroup _ -> FSharpGlyph.Method + | Item.TypeVar _ + | Item.Types _ -> FSharpGlyph.Class + | Item.UnqualifiedType (tcref :: _) -> + if tcref.IsEnumTycon || tcref.IsILEnumTycon then FSharpGlyph.Enum + elif tcref.IsExceptionDecl then FSharpGlyph.Exception + elif tcref.IsFSharpDelegateTycon then FSharpGlyph.Delegate + elif tcref.IsFSharpInterfaceTycon then FSharpGlyph.Interface + elif tcref.IsFSharpStructOrEnumTycon then FSharpGlyph.Struct + elif tcref.IsModule then FSharpGlyph.Module + elif tcref.IsNamespace then FSharpGlyph.NameSpace + elif tcref.IsUnionTycon then FSharpGlyph.Union + elif tcref.IsILTycon then + let (TILObjectReprData (_, _, tydef)) = tcref.ILTyconInfo + if tydef.IsInterface then FSharpGlyph.Interface + elif tydef.IsDelegate then FSharpGlyph.Delegate + elif tydef.IsEnum then FSharpGlyph.Enum + elif tydef.IsStructOrEnum then FSharpGlyph.Struct + else FSharpGlyph.Class + else FSharpGlyph.Class + | Item.ModuleOrNamespaces(modref::_) -> + if modref.IsNamespace then FSharpGlyph.NameSpace else FSharpGlyph.Module + | Item.ArgName _ -> FSharpGlyph.Variable + | Item.SetterArg _ -> FSharpGlyph.Variable + | _ -> FSharpGlyph.Error) + + + /// Get rid of groups of overloads an replace them with single items. + /// (This looks like it is doing the a similar thing as FlattenItems, this code + /// duplication could potentially be removed) + let AnotherFlattenItems g m item = + match item with + | Item.CtorGroup(nm,cinfos) -> List.map (fun minfo -> Item.CtorGroup(nm,[minfo])) cinfos + | Item.FakeInterfaceCtor _ + | Item.DelegateCtor _ -> [item] + | Item.NewDef _ + | Item.ILField _ -> [] + | Item.Event _ -> [] + | Item.RecdField(rfinfo) -> + if isFunction g rfinfo.FieldType then [item] else [] + | Item.Value v -> + if isFunction g v.Type then [item] else [] + | Item.UnionCase(ucr,_) -> + if not ucr.UnionCase.IsNullary then [item] else [] + | Item.ExnCase(ecr) -> + if isNil (recdFieldsOfExnDefRef ecr) then [] else [item] + | Item.Property(_,pinfos) -> + let pinfo = List.head pinfos + if pinfo.IsIndexer then [item] else [] +#if EXTENSIONTYPING + | SymbolHelpers.ItemIsWithStaticArguments m g _ -> + // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them + [item] +#endif + | Item.MethodGroup(nm,minfos,orig) -> minfos |> List.map (fun minfo -> Item.MethodGroup(nm,[minfo],orig)) + | Item.CustomOperation(_name, _helpText, _minfo) -> [item] + | Item.TypeVar _ -> [] + | Item.CustomBuilder _ -> [] + | _ -> [] + + +/// An intellisense declaration +[] +type FSharpDeclarationListItem(name: string, nameInCode: string, fullName: string, glyph: FSharpGlyph, info, accessibility: FSharpAccessibility option, + kind: CompletionItemKind, isOwnMember: bool, priority: int, isResolved: bool, namespaceToOpen: string option) = + + let mutable descriptionTextHolder: FSharpToolTipText<_> option = None + let mutable task = null + + member __.Name = name + member __.NameInCode = nameInCode + + member __.StructuredDescriptionTextAsync = + let userOpName = "ToolTip" + match info with + | Choice1Of2 (items: CompletionItem list, infoReader, m, denv, reactor:IReactorOperations, checkAlive) -> + // reactor causes the lambda to execute on the background compiler thread, through the Reactor + reactor.EnqueueAndAwaitOpAsync (userOpName, "StructuredDescriptionTextAsync", name, fun ctok -> + RequireCompilationThread ctok + // This is where we do some work which may touch TAST data structures owned by the IncrementalBuilder - infoReader, item etc. + // It is written to be robust to a disposal of an IncrementalBuilder, in which case it will just return the empty string. + // It is best to think of this as a "weak reference" to the IncrementalBuilder, i.e. this code is written to be robust to its + // disposal. Yes, you are right to scratch your head here, but this is ok. + cancellable.Return( + if checkAlive() then + FSharpToolTipText(items |> List.map (fun x -> SymbolHelpers.FormatStructuredDescriptionOfItem true infoReader m denv x.ItemWithInst)) + else + FSharpToolTipText [ FSharpStructuredToolTipElement.Single(wordL (tagText (FSComp.SR.descriptionUnavailable())), FSharpXmlDoc.None) ])) + | Choice2Of2 result -> + async.Return result + + member decl.DescriptionTextAsync = + decl.StructuredDescriptionTextAsync + |> Tooltips.Map Tooltips.ToFSharpToolTipText + + member decl.StructuredDescriptionText = + ErrorScope.Protect Range.range0 + (fun () -> + match descriptionTextHolder with + | Some descriptionText -> descriptionText + | None -> + match info with + | Choice1Of2 _ -> + // The dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. + // This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. + if isNull task then + // kick off the actual (non-cooperative) work + task <- System.Threading.Tasks.Task.Factory.StartNew(fun() -> + let text = decl.StructuredDescriptionTextAsync |> Async.RunSynchronously + descriptionTextHolder <- Some text) + + // The dataTipSpinWaitTime limits how long we block the UI thread while a tooltip pops up next to a selected item in an IntelliSense completion list. + // This time appears to be somewhat amortized by the time it takes the VS completion UI to actually bring up the tooltip after selecting an item in the first place. + task.Wait EnvMisc3.dataTipSpinWaitTime |> ignore + match descriptionTextHolder with + | Some text -> text + | None -> FSharpToolTipText [ FSharpStructuredToolTipElement.Single(wordL (tagText (FSComp.SR.loadingDescription())), FSharpXmlDoc.None) ] + + | Choice2Of2 result -> + result + ) + (fun err -> FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) + member decl.DescriptionText = decl.StructuredDescriptionText |> Tooltips.ToFSharpToolTipText + member __.Glyph = glyph + member __.Accessibility = accessibility + member __.Kind = kind + member __.IsOwnMember = isOwnMember + member __.MinorPriority = priority + member __.FullName = fullName + member __.IsResolved = isResolved + member __.NamespaceToOpen = namespaceToOpen + +/// A table of declarations for Intellisense completion +[] +type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[], isForType: bool, isError: bool) = + member __.Items = declarations + member __.IsForType = isForType + member __.IsError = isError + + // Make a 'Declarations' object for a set of selected items + static member Create(infoReader:InfoReader, m, denv, getAccessibility, items: CompletionItem list, reactor, currentNamespaceOrModule: string[] option, isAttributeApplicationContext: bool, checkAlive) = + let g = infoReader.g + let isForType = items |> List.exists (fun x -> x.Type.IsSome) + let items = items |> SymbolHelpers.RemoveExplicitlySuppressedCompletionItems g + + let tyconRefOptEq tref1 tref2 = + match tref1 with + | Some tref1 -> tyconRefEq g tref1 tref2 + | None -> false + + // Adjust items priority. Sort by name. For things with the same name, + // - show types with fewer generic parameters first + // - show types before over other related items - they usually have very useful XmlDocs + let _, _, items = + items + |> List.map (fun x -> + match x.Item with + | Item.Types (_,(TType_app(tcref,_) :: _)) -> { x with MinorPriority = 1 + tcref.TyparsNoRange.Length } + // Put delegate ctors after types, sorted by #typars. RemoveDuplicateItems will remove FakeInterfaceCtor and DelegateCtor if an earlier type is also reported with this name + | Item.FakeInterfaceCtor (TType_app(tcref,_)) + | Item.DelegateCtor (TType_app(tcref,_)) -> { x with MinorPriority = 1000 + tcref.TyparsNoRange.Length } + // Put type ctors after types, sorted by #typars. RemoveDuplicateItems will remove DefaultStructCtors if a type is also reported with this name + | Item.CtorGroup (_, (cinfo :: _)) -> { x with MinorPriority = 1000 + 10 * (tcrefOfAppTy g cinfo.EnclosingType).TyparsNoRange.Length } + | Item.MethodGroup(_, minfo :: _, _) -> { x with IsOwnMember = tyconRefOptEq x.Type minfo.DeclaringEntityRef } + | Item.Property(_, pinfo :: _) -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g pinfo.EnclosingType) } + | Item.ILField finfo -> { x with IsOwnMember = tyconRefOptEq x.Type (tcrefOfAppTy g finfo.EnclosingType) } + | _ -> x) + |> List.sortBy (fun x -> x.MinorPriority) + |> List.fold (fun (prevRealPrior, prevNormalizedPrior, acc) x -> + if x.MinorPriority = prevRealPrior then + prevRealPrior, prevNormalizedPrior, x :: acc + else + let normalizedPrior = prevNormalizedPrior + 1 + x.MinorPriority, normalizedPrior, { x with MinorPriority = normalizedPrior } :: acc + ) (0, 0, []) + + if verbose then dprintf "service.ml: mkDecls: %d found groups after filtering\n" (List.length items); + + // Group by full name for unresolved items and by display name for resolved ones. + let items = + items + |> List.rev + // Prefer items from file check results to ones from referenced assemblies via GetAssemblyContent ("all entities") + |> List.sortBy (fun x -> x.Unresolved.IsSome) + // Remove all duplicates. We've put the types first, so this removes the DelegateCtor and DefaultStructCtor's. + |> SymbolHelpers.RemoveDuplicateCompletionItems g + |> List.groupBy (fun x -> + match x.Unresolved with + | Some u -> + match u.Namespace with + | [||] -> u.DisplayName + | ns -> (ns |> String.concat ".") + "." + u.DisplayName + | None -> x.Item.DisplayName) + |> List.map (fun (_, items) -> + let item = items.Head + let name = + match item.Unresolved with + | Some u -> u.DisplayName + | None -> item.Item.DisplayName + name, items) + + // Filter out operators (and list) + let items = + // Check whether this item looks like an operator. + let isOperatorItem(name, items: CompletionItem list) = + match items |> List.map (fun x -> x.Item) with + | [Item.Value _ | Item.MethodGroup _ | Item.UnionCase _] -> IsOperatorName name + | _ -> false + let isFSharpList name = (name = "[]") // list shows up as a Type and a UnionCase, only such entity with a symbolic name, but want to filter out of intellisense + items |> List.filter (fun (displayName, items) -> not (isOperatorItem(displayName, items)) && not (isFSharpList displayName)) + + let decls = + items + |> List.map (fun (displayName, itemsWithSameFullName) -> + match itemsWithSameFullName with + | [] -> failwith "Unexpected empty bag" + | _ -> + let items = + match itemsWithSameFullName |> List.partition (fun x -> x.Unresolved.IsNone) with + | [], unresolved -> unresolved + // if there are resolvable items, throw out unresolved to prevent duplicates like `Set` and `FSharp.Collections.Set`. + | resolved, _ -> resolved + + let item = items.Head + let glyph = GlyphOfItem(denv, item.Item) + + let name, nameInCode = + if displayName.StartsWith "( " && displayName.EndsWith " )" then + let cleanName = displayName.[2..displayName.Length - 3] + cleanName, + if IsOperatorName displayName then cleanName else "``" + cleanName + "``" + else + displayName, + match item.Unresolved with + | Some _ -> displayName + | None -> Lexhelp.Keywords.QuoteIdentifierIfNeeded displayName + + let isAttribute = SymbolHelpers.IsAttribute infoReader item.Item + + let cutAttributeSuffix (name: string) = + if isAttributeApplicationContext && isAttribute && name <> "Attribute" && name.EndsWith "Attribute" then + name.[0..name.Length - "Attribute".Length - 1] + else name + + let name = cutAttributeSuffix name + let nameInCode = cutAttributeSuffix nameInCode + let fullName = SymbolHelpers.FullNameOfItem g item.Item + + let namespaceToOpen = + item.Unresolved + |> Option.map (fun x -> x.Namespace) + |> Option.bind (fun ns -> + if ns |> Array.startsWith [|"Microsoft"; "FSharp"|] then None + else Some ns) + |> Option.map (fun ns -> + match currentNamespaceOrModule with + | Some currentNs -> + if ns |> Array.startsWith currentNs then + ns.[currentNs.Length..] + else ns + | None -> ns) + |> Option.bind (function + | [||] -> None + | ns -> Some (ns |> String.concat ".")) + + FSharpDeclarationListItem( + name, nameInCode, fullName, glyph, Choice1Of2 (items, infoReader, m, denv, reactor, checkAlive), getAccessibility item.Item, + item.Kind, item.IsOwnMember, item.MinorPriority, item.Unresolved.IsNone, namespaceToOpen)) + + new FSharpDeclarationListInfo(Array.ofList decls, isForType, false) + + static member Error msg = + new FSharpDeclarationListInfo( + [| FSharpDeclarationListItem("", "", "", FSharpGlyph.Error, Choice2Of2 (FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError msg]), + None, CompletionItemKind.Other, false, 0, false, None) |], false, true) + + static member Empty = FSharpDeclarationListInfo([| |], false, false) + + + +/// A single method for Intellisense completion +[] +// 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[]) = + member __.StructuredDescription = description + member __.Description = Tooltips.ToFSharpToolTipText description + member __.XmlDoc = xmlDoc + member __.StructuredReturnTypeText = returnType + member __.ReturnTypeText = showL returnType + member __.Parameters = parameters + member __.HasParameters = hasParameters + member __.HasParamArrayArg = hasParamArrayArg + // Does the type name or method support a static arguments list, like TP<42,"foo"> or conn.CreateCommand<42, "foo">(arg1, arg2)? + member __.StaticParameters = staticParameters + + +/// A table of methods for Intellisense completion +// +// Note: this type does not hold any strong references to any compiler resources, nor does evaluating any of the properties execute any +// code on the compiler thread. +[] +type FSharpMethodGroup( name: string, unsortedMethods: FSharpMethodGroupItem[] ) = + // BUG 413009 : [ParameterInfo] takes about 3 seconds to move from one overload parameter to another + // cache allows to avoid recomputing parameterinfo for the same item +#if !FX_NO_WEAKTABLE + static let methodOverloadsCache = System.Runtime.CompilerServices.ConditionalWeakTable() +#endif + + let methods = + unsortedMethods + // Methods with zero arguments show up here as taking a single argument of type 'unit'. Patch them now to appear as having zero arguments. + |> Array.map (fun meth -> + let parms = meth.Parameters + if parms.Length = 1 && parms.[0].CanonicalTypeTextForSorting="Microsoft.FSharp.Core.Unit" then + FSharpMethodGroupItem(meth.StructuredDescription, meth.XmlDoc, meth.StructuredReturnTypeText, [||], true, meth.HasParamArrayArg, meth.StaticParameters) + else + meth) + // Fix the order of methods, to be stable for unit testing. + |> Array.sortBy (fun meth -> + let parms = meth.Parameters + parms.Length, (parms |> Array.map (fun p -> p.CanonicalTypeTextForSorting))) + + member __.MethodName = name + + member __.Methods = methods + + static member Create (infoReader: InfoReader, m, denv, items:ItemWithInst list) = + let g = infoReader.g + if isNil items then new FSharpMethodGroup("", [| |]) else + let name = items.Head.Item.DisplayName + + let methods = + [| for item in items do +#if !FX_NO_WEAKTABLE + match methodOverloadsCache.TryGetValue item with + | true, res -> yield! res + | false, _ -> +#endif + let flatItems = AnotherFlattenItems g m item.Item + + let methods = + flatItems |> Array.ofList |> Array.map (fun flatItem -> + let prettyParams, prettyRetTyL = + ErrorScope.Protect m + (fun () -> PrettyParamsAndReturnTypeOfItem infoReader m denv { item with Item = flatItem }) + (fun err -> [], wordL (tagText err)) + + let description = FSharpToolTipText [SymbolHelpers.FormatStructuredDescriptionOfItem true infoReader m denv { item with Item = flatItem }] + + let hasParamArrayArg = + match flatItem with + | Item.CtorGroup(_,[meth]) + | Item.MethodGroup(_,[meth],_) -> meth.HasParamArrayArg(infoReader.amap, m, meth.FormalMethodInst) + | _ -> false + + let hasStaticParameters = + match flatItem with +#if EXTENSIONTYPING + | SymbolHelpers.ItemIsProvidedTypeWithStaticArguments m g _ -> false +#endif + | _ -> true + + FSharpMethodGroupItem( + description = description, + returnType = prettyRetTyL, + xmlDoc = SymbolHelpers.GetXmlCommentForItem infoReader m flatItem, + parameters = (prettyParams |> Array.ofList), + hasParameters = hasStaticParameters, + hasParamArrayArg = hasParamArrayArg, +#if EXTENSIONTYPING + staticParameters = StaticParamsOfItem infoReader m denv flatItem +#else + staticParameters = [| |] +#endif + )) +#if !FX_NO_WEAKTABLE + methodOverloadsCache.Add(item, methods) +#endif + yield! methods + |] + + new FSharpMethodGroup(name, methods) + + + diff --git a/src/fsharp/vs/ServiceDeclarationLists.fsi b/src/fsharp/vs/ServiceDeclarationLists.fsi new file mode 100644 index 0000000000..33a05b442e --- /dev/null +++ b/src/fsharp/vs/ServiceDeclarationLists.fsi @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +//---------------------------------------------------------------------------- +// API for declaration lists and method overload lists + +namespace Microsoft.FSharp.Compiler.SourceCodeServices + +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 + + +[] +/// Represents a declaration in F# source code, with information attached ready for display by an editor. +/// Returned by GetDeclarations. +// +// Note: this type holds a weak reference to compiler resources. +#if COMPILER_PUBLIC_API +type FSharpDeclarationListItem = +#else +type internal FSharpDeclarationListItem = +#endif + /// Get the display name for the declaration. + member Name : string + /// Get the name for the declaration as it's presented in source code. + member NameInCode : string + /// Get the description text for the declaration. Computing this property may require using compiler + /// resources and may trigger execution of a type provider method to retrieve documentation. + /// + /// May return "Loading..." if timeout occurs + member StructuredDescriptionText : FSharpStructuredToolTipText + member DescriptionText : FSharpToolTipText + + /// Get the description text, asynchronously. Never returns "Loading...". + member StructuredDescriptionTextAsync : Async + member DescriptionTextAsync : Async + member Glyph : FSharpGlyph + member Accessibility : FSharpAccessibility option + member Kind : CompletionItemKind + member IsOwnMember : bool + member MinorPriority : int + member FullName : string + member IsResolved : bool + member NamespaceToOpen : string option + + +[] +/// Represents a set of declarations in F# source code, with information attached ready for display by an editor. +/// Returned by GetDeclarations. +// +// Note: this type holds a weak reference to compiler resources. +#if COMPILER_PUBLIC_API +type FSharpDeclarationListInfo = +#else +type internal FSharpDeclarationListInfo = +#endif + member Items : FSharpDeclarationListItem[] + member IsForType : bool + member IsError : bool + + // Implementation details used by other code in the compiler + static member internal Create : infoReader:InfoReader * m:range * denv:DisplayEnv * getAccessibility:(Item -> FSharpAccessibility option) * items:CompletionItem list * reactor:IReactorOperations * currentNamespace:string[] option * isAttributeApplicationContex:bool * checkAlive:(unit -> bool) -> FSharpDeclarationListInfo + static member internal Error : message:string -> FSharpDeclarationListInfo + static member Empty : FSharpDeclarationListInfo + +/// Represents one parameter for one method (or other item) in a group. +[] +#if COMPILER_PUBLIC_API +type FSharpMethodGroupItemParameter = +#else +type internal FSharpMethodGroupItemParameter = +#endif + + /// The name of the parameter. + member ParameterName: string + + /// A key that can be used for sorting the parameters, used to help sort overloads. + member CanonicalTypeTextForSorting: string + + /// The structured representation for the parameter including its name, its type and visual indicators of other + /// information such as whether it is optional. + member StructuredDisplay: Layout + + /// The text to display for the parameter including its name, its type and visual indicators of other + /// information such as whether it is optional. + member Display: string + + /// Is the parameter optional + member IsOptional: bool + +/// Represents one method (or other item) in a method group. The item may represent either a method or +/// a single, non-overloaded item such as union case or a named function value. +[] +#if COMPILER_PUBLIC_API +type FSharpMethodGroupItem = +#else +type internal FSharpMethodGroupItem = +#endif + + /// The documentation for the item + member XmlDoc : FSharpXmlDoc + + /// The structured description representation for the method (or other item) + member StructuredDescription : FSharpStructuredToolTipText + + /// The formatted description text for the method (or other item) + member Description : FSharpToolTipText + + /// The The structured description representation for the method (or other item) + member StructuredReturnTypeText: Layout + + /// The formatted type text for the method (or other item) + member ReturnTypeText: string + + /// The parameters of the method in the overload set + member Parameters: FSharpMethodGroupItemParameter[] + + /// Does the method support an arguments list? This is always true except for static type instantiations like TP<42,"foo">. + member HasParameters: bool + + /// Does the method support a params list arg? + member HasParamArrayArg: bool + + /// Does the type name or method support a static arguments list, like TP<42,"foo"> or conn.CreateCommand<42, "foo">(arg1, arg2)? + member StaticParameters: FSharpMethodGroupItemParameter[] + +/// Represents a group of methods (or other items) returned by GetMethods. +[] +#if COMPILER_PUBLIC_API +type FSharpMethodGroup = +#else +type internal FSharpMethodGroup = +#endif + + internal new : string * FSharpMethodGroupItem[] -> FSharpMethodGroup + + /// The shared name of the methods (or other items) in the group + member MethodName: string + + /// The methods (or other items) in the group + member Methods: FSharpMethodGroupItem[] + + static member internal Create : InfoReader * range * DisplayEnv * ItemWithInst list -> FSharpMethodGroup + diff --git a/src/fsharp/vs/ServiceInterfaceStubGenerator.fs b/src/fsharp/vs/ServiceInterfaceStubGenerator.fs index 00e48a068b..96c92aac24 100644 --- a/src/fsharp/vs/ServiceInterfaceStubGenerator.fs +++ b/src/fsharp/vs/ServiceInterfaceStubGenerator.fs @@ -11,6 +11,7 @@ open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +#if !FX_NO_INDENTED_TEXT_WRITER [] module internal CodeGenerationUtils = open System.IO @@ -447,7 +448,7 @@ module internal InterfaceStubGenerator = let internal (|TypeOfMember|_|) (m: FSharpMemberOrFunctionOrValue) = match m.FullTypeSafe with - | Some (MemberFunctionType typ) when m.IsProperty && m.EnclosingEntity.IsFSharp -> + | Some (MemberFunctionType typ) when m.IsProperty && m.EnclosingEntity.IsSome && m.EnclosingEntity.Value.IsFSharp -> Some typ | Some typ -> Some typ | None -> None @@ -909,3 +910,4 @@ module internal InterfaceStubGenerator = None | ParsedInput.ImplFile input -> walkImplFileInput input +#endif diff --git a/src/fsharp/vs/ServiceInterfaceStubGenerator.fsi b/src/fsharp/vs/ServiceInterfaceStubGenerator.fsi index b0ea456e17..f75f7028d1 100644 --- a/src/fsharp/vs/ServiceInterfaceStubGenerator.fsi +++ b/src/fsharp/vs/ServiceInterfaceStubGenerator.fsi @@ -11,6 +11,7 @@ open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +#if !FX_NO_INDENTED_TEXT_WRITER /// Capture information about an interface in ASTs [] type internal InterfaceData = @@ -42,3 +43,4 @@ module internal InterfaceStubGenerator = /// Find corresponding interface declaration at a given position val tryFindInterfaceDeclaration: pos -> parsedInput: ParsedInput -> InterfaceData option +#endif diff --git a/src/fsharp/vs/ServiceLexing.fs b/src/fsharp/vs/ServiceLexing.fs index 8545656af3..a64ae99448 100755 --- a/src/fsharp/vs/ServiceLexing.fs +++ b/src/fsharp/vs/ServiceLexing.fs @@ -70,6 +70,17 @@ module FSharpTokenTag = let RARROW = tagOfToken RARROW let LARROW = tagOfToken LARROW let QUOTE = tagOfToken QUOTE + let WHITESPACE = tagOfToken (WHITESPACE Unchecked.defaultof<_>) + let COMMENT = tagOfToken (COMMENT Unchecked.defaultof<_>) + let LINE_COMMENT = tagOfToken (LINE_COMMENT Unchecked.defaultof<_>) + let BEGIN = tagOfToken BEGIN + let DO = tagOfToken DO + let FUNCTION = tagOfToken FUNCTION + let THEN = tagOfToken THEN + let ELSE = tagOfToken ELSE + let STRUCT = tagOfToken STRUCT + let CLASS = tagOfToken CLASS + let TRY = tagOfToken TRY /// This corresponds to a token categorization originally used in Visual Studio 2003. @@ -304,6 +315,7 @@ type FSharpTokenizerColorState = | Comment = 5 | StringInComment = 6 | VerbatimStringInComment = 7 + | CamlOnly = 8 | VerbatimString = 9 | SingleLineComment = 10 | EndLineThenSkip = 11 @@ -414,6 +426,7 @@ module internal LexerStateEncoding = | LexCont.StringInComment (ifd,n,m) -> FSharpTokenizerColorState.StringInComment, resize32 n, m.Start, ifd | LexCont.VerbatimStringInComment (ifd,n,m) -> FSharpTokenizerColorState.VerbatimStringInComment, resize32 n, m.Start, ifd | LexCont.TripleQuoteStringInComment (ifd,n,m) -> FSharpTokenizerColorState.TripleQuoteStringInComment,resize32 n, m.Start, ifd + | LexCont.MLOnly (ifd,m) -> FSharpTokenizerColorState.CamlOnly, 0L, m.Start, ifd | LexCont.VerbatimString (ifd,m) -> FSharpTokenizerColorState.VerbatimString, 0L, m.Start, ifd | LexCont.TripleQuoteString (ifd,m) -> FSharpTokenizerColorState.TripleQuoteString, 0L, m.Start, ifd encodeLexCont tag n1 p1 ifd lightSyntaxStatus @@ -431,6 +444,7 @@ module internal LexerStateEncoding = | FSharpTokenizerColorState.StringInComment -> LexCont.StringInComment (ifd,n1,mkRange "file" p1 p1) | FSharpTokenizerColorState.VerbatimStringInComment -> LexCont.VerbatimStringInComment (ifd,n1,mkRange "file" p1 p1) | FSharpTokenizerColorState.TripleQuoteStringInComment -> LexCont.TripleQuoteStringInComment (ifd,n1,mkRange "file" p1 p1) + | FSharpTokenizerColorState.CamlOnly -> LexCont.MLOnly (ifd,mkRange "file" p1 p1) | FSharpTokenizerColorState.VerbatimString -> LexCont.VerbatimString (ifd,mkRange "file" p1 p1) | FSharpTokenizerColorState.TripleQuoteString -> LexCont.TripleQuoteString (ifd,mkRange "file" p1 p1) | FSharpTokenizerColorState.EndLineThenSkip -> LexCont.EndLine(LexerEndlineContinuation.Skip(ifd,n1,mkRange "file" p1 p1)) @@ -456,6 +470,7 @@ module internal LexerStateEncoding = | LexCont.StringInComment (ifd,n,m) -> Lexer.stringInComment n m (argsWithIfDefs ifd) skip lexbuf | LexCont.VerbatimStringInComment (ifd,n,m) -> Lexer.verbatimStringInComment n m (argsWithIfDefs ifd) skip lexbuf | LexCont.TripleQuoteStringInComment (ifd,n,m) -> Lexer.tripleQuoteStringInComment n m (argsWithIfDefs ifd) skip lexbuf + | LexCont.MLOnly (ifd,m) -> Lexer.mlOnly m (argsWithIfDefs ifd) skip lexbuf | LexCont.VerbatimString (ifd,m) -> Lexer.verbatimString (ByteBuffer.Create 100,defaultStringFinisher,m,(argsWithIfDefs ifd)) skip lexbuf | LexCont.TripleQuoteString (ifd,m) -> Lexer.tripleQuoteString (ByteBuffer.Create 100,defaultStringFinisher,m,(argsWithIfDefs ifd)) skip lexbuf @@ -758,26 +773,3 @@ module Keywords = let NormalizeIdentifierBackticks s = NormalizeIdentifierBackticks s let KeywordsWithDescription = keywordsWithDescription -[] -type SourceTokenizer = FSharpSourceTokenizer - -[] -type LineTokenizer = FSharpLineTokenizer - -[] -type TokenInformation = FSharpTokenInfo - -[] -type TriggerClass = FSharpTokenTriggerClass - -[] -type TokenCharKind = FSharpTokenCharKind - -[] -type TokenColorKind = FSharpTokenColorKind - -[] -type ColorState = FSharpTokenizerColorState - -[] -type LexState = FSharpTokenizerLexState diff --git a/src/fsharp/vs/ServiceLexing.fsi b/src/fsharp/vs/ServiceLexing.fsi index 8aabb253bd..11de8ac4f9 100755 --- a/src/fsharp/vs/ServiceLexing.fsi +++ b/src/fsharp/vs/ServiceLexing.fsi @@ -29,6 +29,7 @@ type FSharpTokenizerColorState = | Comment = 5 | StringInComment = 6 | VerbatimStringInComment = 7 + | CamlOnly = 8 | VerbatimString = 9 | SingleLineComment = 10 | EndLineThenSkip = 11 @@ -170,6 +171,28 @@ module FSharpTokenTag = val LARROW : int /// Indicates the token is a `"` val QUOTE : int + /// Indicates the token is a whitespace + val WHITESPACE : int + /// Indicates the token is a comment + val COMMENT : int + /// Indicates the token is a line comment + val LINE_COMMENT : int + /// Indicates the token is keyword `begin` + val BEGIN : int + /// Indicates the token is keyword `do` + val DO : int + /// Indicates the token is keyword `function` + val FUNCTION : int + /// Indicates the token is keyword `then` + val THEN : int + /// Indicates the token is keyword `else` + val ELSE : int + /// Indicates the token is keyword `struct` + val STRUCT : int + /// Indicates the token is keyword `class` + val CLASS : int + /// Indicates the token is keyword `try` + val TRY : int /// Information about a particular token from the tokenizer type FSharpTokenInfo = diff --git a/src/fsharp/vs/ServiceNavigation.fsi b/src/fsharp/vs/ServiceNavigation.fsi index 476973ea19..4b17f7f97a 100755 --- a/src/fsharp/vs/ServiceNavigation.fsi +++ b/src/fsharp/vs/ServiceNavigation.fsi @@ -10,7 +10,11 @@ namespace Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler /// Indicates a kind of item to show in an F# navigation bar +#if COMPILER_PUBLIC_API type FSharpNavigationDeclarationItemKind = +#else +type internal FSharpNavigationDeclarationItemKind = +#endif | NamespaceDecl | ModuleFileDecl | ExnDecl @@ -22,7 +26,11 @@ type FSharpNavigationDeclarationItemKind = | OtherDecl [] +#if COMPILER_PUBLIC_API type FSharpEnclosingEntityKind = +#else +type internal FSharpEnclosingEntityKind = +#endif | Namespace | Module | Class @@ -34,7 +42,11 @@ type FSharpEnclosingEntityKind = /// Represents an item to be displayed in the navigation bar [] -type (*internal*) FSharpNavigationDeclarationItem = +#if COMPILER_PUBLIC_API +type FSharpNavigationDeclarationItem = +#else +type internal FSharpNavigationDeclarationItem = +#endif member Name : string member UniqueName : string member Glyph : FSharpGlyph @@ -49,7 +61,11 @@ type (*internal*) FSharpNavigationDeclarationItem = /// Represents top-level declarations (that should be in the type drop-down) /// with nested declarations (that can be shown in the member drop-down) [] -type (*internal*) FSharpNavigationTopLevelDeclaration = +#if COMPILER_PUBLIC_API +type FSharpNavigationTopLevelDeclaration = +#else +type internal FSharpNavigationTopLevelDeclaration = +#endif { Declaration : FSharpNavigationDeclarationItem Nested : FSharpNavigationDeclarationItem[] } @@ -57,7 +73,11 @@ type (*internal*) FSharpNavigationTopLevelDeclaration = /// all the members and currently selected indices. First level correspond to /// types & modules and second level are methods etc. [] -type (*internal*) FSharpNavigationItems = +#if COMPILER_PUBLIC_API +type FSharpNavigationItems = +#else +type internal FSharpNavigationItems = +#endif member Declarations : FSharpNavigationTopLevelDeclaration[] // implementation details used by other code in the compiler @@ -67,7 +87,11 @@ module internal NavigationImpl = val internal getNavigation : Ast.ParsedInput -> FSharpNavigationItems val internal empty : FSharpNavigationItems +#if COMPILER_PUBLIC_API module NavigateTo = +#else +module internal NavigateTo = +#endif [] type NavigableItemKind = | Module diff --git a/src/fsharp/vs/ServiceParamInfoLocations.fs b/src/fsharp/vs/ServiceParamInfoLocations.fs index 5c36ca2a3e..f72c1f4a2a 100755 --- a/src/fsharp/vs/ServiceParamInfoLocations.fs +++ b/src/fsharp/vs/ServiceParamInfoLocations.fs @@ -266,5 +266,3 @@ type FSharpNoteworthyParamInfoLocations with r | _ -> None -[] -type NoteworthyParamInfoLocations = FSharpNoteworthyParamInfoLocations diff --git a/src/fsharp/vs/ServiceParamInfoLocations.fsi b/src/fsharp/vs/ServiceParamInfoLocations.fsi index 40c044e814..ee33ddd39c 100755 --- a/src/fsharp/vs/ServiceParamInfoLocations.fsi +++ b/src/fsharp/vs/ServiceParamInfoLocations.fsi @@ -11,7 +11,11 @@ open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.Range [] -type (*internal*) FSharpNoteworthyParamInfoLocations = +#if COMPILER_PUBLIC_API +type FSharpNoteworthyParamInfoLocations = +#else +type internal FSharpNoteworthyParamInfoLocations = +#endif member LongId : string list member LongIdStartLocation : pos member LongIdEndLocation : pos diff --git a/src/fsharp/vs/ServiceParseTreeWalk.fs b/src/fsharp/vs/ServiceParseTreeWalk.fs index 45fe2d5a76..796b5ed088 100755 --- a/src/fsharp/vs/ServiceParseTreeWalk.fs +++ b/src/fsharp/vs/ServiceParseTreeWalk.fs @@ -13,7 +13,11 @@ open Microsoft.FSharp.Compiler.Ast /// A range of utility functions to assist with traversing an AST -module (*internal*) AstTraversal = +#if COMPILER_PUBLIC_API +module AstTraversal = +#else +module internal AstTraversal = +#endif // treat ranges as though they are half-open: [,) let rangeContainsPosLeftEdgeInclusive (m1:range) p = if posEq m1.Start m1.End then @@ -143,7 +147,7 @@ module (*internal*) AstTraversal = /// traverse an implementation file walking all the way down to SynExpr or TypeAbbrev at a particular location /// - let (*internal*) Traverse(pos:pos, parseTree, visitor:AstVisitorBase<'T>) = + let Traverse(pos:pos, parseTree, visitor:AstVisitorBase<'T>) = let pick x = pick pos x let rec traverseSynModuleDecl path (decl:SynModuleDecl) = let pick = pick decl.Range diff --git a/src/fsharp/vs/ServiceStructure.fs b/src/fsharp/vs/ServiceStructure.fs index d94632054e..edc38ffb85 100644 --- a/src/fsharp/vs/ServiceStructure.fs +++ b/src/fsharp/vs/ServiceStructure.fs @@ -11,33 +11,33 @@ module Structure = /// Set of visitor utilities, designed for the express purpose of fetching ranges /// from an untyped AST for the purposes of block structure. [] - module private Range = + module Range = /// Create a range starting at the end of r1 and finishing at the end of r2 - let inline endToEnd (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.End r2.End + let endToEnd (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.End r2.End /// Create a range starting at the end of r1 and finishing at the start of r2 - let inline endToStart (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.End r2.Start + let endToStart (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.End r2.Start /// Create a range beginning at the start of r1 and finishing at the end of r2 - let inline startToEnd (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.Start r2.End + let startToEnd (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.Start r2.End /// Create a range beginning at the start of r1 and finishing at the start of r2 - let inline startToStart (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.Start r2.Start + let startToStart (r1: range) (r2: range) = mkFileIndexRange r1.FileIndex r1.Start r2.Start /// Create a new range from r by shifting the starting column by m - let inline modStart (m:int) (r: range) = + let modStart (m:int) (r: range) = let modstart = mkPos r.StartLine (r.StartColumn+m) mkFileIndexRange r.FileIndex modstart r.End /// Create a new range from r by shifting the ending column by m - let inline modEnd (m:int) (r: range) = + let modEnd (m:int) (r: range) = let modend = mkPos r.EndLine (r.EndColumn+m) mkFileIndexRange r.FileIndex r.Start modend /// Produce a new range by adding modStart to the StartColumn of `r` /// and subtracting modEnd from the EndColumn of `r` - let inline modBoth modStart modEnd (r:range) = + let modBoth modStart modEnd (r:range) = let rStart = mkPos r.StartLine (r.StartColumn+modStart) let rEnd = mkPos r.EndLine (r.EndColumn - modEnd) mkFileIndexRange r.FileIndex rStart rEnd @@ -63,13 +63,12 @@ module Structure = | ls -> ls |> List.map (fun x -> - match x with - | SynSimplePat.Attrib(range = r) - | SynSimplePat.Id(range = r) - | SynSimplePat.Typed(range = r) -> r) + match x with + | SynSimplePat.Attrib(range = r) + | SynSimplePat.Id(range = r) + | SynSimplePat.Typed(range = r) -> r) |> List.reduce Range.unionRanges - /// Collapse indicates the way a range/snapshot should be collapsed. `Same` is for a scope inside /// some kind of scope delimiter, e.g. `[| ... |]`, `[ ... ]`, `{ ... }`, etc. `Below` is for expressions /// following a binding or the right hand side of a pattern, e.g. `let x = ...` @@ -127,83 +126,95 @@ module Structure = | UnionDefn | Comment | XmlDocComment - override self.ToString() = self |> function - | Open -> "Open" - | Namespace -> "Namespace" - | Module -> "Module" - | Type -> "Type" - | Member -> "Member" - | LetOrUse -> "LetOrUse" - | Val -> "Val" - | CompExpr -> "CompExpr" - | IfThenElse -> "IfThenElse" - | ThenInIfThenElse -> "ThenInIfThenElse" - | ElseInIfThenElse -> "ElseInIfThenElse" - | TryWith -> "TryWith" - | TryInTryWith -> "TryInTryWith" - | WithInTryWith -> "WithInTryWith" - | TryFinally -> "TryFinally" - | TryInTryFinally -> "TryInTryFinally" - | FinallyInTryFinally -> "FinallyInTryFinally" - | ArrayOrList -> "ArrayOrList" - | ObjExpr -> "ObjExpr" - | For -> "For" - | While -> "While" - | Match -> "Match" - | MatchLambda -> "MatchLambda" - | MatchClause -> "MatchClause" - | Lambda -> "Lambda" - | CompExprInternal -> "CompExprInternal" - | Quote -> "Quote" - | Record -> "Record" - | SpecialFunc -> "SpecialFunc" - | Do -> "Do" - | New -> "New" - | Attribute -> "Attribute" - | Interface -> "Interface" - | HashDirective -> "HashDirective" - | LetOrUseBang -> "LetOrUseBang" - | TypeExtension -> "TypeExtension" - | YieldOrReturn -> "YieldOrReturn" - | YieldOrReturnBang -> "YieldOrReturnBang" - | Tuple -> "Tuple" - | UnionCase -> "UnionCase" - | EnumCase -> "EnumCase" - | RecordField -> "RecordField" - | RecordDefn -> "RecordDefn" - | UnionDefn -> "UnionDefn" - | Comment -> "Comment" - | XmlDocComment -> "XmlDocComment" + override self.ToString() = + match self with + | Open -> "Open" + | Namespace -> "Namespace" + | Module -> "Module" + | Type -> "Type" + | Member -> "Member" + | LetOrUse -> "LetOrUse" + | Val -> "Val" + | CompExpr -> "CompExpr" + | IfThenElse -> "IfThenElse" + | ThenInIfThenElse -> "ThenInIfThenElse" + | ElseInIfThenElse -> "ElseInIfThenElse" + | TryWith -> "TryWith" + | TryInTryWith -> "TryInTryWith" + | WithInTryWith -> "WithInTryWith" + | TryFinally -> "TryFinally" + | TryInTryFinally -> "TryInTryFinally" + | FinallyInTryFinally -> "FinallyInTryFinally" + | ArrayOrList -> "ArrayOrList" + | ObjExpr -> "ObjExpr" + | For -> "For" + | While -> "While" + | Match -> "Match" + | MatchLambda -> "MatchLambda" + | MatchClause -> "MatchClause" + | Lambda -> "Lambda" + | CompExprInternal -> "CompExprInternal" + | Quote -> "Quote" + | Record -> "Record" + | SpecialFunc -> "SpecialFunc" + | Do -> "Do" + | New -> "New" + | Attribute -> "Attribute" + | Interface -> "Interface" + | HashDirective -> "HashDirective" + | LetOrUseBang -> "LetOrUseBang" + | TypeExtension -> "TypeExtension" + | YieldOrReturn -> "YieldOrReturn" + | YieldOrReturnBang -> "YieldOrReturnBang" + | Tuple -> "Tuple" + | UnionCase -> "UnionCase" + | EnumCase -> "EnumCase" + | RecordField -> "RecordField" + | RecordDefn -> "RecordDefn" + | UnionDefn -> "UnionDefn" + | Comment -> "Comment" + | XmlDocComment -> "XmlDocComment" /// Stores the range for a construct, the sub-range that should be collapsed for outlinging, /// a tag for the construct type, and a tag for the collapse style [] - type ScopeRange = { - Scope: Scope - Collapse: Collapse - /// HintSpan in BlockSpan - Range: range - /// TextSpan in BlockSpan - CollapseRange:range - } - - /// Validation function to ensure that ranges yielded for outlinging span 2 or more lines - let inline rcheck scope collapse (fullRange:range) (collapseRange:range) = - seq { - if fullRange.StartLine <> fullRange.EndLine then - yield { Scope = scope - Collapse = collapse - Range = fullRange - CollapseRange = collapseRange } - } + type ScopeRange = + { Scope: Scope + Collapse: Collapse + /// HintSpan in BlockSpan + Range: range + /// TextSpan in BlockSpan + CollapseRange: range } + + type LineNumber = int + type LineStr = string + type CommentType = SingleLine | XmlDoc + + [] + type CommentList = + { Lines: ResizeArray + Type: CommentType } + static member New ty lineStr = + { Type = ty + Lines = ResizeArray [lineStr] } - //============================================// - // Implementation File AST Traversal // - //============================================// + /// Returns outlining ranges for given parsed input. + let getOutliningRanges (sourceLines: string[]) (parsedInput: ParsedInput) = + let acc = ResizeArray() + /// Validation function to ensure that ranges yielded for outlinging span 2 or more lines + let inline rcheck scope collapse (fullRange: range) (collapseRange: range) = + if fullRange.StartLine <> fullRange.EndLine then + acc.Add { Scope = scope + Collapse = collapse + Range = fullRange + CollapseRange = collapseRange } + + //============================================// + // Implementation File AST Traversal // + //============================================// - let rec parseExpr expression = - seq { + let rec parseExpr expression = match expression with | SynExpr.Upcast (e,_,_) | SynExpr.Downcast (e,_,_) @@ -215,84 +226,84 @@ module Structure = | SynExpr.DotSet (e,_,_,_) | SynExpr.Typed (e,_,_) | SynExpr.DotIndexedGet (e,_,_,_) - | SynExpr.DotIndexedSet (e,_,_,_,_,_) -> yield! parseExpr e + | SynExpr.DotIndexedSet (e,_,_,_,_,_) -> parseExpr e | SynExpr.New (_,_,expr,r) -> let collapse = Range.endToEnd expr.Range r - yield! rcheck Scope.New Collapse.Below r collapse - yield! parseExpr expr + rcheck Scope.New Collapse.Below r collapse + parseExpr expr | SynExpr.YieldOrReturn (_,e,r) -> - yield! rcheck Scope.YieldOrReturn Collapse.Below r r - yield! parseExpr e + rcheck Scope.YieldOrReturn Collapse.Below r r + parseExpr e | SynExpr.YieldOrReturnFrom (_,e,r) -> - yield! rcheck Scope.YieldOrReturnBang Collapse.Below r r - yield! parseExpr e + rcheck Scope.YieldOrReturnBang Collapse.Below r r + parseExpr e | SynExpr.DoBang (e,r) -> - yield! rcheck Scope.Do Collapse.Below r <| Range.modStart 3 r - yield! parseExpr e + rcheck Scope.Do Collapse.Below r <| Range.modStart 3 r + parseExpr e | SynExpr.LetOrUseBang (_,_,_,pat,e1,e2,_) -> // for `let!` or `use!` the pattern begins at the end of the keyword so that // this scope can be used without adjustment if there is no `=` on the same line // if there is an `=` the range will be adjusted during the tooltip creation let r = Range.endToEnd pat.Range e1.Range - yield! rcheck Scope.LetOrUseBang Collapse.Below r r - yield! parseExpr e1 - yield! parseExpr e2 + rcheck Scope.LetOrUseBang Collapse.Below r r + parseExpr e1 + parseExpr e2 | SynExpr.For (_,_,_,_,_,e,r) | SynExpr.ForEach (_,_,_,_,_,e,r) -> - yield! rcheck Scope.For Collapse.Below r r - yield! parseExpr e + rcheck Scope.For Collapse.Below r r + parseExpr e | SynExpr.LetOrUse (_,_,bindings, body, _) -> - yield! parseBindings bindings - yield! parseExpr body + parseBindings bindings + parseExpr body | SynExpr.Match (seqPointAtBinding,_expr,clauses,_,r) -> match seqPointAtBinding with | SequencePointAtBinding sr -> let collapse = Range.endToEnd sr r - yield! rcheck Scope.Match Collapse.Same r collapse + rcheck Scope.Match Collapse.Same r collapse | _ -> () - yield! parseMatchClauses clauses + List.iter parseMatchClause clauses | SynExpr.MatchLambda (_,caseRange,clauses,matchSeqPoint,r) -> let caseRange = match matchSeqPoint with | SequencePointAtBinding r -> r | _ -> caseRange let collapse = Range.endToEnd caseRange r - yield! rcheck Scope.MatchLambda Collapse.Same r collapse - yield! parseMatchClauses clauses + rcheck Scope.MatchLambda Collapse.Same r collapse + List.iter parseMatchClause clauses | SynExpr.App (atomicFlag,isInfix,funcExpr,argExpr,r) -> // seq exprs, custom operators, etc if ExprAtomicFlag.NonAtomic=atomicFlag && (not isInfix) - && (function | SynExpr.Ident _ -> true | _ -> false) funcExpr - && (function | SynExpr.CompExpr _ -> false | _ -> true ) argExpr then + && (function SynExpr.Ident _ -> true | _ -> false) funcExpr + && (function SynExpr.CompExpr _ -> false | _ -> true ) argExpr then // if the argExrp is a computation expression another match will handle the outlining // these cases must be removed to prevent creating unnecessary tags for the same scope let collapse = Range.endToEnd funcExpr.Range r - yield! rcheck Scope.SpecialFunc Collapse.Below r collapse + rcheck Scope.SpecialFunc Collapse.Below r collapse elif ExprAtomicFlag.NonAtomic=atomicFlag && (not isInfix) - && (function | SynExpr.CompExpr _ -> true | _ -> false) argExpr then + && (function SynExpr.CompExpr _ -> true | _ -> false) argExpr then let collapse = Range.startToEnd argExpr.Range r - yield! rcheck Scope.CompExpr Collapse.Same r <| Range.modBoth 1 1 collapse - yield! parseExpr argExpr - yield! parseExpr funcExpr + rcheck Scope.CompExpr Collapse.Same r <| Range.modBoth 1 1 collapse + parseExpr argExpr + parseExpr funcExpr | SynExpr.Sequential (_,_,e1,e2,_) -> - yield! parseExpr e1 - yield! parseExpr e2 + parseExpr e1 + parseExpr e2 | SynExpr.ArrayOrListOfSeqExpr (isArray,e,r) -> - yield! rcheck Scope.ArrayOrList Collapse.Same r <| Range.modBoth (if isArray then 2 else 1) (if isArray then 2 else 1) r - yield! parseExpr e + rcheck Scope.ArrayOrList Collapse.Same r <| Range.modBoth (if isArray then 2 else 1) (if isArray then 2 else 1) r + parseExpr e | SynExpr.CompExpr (_arrayOrList,_,e,_r) as _c -> - yield! parseExpr e + parseExpr e | SynExpr.ObjExpr (_,argOpt,bindings,extraImpls,newRange,wholeRange) as _objExpr -> match argOpt with | Some (args,_) -> let collapse = Range.endToEnd args.Range wholeRange - yield! rcheck Scope.ObjExpr Collapse.Below wholeRange collapse + rcheck Scope.ObjExpr Collapse.Below wholeRange collapse | None -> let collapse = Range.endToEnd newRange wholeRange - yield! rcheck Scope.ObjExpr Collapse.Below wholeRange collapse - yield! parseBindings bindings - yield! parseExprInterfaces extraImpls - | SynExpr.TryWith (e,_tryRange,matchClauses,_withRange,wholeRange,tryPoint,withPoint) -> + rcheck Scope.ObjExpr Collapse.Below wholeRange collapse + parseBindings bindings + parseExprInterfaces extraImpls + | SynExpr.TryWith (e,_,matchClauses,_,wholeRange,tryPoint,withPoint) -> match tryPoint, withPoint with | SequencePointAtTry tryRange, SequencePointAtWith withRange -> let fullrange = Range.startToEnd tryRange wholeRange @@ -301,456 +312,426 @@ module Structure = let fullrangeTry = Range.startToStart tryRange withRange let collapseWith = Range.endToEnd withRange wholeRange let fullrangeWith = Range.startToEnd withRange wholeRange - yield! rcheck Scope.TryWith Collapse.Below fullrange collapse - yield! rcheck Scope.TryInTryWith Collapse.Below fullrangeTry collapseTry - yield! rcheck Scope.WithInTryWith Collapse.Below fullrangeWith collapseWith + rcheck Scope.TryWith Collapse.Below fullrange collapse + rcheck Scope.TryInTryWith Collapse.Below fullrangeTry collapseTry + rcheck Scope.WithInTryWith Collapse.Below fullrangeWith collapseWith | _ -> () - yield! parseExpr e - yield! parseMatchClauses matchClauses - | SynExpr.TryFinally (tryExpr,finallyExpr,r,tryPoint,finallyPoint) as _tryFinally -> + parseExpr e + List.iter parseMatchClause matchClauses + | SynExpr.TryFinally (tryExpr,finallyExpr,r,tryPoint,finallyPoint) -> match tryPoint, finallyPoint with | SequencePointAtTry tryRange, SequencePointAtFinally finallyRange -> let collapse = Range.endToEnd tryRange finallyExpr.Range let fullrange = Range.startToEnd tryRange finallyExpr.Range let collapseFinally = Range.endToEnd finallyRange r let fullrangeFinally = Range.startToEnd finallyRange r - yield! rcheck Scope.TryFinally Collapse.Below fullrange collapse - yield! rcheck Scope.FinallyInTryFinally Collapse.Below fullrangeFinally collapseFinally + rcheck Scope.TryFinally Collapse.Below fullrange collapse + rcheck Scope.FinallyInTryFinally Collapse.Below fullrangeFinally collapseFinally | _ -> () - yield! parseExpr tryExpr - yield! parseExpr finallyExpr - | SynExpr.IfThenElse (ifExpr,thenExpr,elseExprOpt,spIfToThen,_,ifToThenRange,r) as _ifThenElse-> + parseExpr tryExpr + parseExpr finallyExpr + | SynExpr.IfThenElse (ifExpr,thenExpr,elseExprOpt,spIfToThen,_,ifToThenRange,r) -> match spIfToThen with | SequencePointAtBinding rt -> // Outline the entire IfThenElse let fullrange = Range.startToEnd rt r let collapse = Range.endToEnd ifExpr.Range r - yield! rcheck Scope.IfThenElse Collapse.Below fullrange collapse + rcheck Scope.IfThenElse Collapse.Below fullrange collapse // Outline the `then` scope let thenRange = Range.endToEnd (Range.modEnd -4 ifToThenRange) thenExpr.Range let thenCollapse = Range.endToEnd ifToThenRange thenExpr.Range - yield! rcheck Scope.ThenInIfThenElse Collapse.Below thenRange thenCollapse + rcheck Scope.ThenInIfThenElse Collapse.Below thenRange thenCollapse | _ -> () - yield! parseExpr ifExpr - yield! parseExpr thenExpr + parseExpr ifExpr + parseExpr thenExpr match elseExprOpt with | Some elseExpr -> match elseExpr with // prevent double collapsing on elifs - | SynExpr. IfThenElse (_,_,_,_,_,_,_) -> - yield! parseExpr elseExpr + | SynExpr.IfThenElse _ -> + parseExpr elseExpr | _ -> // This is not the best way to establish the position of `else` // the AST doesn't provide an easy way to find the position of the keyword // as such `else` will be left out of block structuring and outlining until a // a suitable approach is determined - yield! parseExpr elseExpr + parseExpr elseExpr | None -> () | SynExpr.While (_,_,e,r) -> - yield! rcheck Scope.While Collapse.Below r r - yield! parseExpr e + rcheck Scope.While Collapse.Below r r + parseExpr e | SynExpr.Lambda (_,_,pats,e,r) -> match pats with | SynSimplePats.SimplePats (_,pr) | SynSimplePats.Typed (_,_,pr) -> - yield! rcheck Scope.Lambda Collapse.Below r <| Range.endToEnd pr r - yield! parseExpr e + rcheck Scope.Lambda Collapse.Below r (Range.endToEnd pr r) + parseExpr e | SynExpr.Lazy (e,r) -> - yield! rcheck Scope.SpecialFunc Collapse.Below r r - yield! parseExpr e + rcheck Scope.SpecialFunc Collapse.Below r r + parseExpr e | SynExpr.Quote (_,isRaw,e,_,r) -> // subtract columns so the @@> or @> is not collapsed - yield! rcheck Scope.Quote Collapse.Same r <| Range.modBoth (if isRaw then 3 else 2) (if isRaw then 3 else 2) r - yield! parseExpr e + rcheck Scope.Quote Collapse.Same r (Range.modBoth (if isRaw then 3 else 2) (if isRaw then 3 else 2) r) + parseExpr e | SynExpr.Tuple (es,_,r) | SynExpr.StructTuple(es,_,r) -> - yield! rcheck Scope.Tuple Collapse.Same r r - yield! Seq.collect parseExpr es + rcheck Scope.Tuple Collapse.Same r r + List.iter parseExpr es | SynExpr.Paren (e,_,_,_) -> - yield! parseExpr e + parseExpr e | SynExpr.Record (recCtor,recCopy,recordFields,r) -> - if recCtor.IsSome then - let (_,ctorArgs,_,_,_) = recCtor.Value - yield! parseExpr ctorArgs - if recCopy.IsSome then - let (e,_) = recCopy.Value - yield! parseExpr e - yield! recordFields |> (Seq.choose (fun (_,e,_) -> e) >> Seq.collect parseExpr) + match recCtor with + | Some (_,ctorArgs,_,_,_) -> parseExpr ctorArgs + | _ -> () + match recCopy with + | Some (e,_) -> parseExpr e + | _ -> () + recordFields |> List.choose (fun (_,e,_) -> e) |> List.iter parseExpr // exclude the opening `{` and closing `}` of the record from collapsing - yield! rcheck Scope.Record Collapse.Same r <| Range.modBoth 1 1 r + rcheck Scope.Record Collapse.Same r <| Range.modBoth 1 1 r | _ -> () - } - and parseMatchClause (SynMatchClause.Clause(synPat,_,e,_r,_) as clause) = - let rec getLastPat = function - | SynPat.Or(_, pat, _) -> getLastPat pat - | x -> x + and parseMatchClause (SynMatchClause.Clause(synPat,_,e,_r,_) as clause) = + let rec getLastPat = function + | SynPat.Or(_, pat, _) -> getLastPat pat + | x -> x - seq { let synPat = getLastPat synPat let collapse = Range.endToEnd synPat.Range clause.Range // Collapse the scope starting with `->` - yield! rcheck Scope.MatchClause Collapse.Same e.Range collapse - yield! parseExpr e - } - - and parseMatchClauses = Seq.collect parseMatchClause - - and parseAttributes (attrs: SynAttributes) = - seq { - let attrListRange = - if List.isEmpty attrs then Seq.empty else - let range = Range.startToEnd (attrs.[0].Range) (attrs.[attrs.Length-1].ArgExpr.Range) - rcheck Scope.Attribute Collapse.Same range range + rcheck Scope.MatchClause Collapse.Same e.Range collapse + parseExpr e + + and parseAttributes (attrs: SynAttributes) = + let attrListRange() = + if not (List.isEmpty attrs) then + let range = Range.startToEnd (attrs.[0].Range) (attrs.[attrs.Length-1].ArgExpr.Range) + rcheck Scope.Attribute Collapse.Same range range + match attrs with | [] -> () - | [_] -> yield! attrListRange - | hd::tl -> - yield! attrListRange - yield! parseExpr hd.ArgExpr + | [_] -> attrListRange() + | head :: tail -> + attrListRange() + parseExpr head.ArgExpr // If there are more than 2 attributes only add tags to the 2nd and beyond, to avoid double collapsing on the first attribute - yield! tl |> Seq.collect (fun attr -> + for attr in tail do let range = Range.startToEnd attr.Range attr.ArgExpr.Range rcheck Scope.Attribute Collapse.Same range range - ) + // visit the expressions inside each attribute - yield! attrs |> Seq.collect (fun attr -> parseExpr attr.ArgExpr) - } + for attr in attrs do + parseExpr attr.ArgExpr - and parseBinding (SynBinding.Binding (_,kind,_,_,attrs,_,SynValData(memberFlags,_,_),_,_,expr,br,_) as binding) = - seq { + and parseBinding (SynBinding.Binding (_,kind,_,_,attrs,_,SynValData(memberFlags,_,_),_,_,expr,br,_) as binding) = match kind with | NormalBinding -> let collapse = Range.endToEnd binding.RangeOfBindingSansRhs binding.RangeOfBindingAndRhs match memberFlags with | Some ({MemberKind=MemberKind.Constructor}) -> let collapse = Range.startToEnd expr.Range br - yield! rcheck Scope.New Collapse.Below br collapse + rcheck Scope.New Collapse.Below br collapse | Some _ -> - yield! rcheck Scope.Member Collapse.Below binding.RangeOfBindingAndRhs collapse + rcheck Scope.Member Collapse.Below binding.RangeOfBindingAndRhs collapse | None -> - yield! rcheck Scope.LetOrUse Collapse.Below binding.RangeOfBindingAndRhs collapse + rcheck Scope.LetOrUse Collapse.Below binding.RangeOfBindingAndRhs collapse | DoBinding -> let r = Range.modStart 2 br - yield! rcheck Scope.Do Collapse.Below br r + rcheck Scope.Do Collapse.Below br r | _ -> () - yield! parseAttributes attrs - yield! parseExpr expr - } + parseAttributes attrs + parseExpr expr - and parseBindings sqs = sqs |> Seq.collect parseBinding + and parseBindings sqs = for bind in sqs do parseBinding bind - and parseExprInterface (InterfaceImpl(synType,bindings,range)) = seq{ - let collapse = Range.endToEnd synType.Range range |> Range.modEnd -1 - yield! rcheck Scope.Interface Collapse.Below range collapse - yield! parseBindings bindings - } + and parseExprInterface (InterfaceImpl(synType,bindings,range)) = + let collapse = Range.endToEnd synType.Range range |> Range.modEnd -1 + rcheck Scope.Interface Collapse.Below range collapse + parseBindings bindings - and parseExprInterfaces (intfs:SynInterfaceImpl list) = Seq.collect parseExprInterface intfs + and parseExprInterfaces (intfs: SynInterfaceImpl list) = List.iter parseExprInterface intfs - and parseSynMemberDefn (objectModelRange: range) d = - seq { + and parseSynMemberDefn (objectModelRange: range) d = match d with | SynMemberDefn.Member(SynBinding.Binding (attrs=attrs; valData=valData; headPat=synPat; range=bindingRange) as binding,_) -> match valData with | SynValData (Some { MemberKind=MemberKind.Constructor },_,_) -> let collapse = Range.endToEnd synPat.Range d.Range - yield! rcheck Scope.New Collapse.Below d.Range collapse + rcheck Scope.New Collapse.Below d.Range collapse | SynValData (Some { MemberKind=MemberKind.PropertyGet | MemberKind.PropertySet },_,_) -> let range = mkRange d.Range.FileName (mkPos d.Range.StartLine objectModelRange.StartColumn) d.Range.End - + let collapse = match synPat with | SynPat.LongIdent(longDotId=longIdent) -> Range.endToEnd longIdent.Range d.Range | _ -> Range.endToEnd bindingRange d.Range - yield! rcheck Scope.Member Collapse.Below range collapse + rcheck Scope.Member Collapse.Below range collapse | _ -> let collapse = Range.endToEnd bindingRange d.Range - yield! rcheck Scope.Member Collapse.Below d.Range collapse - yield! parseAttributes attrs - yield! parseBinding binding + rcheck Scope.Member Collapse.Below d.Range collapse + parseAttributes attrs + parseBinding binding | SynMemberDefn.LetBindings (bindings,_,_,_) -> - yield! parseBindings bindings + parseBindings bindings | SynMemberDefn.Interface (tp, iMembers, r) -> - yield! rcheck Scope.Interface Collapse.Below d.Range <| Range.endToEnd tp.Range d.Range + rcheck Scope.Interface Collapse.Below d.Range (Range.endToEnd tp.Range d.Range) match iMembers with - | Some members -> - yield! Seq.collect (parseSynMemberDefn r) members + | Some members -> List.iter (parseSynMemberDefn r) members | None -> () | SynMemberDefn.NestedType (td, _, _) -> - yield! parseTypeDefn td + parseTypeDefn td | SynMemberDefn.AbstractSlot (ValSpfn(synType=synt), _, r) -> - yield! rcheck Scope.Member Collapse.Below d.Range (Range.startToEnd synt.Range r) + rcheck Scope.Member Collapse.Below d.Range (Range.startToEnd synt.Range r) | SynMemberDefn.AutoProperty (synExpr=e; range=r) -> - yield! rcheck Scope.Member Collapse.Below d.Range r - yield! parseExpr e + rcheck Scope.Member Collapse.Below d.Range r + parseExpr e | _ -> () - } - - (* For Cases like - -------------- - type JsonDocument = - private { Json : string - Path : string } - Or - type JsonDocument = - internal | Json of string - | Path of string - *) - and parseSimpleRepr simple = - seq { + + (* For Cases like + -------------- + type JsonDocument = + private { Json : string + Path : string } + Or + type JsonDocument = + internal | Json of string + | Path of string + *) + and parseSimpleRepr simple = match simple with | SynTypeDefnSimpleRepr.Enum (cases,_er) -> for EnumCase (attrs, _, _, _, cr) in cases do - yield! rcheck Scope.EnumCase Collapse.Below cr cr - yield! parseAttributes attrs + rcheck Scope.EnumCase Collapse.Below cr cr + parseAttributes attrs | SynTypeDefnSimpleRepr.Record (_,fields,rr) -> - yield! rcheck Scope.RecordDefn Collapse.Same rr rr + rcheck Scope.RecordDefn Collapse.Same rr rr for Field (attrs,_,_,_,_,_,_,fr) in fields do - yield! rcheck Scope.RecordField Collapse.Below fr fr - yield! parseAttributes attrs + rcheck Scope.RecordField Collapse.Below fr fr + parseAttributes attrs | SynTypeDefnSimpleRepr.Union (_,cases,ur) -> - yield! rcheck Scope.UnionDefn Collapse.Same ur ur + rcheck Scope.UnionDefn Collapse.Same ur ur for UnionCase (attrs,_,_,_,_,cr) in cases do - yield! rcheck Scope.UnionCase Collapse.Below cr cr - yield! parseAttributes attrs + rcheck Scope.UnionCase Collapse.Below cr cr + parseAttributes attrs | _ -> () - } - and parseTypeDefn (TypeDefn(ComponentInfo(_,typeArgs,_,_,_,_,_,r), objectModel, members, fullrange)) = - seq { + and parseTypeDefn (TypeDefn(ComponentInfo(_,typeArgs,_,_,_,_,_,r), objectModel, members, fullrange)) = let typeArgsRange = rangeOfTypeArgsElse r typeArgs let collapse = Range.endToEnd (Range.modEnd 1 typeArgsRange) fullrange match objectModel with | SynTypeDefnRepr.ObjectModel (defnKind, objMembers, r) -> match defnKind with | TyconAugmentation -> - yield! rcheck Scope.TypeExtension Collapse.Below fullrange collapse + rcheck Scope.TypeExtension Collapse.Below fullrange collapse | _ -> - yield! rcheck Scope.Type Collapse.Below fullrange collapse - yield! Seq.collect (parseSynMemberDefn r) objMembers + rcheck Scope.Type Collapse.Below fullrange collapse + List.iter (parseSynMemberDefn r) objMembers // visit the members of a type extension - yield! Seq.collect (parseSynMemberDefn r) members + List.iter (parseSynMemberDefn r) members | SynTypeDefnRepr.Simple (simpleRepr, r) -> - yield! rcheck Scope.Type Collapse.Below fullrange collapse - yield! parseSimpleRepr simpleRepr - yield! Seq.collect (parseSynMemberDefn r) members + rcheck Scope.Type Collapse.Below fullrange collapse + parseSimpleRepr simpleRepr + List.iter (parseSynMemberDefn r) members | SynTypeDefnRepr.Exception _ -> () - } - - let getConsecutiveModuleDecls (predicate: SynModuleDecl -> range option) (scope: Scope) (decls: SynModuleDecls) = - let groupConsecutiveDecls input = - let rec loop (input: range list) (res: range list list) currentBulk = - match input, currentBulk with - | [], [] -> List.rev res - | [], _ -> List.rev (currentBulk::res) - | r :: rest, [] -> loop rest res [r] - | r :: rest, last :: _ when r.StartLine = last.EndLine + 1 -> - loop rest res (r::currentBulk) - | r :: rest, _ -> loop rest (currentBulk::res) [r] - loop input [] [] - - let selectRanges (ranges: range list) = - match ranges with - | [] -> None - | [r] when r.StartLine = r.EndLine -> None - | [r] -> - let range = mkRange "" r.Start r.End - Some { Scope = scope; Collapse = Collapse.Same; Range = range ; CollapseRange = range } - | lastRange :: rest -> - let firstRange = Seq.last rest - let range = mkRange "" firstRange.Start lastRange.End - Some { Scope = scope; Collapse = Collapse.Same; Range = range; CollapseRange = range } - - decls |> (List.choose predicate >> groupConsecutiveDecls >> List.choose selectRanges) - - let collectOpens = getConsecutiveModuleDecls (function SynModuleDecl.Open (_, r) -> Some r | _ -> None) Scope.Open - - let collectHashDirectives = - getConsecutiveModuleDecls( - function - | SynModuleDecl.HashDirective (ParsedHashDirective (directive, _, _),r) -> - let prefixLength = "#".Length + directive.Length + " ".Length - Some (mkRange "" (mkPos r.StartLine prefixLength) r.End) - | _ -> None) Scope.HashDirective - - let rec parseDeclaration (decl: SynModuleDecl) = - seq { + + let getConsecutiveModuleDecls (predicate: SynModuleDecl -> range option) (scope: Scope) (decls: SynModuleDecls) = + let groupConsecutiveDecls input = + let rec loop (input: range list) (res: range list list) currentBulk = + match input, currentBulk with + | [], [] -> List.rev res + | [], _ -> List.rev (currentBulk::res) + | r :: rest, [] -> loop rest res [r] + | r :: rest, last :: _ when r.StartLine = last.EndLine + 1 -> + loop rest res (r::currentBulk) + | r :: rest, _ -> loop rest (currentBulk::res) [r] + loop input [] [] + + let selectRanges (ranges: range list) = + match ranges with + | [] -> None + | [r] when r.StartLine = r.EndLine -> None + | [r] -> + let range = mkRange "" r.Start r.End + Some { Scope = scope; Collapse = Collapse.Same; Range = range ; CollapseRange = range } + | lastRange :: rest -> + let firstRange = Seq.last rest + let range = mkRange "" firstRange.Start lastRange.End + Some { Scope = scope; Collapse = Collapse.Same; Range = range; CollapseRange = range } + + decls + |> List.choose predicate + |> groupConsecutiveDecls + |> List.choose selectRanges + |> acc.AddRange + + let collectOpens = getConsecutiveModuleDecls (function SynModuleDecl.Open (_, r) -> Some r | _ -> None) Scope.Open + + let collectHashDirectives = + getConsecutiveModuleDecls( + function + | SynModuleDecl.HashDirective (ParsedHashDirective (directive, _, _),r) -> + let prefixLength = "#".Length + directive.Length + " ".Length + Some (mkRange "" (mkPos r.StartLine prefixLength) r.End) + | _ -> None) Scope.HashDirective + + let rec parseDeclaration (decl: SynModuleDecl) = match decl with | SynModuleDecl.Let (_,bindings,r) -> for binding in bindings do let collapse = Range.endToEnd binding.RangeOfBindingSansRhs r - yield! rcheck Scope.LetOrUse Collapse.Below r collapse - yield! parseBindings bindings + rcheck Scope.LetOrUse Collapse.Below r collapse + parseBindings bindings | SynModuleDecl.Types (types,_r) -> for t in types do - yield! parseTypeDefn t + parseTypeDefn t // Fold the attributes above a module | SynModuleDecl.NestedModule (ComponentInfo (attrs,_,_,_,_,_,_,cmpRange),_, decls,_,_) -> // Outline the full scope of the module let r = Range.endToEnd cmpRange decl.Range - yield! rcheck Scope.Module Collapse.Below decl.Range r + rcheck Scope.Module Collapse.Below decl.Range r // A module's component info stores the ranges of its attributes - yield! parseAttributes attrs - yield! collectOpens decls - yield! Seq.collect parseDeclaration decls + parseAttributes attrs + collectOpens decls + List.iter parseDeclaration decls | SynModuleDecl.DoExpr (_,e,_) -> - yield! parseExpr e + parseExpr e | SynModuleDecl.Attributes (attrs,_) -> - yield! parseAttributes attrs + parseAttributes attrs | _ -> () - } - let parseModuleOrNamespace isScript (SynModuleOrNamespace (longId,_,isModule,decls,_,attribs,_,r)) = - seq { - yield! parseAttributes attribs + let parseModuleOrNamespace isScript (SynModuleOrNamespace (longId,_,isModule,decls,_,attribs,_,r)) = + parseAttributes attribs let idRange = longIdentRange longId let fullrange = Range.startToEnd idRange r let collapse = Range.endToEnd idRange r - + // do not return range for top level implicit module in scripts if isModule && not isScript then - yield! rcheck Scope.Module Collapse.Below fullrange collapse - - yield! collectHashDirectives decls - yield! collectOpens decls - yield! Seq.collect parseDeclaration decls - } - - type LineNum = int - type LineStr = string - type CommentType = SingleLine | XmlDoc - - [] - type CommentList = - { Lines: ResizeArray - Type: CommentType } - static member New ty lineStr = - { Type = ty; Lines = ResizeArray [| lineStr |] } - - /// Determine if a line is a single line or xml docummentation comment - let (|Comment|_|) (line: string) = - if line.StartsWith "///" then Some XmlDoc - elif line.StartsWith "//" then Some SingleLine - else None - - let getCommentRanges (lines: string[]) = - let rec loop ((lastLineNum, currentComment: CommentList option, result) as state) (lines: string list) lineNum = - match lines with - | [] -> state - | lineStr :: rest -> - match lineStr.TrimStart(), currentComment with - | Comment commentType, Some comment -> - loop( - if comment.Type = commentType && lineNum = lastLineNum + 1 then - comment.Lines.Add (lineNum, lineStr) - lineNum, currentComment, result - else lineNum, Some (CommentList.New commentType (lineNum, lineStr)), comment :: result) rest (lineNum + 1) - | Comment commentType, None -> - loop(lineNum, Some (CommentList.New commentType (lineNum, lineStr)), result) rest (lineNum + 1) - | _, Some comment -> - loop(lineNum, None, comment :: result) rest (lineNum + 1) - | _ -> loop(lineNum, None, result) rest (lineNum + 1) - - let comments: CommentList list = - loop (-1, None, []) (List.ofArray lines) 0 - |> fun (_, lastComment, comments) -> - match lastComment with - | Some comment -> - comment :: comments - | _ -> comments - |> List.rev - - comments - |> List.filter (fun comment -> comment.Lines.Count > 1) - |> List.map (fun comment -> - let lines = comment.Lines - let startLine, startStr = lines.[0] - let endLine, endStr = lines.[lines.Count - 1] - let startCol = startStr.IndexOf '/' - let endCol = endStr.TrimEnd().Length - - let scopeType = - match comment.Type with - | SingleLine -> Scope.Comment - | XmlDoc -> Scope.XmlDocComment - - let range = mkRange "" (mkPos (startLine + 1) startCol) (mkPos (endLine + 1) endCol) - - { Scope = scopeType - Collapse = Collapse.Same - Range = range - CollapseRange = range }) - - - //=======================================// - // Signature File AST Traversal // - //=======================================// - - (* - The following helper functions are necessary due to a bug in the Parsed UAST within a - signature file that causes the scopes to extend past the end of the construct and overlap - with the following construct. This necessitates inspecting the children of the construct and - finding the end of the last child's range to use instead. - - Detailed further in - https://github.com/Microsoft/visualfsharp/issues/2094 - *) - - let lastMemberSigRangeElse r memberSigs = - match memberSigs with - | [] -> r - | ls -> - match List.last ls with - | SynMemberSig.Inherit (range=r) - | SynMemberSig.Interface (range=r) - | SynMemberSig.Member (range=r) - | SynMemberSig.NestedType (range=r) - | SynMemberSig.ValField (range=r) -> r - - let lastTypeDefnSigRangeElse range (typeSigs:SynTypeDefnSig list) = - match typeSigs with - | [] -> range - | ls -> - let (TypeDefnSig(_,_,memberSigs,r)) = List.last ls - lastMemberSigRangeElse r memberSigs - - let lastModuleSigDeclRangeElse range (sigDecls:SynModuleSigDecls) = - match sigDecls with - | [] -> range - | ls -> match List.last ls with + rcheck Scope.Module Collapse.Below fullrange collapse + + collectHashDirectives decls + collectOpens decls + List.iter parseDeclaration decls + + /// Determine if a line is a single line or xml docummentation comment + let (|Comment|_|) (line: string) = + if line.StartsWith "///" then Some XmlDoc + elif line.StartsWith "//" then Some SingleLine + else None + + let getCommentRanges (lines: string[]) = + let rec loop ((lastLineNum, currentComment: CommentList option, result) as state) (lines: string list) lineNum = + match lines with + | [] -> state + | lineStr :: rest -> + match lineStr.TrimStart(), currentComment with + | Comment commentType, Some comment -> + loop( + if comment.Type = commentType && lineNum = lastLineNum + 1 then + comment.Lines.Add (lineNum, lineStr) + lineNum, currentComment, result + else lineNum, Some (CommentList.New commentType (lineNum, lineStr)), comment :: result) rest (lineNum + 1) + | Comment commentType, None -> + loop(lineNum, Some (CommentList.New commentType (lineNum, lineStr)), result) rest (lineNum + 1) + | _, Some comment -> + loop(lineNum, None, comment :: result) rest (lineNum + 1) + | _ -> loop(lineNum, None, result) rest (lineNum + 1) + + let comments: CommentList list = + loop (-1, None, []) (List.ofArray lines) 0 + |> fun (_, lastComment, comments) -> + match lastComment with + | Some comment -> + comment :: comments + | _ -> comments + |> List.rev + + comments + |> List.filter (fun comment -> comment.Lines.Count > 1) + |> List.map (fun comment -> + let lines = comment.Lines + let startLine, startStr = lines.[0] + let endLine, endStr = lines.[lines.Count - 1] + let startCol = startStr.IndexOf '/' + let endCol = endStr.TrimEnd().Length + + let scopeType = + match comment.Type with + | SingleLine -> Scope.Comment + | XmlDoc -> Scope.XmlDocComment + + let range = mkRange "" (mkPos (startLine + 1) startCol) (mkPos (endLine + 1) endCol) + + { Scope = scopeType + Collapse = Collapse.Same + Range = range + CollapseRange = range }) + |> acc.AddRange + + + //=======================================// + // Signature File AST Traversal // + //=======================================// + + (* + The following helper functions are necessary due to a bug in the Parsed UAST within a + signature file that causes the scopes to extend past the end of the construct and overlap + with the following construct. This necessitates inspecting the children of the construct and + finding the end of the last child's range to use instead. + + Detailed further in - https://github.com/Microsoft/visualfsharp/issues/2094 + *) + + let lastMemberSigRangeElse r memberSigs = + match memberSigs with + | [] -> r + | ls -> + match List.last ls with + | SynMemberSig.Inherit (range=r) + | SynMemberSig.Interface (range=r) + | SynMemberSig.Member (range=r) + | SynMemberSig.NestedType (range=r) + | SynMemberSig.ValField (range=r) -> r + + let lastTypeDefnSigRangeElse range (typeSigs:SynTypeDefnSig list) = + match typeSigs with + | [] -> range + | ls -> + let (TypeDefnSig(_,_,memberSigs,r)) = List.last ls + lastMemberSigRangeElse r memberSigs + + let lastModuleSigDeclRangeElse range (sigDecls:SynModuleSigDecls) = + match sigDecls with + | [] -> range + | ls -> + match List.last ls with | SynModuleSigDecl.Types (typeSigs,r) -> lastTypeDefnSigRangeElse r typeSigs | SynModuleSigDecl.Val (ValSpfn(range=r),_) -> r | SynModuleSigDecl.Exception(_,r) -> r - | SynModuleSigDecl.Open(_,r)-> r - | SynModuleSigDecl.ModuleAbbrev(_,_,r)-> r + | SynModuleSigDecl.Open(_,r) -> r + | SynModuleSigDecl.ModuleAbbrev(_,_,r) -> r | _ -> range - - let rec parseSynMemberDefnSig (dsig:SynMemberSig) = - seq { - match dsig with - | SynMemberSig.Member(valSigs,_flags,r) -> + let rec parseSynMemberDefnSig = function + | SynMemberSig.Member(valSigs,_,r) -> let collapse = Range.endToEnd valSigs.RangeOfId r - yield! rcheck Scope.Member Collapse.Below r collapse - | SynMemberSig.ValField(Field(attrs,_a,_b,_c,_d,_e,_,fr),fullrange) -> + rcheck Scope.Member Collapse.Below r collapse + | SynMemberSig.ValField(Field(attrs,_,_,_,_,_,_,fr),fullrange) -> let collapse = Range.endToEnd fr fullrange - yield! rcheck Scope.Val Collapse.Below fullrange collapse - yield! parseAttributes attrs + rcheck Scope.Val Collapse.Below fullrange collapse + parseAttributes attrs | SynMemberSig.Interface(tp,r) -> - yield! rcheck Scope.Interface Collapse.Below r <| Range.endToEnd tp.Range r + rcheck Scope.Interface Collapse.Below r (Range.endToEnd tp.Range r) | SynMemberSig.NestedType (typeDefSig, _r) -> - yield! parseTypeDefnSig typeDefSig + parseTypeDefnSig typeDefSig | _ -> () - } - and parseTypeDefnSig - (TypeDefnSig (ComponentInfo(attribs,typeArgs,_constraints,longId,_doc,_b,_access,r) - as _componentInfo, objectModel, memberSigs, _)) = seq { - yield! parseAttributes attribs + and parseTypeDefnSig (TypeDefnSig (ComponentInfo(attribs,typeArgs,_,longId,_,_,_,r) as __, objectModel, memberSigs, _)) = + parseAttributes attribs let makeRanges memberSigs = let typeArgsRange = rangeOfTypeArgsElse r typeArgs @@ -759,117 +740,112 @@ module Structure = let fullrange = Range.startToEnd (longIdentRange longId) rangeEnd fullrange, collapse - yield! Seq.collect parseSynMemberDefnSig memberSigs + List.iter parseSynMemberDefnSig memberSigs + match objectModel with // matches against a type declaration with <'T,...> and (args,...) | SynTypeDefnSigRepr.ObjectModel - (TyconUnspecified,objMembers,_r) -> - yield! Seq.collect parseSynMemberDefnSig objMembers + (TyconUnspecified, objMembers, _) -> + List.iter parseSynMemberDefnSig objMembers let fullrange,collapse = makeRanges objMembers - yield! rcheck Scope.Type Collapse.Below fullrange collapse - | SynTypeDefnSigRepr.ObjectModel - (TyconAugmentation , objMembers, _) -> + rcheck Scope.Type Collapse.Below fullrange collapse + | SynTypeDefnSigRepr.ObjectModel (TyconAugmentation, objMembers, _) -> let fullrange,collapse = makeRanges objMembers - yield! rcheck Scope.TypeExtension Collapse.Below fullrange collapse - yield! Seq.collect parseSynMemberDefnSig objMembers - | SynTypeDefnSigRepr.ObjectModel - (_ , objMembers, _) -> + rcheck Scope.TypeExtension Collapse.Below fullrange collapse + List.iter parseSynMemberDefnSig objMembers + | SynTypeDefnSigRepr.ObjectModel (_, objMembers, _) -> let fullrange,collapse = makeRanges objMembers - yield! rcheck Scope.Type Collapse.Below fullrange collapse - yield! Seq.collect parseSynMemberDefnSig objMembers + rcheck Scope.Type Collapse.Below fullrange collapse + List.iter parseSynMemberDefnSig objMembers // visit the members of a type extension - | SynTypeDefnSigRepr.Simple (simpleRepr,_r) -> + | SynTypeDefnSigRepr.Simple (simpleRepr, _) -> let fullrange,collapse = makeRanges memberSigs - yield! rcheck Scope.Type Collapse.Below fullrange collapse - yield! parseSimpleRepr simpleRepr + rcheck Scope.Type Collapse.Below fullrange collapse + parseSimpleRepr simpleRepr | SynTypeDefnSigRepr.Exception _ -> () - } - - let getConsecutiveSigModuleDecls (predicate: SynModuleSigDecl -> range option) (scope:Scope) (decls: SynModuleSigDecls) = - let groupConsecutiveSigDecls input = - let rec loop (input: range list) (res: range list list) currentBulk = - match input, currentBulk with - | [], [] -> List.rev res - | [], _ -> List.rev (currentBulk::res) - | r :: rest, [] -> loop rest res [r] - | r :: rest, last :: _ when r.StartLine = last.EndLine + 1 -> - loop rest res (r::currentBulk) - | r :: rest, _ -> loop rest (currentBulk::res) [r] - loop input [] [] - - - let selectSigRanges (ranges: range list) = - match ranges with - | [] -> None - | [r] when r.StartLine = r.EndLine -> None - | [r] -> - let range = mkRange "" r.Start r.End - Some { Scope = scope; Collapse = Collapse.Same; Range = range ; CollapseRange = range } - | lastRange :: rest -> - let firstRange = Seq.last rest - let range = mkRange "" firstRange.Start lastRange.End - Some { Scope = scope; Collapse = Collapse.Same; Range = range; CollapseRange = range } - - decls |> (List.choose predicate >> groupConsecutiveSigDecls >> List.choose selectSigRanges) - - let collectSigHashDirectives (decls: SynModuleSigDecls) = - decls - |> getConsecutiveSigModuleDecls( - function - | SynModuleSigDecl.HashDirective (ParsedHashDirective (directive, _, _),r) -> - let prefixLength = "#".Length + directive.Length + " ".Length - Some (mkRange "" (mkPos r.StartLine prefixLength) r.End) - | _ -> None) Scope.HashDirective - - - let collectSigOpens = getConsecutiveSigModuleDecls (function SynModuleSigDecl.Open (_,r) -> Some r | _ -> None) Scope.Open - - let rec parseModuleSigDeclaration (decl: SynModuleSigDecl) = - seq { + + let getConsecutiveSigModuleDecls (predicate: SynModuleSigDecl -> range option) (scope:Scope) (decls: SynModuleSigDecls) = + let groupConsecutiveSigDecls input = + let rec loop (input: range list) (res: range list list) currentBulk = + match input, currentBulk with + | [], [] -> List.rev res + | [], _ -> List.rev (currentBulk::res) + | r :: rest, [] -> loop rest res [r] + | r :: rest, last :: _ when r.StartLine = last.EndLine + 1 -> + loop rest res (r::currentBulk) + | r :: rest, _ -> loop rest (currentBulk::res) [r] + loop input [] [] + + let selectSigRanges (ranges: range list) = + match ranges with + | [] -> None + | [r] when r.StartLine = r.EndLine -> None + | [r] -> + let range = mkRange "" r.Start r.End + Some { Scope = scope; Collapse = Collapse.Same; Range = range ; CollapseRange = range } + | lastRange :: rest -> + let firstRange = Seq.last rest + let range = mkRange "" firstRange.Start lastRange.End + Some { Scope = scope; Collapse = Collapse.Same; Range = range; CollapseRange = range } + + decls + |> List.choose predicate + |> groupConsecutiveSigDecls + |> List.choose selectSigRanges + |> acc.AddRange + + let collectSigHashDirectives (decls: SynModuleSigDecls) = + decls + |> getConsecutiveSigModuleDecls( + function + | SynModuleSigDecl.HashDirective (ParsedHashDirective (directive, _, _), r) -> + let prefixLength = "#".Length + directive.Length + " ".Length + Some (mkRange "" (mkPos r.StartLine prefixLength) r.End) + | _ -> None) Scope.HashDirective + + let collectSigOpens = getConsecutiveSigModuleDecls (function SynModuleSigDecl.Open (_,r) -> Some r | _ -> None) Scope.Open + + let rec parseModuleSigDeclaration (decl: SynModuleSigDecl) = match decl with - | SynModuleSigDecl.Val ((ValSpfn(attrs,ident,_valdecls,_,_,_,_,_,_,_,valrange)),_r) -> - let collapse = Range.endToEnd ident.idRange valrange - yield! rcheck Scope.Val Collapse.Below _r collapse - yield! parseAttributes attrs - | SynModuleSigDecl.Types (typeSigs,_r) -> - yield! Seq.collect parseTypeDefnSig typeSigs + | SynModuleSigDecl.Val ((ValSpfn(attrs,ident,_,_,_,_,_,_,_,_,valrange)),r) -> + let collapse = Range.endToEnd ident.idRange valrange + rcheck Scope.Val Collapse.Below r collapse + parseAttributes attrs + | SynModuleSigDecl.Types (typeSigs,_) -> + List.iter parseTypeDefnSig typeSigs // Fold the attributes above a module - | SynModuleSigDecl.NestedModule (ComponentInfo (attrs,_,_,_,_,_,_,cmpRange),_, decls,moduleRange) -> + | SynModuleSigDecl.NestedModule (ComponentInfo (attrs,_,_,_,_,_,_,cmpRange),_,decls,moduleRange) -> let rangeEnd = lastModuleSigDeclRangeElse moduleRange decls // Outline the full scope of the module let collapse = Range.endToEnd cmpRange rangeEnd let fullrange = Range.startToEnd moduleRange rangeEnd - yield! rcheck Scope.Module Collapse.Below fullrange collapse + rcheck Scope.Module Collapse.Below fullrange collapse // A module's component info stores the ranges of its attributes - yield! parseAttributes attrs - yield! collectSigOpens decls - yield! Seq.collect parseModuleSigDeclaration decls + parseAttributes attrs + collectSigOpens decls + List.iter parseModuleSigDeclaration decls | _ -> () - } - let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId,_,isModule,decls,_,attribs,_,r)) = - seq { - yield! parseAttributes attribs + let parseModuleOrNamespaceSigs (SynModuleOrNamespaceSig(longId,_,isModule,decls,_,attribs,_,r)) = + parseAttributes attribs let rangeEnd = lastModuleSigDeclRangeElse r decls let idrange = longIdentRange longId let fullrange = Range.startToEnd idrange rangeEnd let collapse = Range.endToEnd idrange rangeEnd if isModule then - yield! rcheck Scope.Module Collapse.Below fullrange collapse + rcheck Scope.Module Collapse.Below fullrange collapse - yield! collectSigHashDirectives decls - yield! collectSigOpens decls - yield! Seq.collect parseModuleSigDeclaration decls - } + collectSigHashDirectives decls + collectSigOpens decls + List.iter parseModuleSigDeclaration decls - let getOutliningRanges (sourceLines: string []) (parsedInput: ParsedInput) = match parsedInput with | ParsedInput.ImplFile (ParsedImplFileInput (modules = modules; isScript = isScript)) -> - let astBasedRanges = modules |> Seq.collect (parseModuleOrNamespace isScript) - let commentRanges = getCommentRanges sourceLines - Seq.append astBasedRanges commentRanges + modules |> List.iter (parseModuleOrNamespace isScript) + getCommentRanges sourceLines | ParsedInput.SigFile (ParsedSigFileInput (modules = moduleSigs)) -> - let astBasedRanges = Seq.collect parseModuleOrNamespaceSigs moduleSigs - let commentRanges = getCommentRanges sourceLines - Seq.append astBasedRanges commentRanges + List.iter parseModuleOrNamespaceSigs moduleSigs + getCommentRanges sourceLines + + acc :> seq<_> \ No newline at end of file diff --git a/src/fsharp/vs/ServiceUntypedParse.fs b/src/fsharp/vs/ServiceUntypedParse.fs index 58d77d0485..c90ca7a04a 100755 --- a/src/fsharp/vs/ServiceUntypedParse.fs +++ b/src/fsharp/vs/ServiceUntypedParse.fs @@ -10,6 +10,7 @@ namespace Microsoft.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 @@ -20,7 +21,7 @@ open Microsoft.FSharp.Compiler.CompileOps open Microsoft.FSharp.Compiler.Lib /// Methods for dealing with F# sources files. -module internal SourceFile = +module SourceFile = /// Source file extensions let private compilableExtensions = CompileOps.FSharpSigFileSuffixes @ CompileOps.FSharpImplFileSuffixes @ CompileOps.FSharpScriptFileSuffixes /// Single file projects extensions @@ -34,7 +35,7 @@ module internal SourceFile = let ext = Path.GetExtension(file) singleFileProjectExtensions |> List.exists(fun e-> 0 = String.Compare(e,ext,StringComparison.OrdinalIgnoreCase)) -module internal SourceFileImpl = +module SourceFileImpl = let IsInterfaceFile file = let ext = Path.GetExtension(file) 0 = String.Compare(".fsi",ext,StringComparison.OrdinalIgnoreCase) @@ -46,21 +47,25 @@ module internal SourceFileImpl = type CompletionPath = string list * string option // plid * residue +[] type InheritanceOrigin = | Class | Interface | Unknown +[] type InheritanceContext = | Class | Interface | Unknown +[] type RecordContext = | CopyOnUpdate of range * CompletionPath // range of copy-expr + current field | Constructor of string // typename | New of CompletionPath +[] type CompletionContext = // completion context cannot be determined due to errors | Invalid @@ -104,7 +109,9 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput NavigationImpl.empty | _ -> NavigationImpl.empty ) - (fun _ -> NavigationImpl.empty) + (fun err -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetNavigationItemsImpl: '%s'" err) + NavigationImpl.empty) member private scope.ValidateBreakpointLocationImpl(pos) = let isMatchRange m = rangeContainsPos m pos || m.StartLine = pos.Line @@ -369,7 +376,9 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput | [] -> Seq.tryHead locations | locationsAfterPos -> Seq.tryHead locationsAfterPos | coveringLocations -> Seq.tryLast coveringLocations) - (fun _msg -> None) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in ValidateBreakpointLocationImpl: '%s'" msg) + None) /// When these files appear or disappear the configuration for the current project is invalidated. member scope.DependencyFiles = dependencyFiles @@ -391,6 +400,7 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput type ModuleKind = { IsAutoOpen: bool; HasModuleSuffix: bool } +[] type EntityKind = | Attribute | Type @@ -994,7 +1004,7 @@ module UntypedParseImpl = let GetCompletionContextForInheritSynMember ((ComponentInfo(synAttributes, _, _, _,_, _, _, _)), typeDefnKind : SynTypeDefnKind, completionPath) = - let success k = Some (Inherit (k, completionPath)) + let success k = Some (CompletionContext.Inherit (k, completionPath)) // if kind is specified - take it // if kind is non-specified @@ -1003,22 +1013,22 @@ module UntypedParseImpl = match typeDefnKind with | TyconClass -> match synAttributes with - | Class | Unknown -> success Class + | Class | Unknown -> success InheritanceContext.Class | _ -> Some CompletionContext.Invalid // non-matching attributes | TyconInterface -> match synAttributes with - | Interface | Unknown -> success Interface + | Interface | Unknown -> success InheritanceContext.Interface | _ -> Some CompletionContext.Invalid // non-matching attributes | TyconStruct -> // display nothing for structs Some CompletionContext.Invalid | TyconUnspecified -> match synAttributes with - | Class -> success Class - | Interface -> success Interface + | Class -> success InheritanceContext.Class + | Interface -> success InheritanceContext.Interface | Unknown -> // user do not specify kind explicitly or via attributes - success Unknown + success InheritanceContext.Unknown | _ -> // unable to uniquely detect kind from the attributes - return invalid context Some CompletionContext.Invalid @@ -1074,16 +1084,16 @@ module UntypedParseImpl = | (SynExpr.New (_, SynType.App(SynType.LongIdent typeName, _, _, _, mGreaterThan, _, _), arg, _)) -> // new A<_>() Some (endOfClosingTokenOrLastIdent mGreaterThan typeName, findSetters arg) - | (SynExpr.App (ExprAtomicFlag.Atomic, false, SynExpr.Ident id, arg, _)) -> + | (SynExpr.App (_, false, SynExpr.Ident id, arg, _)) -> // A() Some (id.idRange.End, findSetters arg) - | (SynExpr.App (ExprAtomicFlag.Atomic, false, SynExpr.TypeApp(SynExpr.Ident id, _, _, _, mGreaterThan, _, _), arg, _)) -> + | (SynExpr.App (_, false, SynExpr.TypeApp(SynExpr.Ident id, _, _, _, mGreaterThan, _, _), arg, _)) -> // A<_>() Some (endOfClosingTokenOrIdent mGreaterThan id , findSetters arg) - | (SynExpr.App (ExprAtomicFlag.Atomic, false, SynExpr.LongIdent(_, lid, _, _), arg, _)) -> + | (SynExpr.App (_, false, SynExpr.LongIdent(_, lid, _, _), arg, _)) -> // A.B() Some (endOfLastIdent lid, findSetters arg) - | (SynExpr.App (ExprAtomicFlag.Atomic, false, SynExpr.TypeApp(SynExpr.LongIdent(_, lid, _, _), _, _, _, mGreaterThan, _, _), arg, _)) -> + | (SynExpr.App (_, false, SynExpr.TypeApp(SynExpr.LongIdent(_, lid, _, _), _, _, _, mGreaterThan, _, _), arg, _)) -> // A.B<_>() Some (endOfClosingTokenOrLastIdent mGreaterThan lid, findSetters arg) | _ -> None @@ -1120,40 +1130,41 @@ module UntypedParseImpl = let walker = { new AstTraversal.AstVisitorBase<_>() with - member this.VisitExpr(path, traverseSynExpr, defaultTraverse, expr) = + member __.VisitExpr(path, _, defaultTraverse, expr) = + if isInRhsOfRangeOp path then match defaultTraverse expr with - | None -> Some (CompletionContext.RangeOperator) // nothing was found - report that we were in the context of range operator + | None -> Some CompletionContext.RangeOperator // nothing was found - report that we were in the context of range operator | x -> x // ok, we found something - return it else - match expr with - // new A($) - | SynExpr.Const(SynConst.Unit, m) when rangeContainsPos m pos -> - match path with - | TS.Expr(NewObjectOrMethodCall args)::_ -> - Some (CompletionContext.ParameterList args) - | _ -> - defaultTraverse expr - // new (... A$) - | SynExpr.Ident id when id.idRange.End = pos -> - match path with - | PartOfParameterList None args -> - Some (CompletionContext.ParameterList args) - | _ -> - defaultTraverse expr - // new (A$ = 1) - // new (A = 1,$) - | Setter id when id.idRange.End = pos || rangeBeforePos expr.Range pos -> - let precedingArgument = if id.idRange.End = pos then None else Some expr - match path with - | PartOfParameterList precedingArgument args-> - Some (CompletionContext.ParameterList args) - | _ -> - defaultTraverse expr - - | _ -> defaultTraverse expr - - member this.VisitRecordField(path, copyOpt, field) = + match expr with + // new A($) + | SynExpr.Const(SynConst.Unit, m) when rangeContainsPos m pos -> + match path with + | TS.Expr(NewObjectOrMethodCall args)::_ -> + Some (CompletionContext.ParameterList args) + | _ -> + defaultTraverse expr + // new (... A$) + | SynExpr.Ident id when id.idRange.End = pos -> + match path with + | PartOfParameterList None args -> + Some (CompletionContext.ParameterList args) + | _ -> + defaultTraverse expr + // new (A$ = 1) + // new (A = 1,$) + | Setter id when id.idRange.End = pos || rangeBeforePos expr.Range pos -> + let precedingArgument = if id.idRange.End = pos then None else Some expr + match path with + | PartOfParameterList precedingArgument args-> + Some (CompletionContext.ParameterList args) + | _ -> + defaultTraverse expr + + | _ -> defaultTraverse expr + + member __.VisitRecordField(path, copyOpt, field) = let contextFromTreePath completionPath = // detect records usage in constructor match path with @@ -1177,7 +1188,7 @@ module UntypedParseImpl = | None -> contextFromTreePath ([], None) Some (CompletionContext.RecordField recordContext) - member this.VisitInheritSynMemberDefn(componentInfo, typeDefnKind, synType, _members, _range) = + member __.VisitInheritSynMemberDefn(componentInfo, typeDefnKind, synType, _members, _range) = match synType with | SynType.LongIdent lidwd -> match parseLid lidwd with @@ -1186,7 +1197,7 @@ module UntypedParseImpl = | _ -> None - member this.VisitBinding(defaultTraverse, (Binding(headPat = headPat) as synBinding)) = + member __.VisitBinding(defaultTraverse, (Binding(headPat = headPat) as synBinding)) = let visitParam = function | SynPat.Named (range = range) when rangeContainsPos range pos -> @@ -1216,11 +1227,11 @@ module UntypedParseImpl = | _ -> defaultTraverse synBinding | _ -> defaultTraverse synBinding - member this.VisitHashDirective(range) = + member __.VisitHashDirective(range) = if rangeContainsPos range pos then Some CompletionContext.Invalid else None - member this.VisitModuleOrNamespace(SynModuleOrNamespace(longId = idents)) = + member __.VisitModuleOrNamespace(SynModuleOrNamespace(longId = idents)) = match List.tryLast idents with | Some lastIdent when pos.Line = lastIdent.idRange.EndLine && lastIdent.idRange.EndColumn >= 0 && pos.Column <= lineStr.Length -> let stringBetweenModuleNameAndPos = lineStr.[lastIdent.idRange.EndColumn..pos.Column - 1] @@ -1229,16 +1240,16 @@ module UntypedParseImpl = else None | _ -> None - member this.VisitComponentInfo(ComponentInfo(range = range)) = + member __.VisitComponentInfo(ComponentInfo(range = range)) = if rangeContainsPos range pos then Some CompletionContext.Invalid else None - member this.VisitLetOrUse(bindings, range) = + member __.VisitLetOrUse(bindings, range) = match bindings with | [] when range.StartLine = pos.Line -> Some CompletionContext.Invalid | _ -> None - member this.VisitSimplePats(pats) = + member __.VisitSimplePats(pats) = pats |> List.tryPick (fun pat -> match pat with | SynSimplePat.Id(range = range) @@ -1246,7 +1257,7 @@ module UntypedParseImpl = Some CompletionContext.Invalid | _ -> None) - member this.VisitModuleDecl(defaultTraverse, decl) = + member __.VisitModuleDecl(defaultTraverse, decl) = match decl with | SynModuleDecl.Open(_, m) -> // in theory, this means we're "in an open" diff --git a/src/fsharp/vs/ServiceUntypedParse.fsi b/src/fsharp/vs/ServiceUntypedParse.fsi index a7bf6c90c1..f8331c6c7d 100755 --- a/src/fsharp/vs/ServiceUntypedParse.fsi +++ b/src/fsharp/vs/ServiceUntypedParse.fsi @@ -15,7 +15,11 @@ open Microsoft.FSharp.Compiler.ErrorLogger [] /// Represents the results of parsing an F# file +#if COMPILER_PUBLIC_API type FSharpParseFileResults = +#else +type internal FSharpParseFileResults = +#endif /// The syntax tree resulting from the parse member ParseTree : Ast.ParsedInput option @@ -32,6 +36,9 @@ type FSharpParseFileResults = /// Return the inner-most range associated with a possible breakpoint location member ValidateBreakpointLocation : pos:pos -> range option + /// When these files change then the build is invalid + member DependencyFiles : string list + /// Get the errors and warnings for the parse member Errors : FSharpErrorInfo[] @@ -41,7 +48,11 @@ type FSharpParseFileResults = internal new : errors : FSharpErrorInfo[] * input : Ast.ParsedInput option * parseHadErrors : bool * dependencyFiles : string list -> FSharpParseFileResults /// Information about F# source file names +#if COMPILER_PUBLIC_API +module SourceFile = +#else module internal SourceFile = +#endif /// Whether or not this file is compilable val IsCompilable : string -> bool @@ -49,19 +60,38 @@ module internal SourceFile = /// Whether or not this file should be a single-file project val MustBeSingleFileProject : string -> bool +#if COMPILER_PUBLIC_API type CompletionPath = string list * string option // plid * residue +#else +type internal CompletionPath = string list * string option // plid * residue +#endif +[] +#if COMPILER_PUBLIC_API type InheritanceContext = +#else +type internal InheritanceContext = +#endif | Class | Interface | Unknown +[] +#if COMPILER_PUBLIC_API type RecordContext = +#else +type internal RecordContext = +#endif | CopyOnUpdate of range * CompletionPath // range | Constructor of string // typename | New of CompletionPath +[] +#if COMPILER_PUBLIC_API type CompletionContext = +#else +type internal CompletionContext = +#endif // completion context cannot be determined due to errors | Invalid // completing something after the inherit keyword @@ -75,16 +105,29 @@ type CompletionContext = | AttributeApplication | OpenDeclaration +#if COMPILER_PUBLIC_API type ModuleKind = { IsAutoOpen: bool; HasModuleSuffix: bool } +#else +type internal ModuleKind = { IsAutoOpen: bool; HasModuleSuffix: bool } +#endif +[] +#if COMPILER_PUBLIC_API type EntityKind = +#else +type internal EntityKind = +#endif | Attribute | Type | FunctionOrValue of isActivePattern:bool | Module of ModuleKind // implementation details used by other code in the compiler +#if COMPILER_PUBLIC_API module UntypedParseImpl = +#else +module internal UntypedParseImpl = +#endif val TryFindExpressionASTLeftOfDotLeftOfCursor : pos * ParsedInput option -> (pos * bool) option val GetRangeOfExprLeftOfDot : pos * ParsedInput option -> range option val TryFindExpressionIslandInPosition : pos * ParsedInput option -> string option diff --git a/src/fsharp/vs/ServiceXmlDocParser.fs b/src/fsharp/vs/ServiceXmlDocParser.fs index bb21924e31..2e910a8e7a 100644 --- a/src/fsharp/vs/ServiceXmlDocParser.fs +++ b/src/fsharp/vs/ServiceXmlDocParser.fs @@ -5,10 +5,10 @@ namespace Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library /// Represent an Xml documentation block in source code -type internal XmlDocable = +type XmlDocable = | XmlDocable of line:int * indent:int * paramNames:string list -module internal XmlDocParsing = +module XmlDocParsing = open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.Ast @@ -159,7 +159,7 @@ module internal XmlDocParsing = // Should not fail here, just in case [] -module internal XmlDocComment = +module XmlDocComment = let private ws (s: string, pos) = let res = s.TrimStart() Some (res, pos + (s.Length - res.Length)) @@ -184,7 +184,7 @@ module internal XmlDocComment = let res = parser (s.TrimEnd(), 0) |> Option.map snd |> Option.map (fun x -> x - 1) res -module internal XmlDocParser = +module XmlDocParser = /// Get the list of Xml documentation from current source code let getXmlDocables (sourceCodeOfTheFile, input) = let sourceCodeLinesOfTheFile = String.getLines sourceCodeOfTheFile diff --git a/src/fsharp/vs/ServiceXmlDocParser.fsi b/src/fsharp/vs/ServiceXmlDocParser.fsi index 3946634df0..5509a7d3f9 100644 --- a/src/fsharp/vs/ServiceXmlDocParser.fsi +++ b/src/fsharp/vs/ServiceXmlDocParser.fsi @@ -7,15 +7,27 @@ open Microsoft.FSharp.Compiler.Range open Microsoft.FSharp.Compiler.Ast /// Represent an Xml documentation block in source code +#if COMPILER_PUBLIC_API +type XmlDocable = +#else type internal XmlDocable = +#endif | XmlDocable of line:int * indent:int * paramNames:string list +#if COMPILER_PUBLIC_API +module XmlDocComment = +#else module internal XmlDocComment = +#endif /// if it's a blank XML comment with trailing "<", returns Some (index of the "<"), otherwise returns None val isBlank : string -> int option +#if COMPILER_PUBLIC_API +module XmlDocParser = +#else module internal XmlDocParser = +#endif /// Get the list of Xml documentation from current source code val getXmlDocables : sourceCodeOfTheFile : string * input : Ast.ParsedInput option -> XmlDocable list \ No newline at end of file diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 29cc24a6ab..da4b9292b3 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -6,16 +6,18 @@ namespace Microsoft.FSharp.Compiler.SourceCodeServices open System -open System.IO -open System.Text open System.Collections.Generic open System.Collections.Concurrent +open System.Diagnostics +open System.IO +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.Diagnostics +open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics open Microsoft.FSharp.Compiler.AbstractIL.Internal open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library @@ -37,13 +39,17 @@ 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.ItemDescriptionsImpl +open Microsoft.FSharp.Compiler.SourceCodeServices.SymbolHelpers open Internal.Utilities open Internal.Utilities.Collections open Microsoft.FSharp.Compiler.Layout.TaggedTextOps -type internal Layout = Internal.Utilities.StructuredFormat.Layout +#if FX_RESHAPED_REFLECTION +open Microsoft.FSharp.Core.ReflectionAdapters +#endif + +type internal Layout = StructuredFormat.Layout [] module EnvMisc = @@ -63,374 +69,18 @@ module EnvMisc = /// (via an Eventually<_> value of case NotYetDone) that can be called as the next piece of work. let maxTimeShareMilliseconds = match System.Environment.GetEnvironmentVariable("FCS_MaxTimeShare") with - | null | "" -> 50L + | null | "" -> 100L | s -> int64 s -//---------------------------------------------------------------------------- -// Methods -//-------------------------------------------------------------------------- - -[] -type FSharpMethodGroupItemParameter(name: string, canonicalTypeTextForSorting: string, display: Layout, isOptional: bool) = - member __.ParameterName = name - member __.CanonicalTypeTextForSorting = canonicalTypeTextForSorting - member __.Description = "" - member __.StructuredDisplay = display - member __.Display = showL display - member __.IsOptional = isOptional - -/// Format parameters for Intellisense completion -module internal Params = - let printCanonicalizedTypeName g (denv:DisplayEnv) tau = - // get rid of F# abbreviations and such - let strippedType = stripTyEqnsWrtErasure EraseAll g tau - // pretend no namespaces are open - let denv = denv.SetOpenPaths([]) - // now printing will see a .NET-like canonical representation, that is good for sorting overloads into a reasonable order (see bug 94520) - NicePrint.stringOfTy denv strippedType - - let ParamOfRecdField g denv f = - FSharpMethodGroupItemParameter( - name = f.rfield_id.idText, - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv f.rfield_type, - display = NicePrint.prettyLayoutOfTy denv f.rfield_type, - isOptional=false) - - let ParamOfUnionCaseField g denv isGenerated (i : int) f = - let initial = ParamOfRecdField g denv f - let display = if isGenerated i f then initial.StructuredDisplay else NicePrint.layoutOfParamData denv (ParamData(false, false, NotOptional, NoCallerInfo, Some f.rfield_id, ReflectedArgInfo.None, f.rfield_type)) - FSharpMethodGroupItemParameter( - name=initial.ParameterName, - canonicalTypeTextForSorting=initial.CanonicalTypeTextForSorting, - display=display, - isOptional=false) - - let ParamOfParamData g denv (ParamData(_isParamArrayArg, _isOutArg, optArgInfo, _callerInfoInfo, nmOpt, _reflArgInfo, pty) as paramData) = - FSharpMethodGroupItemParameter( - name = (match nmOpt with None -> "" | Some pn -> pn.idText), - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv pty, - display = NicePrint.layoutOfParamData denv paramData, - isOptional=optArgInfo.IsOptional) - - // TODO this code is similar to NicePrint.fs:formatParamDataToBuffer, refactor or figure out why different? - let ParamsOfParamDatas g denv (paramDatas:ParamData list) rty = - let paramInfo,paramTypes = - paramDatas - |> List.map (fun (ParamData(isParamArrayArg, _isOutArg, optArgInfo, _callerInfoInfo, nmOpt, _reflArgInfo, pty)) -> - let isOptArg = optArgInfo.IsOptional - match nmOpt, isOptArg, tryDestOptionTy denv.g pty with - // Layout an optional argument - | Some id, true, ptyOpt -> - let nm = id.idText - // detect parameter type, if ptyOpt is None - this is .NET style optional argument - let pty = defaultArg ptyOpt pty - (nm, isOptArg, SepL.questionMark ^^ (wordL (TaggedTextOps.tagParameter nm))), pty - // Layout an unnamed argument - | None, _,_ -> - ("", isOptArg, emptyL), pty - // Layout a named argument - | Some id,_,_ -> - let nm = id.idText - let prefix = - if isParamArrayArg then - NicePrint.PrintUtilities.layoutBuiltinAttribute denv denv.g.attrib_ParamArrayAttribute ^^ - wordL (TaggedTextOps.tagParameter nm) ^^ - RightL.colon - //sprintf "%s %s: " (NicePrint.PrintUtilities.layoutBuiltinAttribute denv denv.g.attrib_ParamArrayAttribute |> showL) nm - else - wordL (TaggedTextOps.tagParameter nm) ^^ - RightL.colon - //sprintf "%s: " nm - (nm,isOptArg, prefix),pty) - |> List.unzip - let paramTypeAndRetLs,_ = NicePrint.layoutPrettifiedTypes denv (paramTypes@[rty]) - let paramTypeLs,_ = List.frontAndBack paramTypeAndRetLs - (paramInfo,paramTypes,paramTypeLs) |||> List.map3 (fun (nm,isOptArg,paramPrefix) tau tyL -> - FSharpMethodGroupItemParameter( - name = nm, - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, - display = paramPrefix ^^ tyL, - isOptional=isOptArg - )) - - let ParamsOfTypes g denv args rtau = - let ptausL, _ = NicePrint.layoutPrettifiedTypes denv (args@[rtau]) - let argsL,_ = List.frontAndBack ptausL - let mkParam (tau,tyL) = - FSharpMethodGroupItemParameter( - name = "", - canonicalTypeTextForSorting = printCanonicalizedTypeName g denv tau, - display = tyL, - isOptional=false - ) - (args,argsL) ||> List.zip |> List.map mkParam - -#if EXTENSIONTYPING - - let (|ItemIsProvidedType|_|) g item = - match item with - | Item.Types(_name,tys) -> - match tys with - | [AppTy g (tyconRef,_typeInst)] -> - if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then - Some tyconRef - else - None - | _ -> None - | _ -> None - - let (|ItemIsProvidedTypeWithStaticArguments|_|) m g item = - match item with - | Item.Types(_name,tys) -> - match tys with - | [AppTy g (tyconRef,_typeInst)] -> - if tyconRef.IsProvidedErasedTycon || tyconRef.IsProvidedGeneratedTycon then - let typeBeforeArguments = - match tyconRef.TypeReprInfo with - | TProvidedTypeExtensionPoint info -> info.ProvidedType - | _ -> failwith "unreachable" - let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments,provider) -> typeBeforeArguments.GetStaticParameters(provider)), range=m) - let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters",m) - Some staticParameters - else - None - | _ -> None - | _ -> None - - - let (|ItemIsProvidedMethodWithStaticArguments|_|) item = - match item with - // Prefer the static parameters from the uninstantiated method info - | Item.MethodGroup(_,_,Some minfo) -> - match minfo.ProvidedStaticParameterInfo with - | Some (_,staticParameters) -> Some staticParameters - | _ -> None - | Item.MethodGroup(_,[minfo],_) -> - match minfo.ProvidedStaticParameterInfo with - | Some (_,staticParameters) -> Some staticParameters - | _ -> None - | _ -> None - - let (|ItemIsWithStaticArguments|_|) m g item = - match item with - | ItemIsProvidedTypeWithStaticArguments m g staticParameters -> Some staticParameters - | ItemIsProvidedMethodWithStaticArguments staticParameters -> Some staticParameters - | _ -> None -#endif - -#if EXTENSIONTYPING - let StaticParamsOfItem (infoReader:InfoReader) m denv d = - let amap = infoReader.amap - let g = infoReader.g - match d with - | ItemIsWithStaticArguments m g staticParameters -> - staticParameters - |> Array.map (fun sp -> - let typ = Import.ImportProvidedType amap m (sp.PApply((fun x -> x.ParameterType),m)) - let spKind = NicePrint.prettyLayoutOfTy denv typ - let spName = sp.PUntaint((fun sp -> sp.Name), m) - let spOpt = sp.PUntaint((fun sp -> sp.IsOptional), m) - FSharpMethodGroupItemParameter( - name = spName, - canonicalTypeTextForSorting = showL spKind, - display = (if spOpt then SepL.questionMark else emptyL) ^^ wordL (TaggedTextOps.tagParameter spName) ^^ RightL.colon ^^ spKind, - //display = sprintf "%s%s: %s" (if spOpt then "?" else "") spName spKind, - isOptional=spOpt)) - | _ -> [||] -#else - let StaticParamsOfItem _infoReader _m _denv _d = [||] -#endif - - let rec ParamsOfItem (infoReader:InfoReader) m denv d = - let amap = infoReader.amap - let g = infoReader.g - match d with - | Item.Value vref -> - let getParamsOfTypes() = - let _, tau = vref.TypeScheme - match tryDestFunTy denv.g tau with - | Some(arg,rtau) -> - let args = tryDestRefTupleTy denv.g arg - ParamsOfTypes g denv args rtau - | None -> [] - match vref.ValReprInfo with - | None -> - // ValReprInfo = None i.e. in let bindings defined in types or in local functions - // in this case use old approach and return only information about types - getParamsOfTypes () - | Some valRefInfo -> - // ValReprInfo will exist for top-level syntactic functions - // per spec: binding is considered to define a syntactic function if it is either a function or its immediate right-hand-side is a anonymous function - let (_, argInfos, returnTy, _) = GetTopValTypeInFSharpForm g valRefInfo vref.Type m - match argInfos with - | [] -> - // handles cases like 'let foo = List.map' - getParamsOfTypes() - | argInfo::_ -> - // result 'paramDatas' collection corresponds to the first argument of curried function - // i.e. let func (a : int) (b : int) = a + b - // paramDatas will contain information about a and returnTy will be: int -> int - // This is good enough as we don't provide ways to display info for the second curried argument - let paramDatas = - argInfo - |> List.map ParamNameAndType.FromArgInfo - |> List.map (fun (ParamNameAndType(nmOpt, pty)) -> ParamData(false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None, pty)) - ParamsOfParamDatas g denv paramDatas returnTy - | Item.UnionCase(ucr,_) -> - match ucr.UnionCase.RecdFields with - | [f] -> [ParamOfUnionCaseField g denv NicePrint.isGeneratedUnionCaseField -1 f] - | fs -> fs |> List.mapi (ParamOfUnionCaseField g denv NicePrint.isGeneratedUnionCaseField) - | Item.ActivePatternCase(apref) -> - let v = apref.ActivePatternVal - let _,tau = v.TypeScheme - let args, _ = stripFunTy denv.g tau - ParamsOfTypes g denv args tau - | Item.ExnCase(ecref) -> - ecref |> recdFieldsOfExnDefRef |> List.mapi (ParamOfUnionCaseField g denv NicePrint.isGeneratedExceptionField) - | Item.Property(_,pinfo :: _) -> - let paramDatas = pinfo.GetParamDatas(amap,m) - let rty = pinfo.GetPropertyType(amap,m) - ParamsOfParamDatas g denv paramDatas rty - | Item.CtorGroup(_,(minfo :: _)) - | Item.MethodGroup(_,(minfo :: _),_) -> - let paramDatas = minfo.GetParamDatas(amap, m, minfo.FormalMethodInst) |> List.head - let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) - ParamsOfParamDatas g denv paramDatas rty - | Item.CustomBuilder (_,vref) -> ParamsOfItem infoReader m denv (Item.Value vref) - | Item.TypeVar _ -> [] - - | Item.CustomOperation (_,usageText, Some minfo) -> - match usageText() with - | None -> - let argNamesAndTys = ItemDescriptionsImpl.ParamNameAndTypesOfUnaryCustomOperation g minfo - let _, argTys, _ = PrettyTypes.PrettifyTypesN g (argNamesAndTys |> List.map (fun (ParamNameAndType(_,ty)) -> ty)) - let paramDatas = (argNamesAndTys, argTys) ||> List.map2 (fun (ParamNameAndType(nmOpt, _)) argTy -> ParamData(false, false, NotOptional, NoCallerInfo, nmOpt, ReflectedArgInfo.None,argTy)) - let rty = minfo.GetFSharpReturnTy(amap, m, minfo.FormalMethodInst) - ParamsOfParamDatas g denv paramDatas rty - | Some _ -> - [] // no parameter data available for binary operators like 'zip', 'join' and 'groupJoin' since they use bespoke syntax - - | Item.FakeInterfaceCtor _ -> [] - | Item.DelegateCtor delty -> - let (SigOfFunctionForDelegate(_, _, _, fty)) = GetSigOfFunctionForDelegate infoReader delty m AccessibleFromSomeFSharpCode - ParamsOfParamDatas g denv [ParamData(false, false, NotOptional, NoCallerInfo, None, ReflectedArgInfo.None, fty)] delty - | _ -> [] - - -/// A single method for Intellisense completion -[] -// Note: instances of this type do not hold any references to any compiler resources. -type FSharpMethodGroupItem(description: FSharpToolTipText, xmlDoc: FSharpXmlDoc, typeText: Layout, parameters: FSharpMethodGroupItemParameter[], hasParameters: bool, hasParamArrayArg: bool, staticParameters: FSharpMethodGroupItemParameter[]) = - member __.StructuredDescription = description - member __.Description = Tooltips.ToFSharpToolTipText description - member __.XmlDoc = xmlDoc - member __.StructuredTypeText = typeText - member __.TypeText = showL typeText - member __.Parameters = parameters - member __.HasParameters = hasParameters - member __.HasParamArrayArg = hasParamArrayArg - // Does the type name or method support a static arguments list, like TP<42,"foo"> or conn.CreateCommand<42, "foo">(arg1, arg2)? - member __.StaticParameters = staticParameters - - -/// A table of methods for Intellisense completion -// -// Note: this type does not hold any strong references to any compiler resources, nor does evaluating any of the properties execute any -// code on the compiler thread. -[] -type FSharpMethodGroup( name: string, unsortedMethods: FSharpMethodGroupItem[] ) = - // BUG 413009 : [ParameterInfo] takes about 3 seconds to move from one overload parameter to another - // cache allows to avoid recomputing parameterinfo for the same item -#if !FX_NO_WEAKTABLE - static let methodOverloadsCache = System.Runtime.CompilerServices.ConditionalWeakTable() -#endif - - let methods = - unsortedMethods - // Methods with zero arguments show up here as taking a single argument of type 'unit'. Patch them now to appear as having zero arguments. - |> Array.map (fun meth -> - let parms = meth.Parameters - if parms.Length = 1 && parms.[0].CanonicalTypeTextForSorting="Microsoft.FSharp.Core.Unit" then - FSharpMethodGroupItem(meth.StructuredDescription, meth.XmlDoc, meth.StructuredTypeText, [||], true, meth.HasParamArrayArg, meth.StaticParameters) - else - meth) - // Fix the order of methods, to be stable for unit testing. - |> Array.sortBy (fun meth -> - let parms = meth.Parameters - parms.Length, (parms |> Array.map (fun p -> p.CanonicalTypeTextForSorting))) - member x.MethodName = name - member x.Methods = methods - - static member Create(infoReader:InfoReader,m,denv,items:Item list) = - let g = infoReader.g - if isNil items then new FSharpMethodGroup("", [| |]) else - let name = items.Head.DisplayName - let getOverloadsForItem item = -#if !FX_NO_WEAKTABLE - match methodOverloadsCache.TryGetValue item with - | true, overloads -> overloads - | false, _ -> -#endif - let items = - match item with - | Item.CtorGroup(nm,cinfos) -> List.map (fun minfo -> Item.CtorGroup(nm,[minfo])) cinfos - | Item.FakeInterfaceCtor _ - | Item.DelegateCtor _ -> [item] - | Item.NewDef _ - | Item.ILField _ -> [] - | Item.Event _ -> [] - | Item.RecdField(rfinfo) -> - if isFunction g rfinfo.FieldType then [item] else [] - | Item.Value v -> - if isFunction g v.Type then [item] else [] - | Item.UnionCase(ucr,_) -> - if not ucr.UnionCase.IsNullary then [item] else [] - | Item.ExnCase(ecr) -> - if isNil (recdFieldsOfExnDefRef ecr) then [] else [item] - | Item.Property(_,pinfos) -> - let pinfo = List.head pinfos - if pinfo.IsIndexer then [item] else [] -#if EXTENSIONTYPING - | Params.ItemIsWithStaticArguments m g _ -> [item] // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them -#endif - | Item.MethodGroup(nm,minfos,orig) -> minfos |> List.map (fun minfo -> Item.MethodGroup(nm,[minfo],orig)) - | Item.CustomOperation(_name, _helpText, _minfo) -> [item] - | Item.TypeVar _ -> [] - | Item.CustomBuilder _ -> [] - | _ -> [] - - let methods = - items |> Array.ofList |> Array.map (fun item -> - FSharpMethodGroupItem( - description = FSharpToolTipText [FormatStructuredDescriptionOfItem true infoReader m denv item], - typeText = FormatStructuredReturnTypeOfItem infoReader m denv item, - xmlDoc = GetXmlCommentForItem infoReader m item, - parameters = (Params.ParamsOfItem infoReader m denv item |> Array.ofList), - #if EXTENSIONTYPING - hasParameters = (match item with Params.ItemIsProvidedTypeWithStaticArguments m g _ -> false | _ -> true), - #else - hasParameters = true, - #endif - hasParamArrayArg = (match item with Item.CtorGroup(_,[meth]) | Item.MethodGroup(_,[meth],_) -> meth.HasParamArrayArg(infoReader.amap, m, meth.FormalMethodInst) | _ -> false), - staticParameters = Params.StaticParamsOfItem infoReader m denv item - )) -#if !FX_NO_WEAKTABLE - methodOverloadsCache.Add(item, methods) -#endif - methods - let methods = [| for item in items do yield! getOverloadsForItem item |] - - new FSharpMethodGroup(name, methods) - //---------------------------------------------------------------------------- // Scopes. //-------------------------------------------------------------------------- [] -type (*internal*) FSharpFindDeclFailureReason = +type FSharpFindDeclFailureReason = // generic reason: no particular information about error - | Unknown + | Unknown of message: string // source code file is not available | NoSourceCode // trying to find declaration of ProvidedType without TypeProviderDefinitionLocationAttribute @@ -438,19 +88,21 @@ type (*internal*) FSharpFindDeclFailureReason = // trying to find declaration of ProvidedMember without TypeProviderDefinitionLocationAttribute | ProvidedMember of string +[] type FSharpFindDeclResult = /// declaration not found + reason | DeclNotFound of FSharpFindDeclFailureReason /// found declaration | DeclFound of range - + /// Indicates an external declaration was found + | ExternalDecl of assembly : string * externalSym : ExternalSymbol /// This type is used to describe what was found during the name resolution. /// (Depending on the kind of the items, we may stop processing or continue to find better items) [] [] type internal NameResResult = - | Members of (Item list * DisplayEnv * range) + | Members of (ItemWithInst list * DisplayEnv * range) | Cancel of DisplayEnv * range | Empty | TypecheckStaleAndTextChanged @@ -466,32 +118,10 @@ type GetPreciseCompletionListFromExprTypingsResult = | NoneBecauseTypecheckIsStaleAndTextChanged | NoneBecauseThereWereTypeErrors | None - | Some of (Item list * DisplayEnv * range) * TType + | Some of (ItemWithInst list * DisplayEnv * range) * TType type Names = string list -[] -type FSharpSymbolUse(g:TcGlobals, denv: DisplayEnv, symbol:FSharpSymbol, itemOcc, range: range) = - member __.Symbol = symbol - member __.DisplayContext = FSharpDisplayContext(fun _ -> denv) - member x.IsDefinition = x.IsFromDefinition - member __.IsFromDefinition = (match itemOcc with ItemOccurence.Binding -> true | _ -> false) - member __.IsFromPattern = (match itemOcc with ItemOccurence.Pattern -> true | _ -> false) - member __.IsFromType = (match itemOcc with ItemOccurence.UseInType -> true | _ -> false) - member __.IsFromAttribute = (match itemOcc with ItemOccurence.UseInAttribute -> true | _ -> false) - member __.IsFromDispatchSlotImplementation = (match itemOcc with ItemOccurence.Implemented -> true | _ -> false) - member __.IsFromComputationExpression = - match symbol.Item, itemOcc with - // 'seq' in 'seq { ... }' gets colored as keywords - | (Item.Value vref), ItemOccurence.Use when valRefEq g g.seq_vref vref -> true - // custom builders, custom operations get colored as keywords - | (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use -> true - | _ -> false - - member __.FileName = range.FileName - member __.Range = Range.toZ range - member __.RangeAlternate = range - [] type SemanticClassificationType = | ReferenceType @@ -510,10 +140,10 @@ type SemanticClassificationType = | Operator | Disposable -// A scope represents everything we get back from the typecheck of a file. -// It acts like an in-memory database about the file. -// It is effectively immutable and not updated: when we re-typecheck we just drop the previous -// scope object on the floor and make a new one. +/// A TypeCheckInfo represents everything we get back from the typecheck of a file. +/// It acts like an in-memory database about the file. +/// It is effectively immutable and not updated: when we re-typecheck we just drop the previous +/// scope object on the floor and make a new one. [] type TypeCheckInfo (// Information corresponding to miscellaneous command-line options (--define, etc). @@ -524,8 +154,8 @@ type TypeCheckInfo thisCcu: CcuThunk, tcImports: TcImports, tcAccessRights: AccessorDomain, - projectFileName: string , - mainInputFileName: string , + projectFileName: string, + mainInputFileName: string, sResolutions: TcResolutions, sSymbolUses: TcSymbolUses, // This is a name resolution environment to use if no better match can be found. @@ -544,7 +174,7 @@ type TypeCheckInfo // Is not keyed on 'Names' collection because this is invariant for the current position in // this unchanged file. Keyed on lineStr though to prevent a change to the currently line // being available against a stale scope. - let getToolTipTextCache = AgedLookup>(getToolTipTextSize,areSame=(fun (x,y) -> x = y)) + let getToolTipTextCache = AgedLookup>(getToolTipTextSize,areSimilar=(fun (x,y) -> x = y)) let amap = tcImports.GetImportMap() let infoReader = new InfoReader(g,amap) @@ -611,12 +241,12 @@ type TypeCheckInfo /// noisy. Filter a few things out. /// /// e.g. prefer types to constructors for FSharpToolTipText - let FilterItemsForCtors filterCtors items = - let items = items |> List.filter (function (Item.CtorGroup _) when filterCtors = ResolveTypeNamesToTypeRefs -> false | _ -> true) + let FilterItemsForCtors filterCtors (items: ItemWithInst list) = + let items = items |> List.filter (fun item -> match item.Item with (Item.CtorGroup _) when filterCtors = ResolveTypeNamesToTypeRefs -> false | _ -> true) items // Filter items to show only valid & return Some if there are any - let ReturnItemsOfType items g denv (m:range) filterCtors hasTextChangedSinceLastTypecheck f = + let ReturnItemsOfType (items: ItemWithInst list) g denv (m:range) filterCtors hasTextChangedSinceLastTypecheck = let items = items |> RemoveDuplicateItems g @@ -627,7 +257,7 @@ type TypeCheckInfo if hasTextChangedSinceLastTypecheck(textSnapshotInfo, m) then NameResResult.TypecheckStaleAndTextChanged // typecheck is stale, wait for second-chance IntelliSense to bring up right result else - f(items, denv, m) + NameResResult.Members (items, denv, m) else NameResResult.Empty let GetCapturedNameResolutions endOfNamesPos resolveOverloads = @@ -648,15 +278,16 @@ type TypeCheckInfo let endOfNamesPos = mkPos line colAtEndOfNames // Logic below expects the list to be in reverse order of resolution - let items = GetCapturedNameResolutions endOfNamesPos resolveOverloads |> ResizeArray.toList |> List.rev + let cnrs = GetCapturedNameResolutions endOfNamesPos resolveOverloads |> ResizeArray.toList |> List.rev - match items, membersByResidue with + match cnrs, membersByResidue with // If we're looking for members using a residue, we'd expect only // a single item (pick the first one) and we need the residue (which may be "") - | CNR(_,Item.Types(_,(typ::_)),_,denv,nenv,ad,m)::_, Some _ -> + | CNR(_,Item.Types(_,(typ::_)), _, denv, nenv, ad, m)::_, Some _ -> let items = ResolveCompletionsInType ncenv nenv (ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m)) m ad true typ - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck NameResResult.Members + let items = List.map ItemWithNoInst items + ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck // Value reference from the name resolution. Primarily to disallow "let x.$ = 1" // In most of the cases, value references can be obtained from expression typings or from environment, @@ -688,16 +319,19 @@ type TypeCheckInfo | _ -> ad let items = ResolveCompletionsInType ncenv nenv (ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m)) m ad false ty - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck NameResResult.Members + let items = List.map ItemWithNoInst items + ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck // No residue, so the items are the full resolution of the name - | CNR(_,_,_,denv,_,_,m) :: _, None -> - let items = items |> List.map (fun (CNR(_,item,_,_,_,_,_)) -> item) - // "into" is special magic syntax, not an identifier or a library call. It is part of capturedNameResolutions as an - // implementation detail of syntax coloring, but we should not report name resolution results for it, to prevent spurious QuickInfo. - |> List.filter (function Item.CustomOperation(CustomOperations.Into,_,_) -> false | _ -> true) - ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck NameResResult.Members - | _ , _ -> NameResResult.Empty + | CNR(_, _, _, denv, _, _, m) :: _, None -> + let items = + cnrs + |> List.map (fun cnr -> cnr.ItemWithInst) + // "into" is special magic syntax, not an identifier or a library call. It is part of capturedNameResolutions as an + // implementation detail of syntax coloring, but we should not report name resolution results for it, to prevent spurious QuickInfo. + |> List.filter (fun item -> match item.Item with Item.CustomOperation(CustomOperations.Into,_,_) -> false | _ -> true) + ReturnItemsOfType items g denv m filterCtors hasTextChangedSinceLastTypecheck + | _, _ -> NameResResult.Empty let TryGetTypeFromNameResolution(line, colAtEndOfNames, membersByResidue, resolveOverloads) = let endOfNamesPos = mkPos line colAtEndOfNames @@ -708,7 +342,7 @@ type TypeCheckInfo | CNR(_, Item.Value(vref), occurence,_,_,_,_)::_, Some _ -> if (occurence = ItemOccurence.Binding || occurence = ItemOccurence.Pattern) then None else Some (StripSelfRefCell(g, vref.BaseOrThisInfo, vref.TauType)) - | _ , _ -> None + | _, _ -> None let CollectParameters (methods: MethInfo list) amap m: Item list = methods @@ -726,11 +360,12 @@ type TypeCheckInfo let cnrs = GetCapturedNameResolutions endOfExprPos ResolveOverloads.No |> ResizeArray.toList |> List.rev let result = match cnrs with - | CNR(_, Item.CtorGroup(_, ((ctor::_) as ctors)), _, denv, nenv, ad, m)::_ -> + | CNR(_, Item.CtorGroup(_, ((ctor::_) as ctors)), _, denv, nenv, ad, m) ::_ -> let props = ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ctor.EnclosingType let parameters = CollectParameters ctors amap m - Some (denv, m, props @ parameters) - | CNR(_, Item.MethodGroup(_, methods, _), _, denv, nenv, ad, m)::_ -> + let items = props @ parameters + Some (denv, m, items) + | CNR(_, Item.MethodGroup(_, methods, _), _, denv, nenv, ad, m) ::_ -> let props = methods |> List.collect (fun meth -> @@ -738,14 +373,16 @@ type TypeCheckInfo ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false retTy ) let parameters = CollectParameters methods amap m - Some (denv, m, props @ parameters) + let items = props @ parameters + Some (denv, m, items) | _ -> None match result with | None -> NameResResult.Empty - | Some (denv, m, result) -> - ReturnItemsOfType result g denv m TypeNameResolutionFlag.ResolveTypeNamesToTypeRefs hasTextChangedSinceLastTypecheck NameResResult.Members + | Some (denv, m, items) -> + let items = List.map ItemWithNoInst items + ReturnItemsOfType items g denv m TypeNameResolutionFlag.ResolveTypeNamesToTypeRefs hasTextChangedSinceLastTypecheck /// finds captured typing for the given position let GetExprTypingForPosition(endOfExprPos) = @@ -826,6 +463,7 @@ type TypeCheckInfo | Some bestQual -> let (_,typ,denv,nenv,ad,m) = bestQual let items = ResolveCompletionsInType ncenv nenv (ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m)) m ad false typ + let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g let items = items |> RemoveExplicitlySuppressed g let items = items |> FilterItemsForCtors filterCtors @@ -835,25 +473,27 @@ type TypeCheckInfo else GetPreciseCompletionListFromExprTypingsResult.None /// Find items in the best naming environment. - let GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, showObsolete) : Item list * DisplayEnv * range = + let GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, showObsolete) = let items = NameResolution.ResolvePartialLongIdent ncenv nenv (ConstraintSolver.IsApplicableMethApprox g amap m) m ad plid showObsolete + let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g let items = items |> RemoveExplicitlySuppressed g let items = items |> FilterItemsForCtors filterCtors (items, nenv.DisplayEnv, m) /// Find items in the best naming environment. - let GetEnvironmentLookupResolutionsAtPosition(cursorPos, plid, filterCtors, showObsolete) : Item list * DisplayEnv * range = + let GetEnvironmentLookupResolutionsAtPosition(cursorPos, plid, filterCtors, showObsolete) = let (nenv,ad),m = GetBestEnvForPos cursorPos GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, showObsolete) /// Find record fields in the best naming environment. - let GetClassOrRecordFieldsEnvironmentLookupResolutions(cursorPos, plid, (_residue : string option)) : Item list * DisplayEnv * range = + let GetClassOrRecordFieldsEnvironmentLookupResolutions(cursorPos, plid) = let (nenv, ad),m = GetBestEnvForPos cursorPos let items = NameResolution.ResolvePartialLongIdentToClassOrRecdFields ncenv nenv m ad plid false + let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g let items = items |> RemoveExplicitlySuppressed g - items, nenv.DisplayEnv,m + items, nenv.DisplayEnv, m /// Resolve a location and/or text to items. // Three techniques are used @@ -914,9 +554,9 @@ type TypeCheckInfo p <- p - 1 if p >= 0 then Some p else None - let CompletionItem (ty: TyconRef option) (unresolvedEntity: AssemblySymbol option) (item: Item) = + let CompletionItem (ty: TyconRef option) (unresolvedEntity: AssemblySymbol option) (item: ItemWithInst) = let kind = - match item with + match item.Item with | Item.MethodGroup (_, minfo :: _, _) -> CompletionItemKind.Method minfo.IsExtensionMember | Item.RecdField _ | Item.Property _ -> CompletionItemKind.Property @@ -939,18 +579,19 @@ type TypeCheckInfo { DisplayName = displayName Namespace = ns }) - { Item = item + { ItemWithInst = item MinorPriority = 0 Kind = kind IsOwnMember = false Type = ty Unresolved = unresolved } - let DefaultCompletionItem = CompletionItem None None + let DefaultCompletionItem item = CompletionItem None None item + let getItem (x: ItemWithInst) = x.Item let GetDeclaredItems (parseResultsOpt: FSharpParseFileResults option, lineStr: string, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors, resolveOverloads, hasTextChangedSinceLastTypecheck, isInRangeOperator, allSymbols: unit -> AssemblySymbol list) = - + // Are the last two chars (except whitespaces) = ".." let isLikeRangeOp = match FindFirstNonWhitespacePosition lineStr (colAtEndOfNamesAndResidue - 1) with @@ -1019,7 +660,7 @@ type TypeCheckInfo match nameResItems with | NameResResult.TypecheckStaleAndTextChanged -> None // second-chance intellisense will try again | NameResResult.Cancel(denv,m) -> Some([], denv, m) - | NameResResult.Members(FilterRelevantItems id exactMatchResidueOpt (items, denv, m)) -> + | NameResResult.Members(FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m)) -> // lookup based on name resolution results successful Some (items |> List.map (CompletionItem (getType()) None), denv, m) | _ -> @@ -1049,7 +690,7 @@ type TypeCheckInfo GetPreciseCompletionListFromExprTypingsResult.None, false match qualItems,thereIsADotInvolved with - | GetPreciseCompletionListFromExprTypingsResult.Some(FilterRelevantItems id exactMatchResidueOpt (items, denv, m), ty), _ + | GetPreciseCompletionListFromExprTypingsResult.Some(FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m), ty), _ // Initially we only use the expression typings when looking up, e.g. (expr).Nam or (expr).Name1.Nam // These come through as an empty plid and residue "". Otherwise we try an environment lookup // and then return to the qualItems. This is because the expression typings are a little inaccurate, primarily because @@ -1083,12 +724,12 @@ type TypeCheckInfo // If we have nonempty items from environment that were resolved from a type, then use them... // (that's better than the next case - here we'd return 'int' as a type) - | _, FilterRelevantItems id exactMatchResidueOpt (items, denv, m), _ when not (isNil items) -> + | _, FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m), _ when not (isNil items) -> // lookup based on name and environment successful Some(items |> List.map (CompletionItem (getType()) None), denv, m) // Try again with the qualItems - | _, _, GetPreciseCompletionListFromExprTypingsResult.Some(FilterRelevantItems id exactMatchResidueOpt (items, denv, m), ty) -> + | _, _, GetPreciseCompletionListFromExprTypingsResult.Some(FilterRelevantItems getItem exactMatchResidueOpt (items, denv, m), ty) -> Some(items |> List.map (CompletionItem (tryDestAppTy g ty) None), denv, m) | _ -> None @@ -1096,7 +737,7 @@ type TypeCheckInfo let globalResult = match origLongIdentOpt with | None | Some [] -> - let allItems = + let globalItems = allSymbols() |> List.filter (fun x -> not x.Symbol.IsExplicitlySuppressed) |> List.filter (fun x -> @@ -1106,13 +747,11 @@ type TypeCheckInfo let getItem (x: AssemblySymbol) = x.Symbol.Item - match allItems, denv, m with - | FilterRelevantItems getItem exactMatchResidueOpt (entities, denv, m) when not (isNil entities) -> - // lookup based on name and environment successful - Some( - entities - |> List.map(fun entity -> - CompletionItem (getType()) (Some entity) entity.Symbol.Item), denv, m) + match globalItems, denv, m with + | FilterRelevantItems getItem exactMatchResidueOpt (globalItemsFiltered, denv, m) when not (isNil globalItemsFiltered) -> + globalItemsFiltered + |> List.map(fun globalItem -> CompletionItem (getType()) (Some globalItem) (ItemWithNoInst globalItem.Symbol.Item)) + |> fun r -> Some(r, denv, m) | _ -> None | _ -> None // do not return unresolved items after dot @@ -1123,7 +762,7 @@ type TypeCheckInfo | None, None -> None - let toCompletionItems (items: Item list, denv: DisplayEnv, m: range) : CompletionItem list * DisplayEnv * range = + let toCompletionItems (items: ItemWithInst list, denv: DisplayEnv, m: range ) = items |> List.map DefaultCompletionItem, denv, m /// Get the auto-complete items at a particular location. @@ -1150,41 +789,43 @@ type TypeCheckInfo // Completion at 'inherit C(...)" | Some (CompletionContext.Inherit(InheritanceContext.Class, (plid, _))) -> GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) - |> FilterRelevantItemsBy id None GetBaseClassCandidates + |> FilterRelevantItemsBy getItem None (getItem >> GetBaseClassCandidates) |> Option.map toCompletionItems - + // Completion at 'interface ..." | Some (CompletionContext.Inherit(InheritanceContext.Interface, (plid, _))) -> GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) - |> FilterRelevantItemsBy id None GetInterfaceCandidates + |> FilterRelevantItemsBy getItem None (getItem >> GetInterfaceCandidates) |> Option.map toCompletionItems // Completion at 'implement ..." | Some (CompletionContext.Inherit(InheritanceContext.Unknown, (plid, _))) -> GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) - |> FilterRelevantItemsBy id None (fun t -> GetBaseClassCandidates t || GetInterfaceCandidates t) + |> FilterRelevantItemsBy getItem None (getItem >> (fun t -> GetBaseClassCandidates t || GetInterfaceCandidates t)) |> Option.map toCompletionItems // Completion at ' { XXX = ... } " - | Some(CompletionContext.RecordField(RecordContext.New(plid, residue))) -> + | Some(CompletionContext.RecordField(RecordContext.New(plid, _))) -> // { x. } can be either record construction or computation expression. Try to get all visible record fields first - match GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, residue) |> toCompletionItems with + match GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid) |> toCompletionItems with | [],_,_ -> // no record fields found, return completion list as if we were outside any computation expression GetDeclaredItems (parseResultsOpt, lineStr, origLongIdentOpt, colAtEndOfNamesAndResidue, residueOpt, line, loc, filterCtors,resolveOverloads, hasTextChangedSinceLastTypecheck, false, fun() -> []) | result -> Some(result) // Completion at ' { XXX = ... with ... } " - | Some(CompletionContext.RecordField(RecordContext.CopyOnUpdate(r, (plid, residue)))) -> + | Some(CompletionContext.RecordField(RecordContext.CopyOnUpdate(r, (plid, _)))) -> match GetRecdFieldsForExpr(r) with | None -> - Some (GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, residue)) + Some (GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid)) + |> Option.map toCompletionItems + | Some (items, denv, m) -> + Some (List.map ItemWithNoInst items, denv, m) |> Option.map toCompletionItems - | x -> x |> Option.map toCompletionItems // Completion at ' { XXX = ... with ... } " | Some(CompletionContext.RecordField(RecordContext.Constructor(typeName))) -> - Some(GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, [typeName], None)) + Some(GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, [typeName])) |> Option.map toCompletionItems // Completion at ' SomeMethod( ... ) ' with named arguments @@ -1201,9 +842,9 @@ type TypeCheckInfo items |> RemoveDuplicateItems g |> RemoveExplicitlySuppressed g - |> List.filter (fun m -> not (fields.Contains m.DisplayName)) - |> List.map (fun x -> - { Item = x + |> List.filter (fun item -> not (fields.Contains item.Item.DisplayName)) + |> List.map (fun item -> + { ItemWithInst = item Kind = CompletionItemKind.Argument MinorPriority = 0 IsOwnMember = false @@ -1242,25 +883,24 @@ type TypeCheckInfo | Item.Types _ | Item.ModuleOrNamespaces _ -> true | _ -> false - member x.GetVisibleNamespacesAndModulesAtPosition(cursorPos: pos) : ModuleOrNamespaceRef list = + member __.GetVisibleNamespacesAndModulesAtPosition(cursorPos: pos) : ModuleOrNamespaceRef list = let (nenv, ad), m = GetBestEnvForPos cursorPos NameResolution.GetVisibleNamespacesAndModulesAtPoint ncenv nenv m ad - member x.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item) : bool = /// Determines if a long ident is resolvable at a specific point. + member __.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item) : bool = ErrorScope.Protect Range.range0 (fun () -> /// Find items in the best naming environment. let (nenv, ad), m = GetBestEnvForPos cursorPos NameResolution.IsItemResolvable ncenv nenv m ad plid item) - (fun _ -> false) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in IsRelativeNameResolvable: '%s'" msg) + false) - //let items = NameResolution.ResolvePartialLongIdent ncenv nenv (fun _ _ -> true) m ad plid true - //items |> List.exists (ItemsAreEffectivelyEqual g item) - /// Get the auto-complete items at a location - member x.GetDeclarations (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, getAllSymbols, hasTextChangedSinceLastTypecheck) = + member __.GetDeclarations (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, getAllSymbols, hasTextChangedSinceLastTypecheck) = let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName ErrorScope.Protect Range.range0 (fun () -> @@ -1275,10 +915,12 @@ type TypeCheckInfo |> Option.map (fun parsedInput -> UntypedParseImpl.GetFullNameOfSmallestModuleOrNamespaceAtPoint(parsedInput, mkPos line 0)) let isAttributeApplication = ctx = Some CompletionContext.AttributeApplication FSharpDeclarationListInfo.Create(infoReader,m,denv,getAccessibility,items,reactorOps,currentNamespaceOrModule,isAttributeApplication,checkAlive)) - (fun msg -> FSharpDeclarationListInfo.Error msg) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetDeclarations: '%s'" msg) + FSharpDeclarationListInfo.Error msg) /// Get the symbols for auto-complete items at a location - member x.GetDeclarationListSymbols (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck) = + member __.GetDeclarationListSymbols (ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck) = let isInterfaceFile = SourceFileImpl.IsInterfaceFile mainInputFileName ErrorScope.Protect Range.range0 (fun () -> @@ -1309,8 +951,6 @@ type TypeCheckInfo // Remove all duplicates. We've put the types first, so this removes the DelegateCtor and DefaultStructCtor's. let items = items |> RemoveDuplicateCompletionItems g - if verbose then dprintf "service.ml: mkDecls: %d found groups after filtering\n" (List.length items); - // Group by display name let items = items |> List.groupBy (fun d -> d.Item.DisplayName) @@ -1341,10 +981,12 @@ type TypeCheckInfo //end filtering items) - (fun _msg -> []) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetDeclarationListSymbols: '%s'" msg) + []) /// Get the "reference resolution" tooltip for at a location - member scope.GetReferenceResolutionStructuredToolTipText(ctok, line,col) = + member __.GetReferenceResolutionStructuredToolTipText(ctok, line,col) = RequireCompilationThread ctok // the operations in this method need the reactor thread but the reasons why are not yet grounded @@ -1369,24 +1011,28 @@ type TypeCheckInfo | resolved::_ // Take the first seen | [resolved] -> let tip = wordL (TaggedTextOps.tagStringLiteral((resolved.prepareToolTip ()).TrimEnd([|'\n'|]))) - FSharpStructuredToolTipText.FSharpToolTipText [FSharpStructuredToolTipElement.Single(tip ,FSharpXmlDoc.None)] + FSharpStructuredToolTipText.FSharpToolTipText [FSharpStructuredToolTipElement.Single(tip, FSharpXmlDoc.None)] | [] -> FSharpStructuredToolTipText.FSharpToolTipText [] ErrorScope.Protect Range.range0 dataTipOfReferences - (fun err -> FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) + (fun err -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetReferenceResolutionStructuredToolTipText: '%s'" err) + FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) // GetToolTipText: return the "pop up" (or "Quick Info") text given a certain context. - member x.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names) = + member __.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names) = let Compute() = ErrorScope.Protect Range.range0 (fun () -> match GetDeclItemsForNamesAtPosition(ctok, None,Some(names),None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []),fun _ -> false) with | None -> FSharpToolTipText [] | Some(items, denv, _, m) -> - FSharpToolTipText(items |> List.map (fun x -> FormatStructuredDescriptionOfItem false infoReader m denv x.Item))) - (fun err -> FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) + FSharpToolTipText(items |> List.map (fun x -> FormatStructuredDescriptionOfItem false infoReader m denv x.ItemWithInst))) + (fun err -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetStructuredToolTipText: '%s'" err) + FSharpToolTipText [FSharpStructuredToolTipElement.CompositionError err]) // See devdiv bug 646520 for rationale behind truncating and caching these quick infos (they can be big!) let key = line,colAtEndOfNames,lineStr @@ -1397,12 +1043,7 @@ type TypeCheckInfo getToolTipTextCache.Put(ctok, key,res) res - // GetToolTipText: return the "pop up" (or "Quick Info") text given a certain context. - member x.GetToolTipText ctok line lineStr colAtEndOfNames names = - x.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names) - |> Tooltips.ToFSharpToolTipText - - member x.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names) : string option = + member __.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names) : string option = ErrorScope.Protect Range.range0 (fun () -> match GetDeclItemsForNamesAtPosition(ctok, None, Some names, None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []), fun _ -> false) with // F1 Keywords do not distinguish between overloads @@ -1411,7 +1052,7 @@ type TypeCheckInfo match items with | [] -> None | [item] -> - GetF1Keyword item.Item + GetF1Keyword g item.Item | _ -> // handle new Type() let allTypes, constr, typ = @@ -1425,118 +1066,171 @@ type TypeCheckInfo (true,None,None) items match allTypes, constr, typ with | true, Some (Item.CtorGroup(_, _) as item), _ - -> GetF1Keyword item + -> GetF1Keyword g item | true, _, Some typ - -> GetF1Keyword typ + -> GetF1Keyword g typ | _ -> None ) - (fun _ -> None) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetF1Keyword: '%s'" msg) + None) - member scope.GetMethods (ctok, line, lineStr, colAtEndOfNames, namesOpt) = + member __.GetMethods (ctok, line, lineStr, colAtEndOfNames, namesOpt) = ErrorScope.Protect Range.range0 (fun () -> match GetDeclItemsForNamesAtPosition(ctok, None,namesOpt,None,line,lineStr,colAtEndOfNames,ResolveTypeNamesToCtors,ResolveOverloads.No,(fun() -> []),fun _ -> false) with | None -> FSharpMethodGroup("",[| |]) - | Some (items, denv,_, m) -> FSharpMethodGroup.Create(infoReader,m,denv,items |> List.map (fun x -> x.Item))) + | Some (items, denv, _, m) -> FSharpMethodGroup.Create(infoReader, m, denv, items |> List.map (fun x -> x.ItemWithInst))) (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetMethods: '%s'" msg) FSharpMethodGroup(msg,[| |])) - member scope.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) = + member __.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) = + ErrorScope.Protect Range.range0 + (fun () -> match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.No,(fun() -> []),fun _ -> false) with | None | Some ([],_,_,_) -> None | Some (items, denv, _, m) -> - let allItems = - items - |> List.collect (fun item -> - match item.Item with - | Item.MethodGroup(nm,minfos,orig) -> minfos |> List.map (fun minfo -> Item.MethodGroup(nm,[minfo],orig)) - | Item.CtorGroup(nm,cinfos) -> cinfos |> List.map (fun minfo -> Item.CtorGroup(nm,[minfo])) - | Item.FakeInterfaceCtor _ - | Item.DelegateCtor _ -> [item.Item] - | Item.NewDef _ - | Item.ILField _ -> [] - | Item.Event _ -> [] - | Item.RecdField(rfinfo) -> if isFunction g rfinfo.FieldType then [item.Item] else [] - | Item.Value v -> if isFunction g v.Type then [item.Item] else [] - | Item.UnionCase(ucr,_) -> if not ucr.UnionCase.IsNullary then [item.Item] else [] - | Item.ExnCase(ecr) -> if isNil (recdFieldsOfExnDefRef ecr) then [] else [item.Item] - | Item.Property(_,pinfos) -> - let pinfo = List.head pinfos - if pinfo.IsIndexer then [item.Item] else [] -#if EXTENSIONTYPING - | Params.ItemIsWithStaticArguments m g _ -> [item.Item] // we pretend that provided-types-with-static-args are method-like in order to get ParamInfo for them -#endif - | Item.CustomOperation(_name, _helpText, _minfo) -> [item.Item] - | Item.TypeVar _ -> [] - | Item.CustomBuilder _ -> [] - | _ -> [] ) - + let allItems = items |> List.collect (fun item -> SymbolHelpers.FlattenItems g m item.Item) let symbols = allItems |> List.map (fun item -> FSharpSymbol.Create(g, thisCcu, tcImports, item)) Some (symbols, denv, m) - + ) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetMethodsAsSymbols: '%s'" msg) + None) + member scope.GetDeclarationLocation (ctok, line, lineStr, colAtEndOfNames, names, preferFlag) = + ErrorScope.Protect Range.range0 + (fun () -> match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors,ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with | None - | Some ([], _, _, _) -> FSharpFindDeclResult.DeclNotFound FSharpFindDeclFailureReason.Unknown - | Some (item :: _ , _, _, _) -> - - // For IL-based entities, switch to a different item. This is because - // rangeOfItem, ccuOfItem don't work on IL methods or fields. - // - // Later comment: to be honest, they aren't going to work on these new items either. - // This is probably old code from when we supported 'go to definition' generating IL metadata. - let item = + | Some ([], _, _, _) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "") + | Some (item :: _, _, _, _) -> + let getTypeVarNames (ilinfo: ILMethInfo) = + let classTypeParams = ilinfo.DeclaringTyconRef.ILTyconRawMetadata.GenericParams |> List.map (fun paramDef -> paramDef.Name) + let methodTypeParams = ilinfo.FormalMethodTypars |> List.map (fun typ -> typ.Name) + classTypeParams @ methodTypeParams |> Array.ofList + + let result = match item.Item with - | Item.MethodGroup (_, (ILMeth (_,ilinfo,_)) :: _, _) - | Item.CtorGroup (_, (ILMeth (_,ilinfo,_)) :: _) -> Item.Types ("", [ ilinfo.ApparentEnclosingType ]) - | Item.ILField (ILFieldInfo (typeInfo, _)) -> Item.Types ("", [ typeInfo.ToType ]) - | Item.ImplicitOp(_, {contents = Some(TraitConstraintSln.FSMethSln(_, vref, _))}) -> Item.Value(vref) - | _ -> item.Item - - let fail defaultReason = - match item with + | Item.CtorGroup (_, (ILMeth (_,ilinfo,_)) :: _) -> + match ilinfo.MetadataScope with + | ILScopeRef.Assembly assref -> + let typeVarNames = getTypeVarNames ilinfo + ParamTypeSymbol.tryOfILTypes typeVarNames ilinfo.ILMethodRef.ArgTypes + |> Option.map (fun args -> + let externalSym = ExternalSymbol.Constructor (ilinfo.ILMethodRef.EnclosingTypeRef.FullName, args) + FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) + | _ -> None + + | Item.MethodGroup (name, (ILMeth (_,ilinfo,_)) :: _, _) -> + match ilinfo.MetadataScope with + | ILScopeRef.Assembly assref -> + let typeVarNames = getTypeVarNames ilinfo + ParamTypeSymbol.tryOfILTypes typeVarNames ilinfo.ILMethodRef.ArgTypes + |> Option.map (fun args -> + let externalSym = ExternalSymbol.Method (ilinfo.ILMethodRef.EnclosingTypeRef.FullName, name, args, ilinfo.ILMethodRef.GenericArity) + FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) + | _ -> None + + | Item.Property (name, ILProp (_, propInfo) :: _) -> + let methInfo = + if propInfo.HasGetter then Some (propInfo.GetterMethod g) + elif propInfo.HasSetter then Some (propInfo.SetterMethod g) + else None + + match methInfo with + | Some methInfo -> + match methInfo.MetadataScope with + | ILScopeRef.Assembly assref -> + let externalSym = ExternalSymbol.Property (methInfo.ILMethodRef.EnclosingTypeRef.FullName, name) + Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) + | _ -> None + | None -> None + + | Item.ILField (ILFieldInfo (ILTypeInfo (tr, _, _, _) & typeInfo, fieldDef)) when not tr.IsLocalRef -> + match typeInfo.ILScopeRef with + | ILScopeRef.Assembly assref -> + let externalSym = ExternalSymbol.Field (typeInfo.ILTypeRef.FullName, fieldDef.Name) + Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) + | _ -> None + + | Item.Event (ILEvent (_, ILEventInfo (ILTypeInfo (tr, _, _, _) & typeInfo, eventDef))) when not tr.IsLocalRef -> + match typeInfo.ILScopeRef with + | ILScopeRef.Assembly assref -> + let externalSym = ExternalSymbol.Event (typeInfo.ILTypeRef.FullName, eventDef.Name) + Some (FSharpFindDeclResult.ExternalDecl (assref.Name, externalSym)) + | _ -> None + + | Item.ImplicitOp(_, {contents = Some(TraitConstraintSln.FSMethSln(_, _vref, _))}) -> + //Item.Value(vref) + None + + | Item.Types (_, [AppTy g (tr, _)]) when not tr.IsLocalRef -> + match tr.TypeReprInfo, tr.PublicPath with + | TILObjectRepr(TILObjectReprData (ILScopeRef.Assembly assref, _, _)), Some (PubPath parts) -> + let fullName = parts |> String.concat "." + Some (FSharpFindDeclResult.ExternalDecl (assref.Name, ExternalSymbol.Type fullName)) + | _ -> None + | _ -> None + + match result with + | Some x -> x + | None -> + let fail defaultReason = + match item.Item with #if EXTENSIONTYPING - | Params.ItemIsProvidedType g (tcref) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedType(tcref.DisplayName)) - | Item.CtorGroup(name, ProvidedMeth(_)::_) - | Item.MethodGroup(name, ProvidedMeth(_)::_, _) - | Item.Property(name, ProvidedProp(_)::_) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(name)) - | Item.Event(ProvidedEvent(_) as e) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(e.EventName)) - | Item.ILField(ProvidedField(_) as f) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(f.FieldName)) + | SymbolHelpers.ItemIsProvidedType g (tcref) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedType(tcref.DisplayName)) + | Item.CtorGroup(name, ProvidedMeth(_)::_) + | Item.MethodGroup(name, ProvidedMeth(_)::_, _) + | Item.Property(name, ProvidedProp(_)::_) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(name)) + | Item.Event(ProvidedEvent(_) as e) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(e.EventName)) + | Item.ILField(ProvidedField(_) as f) -> FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.ProvidedMember(f.FieldName)) #endif - | _ -> FSharpFindDeclResult.DeclNotFound defaultReason - - match rangeOfItem g preferFlag item with - | None -> fail FSharpFindDeclFailureReason.Unknown - | Some itemRange -> - - let projectDir = Filename.directoryName (if projectFileName = "" then mainInputFileName else projectFileName) - let filename = fileNameOfItem g (Some projectDir) itemRange item - if FileSystem.SafeExists filename then - FSharpFindDeclResult.DeclFound (mkRange filename itemRange.Start itemRange.End) - else - fail FSharpFindDeclFailureReason.NoSourceCode // provided items may have TypeProviderDefinitionLocationAttribute that binds them to some location + | _ -> FSharpFindDeclResult.DeclNotFound defaultReason + + match rangeOfItem g preferFlag item.Item with + | None -> fail (FSharpFindDeclFailureReason.Unknown "") + | Some itemRange -> + + let projectDir = Filename.directoryName (if projectFileName = "" then mainInputFileName else projectFileName) + let filename = fileNameOfItem g (Some projectDir) itemRange item.Item + if FileSystem.SafeExists filename then + FSharpFindDeclResult.DeclFound (mkRange filename itemRange.Start itemRange.End) + else + fail FSharpFindDeclFailureReason.NoSourceCode // provided items may have TypeProviderDefinitionLocationAttribute that binds them to some location + ) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetDeclarationLocation: '%s'" msg) + FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown msg)) member scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) = + ErrorScope.Protect Range.range0 + (fun () -> match GetDeclItemsForNamesAtPosition (ctok, None,Some(names), None, line, lineStr, colAtEndOfNames, ResolveTypeNamesToCtors, ResolveOverloads.Yes,(fun() -> []), fun _ -> false) with | None | Some ([], _, _, _) -> None - | Some (item :: _ , denv, _, m) -> + | Some (item :: _, denv, _, m) -> let symbol = FSharpSymbol.Create(g, thisCcu, tcImports, item.Item) Some (symbol, denv, m) + ) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetSymbolUseAtLocation: '%s'" msg) + None) member scope.PartialAssemblySignature() = FSharpAssemblySignature(g, thisCcu, tcImports, None, ccuSig) - member scope.AccessRights = tcAccessRights + member __.AccessRights = tcAccessRights - member scope.GetReferencedAssemblies() = + member __.GetReferencedAssemblies() = [ for x in tcImports.GetImportedAssemblies() do yield FSharpAssembly(g, tcImports, x.FSharpViewOfMetadata) ] - // Note, this does not have to be a SyncOp, it can be called from any thread - member scope.GetFormatSpecifierLocationsAndArity() = + member __.GetFormatSpecifierLocationsAndArity() = sSymbolUses.GetFormatSpecifierLocationsAndArity() - // Not, this does not have to be a SyncOp, it can be called from any thread - member scope.GetSemanticClassification(range: range option) : (range * SemanticClassificationType) [] = + member __.GetSemanticClassification(range: range option) : (range * SemanticClassificationType) [] = + ErrorScope.Protect Range.range0 + (fun () -> let (|LegitTypeOccurence|_|) = function | ItemOccurence.UseInType | ItemOccurence.UseInAttribute @@ -1545,7 +1239,7 @@ type TypeCheckInfo | ItemOccurence.Pattern _ -> Some() | _ -> None - let inline (|OptionalArgumentAttribute|_|) ttype = + let (|OptionalArgumentAttribute|_|) ttype = match ttype with | TType.TType_app(tref, _) when tref.Stamp = g.attrib_OptionalArgumentAttribute.TyconRef.Stamp -> Some() | _ -> None @@ -1605,7 +1299,7 @@ type TypeCheckInfo Some (m, SemanticClassificationType.Function) | CNR(_, Item.RecdField EnumCaseFieldInfo, _, _, _, _, m) -> Some (m, SemanticClassificationType.Enumeration) - | CNR(_, Item.MethodGroup(_, _, _), _, _, _, _, m) -> + | CNR(_, Item.MethodGroup _, _, _, _, _, m) -> Some (m, SemanticClassificationType.Function) // custom builders, custom operations get colored as keywords | CNR(_, (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, _, _, _, m) -> @@ -1632,6 +1326,8 @@ type TypeCheckInfo if minfos |> List.exists (fun minfo -> isStructTy g minfo.EnclosingType) then Some (m, SemanticClassificationType.ValueType) else Some (m, SemanticClassificationType.ReferenceType) + | CNR(_, Item.ExnCase _, LegitTypeOccurence, _, _, _, m) -> + Some (m, SemanticClassificationType.ReferenceType) | CNR(_, Item.ModuleOrNamespaces refs, LegitTypeOccurence, _, _, _, m) when refs |> List.exists (fun x -> x.IsModule) -> Some (m, SemanticClassificationType.Module) | CNR(_, (Item.ActivePatternCase _ | Item.UnionCase _ | Item.ActivePatternResult _), _, _, _, _, m) -> @@ -1639,13 +1335,30 @@ type TypeCheckInfo | _ -> None) |> Seq.toArray |> Array.append (sSymbolUses.GetFormatSpecifierLocationsAndArity() |> Array.map (fun m -> fst m, SemanticClassificationType.Printf)) + ) + (fun msg -> + Trace.TraceInformation(sprintf "FCS: recovering from error in GetSemanticClassification: '%s'" msg) + Array.empty) + + /// The resolutions in the file + member __.ScopeResolutions = sResolutions + + /// The uses of symbols in the analyzed file + member __.ScopeSymbolUses = sSymbolUses + + member __.TcGlobals = g + + member __.TcImports = tcImports + + /// The inferred signature of the file + member __.CcuSig = ccuSig + + /// The assembly being analyzed + member __.ThisCcu = thisCcu + + override __.ToString() = "TypeCheckInfo(" + mainInputFileName + ")" + - member x.ScopeResolutions = sResolutions - member x.ScopeSymbolUses = sSymbolUses - member x.TcGlobals = g - member x.TcImports = tcImports - member x.CcuSig = ccuSig - member x.ThisCcu = thisCcu module internal Parser = @@ -1657,27 +1370,6 @@ module internal Parser = let lastLineLength = source.Length - source.LastIndexOf("\n",StringComparison.Ordinal) - 1 lastLine, lastLineLength - let ReportError (tcConfig:TcConfig, allErrors, mainInputFileName, fileInfo, (exn, sev)) = - [ let isError = (sev = FSharpErrorSeverity.Error) || ReportWarningAsError (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn, tcConfig.specificWarnAsError, tcConfig.specificWarnAsWarn, tcConfig.globalWarnAsError) exn - if (isError || ReportWarning (tcConfig.globalWarnLevel, tcConfig.specificWarnOff, tcConfig.specificWarnOn) exn) then - let oneError trim exn = - [ // We use the first line of the file as a fallbackRange for reporting unexpected errors. - // Not ideal, but it's hard to see what else to do. - let fallbackRange = rangeN mainInputFileName 1 - let ei = FSharpErrorInfo.CreateFromExceptionAndAdjustEof (exn, isError, trim, fallbackRange, fileInfo) - if allErrors || (ei.FileName=mainInputFileName) || (ei.FileName=Microsoft.FSharp.Compiler.TcGlobals.DummyFileNameForRangesWithoutASpecificLocation) then - yield ei ] - - let mainError,relatedErrors = SplitRelatedDiagnostics exn - yield! oneError false mainError - for e in relatedErrors do - yield! oneError true e ] - - let CreateErrorInfos (tcConfig:TcConfig, allErrors, mainInputFileName, errors) = - let fileInfo = (Int32.MaxValue, Int32.MaxValue) - [| for (exn,isError) in errors do - yield! ReportError (tcConfig, allErrors, mainInputFileName, fileInfo, (exn, isError)) |] - /// Error handler for parsing & type checking while processing a single file type ErrorHandler(reportErrors, mainInputFileName, tcConfig: TcConfig, source: string) = @@ -1695,12 +1387,12 @@ module internal Parser = if not(exn.IsPhaseInCompile()) then // Reaching this point means that the error would be sticky if we let it prop up to the language service. // Assert and recover by replacing phase with one known to the language service. - System.Diagnostics.Debug.Assert(false, sprintf "The subcategory '%s' seen in an error should not be seen by the language service" (exn.Subcategory())) + Trace.TraceInformation(sprintf "The subcategory '%s' seen in an error should not be seen by the language service" (exn.Subcategory())) {exn with Phase=BuildPhase.TypeCheck} else exn if reportErrors then let report exn = - for ei in ReportError (tcConfig, false, mainInputFileName, fileInfo, (exn, sev)) do + for ei in ErrorHelpers.ReportError (tcConfig, false, mainInputFileName, fileInfo, (exn, sev)) do errorsAndWarningsCollector.Add ei if sev = FSharpErrorSeverity.Error then errorCount <- errorCount + 1 @@ -1742,6 +1434,8 @@ module internal Parser = // Initialize the error handler let errHandler = new ErrorHandler(reportErrors, mainInputFileName, tcConfig, source) + // Adding this new-line character at the end of the source seems odd but is required for some unit tests + let source = if source.Length = 0 || not (source.[source.Length - 1] = '\n') then source + "\n" else source let lexbuf = UnicodeLexing.StringAsLexbuf source // Collector for parens matching @@ -1770,6 +1464,10 @@ module internal Parser = lexResourceManager, ref [], errHandler.ErrorLogger) + + // When analyzing files using ParseOneFile, i.e. for the use of editing clients, we do not apply line directives. + let lexargs = { lexargs with applyLineDirectives=false } + Lexhelp.usingLexbufForParsing (lexbuf, mainInputFileName) (fun lexbuf -> try let skip = true @@ -1826,7 +1524,7 @@ module internal Parser = type TypeCheckAborted = Yes | No of TypeCheckInfo // Type check a single file against an initial context, gleaning both errors and intellisense information. - let TypeCheckOneFile + let CheckOneFile (parseResults: FSharpParseFileResults, source: string, mainInputFileName: string, @@ -1841,7 +1539,8 @@ module internal Parser = reactorOps: IReactorOperations, // Used by 'FSharpDeclarationListInfo' to check the IncrementalBuilder is still alive. checkAlive : (unit -> bool), - textSnapshotInfo : obj option) = + textSnapshotInfo : obj option, + userOpName: string) = async { match parseResults.ParseTree with @@ -1943,7 +1642,7 @@ module internal Parser = |> Eventually.repeatedlyProgressUntilDoneOrTimeShareOverOrCanceled maxTimeShareMilliseconds ct (fun ctok f -> f ctok) |> Eventually.forceAsync (fun work -> - reactorOps.EnqueueAndAwaitOpAsync("TypeCheckOneFile", + reactorOps.EnqueueAndAwaitOpAsync(userOpName, "CheckOneFile.Fragment", mainInputFileName, fun ctok -> // This work is not cancellable let res = @@ -1985,13 +1684,13 @@ module internal Parser = return errors, TypeCheckAborted.Yes } -type UnresolvedReferencesSet = UnresolvedReferencesSet of UnresolvedAssemblyReference list +type UnresolvedReferencesSet = UnresolvedReferencesSet of UnresolvedAssemblyReference list // NOTE: may be better just to move to optional arguments here type FSharpProjectOptions = { ProjectFileName: string - ProjectFileNames: string[] + SourceFiles: string[] OtherOptions: string[] ReferencedProjects: (string * FSharpProjectOptions)[] IsIncompleteTypeCheckEnvironment : bool @@ -2000,22 +1699,29 @@ type FSharpProjectOptions = UnresolvedReferences : UnresolvedReferencesSet option OriginalLoadReferences: (range * string) list ExtraProjectInfo : obj option + Stamp : int64 option } member x.ProjectOptions = x.OtherOptions /// Whether the two parse options refer to the same project. - static member AreSubsumable(options1,options2) = + static member UseSameProjectFileName(options1,options2) = options1.ProjectFileName = options2.ProjectFileName /// Compare two options sets with respect to the parts of the options that are important to parsing. static member AreSameForParsing(options1,options2) = + match options1.Stamp, options2.Stamp with + | Some x, Some y -> (x = y) + | _ -> options1.ProjectFileName = options2.ProjectFileName && options1.OtherOptions = options2.OtherOptions && options1.UnresolvedReferences = options2.UnresolvedReferences /// Compare two options sets with respect to the parts of the options that are important to building. static member AreSameForChecking(options1,options2) = + match options1.Stamp, options2.Stamp with + | Some x, Some y -> (x = y) + | _ -> options1.ProjectFileName = options2.ProjectFileName && - options1.ProjectFileNames = options2.ProjectFileNames && + options1.SourceFiles = options2.SourceFiles && options1.OtherOptions = options2.OtherOptions && options1.UnresolvedReferences = options2.UnresolvedReferences && options1.OriginalLoadReferences = options2.OriginalLoadReferences && @@ -2025,16 +1731,7 @@ type FSharpProjectOptions = /// Compute the project directory. member po.ProjectDirectory = System.IO.Path.GetDirectoryName(po.ProjectFileName) - override this.ToString() = - let files = - let sb = new StringBuilder() - this.ProjectFileNames |> Array.iter (fun file -> sb.AppendFormat(" {0}\n", file) |> ignore) - sb.ToString() - let options = - let sb = new StringBuilder() - this.OtherOptions |> Array.iter (fun op -> sb.AppendFormat("{0} ", op) |> ignore) - sb.ToString() - sprintf "OtherOptions(%s)\n Files:\n%s Options: %s" this.ProjectFileName files options + override this.ToString() = "FSharpProjectOptions(" + this.ProjectFileName + ")" [] @@ -2048,7 +1745,7 @@ type FSharpProjectContext(thisCcu: CcuThunk, assemblies: FSharpAssembly list, ad [] // 'details' is an option because the creation of the tcGlobals etc. for the project may have failed. -type FSharpCheckProjectResults(keepAssemblyContents, errors: FSharpErrorInfo[], details:(TcGlobals*TcImports*CcuThunk*ModuleOrNamespaceType*TcSymbolUses list*TopAttribs option*CompileOps.IRawFSharpAssemblyData option * ILAssemblyRef * AccessorDomain * TypedImplFile list option * string list) option, reactorOps: IReactorOperations) = +type FSharpCheckProjectResults(projectFileName:string, keepAssemblyContents, errors: FSharpErrorInfo[], details:(TcGlobals*TcImports*CcuThunk*ModuleOrNamespaceType*TcSymbolUses list*TopAttribs option*CompileOps.IRawFSharpAssemblyData option * ILAssemblyRef * AccessorDomain * TypedImplFile list option * string list) option, _reactorOps: IReactorOperations) = let getDetails() = match details with @@ -2075,30 +1772,24 @@ type FSharpCheckProjectResults(keepAssemblyContents, errors: FSharpErrorInfo[], // Not, this does not have to be a SyncOp, it can be called from any thread member info.GetUsesOfSymbol(symbol:FSharpSymbol) = let (tcGlobals, _tcImports, _thisCcu, _ccuSig, tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() - // This probably doesn't need to be run on the reactor since all data touched by GetUsesOfSymbol is immutable. - reactorOps.EnqueueAndAwaitOpAsync("GetUsesOfSymbol", fun ctok -> - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok - - [| for r in tcSymbolUses do yield! r.GetUsesOfSymbol(symbol.Item) |] - |> Seq.distinctBy (fun (itemOcc,_denv,m) -> itemOcc, m) - |> Seq.filter (fun (itemOcc,_,_) -> itemOcc <> ItemOccurence.RelatedText) - |> Seq.map (fun (itemOcc,denv,m) -> FSharpSymbolUse(tcGlobals, denv, symbol, itemOcc, m)) - |> Seq.toArray - |> cancellable.Return) + + [| for r in tcSymbolUses do yield! r.GetUsesOfSymbol(symbol.Item) |] + |> Seq.distinctBy (fun (itemOcc,_denv,m) -> itemOcc, m) + |> Seq.filter (fun (itemOcc,_,_) -> itemOcc <> ItemOccurence.RelatedText) + |> Seq.map (fun (itemOcc,denv,m) -> FSharpSymbolUse(tcGlobals, denv, symbol, itemOcc, m)) + |> Seq.toArray + |> async.Return // Not, this does not have to be a SyncOp, it can be called from any thread member info.GetAllUsesOfAllSymbols() = let (tcGlobals, tcImports, thisCcu, _ccuSig, tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() - // This probably doesn't need to be run on the reactor since all data touched by GetAllUsesOfSymbols is immutable. - reactorOps.EnqueueAndAwaitOpAsync("GetAllUsesOfAllSymbols", fun ctok -> - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok - [| for r in tcSymbolUses do - for (item,itemOcc,denv,m) in r.GetAllUsesOfSymbols() do - if itemOcc <> ItemOccurence.RelatedText then - let symbol = FSharpSymbol.Create(tcGlobals, thisCcu, tcImports, item) - yield FSharpSymbolUse(tcGlobals, denv, symbol, itemOcc, m) |] - |> cancellable.Return) + [| for r in tcSymbolUses do + for (item,itemOcc,denv,m) in r.GetAllUsesOfSymbols() do + if itemOcc <> ItemOccurence.RelatedText then + let symbol = FSharpSymbol.Create(tcGlobals, thisCcu, tcImports, item) + yield FSharpSymbolUse(tcGlobals, denv, symbol, itemOcc, m) |] + |> async.Return member info.ProjectContext = let (tcGlobals, tcImports, thisCcu, _ccuSig, _tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() @@ -2119,22 +1810,23 @@ type FSharpCheckProjectResults(keepAssemblyContents, errors: FSharpErrorInfo[], let (_tcGlobals, _tcImports, _thisCcu, _ccuSig, _tcSymbolUses, _topAttribs, _tcAssemblyData, ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() ilAssemRef.QualifiedName + override info.ToString() = "FSharpCheckProjectResults(" + projectFileName + ")" + [] /// A live object of this type keeps the background corresponding background builder (and type providers) alive (through reference-counting). // // There is an important property of all the objects returned by the methods of this type: they do not require // the corresponding background builder to be alive. That is, they are simply plain-old-data through pre-formatting of all result text. -type FSharpCheckFileResults(errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo option, dependencyFiles: string list, builderX: IncrementalBuilder option, reactorOpsX:IReactorOperations) = +type FSharpCheckFileResults(filename: string, errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo option, dependencyFiles: string list, builderX: IncrementalBuilder option, reactorOpsX:IReactorOperations) = // This may be None initially, or may be set to None when the object is disposed or finalized let mutable details = match scopeOptX with None -> None | Some scopeX -> Some (scopeX, builderX, reactorOpsX) + // Increment the usage count on the IncrementalBuilder. We want to keep the IncrementalBuilder and all associated + // resources and type providers alive for the duration of the lifetime of this object. let decrementer = match details with - | Some (_,Some builder,_) -> - // Increment the usage count on the IncrementalBuilder. We want to keep the IncrementalBuilder and all associated - // resources and type providers alive for the duration of the lifetime of this object. - builder.IncrementUsageCount() + | Some (_,builderOpt,_) -> IncrementalBuilder.KeepBuilderAlive builderOpt | _ -> { new System.IDisposable with member x.Dispose() = () } let mutable disposed = false @@ -2146,37 +1838,32 @@ type FSharpCheckFileResults(errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo | Some (_,_,reactor) -> // Make sure we run disposal in the reactor thread, since it may trigger type provider disposals etc. details <- None - reactor.EnqueueOp ("Dispose", fun ctok -> + reactor.EnqueueOp ("GCFinalizer","FSharpCheckFileResults.DecrementUsageCountOnIncrementalBuilder", filename, fun ctok -> RequireCompilationThread ctok decrementer.Dispose()) | _ -> () - // Run an operation that needs to be run in the reactor thread - let reactorOp desc dflt f = + // Run an operation that needs to access a builder and be run in the reactor thread + let reactorOp userOpName opName dflt f = async { match details with | None -> return dflt - | Some (_ , Some builder, _) when not builder.IsAlive -> + | Some (_, Some builder, _) when not builder.IsAlive -> System.Diagnostics.Debug.Assert(false,"unexpected dead builder") return dflt | Some (scope, builderOpt, reactor) -> - // Ensure the builder doesn't get released while running operations asynchronously. - use _unwind = match builderOpt with Some builder -> builder.IncrementUsageCount() | None -> { new System.IDisposable with member __.Dispose() = () } - let! res = reactor.EnqueueAndAwaitOpAsync(desc, fun ctok -> f ctok scope |> cancellable.Return) + // Increment the usage count to ensure the builder doesn't get released while running operations asynchronously. + use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! res = reactor.EnqueueAndAwaitOpAsync(userOpName, opName, filename, fun ctok -> f ctok scope |> cancellable.Return) return res } // Run an operation that can be called from any thread let threadSafeOp dflt f = match details with - | None -> - dflt() - | Some (_ , Some builder, _) when not builder.IsAlive -> - System.Diagnostics.Debug.Assert(false,"unexpected dead builder") - dflt() - | Some (scope, builderOpt, ops) -> - f(scope, builderOpt, ops) + | None -> dflt() + | Some (scope, _builderOpt, _ops) -> f scope // At the moment we only dispose on finalize - we never explicitly dispose these objects. Explicitly disposing is not // really worth much since the underlying project builds are likely to still be in the incrementalBuilder cache. @@ -2187,58 +1874,67 @@ type FSharpCheckFileResults(errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo member info.HasFullTypeCheckInfo = details.IsSome /// Intellisense autocompletions - member info.GetDeclarationListInfo(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, getAllEntities, ?hasTextChangedSinceLastTypecheck) = + member info.GetDeclarationListInfo(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, getAllEntities, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) - reactorOp "GetDeclarations" FSharpDeclarationListInfo.Empty (fun ctok scope -> + reactorOp userOpName "GetDeclarations" FSharpDeclarationListInfo.Empty (fun ctok scope -> scope.GetDeclarations(ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, getAllEntities, hasTextChangedSinceLastTypecheck)) - member info.GetDeclarationListSymbols(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, ?hasTextChangedSinceLastTypecheck) = + member info.GetDeclarationListSymbols(parseResultsOpt, line, colAtEndOfNamesAndResidue, lineStr, qualifyingNames, partialName, ?hasTextChangedSinceLastTypecheck, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" let hasTextChangedSinceLastTypecheck = defaultArg hasTextChangedSinceLastTypecheck (fun _ -> false) - reactorOp "GetDeclarationListSymbols" List.empty (fun ctok scope -> scope.GetDeclarationListSymbols(ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck)) + reactorOp userOpName "GetDeclarationListSymbols" List.empty (fun ctok scope -> scope.GetDeclarationListSymbols(ctok, parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck)) /// Resolve the names at the given location to give a data tip - member info.GetStructuredToolTipTextAlternate(line, colAtEndOfNames, lineStr, names, tokenTag) = + member info.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" let dflt = FSharpToolTipText [] match tokenTagToTokenId tokenTag with | TOKEN_IDENT -> - reactorOp "GetToolTipText" dflt (fun ctok scope -> scope.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names)) + reactorOp userOpName "GetStructuredToolTipText" dflt (fun ctok scope -> scope.GetStructuredToolTipText(ctok, line, lineStr, colAtEndOfNames, names)) | TOKEN_STRING | TOKEN_STRING_TEXT -> - reactorOp "GetReferenceResolutionToolTipText" dflt (fun ctok scope -> scope.GetReferenceResolutionStructuredToolTipText(ctok, line, colAtEndOfNames) ) + reactorOp userOpName "GetReferenceResolutionToolTipText" dflt (fun ctok scope -> scope.GetReferenceResolutionStructuredToolTipText(ctok, line, colAtEndOfNames) ) | _ -> async.Return dflt - member info.GetToolTipTextAlternate(line, colAtEndOfNames, lineStr, names, tokenTag) = - info.GetStructuredToolTipTextAlternate(line, colAtEndOfNames, lineStr, names, tokenTag) + member info.GetToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, userOpName) = + info.GetStructuredToolTipText(line, colAtEndOfNames, lineStr, names, tokenTag, ?userOpName=userOpName) |> Tooltips.Map Tooltips.ToFSharpToolTipText - member info.GetF1KeywordAlternate (line, colAtEndOfNames, lineStr, names) = - reactorOp "GetF1Keyword" None (fun ctok scope -> + member info.GetF1Keyword (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + reactorOp userOpName "GetF1Keyword" None (fun ctok scope -> scope.GetF1Keyword (ctok, line, lineStr, colAtEndOfNames, names)) // Resolve the names at the given location to a set of methods - member info.GetMethodsAlternate(line, colAtEndOfNames, lineStr, names) = + member info.GetMethods(line, colAtEndOfNames, lineStr, names, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" let dflt = FSharpMethodGroup("",[| |]) - reactorOp "GetMethods" dflt (fun ctok scope -> + reactorOp userOpName "GetMethods" dflt (fun ctok scope -> scope.GetMethods (ctok, line, lineStr, colAtEndOfNames, names)) - member info.GetDeclarationLocationAlternate (line, colAtEndOfNames, lineStr, names, ?preferFlag) = - let dflt = FSharpFindDeclResult.DeclNotFound FSharpFindDeclFailureReason.Unknown - reactorOp "GetDeclarationLocation" dflt (fun ctok scope -> + member info.GetDeclarationLocation (line, colAtEndOfNames, lineStr, names, ?preferFlag, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + let dflt = FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "") + reactorOp userOpName "GetDeclarationLocation" dflt (fun ctok scope -> scope.GetDeclarationLocation (ctok, line, lineStr, colAtEndOfNames, names, preferFlag)) - member info.GetSymbolUseAtLocation (line, colAtEndOfNames, lineStr, names) = - reactorOp "GetSymbolUseAtLocation" None (fun ctok scope -> + member info.GetSymbolUseAtLocation (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + reactorOp userOpName "GetSymbolUseAtLocation" None (fun ctok scope -> scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) |> Option.map (fun (sym,denv,m) -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m))) - member info.GetMethodsAsSymbols (line, colAtEndOfNames, lineStr, names) = - reactorOp "GetMethodsAsSymbols" None (fun ctok scope -> + member info.GetMethodsAsSymbols (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + reactorOp userOpName "GetMethodsAsSymbols" None (fun ctok scope -> scope.GetMethodsAsSymbols (ctok, line, lineStr, colAtEndOfNames, names) |> Option.map (fun (symbols,denv,m) -> symbols |> List.map (fun sym -> FSharpSymbolUse(scope.TcGlobals,denv,sym,ItemOccurence.Use,m)))) - member info.GetSymbolAtLocationAlternate (line, colAtEndOfNames, lineStr, names) = - reactorOp "GetSymbolUseAtLocation" None (fun ctok scope -> + member info.GetSymbolAtLocation (line, colAtEndOfNames, lineStr, names, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + reactorOp userOpName "GetSymbolAtLocation" None (fun ctok scope -> scope.GetSymbolUseAtLocation (ctok, line, lineStr, colAtEndOfNames, names) |> Option.map (fun (sym,_,_) -> sym)) @@ -2248,61 +1944,67 @@ type FSharpCheckFileResults(errors: FSharpErrorInfo[], scopeOptX: TypeCheckInfo member info.GetFormatSpecifierLocationsAndArity() = threadSafeOp (fun () -> [| |]) - (fun (scope, _builder, _reactor) -> + (fun scope -> // This operation is not asynchronous - GetFormatSpecifierLocationsAndArity can be run on the calling thread scope.GetFormatSpecifierLocationsAndArity()) member info.GetSemanticClassification(range: range option) = threadSafeOp (fun () -> [| |]) - (fun (scope, _builder, _reactor) -> - // This operation is not asynchronous - GetExtraColorizations can be run on the calling thread + (fun scope -> + // This operation is not asynchronous - GetSemanticClassification can be run on the calling thread scope.GetSemanticClassification(range)) member info.PartialAssemblySignature = threadSafeOp (fun () -> failwith "not available") - (fun (scope, _builder, _reactor) -> + (fun scope -> // This operation is not asynchronous - PartialAssemblySignature can be run on the calling thread scope.PartialAssemblySignature()) member info.ProjectContext = threadSafeOp (fun () -> failwith "not available") - (fun (scope, _builder, _reactor) -> + (fun scope -> // This operation is not asynchronous - GetReferencedAssemblies can be run on the calling thread FSharpProjectContext(scope.ThisCcu, scope.GetReferencedAssemblies(), scope.AccessRights)) member info.DependencyFiles = dependencyFiles member info.GetAllUsesOfAllSymbolsInFile() = - reactorOp "GetAllUsesOfAllSymbolsInFile" [| |] (fun ctok scope -> - - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok - - [| for (item,itemOcc,denv,m) in scope.ScopeSymbolUses.GetAllUsesOfSymbols() do - if itemOcc <> ItemOccurence.RelatedText then - let symbol = FSharpSymbol.Create(scope.TcGlobals, scope.ThisCcu, scope.TcImports, item) - yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |]) + threadSafeOp + (fun () -> [| |]) + (fun scope -> + [| for (item,itemOcc,denv,m) in scope.ScopeSymbolUses.GetAllUsesOfSymbols() do + if itemOcc <> ItemOccurence.RelatedText then + let symbol = FSharpSymbol.Create(scope.TcGlobals, scope.ThisCcu, scope.TcImports, item) + yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |]) + |> async.Return member info.GetUsesOfSymbolInFile(symbol:FSharpSymbol) = - reactorOp "GetUsesOfSymbolInFile" [| |] (fun ctok scope -> - - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok - - [| for (itemOcc,denv,m) in scope.ScopeSymbolUses.GetUsesOfSymbol(symbol.Item) |> Seq.distinctBy (fun (itemOcc,_denv,m) -> itemOcc, m) do - if itemOcc <> ItemOccurence.RelatedText then - yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |]) - - member info.GetVisibleNamespacesAndModulesAtPoint(pos: pos) : Async = - reactorOp "GetVisibleNamespacesAndModulesAtPoint" [| |] (fun _ctok scope -> scope.GetVisibleNamespacesAndModulesAtPosition(pos) |> List.toArray) - - member info.IsRelativeNameResolvable(pos: pos, plid: string list, item: Item) : Async = - reactorOp "IsRelativeNameResolvable" true (fun ctok scope -> - DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok + threadSafeOp + (fun () -> [| |]) + (fun scope -> + [| for (itemOcc,denv,m) in scope.ScopeSymbolUses.GetUsesOfSymbol(symbol.Item) |> Seq.distinctBy (fun (itemOcc,_denv,m) -> itemOcc, m) do + if itemOcc <> ItemOccurence.RelatedText then + yield FSharpSymbolUse(scope.TcGlobals, denv, symbol, itemOcc, m) |]) + |> async.Return + + member info.GetVisibleNamespacesAndModulesAtPoint(pos: pos) = + threadSafeOp + (fun () -> [| |]) + (fun scope -> scope.GetVisibleNamespacesAndModulesAtPosition(pos) |> List.toArray) + |> async.Return + + member info.IsRelativeNameResolvable(pos: pos, plid: string list, item: Item, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + reactorOp userOpName "IsRelativeNameResolvable" true (fun ctok scope -> + RequireCompilationThread ctok scope.IsRelativeNameResolvable(pos, plid, item)) + override info.ToString() = "FSharpCheckFileResults(" + filename + ")" + //---------------------------------------------------------------------------- // BackgroundCompiler // @@ -2315,12 +2017,15 @@ type FSharpCheckFileAnswer = /// Callback that indicates whether a requested result has become obsolete. [] -type (*internal*) IsResultObsolete = +type IsResultObsolete = | IsResultObsolete of (unit->bool) [] module Helpers = + + // Look for DLLs in the location of the service DLL first. + let defaultFSharpBinariesDir = FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(Some(typeof.Assembly.Location)).Value /// Determine whether two (fileName,options) keys are identical w.r.t. affect on checking let AreSameForChecking2((fileName1: string, options1: FSharpProjectOptions), (fileName2, o2)) = @@ -2330,7 +2035,7 @@ module Helpers = /// Determine whether two (fileName,options) keys should be identical w.r.t. resource usage let AreSubsumable2((fileName1:string,o1:FSharpProjectOptions),(fileName2:string,o2:FSharpProjectOptions)) = (fileName1 = fileName2) - && FSharpProjectOptions.AreSubsumable(o1,o2) + && FSharpProjectOptions.UseSameProjectFileName(o1,o2) /// Determine whether two (fileName,sourceText,options) keys should be identical w.r.t. parsing let AreSameForParsing3((fileName1: string, source1: string, options1: FSharpProjectOptions), (fileName2, source2, options2)) = @@ -2347,7 +2052,7 @@ module Helpers = /// Determine whether two (fileName,sourceText,options) keys should be identical w.r.t. resource usage let AreSubsumable3((fileName1:string,_,o1:FSharpProjectOptions),(fileName2:string,_,o2:FSharpProjectOptions)) = (fileName1 = fileName2) - && FSharpProjectOptions.AreSubsumable(o1,o2) + && FSharpProjectOptions.UseSameProjectFileName(o1,o2) module CompileHelpers = let mkCompilationErorHandlers() = @@ -2381,16 +2086,16 @@ module CompileHelpers = 1 /// Compile using the given flags. Source files names are resolved via the FileSystem API. The output file must be given by a -o flag. - let compileFromArgs (ctok, argv: string[], referenceResolver, tcImportsCapture, dynamicAssemblyCreator) = + let compileFromArgs (ctok, argv: string[], legacyReferenceResolver, tcImportsCapture, dynamicAssemblyCreator) = let errors, errorLogger, loggerProvider = mkCompilationErorHandlers() let result = tryCompile errorLogger (fun exiter -> - mainCompile (ctok, argv, referenceResolver, (*bannerAlreadyPrinted*)true, (*openBinariesInMemory*)true, exiter, loggerProvider, tcImportsCapture, dynamicAssemblyCreator) ) + mainCompile (ctok, argv, legacyReferenceResolver, (*bannerAlreadyPrinted*)true, (*openBinariesInMemory*)true, (*defaultCopyFSharpCore*)false, exiter, loggerProvider, tcImportsCapture, dynamicAssemblyCreator) ) errors.ToArray(), result - let compileFromAsts (ctok, referenceResolver, asts, assemblyName, outFile, dependencies, noframework, pdbFile, executable, tcImportsCapture, dynamicAssemblyCreator) = + let compileFromAsts (ctok, legacyReferenceResolver, asts, assemblyName, outFile, dependencies, noframework, pdbFile, executable, tcImportsCapture, dynamicAssemblyCreator) = let errors, errorLogger, loggerProvider = mkCompilationErorHandlers() @@ -2399,7 +2104,7 @@ module CompileHelpers = let result = tryCompile errorLogger (fun exiter -> - compileOfAst (ctok, referenceResolver, (*openBinariesInMemory=*)true, assemblyName, target, outFile, pdbFile, dependencies, noframework, exiter, loggerProvider, asts, tcImportsCapture, dynamicAssemblyCreator)) + compileOfAst (ctok, legacyReferenceResolver, (*openBinariesInMemory=*)true, assemblyName, target, outFile, pdbFile, dependencies, noframework, exiter, loggerProvider, asts, tcImportsCapture, dynamicAssemblyCreator)) errors.ToArray(), result @@ -2438,7 +2143,9 @@ module CompileHelpers = for exec in execs do match exec() with | None -> () - | Some exn -> raise exn + | Some exn -> + PreserveStackTrace(exn) + raise exn // Register the reflected definitions for the dynamically generated assembly for resource in ilxMainModule.Resources.AsList do @@ -2466,8 +2173,9 @@ type FileVersion = int type ParseCacheLockToken() = interface LockToken type ScriptClosureCacheToken() = interface LockToken + // There is only one instance of this type, held in FSharpChecker -type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) as self = +type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) as self = // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.backgroundCompiler.reactor: The one and only Reactor let reactor = Reactor.Singleton let beforeFileChecked = Event() @@ -2475,43 +2183,53 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent let fileChecked = Event() let projectChecked = Event() + let mutable implicitlyStartBackgroundWork = true let reactorOps = { new IReactorOperations with - member __.EnqueueAndAwaitOpAsync (desc, op) = reactor.EnqueueAndAwaitOpAsync (desc, op) - member __.EnqueueOp (desc, op) = reactor.EnqueueOp (desc, op) } + member __.EnqueueAndAwaitOpAsync (userOpName, opName, opArg, op) = reactor.EnqueueAndAwaitOpAsync (userOpName, opName, opArg, op) + member __.EnqueueOp (userOpName, opName, opArg, op) = reactor.EnqueueOp (userOpName, opName, opArg, op) } // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.backgroundCompiler.scriptClosureCache /// Information about the derived script closure. let scriptClosureCache = MruCache(projectCacheSize, areSame=FSharpProjectOptions.AreSameForChecking, - areSameForSubsumption=FSharpProjectOptions.AreSubsumable) + areSimilar=FSharpProjectOptions.UseSameProjectFileName) let scriptClosureCacheLock = Lock() let frameworkTcImportsCache = FrameworkImportsCache(frameworkTcImportsCacheStrongSize) /// CreateOneIncrementalBuilder (for background type checking). Note that fsc.fs also /// creates an incremental builder used by the command line compiler. - let CreateOneIncrementalBuilder (ctok, options:FSharpProjectOptions) = + let CreateOneIncrementalBuilder (ctok, options:FSharpProjectOptions, userOpName) = cancellable { - + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "CreateOneIncrementalBuilder", options.ProjectFileName) let projectReferences = - [ for (nm,opts) in options.ReferencedProjects -> - { new IProjectReference with + [ for (nm,opts) in options.ReferencedProjects do + + // Don't use cross-project references for FSharp.Core, since various bits of code require a concrete FSharp.Core to exist on-disk. + // The only solutions that have these cross-project references to FSharp.Core are VisualFSharp.sln and FSharp.sln. The only ramification + // of this is that you need to build FSharp.Core to get intellisense in those projects. + + if (try Path.GetFileNameWithoutExtension(nm) with _ -> "") <> GetFSharpCoreLibraryName() then + + yield + { new IProjectReference with member x.EvaluateRawContents(ctok) = cancellable { - let! r = self.ParseAndCheckProjectImpl(opts, ctok) + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "ParseAndCheckProjectImpl", nm) + let! r = self.ParseAndCheckProjectImpl(opts, ctok, userOpName + ".CheckReferencedProject("+nm+")") return r.RawFSharpAssemblyData } member x.TryGetLogicalTimeStamp(cache, ctok) = - self.TryGetLogicalTimeStampForProject(cache, ctok, opts) + self.TryGetLogicalTimeStampForProject(cache, ctok, opts, userOpName + ".TimeStampReferencedProject("+nm+")") member x.FileName = nm } ] let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options)) let! builderOpt, diagnostics = IncrementalBuilder.TryCreateBackgroundBuilderForProjectOptions - (ctok, referenceResolver, frameworkTcImportsCache, loadClosure, Array.toList options.ProjectFileNames, + (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, frameworkTcImportsCache, loadClosure, Array.toList options.SourceFiles, Array.toList options.OtherOptions, projectReferences, options.ProjectDirectory, options.UseScriptResolutionRules, keepAssemblyContents, keepAllBackgroundResolutions, maxTimeShareMilliseconds) @@ -2525,7 +2243,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent // Register the behaviour that responds to CCUs being invalidated because of type // provider Invalidate events. This invalidates the configuration in the build. builder.ImportedCcusInvalidated.Add (fun _ -> - self.InvalidateConfiguration options) + self.InvalidateConfiguration(options, None, userOpName)) // Register the callback called just before a file is typechecked by the background builder (without recording // errors or intellisense information). @@ -2549,19 +2267,22 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent MruCache (keepStrongly=projectCacheSize, keepMax=projectCacheSize, areSame = FSharpProjectOptions.AreSameForChecking, - areSameForSubsumption = FSharpProjectOptions.AreSubsumable, + areSimilar = FSharpProjectOptions.UseSameProjectFileName, requiredToKeep=(fun (builderOpt,_,_) -> match builderOpt with None -> false | Some (b:IncrementalBuilder) -> b.IsBeingKeptAliveApartFromCacheEntry), onDiscard = (fun (_, _, decrement:IDisposable) -> decrement.Dispose())) - let getOrCreateBuilder (ctok, options) = + let getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) = cancellable { - RequireCompilationThread ctok - match incrementalBuildersCache.TryGet (ctok, options) with - | Some b -> return b - | None -> - let! b = CreateOneIncrementalBuilder (ctok, options) - incrementalBuildersCache.Set (ctok, options, b) - return b + RequireCompilationThread ctok + match incrementalBuildersCache.TryGet (ctok, options) with + | Some (builderOpt,creationErrors,_) -> + let decrement = IncrementalBuilder.KeepBuilderAlive builderOpt + return builderOpt,creationErrors, decrement + | None -> + let! (builderOpt,creationErrors,_) as info = CreateOneIncrementalBuilder (ctok, options, userOpName) + incrementalBuildersCache.Set (ctok, options, info) + let decrement = IncrementalBuilder.KeepBuilderAlive builderOpt + return builderOpt, creationErrors, decrement } let parseCacheLock = Lock() @@ -2571,7 +2292,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent let parseFileInProjectCache = MruCache(parseFileInProjectCacheSize, areSame=AreSameForParsing3, - areSameForSubsumption=AreSubsumable3) + areSimilar=AreSubsumable3) // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.parseAndCheckFileInProjectCachePossiblyStale // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.parseAndCheckFileInProjectCache @@ -2585,14 +2306,14 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent MruCache (keepStrongly=incrementalTypeCheckCacheSize, areSame=AreSameForChecking2, - areSameForSubsumption=AreSubsumable2) + areSimilar=AreSubsumable2) // Also keyed on source. This can only be out of date if the antecedent is out of date let parseAndCheckFileInProjectCache = MruCache (keepStrongly=incrementalTypeCheckCacheSize, areSame=AreSameForChecking3, - areSameForSubsumption=AreSubsumable3) + areSimilar=AreSubsumable3) /// Holds keys for files being currently checked. It's used to prevent checking same file in parallel (interleaving chunck queued to Reactor). let beingCheckedFileTable = @@ -2604,10 +2325,10 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent static let mutable foregroundParseCount = 0 static let mutable foregroundTypeCheckCount = 0 - let MakeCheckFileResultsEmpty(creationErrors) = - FSharpCheckFileResults (Array.ofList creationErrors, None, [], None, reactorOps) + let MakeCheckFileResultsEmpty(filename, creationErrors) = + FSharpCheckFileResults (filename, Array.ofList creationErrors, None, [], None, reactorOps) - let MakeCheckFileResults(options:FSharpProjectOptions, builder, scope, dependencyFiles, creationErrors, parseErrors, tcErrors) = + let MakeCheckFileResults(filename, options:FSharpProjectOptions, builder, scope, dependencyFiles, creationErrors, parseErrors, tcErrors) = let errors = [| yield! creationErrors yield! parseErrors @@ -2616,12 +2337,12 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent else yield! tcErrors |] - FSharpCheckFileResults (errors, Some scope, dependencyFiles, Some builder, reactorOps) + FSharpCheckFileResults (filename, errors, Some scope, dependencyFiles, Some builder, reactorOps) - let MakeCheckFileAnswer(tcFileResult, options:FSharpProjectOptions, builder, dependencyFiles, creationErrors, parseErrors, tcErrors) = + let MakeCheckFileAnswer(filename, tcFileResult, options:FSharpProjectOptions, builder, dependencyFiles, creationErrors, parseErrors, tcErrors) = match tcFileResult with | Parser.TypeCheckAborted.Yes -> FSharpCheckFileAnswer.Aborted - | Parser.TypeCheckAborted.No scope -> FSharpCheckFileAnswer.Succeeded(MakeCheckFileResults(options, builder, scope, dependencyFiles, creationErrors, parseErrors, tcErrors)) + | Parser.TypeCheckAborted.No scope -> FSharpCheckFileAnswer.Succeeded(MakeCheckFileResults(filename, options, builder, scope, dependencyFiles, creationErrors, parseErrors, tcErrors)) member bc.RecordTypeCheckFileInProjectResults(filename,options,parseResults,fileVersion,priorTimeStamp,checkAnswer,source) = match checkAnswer with @@ -2634,12 +2355,12 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent parseAndCheckFileInProjectCache.Set(ltok, (filename,source,options),(parseResults,typedResults,fileVersion,priorTimeStamp)) parseFileInProjectCache.Set(ltok, (filename,source,options),parseResults)) - member bc.ImplicitlyStartCheckProjectInBackground(options) = + member bc.ImplicitlyStartCheckProjectInBackground(options, userOpName) = if implicitlyStartBackgroundWork then - bc.CheckProjectInBackground(options) + bc.CheckProjectInBackground(options, userOpName + ".ImplicitlyStartCheckProjectInBackground") /// Parses the source file and returns untyped AST - member bc.ParseFileInProject(filename:string, source,options:FSharpProjectOptions) = + member bc.ParseFileInProject(filename:string, source,options:FSharpProjectOptions, userOpName) = match parseCacheLock.AcquireLock (fun ctok -> parseFileInProjectCache.TryGet (ctok, (filename, source, options))) with | Some parseResults -> async.Return parseResults | None -> @@ -2648,7 +2369,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent match cachedResults with | Some (parseResults, _checkResults,_,_) -> async.Return parseResults | _ -> - reactor.EnqueueAndAwaitOpAsync("ParseFileInProject " + filename, fun ctok -> + reactor.EnqueueAndAwaitOpAsync(userOpName, "ParseFileInProject", filename, fun ctok -> cancellable { // Try the caches again - it may have been filled by the time this operation runs match parseCacheLock.AcquireLock (fun ctok -> parseFileInProjectCache.TryGet (ctok, (filename, source, options))) with @@ -2658,15 +2379,16 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent match cachedResults with | Some (parseResults, _checkResults,_,_) -> return parseResults | _ -> + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "ParseFileInProject.CacheMiss", filename) foregroundParseCount <- foregroundParseCount + 1 - let! builderOpt,creationErrors,_ = getOrCreateBuilder (ctok, options) - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! builderOpt,creationErrors,decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + use _unwind = decrement match builderOpt with | None -> return FSharpParseFileResults(List.toArray creationErrors, None, true, []) | Some builder -> // Do the parsing. let parseErrors, _matchPairs, inputOpt, anyErrors = - Parser.ParseOneFile (ctok, source, false, true, filename, builder.ProjectFileNames, builder.TcConfig) + Parser.ParseOneFile (ctok, source, false, true, filename, builder.SourceFiles, builder.TcConfig) let res = FSharpParseFileResults(parseErrors, inputOpt, anyErrors, builder.AllDependenciesDeprecated ) parseCacheLock.AcquireLock (fun ctok -> parseFileInProjectCache.Set (ctok, (filename, source, options), res)) @@ -2675,30 +2397,30 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent ) /// Fetch the parse information from the background compiler (which checks w.r.t. the FileSystem API) - member bc.GetBackgroundParseResultsForFileInProject(filename, options) = - reactor.EnqueueAndAwaitOpAsync("GetBackgroundParseResultsForFileInProject " + filename, fun ctok -> + member bc.GetBackgroundParseResultsForFileInProject(filename, options, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "GetBackgroundParseResultsForFileInProject ", filename, fun ctok -> cancellable { - let! builderOpt, creationErrors, _ = getOrCreateBuilder (ctok, options) - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! builderOpt, creationErrors, decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + use _unwind = decrement match builderOpt with | None -> return FSharpParseFileResults(List.toArray creationErrors, None, true, []) | Some builder -> let! inputOpt,_,_,parseErrors = builder.GetParseResultsForFile (ctok, filename) - let errors = [| yield! creationErrors; yield! Parser.CreateErrorInfos (builder.TcConfig, false, filename, parseErrors) |] + let errors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (builder.TcConfig, false, filename, parseErrors) |] return FSharpParseFileResults(errors = errors, input = inputOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated) } ) - member bc.MatchBraces(filename:string, source, options)= - reactor.EnqueueAndAwaitOpAsync("MatchBraces " + filename, fun ctok -> + member bc.MatchBraces(filename:string, source, options, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "MatchBraces", filename, fun ctok -> cancellable { - let! builderOpt,_,_ = getOrCreateBuilder (ctok, options) - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! builderOpt,_,decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + use _unwind = decrement match builderOpt with | None -> return [| |] | Some builder -> let _parseErrors, matchPairs, _inputOpt, _anyErrors = - Parser.ParseOneFile (ctok, source, true, false, filename, builder.ProjectFileNames, builder.TcConfig) + Parser.ParseOneFile (ctok, source, true, false, filename, builder.SourceFiles, builder.TcConfig) return matchPairs } @@ -2712,7 +2434,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent // | Some (parseResults, checkResults, _, _) when builder.AreCheckResultsBeforeFileInProjectReady(filename) -> | Some (parseResults, checkResults,_,priorTimeStamp) when - (match builder.GetCheckResultsBeforeFileInProjectIfReady filename with + (match builder.GetCheckResultsBeforeFileInProjectEvenIfStale filename with | None -> false | Some(tcPrior) -> tcPrior.TimeStamp = priorTimeStamp && @@ -2733,7 +2455,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent /// 6. Starts whole project background compilation. /// /// 7. Releases the file "lock". - member private bc.CheckOneFile + member private bc.CheckOneFileImpl (parseResults: FSharpParseFileResults, source: string, fileName: string, @@ -2742,11 +2464,12 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent fileVersion : int, builder : IncrementalBuilder, tcPrior : PartialCheckResults, - creationErrors : FSharpErrorInfo list) = + creationErrors : FSharpErrorInfo list, + userOpName: string) = async { let beingCheckedFileKey = fileName, options, fileVersion - let stopwatch = Diagnostics.Stopwatch.StartNew() + let stopwatch = Stopwatch.StartNew() let rec loop() = async { // results may appear while we were waiting for the lock, let's recheck if it's the case @@ -2761,9 +2484,9 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent // For scripts, this will have been recorded by GetProjectOptionsFromScript. let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options)) let! tcErrors, tcFileResult = - Parser.TypeCheckOneFile(parseResults, source, fileName, options.ProjectFileName, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, - tcPrior.TcState, loadClosure, tcPrior.Errors, reactorOps, (fun () -> builder.IsAlive), textSnapshotInfo) - let checkAnswer = MakeCheckFileAnswer(tcFileResult, options, builder, tcPrior.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors) + Parser.CheckOneFile(parseResults, source, fileName, options.ProjectFileName, tcPrior.TcConfig, tcPrior.TcGlobals, tcPrior.TcImports, + tcPrior.TcState, loadClosure, tcPrior.Errors, reactorOps, (fun () -> builder.IsAlive), textSnapshotInfo, userOpName) + let checkAnswer = MakeCheckFileAnswer(fileName, tcFileResult, options, builder, tcPrior.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors) bc.RecordTypeCheckFileInProjectResults(fileName, options, parseResults, fileVersion, tcPrior.TimeStamp, Some checkAnswer, source) return checkAnswer finally @@ -2780,10 +2503,13 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent } /// Type-check the result obtained by parsing, but only if the antecedent type checking context is available. - member bc.CheckFileInProjectIfReady(parseResults: FSharpParseFileResults, filename, fileVersion, source, options, textSnapshotInfo: obj option) = - let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync("CheckFileInProjectIfReady " + filename, action >> cancellable.Return) + member bc.CheckFileInProjectAllowingStaleCachedResults(parseResults: FSharpParseFileResults, filename, fileVersion, source, options, textSnapshotInfo: obj option, userOpName) = + let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "CheckFileInProjectAllowingStaleCachedResults ", filename, action >> cancellable.Return) async { try + if implicitlyStartBackgroundWork then + reactor.CancelBackgroundOp() // cancel the background work, since we will start new work after we're done + let! cachedResults = execWithReactorAsync <| fun ctok -> match incrementalBuildersCache.TryGetAny (ctok, options) with @@ -2797,88 +2523,99 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent | None -> return None | Some (_, _, Some x) -> return Some x | Some (builder, creationErrors, None) -> + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "CheckFileInProjectAllowingStaleCachedResults.CacheMiss", filename) let! tcPrior = execWithReactorAsync <| fun ctok -> DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent ctok - builder.GetCheckResultsBeforeFileInProjectIfReady filename + builder.GetCheckResultsBeforeFileInProjectEvenIfStale filename match tcPrior with | Some tcPrior -> - let! checkResults = bc.CheckOneFile(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors) + let! checkResults = bc.CheckOneFileImpl(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName) return Some checkResults | None -> return None // the incremental builder was not up to date finally - bc.ImplicitlyStartCheckProjectInBackground(options) + bc.ImplicitlyStartCheckProjectInBackground(options, userOpName) } /// Type-check the result obtained by parsing. Force the evaluation of the antecedent type checking context if needed. - member bc.CheckFileInProject(parseResults: FSharpParseFileResults, filename, fileVersion, source, options, textSnapshotInfo) = - let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync("CheckFileInProject " + filename, action) + member bc.CheckFileInProject(parseResults: FSharpParseFileResults, filename, fileVersion, source, options, textSnapshotInfo, userOpName) = + let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "CheckFileInProject", filename, action) async { - let! builderOpt,creationErrors,_ = execWithReactorAsync <| fun ctok -> getOrCreateBuilder (ctok, options) // Q: Whis it it ok to ignore creationErrors in the build cache? A: These errors will be appended into the typecheck results - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt - match builderOpt with - | None -> return FSharpCheckFileAnswer.Succeeded (MakeCheckFileResultsEmpty(creationErrors)) - | Some builder -> - // Check the cache. We can only use cached results when there is no work to do to bring the background builder up-to-date - let cachedResults = bc.GetCachedCheckFileResult(builder, filename, source, options) + try + if implicitlyStartBackgroundWork then + reactor.CancelBackgroundOp() // cancel the background work, since we will start new work after we're done + let! builderOpt,creationErrors, decrement = execWithReactorAsync (fun ctok -> getOrCreateBuilderAndKeepAlive (ctok, options, userOpName)) + use _unwind = decrement + match builderOpt with + | None -> return FSharpCheckFileAnswer.Succeeded (MakeCheckFileResultsEmpty(filename, creationErrors)) + | Some builder -> + // Check the cache. We can only use cached results when there is no work to do to bring the background builder up-to-date + let cachedResults = bc.GetCachedCheckFileResult(builder, filename, source, options) - match cachedResults with - | Some (_, checkResults) -> return FSharpCheckFileAnswer.Succeeded checkResults - | _ -> - let! tcPrior = execWithReactorAsync <| fun ctok -> builder.GetCheckResultsBeforeFileInProject (ctok, filename) - let! checkAnswer = bc.CheckOneFile(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors) - bc.ImplicitlyStartCheckProjectInBackground(options) - return checkAnswer + match cachedResults with + | Some (_, checkResults) -> return FSharpCheckFileAnswer.Succeeded checkResults + | _ -> + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "CheckFileInProject.CacheMiss", filename) + let! tcPrior = execWithReactorAsync <| fun ctok -> builder.GetCheckResultsBeforeFileInProject (ctok, filename) + let! checkAnswer = bc.CheckOneFileImpl(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName) + return checkAnswer + finally + bc.ImplicitlyStartCheckProjectInBackground(options, userOpName) } /// Parses and checks the source file and returns untyped AST and check results. - member bc.ParseAndCheckFileInProject(filename:string, fileVersion, source, options:FSharpProjectOptions,textSnapshotInfo) = - let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync("ParseAndCheckFileInProject " + filename, action) + member bc.ParseAndCheckFileInProject (filename:string, fileVersion, source, options:FSharpProjectOptions, textSnapshotInfo, userOpName) = + let execWithReactorAsync action = reactor.EnqueueAndAwaitOpAsync(userOpName, "ParseAndCheckFileInProject", filename, action) async { - let! builderOpt,creationErrors,_ = execWithReactorAsync <| fun ctok -> getOrCreateBuilder (ctok, options) // Q: Whis it it ok to ignore creationErrors in the build cache? A: These errors will be appended into the typecheck results - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt - match builderOpt with - | None -> - let parseResults = FSharpParseFileResults(List.toArray creationErrors, None, true, []) - return (parseResults, FSharpCheckFileAnswer.Aborted) + try + if implicitlyStartBackgroundWork then + reactor.CancelBackgroundOp() // cancel the background work, since we will start new work after we're done + let! builderOpt,creationErrors,decrement = execWithReactorAsync (fun ctok -> getOrCreateBuilderAndKeepAlive (ctok, options, userOpName)) + use _unwind = decrement + match builderOpt with + | None -> + let parseResults = FSharpParseFileResults(List.toArray creationErrors, None, true, []) + return (parseResults, FSharpCheckFileAnswer.Aborted) - | Some builder -> - let cachedResults = bc.GetCachedCheckFileResult(builder, filename, source, options) - - match cachedResults with - | Some (parseResults, checkResults) -> return parseResults, FSharpCheckFileAnswer.Succeeded checkResults - | _ -> - // todo this blocks the Reactor queue until all files up to the current are type checked. It's OK while editing the file, - // but results with non cooperative blocking when a firts file from a project opened. - let! tcPrior = execWithReactorAsync <| fun ctok -> builder.GetCheckResultsBeforeFileInProject (ctok, filename) + | Some builder -> + let cachedResults = bc.GetCachedCheckFileResult(builder, filename, source, options) + + match cachedResults with + | Some (parseResults, checkResults) -> return parseResults, FSharpCheckFileAnswer.Succeeded checkResults + | _ -> + Trace.TraceInformation("FCS: {0}.{1} ({2})", userOpName, "ParseAndCheckFileInProject.CacheMiss", filename) + // todo this blocks the Reactor queue until all files up to the current are type checked. It's OK while editing the file, + // but results with non cooperative blocking when a firts file from a project opened. + let! tcPrior = execWithReactorAsync <| fun ctok -> builder.GetCheckResultsBeforeFileInProject (ctok, filename) - // Do the parsing. - let! parseErrors, _matchPairs, inputOpt, anyErrors = - execWithReactorAsync <| fun ctok -> - Parser.ParseOneFile (ctok, source, false, true, filename, builder.ProjectFileNames, builder.TcConfig) |> cancellable.Return + // Do the parsing. + let! parseErrors, _matchPairs, inputOpt, anyErrors = + execWithReactorAsync <| fun ctok -> + Parser.ParseOneFile (ctok, source, false, true, filename, builder.SourceFiles, builder.TcConfig) |> cancellable.Return - let parseResults = FSharpParseFileResults(parseErrors, inputOpt, anyErrors, builder.AllDependenciesDeprecated) - let! checkResults = bc.CheckOneFile(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors) - bc.ImplicitlyStartCheckProjectInBackground(options) - return parseResults, checkResults + let parseResults = FSharpParseFileResults(parseErrors, inputOpt, anyErrors, builder.AllDependenciesDeprecated) + let! checkResults = bc.CheckOneFileImpl(parseResults, source, filename, options, textSnapshotInfo, fileVersion, builder, tcPrior, creationErrors, userOpName) + return parseResults, checkResults + finally + bc.ImplicitlyStartCheckProjectInBackground(options, userOpName) } /// Fetch the check information from the background compiler (which checks w.r.t. the FileSystem API) - member bc.GetBackgroundCheckResultsForFileInProject(filename,options) = - reactor.EnqueueAndAwaitOpAsync("GetBackgroundCheckResultsForFileInProject " + filename, fun ctok -> + member bc.GetBackgroundCheckResultsForFileInProject(filename, options, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "GetBackgroundCheckResultsForFileInProject", filename, fun ctok -> cancellable { - let! builderOpt, creationErrors, _ = getOrCreateBuilder (ctok, options) - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! builderOpt, creationErrors, decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + use _unwind = decrement match builderOpt with | None -> let parseResults = FSharpParseFileResults(Array.ofList creationErrors, None, true, []) - let typedResults = MakeCheckFileResultsEmpty(creationErrors) + let typedResults = MakeCheckFileResultsEmpty(filename, creationErrors) return (parseResults, typedResults) | Some builder -> let! (inputOpt, _, _, untypedErrors) = builder.GetParseResultsForFile (ctok, filename) let! tcProj = builder.GetCheckResultsAfterFileInProject (ctok, filename) - let untypedErrors = [| yield! creationErrors; yield! Parser.CreateErrorInfos (builder.TcConfig, false, filename, untypedErrors) |] - let tcErrors = [| yield! creationErrors; yield! Parser.CreateErrorInfos (builder.TcConfig, false, filename, tcProj.Errors) |] + let untypedErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (builder.TcConfig, false, filename, untypedErrors) |] + let tcErrors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (builder.TcConfig, false, filename, tcProj.Errors) |] let parseResults = FSharpParseFileResults(errors = untypedErrors, input = inputOpt, parseHadErrors = false, dependencyFiles = builder.AllDependenciesDeprecated) let loadClosure = scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.TryGet (ltok, options) ) let scope = @@ -2888,61 +2625,60 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent List.last tcProj.TcSymbolUses, tcProj.TcEnvAtEnd.NameEnv, loadClosure, reactorOps, (fun () -> builder.IsAlive), None) - let typedResults = MakeCheckFileResults(options, builder, scope, tcProj.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors) + let typedResults = MakeCheckFileResults(filename, options, builder, scope, tcProj.TcDependencyFiles, creationErrors, parseResults.Errors, tcErrors) return (parseResults, typedResults) }) /// Try to get recent approximate type check results for a file. - member bc.TryGetRecentCheckResultsForFile(filename: string, options:FSharpProjectOptions, source) = + member bc.TryGetRecentCheckResultsForFile(filename: string, options:FSharpProjectOptions, source, _userOpName: string) = match source with | Some sourceText -> - parseCacheLock.AcquireLock (fun ctok -> - match parseAndCheckFileInProjectCache.TryGet(ctok,(filename,sourceText,options)) with + parseCacheLock.AcquireLock (fun ltok -> + match parseAndCheckFileInProjectCache.TryGet(ltok,(filename,sourceText,options)) with | Some (a,b,c,_) -> Some (a,b,c) | None -> None) - | None -> parseCacheLock.AcquireLock (fun ctok -> parseAndCheckFileInProjectCachePossiblyStale.TryGet(ctok,(filename,options))) + | None -> parseCacheLock.AcquireLock (fun ltok -> parseAndCheckFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options))) /// Parse and typecheck the whole project (the implementation, called recursively as project graph is evaluated) - member private bc.ParseAndCheckProjectImpl(options, ctok) : Cancellable = + member private bc.ParseAndCheckProjectImpl(options, ctok, userOpName) : Cancellable = cancellable { - let! builderOpt,creationErrors,_ = getOrCreateBuilder (ctok, options) - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let! builderOpt,creationErrors,decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + use _unwind = decrement match builderOpt with | None -> - return FSharpCheckProjectResults (keepAssemblyContents, Array.ofList creationErrors, None, reactorOps) + return FSharpCheckProjectResults (options.ProjectFileName, keepAssemblyContents, Array.ofList creationErrors, None, reactorOps) | Some builder -> let! (tcProj, ilAssemRef, tcAssemblyDataOpt, tcAssemblyExprOpt) = builder.GetCheckResultsAndImplementationsForProject(ctok) - let errors = [| yield! creationErrors; yield! Parser.CreateErrorInfos (tcProj.TcConfig, true, Microsoft.FSharp.Compiler.TcGlobals.DummyFileNameForRangesWithoutASpecificLocation, tcProj.Errors) |] - return FSharpCheckProjectResults (keepAssemblyContents, errors, Some(tcProj.TcGlobals, tcProj.TcImports, tcProj.TcState.Ccu, tcProj.TcState.PartialAssemblySignature, tcProj.TcSymbolUses, tcProj.TopAttribs, tcAssemblyDataOpt, ilAssemRef, tcProj.TcEnvAtEnd.AccessRights, tcAssemblyExprOpt, tcProj.TcDependencyFiles), reactorOps) + let errors = [| yield! creationErrors; yield! ErrorHelpers.CreateErrorInfos (tcProj.TcConfig, true, Microsoft.FSharp.Compiler.TcGlobals.DummyFileNameForRangesWithoutASpecificLocation, tcProj.Errors) |] + return FSharpCheckProjectResults (options.ProjectFileName, keepAssemblyContents, errors, Some(tcProj.TcGlobals, tcProj.TcImports, tcProj.TcState.Ccu, tcProj.TcState.PartialAssemblySignature, tcProj.TcSymbolUses, tcProj.TopAttribs, tcAssemblyDataOpt, ilAssemRef, tcProj.TcEnvAtEnd.AccessRights, tcAssemblyExprOpt, tcProj.TcDependencyFiles), reactorOps) } /// Get the timestamp that would be on the output if fully built immediately - member private bc.TryGetLogicalTimeStampForProject(cache, ctok, options) = + member private bc.TryGetLogicalTimeStampForProject(cache, ctok, options, userOpName: string) = // NOTE: This creation of the background builder is currently run as uncancellable. Creating background builders is generally // cheap though the timestamp computations look suspicious for transitive project references. - let builderOpt,_creationErrors,_ = getOrCreateBuilder (ctok, options) |> Cancellable.runWithoutCancellation - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt + let builderOpt,_creationErrors,decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName + ".TryGetLogicalTimeStampForProject") |> Cancellable.runWithoutCancellation + use _unwind = decrement match builderOpt with | None -> None | Some builder -> Some (builder.GetLogicalTimeStampForProject(cache, ctok)) /// Keep the projet builder alive over a scope - member bc.KeepProjectAlive(options) = - reactor.EnqueueAndAwaitOpAsync("KeepProjectAlive " + options.ProjectFileName, fun ctok -> + member bc.KeepProjectAlive(options, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "KeepProjectAlive", options.ProjectFileName, fun ctok -> cancellable { - let! builderOpt,_creationErrors,_ = getOrCreateBuilder (ctok, options) - // This increments, and lets the caller decrement - return IncrementalBuilder.KeepBuilderAlive builderOpt + let! _builderOpt,_creationErrors,decrement = getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) + return decrement }) /// Parse and typecheck the whole project. - member bc.ParseAndCheckProject(options) = - reactor.EnqueueAndAwaitOpAsync("ParseAndCheckProject " + options.ProjectFileName, fun ctok -> bc.ParseAndCheckProjectImpl(options, ctok)) + member bc.ParseAndCheckProject(options, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "ParseAndCheckProject", options.ProjectFileName, fun ctok -> bc.ParseAndCheckProjectImpl(options, ctok, userOpName)) - member bc.GetProjectOptionsFromScript(filename, source, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?assumeDotNetFramework, ?extraProjectInfo: obj) = - reactor.EnqueueAndAwaitOpAsync ("GetProjectOptionsFromScript " + filename, fun ctok -> + member bc.GetProjectOptionsFromScript(filename, source, loadedTimeStamp, otherFlags, useFsiAuxLib: bool option, assumeDotNetFramework: bool option, extraProjectInfo: obj option, optionsStamp: int64 option, userOpName) = + reactor.EnqueueAndAwaitOpAsync (userOpName, "GetProjectOptionsFromScript", filename, fun ctok -> cancellable { use errors = new ErrorScope() // Do we add a reference to FSharp.Compiler.Interactive.Settings by default? @@ -2960,7 +2696,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent let applyCompilerOptions tcConfigB = let fsiCompilerOptions = CompileOptions.GetCoreFsiCompilerOptions tcConfigB CompileOptions.ParseCompilerOptions (ignore, fsiCompilerOptions, Array.toList otherFlags) - let loadClosure = LoadClosure.ComputeClosureOfSourceText(ctok, referenceResolver,filename, source, CodeContext.Editing, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions, assumeDotNetFramework) + let loadClosure = LoadClosure.ComputeClosureOfSourceText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, CodeContext.Editing, useSimpleResolution, useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions, assumeDotNetFramework) let otherFlags = [| yield "--noframework"; yield "--warn:3"; yield! otherFlags @@ -2970,7 +2706,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent let options = { ProjectFileName = filename + ".fsproj" // Make a name that is unique in this directory. - ProjectFileNames = loadClosure.SourceFiles |> List.map fst |> List.toArray + SourceFiles = loadClosure.SourceFiles |> List.map fst |> List.toArray OtherOptions = otherFlags ReferencedProjects= [| |] IsIncompleteTypeCheckEnvironment = false @@ -2979,48 +2715,56 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent UnresolvedReferences = Some (UnresolvedReferencesSet(loadClosure.UnresolvedReferences)) OriginalLoadReferences = loadClosure.OriginalLoadReferences ExtraProjectInfo=extraProjectInfo + Stamp = optionsStamp } scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Set(ltok, options, loadClosure)) // Save the full load closure for later correlation. return options, errors.Diagnostics }) - member bc.InvalidateConfiguration(options : FSharpProjectOptions) = - reactor.EnqueueOp("InvalidateConfiguration", fun ctok -> - // This operation can't currently be cancelled and is not async - match incrementalBuildersCache.TryGetAny (ctok, options) with - | None -> () - | Some (_oldBuilder, _, _) -> - // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, - // including by SetAlternate. - let builderB, errorsB, decrementB = CreateOneIncrementalBuilder (ctok, options) |> Cancellable.runWithoutCancellation - incrementalBuildersCache.Set(ctok, options, (builderB, errorsB, decrementB)) - if implicitlyStartBackgroundWork then - bc.CheckProjectInBackground(options)) - - member bc.NotifyProjectCleaned (options : FSharpProjectOptions) = - reactor.EnqueueAndAwaitOpAsync("NotifyProjectCleaned", fun ctok -> - cancellable { -#if EXTENSIONTYPING - match incrementalBuildersCache.TryGetAny (ctok, options) with - | None -> return () - | Some (builderOpt, _, _) -> - builderOpt |> Option.iter (fun builder -> - if builder.ThereAreLiveTypeProviders then - bc.InvalidateConfiguration(options)) -#endif - return () - }) + member bc.InvalidateConfiguration(options : FSharpProjectOptions, startBackgroundCompileIfAlreadySeen, userOpName) = + let startBackgroundCompileIfAlreadySeen = defaultArg startBackgroundCompileIfAlreadySeen implicitlyStartBackgroundWork + // This operation can't currently be cancelled nor awaited + reactor.EnqueueOp(userOpName, "InvalidateConfiguration", options.ProjectFileName, fun ctok -> + // If there was a similar entry then re-establish an empty builder . This is a somewhat arbitrary choice - it + // will have the effect of releasing memory associated with the previous builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then + + // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, + // including by incrementalBuildersCache.Set. + let newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) |> Cancellable.runWithoutCancellation + incrementalBuildersCache.Set(ctok, options, newBuilderInfo) + + // Start working on the project. Also a somewhat arbitrary choice + if startBackgroundCompileIfAlreadySeen then + bc.CheckProjectInBackground(options, userOpName + ".StartBackgroundCompile")) + + member bc.NotifyProjectCleaned (options : FSharpProjectOptions, userOpName) = + reactor.EnqueueAndAwaitOpAsync(userOpName, "NotifyProjectCleaned", options.ProjectFileName, fun ctok -> + cancellable { + // If there was a similar entry (as there normally will have been) then re-establish an empty builder . This + // is a somewhat arbitrary choice - it will have the effect of releasing memory associated with the previous + // builder, but costs some time. + if incrementalBuildersCache.ContainsSimilarKey (ctok, options) then + // We do not need to decrement here - the onDiscard function is called each time an entry is pushed out of the build cache, + // including by incrementalBuildersCache.Set. + let! newBuilderInfo = CreateOneIncrementalBuilder (ctok, options, userOpName) + incrementalBuildersCache.Set(ctok, options, newBuilderInfo) + }) - member bc.CheckProjectInBackground (options) = - reactor.SetBackgroundOp (Some (fun ctok -> + member bc.CheckProjectInBackground (options, userOpName) = + reactor.SetBackgroundOp (Some (userOpName, "CheckProjectInBackground", options.ProjectFileName, (fun ctok ct -> // The creation of the background builder can't currently be cancelled - let builderOpt,_,_ = getOrCreateBuilder (ctok, options) |> Cancellable.runWithoutCancellation - use _unwind = IncrementalBuilder.KeepBuilderAlive builderOpt - match builderOpt with - | None -> false - | Some builder -> - // The individual steps of the background build can't currently be cancelled - builder.Step(ctok) |> Cancellable.runWithoutCancellation)) + match getOrCreateBuilderAndKeepAlive (ctok, options, userOpName) |> Cancellable.run ct with + | ValueOrCancelled.Cancelled _ -> false + | ValueOrCancelled.Value (builderOpt,_,decrement) -> + use _unwind = decrement + match builderOpt with + | None -> false + | Some builder -> + // The individual steps of the background build + match builder.Step(ctok) |> Cancellable.run ct with + | ValueOrCancelled.Value v -> v + | ValueOrCancelled.Cancelled _ -> false))) member bc.StopBackgroundCompile () = reactor.SetBackgroundOp(None) @@ -3040,8 +2784,8 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent member bc.CurrentQueueLength = reactor.CurrentQueueLength - member bc.ClearCachesAsync () = - reactor.EnqueueAndAwaitOpAsync ("ClearCachesAsync", fun ctok -> + member bc.ClearCachesAsync (userOpName) = + reactor.EnqueueAndAwaitOpAsync (userOpName, "ClearCachesAsync", "", fun ctok -> parseCacheLock.AcquireLock (fun ltok -> parseAndCheckFileInProjectCachePossiblyStale.Clear ltok parseAndCheckFileInProjectCache.Clear ltok @@ -3051,8 +2795,8 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent scriptClosureCacheLock.AcquireLock (fun ltok -> scriptClosureCache.Clear ltok) cancellable.Return ()) - member bc.DownsizeCaches() = - reactor.EnqueueAndAwaitOpAsync ("DownsizeCaches", fun ctok -> + member bc.DownsizeCaches(userOpName) = + reactor.EnqueueAndAwaitOpAsync (userOpName, "DownsizeCaches", "", fun ctok -> parseCacheLock.AcquireLock (fun ltok -> parseAndCheckFileInProjectCachePossiblyStale.Resize(ltok, keepStrongly=1) parseAndCheckFileInProjectCache.Resize(ltok, keepStrongly=1) @@ -3067,6 +2811,7 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent static member GlobalForegroundParseCountStatistic = foregroundParseCount static member GlobalForegroundTypeCheckCountStatistic = foregroundTypeCheckCount + //---------------------------------------------------------------------------- // FSharpChecker // @@ -3074,15 +2819,12 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent [] [] // There is typically only one instance of this type in a Visual Studio process. -type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) = +type FSharpChecker(legacyReferenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) = - let backgroundCompiler = BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) + let backgroundCompiler = BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyContents, keepAllBackgroundResolutions) static let globalInstance = lazy FSharpChecker.Create() - // Parse using backgroundCompiler - let ComputeBraceMatching(filename:string,source,options:FSharpProjectOptions) = - backgroundCompiler.MatchBraces(filename,source,options) // STATIC ROOT: FSharpLanguageServiceTestable.FSharpChecker.braceMatchCache. Most recently used cache for brace matching. Accessed on the // background UI thread, not on the compiler thread. @@ -3091,65 +2833,75 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke let braceMatchCache = MruCache(braceMatchCacheSize, areSame=AreSameForParsing3, - areSameForSubsumption=AreSubsumable3) + areSimilar=AreSubsumable3) let mutable maxMemoryReached = false let mutable maxMB = maxMBDefault let maxMemEvent = new Event() /// Instantiate an interactive checker. - static member Create(?projectCacheSize, ?keepAssemblyContents, ?keepAllBackgroundResolutions, ?msbuildEnabled) = - let referenceResolver = SimulatedMSBuildReferenceResolver.GetBestAvailableResolver(defaultArg msbuildEnabled true) + static member Create(?projectCacheSize, ?keepAssemblyContents, ?keepAllBackgroundResolutions, ?legacyReferenceResolver) = + + let legacyReferenceResolver = + match legacyReferenceResolver with + | None -> SimulatedMSBuildReferenceResolver.GetBestAvailableResolver() + | Some rr -> rr + let keepAssemblyContents = defaultArg keepAssemblyContents false let keepAllBackgroundResolutions = defaultArg keepAllBackgroundResolutions true let projectCacheSizeReal = defaultArg projectCacheSize projectCacheSizeDefault - new FSharpChecker(referenceResolver, projectCacheSizeReal,keepAssemblyContents, keepAllBackgroundResolutions) + new FSharpChecker(legacyReferenceResolver, projectCacheSizeReal,keepAssemblyContents, keepAllBackgroundResolutions) - member ic.ReferenceResolver = referenceResolver + member ic.ReferenceResolver = legacyReferenceResolver - member ic.MatchBracesAlternate(filename, source, options) = + member ic.MatchBraces(filename, source, options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" async { match braceMatchCache.TryGet (AssumeAnyCallerThreadWithoutEvidence(), (filename, source, options)) with | Some res -> return res | None -> - let! res = ComputeBraceMatching (filename, source, options) + let! res = backgroundCompiler.MatchBraces(filename, source, options, userOpName) braceMatchCache.Set (AssumeAnyCallerThreadWithoutEvidence(), (filename, source, options), res) return res } - member ic.ParseFileInProject(filename, source, options) = + member ic.ParseFileInProject(filename, source, options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.ParseFileInProject(filename, source, options) + backgroundCompiler.ParseFileInProject(filename, source, options, userOpName) - member ic.GetBackgroundParseResultsForFileInProject (filename,options) = - backgroundCompiler.GetBackgroundParseResultsForFileInProject(filename,options) + member ic.GetBackgroundParseResultsForFileInProject (filename,options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.GetBackgroundParseResultsForFileInProject(filename, options, userOpName) - member ic.GetBackgroundCheckResultsForFileInProject (filename,options) = - backgroundCompiler.GetBackgroundCheckResultsForFileInProject(filename,options) + member ic.GetBackgroundCheckResultsForFileInProject (filename,options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.GetBackgroundCheckResultsForFileInProject(filename,options, userOpName) /// Try to get recent approximate type check results for a file. - member ic.TryGetRecentCheckResultsForFile(filename: string, options:FSharpProjectOptions, ?source) = - backgroundCompiler.TryGetRecentCheckResultsForFile(filename,options,source) - - member ic.TryGetRecentTypeCheckResultsForFile(filename, options, ?source) = ic.TryGetRecentCheckResultsForFile(filename,options,?source=source) - - member ic.Compile(argv: string[]) = - backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync ("Compile", fun ctok -> - cancellable { - return CompileHelpers.compileFromArgs (ctok, argv, referenceResolver, None, None) - } - ) - - member ic.Compile (ast:ParsedInput list, assemblyName:string, outFile:string, dependencies:string list, ?pdbFile:string, ?executable:bool, ?noframework:bool) = - backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync ("Compile", fun ctok -> + member ic.TryGetRecentCheckResultsForFile(filename: string, options:FSharpProjectOptions, ?source, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.TryGetRecentCheckResultsForFile(filename,options,source, userOpName) + + member ic.Compile(argv: string[], ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync (userOpName, "Compile", "", fun ctok -> + cancellable { + return CompileHelpers.compileFromArgs (ctok, argv, legacyReferenceResolver, None, None) + }) + + member ic.Compile (ast:ParsedInput list, assemblyName:string, outFile:string, dependencies:string list, ?pdbFile:string, ?executable:bool, ?noframework:bool, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync (userOpName, "Compile", assemblyName, fun ctok -> cancellable { let noframework = defaultArg noframework false - return CompileHelpers.compileFromAsts (ctok, referenceResolver, ast, assemblyName, outFile, dependencies, noframework, pdbFile, executable, None, None) + return CompileHelpers.compileFromAsts (ctok, legacyReferenceResolver, ast, assemblyName, outFile, dependencies, noframework, pdbFile, executable, None, None) } ) - member ic.CompileToDynamicAssembly (otherFlags: string[], execute: (TextWriter * TextWriter) option) = - backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync ("CompileToDynamicAssembly", fun ctok -> + member ic.CompileToDynamicAssembly (otherFlags: string[], execute: (TextWriter * TextWriter) option, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync (userOpName, "CompileToDynamicAssembly", "", fun ctok -> cancellable { CompileHelpers.setOutputStreams execute @@ -3163,7 +2915,7 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke let dynamicAssemblyCreator = Some (CompileHelpers.createDynamicAssembly (ctok, debugInfo, tcImportsRef, execute.IsSome, assemblyBuilderRef)) // Perform the compilation, given the above capturing function. - let errorsAndWarnings, result = CompileHelpers.compileFromArgs (ctok, otherFlags, referenceResolver, tcImportsCapture, dynamicAssemblyCreator) + let errorsAndWarnings, result = CompileHelpers.compileFromArgs (ctok, otherFlags, legacyReferenceResolver, tcImportsCapture, dynamicAssemblyCreator) // Retrieve and return the results let assemblyOpt = @@ -3175,8 +2927,9 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke } ) - member ic.CompileToDynamicAssembly (asts:ParsedInput list, assemblyName:string, dependencies:string list, execute: (TextWriter * TextWriter) option, ?debug:bool, ?noframework:bool) = - backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync ("CompileToDynamicAssembly", fun ctok -> + member ic.CompileToDynamicAssembly (asts:ParsedInput list, assemblyName:string, dependencies:string list, execute: (TextWriter * TextWriter) option, ?debug:bool, ?noframework:bool, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.Reactor.EnqueueAndAwaitOpAsync (userOpName, "CompileToDynamicAssembly", assemblyName, fun ctok -> cancellable { CompileHelpers.setOutputStreams execute @@ -3197,7 +2950,7 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke // Perform the compilation, given the above capturing function. let errorsAndWarnings, result = - CompileHelpers.compileFromAsts (ctok, referenceResolver, asts, assemblyName, outFile, dependencies, noframework, None, Some execute.IsSome, tcImportsCapture, dynamicAssemblyCreator) + CompileHelpers.compileFromAsts (ctok, legacyReferenceResolver, asts, assemblyName, outFile, dependencies, noframework, None, Some execute.IsSome, tcImportsCapture, dynamicAssemblyCreator) // Retrieve and return the results let assemblyOpt = @@ -3214,27 +2967,27 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke member ic.InvalidateAll() = ic.ClearCaches() - member ic.ClearCachesAsync() = + member ic.ClearCachesAsync(?userOpName: string) = let utok = AssumeAnyCallerThreadWithoutEvidence() + let userOpName = defaultArg userOpName "Unknown" braceMatchCache.Clear(utok) - backgroundCompiler.ClearCachesAsync() + backgroundCompiler.ClearCachesAsync(userOpName) - member ic.ClearCaches() = - ic.ClearCachesAsync() |> Async.Start // this cache clearance is not synchronous, it will happen when the background op gets run + member ic.ClearCaches(?userOpName) = + ic.ClearCachesAsync(?userOpName=userOpName) |> Async.Start // this cache clearance is not synchronous, it will happen when the background op gets run member ic.CheckMaxMemoryReached() = - if not maxMemoryReached && System.GC.GetTotalMemory(false) > int64 maxMB * 1024L * 1024L then - // If the maxMB limit is reached, drastic action is taken - // - reduce strong cache sizes to a minimum - backgroundCompiler.CompleteAllQueuedOps() - maxMemoryReached <- true - braceMatchCache.Resize(AssumeAnyCallerThreadWithoutEvidence(), keepStrongly=1) - backgroundCompiler.DownsizeCaches() |> Async.RunSynchronously - maxMemEvent.Trigger( () ) + if not maxMemoryReached && System.GC.GetTotalMemory(false) > int64 maxMB * 1024L * 1024L then + Trace.TraceWarning("!!!!!!!! MAX MEMORY REACHED, DOWNSIZING F# COMPILER CACHES !!!!!!!!!!!!!!!") + // If the maxMB limit is reached, drastic action is taken + // - reduce strong cache sizes to a minimum + let userOpName = "MaxMemoryReached" + backgroundCompiler.CompleteAllQueuedOps() + maxMemoryReached <- true + braceMatchCache.Resize(AssumeAnyCallerThreadWithoutEvidence(), keepStrongly=10) + backgroundCompiler.DownsizeCaches(userOpName) |> Async.RunSynchronously + maxMemEvent.Trigger( () ) - /// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation. - /// For example, the type provider approvals file may have changed. - // // This is for unit testing only member ic.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients() = backgroundCompiler.CompleteAllQueuedOps() // flush AsyncOp @@ -3245,50 +2998,53 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke /// This function is called when the configuration is known to have changed for reasons not encoded in the ProjectOptions. /// For example, dependent references may have been deleted or created. - member ic.InvalidateConfiguration(options: FSharpProjectOptions) = - backgroundCompiler.InvalidateConfiguration options - - /// This function is called when the configuration is known to have changed for reasons not encoded in the ProjectOptions. - /// For example, dependent references may have been deleted or created. - member ic.NotifyDependencyChanged(options: FSharpProjectOptions) = - backgroundCompiler.InvalidateConfiguration options + member ic.InvalidateConfiguration(options: FSharpProjectOptions, ?startBackgroundCompile, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.InvalidateConfiguration(options, startBackgroundCompile, userOpName) /// This function is called when a project has been cleaned, and thus type providers should be refreshed. - member ic.NotifyProjectCleaned(options: FSharpProjectOptions) = - backgroundCompiler.NotifyProjectCleaned options + member ic.NotifyProjectCleaned(options: FSharpProjectOptions, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.NotifyProjectCleaned (options, userOpName) /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member ic.CheckFileInProjectIfReady(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj) = - backgroundCompiler.CheckFileInProjectIfReady(parseResults,filename,fileVersion,source,options,textSnapshotInfo) + member ic.CheckFileInProjectAllowingStaleCachedResults(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.CheckFileInProjectAllowingStaleCachedResults(parseResults,filename,fileVersion,source,options,textSnapshotInfo, userOpName) /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member ic.CheckFileInProject(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj) = + member ic.CheckFileInProject(parseResults:FSharpParseFileResults, filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.CheckFileInProject(parseResults,filename,fileVersion,source,options,textSnapshotInfo) + backgroundCompiler.CheckFileInProject(parseResults,filename,fileVersion,source,options,textSnapshotInfo, userOpName) /// Typecheck a source code file, returning a handle to the results of the /// parse including the reconstructed types in the file. - member ic.ParseAndCheckFileInProject(filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj) = + member ic.ParseAndCheckFileInProject(filename:string, fileVersion:int, source:string, options:FSharpProjectOptions, ?textSnapshotInfo:obj, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.ParseAndCheckFileInProject(filename, fileVersion, source, options, textSnapshotInfo) + backgroundCompiler.ParseAndCheckFileInProject(filename, fileVersion, source, options, textSnapshotInfo, userOpName) - member ic.ParseAndCheckProject(options) = + member ic.ParseAndCheckProject(options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" ic.CheckMaxMemoryReached() - backgroundCompiler.ParseAndCheckProject(options) + backgroundCompiler.ParseAndCheckProject(options, userOpName) - member ic.KeepProjectAlive(options) = - backgroundCompiler.KeepProjectAlive(options) + member ic.KeepProjectAlive(options, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.KeepProjectAlive(options, userOpName) /// For a given script file, get the ProjectOptions implied by the #load closure - member ic.GetProjectOptionsFromScript(filename, source, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?assumeDotNetFramework, ?extraProjectInfo: obj) = - backgroundCompiler.GetProjectOptionsFromScript(filename,source,?loadedTimeStamp=loadedTimeStamp, ?otherFlags=otherFlags, ?useFsiAuxLib=useFsiAuxLib, ?assumeDotNetFramework=assumeDotNetFramework, ?extraProjectInfo=extraProjectInfo) + member ic.GetProjectOptionsFromScript(filename, source, ?loadedTimeStamp, ?otherFlags, ?useFsiAuxLib, ?assumeDotNetFramework, ?extraProjectInfo: obj, ?optionsStamp: int64, ?userOpName: string) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.GetProjectOptionsFromScript(filename, source, loadedTimeStamp, otherFlags, useFsiAuxLib, assumeDotNetFramework, extraProjectInfo, optionsStamp, userOpName) member ic.GetProjectOptionsFromCommandLineArgs(projectFileName, argv, ?loadedTimeStamp, ?extraProjectInfo: obj) = let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading { ProjectFileName = projectFileName - ProjectFileNames = [| |] // the project file names will be inferred from the ProjectOptions + SourceFiles = [| |] // the project file names will be inferred from the ProjectOptions OtherOptions = argv ReferencedProjects= [| |] IsIncompleteTypeCheckEnvironment = false @@ -3296,21 +3052,21 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke LoadTime = loadedTimeStamp UnresolvedReferences = None OriginalLoadReferences=[] - ExtraProjectInfo=extraProjectInfo } - -#if FX_ATLEAST_45 - member ic.GetProjectOptionsFromProjectFile(_ : string, ?_a : (string * string) list, ?_b : System.DateTime) : FSharpProjectOptions = - failwithf "This method has been removed." -#endif + ExtraProjectInfo=extraProjectInfo + Stamp = None } /// Begin background parsing the given project. - member ic.StartBackgroundCompile(options) = backgroundCompiler.CheckProjectInBackground(options) + member ic.StartBackgroundCompile(options, ?userOpName) = + let userOpName = defaultArg userOpName "Unknown" + backgroundCompiler.CheckProjectInBackground(options, userOpName) /// Begin background parsing the given project. - member ic.CheckProjectInBackground(options) = backgroundCompiler.CheckProjectInBackground(options) + member ic.CheckProjectInBackground(options, ?userOpName) = + ic.StartBackgroundCompile(options, ?userOpName=userOpName) /// Stop the background compile. - member ic.StopBackgroundCompile() = backgroundCompiler.StopBackgroundCompile() + member ic.StopBackgroundCompile() = + backgroundCompiler.StopBackgroundCompile() /// Block until the background compile finishes. // @@ -3360,18 +3116,16 @@ type FSharpChecker(referenceResolver, projectCacheSize, keepAssemblyContents, ke tokens -type FsiInteractiveChecker(referenceResolver, reactorOps: IReactorOperations, tcConfig: TcConfig, tcGlobals, tcImports, tcState) = +type FsiInteractiveChecker(legacyReferenceResolver, reactorOps: IReactorOperations, tcConfig: TcConfig, tcGlobals, tcImports, tcState) = let keepAssemblyContents = false - static member CreateErrorInfos (tcConfig, allErrors, mainInputFileName, errors) = - Parser.CreateErrorInfos(tcConfig, allErrors, mainInputFileName, errors) - - member __.ParseAndCheckInteraction (ctok, source) = + member __.ParseAndCheckInteraction (ctok, source, ?userOpName: string) = async { - let mainInputFileName = Path.Combine(tcConfig.implicitIncludeDir, "stdin.fsx") + let userOpName = defaultArg userOpName "Unknown" + let filename = Path.Combine(tcConfig.implicitIncludeDir, "stdin.fsx") // Note: projectSourceFiles is only used to compute isLastCompiland, and is ignored if Build.IsScript(mainInputFileName) is true (which it is in this case). let projectSourceFiles = [ ] - let parseErrors, _matchPairs, inputOpt, anyErrors = Parser.ParseOneFile (ctok, source, false, true, mainInputFileName, projectSourceFiles, tcConfig) + let parseErrors, _matchPairs, inputOpt, anyErrors = Parser.ParseOneFile (ctok, source, false, true, filename, projectSourceFiles, tcConfig) let dependencyFiles = [] // interactions have no dependencies let parseResults = FSharpParseFileResults(parseErrors, inputOpt, parseHadErrors = anyErrors, dependencyFiles = dependencyFiles) @@ -3383,17 +3137,15 @@ type FsiInteractiveChecker(referenceResolver, reactorOps: IReactorOperations, tc let fsiCompilerOptions = CompileOptions.GetCoreFsiCompilerOptions tcConfigB CompileOptions.ParseCompilerOptions (ignore, fsiCompilerOptions, [ ]) - let loadClosure = LoadClosure.ComputeClosureOfSourceText(ctok, referenceResolver, mainInputFileName, source, CodeContext.Editing, tcConfig.useSimpleResolution, tcConfig.useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions, assumeDotNetFramework) - let! tcErrors, tcFileResult = - Parser.TypeCheckOneFile(parseResults,source,mainInputFileName,"project",tcConfig,tcGlobals,tcImports, tcState, - Some loadClosure,backgroundDiagnostics,reactorOps,(fun () -> true),None) + let loadClosure = LoadClosure.ComputeClosureOfSourceText(ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, source, CodeContext.Editing, tcConfig.useSimpleResolution, tcConfig.useFsiAuxLib, new Lexhelp.LexResourceManager(), applyCompilerOptions, assumeDotNetFramework) + let! tcErrors, tcFileResult = Parser.CheckOneFile(parseResults, source, filename, "project", tcConfig, tcGlobals, tcImports, tcState, Some loadClosure, backgroundDiagnostics, reactorOps, (fun () -> true), None, userOpName) return match tcFileResult with | Parser.TypeCheckAborted.No scope -> let errors = [| yield! parseErrors; yield! tcErrors |] - let typeCheckResults = FSharpCheckFileResults (errors, Some scope, dependencyFiles, None, reactorOps) - let projectResults = FSharpCheckProjectResults (keepAssemblyContents, errors, Some(tcGlobals, tcImports, scope.ThisCcu, scope.CcuSig, [scope.ScopeSymbolUses], None, None, mkSimpleAssRef "stdin", tcState.TcEnvFromImpls.AccessRights, None, dependencyFiles), reactorOps) + let typeCheckResults = FSharpCheckFileResults (filename, errors, Some scope, dependencyFiles, None, reactorOps) + let projectResults = FSharpCheckProjectResults (filename, keepAssemblyContents, errors, Some(tcGlobals, tcImports, scope.ThisCcu, scope.CcuSig, [scope.ScopeSymbolUses], None, None, mkSimpleAssRef "stdin", tcState.TcEnvFromImpls.AccessRights, None, dependencyFiles), reactorOps) parseResults, typeCheckResults, projectResults | _ -> failwith "unexpected aborted" @@ -3404,8 +3156,8 @@ type FsiInteractiveChecker(referenceResolver, reactorOps: IReactorOperations, tc // type CompilerEnvironment = - static member BinFolderOfDefaultFSharpCompiler ?probePoint = - Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler probePoint + static member BinFolderOfDefaultFSharpCompiler(?probePoint) = + FSharpEnvironment.BinFolderOfDefaultFSharpCompiler(probePoint) /// Information about the compilation environment [] diff --git a/src/fsharp/vs/service.fsi b/src/fsharp/vs/service.fsi index ddba1aa812..98df8e598d 100755 --- a/src/fsharp/vs/service.fsi +++ b/src/fsharp/vs/service.fsi @@ -29,77 +29,16 @@ open Microsoft.FSharp.Compiler.InfoReader open Microsoft.FSharp.Compiler.Tast open Microsoft.FSharp.Compiler.Tastops -/// Represents one parameter for one method (or other item) in a group. -[] -type FSharpMethodGroupItemParameter = - - /// The name of the parameter. - member ParameterName: string - - /// A key that can be used for sorting the parameters, used to help sort overloads. - member CanonicalTypeTextForSorting: string - - /// The structured representation for the parameter including its name, its type and visual indicators of other - /// information such as whether it is optional. - member StructuredDisplay: Layout - - /// The text to display for the parameter including its name, its type and visual indicators of other - /// information such as whether it is optional. - member Display: string - - /// The descriptive help text to display for the parameter. - member Description: string - - /// Is the parameter optional - member IsOptional: bool - -/// Represents one method (or other item) in a method group. The item may represent either a method or -/// a single, non-overloaded item such as union case or a named function value. -[] -type FSharpMethodGroupItem = - - /// The documentation for the item - member XmlDoc : FSharpXmlDoc - - /// The structured description representation for the method (or other item) - member StructuredDescription : FSharpStructuredToolTipText - - /// The formatted description text for the method (or other item) - member Description : FSharpToolTipText - - /// The The structured description representation for the method (or other item) - member StructuredTypeText: Layout - - /// The formatted type text for the method (or other item) - member TypeText: string - - /// The parameters of the method in the overload set - member Parameters: FSharpMethodGroupItemParameter[] - - /// Does the method support an arguments list? This is always true except for static type instantiations like TP<42,"foo">. - member HasParameters: bool - - /// Does the method support a params list arg? - member HasParamArrayArg: bool - - /// Does the type name or method support a static arguments list, like TP<42,"foo"> or conn.CreateCommand<42, "foo">(arg1, arg2)? - member StaticParameters: FSharpMethodGroupItemParameter[] - -/// Represents a group of methods (or other items) returned by GetMethods. -[] -type FSharpMethodGroup = - /// The shared name of the methods (or other items) in the group - member MethodName: string - - /// The methods (or other items) in the group - member Methods: FSharpMethodGroupItem[] - /// Represents the reason why the GetDeclarationLocation operation failed. [] +#if COMPILER_PUBLIC_API type FSharpFindDeclFailureReason = +#else +type internal FSharpFindDeclFailureReason = +#endif - /// Generic reason: no particular information about error - | Unknown + /// Generic reason: no particular information about error apart from a message + | Unknown of message: string /// Source code file is not available | NoSourceCode @@ -112,15 +51,25 @@ type FSharpFindDeclFailureReason = /// Represents the result of the GetDeclarationLocation operation. [] +#if COMPILER_PUBLIC_API type FSharpFindDeclResult = +#else +type internal FSharpFindDeclResult = +#endif /// Indicates a declaration location was not found, with an additional reason | DeclNotFound of FSharpFindDeclFailureReason /// Indicates a declaration location was found - | DeclFound of range + | DeclFound of range + /// Indicates an external declaration was found + | ExternalDecl of assembly : string * externalSym : ExternalSymbol /// Represents the checking context implied by the ProjectOptions [] +#if COMPILER_PUBLIC_API type FSharpProjectContext = +#else +type internal FSharpProjectContext = +#endif /// Get the resolution and full contents of the assemblies referenced by the project options member GetReferencedAssemblies : unit -> FSharpAssembly list @@ -128,45 +77,12 @@ type FSharpProjectContext = member AccessibilityRights : FSharpAccessibilityRights -/// Represents the use of an F# symbol from F# source code -[] -type FSharpSymbolUse = - // For internal use only - internal new : g:TcGlobals * denv: Tastops.DisplayEnv * symbol:FSharpSymbol * itemOcc:ItemOccurence * range: range -> FSharpSymbolUse - - /// The symbol referenced - member Symbol : FSharpSymbol - - /// The display context active at the point where the symbol is used. Can be passed to FSharpType.Format - /// and other methods to format items in a way that is suitable for a specific source code location. - member DisplayContext : FSharpDisplayContext - - /// Indicates if the reference is a definition for the symbol, either in a signature or implementation - member IsFromDefinition : bool - - /// Indicates if the reference is in a pattern - member IsFromPattern : bool - - /// Indicates if the reference is in a syntactic type - member IsFromType : bool - - /// Indicates if the reference is in an attribute - member IsFromAttribute : bool - - /// Indicates if the reference is via the member being implemented in a class or object expression - member IsFromDispatchSlotImplementation : bool - - /// Indicates if the reference is either a builder or a custom operation in a computation expression - member IsFromComputationExpression : bool - - /// The file name the reference occurs in - member FileName: string - - /// The range of text representing the reference to the symbol - member RangeAlternate: range - [] -type (*internal*) SemanticClassificationType = +#if COMPILER_PUBLIC_API +type SemanticClassificationType = +#else +type internal SemanticClassificationType = +#endif | ReferenceType | ValueType | UnionCase @@ -185,7 +101,11 @@ type (*internal*) SemanticClassificationType = /// A handle to the results of CheckFileInProject. [] +#if COMPILER_PUBLIC_API type FSharpCheckFileResults = +#else +type internal FSharpCheckFileResults = +#endif /// The errors returned by parsing a source file. member Errors : FSharpErrorInfo[] @@ -225,8 +145,8 @@ type FSharpCheckFileResults = /// callback to the client to check if the text has changed. If it has, then give up /// and assume that we're going to repeat the operation later on. /// - - member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * getAllSymbols: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetDeclarationListInfo : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * getAllSymbols: (unit -> AssemblySymbol list) * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async /// Get the items for a declaration list in FSharpSymbol format /// @@ -249,7 +169,8 @@ type FSharpCheckFileResults = /// callback to the client to check if the text has changed. If it has, then give up /// and assume that we're going to repeat the operation later on. /// - member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetDeclarationListSymbols : ParsedFileResultsOpt:FSharpParseFileResults option * line: int * colAtEndOfPartialName: int * lineText:string * qualifyingNames: string list * partialName: string * ?hasTextChangedSinceLastTypecheck: (obj * range -> bool) * ?userOpName: string -> Async /// Compute a formatted tooltip for the given location @@ -259,7 +180,8 @@ type FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// Used to discriminate between 'identifiers', 'strings' and others. For strings, an attempt is made to give a tooltip for a #r "..." location. Use a value from FSharpTokenInfo.Tag, or FSharpTokenTag.Identifier, unless you have other information available. - member GetStructuredToolTipTextAlternate : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetStructuredToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async /// Compute a formatted tooltip for the given location /// @@ -268,7 +190,8 @@ type FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// Used to discriminate between 'identifiers', 'strings' and others. For strings, an attempt is made to give a tooltip for a #r "..." location. Use a value from FSharpTokenInfo.Tag, or FSharpTokenTag.Identifier, unless you have other information available. - member GetToolTipTextAlternate : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetToolTipText : line:int * colAtEndOfNames:int * lineText:string * names:string list * tokenTag:int * ?userOpName: string -> Async /// Compute the Visual Studio F1-help key identifier for the given location, based on name resolution results /// @@ -276,7 +199,8 @@ type FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. - member GetF1KeywordAlternate : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetF1Keyword : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async /// Compute a set of method overloads to show in a dialog relevant to the given code location. @@ -285,14 +209,16 @@ type FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. - member GetMethodsAlternate : line:int * colAtEndOfNames:int * lineText:string * names:string list option -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetMethods : line:int * colAtEndOfNames:int * lineText:string * names:string list option * ?userOpName: string -> Async /// Compute a set of method overloads to show in a dialog relevant to the given code location. The resulting method overloads are returned as symbols. /// The line number where the information is being requested. /// The column number at the end of the identifiers where the information is being requested. /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. - member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetMethodsAsSymbols : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async /// Resolve the names at the given location to the declaration location of the corresponding construct. /// @@ -301,7 +227,8 @@ type FSharpCheckFileResults = /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. /// If not given, then get the location of the symbol. If false, then prefer the location of the corresponding symbol in the implementation of the file (rather than the signature if present). If true, prefer the location of the corresponding symbol in the signature of the file (rather than the implementation). - member GetDeclarationLocationAlternate : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetDeclarationLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?preferFlag:bool * ?userOpName: string -> Async /// Resolve the names at the given location to a use of symbol. @@ -310,7 +237,8 @@ type FSharpCheckFileResults = /// The column number at the end of the identifiers where the information is being requested. /// The text of the line where the information is being requested. /// The identifiers at the location where the information is being requested. - member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetSymbolUseAtLocation : line:int * colAtEndOfNames:int * lineText:string * names:string list * ?userOpName: string -> Async /// Get any extra colorization info that is available after the typecheck member GetSemanticClassification : range option -> (range * SemanticClassificationType)[] @@ -323,7 +251,7 @@ type FSharpCheckFileResults = member GetFormatSpecifierLocationsAndArity : unit -> (range*int)[] /// Get all textual usages of all symbols throughout the file - member GetAllUsesOfAllSymbolsInFile : unit -> Async + member GetAllUsesOfAllSymbolsInFile : unit -> Async /// Get the textual usages that resolved to the given symbol throughout the file member GetUsesOfSymbolInFile : symbol:FSharpSymbol -> Async @@ -331,79 +259,115 @@ type FSharpCheckFileResults = member internal GetVisibleNamespacesAndModulesAtPoint : pos -> Async /// Determines if a long ident is resolvable at a specific point. - member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item -> Async + /// An optional string used for tracing compiler operations associated with this request. + member internal IsRelativeNameResolvable: cursorPos : pos * plid : string list * item: Item * ?userOpName: string -> Async /// A handle to the results of CheckFileInProject. [] +#if COMPILER_PUBLIC_API type FSharpCheckProjectResults = +#else +type internal FSharpCheckProjectResults = +#endif + /// The errors returned by processing the project - member Errors : FSharpErrorInfo[] + member Errors: FSharpErrorInfo[] /// Get a view of the overall signature of the assembly. Only valid to use if HasCriticalErrors is false. - member AssemblySignature : FSharpAssemblySignature + member AssemblySignature: FSharpAssemblySignature /// Get a view of the overall contents of the assembly. Only valid to use if HasCriticalErrors is false. - member AssemblyContents : FSharpAssemblyContents + member AssemblyContents: FSharpAssemblyContents /// Get the resolution of the ProjectOptions - member ProjectContext : FSharpProjectContext + member ProjectContext: FSharpProjectContext /// Get the textual usages that resolved to the given symbol throughout the project - member GetUsesOfSymbol : symbol:FSharpSymbol -> Async + member GetUsesOfSymbol: symbol:FSharpSymbol -> Async /// Get all textual usages of all symbols throughout the project - member GetAllUsesOfAllSymbols : unit -> Async + member GetAllUsesOfAllSymbols: unit -> Async /// Indicates if critical errors existed in the project options - member HasCriticalErrors : bool + member HasCriticalErrors: bool /// Indicates the set of files which must be watched to accurately track changes that affect these results, /// Clients interested in reacting to updates to these files should watch these files and take actions as described /// in the documentation for compiler service. - member DependencyFiles : string list + member DependencyFiles: string list /// Unused in this API +#if COMPILER_PUBLIC_API type UnresolvedReferencesSet +#else +type internal UnresolvedReferencesSet +#endif /// A set of information describing a project or script build configuration. +#if COMPILER_PUBLIC_API type FSharpProjectOptions = +#else +type internal FSharpProjectOptions = +#endif { // Note that this may not reduce to just the project directory, because there may be two projects in the same directory. ProjectFileName: string + /// The files in the project - ProjectFileNames: string[] + SourceFiles: string[] + /// Additional command line argument options for the project. These can include additional files and references. OtherOptions: string[] + /// The command line arguments for the other projects referenced by this project, indexed by the /// exact text used in the "-r:" reference in FSharpProjectOptions. ReferencedProjects: (string * FSharpProjectOptions)[] + /// When true, the typechecking environment is known a priori to be incomplete, for /// example when a .fs file is opened outside of a project. In this case, the number of error /// messages reported is reduced. IsIncompleteTypeCheckEnvironment : bool + /// When true, use the reference resolution rules for scripts rather than the rules for compiler. UseScriptResolutionRules : bool + /// Timestamp of project/script load, used to differentiate between different instances of a project load. /// This ensures that a complete reload of the project or script type checking /// context occurs on project or script unload/reload. LoadTime : DateTime + /// Unused in this API and should be 'None' when used as user-specified input UnresolvedReferences : UnresolvedReferencesSet option + /// Unused in this API and should be '[]' when used as user-specified input OriginalLoadReferences: (range * string) list + /// Extra information passed back on event trigger ExtraProjectInfo : obj option + + /// An optional stamp to uniquely identify this set of options + /// If two sets of options both have stamps, then they are considered equal + /// if and only if the stamps are equal + Stamp: int64 option } /// The result of calling TypeCheckResult including the possibility of abort and background compiler not caught up. [] +#if COMPILER_PUBLIC_API type FSharpCheckFileAnswer = +#else +type internal FSharpCheckFileAnswer = +#endif | Aborted // because cancellation caused an abandonment of the operation | Succeeded of FSharpCheckFileResults [] /// Used to parse and check F# source code. +#if COMPILER_PUBLIC_API type FSharpChecker = +#else +type internal FSharpChecker = +#endif /// /// Create an instance of an FSharpChecker. /// @@ -411,8 +375,8 @@ type FSharpChecker = /// The optional size of the project checking cache. /// Keep the checked contents of projects. /// If false, do not keep full intermediate checking results from background checking suitable for returning from GetBackgroundCheckResultsForFileInProject. This reduces memory usage. - /// If false, no dependency on MSBuild v12 is assumed. If true, at attempt is made to load MSBuild for reference resolution in scripts - static member Create : ?projectCacheSize: int * ?keepAssemblyContents: bool * ?keepAllBackgroundResolutions: bool * ?msbuildEnabled: bool -> FSharpChecker + /// An optional resolver for non-file references, for legacy purposes + static member Create : ?projectCacheSize: int * ?keepAssemblyContents: bool * ?keepAllBackgroundResolutions: bool * ?legacyReferenceResolver: ReferenceResolver.Resolver -> FSharpChecker /// /// Parse a source code file, returning information about brace matching in the file. @@ -422,7 +386,8 @@ type FSharpChecker = /// The filename for the file, used to help caching of results. /// The full source for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. - member MatchBracesAlternate : filename : string * source: string * options: FSharpProjectOptions -> Async<(range * range)[]> + /// An optional string used for tracing compiler operations associated with this request. + member MatchBraces : filename : string * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async<(range * range)[]> /// /// Parse a source code file, returning a handle that can be used for obtaining navigation bar information @@ -433,7 +398,8 @@ type FSharpChecker = /// The filename for the file. /// The full source for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. - member ParseFileInProject : filename: string * source: string * options: FSharpProjectOptions -> Async + /// An optional string used for tracing compiler operations associated with this request. + member ParseFileInProject : filename: string * source: string * options: FSharpProjectOptions * ?userOpName: string -> Async /// /// Check a source code file, returning a handle to the results of the parse including @@ -456,8 +422,8 @@ type FSharpChecker = /// an approximate intellisense resolution is inaccurate because a range of text has changed. This /// can be used to marginally increase accuracy of intellisense results in some situations. /// - /// - member CheckFileInProjectIfReady : parsed: FSharpParseFileResults * filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj -> Async + /// An optional string used for tracing compiler operations associated with this request. + member CheckFileInProjectAllowingStaleCachedResults : parsed: FSharpParseFileResults * filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?userOpName: string -> Async /// /// @@ -481,8 +447,8 @@ type FSharpChecker = /// an approximate intellisense resolution is inaccurate because a range of text has changed. This /// can be used to marginally increase accuracy of intellisense results in some situations. /// - /// - member CheckFileInProject : parsed: FSharpParseFileResults * filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj -> Async + /// An optional string used for tracing compiler operations associated with this request. + member CheckFileInProject : parsed: FSharpParseFileResults * filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?userOpName: string -> Async /// /// @@ -505,8 +471,8 @@ type FSharpChecker = /// an approximate intellisense resolution is inaccurate because a range of text has changed. This /// can be used to marginally increase accuracy of intellisense results in some situations. /// - /// - member ParseAndCheckFileInProject : filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj -> Async + /// An optional string used for tracing compiler operations associated with this request. + member ParseAndCheckFileInProject : filename: string * fileversion: int * source: string * options: FSharpProjectOptions * ?textSnapshotInfo: obj * ?userOpName: string -> Async /// /// Parse and typecheck all files in a project. @@ -514,14 +480,16 @@ type FSharpChecker = /// /// /// The options for the project or script. - member ParseAndCheckProject : options: FSharpProjectOptions -> Async + /// An optional string used for tracing compiler operations associated with this request. + member ParseAndCheckProject : options: FSharpProjectOptions * ?userOpName: string -> Async /// /// Create resources for the project and keep the project alive until the returned object is disposed. /// /// /// The options for the project or script. - member KeepProjectAlive : options: FSharpProjectOptions -> Async + /// An optional string used for tracing compiler operations associated with this request. + member KeepProjectAlive : options: FSharpProjectOptions * ?userOpName: string -> Async /// /// For a given script file, get the FSharpProjectOptions implied by the #load closure. @@ -534,7 +502,8 @@ type FSharpChecker = /// Indicates when the script was loaded into the editing environment, /// so that an 'unload' and 'reload' action will cause the script to be considered as a new project, /// so that references are re-resolved. - member GetProjectOptionsFromScript : filename: string * source: string * ?loadedTimeStamp: DateTime * ?otherFlags: string[] * ?useFsiAuxLib: bool * ?assumeDotNetFramework: bool * ?extraProjectInfo: obj -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetProjectOptionsFromScript : filename: string * source: string * ?loadedTimeStamp: DateTime * ?otherFlags: string[] * ?useFsiAuxLib: bool * ?assumeDotNetFramework: bool * ?extraProjectInfo: obj * ?optionsStamp: int64 * ?userOpName: string -> Async /// /// Get the FSharpProjectOptions implied by a set of command line arguments. @@ -547,19 +516,6 @@ type FSharpChecker = /// so that references are re-resolved. member GetProjectOptionsFromCommandLineArgs : projectFileName: string * argv: string[] * ?loadedTimeStamp: DateTime * ?extraProjectInfo: obj -> FSharpProjectOptions -#if FX_ATLEAST_45 - /// - /// Get the project options implied by a standard F# project file in the xbuild/msbuild format. - /// - /// - /// Used to differentiate between projects and for the base directory of the project. - /// The build properties such as Configuration=Debug etc. - /// Indicates when the project was loaded into the editing environment, - /// so that an 'unload' and 'reload' action will cause the project to be considered as a new project. - [] - member GetProjectOptionsFromProjectFile : projectFileName: string * ?properties : (string * string) list * ?loadedTimeStamp: DateTime -> FSharpProjectOptions -#endif - /// /// Like ParseFileInProject, but uses results from the background builder. /// All files are read from the FileSystem API, including the file being checked. @@ -567,7 +523,8 @@ type FSharpChecker = /// /// The filename for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. - member GetBackgroundParseResultsForFileInProject : filename : string * options : FSharpProjectOptions -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetBackgroundParseResultsForFileInProject : filename : string * options : FSharpProjectOptions * ?userOpName: string -> Async /// /// Like ParseFileInProject, but uses the existing results from the background builder. @@ -576,16 +533,24 @@ type FSharpChecker = /// /// The filename for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. - member GetBackgroundCheckResultsForFileInProject : filename : string * options : FSharpProjectOptions -> Async + /// An optional string used for tracing compiler operations associated with this request. + member GetBackgroundCheckResultsForFileInProject : filename : string * options : FSharpProjectOptions * ?userOpName: string -> Async + /// /// Compile using the given flags. Source files names are resolved via the FileSystem API. /// The output file must be given by a -o flag. /// The first argument is ignored and can just be "fsc.exe". - member Compile: argv:string [] -> Async + /// + /// An optional string used for tracing compiler operations associated with this request. + member Compile: argv:string[] * ?userOpName: string -> Async + /// /// TypeCheck and compile provided AST - member Compile: ast:ParsedInput list * assemblyName:string * outFile:string * dependencies:string list * ?pdbFile:string * ?executable:bool * ?noframework:bool -> Async + /// + /// An optional string used for tracing compiler operations associated with this request. + member Compile: ast:ParsedInput list * assemblyName:string * outFile:string * dependencies:string list * ?pdbFile:string * ?executable:bool * ?noframework:bool * ?userOpName: string -> Async + /// /// Compiles to a dynamic assembly using the given flags. /// /// The first argument is ignored and can just be "fsc.exe". @@ -596,10 +561,15 @@ type FSharpChecker = /// If the 'execute' parameter is given the entry points for the code are executed and /// the given TextWriters are used for the stdout and stderr streams respectively. In this /// case, a global setting is modified during the execution. - member CompileToDynamicAssembly: otherFlags:string [] * execute:(TextWriter * TextWriter) option -> Async + /// + /// An optional string used for tracing compiler operations associated with this request. + member CompileToDynamicAssembly: otherFlags:string [] * execute:(TextWriter * TextWriter) option * ?userOpName: string -> Async + /// /// TypeCheck and compile provided AST - member CompileToDynamicAssembly: ast:ParsedInput list * assemblyName:string * dependencies:string list * execute:(TextWriter * TextWriter) option * ?debug:bool * ?noframework:bool -> Async + /// + /// An optional string used for tracing compiler operations associated with this request. + member CompileToDynamicAssembly: ast:ParsedInput list * assemblyName:string * dependencies:string list * execute:(TextWriter * TextWriter) option * ?debug:bool * ?noframework:bool * ?userOpName: string -> Async /// /// Try to get type check results for a file. This looks up the results of recent type checks of the @@ -610,19 +580,29 @@ type FSharpChecker = /// The filename for the file. /// The options for the project or script, used to determine active --define conditionals and other options relevant to parsing. /// Optionally, specify source that must match the previous parse precisely. - member TryGetRecentCheckResultsForFile : filename: string * options:FSharpProjectOptions * ?source: string -> (FSharpParseFileResults * FSharpCheckFileResults * (*version*)int) option + /// An optional string used for tracing compiler operations associated with this request. + member TryGetRecentCheckResultsForFile : filename: string * options:FSharpProjectOptions * ?source: string * ?userOpName: string -> (FSharpParseFileResults * FSharpCheckFileResults * (*version*)int) option /// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation. - /// For example, the type provider approvals file may have changed. member InvalidateAll : unit -> unit /// This function is called when the configuration is known to have changed for reasons not encoded in the ProjectOptions. /// For example, dependent references may have been deleted or created. - member InvalidateConfiguration: options: FSharpProjectOptions -> unit + /// Start a background compile of the project if a project with the same name has already been seen before. + /// An optional string used for tracing compiler operations associated with this request. + member InvalidateConfiguration: options: FSharpProjectOptions * ?startBackgroundCompileIfAlreadySeen: bool * ?userOpName: string -> unit /// Set the project to be checked in the background. Overrides any previous call to CheckProjectInBackground - member CheckProjectInBackground: options: FSharpProjectOptions -> unit + member CheckProjectInBackground: options: FSharpProjectOptions * ?userOpName: string -> unit + + /// Stop the background compile. + //[] + member StopBackgroundCompile : unit -> unit + /// Block until the background compile finishes. + //[] + member WaitForBackgroundCompile : unit -> unit + /// Report a statistic for testability static member GlobalForegroundParseCountStatistic : int @@ -637,8 +617,11 @@ type FSharpChecker = /// may be in progress - such an operation is not counted in the queue length. member CurrentQueueLength : int + /// /// This function is called when a project has been cleaned/rebuilt, and thus any live type providers should be refreshed. - member NotifyProjectCleaned: options: FSharpProjectOptions -> Async + /// + /// An optional string used for tracing compiler operations associated with this request. + member NotifyProjectCleaned: options: FSharpProjectOptions * ?userOpName: string -> Async /// Notify the host that the logical type checking context for a file has now been updated internally /// and that the file has become eligible to be re-typechecked for errors. @@ -690,24 +673,32 @@ type FSharpChecker = /// Tokenize an entire file, line by line member TokenizeFile: source:string -> FSharpTokenInfo [] [] - - + // An object to typecheck source in a given typechecking environment. // Used internally to provide intellisense over F# Interactive. type internal FsiInteractiveChecker = internal new : ReferenceResolver.Resolver * ops: IReactorOperations * tcConfig: TcConfig * tcGlobals: TcGlobals * tcImports: TcImports * tcState: TcState -> FsiInteractiveChecker - member internal ParseAndCheckInteraction : CompilationThreadToken * source:string -> Async - static member internal CreateErrorInfos : tcConfig: TcConfig * allErrors:bool * mainInputFileName : string * seq -> FSharpErrorInfo[] + + /// An optional string used for tracing compiler operations associated with this request. + member internal ParseAndCheckInteraction : CompilationThreadToken * source:string * ?userOpName: string -> Async /// Information about the compilation environment +#if COMPILER_PUBLIC_API type [] CompilerEnvironment = +#else +type [] internal CompilerEnvironment = +#endif /// The default location of FSharp.Core.dll and fsc.exe based on the version of fsc.exe that is running - static member BinFolderOfDefaultFSharpCompiler : string option -> string option + static member BinFolderOfDefaultFSharpCompiler : ?probePoint: string -> string option /// Information about the compilation environment [] +#if COMPILER_PUBLIC_API module CompilerEnvironment = +#else +module internal CompilerEnvironment = +#endif /// These are the names of assemblies that should be referenced for .fs or .fsi files that /// are not associated with a project. val DefaultReferencesForOrphanSources : assumeDotNetFramework: bool -> string list @@ -717,14 +708,23 @@ module CompilerEnvironment = val IsCheckerSupportedSubcategory : string -> bool /// Information about the debugging environment +#if COMPILER_PUBLIC_API module DebuggerEnvironment = +#else +module internal DebuggerEnvironment = +#endif /// Return the language ID, which is the expression evaluator id that the /// debugger will use. val GetLanguageID : unit -> Guid /// A set of helpers related to naming of identifiers +#if COMPILER_PUBLIC_API module PrettyNaming = +#else +module internal PrettyNaming = +#endif + val IsIdentifierPartCharacter : char -> bool val IsLongIdentifierPartCharacter : char -> bool val IsOperatorName : string -> bool diff --git a/src/ilx/EraseClosures.fs b/src/ilx/EraseClosures.fs index 9e49945b3d..27faa0e23f 100755 --- a/src/ilx/EraseClosures.fs +++ b/src/ilx/EraseClosures.fs @@ -490,7 +490,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = Implements = List.empty; IsAbstract = false; NestedTypes = emptyILTypeDefs; - IsSealed = false; + IsSealed = true; IsSerializable=td.IsSerializable; IsComInterop=false; IsSpecialName=false; @@ -590,7 +590,7 @@ let rec convIlxClosureDef cenv encl (td: ILTypeDef) clo = Access = td.Access; Implements = [] IsAbstract = false; - IsSealed = false; + IsSealed = true; IsSerializable=td.IsSerializable; IsComInterop=false; IsSpecialName=false; diff --git a/src/ilx/EraseUnions.fs b/src/ilx/EraseUnions.fs index 1b300c8e78..2d3ee0996a 100755 --- a/src/ilx/EraseUnions.fs +++ b/src/ilx/EraseUnions.fs @@ -318,6 +318,12 @@ let rec extraTysAndInstrsForStructCtor (ilg: ILGlobals) cidx = let tys, instrs = extraTysAndInstrsForStructCtor ilg (cidx - 7) (ilg.typ_UInt32 :: tys, mkLdcInt32 0 :: instrs) +let takesExtraParams (alts: IlxUnionAlternative[]) = + alts.Length > 1 && + (alts |> Array.exists (fun d -> d.FieldDefs.Length > 0) || + // Check if not all lengths are distinct + alts |> Array.countBy (fun d -> d.FieldDefs.Length) |> Array.length <> alts.Length) + let convNewDataInstrInternal ilg cuspec cidx = let alt = altOfUnionSpec cuspec cidx let altTy = tyForAlt cuspec alt @@ -344,7 +350,7 @@ let convNewDataInstrInternal ilg cuspec cidx = | _ -> [], [] let ctorFieldTys = alt.FieldTypes |> Array.toList let extraTys, extraInstrs = - if cuspec.AlternativesArray.Length > 1 && cuspec.AlternativesArray |> Array.exists (fun d -> d.FieldDefs.Length > 0) then + if takesExtraParams cuspec.AlternativesArray then extraTysAndInstrsForStructCtor ilg cidx else [], [] @@ -949,7 +955,7 @@ let mkClassUnionDef (addMethodGeneratedAttrs, addPropertyGeneratedAttrs, addProp | Some typ -> Some typ.TypeSpec let extraParamsForCtor = - if isStruct && cud.cudAlternatives.Length > 1 && cud.cudAlternatives |> Array.exists (fun d -> d.FieldDefs.Length > 0) then + if isStruct && takesExtraParams cud.cudAlternatives then let extraTys, _extraInstrs = extraTysAndInstrsForStructCtor ilg cidx List.map mkILParamAnon extraTys else diff --git a/src/scripts/fssrgen.fsx b/src/scripts/fssrgen.fsx index 86b489c339..e7f2fb1555 100644 --- a/src/scripts/fssrgen.fsx +++ b/src/scripts/fssrgen.fsx @@ -440,23 +440,26 @@ let RunMain(filename, outFilename, outXmlFilenameOpt, projectNameOpt) = PrintErr(filename, 0, sprintf "An exception occurred when processing '%s'\n%s" filename (e.ToString())) 1 +#if COMPILED +[] +#endif let Main args = match args |> List.ofArray with - | [ _; inputFile; outFile; ] -> + | [ inputFile; outFile; ] -> let filename = System.IO.Path.GetFullPath(inputFile) let outFilename = System.IO.Path.GetFullPath(outFile) RunMain(filename, outFilename, None, None) - | [ _; inputFile; outFile; outXml ] -> + | [ inputFile; outFile; outXml ] -> let filename = System.IO.Path.GetFullPath inputFile let outFilename = System.IO.Path.GetFullPath outFile let outXmlFilename = System.IO.Path.GetFullPath outXml RunMain(filename, outFilename, Some outXmlFilename, None) - | [ _; inputFile; outFile; outXml; projectName ] -> + | [ inputFile; outFile; outXml; projectName ] -> let filename = System.IO.Path.GetFullPath inputFile let outFilename = System.IO.Path.GetFullPath outFile let outXmlFilename = System.IO.Path.GetFullPath outXml @@ -467,6 +470,7 @@ let Main args = printfn "Error: invalid arguments." printfn "Usage: " 1 - +#if !COMPILED printfn "fssrgen: args = %A" fsi.CommandLineArgs -Main fsi.CommandLineArgs +Main (fsi.CommandLineArgs |> Seq.skip 1 |> Seq.toArray) +#endif diff --git a/src/update.cmd b/src/update.cmd new file mode 100644 index 0000000000..480ef80b76 --- /dev/null +++ b/src/update.cmd @@ -0,0 +1,70 @@ +@if "%_echo%"=="" echo off +@rem =========================================================================================================== +@rem Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, +@rem Version 2.0. See License.txt in the project root for license information. +@rem =========================================================================================================== + +if /i "%1" == "debug" goto :ok +if /i "%1" == "release" goto :ok +if /i "%1" == "signonly" goto :ok + +echo adding required strong name verification skipping, and NGening built binaries +echo Usage: +echo update.cmd debug [-ngen] +echo update.cmd release [-ngen] +exit /b 1 + +:ok + +set BINDIR=%~dp0..\%1\net40\bin + +if exist "%WindowsSDK_ExecutablePath_x64%" set WINSDKNETFXTOOLS_X64=%WindowsSDK_ExecutablePath_x64% +if exist "%WindowsSDK_ExecutablePath_x86%" set WINSDKNETFXTOOLS_X86=%WindowsSDK_ExecutablePath_x86% + +if not "%WindowsSDK_ExecutablePath_x86%" == "" goto :havesdk + +set REGEXE32BIT=reg.exe +if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe + + FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B +if "%WINSDKNETFXTOOLS_x86%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools" /v InstallationFolder') DO SET WINSDKNETFXTOOLS_x86=%%B + +set WINSDKNETFXTOOLS_x64=%WINSDKNETFXTOOLS_x86%x64\ + +:havesdk +set SN32="%WINSDKNETFXTOOLS_x86%sn.exe" +set SN64="%WINSDKNETFXTOOLS_x64%sn.exe" + +set NGEN32=%windir%\Microsoft.NET\Framework\v4.0.30319\ngen.exe +set NGEN64=%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen.exe + +rem Disable strong-name validation for binaries that are delay-signed with the microsoft key +%SN32% -q -Vr *,b03f5f7f11d50a3a + +if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( + %SN64% -q -Vr *,b03f5f7f11d50a3a +) + +if /i "%1" == "signonly" goto :eof +if /i "%1" == "debug" set NGEN_FLAGS=/Debug + +rem NGen fsc, fsi, fsiAnyCpu, and FSharp.Build.dll +if /i not "%2"=="-ngen" goto :donengen + +"%NGEN32%" install "%BINDIR%\fsc.exe" %NGEN_FLAGS% /queue:1 /nologo +"%NGEN32%" install "%BINDIR%\fsi.exe" %NGEN_FLAGS% /queue:1 /nologo +"%NGEN32%" install "%BINDIR%\FSharp.Build.dll" %NGEN_FLAGS% /queue:1 /nologo +"%NGEN32%" executeQueuedItems 1 /nologo + +if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( + "%NGEN64%" install "%BINDIR%\fsiAnyCpu.exe" %NGEN_FLAGS% /queue:1 /nologo + "%NGEN64%" install "%BINDIR%\FSharp.Build.dll" %NGEN_FLAGS% /queue:1 /nologo + "%NGEN64%" executeQueuedItems 1 /nologo +) + +:donengen diff --git a/src/utils/CompilerLocationUtils.fs b/src/utils/CompilerLocationUtils.fs index 55b41a240d..194424e70b 100755 --- a/src/utils/CompilerLocationUtils.fs +++ b/src/utils/CompilerLocationUtils.fs @@ -160,15 +160,16 @@ module internal FSharpEnvironment = #endif let internal tryCurrentDomain() = + let pathFromCurrentDomain = #if FX_NO_APP_DOMAINS - None + System.AppContext.BaseDirectory #else - let pathFromCurrentDomain = System.AppDomain.CurrentDomain.BaseDirectory + System.AppDomain.CurrentDomain.BaseDirectory +#endif if not(String.IsNullOrEmpty(pathFromCurrentDomain)) then Some pathFromCurrentDomain else None -#endif #if FX_NO_SYSTEM_CONFIGURATION let internal tryAppConfig (_appConfigKey:string) = None @@ -189,13 +190,11 @@ module internal FSharpEnvironment = // The default location of FSharp.Core.dll and fsc.exe based on the version of fsc.exe that is running // Used for // - location of design-time copies of FSharp.Core.dll and FSharp.Compiler.Interactive.Settings.dll for the default assumed environment for scripts - // - default ToolPath in tasks in FSharp.Build.dll (for Fsc tasks) + // - default ToolPath in tasks in FSharp.Build.dll (for Fsc tasks, but note a probe location is given) // - default F# binaries directory in service.fs (REVIEW: check this) - // - default location of fsi.exe in FSharp.VS.FSI.dll - // - default location of fsc.exe in FSharp.Compiler.CodeDom.dll + // - default location of fsi.exe in FSharp.VS.FSI.dll (REVIEW: check this) // - default F# binaries directory in (project system) Project.fs let BinFolderOfDefaultFSharpCompiler(probePoint:string option) = - ignore probePoint #if FX_NO_WIN_REGISTRY ignore probePoint #if FX_NO_APP_DOMAINS @@ -213,50 +212,39 @@ module internal FSharpEnvironment = | Some _ -> result | None -> - let safeExists f = (try File.Exists(f) with _ -> false) - // Look in the probePoint if given, e.g. look for a compiler alongside of FSharp.Build.dll - match probePoint with - | Some p when safeExists (Path.Combine(p,"fsc.exe")) || safeExists (Path.Combine(p,"Fsc.exe")) -> Some p - | _ -> + let safeExists f = (try File.Exists(f) with _ -> false) + // Look in the probePoint if given, e.g. look for a compiler alongside of FSharp.Build.dll + match probePoint with + | Some p when safeExists (Path.Combine(p,"FSharp.Core.dll")) -> Some p + | _ -> - // On windows the location of the compiler is via a registry key + // On windows the location of the compiler is via a registry key - // Note: If the keys below change, be sure to update code in: - // Property pages (ApplicationPropPage.vb) + // Note: If the keys below change, be sure to update code in: + // Property pages (ApplicationPropPage.vb) - let key20 = @"Software\Microsoft\.NETFramework\AssemblyFolders\Microsoft.FSharp-" + FSharpTeamVersionNumber - let key40a = @"Software\Microsoft\FSharp\4.0\Runtime\v4.0" - let key40b = @"Software\Microsoft\FSharp\3.1\Runtime\v4.0" - let key40c = @"Software\Microsoft\FSharp\2.0\Runtime\v4.0" - let key1,key2,key3,key4 = key40a, key40b, key40c, key20 - - let result = tryRegKey key1 - match result with - | Some _ -> result - | None -> - let result = tryRegKey key2 - match result with - | Some _ -> result - | None -> - let result = tryRegKey key3 - match result with - | Some _ -> result - | None -> - let result = tryRegKey key4 - match result with - | Some _ -> result - | None -> - - // On Unix we let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions. - let result = - let var = System.Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") - if String.IsNullOrEmpty(var) then None - else Some(var) - match result with - | Some _ -> result - | None -> - // For the prototype compiler, we can just use the current domain - tryCurrentDomain() + let key1 = @"Software\Microsoft\FSharp\4.1\Runtime\v4.0" + let key2 = @"Software\Microsoft\FSharp\4.0\Runtime\v4.0" + + let result = tryRegKey key1 + match result with + | Some _ -> result + | None -> + let result = tryRegKey key2 + match result with + | Some _ -> result + | None -> + + // On Unix we let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions. + let result = + let var = System.Environment.GetEnvironmentVariable("FSHARP_COMPILER_BIN") + if String.IsNullOrEmpty(var) then None + else Some(var) + match result with + | Some _ -> result + | None -> + // For the prototype compiler, we can just use the current domain + tryCurrentDomain() with e -> System.Diagnostics.Debug.Assert(false, "Error while determining default location of F# compiler") None diff --git a/src/utils/TaggedCollections.fs b/src/utils/TaggedCollections.fs index 60a2e0bab9..83864aa450 100755 --- a/src/utils/TaggedCollections.fs +++ b/src/utils/TaggedCollections.fs @@ -570,10 +570,7 @@ namespace Internal.Utilities.Collections.Tagged let ofArray comparer l = Array.fold (fun acc k -> add comparer k acc) empty l -#if FX_NO_DEBUG_DISPLAYS -#else [] -#endif [] type internal Set<'T,'ComparerTag> when 'ComparerTag :> IComparer<'T>(comparer: IComparer<'T>, tree: SetTree<'T>) = @@ -1096,10 +1093,7 @@ namespace Internal.Utilities.Collections.Tagged member self.Dispose() = ()} -#if FX_NO_DEBUG_DISPLAYS -#else [] -#endif [] type internal Map<'Key,'T,'ComparerTag> when 'ComparerTag :> IComparer<'Key>( comparer: IComparer<'Key>, tree: MapTree<'Key,'T>) = diff --git a/src/utils/reshapedreflection.fs b/src/utils/reshapedreflection.fs index 80e8da9cdc..adfffceb6c 100644 --- a/src/utils/reshapedreflection.fs +++ b/src/utils/reshapedreflection.fs @@ -49,10 +49,6 @@ module internal ReflectionAdapters = let isInstanceFlag f = hasFlag BindingFlags.Instance f let isNonPublicFlag f = hasFlag BindingFlags.NonPublic f -#if FX_NO_EXIT - let exit (_n:int) = failwith "System.Environment.Exit does not exist!" -#endif - #if FX_NO_TYPECODE [] type TypeCode = @@ -147,8 +143,8 @@ module internal ReflectionAdapters = |> Array.filter (fun ei -> ei.Name = name) |> commit #endif - member this.GetConstructor(_bindingFlags, _binder, argsT:Type[], _parameterModifiers) = - this.GetConstructor(argsT) + member this.GetConstructor(bindingFlags, _binder, argsT:Type[], _parameterModifiers) = + this.GetConstructor(bindingFlags,argsT) member this.GetMethod(name, ?bindingFlags) = let bindingFlags = defaultArg bindingFlags publicFlags this.GetMethods(bindingFlags) @@ -199,10 +195,11 @@ module internal ReflectionAdapters = member this.IsSealed = this.GetTypeInfo().IsSealed member this.BaseType = this.GetTypeInfo().BaseType - member this.GetConstructor(parameterTypes : Type[]) = + + member this.GetConstructor(bindingFlags, parameterTypes : Type[]) = this.GetTypeInfo().DeclaredConstructors + |> Seq.filter (fun ci -> isAcceptable bindingFlags ci.IsStatic ci.IsPublic) |> Seq.filter (fun ci -> - not ci.IsStatic && //exclude type initializer ( let parameters = ci.GetParameters() (parameters.Length = parameterTypes.Length) && @@ -211,14 +208,19 @@ module internal ReflectionAdapters = ) |> Seq.toArray |> commit - // MSDN: returns an array of Type objects representing all the interfaces implemented or inherited by the current Type. - member this.GetInterfaces() = this.GetTypeInfo().ImplementedInterfaces |> Seq.toArray + + member this.GetConstructor(parameterTypes : Type[]) = + this.GetConstructor(BindingFlags.Public ||| BindingFlags.NonPublic ||| BindingFlags.Instance, parameterTypes) + member this.GetConstructors(?bindingFlags) = - let bindingFlags = defaultArg bindingFlags publicFlags + let bindingFlags = defaultArg bindingFlags (BindingFlags.Public ||| BindingFlags.Instance) // type initializer will also be included in resultset this.GetTypeInfo().DeclaredConstructors |> Seq.filter (fun ci -> isAcceptable bindingFlags ci.IsStatic ci.IsPublic) |> Seq.toArray + + // MSDN: returns an array of Type objects representing all the interfaces implemented or inherited by the current Type. + member this.GetInterfaces() = this.GetTypeInfo().ImplementedInterfaces |> Seq.toArray member this.GetMethods() = this.GetMethods(publicFlags) member this.Assembly = this.GetTypeInfo().Assembly member this.IsSubclassOf(otherTy : Type) = this.GetTypeInfo().IsSubclassOf(otherTy) diff --git a/src/utils/sformat.fs b/src/utils/sformat.fs index f50593c565..6b02f7eaaa 100755 --- a/src/utils/sformat.fs +++ b/src/utils/sformat.fs @@ -1,11 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // This file is compiled 3(!) times in the codebase -// - as the internal implementation of printf '%A' formatting -// defines: RUNTIME -// - as the internal implementation of structured formatting in FSharp.Compiler.dll +// - as the internal implementation of printf '%A' formatting in FSharp.Core +// - as the internal implementation of structured formatting in the compiler and F# Interactive // defines: COMPILER -// NOTE: this implementation is used by fsi.exe. This is very important. // // The one implementation file is used because we very much want to keep the implementations of // structured formatting the same for fsi.exe and '%A' printing. However fsi.exe may have @@ -17,17 +15,10 @@ #nowarn "52" // The value has been copied to ensure the original is not mutated by this operation #if COMPILER -// FSharp.Compiler-proto.dll: -// FSharp.Compiler.dll: namespace Internal.Utilities.StructuredFormat #else -#if RUNTIME // FSharp.Core.dll: namespace Microsoft.FSharp.Text.StructuredPrintfImpl -#else -// Powerpack: -namespace Microsoft.FSharp.Text.StructuredFormat -#endif #endif // Breakable block layout implementation. @@ -53,11 +44,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat #endif [] -#if COMPILER_SERVICE type LayoutTag = -#else - type internal LayoutTag = -#endif | ActivePatternCase | ActivePatternResult | Alias @@ -92,19 +79,11 @@ namespace Microsoft.FSharp.Text.StructuredFormat | UnknownType | UnknownEntity -#if COMPILER_SERVICE type TaggedText = -#else - type (* internal *) TaggedText = -#endif abstract Tag: LayoutTag abstract Text: string - -#if COMPILER_SERVICE + type TaggedTextWriter = -#else - type (* internal *) TaggedTextWriter = -#endif abstract Write: t: TaggedText -> unit abstract WriteLine: unit -> unit @@ -112,11 +91,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// - unbreakable, or /// - breakable, and if broken the second block has a given indentation. [] -#if COMPILER_SERVICE type Joint = -#else - type (* internal *) Joint = -#endif | Unbreakable | Breakable of int | Broken of int @@ -126,43 +101,23 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// /// If either juxt flag is true, then no space between words. [] -#if COMPILER_SERVICE type Layout = -#else - type (* internal *) Layout = -#endif | ObjLeaf of bool * obj * bool | Leaf of bool * TaggedText * bool | Node of bool * layout * bool * layout * bool * joint | Attr of string * (string * string) list * layout -#if COMPILER_SERVICE and layout = Layout -#else - and internal layout = Layout -#endif -#if COMPILER_SERVICE and joint = Joint -#else - and internal joint = Joint -#endif [] -#if COMPILER_SERVICE type IEnvironment = -#else - type internal IEnvironment = -#endif abstract GetLayout : obj -> layout abstract MaxColumns : int abstract MaxRows : int -#if COMPILER_SERVICE module TaggedTextOps = -#else - module (* internal *) TaggedTextOps = -#endif let tag tag text = { new TaggedText with member x.Tag = tag @@ -248,11 +203,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat let arrow = tagPunctuation "->" let questionMark = tagPunctuation "?" -#if COMPILER_SERVICE module LayoutOps = -#else - module (* internal *) LayoutOps = -#endif open TaggedTextOps let rec juxtLeft = function @@ -353,19 +304,12 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// These are a typical set of options used to control structured formatting. [] -#if COMPILER_SERVICE type FormatOptions = -#else - type internal FormatOptions = -#endif { FloatingPointFormat: string; AttributeProcessor: (string -> (string * string) list -> bool -> unit); -#if RUNTIME -#else -#if COMPILER // FSharp.Compiler.dll: This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter +#if COMPILER // This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter PrintIntercepts: (IEnvironment -> obj -> Layout option) list; StringLimit : int; -#endif #endif FormatProvider: System.IFormatProvider; #if FX_RESHAPED_REFLECTION @@ -381,12 +325,9 @@ namespace Microsoft.FSharp.Text.StructuredFormat ShowIEnumerable: bool; } static member Default = { FormatProvider = (System.Globalization.CultureInfo.InvariantCulture :> System.IFormatProvider); -#if RUNTIME -#else -#if COMPILER // FSharp.Compiler.dll: This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter +#if COMPILER // This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter PrintIntercepts = []; StringLimit = System.Int32.MaxValue; -#endif #endif AttributeProcessor= (fun _ _ _ -> ()); #if FX_RESHAPED_REFLECTION @@ -404,11 +345,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat -#if COMPILER_SERVICE module ReflectUtils = -#else - module internal ReflectUtils = -#endif open System open System.Reflection @@ -536,11 +473,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat | _ -> GetValueInfoOfObject bindingFlags (obj) -#if COMPILER_SERVICE module Display = -#else - module internal Display = -#endif open ReflectUtils open LayoutOps @@ -566,11 +499,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat #endif /// If "str" ends with "ending" then remove it from "str", otherwise no change. let trimEnding (ending:string) (str:string) = -#if FX_NO_CULTURE_INFO_ARGS - if str.EndsWith(ending) then -#else if str.EndsWith(ending,StringComparison.Ordinal) then -#endif str.Substring(0,str.Length - ending.Length) else str @@ -883,12 +812,8 @@ namespace Microsoft.FSharp.Text.StructuredFormat let msg = System.String.Concat([| "Method '"; ty.FullName; "."; name; "' not found." |]) raise (System.MissingMethodException(msg)) #endif -#else -#if FX_NO_CULTURE_INFO_ARGS - ty.InvokeMember(name, (BindingFlags.GetProperty ||| BindingFlags.Instance ||| BindingFlags.Public ||| BindingFlags.NonPublic), null, obj, [| |]) #else ty.InvokeMember(name, (BindingFlags.GetProperty ||| BindingFlags.Instance ||| BindingFlags.Public ||| BindingFlags.NonPublic), null, obj, [| |],CultureInfo.InvariantCulture) -#endif #endif let getField obj (fieldInfo: FieldInfo) = fieldInfo.GetValue(obj) @@ -1080,9 +1005,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat None // Seed with an empty layout with a space to the left for formatting purposes buildObjMessageL txt [leftL (tagText "")] -#if RUNTIME -#else -#if COMPILER // FSharp.Compiler.dll: This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter +#if COMPILER // This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter let res = match res with | Some _ -> res @@ -1092,7 +1015,6 @@ namespace Microsoft.FSharp.Text.StructuredFormat member env.MaxColumns = opts.PrintLength member env.MaxRows = opts.PrintLength } opts.PrintIntercepts |> List.tryPick (fun intercept -> intercept env x) -#endif #endif let res = match res with @@ -1389,7 +1311,11 @@ namespace Microsoft.FSharp.Text.StructuredFormat let any_to_string x = layout_as_string FormatOptions.Default x -#if RUNTIME +#if COMPILER + /// Called + let fsi_any_to_layout opts x = anyL ShowTopLevelBinding BindingFlags.Public opts x +#else +// FSharp.Core #if FX_RESHAPED_REFLECTION let internal anyToStringForPrintf opts (showNonPublicMembers : bool) x = let bindingFlags = ReflectionUtils.toBindingFlags showNonPublicMembers @@ -1399,7 +1325,3 @@ namespace Microsoft.FSharp.Text.StructuredFormat x |> anyL ShowAll bindingFlags opts |> layout_to_string opts #endif -#if COMPILER - /// Called - let fsi_any_to_layout opts x = anyL ShowTopLevelBinding BindingFlags.Public opts x -#endif diff --git a/src/utils/sformat.fsi b/src/utils/sformat.fsi index 9f9b9b11dc..4842e73c97 100755 --- a/src/utils/sformat.fsi +++ b/src/utils/sformat.fsi @@ -2,8 +2,8 @@ // This file is compiled 2(!) times in the codebase // - as the internal implementation of printf '%A' formatting -// defines: RUNTIME -// - as the internal implementation of structured formatting in FSharp.Compiler.dll +// defines: FSHARP_CORE +// - as the internal implementation of structured formatting in FSharp.Compiler.Service.dll // defines: COMPILER // NOTE: this implementation is used by fsi.exe. This is very important. // @@ -15,17 +15,12 @@ // all 4 cases the layout types are really different types. #if COMPILER -// FSharp.Compiler-proto.dll: -// FSharp.Compiler.dll: +// fsc-proto.exe: +// FSharp.Compiler.Service.dll: namespace Internal.Utilities.StructuredFormat #else -#if RUNTIME // FSharp.Core.dll: namespace Microsoft.FSharp.Text.StructuredPrintfImpl -#else -// Powerpack: -namespace Microsoft.FSharp.Text.StructuredFormat -#endif #endif open System @@ -35,30 +30,28 @@ namespace Microsoft.FSharp.Text.StructuredFormat open Microsoft.FSharp.Primitives.Basics /// Data representing structured layouts of terms. -#if RUNTIME // FSharp.Core.dll makes things internal and hides representations +#if FSHARP_CORE // FSharp.Core.dll makes things internal and hides representations type internal Layout type internal LayoutTag type internal TaggedText = abstract Tag: LayoutTag abstract Text: string -#else // FSharp.Compiler.dll, FSharp.Compiler-proto.dll, FSharp.PowerPack.dll - // FSharp.PowerPack.dll: reveals representations - // FSharp.Compiler-proto.dll, FSharp.Compiler.dll: the F# compiler likes to see these representations +#else // FSharp.Compiler.Service.dll, fsc-proto.exe /// Data representing joints in structured layouts of terms. The representation /// of this data type is only for the consumption of formatting engines. [] -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type Joint = #else - type (* internal *) Joint = + type internal Joint = #endif | Unbreakable | Breakable of int | Broken of int [] -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type LayoutTag = #else type internal LayoutTag = @@ -97,19 +90,19 @@ namespace Microsoft.FSharp.Text.StructuredFormat | UnknownType | UnknownEntity -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type TaggedText = #else - type (* internal *) TaggedText = + type internal TaggedText = #endif abstract Tag : LayoutTag abstract Text : string -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type TaggedTextWriter = #else - type (* internal *) TaggedTextWriter = + type internal TaggedTextWriter = #endif abstract Write: t: TaggedText -> unit abstract WriteLine: unit -> unit @@ -117,10 +110,10 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// Data representing structured layouts of terms. The representation /// of this data type is only for the consumption of formatting engines. [] -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type Layout = #else - type (* internal *) Layout = + type internal Layout = #endif | ObjLeaf of bool * obj * bool | Leaf of bool * TaggedText * bool @@ -128,7 +121,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat | Attr of string * (string * string) list * Layout #endif -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API module TaggedTextOps = #else module internal TaggedTextOps = @@ -179,9 +172,8 @@ namespace Microsoft.FSharp.Text.StructuredFormat val arrow : TaggedText val questionMark : TaggedText -#if RUNTIME // FSharp.Core.dll doesn't use PrintIntercepts -#else // FSharp.Compiler.dll, FSharp.Compiler-proto.dll, FSharp.PowerPack.dll -#if COMPILER_SERVICE +#if !FSHARP_CORE // FSharp.Core.dll doesn't use PrintIntercepts +#if COMPILER_PUBLIC_API type IEnvironment = #else type internal IEnvironment = @@ -204,7 +196,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// A joint is either unbreakable, breakable or broken. /// If a joint is broken the RHS layout occurs on the next line with optional indentation. /// A layout can be squashed to for given width which forces breaks as required. -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API module LayoutOps = #else module internal LayoutOps = @@ -304,19 +296,16 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// /// [] -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API type FormatOptions = #else type internal FormatOptions = #endif { FloatingPointFormat: string AttributeProcessor: (string -> (string * string) list -> bool -> unit); -#if RUNTIME // FSharp.Core.dll: PrintIntercepts aren't used there -#else -#if COMPILER // FSharp.Compiler.dll: This is the PrintIntercepts extensibility point currently revealed by fsi.exe's AddPrinter +#if COMPILER // FSharp.Core.dll: PrintIntercepts aren't used there PrintIntercepts: (IEnvironment -> obj -> Layout option) list; StringLimit: int; -#endif #endif FormatProvider: System.IFormatProvider #if FX_RESHAPED_REFLECTION @@ -332,7 +321,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat ShowIEnumerable: bool } static member Default : FormatOptions -#if COMPILER_SERVICE +#if COMPILER_PUBLIC_API module Display = #else module internal Display = @@ -356,7 +345,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat /// as any_to_string val output_any: writer:TextWriter -> value:'T * Type -> unit -#if RUNTIME // FSharp.Core.dll: Most functions aren't needed in FSharp.Core.dll, but we add one entry for printf +#if FSHARP_CORE // FSharp.Core.dll: Most functions aren't needed in FSharp.Core.dll, but we add one entry for printf #if FX_RESHAPED_REFLECTION val anyToStringForPrintf: options:FormatOptions -> showNonPublicMembers : bool -> value:'T * Type -> string diff --git a/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40.fsproj b/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40.fsproj index 140f409ed4..4eddaeffb8 100644 --- a/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40.fsproj +++ b/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40/Sample_VS2012_FSharp_ConsoleApp_net40.fsproj @@ -43,7 +43,7 @@ - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013.fsproj b/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013.fsproj index f9ced7efef..0c174af62d 100644 --- a/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013.fsproj +++ b/tests/projects/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013/Sample_VS2012_FSharp_ConsoleApp_net40_upgraded_VS2013.fsproj @@ -43,7 +43,7 @@ - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2012_FSharp_Portable_Library/Sample_VS2012_FSharp_Portable_Library.fsproj b/tests/projects/Sample_VS2012_FSharp_Portable_Library/Sample_VS2012_FSharp_Portable_Library.fsproj index e3794f65c8..921365806d 100644 --- a/tests/projects/Sample_VS2012_FSharp_Portable_Library/Sample_VS2012_FSharp_Portable_Library.fsproj +++ b/tests/projects/Sample_VS2012_FSharp_Portable_Library/Sample_VS2012_FSharp_Portable_Library.fsproj @@ -36,7 +36,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2012_FSharp_Portable_Library_upgraded_2013/Sample_VS2012_FSharp_Portable_Library_upgraded_2013.fsproj b/tests/projects/Sample_VS2012_FSharp_Portable_Library_upgraded_2013/Sample_VS2012_FSharp_Portable_Library_upgraded_2013.fsproj index ffe67bbba1..75b8b871bd 100644 --- a/tests/projects/Sample_VS2012_FSharp_Portable_Library_upgraded_2013/Sample_VS2012_FSharp_Portable_Library_upgraded_2013.fsproj +++ b/tests/projects/Sample_VS2012_FSharp_Portable_Library_upgraded_2013/Sample_VS2012_FSharp_Portable_Library_upgraded_2013.fsproj @@ -35,7 +35,7 @@ - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll True diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net40/Sample_VS2013_FSharp_Portable_Library_Legacy_net40.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net40/Sample_VS2013_FSharp_Portable_Library_Legacy_net40.fsproj index 14a589f4e5..727a28f6d8 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net40/Sample_VS2013_FSharp_Portable_Library_Legacy_net40.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net40/Sample_VS2013_FSharp_Portable_Library_Legacy_net40.fsproj @@ -37,7 +37,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net45/Sample_VS2013_FSharp_Portable_Library_Legacy_net45.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net45/Sample_VS2013_FSharp_Portable_Library_Legacy_net45.fsproj index 3fe583a665..77e65fa263 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net45/Sample_VS2013_FSharp_Portable_Library_Legacy_net45.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net45/Sample_VS2013_FSharp_Portable_Library_Legacy_net45.fsproj @@ -37,7 +37,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net451/Sample_VS2013_FSharp_Portable_Library_Legacy_net451.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net451/Sample_VS2013_FSharp_Portable_Library_Legacy_net451.fsproj index 3c0d92e1f5..4fc3681cb3 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net451/Sample_VS2013_FSharp_Portable_Library_Legacy_net451.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_Legacy_net451/Sample_VS2013_FSharp_Portable_Library_Legacy_net451.fsproj @@ -37,7 +37,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj index f0b91773ef..5ee9437dc1 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net45/Sample_VS2013_FSharp_Portable_Library_net45.fsproj @@ -38,7 +38,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451/Sample_VS2013_FSharp_Portable_Library_net451.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451/Sample_VS2013_FSharp_Portable_Library_net451.fsproj index db8e098888..2bd9905029 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451/Sample_VS2013_FSharp_Portable_Library_net451.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451/Sample_VS2013_FSharp_Portable_Library_net451.fsproj @@ -38,7 +38,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj index 982a84f20a..84cd51e717 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile259/Sample_VS2013_FSharp_Portable_Library_net451.fsproj @@ -38,7 +38,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj index 0810f435bb..960a7f5a33 100644 --- a/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj +++ b/tests/projects/Sample_VS2013_FSharp_Portable_Library_net451_adjusted_to_profile78/Sample_VS2013_FSharp_Portable_Library_net451.fsproj @@ -38,7 +38,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45+wp8\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2015_FSharp_Portable259_Library/Sample_VS2015_FSharp_Portable259_Library.fsproj b/tests/projects/Sample_VS2015_FSharp_Portable259_Library/Sample_VS2015_FSharp_Portable259_Library.fsproj index d0bc4d0d83..3860254ff7 100644 --- a/tests/projects/Sample_VS2015_FSharp_Portable259_Library/Sample_VS2015_FSharp_Portable259_Library.fsproj +++ b/tests/projects/Sample_VS2015_FSharp_Portable259_Library/Sample_VS2015_FSharp_Portable259_Library.fsproj @@ -39,7 +39,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2015_FSharp_Portable47_Library/Sample_VS2015_FSharp_Portable47_Library.fsproj b/tests/projects/Sample_VS2015_FSharp_Portable47_Library/Sample_VS2015_FSharp_Portable47_Library.fsproj index 6877656196..2497d03f00 100644 --- a/tests/projects/Sample_VS2015_FSharp_Portable47_Library/Sample_VS2015_FSharp_Portable47_Library.fsproj +++ b/tests/projects/Sample_VS2015_FSharp_Portable47_Library/Sample_VS2015_FSharp_Portable47_Library.fsproj @@ -38,7 +38,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+sl5+netcore45\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+sl5+netcore45\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2015_FSharp_Portable78_Library/Sample_VS2015_FSharp_Portable78_Library.fsproj b/tests/projects/Sample_VS2015_FSharp_Portable78_Library/Sample_VS2015_FSharp_Portable78_Library.fsproj index 06a1107fc5..7741d5f5b3 100644 --- a/tests/projects/Sample_VS2015_FSharp_Portable78_Library/Sample_VS2015_FSharp_Portable78_Library.fsproj +++ b/tests/projects/Sample_VS2015_FSharp_Portable78_Library/Sample_VS2015_FSharp_Portable78_Library.fsproj @@ -39,7 +39,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wp8\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45+wp8\FSharp.Core.dll diff --git a/tests/projects/Sample_VS2015_FSharp_Portable7_Library/Sample_VS2015_FSharp_Portable7_Library.fsproj b/tests/projects/Sample_VS2015_FSharp_Portable7_Library/Sample_VS2015_FSharp_Portable7_Library.fsproj index 9357bc94aa..8ebe0160da 100644 --- a/tests/projects/Sample_VS2015_FSharp_Portable7_Library/Sample_VS2015_FSharp_Portable7_Library.fsproj +++ b/tests/projects/Sample_VS2015_FSharp_Portable7_Library/Sample_VS2015_FSharp_Portable7_Library.fsproj @@ -39,7 +39,7 @@ FSharp.Core FSharp.Core.dll - ..\..\..\packages\FSharp.Core\lib\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\portable-net45+netcore45+wpa81+wp8\FSharp.Core.dll diff --git a/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/App.config b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/App.config new file mode 100644 index 0000000000..88fa4027bd --- /dev/null +++ b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/AssemblyInfo.fs b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/AssemblyInfo.fs new file mode 100644 index 0000000000..540132cd52 --- /dev/null +++ b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace ProjectWithBuildErrors.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/Program.fs b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/Program.fs new file mode 100644 index 0000000000..a50a68fd4e --- /dev/null +++ b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/Program.fs @@ -0,0 +1,21 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + + +let private x : int = failwith "" + +let inline f () = x + +let f1 argv = + //let x = 1 + 1.0 + let y = argx // this gives a multi-line error message + printfn "%A" argv + 0 // return an integer exit code + +[] +let main argv = + //let x = 1 + 1.0 + //let y = argx // this gives + printfn "%A" argv + 0 // return an integer exit code + \ No newline at end of file diff --git a/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/ProjectWithBuildErrors.fsproj b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/ProjectWithBuildErrors.fsproj new file mode 100644 index 0000000000..8a07b57459 --- /dev/null +++ b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/ProjectWithBuildErrors.fsproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + 2.0 + 9eda4075-e1e5-4f51-8908-5d608c092254 + Exe + ProjectWithBuildErrors + ProjectWithBuildErrors + v4.5.2 + true + 4.4.1.0 + ProjectWithBuildErrors + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + + + + \ No newline at end of file diff --git a/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/packages.config b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/packages.config new file mode 100644 index 0000000000..9f3f54425f --- /dev/null +++ b/tests/projects/misc/ProjectWithBuildErrors/ProjectWithBuildErrors/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/Library1/AssemblyInfo.fs b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library1/AssemblyInfo.fs new file mode 100644 index 0000000000..b4d90369ae --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library1/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Library1.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/AssemblyInfo.fs b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/AssemblyInfo.fs new file mode 100644 index 0000000000..f5d828440f --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Library2.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/Library2.fsproj b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/Library2.fsproj new file mode 100644 index 0000000000..c74263a7c7 --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/Library2.fsproj @@ -0,0 +1,81 @@ + + + + + Debug + AnyCPU + 2.0 + e72ee9de-323e-4f99-8d7e-1a1ed8a3477c + Library + Library2 + Library2 + v4.5.2 + 4.4.1.0 + true + Library2 + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + pdbonly + true + true + bin\$(Configuration)\ + RELEASE;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + Class.fs + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + + + + \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/packages.config b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/packages.config new file mode 100644 index 0000000000..9f3f54425f --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/Library2/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.sln b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.sln new file mode 100644 index 0000000000..b4e57f4ea2 --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SameFileBelongsToMultipleProjects", "SameFileBelongsToMultipleProjects\SameFileBelongsToMultipleProjects.fsproj", "{DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Library1", "Library1\Library1.fsproj", "{9F36577A-657B-4117-A118-F69AB182AA31}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Library2", "Library2\Library2.fsproj", "{E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Release|Any CPU.Build.0 = Release|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Release|Any CPU.Build.0 = Release|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Release|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/App.config b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/App.config new file mode 100644 index 0000000000..88fa4027bd --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/AssemblyInfo.fs b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/AssemblyInfo.fs new file mode 100644 index 0000000000..973e1b5c8a --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace ConsoleApplication1.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/Program.fs b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/Program.fs new file mode 100644 index 0000000000..55b67799e9 --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/Program.fs @@ -0,0 +1,9 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +[] +let main argv = + printfn "%A" argv + let c1 = Library1.Class.PropertyAlwaysAvailable + let c1 = Library2.Class.PropertyAlwaysAvailable + 0 // return an integer exit code diff --git a/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.fsproj b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.fsproj new file mode 100644 index 0000000000..cfb266a2ed --- /dev/null +++ b/tests/projects/misc/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects/SameFileBelongsToMultipleProjects.fsproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + 2.0 + df29450f-abd7-49fb-96c5-c9cae9a54f40 + Exe + ConsoleApplication1 + ConsoleApplication1 + v4.5.2 + true + 4.4.1.0 + SameFileBelongsToMultipleProjects + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + True + + + + + + + + + + + + + Library2 + {e72ee9de-323e-4f99-8d7e-1a1ed8a3477c} + True + + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/AssemblyInfo.fs b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/AssemblyInfo.fs new file mode 100644 index 0000000000..6d9185a23f --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Library1AlwaysInMatchingConfiguration.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Class.fs b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Class.fs new file mode 100644 index 0000000000..4c07dc3106 --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Class.fs @@ -0,0 +1,11 @@ + +namespace Library1AlwaysInMatchingConfiguration + +type Class() = + static member PropertyAlwaysAvailable = "F#" +#if DEBUG + static member PropertyAvailableInProject1DebugConfiguration = "F#" +#endif +#if RELEASE + static member PropertyAvailableInProject1ReleaseConfiguration = "F#" +#endif diff --git a/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Library1AlwaysInMatchingConfiguration.fsproj b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Library1AlwaysInMatchingConfiguration.fsproj new file mode 100644 index 0000000000..0c7cbb9b42 --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/Library1AlwaysInMatchingConfiguration.fsproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + 2.0 + 9f36577a-657b-4117-a118-f69ab182aa31 + Library + Library1AlwaysInMatchingConfiguration + Library1AlwaysInMatchingConfiguration + v4.5.2 + 4.4.1.0 + true + Library1AlwaysInMatchingConfiguration + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + pdbonly + true + true + bin\$(Configuration)\ + RELEASE;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/fff.config b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/fff.config new file mode 100644 index 0000000000..9f3f54425f --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library1AlwaysInMatchingConfiguration/fff.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/AssemblyInfo.fs b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/AssemblyInfo.fs new file mode 100644 index 0000000000..2060387a9b --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Library2AlwaysInDebugConfiguration.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Class.fs b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Class.fs new file mode 100644 index 0000000000..a2c57eefb3 --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Class.fs @@ -0,0 +1,10 @@ +namespace Library2AlwaysInDebugConfiguration + +type Class() = + static member PropertyAlwaysAvailable = "F#" +#if DEBUG + static member PropertyAvailableInProject2DebugConfiguration = "F#" +#endif +#if RELEASE + static member PropertyAvailableInProject2ReleaseConfiguration = "F#" +#endif diff --git a/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Library2AlwaysInDebugConfiguration.fsproj b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Library2AlwaysInDebugConfiguration.fsproj new file mode 100644 index 0000000000..9a0fd4ea2a --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/Library2AlwaysInDebugConfiguration.fsproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + 2.0 + e72ee9de-323e-4f99-8d7e-1a1ed8a3477c + Library + Library2AlwaysInDebugConfiguration + Library2AlwaysInDebugConfiguration + v4.5.2 + 4.4.1.0 + true + Library2AlwaysInDebugConfiguration + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + pdbonly + true + true + bin\$(Configuration)\ + RELEASE;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/packages.config b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/packages.config new file mode 100644 index 0000000000..9f3f54425f --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/Library2AlwaysInDebugConfiguration/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/TestProjectChanges.sln b/tests/projects/misc/TestProjectChanges/TestProjectChanges.sln new file mode 100644 index 0000000000..5a19cafa3e --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/TestProjectChanges.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestProjectChanges", "TestProjectChanges\TestProjectChanges.fsproj", "{DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Library1AlwaysInMatchingConfiguration", "Library1AlwaysInMatchingConfiguration\Library1AlwaysInMatchingConfiguration.fsproj", "{9F36577A-657B-4117-A118-F69AB182AA31}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Library2AlwaysInDebugConfiguration", "Library2AlwaysInDebugConfiguration\Library2AlwaysInDebugConfiguration.fsproj", "{E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF29450F-ABD7-49FB-96C5-C9CAE9A54F40}.Release|Any CPU.Build.0 = Release|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F36577A-657B-4117-A118-F69AB182AA31}.Release|Any CPU.Build.0 = Release|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {E72EE9DE-323E-4F99-8D7E-1A1ED8A3477C}.Release|Any CPU.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tests/projects/misc/TestProjectChanges/TestProjectChanges/App.config b/tests/projects/misc/TestProjectChanges/TestProjectChanges/App.config new file mode 100644 index 0000000000..88fa4027bd --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/TestProjectChanges/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/TestProjectChanges/AssemblyInfo.fs b/tests/projects/misc/TestProjectChanges/TestProjectChanges/AssemblyInfo.fs new file mode 100644 index 0000000000..973e1b5c8a --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/TestProjectChanges/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace ConsoleApplication1.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/projects/misc/TestProjectChanges/TestProjectChanges/Program.fs b/tests/projects/misc/TestProjectChanges/TestProjectChanges/Program.fs new file mode 100644 index 0000000000..97fad1e1a7 --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/TestProjectChanges/Program.fs @@ -0,0 +1,18 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +[] +let main argv = + printfn "%A" argv + let c1 = Library1AlwaysInMatchingConfiguration.Class.PropertyAlwaysAvailable + let c1 = Library2AlwaysInDebugConfiguration.Class.PropertyAlwaysAvailable +#if DEBUG + let c1 = Library1AlwaysInMatchingConfiguration.Class.PropertyAvailableInProject1DebugConfiguration + let c2 = Library2AlwaysInDebugConfiguration.Class.PropertyAvailableInProject2DebugConfiguration +#else + let c1 = Library1AlwaysInMatchingConfiguration.Class.PropertyAvailableInProject1ReleaseConfiguration + let c2 = Library2AlwaysInDebugConfiguration.Class.PropertyAvailableInProject2DebugConfiguration +#endif + + + 0 // return an integer exit code diff --git a/tests/projects/misc/TestProjectChanges/TestProjectChanges/TestProjectChanges.fsproj b/tests/projects/misc/TestProjectChanges/TestProjectChanges/TestProjectChanges.fsproj new file mode 100644 index 0000000000..5e881d625e --- /dev/null +++ b/tests/projects/misc/TestProjectChanges/TestProjectChanges/TestProjectChanges.fsproj @@ -0,0 +1,96 @@ + + + + + Debug + AnyCPU + 2.0 + df29450f-abd7-49fb-96c5-c9cae9a54f40 + Exe + ConsoleApplication1 + ConsoleApplication1 + v4.5.2 + true + 4.4.1.0 + TestProjectChanges + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + ..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll + True + + + + + + + + + + + + + Library1AlwaysInMatchingConfiguration + {9f36577a-657b-4117-a118-f69ab182aa31} + True + + + Library2AlwaysInDebugConfiguration + {e72ee9de-323e-4f99-8d7e-1a1ed8a3477c} + True + + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index f66365064f..ea5b379a1e 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -1,8 +1,8 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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/lib/nunit.framework.dll" +#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -22,7 +22,7 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common -let createOptionsForFile (content, dllFiles, libDirs, otherFlags) = +let internal getProjectReferences (content, dllFiles, libDirs, otherFlags) = let otherFlags = defaultArg otherFlags [] let libDirs = defaultArg libDirs [] let base1 = Path.GetTempFileName() @@ -47,27 +47,23 @@ let createOptionsForFile (content, dllFiles, libDirs, otherFlags) = yield "-I:"+libDir yield! otherFlags yield fileName1 |]) - fileName1, options - -let getProjectReferences(options) = - let projectCheckResults = checker.ParseAndCheckProject(options) |> Async.RunSynchronously - if projectCheckResults.HasCriticalErrors then + let results = checker.ParseAndCheckProject(options) |> Async.RunSynchronously + if results.HasCriticalErrors then let builder = new System.Text.StringBuilder() - for err in projectCheckResults.Errors do + for err in results.Errors do builder.AppendLine(sprintf "**** %s: %s" (if err.Severity = FSharpErrorSeverity.Error then "error" else "warning") err.Message) |> ignore failwith (builder.ToString()) let assemblies = - projectCheckResults.ProjectContext.GetReferencedAssemblies() + results.ProjectContext.GetReferencedAssemblies() |> List.map(fun x -> x.SimpleName, x) |> dict - projectCheckResults, assemblies + results, assemblies [] let ``Test that csharp references are recognized as such`` () = - let csharpAssembly = typeof.Assembly.Location - let _, options = createOptionsForFile("""module M""", [csharpAssembly], None, None) - let _, table = getProjectReferences(options) + let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" + let _, table = getProjectReferences("""module M""", [csharpAssembly], None, None) let ass = table.["CSharp_Analysis"] let search = ass.Contents.Entities |> Seq.tryFind (fun e -> e.DisplayName = "CSharpClass") Assert.True search.IsSome @@ -101,7 +97,7 @@ let ``Test that csharp references are recognized as such`` () = [] let ``Test that symbols of csharp inner classes/enums are reported`` () = - let csharpAssembly = typeof.Assembly.Location + let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" let content = """ module NestedEnumClass open FSharp.Compiler.Service.Tests @@ -109,8 +105,8 @@ open FSharp.Compiler.Service.Tests let _ = CSharpOuterClass.InnerEnum.Case1 let _ = CSharpOuterClass.InnerClass.StaticMember() """ - let _, options = createOptionsForFile(content, [csharpAssembly], None, None) - let results, _ = getProjectReferences(options) + + let results, _ = getProjectReferences(content, [csharpAssembly], None, None) results.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Array.map (fun su -> su.Symbol.ToString()) @@ -127,18 +123,16 @@ open FSharp.Compiler.Service.Tests let _ = CSharpClass(0) """ - let fileName, options = createOptionsForFile(content, [csharpAssembly], None, None) - let _, checkResults = - checker.ParseAndCheckFileInProject(fileName, 0, content, options) - |> Async.RunSynchronously - match checkResults with - | FSharpCheckFileAnswer.Succeeded(results) -> - let ctor = - results.GetAllUsesOfAllSymbolsInFile() + let results, _ = getProjectReferences(content, [csharpAssembly], None, None) + let ctor = + results.GetAllUsesOfAllSymbols() |> Async.RunSynchronously |> Seq.map (fun su -> su.Symbol) |> Seq.find (function :? FSharpMemberOrFunctionOrValue as mfv -> mfv.IsConstructor | _ -> false) - let members = (ctor :?> FSharpMemberOrFunctionOrValue).EnclosingEntity.MembersFunctionsAndValues + match (ctor :?> FSharpMemberOrFunctionOrValue).EnclosingEntity with + | Some e -> + let members = e.MembersFunctionsAndValues Seq.exists (fun (mfv : FSharpMemberOrFunctionOrValue) -> mfv.IsConstructor) members |> should be True Seq.exists (fun (mfv : FSharpMemberOrFunctionOrValue) -> mfv.IsEffectivelySameAs ctor) members |> should be True - | _ -> failwith "Could not check file" + | None -> failwith "Expected Some for EnclosingEntity" + diff --git a/tests/service/Common.fs b/tests/service/Common.fs index ab0cd50cd5..9f5e567617 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -1,4 +1,4 @@ -module FSharp.Compiler.Service.Tests.Common +module internal FSharp.Compiler.Service.Tests.Common open System.IO open System.Collections.Generic @@ -69,7 +69,7 @@ let sysLib nm = #if !FX_ATLEAST_PORTABLE if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows let programFilesx86Folder = System.Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") - programFilesx86Folder + @"\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\" + nm + ".dll" + programFilesx86Folder + @"\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\" + nm + ".dll" else #endif #if FX_NO_RUNTIMEENVIRONMENT @@ -84,9 +84,12 @@ 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" + +(* #if !FX_ATLEAST_PORTABLE if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows let programFilesx86Folder = System.Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") @@ -94,6 +97,19 @@ let fsCoreDefaultReference() = else #endif sysLib "FSharp.Core" +*) + +let mkStandardProjectReferences () = +#if DOTNETCORE + let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj" + let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6") + readRefs projDir file +#else + [ yield sysLib "mscorlib" + yield sysLib "System" + yield sysLib "System.Core" + yield fsCoreDefaultReference() ] +#endif let mkProjectCommandLineArgs (dllName, fileNames) = let args = @@ -113,17 +129,7 @@ let mkProjectCommandLineArgs (dllName, fileNames) = yield "--target:library" for x in fileNames do yield x - let references = -#if DOTNETCORE - let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj" - let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6") - readRefs projDir file -#else - [ yield sysLib "mscorlib" - yield sysLib "System" - yield sysLib "System.Core" - yield fsCoreDefaultReference() ] -#endif + let references = mkStandardProjectReferences () for r in references do yield "-r:" + r |] @@ -148,11 +154,7 @@ let mkProjectCommandLineArgsForScript (dllName, fileNames) = yield "--target:library" for x in fileNames do yield x - // let implDir = Path.GetDirectoryName(typeof.Assembly.Location) - let references = - let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj" - let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6") - readRefs projDir file + let references = mkStandardProjectReferences () for r in references do yield "-r:" + r |] @@ -169,6 +171,7 @@ let parseAndCheckScript (file, input) = #else let projectOptions, _diagnostics = checker.GetProjectOptionsFromScript(file, input) |> Async.RunSynchronously + printfn "projectOptions = %A" projectOptions #endif let parseResult, typedRes = checker.ParseAndCheckFileInProject(file, 0, input, projectOptions) |> Async.RunSynchronously @@ -233,12 +236,12 @@ let attribsOfSymbol (s:FSharpSymbol) = if v.IsFSharpUnion then yield "union" if v.IsInterface then yield "interface" if v.IsMeasure then yield "measure" - #if EXTENSIONTYPING +#if EXTENSIONTYPING if v.IsProvided then yield "provided" if v.IsStaticInstantiation then yield "staticinst" if v.IsProvidedAndErased then yield "erased" if v.IsProvidedAndGenerated then yield "generated" - #endif +#endif if v.IsUnresolved then yield "unresolved" if v.IsValueType then yield "valuetype" diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index dcda35c5f9..5dabe9ced7 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 "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -83,13 +83,13 @@ let ``Intro test`` () = msg.Message.Contains("Missing qualification after '.'") |> shouldEqual true // Get tool tip at the specified location - let tip = typeCheckResults.GetToolTipTextAlternate(4, 7, inputLines.[1], ["foo"], identToken) |> Async.RunSynchronously - (sprintf "%A" tip).Replace("\n","") |> shouldEqual """FSharpToolTipText [Single ("val foo : unit -> unitFull name: Test.foo",None)]""" + let tip = typeCheckResults.GetToolTipText(4, 7, inputLines.[1], ["foo"], identToken) |> Async.RunSynchronously + // (sprintf "%A" tip).Replace("\n","") |> shouldEqual """FSharpToolTipText [Single ("val foo : unit -> unitFull name: Test.foo",None)]""" // Get declarations (autocomplete) for a location let decls = typeCheckResults.GetDeclarationListInfo(Some parseResult, 7, 23, inputLines.[6], [], "msg", (fun _ -> []), fun _ -> false)|> Async.RunSynchronously CollectionAssert.AreEquivalent(stringMethods,[ for item in decls.Items -> item.Name ]) // Get overloads of the String.Concat method - let methods = typeCheckResults.GetMethodsAlternate(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously + let methods = typeCheckResults.GetMethods(5, 27, inputLines.[4], Some ["String"; "Concat"]) |> Async.RunSynchronously methods.MethodName |> shouldEqual "Concat" @@ -220,8 +220,8 @@ let ``Symbols many tests`` () = fnVal.CurriedParameterGroups.[0].[1].Name.Value |> shouldEqual "y" fnVal.DeclarationLocation.StartLine |> shouldEqual 3 fnVal.DisplayName |> shouldEqual "foo" - fnVal.EnclosingEntity.DisplayName |> shouldEqual "Test" - fnVal.EnclosingEntity.DeclarationLocation.StartLine |> shouldEqual 1 + fnVal.EnclosingEntity.Value.DisplayName |> shouldEqual "Test" + fnVal.EnclosingEntity.Value.DeclarationLocation.StartLine |> shouldEqual 1 fnVal.GenericParameters.Count |> shouldEqual 0 fnVal.InlineAnnotation |> shouldEqual FSharpInlineAnnotation.OptionalInline fnVal.IsActivePattern |> shouldEqual false @@ -267,15 +267,16 @@ let date = System.DateTime.Now.ToString().PadRight(25) [] let ``Expression typing test`` () = + printfn "------ Expression typing test -----------------" // Split the input & define file name let inputLines = input3.Split('\n') let file = "/home/user/Test.fsx" let parseResult, typeCheckResults = parseAndCheckScript(file, input3) let identToken = FSharpTokenTag.IDENT - // We only expect one reported error. However, - // on Unix, using filenames like /home/user/Test.fsx gives a second copy of all parse errors due to the - // way the load closure for scripts is generated. So this returns two identical errors + for msg in typeCheckResults.Errors do + printfn "***Expression typing test: Unexpected error: %A" msg.Message + typeCheckResults.Errors.Length |> shouldEqual 0 // Get declarations (autocomplete) for a location @@ -618,7 +619,7 @@ let test3 = System.Text.RegularExpressions.RegexOptions.Compiled #if TEST_TP_PROJECTS -module TPProject = +module internal TPProject = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -647,7 +648,7 @@ let _ = RegexTypedStatic.IsMatch<"ABC" >( (*$*) ) // TEST: no assert on Ctrl-sp let fileLines1 = File.ReadAllLines(fileName1) let fileNames = [fileName1] let args = Array.append (mkProjectCommandLineArgs (dllName, fileNames)) [| "-r:" + PathRelativeToTestAssembly(@"UnitTests\MockTypeProviders\DummyProviderForLanguageServiceTesting.dll") |] - let internal options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) + let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) let cleanFileName a = if a = fileName1 then "file1" else "??" [] @@ -716,11 +717,9 @@ let ``Test TPProject errors`` () = let internal extractToolTipText (FSharpToolTipText(els)) = [ for e in els do match e with - | FSharpToolTipElement.Single (txt,_) -> yield txt - | FSharpToolTipElement.Group txts -> for (t,_) in txts do yield t + | FSharpToolTipElement.Group txts -> for item in txts do yield item.MainDescription | FSharpToolTipElement.CompositionError err -> yield err - | FSharpToolTipElement.None -> yield "NONE!" - | FSharpToolTipElement.SingleParameter (txt,p,_) -> yield txt ] + | FSharpToolTipElement.None -> yield "NONE!" ] [] let ``Test TPProject quick info`` () = diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index b889f6f35c..0fe1dffcf5 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -1,8 +1,8 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../Debug/net40/bin/FSharp.Compiler.Service.ProjectCracker.dll" +#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -20,12 +20,11 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service open FSharp.Compiler.Service.Tests.Common -// Create an interactive checker instance -let checker = FSharpChecker.Create(keepAssemblyContents=true) +let internal exprChecker = FSharpChecker.Create(keepAssemblyContents=true) [] -module Utils = +module internal Utils = let rec printExpr low (e:FSharpExpr) = match e with | BasicPatterns.AddressOf(e1) -> "&"+printExpr 0 e1 @@ -33,7 +32,7 @@ module Utils = | BasicPatterns.Application(f,tyargs,args) -> quote low (printExpr 10 f + printTyargs tyargs + " " + printCurriedArgs args) | BasicPatterns.BaseValue(_) -> "base" | BasicPatterns.Call(Some obj,v,tyargs1,tyargs2,argsL) -> printObjOpt (Some obj) + v.CompiledName + printTyargs tyargs2 + printTupledArgs argsL - | BasicPatterns.Call(None,v,tyargs1,tyargs2,argsL) -> v.EnclosingEntity.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs argsL + | BasicPatterns.Call(None,v,tyargs1,tyargs2,argsL) -> v.EnclosingEntity.Value.CompiledName + printTyargs tyargs1 + "." + v.CompiledName + printTyargs tyargs2 + " " + printTupledArgs argsL | BasicPatterns.Coerce(ty1,e1) -> quote low (printExpr 10 e1 + " :> " + printTy ty1) | BasicPatterns.DefaultValue(ty1) -> "dflt" | BasicPatterns.FastIntegerForLoop _ -> "for-loop" @@ -46,7 +45,7 @@ module Utils = | BasicPatterns.LetRec(vse,b) -> "let rec ... in " + printExpr 0 b | BasicPatterns.NewArray(ty,es) -> "[|" + (es |> Seq.map (printExpr 0) |> String.concat "; ") + "|]" | BasicPatterns.NewDelegate(ty,es) -> "new-delegate" - | BasicPatterns.NewObject(v,tys,args) -> "new " + v.EnclosingEntity.CompiledName + printTupledArgs args + | BasicPatterns.NewObject(v,tys,args) -> "new " + v.EnclosingEntity.Value.CompiledName + printTupledArgs args | BasicPatterns.NewRecord(v,args) -> let fields = v.TypeDefinition.FSharpFields "{" + ((fields, args) ||> Seq.map2 (fun f a -> f.Name + " = " + printExpr 0 a) |> String.concat "; ") + "}" @@ -251,7 +250,7 @@ module Utils = //--------------------------------------------------------------------------------------------------------- // This project is a smoke test for a whole range of standard and obscure expressions -module Project1 = +module internal Project1 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -532,7 +531,7 @@ let bool2 = false #if EXTENSIONTYPING [] let ``Test Declarations project1`` () = - let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously + let wholeProjectResults = exprChecker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously for e in wholeProjectResults.Errors do printfn "Project1 error: <<<%s>>>" e.Message @@ -654,7 +653,7 @@ let ``Test Declarations project1`` () = //--------------------------------------------------------------------------------------------------------- // This big list expression was causing us trouble -module ProjectStressBigExpressions = +module internal ProjectStressBigExpressions = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -852,12 +851,12 @@ let BigSequenceExpression(outFileOpt,docFileOpt,baseAddressOpt) = let fileNames = [fileName1] let args = mkProjectCommandLineArgs (dllName, fileNames) - let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) + let options = exprChecker.GetProjectOptionsFromCommandLineArgs (projFileName, args) [] let ``Test expressions of declarations stress big expressions`` () = - let wholeProjectResults = checker.ParseAndCheckProject(ProjectStressBigExpressions.options) |> Async.RunSynchronously + let wholeProjectResults = exprChecker.ParseAndCheckProject(ProjectStressBigExpressions.options) |> Async.RunSynchronously wholeProjectResults.Errors.Length |> shouldEqual 0 @@ -867,7 +866,9 @@ let ``Test expressions of declarations stress big expressions`` () = // This should not stack overflow printDeclarations None (List.ofSeq file1.Declarations) |> Seq.toList |> ignore -#if FX_ATLEAST_45 && !DOTNETCORE +#if NOT_YET_ENABLED + +#if !NO_PROJECTCRACKER && !DOTNETCORE [] let ``Check use of type provider that provides calls to F# code`` () = @@ -882,7 +883,7 @@ let ``Check use of type provider that provides calls to F# code`` () = let res = options - |> checker.ParseAndCheckProject + |> exprChecker.ParseAndCheckProject |> Async.RunSynchronously Assert.AreEqual ([||], res.Errors, sprintf "Should not be errors, but: %A" res.Errors) @@ -1087,6 +1088,8 @@ let ``Check use of type provider that provides calls to F# code`` () = ] #endif +#endif + #if SELF_HOST_STRESS @@ -1096,7 +1099,7 @@ let ``Test Declarations selfhost`` () = let projectFile = __SOURCE_DIRECTORY__ + @"/FSharp.Compiler.Service.Tests.fsproj" // Check with Configuration = Release let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) - let wholeProjectResults = checker.ParseAndCheckProject(options) |> Async.RunSynchronously + let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunSynchronously wholeProjectResults.Errors.Length |> shouldEqual 0 @@ -1121,7 +1124,7 @@ let ``Test Declarations selfhost whole compiler`` () = //for x in options.OtherOptions do printfn "%s" x - let wholeProjectResults = checker.ParseAndCheckProject(options) |> Async.RunSynchronously + let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunSynchronously (wholeProjectResults.Errors |> Array.filter (fun x -> x.Severity = FSharpErrorSeverity.Error)).Length |> shouldEqual 0 @@ -1154,7 +1157,7 @@ let ``Test Declarations selfhost FSharp.Core`` () = let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) - let wholeProjectResults = checker.ParseAndCheckProject(options) |> Async.RunSynchronously + let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunSynchronously //(wholeProjectResults.Errors |> Array.filter (fun x -> x.Severity = FSharpErrorSeverity.Error)).Length |> shouldEqual 0 diff --git a/tests/service/FileSystemTests.fs b/tests/service/FileSystemTests.fs index 8f47cd895b..ee5f1f3603 100644 --- a/tests/service/FileSystemTests.fs +++ b/tests/service/FileSystemTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -15,7 +15,6 @@ open System.IO open System.Collections.Generic open System.Text open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Interactive.Shell open Microsoft.FSharp.Compiler.SourceCodeServices open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.Service.Tests.Common @@ -23,7 +22,7 @@ open FSharp.Compiler.Service.Tests.Common let fileName1 = @"c:\mycode\test1.fs" // note, the path doesn' exist let fileName2 = @"c:\mycode\test2.fs" // note, the path doesn' exist -type MyFileSystem(defaultFileSystem:IFileSystem) = +type internal MyFileSystem(defaultFileSystem:IFileSystem) = let file1 = """ module File1 @@ -96,7 +95,7 @@ let ``FileSystem compilation test``() = yield "-r:" + r |] { ProjectFileName = @"c:\mycode\compilation.fsproj" // Make a name that is unique in this directory. - ProjectFileNames = [| fileName1; fileName2 |] + SourceFiles = [| fileName1; fileName2 |] OtherOptions = allFlags ReferencedProjects = [| |]; IsIncompleteTypeCheckEnvironment = false @@ -104,7 +103,8 @@ let ``FileSystem compilation test``() = LoadTime = System.DateTime.Now // Not 'now', we don't want to force reloading UnresolvedReferences = None OriginalLoadReferences = [] - ExtraProjectInfo = None } + ExtraProjectInfo = None + Stamp = None } let results = checker.ParseAndCheckProject(projectOptions) |> Async.RunSynchronously diff --git a/tests/service/FscTests.fs b/tests/service/FscTests.fs index 2214efb4bd..c2ba5396c2 100644 --- a/tests/service/FscTests.fs +++ b/tests/service/FscTests.fs @@ -1,7 +1,7 @@ #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else diff --git a/tests/service/FsiTests.fs b/tests/service/FsiTests.fs index 1dbd15c288..5449d44114 100644 --- a/tests/service/FsiTests.fs +++ b/tests/service/FsiTests.fs @@ -1,7 +1,7 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else diff --git a/tests/service/InteractiveCheckerTests.fs b/tests/service/InteractiveCheckerTests.fs index 82aaefa5ad..e1ad86c2bf 100644 --- a/tests/service/InteractiveCheckerTests.fs +++ b/tests/service/InteractiveCheckerTests.fs @@ -1,7 +1,7 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -15,14 +15,14 @@ open Microsoft.FSharp.Compiler open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common -let longIdentToString (longIdent: Ast.LongIdent) = +let internal longIdentToString (longIdent: Ast.LongIdent) = String.Join(".", longIdent |> List.map (fun ident -> ident.ToString())) -let longIdentWithDotsToString (Ast.LongIdentWithDots (longIdent, _)) = longIdentToString longIdent +let internal longIdentWithDotsToString (Ast.LongIdentWithDots (longIdent, _)) = longIdentToString longIdent -let posToTuple (pos: Range.pos) = (pos.Line, pos.Column) -let rangeToTuple (range: Range.range) = (posToTuple range.Start, posToTuple range.End) +let internal posToTuple (pos: Range.pos) = (pos.Line, pos.Column) +let internal rangeToTuple (range: Range.range) = (posToTuple range.Start, posToTuple range.End) -let identsAndRanges (input: Ast.ParsedInput) = +let internal identsAndRanges (input: Ast.ParsedInput) = let identAndRange ident (range: Range.range) = (ident, rangeToTuple range) let extractFromComponentInfo (componentInfo: Ast.SynComponentInfo) = @@ -53,7 +53,7 @@ let identsAndRanges (input: Ast.ParsedInput) = modulesOrNamespaces |> List.collect extractFromModuleOrNamespace | Ast.ParsedInput.SigFile _ -> [] -let parseAndExtractRanges code = +let internal parseAndExtractRanges code = let file = "Test" let result = parseSourceCode (file, code) match result with @@ -69,7 +69,9 @@ let input = [] let ``Test ranges - namespace`` () = - parseAndExtractRanges input |> should equal [("N", ((4, 4), (5, 4))); ("Sample", ((4, 9), (4, 15)))] + let res = parseAndExtractRanges input + printfn "Test ranges - namespace, res = %A" res + res |> shouldEqual [("N", ((4, 4), (6, 0))); ("Sample", ((4, 9), (4, 15)))] let input2 = """ @@ -80,7 +82,9 @@ let input2 = [] let ``Test ranges - module`` () = - parseAndExtractRanges input2 |> should equal [("M", ((2, 4), (4, 26))); ("Sample", ((4, 9), (4, 15)))] + let res = parseAndExtractRanges input2 + printfn "Test ranges - module, res = %A" res + res |> shouldEqual [("M", ((2, 4), (4, 26))); ("Sample", ((4, 9), (4, 15)))] let input3 = """ @@ -91,4 +95,6 @@ let input3 = [] let ``Test ranges - global namespace`` () = - parseAndExtractRanges input3 |> should equal [("", ((4, 4), (5, 4))); ("Sample", ((4, 9), (4, 15)))] + let res = parseAndExtractRanges input3 + printfn "Test ranges - global namespace, res = %A" res + res |> shouldEqual [("", ((4, 4), (6, 0))); ("Sample", ((4, 9), (4, 15)))] diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index ff4dc0643f..583cf53081 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -1,8 +1,7 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -23,13 +22,13 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let numProjectsForStressTest = 100 -let checker = FSharpChecker.Create(projectCacheSize=numProjectsForStressTest + 10) +let internal checker = FSharpChecker.Create(projectCacheSize=numProjectsForStressTest + 10) /// Extract range info -let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn) +let internal tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn) -module Project1A = +module internal Project1A = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -58,7 +57,7 @@ let x2 = C.M(arg1 = 3, arg2 = 4, ?arg3 = Some 5) //----------------------------------------------------------------------------------------- -module Project1B = +module internal Project1B = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -86,7 +85,7 @@ let x = // A project referencing two sub-projects -module MultiProject1 = +module internal MultiProject1 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -122,6 +121,9 @@ let ``Test multi project 1 whole project errors`` () = let wholeProjectResults = checker.ParseAndCheckProject(MultiProject1.options) |> Async.RunSynchronously + for e in wholeProjectResults.Errors do + printfn "multi project 1 error: <<<%s>>>" e.Message + wholeProjectResults .Errors.Length |> shouldEqual 0 wholeProjectResults.ProjectContext.GetReferencedAssemblies().Length |> shouldEqual 6 @@ -255,6 +257,9 @@ let ``Test ManyProjectsStressTest whole project errors`` () = let wholeProjectResults = checker.ParseAndCheckProject(ManyProjectsStressTest.jointProject.Options) |> Async.RunSynchronously let wholeProjectResults = checker.ParseAndCheckProject(ManyProjectsStressTest.jointProject.Options) |> Async.RunSynchronously + for e in wholeProjectResults.Errors do + printfn "ManyProjectsStressTest error: <<<%s>>>" e.Message + wholeProjectResults .Errors.Length |> shouldEqual 0 wholeProjectResults.ProjectContext.GetReferencedAssemblies().Length |> shouldEqual (ManyProjectsStressTest.numProjectsForStressTest + 4) @@ -323,7 +328,7 @@ let ``Test ManyProjectsStressTest all symbols`` () = //----------------------------------------------------------------------------------------- -module MultiProjectDirty1 = +module internal MultiProjectDirty1 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -345,7 +350,7 @@ let x = "F#" let args = mkProjectCommandLineArgs (dllName, fileNames) checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) -module MultiProjectDirty2 = +module internal MultiProjectDirty2 = open System.IO @@ -541,7 +546,7 @@ let ``Test multi project symbols should pick up changes in dependent projects`` //------------------------------------------------------------------ -module Project2A = +module internal Project2A = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -571,7 +576,7 @@ type C() = //Project2A.fileSource1 // A project referencing Project2A -module Project2B = +module internal Project2B = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -596,7 +601,7 @@ let v = Project2A.C().InternalMember // access an internal symbol //Project2A.fileSource1 // A project referencing Project2A but without access to the internals of A -module Project2C = +module internal Project2C = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -623,6 +628,9 @@ let v = Project2A.C().InternalMember // access an internal symbol let ``Test multi project2 errors`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project2B.options) |> Async.RunSynchronously + for e in wholeProjectResults.Errors do + printfn "multi project2 error: <<<%s>>>" e.Message + wholeProjectResults .Errors.Length |> shouldEqual 0 @@ -658,7 +666,7 @@ let ``Test multi project 2 all symbols`` () = //------------------------------------------------------------------------------------ -module Project3A = +module internal Project3A = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -682,7 +690,7 @@ let (|DivisibleBy|_|) by n = // A project referencing a sub-project -module MultiProject3 = +module internal MultiProject3 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -715,6 +723,8 @@ let fizzBuzz = function let ``Test multi project 3 whole project errors`` () = let wholeProjectResults = checker.ParseAndCheckProject(MultiProject3.options) |> Async.RunSynchronously + for e in wholeProjectResults.Errors do + printfn "multi project 3 error: <<<%s>>>" e.Message wholeProjectResults.Errors.Length |> shouldEqual 0 @@ -761,19 +771,180 @@ let ``Test max memory gets triggered`` () = //------------------------------------------------------------------------------------ -#if FX_ATLEAST_45 +#if !DOTNETCORE [] let ``Type provider project references should not throw exceptions`` () = - let projectFile = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/TypeProviderConsole.fsproj" - let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) + //let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) + let options = + {ProjectFileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/TypeProviderConsole.fsproj"; + SourceFiles = [|__SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/Program.fs"|]; + Stamp = None + OtherOptions = + [|yield "--simpleresolution"; + yield "--noframework"; + yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/bin/Debug/TypeProviderConsole.exe"; + yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/bin/Debug/TypeProviderConsole.xml"; + yield "--subsystemversion:6.00"; + yield "--highentropyva+"; + yield "--fullpaths"; + yield "--flaterrors"; + yield "--target:exe"; + yield "--define:DEBUG"; + yield "--define:TRACE"; + yield "--debug+"; + yield "--optimize-"; + yield "--tailcalls-"; + yield "--debug:full"; + yield "--platform:anycpu"; + for r in mkStandardProjectReferences () do + yield "-r:" + r + yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll"|]; + ReferencedProjects = + [|(__SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll", + {ProjectFileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.fsproj"; + SourceFiles = [|__SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/Library1.fs"|]; + Stamp = None + OtherOptions = + [|yield "--simpleresolution"; + yield "--noframework"; + yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/TypeProviderLibrary.dll"; + yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/bin/Debug/TypeProviderLibrary.xml"; + yield "--subsystemversion:6.00"; + yield "--highentropyva+"; + yield "--fullpaths"; + yield "--flaterrors"; + yield "--target:library"; + yield "--define:DEBUG"; + yield "--define:TRACE"; + yield "--debug+"; + yield "--optimize-"; + yield "--tailcalls-"; + yield "--debug:full"; + yield "--platform:anycpu"; + for r in mkStandardProjectReferences () do + yield "-r:" + r + yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProviderLibrary/FSharp.Data.TypeProviders.dll"; + |]; + ReferencedProjects = [||]; + IsIncompleteTypeCheckEnvironment = false; + UseScriptResolutionRules = false; + LoadTime = System.DateTime.Now + UnresolvedReferences = None; + OriginalLoadReferences = []; + ExtraProjectInfo = None;})|]; + IsIncompleteTypeCheckEnvironment = false; + UseScriptResolutionRules = false; + LoadTime = System.DateTime.Now + UnresolvedReferences = None; + OriginalLoadReferences = []; + ExtraProjectInfo = None;} + //printfn "options: %A" options let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProviderConsole/Program.fs" let fileSource = File.ReadAllText(fileName) - let fileCheckResults, _ = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously - //printfn "Errors: %A" fileCheckResults.Errors + let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously + let fileCheckResults = + match fileCheckAnswer with + | FSharpCheckFileAnswer.Succeeded(res) -> res + | res -> failwithf "Parsing did not finish... (%A)" res + + printfn "Parse Errors: %A" fileParseResults.Errors + printfn "Errors: %A" fileCheckResults.Errors + fileCheckResults.Errors |> Array.exists (fun error -> error.Severity = FSharpErrorSeverity.Error) |> shouldEqual false + + + + +//------------------------------------------------------------------------------------ + +[] +let ``Projects creating generated types should not utilize cross-project-references but should still analyze oK once project is built`` () = + //let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Debug")]) + let options = + {ProjectFileName = + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/TestConsole.fsproj"; + SourceFiles = + [|__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/AssemblyInfo.fs"; + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/Program.fs"|]; + OtherOptions = + [|yield "--simpleresolution"; + yield "--noframework"; + yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/bin/Debug/TestConsole.exe"; + yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/bin/Debug/TestConsole.XML"; + yield "--subsystemversion:6.00"; + yield "--highentropyva+"; + yield "--fullpaths"; + yield "--flaterrors"; + yield "--target:exe"; + yield "--define:DEBUG"; + yield "--define:TRACE"; + yield "--debug+"; + yield "--optimize-"; + yield "--tailcalls-"; + yield "--debug:full"; + yield "--platform:anycpu"; + yield "-r:" + __SOURCE_DIRECTORY__ + @"/../../packages/FSharp.Configuration.1.3.0/lib/net45/FSharp.Configuration.dll"; + for r in mkStandardProjectReferences () do + yield "-r:" + r + yield "-r:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll"|]; + ReferencedProjects = + [|(__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll", + {ProjectFileName = + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/TypeProvidersBug.fsproj"; + SourceFiles = + [|__SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/AssemblyInfo.fs"; + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/Library1.fs"|]; + OtherOptions = + [|yield "--simpleresolution"; + yield "--noframework"; + yield "--out:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll"; + yield "--doc:" + __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.XML"; + yield "--subsystemversion:6.00"; + yield "--highentropyva+"; + yield "--fullpaths"; + yield "--flaterrors"; + yield "--target:library"; + yield "--define:DEBUG"; + yield "--define:TRACE"; + yield "--debug+"; + yield "--optimize-"; + yield "--tailcalls-"; + yield "--debug:full"; + yield "--platform:anycpu"; + yield "-r:" + __SOURCE_DIRECTORY__ + @"/../../packages/FSharp.Configuration.1.3.0/lib/net45/FSharp.Configuration.dll"; + for r in mkStandardProjectReferences () do + yield "-r:" + r |]; + ReferencedProjects = [||]; + IsIncompleteTypeCheckEnvironment = false; + UseScriptResolutionRules = false; + LoadTime = System.DateTime.Now + UnresolvedReferences = None; + OriginalLoadReferences = []; + Stamp = None; + ExtraProjectInfo = None;})|]; + IsIncompleteTypeCheckEnvironment = false; + UseScriptResolutionRules = false; + LoadTime = System.DateTime.Now + UnresolvedReferences = None; + Stamp = None; + OriginalLoadReferences = []; + ExtraProjectInfo = None;} + //printfn "options: %A" options + let fileName = __SOURCE_DIRECTORY__ + @"/data/TypeProvidersBug/TestConsole/Program.fs" + let fileSource = File.ReadAllText(fileName) + let fileParseResults, fileCheckAnswer = checker.ParseAndCheckFileInProject(fileName, 0, fileSource, options) |> Async.RunSynchronously + let fileCheckResults = + match fileCheckAnswer with + | FSharpCheckFileAnswer.Succeeded(res) -> res + | res -> failwithf "Parsing did not finish... (%A)" res + + printfn "Parse Errors: %A" fileParseResults.Errors + printfn "Errors: %A" fileCheckResults.Errors fileCheckResults.Errors |> Array.exists (fun error -> error.Severity = FSharpErrorSeverity.Error) |> shouldEqual false + + #endif //------------------------------------------------------------------------------------ diff --git a/tests/service/PerfTests.fs b/tests/service/PerfTests.fs index e3138706f8..f7510bb224 100644 --- a/tests/service/PerfTests.fs +++ b/tests/service/PerfTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -20,9 +20,9 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common // Create an interactive checker instance -let checker = FSharpChecker.Create() +let internal checker = FSharpChecker.Create() -module Project1 = +module internal Project1 = open System.IO let fileNamesI = [ for i in 1 .. 10 -> (i, Path.ChangeExtension(Path.GetTempFileName(), ".fs")) ] diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index bcdd482878..18da534dde 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -1,6 +1,6 @@ #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else @@ -20,7 +20,7 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common -module Project1 = +module internal Project1 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -619,7 +619,7 @@ let ``Test file explicit parse all symbols`` () = //----------------------------------------------------------------------------------------- -module Project2 = +module internal Project2 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -816,7 +816,7 @@ let ``Test project2 all uses of all symbols`` () = //----------------------------------------------------------------------------------------- -module Project3 = +module internal Project3 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1257,7 +1257,7 @@ let ``Test project3 all uses of all signature symbols`` () = //----------------------------------------------------------------------------------------- -module Project4 = +module internal Project4 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1412,7 +1412,7 @@ let ``Test project4 T symbols`` () = //----------------------------------------------------------------------------------------- -module Project5 = +module internal Project5 = open System.IO @@ -1632,7 +1632,7 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = //----------------------------------------------------------------------------------------- -module Project6 = +module internal Project6 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1686,7 +1686,7 @@ let ``Test project 6 all symbols`` () = //----------------------------------------------------------------------------------------- -module Project7 = +module internal Project7 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1748,7 +1748,7 @@ let ``Test project 7 all symbols`` () = //----------------------------------------------------------------------------------------- -module Project8 = +module internal Project8 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1833,7 +1833,7 @@ let ``Test project 8 all symbols`` () = (Some ((4, 14), (4, 17)), "file1", ((10, 9), (10, 12)))|] //----------------------------------------------------------------------------------------- -module Project9 = +module internal Project9 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1911,7 +1911,7 @@ let ``Test project 9 all symbols`` () = //----------------------------------------------------------------------------------------- // see https://github.com/fsharp/FSharp.Compiler.Service/issues/95 -module Project10 = +module internal Project10 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1994,7 +1994,7 @@ let ``Test Project10 all symbols`` () = //----------------------------------------------------------------------------------------- // see https://github.com/fsharp/FSharp.Compiler.Service/issues/92 -module Project11 = +module internal Project11 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2067,7 +2067,7 @@ let ``Test Project11 all symbols`` () = //----------------------------------------------------------------------------------------- // see https://github.com/fsharp/FSharp.Compiler.Service/issues/92 -module Project12 = +module internal Project12 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2136,7 +2136,7 @@ let ``Test Project12 all symbols`` () = //----------------------------------------------------------------------------------------- // Test fetching information about some external types (e.g. System.Object, System.DateTime) -module Project13 = +module internal Project13 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2288,7 +2288,7 @@ let ``Test Project13 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - structs -module Project14 = +module internal Project14 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2357,7 +2357,7 @@ let ``Test Project14 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - union patterns -module Project15 = +module internal Project15 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2417,7 +2417,7 @@ let ``Test Project15 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - signature files -module Project16 = +module internal Project16 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2691,7 +2691,7 @@ let ``Test Project16 sym locations`` () = //----------------------------------------------------------------------------------------- // Misc - namespace symbols -module Project17 = +module internal Project17 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2791,7 +2791,7 @@ let ``Test Project17 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - generic type definnitions -module Project18 = +module internal Project18 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2842,7 +2842,7 @@ let ``Test Project18 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - enums -module Project19 = +module internal Project19 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2921,7 +2921,7 @@ let ``Test Project19 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - https://github.com/fsharp/FSharp.Compiler.Service/issues/109 -module Project20 = +module internal Project20 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -2974,7 +2974,7 @@ let ``Test Project20 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - https://github.com/fsharp/FSharp.Compiler.Service/issues/137 -module Project21 = +module internal Project21 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3053,7 +3053,7 @@ let ``Test Project21 all symbols`` () = //----------------------------------------------------------------------------------------- // Misc - namespace symbols -module Project22 = +module internal Project22 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3193,7 +3193,7 @@ let ``Test Project22 IList properties`` () = //----------------------------------------------------------------------------------------- // Misc - properties -module Project23 = +module internal Project23 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3267,9 +3267,9 @@ let ``Test Project23 property`` () = extensionProps |> Array.collect (fun f -> [| if f.HasGetterMethod then - yield (f.EnclosingEntity.FullName, f.GetterMethod.CompiledName, f.GetterMethod.EnclosingEntity.FullName, attribsOfSymbol f) + yield (f.EnclosingEntity.Value.FullName, f.GetterMethod.CompiledName, f.GetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.EnclosingEntity.FullName, f.SetterMethod.CompiledName, f.SetterMethod.EnclosingEntity.FullName, attribsOfSymbol f) + yield (f.EnclosingEntity.Value.FullName, f.SetterMethod.CompiledName, f.SetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) |]) |> Array.toList @@ -3313,9 +3313,9 @@ let ``Test Project23 extension properties' getters/setters should refer to the c match x.Symbol with | :? FSharpMemberOrFunctionOrValue as f -> if f.HasGetterMethod then - yield (f.EnclosingEntity.FullName, f.GetterMethod.EnclosingEntity.FullName, attribsOfSymbol f) + yield (f.EnclosingEntity.Value.FullName, f.GetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) if f.HasSetterMethod then - yield (f.EnclosingEntity.FullName, f.SetterMethod.EnclosingEntity.FullName, attribsOfSymbol f) + yield (f.EnclosingEntity.Value.FullName, f.SetterMethod.EnclosingEntity.Value.FullName, attribsOfSymbol f) | _ -> () |]) |> Array.toList @@ -3326,7 +3326,7 @@ let ``Test Project23 extension properties' getters/setters should refer to the c ("System.Int32", "Impl.Getter", ["member"; "prop"; "extmem"]) ] // Misc - property symbols -module Project24 = +module internal Project24 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3628,7 +3628,7 @@ let ``Test symbol uses of properties with both getters and setters`` () = #if NO_CHECK_USE_OF_FSHARP_DATA_DLL #endif // Misc - type provider symbols -module Project25 = +module internal Project25 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3652,7 +3652,7 @@ let _ = XmlProvider<"13">.GetSample() let fileNames = [fileName1] let args = [| yield! mkProjectCommandLineArgs (dllName, fileNames) - yield "-r:" + Path.Combine(__SOURCE_DIRECTORY__, "FSharp.Data.dll") + yield @"-r:" + Path.Combine(__SOURCE_DIRECTORY__, Path.Combine("data", "FSharp.Data.dll")) yield @"-r:" + sysLib "System.Xml.Linq" |] let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) @@ -3672,7 +3672,7 @@ let ``Test Project25 whole project errors`` () = #else [] #endif -let ``Test symbol uses of type-provided members`` () = +let ``Test Project25 symbol uses of type-provided members`` () = let wholeProjectResults = checker.ParseAndCheckProject(Project25.options) |> Async.RunSynchronously let backgroundParseResults1, backgroundTypedParse1 = checker.GetBackgroundCheckResultsForFileInProject(Project25.fileName1, Project25.options) @@ -3769,7 +3769,7 @@ let ``Test symbol uses of fully-qualified records`` () = usesOfGetSampleSymbol |> shouldEqual [|("file1", ((7, 5), (7, 11))); ("file1", ((8, 10), (8, 16)))|] -module Project26 = +module internal Project26 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3857,7 +3857,7 @@ let ``Test Project26 parameter symbols`` () = ("M2", None, "type Microsoft.FSharp.Core.unit", ""); ("M3", None, "type Microsoft.FSharp.Core.unit", "")]) -module Project27 = +module internal Project27 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -3903,7 +3903,7 @@ let ``Test project27 all symbols in signature`` () = ("member .ctor", ["member"; "ctor"]); ("member AbstractMethod", ["member"; "overridemem"])] -module Project28 = +module internal Project28 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4006,7 +4006,7 @@ let ``Test project28 all symbols in signature`` () = ("FSharpMemberOrFunctionOrValue", "Test", "M:M.Use.Test``1(``0)"); ("FSharpGenericParameter", "?", "")|] #endif -module Project29 = +module internal Project29 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4063,7 +4063,7 @@ let ``Test project29 event symbols`` () = ("remove_PropertyChanged", None, "unit")]) -module Project30 = +module internal Project30 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4124,7 +4124,7 @@ let ``Test project30 Format attributes`` () = [("""[]""", """[]""")]) -module Project31 = +module internal Project31 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4242,7 +4242,7 @@ let ``Test project31 Format C# method attributes`` () = #endif ]) -module Project32 = +module internal Project32 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4315,7 +4315,7 @@ let ``Test Project32 should be able to find impl symbols`` () = [("sig1", ((4, 4), (4, 8)), ["val"]); ("file1", ((3, 4), (3, 8)), ["val"])] -module Project33 = +module internal Project33 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4361,7 +4361,7 @@ let ``Test Project33 extension methods`` () = [("SetValue", ["member"; "extmem"]); ("GetValue", ["member"; "extmem"])] -module Project34 = +module internal Project34 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4380,7 +4380,7 @@ module Dummy yield! mkProjectCommandLineArgs (dllName, fileNames) // We use .NET-buit version of System.Data.dll since the tests depend on implementation details // i.e. the private type System.Data.Listeners may not be available on Mono. - yield @"-r:" + Path.Combine(__SOURCE_DIRECTORY__, "System.Data.dll") + yield @"-r:" + Path.Combine(__SOURCE_DIRECTORY__, Path.Combine("data", "System.Data.dll")) |] let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) @@ -4423,7 +4423,7 @@ let ``Test project34 should report correct accessibility for System.Data.Listene //------------------------------------------------------ -module Project35 = +module internal Project35 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4501,7 +4501,7 @@ let ``Test project35 CurriedParameterGroups should be available for nested funct //------------------------------------------------------ -module Project35b = +module internal Project35b = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fsx") @@ -4520,7 +4520,7 @@ module Project35b = let args2 = Array.append args [| "-r:notexist.dll" |] let options = checker.GetProjectOptionsFromCommandLineArgs (projPath, args2) #else - let internal options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously |> fst + let options = checker.GetProjectOptionsFromScript(fileName1, fileSource1) |> Async.RunSynchronously |> fst #endif [] @@ -4555,7 +4555,7 @@ let ``Test project35b Dependency files for check of project`` () = //------------------------------------------------------ -module Project36 = +module internal Project36 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4653,7 +4653,7 @@ let ``Test project36 FSharpMemberOrFunctionOrValue.LiteralValue`` () = let notLit = project36Module.MembersFunctionsAndValues.[1] shouldEqual true notLit.LiteralValue.IsNone -module Project37 = +module internal Project37 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4756,7 +4756,7 @@ let ``Test project37 typeof and arrays in attribute constructor arguments`` () = //----------------------------------------------------------- -module Project38 = +module internal Project38 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4854,7 +4854,7 @@ let ``Test project38 abstract slot information`` () = //-------------------------------------------- -module Project39 = +module internal Project39 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4935,7 +4935,7 @@ let ``Test project39 all symbols`` () = //-------------------------------------------- -module Project40 = +module internal Project40 = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -4999,7 +4999,7 @@ let ``Test Project40 all symbols`` () = ("g", ((13, 4), (13, 5)), ["val"]); ("M", ((2, 7), (2, 8)), ["module"])] -module ProjectBig = +module internal ProjectBig = open System.IO let fileNamesI = [ for i in 1 .. 10 -> (i, Path.ChangeExtension(Path.GetTempFileName(), ".fs")) ] @@ -5086,7 +5086,7 @@ let ``add files with same name from different folders`` () = printfn "ERROR: %s" err.Message shouldEqual 0 errors.Length -module ProjectStructUnions = +module internal ProjectStructUnions = open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -5132,3 +5132,45 @@ let ``Test typed AST for struct unions`` () = // See https://github.com/fsharp/F when uci.Name = "Ok" && obj.Equals(trueValue, true) && obj.Equals(falseValue, false) -> true | _ -> failwith "unexpected expression" |> shouldEqual true + +module internal ProjectLineDirectives = + open System.IO + + let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") + let base2 = Path.GetTempFileName() + let dllName = Path.ChangeExtension(base2, ".dll") + let projFileName = Path.ChangeExtension(base2, ".fsproj") + let fileSource1 = """ +module M + +# 10 "Test.fsy" +let x = (1 = 3.0) + """ + + File.WriteAllText(fileName1, fileSource1) + let fileNames = [fileName1] + let args = mkProjectCommandLineArgs (dllName, fileNames) + let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) + +[] +let ``Test line directives in foreground analysis`` () = // see https://github.com/Microsoft/visualfsharp/issues/3317 + + // In background analysis and normal compiler checking, the errors are reported w.r.t. the line directives + let wholeProjectResults = checker.ParseAndCheckProject(ProjectLineDirectives.options) |> Async.RunSynchronously + for e in wholeProjectResults.Errors do + printfn "ProjectLineDirectives wholeProjectResults error file: <<<%s>>>" e.FileName + + [ for e in wholeProjectResults.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(10, 10, "Test.fsy")] + + // In foreground analysis routines, used by visual editing tools, the errors are reported w.r.t. the source + // file, which is assumed to be in the editor, not the other files referred to by line directives. + let checkResults1 = + checker.ParseAndCheckFileInProject(ProjectLineDirectives.fileName1, 0, ProjectLineDirectives.fileSource1, ProjectLineDirectives.options) + |> Async.RunSynchronously + |> function (_,FSharpCheckFileAnswer.Succeeded x) -> x | _ -> failwith "unexpected aborted" + + for e in checkResults1.Errors do + printfn "ProjectLineDirectives checkResults1 error file: <<<%s>>>" e.FileName + + [ for e in checkResults1.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(4, 4, ProjectLineDirectives.fileName1)] + diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index 93edb73b95..7595d0b08b 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -1,7 +1,7 @@ #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' to generate this, this DLL has a public API so can be used from F# Interactive +#r "../../Debug/net40/bin/FSharp.Compiler.Service.ProjectCracker.dll" +#r "../../packages/NUnit.3.5.0/lib/net45/nunit.framework.dll" #load "FsUnit.fs" #load "Common.fs" #else @@ -18,7 +18,6 @@ open Microsoft.FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common -#if FX_ATLEAST_45 #if !NO_PROJECTCRACKER let normalizePath s = (new Uri(s)).LocalPath @@ -45,12 +44,13 @@ let getCompiledFilenames = else None) >> Array.distinct +(* [] -let ``Project file parsing example 1 Default Configuration`` () = + let ``Project file parsing example 1 Default Configuration`` () = let projectFile = __SOURCE_DIRECTORY__ + @"/FSharp.Compiler.Service.Tests.fsproj" let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile) - checkOption options.ProjectFileNames "FileSystemTests.fs" + checkOption options.SourceFiles "FileSystemTests.fs" checkOption options.OtherOptions "FSharp.Compiler.Service.dll" checkOption options.OtherOptions "--define:TRACE" @@ -65,7 +65,7 @@ let ``Project file parsing example 1 Release Configuration`` () = // Check with Configuration = Release let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile, [("Configuration", "Release")]) - checkOption options.ProjectFileNames "FileSystemTests.fs" + checkOption options.SourceFiles "FileSystemTests.fs" checkOption options.OtherOptions "FSharp.Compiler.Service.dll" checkOption options.OtherOptions "--define:TRACE" @@ -78,7 +78,7 @@ let ``Project file parsing example 1 Default configuration relative path`` () = Directory.SetCurrentDirectory(__SOURCE_DIRECTORY__) let options = ProjectCracker.GetProjectOptionsFromProjectFile(projectFile) - checkOption options.ProjectFileNames "FileSystemTests.fs" + checkOption options.SourceFiles "FileSystemTests.fs" checkOption options.OtherOptions "FSharp.Compiler.Service.dll" checkOption options.OtherOptions "--define:TRACE" @@ -86,6 +86,7 @@ let ``Project file parsing example 1 Default configuration relative path`` () = checkOption options.OtherOptions "--flaterrors" checkOption options.OtherOptions "--simpleresolution" checkOption options.OtherOptions "--noframework" +*) [] let ``Project file parsing VS2013_FSharp_Portable_Library_net45``() = @@ -123,14 +124,14 @@ let ``Project file parsing Sample_VS2013_FSharp_Portable_Library_net451_adjusted [] let ``Project file parsing -- compile files 1``() = let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test1.fsproj") - CollectionAssert.AreEqual (["Test1File2.fs"; "Test1File1.fs"], opts.ProjectFileNames |> Array.map Path.GetFileName) + CollectionAssert.AreEqual (["Test1File2.fs"; "Test1File1.fs"], opts.SourceFiles |> Array.map Path.GetFileName) CollectionAssert.IsEmpty (getCompiledFilenames opts.OtherOptions) [] let ``Project file parsing -- compile files 2``() = let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test2.fsproj") - CollectionAssert.AreEqual (["Test2File2.fs"; "Test2File1.fs"], opts.ProjectFileNames |> Array.map Path.GetFileName) + CollectionAssert.AreEqual (["Test2File2.fs"; "Test2File1.fs"], opts.SourceFiles |> Array.map Path.GetFileName) CollectionAssert.IsEmpty (getCompiledFilenames opts.OtherOptions) [] @@ -150,7 +151,7 @@ let ``Project file parsing -- output file``() = let p = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Test1.fsproj") let expectedOutputPath = - normalizePath (__SOURCE_DIRECTORY__ + "/data/Test1/bin/Debug/Test1.dll") + normalizePath (__SOURCE_DIRECTORY__ + "/data/bin/Debug/Test1.dll") p.OtherOptions |> getOutputFile @@ -372,6 +373,7 @@ let ``Project file parsing -- PCL profile259 project``() = checkOption options.OtherOptions "--targetprofile:netcore" +(* [] let ``Project file parsing -- Exe with a PCL reference``() = @@ -391,7 +393,7 @@ let ``Project file parsing -- Exe with a PCL reference``() = references |> should contain "mscorlib.dll" references |> should contain "System.Reflection.dll" references |> should contain "System.Reflection.Emit.Lightweight.dll" - +*) [] let ``Project file parsing -- project file contains project reference to out-of-solution project and is used in release mode``() = @@ -413,7 +415,7 @@ let ``Project file parsing -- project file contains project reference to out-of- [] let ``Project file parsing -- space in file name``() = let opts = ProjectCracker.GetProjectOptionsFromProjectFile(__SOURCE_DIRECTORY__ + @"/data/Space in name.fsproj") - CollectionAssert.AreEqual (["Test2File2.fs"; "Test2File1.fs"], opts.ProjectFileNames |> Array.map Path.GetFileName) + CollectionAssert.AreEqual (["Test2File2.fs"; "Test2File1.fs"], opts.SourceFiles |> Array.map Path.GetFileName) CollectionAssert.IsEmpty (getCompiledFilenames opts.OtherOptions) [] @@ -461,14 +463,14 @@ let ``Test OtherOptions order for GetProjectOptionsFromScript`` () = #endif [] -let ``Test ProjectFileNames order for GetProjectOptionsFromScript`` () = // See #594 +let ``Test SourceFiles order for GetProjectOptionsFromScript`` () = // See #594 let test scriptName expected = let scriptPath = __SOURCE_DIRECTORY__ + @"/data/ScriptProject/" + scriptName + ".fsx" let scriptSource = File.ReadAllText scriptPath let projOpts, _diagnostics = checker.GetProjectOptionsFromScript(scriptPath, scriptSource) |> Async.RunSynchronously - projOpts.ProjectFileNames + projOpts.SourceFiles |> Array.map Path.GetFileNameWithoutExtension |> shouldEqual expected test "Main1" [|"BaseLib1"; "Lib1"; "Lib2"; "Main1"|] @@ -477,7 +479,6 @@ let ``Test ProjectFileNames order for GetProjectOptionsFromScript`` () = // See test "Main4" [|"BaseLib2"; "Lib5"; "BaseLib1"; "Lib1"; "Lib2"; "Main4"|] test "MainBad" [|"MainBad"|] -#endif diff --git a/tests/service/TokenizerTests.fs b/tests/service/TokenizerTests.fs index af9bcdefb0..105f55a202 100644 --- a/tests/service/TokenizerTests.fs +++ b/tests/service/TokenizerTests.fs @@ -1,7 +1,7 @@  #if INTERACTIVE -#r "../../bin/v4.5/FSharp.Compiler.Service.dll" -#r "../../packages/NUnit/lib/nunit.framework.dll" +#r "../../Debug/net40/bin/FSharp.Compiler.Service.dll" // note, run 'build fcs' 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" #load "FsUnit.fs" #load "Common.fs" #else diff --git a/tests/service/data/CSharp_Analysis/CSharp_Analysis.csproj b/tests/service/data/CSharp_Analysis/CSharp_Analysis.csproj index 31b1673143..cfd59b04c4 100644 --- a/tests/service/data/CSharp_Analysis/CSharp_Analysis.csproj +++ b/tests/service/data/CSharp_Analysis/CSharp_Analysis.csproj @@ -11,7 +11,7 @@ CSharp_Analysis v4.5 ..\..\..\..\ - ..\..\..\..\bin\$(TargetFrameworkVersion)\ + ..\..\..\..\$(Configuration)\net40\bin 512 @@ -44,13 +44,6 @@ - diff --git a/tests/service/data/DifferingOutputDir/Dir1/OutputDir1/FSharp.Core.dll b/tests/service/data/DifferingOutputDir/Dir1/OutputDir1/FSharp.Core.dll index a8ab078271..ae969cedb0 100644 Binary files a/tests/service/data/DifferingOutputDir/Dir1/OutputDir1/FSharp.Core.dll and b/tests/service/data/DifferingOutputDir/Dir1/OutputDir1/FSharp.Core.dll differ diff --git a/tests/service/data/DifferingOutputDir/Dir1/Test1.fsproj b/tests/service/data/DifferingOutputDir/Dir1/Test1.fsproj index 2fb4f14259..4b09f770c4 100644 --- a/tests/service/data/DifferingOutputDir/Dir1/Test1.fsproj +++ b/tests/service/data/DifferingOutputDir/Dir1/Test1.fsproj @@ -11,7 +11,6 @@ Test1 Test1 False - 4.3.0.0 11 @@ -37,8 +36,8 @@ False - - True + + ..\..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -48,26 +47,7 @@ - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/DifferingOutputDir/Dir2/OutputDir2/FSharp.Core.dll b/tests/service/data/DifferingOutputDir/Dir2/OutputDir2/FSharp.Core.dll index a8ab078271..ae969cedb0 100644 Binary files a/tests/service/data/DifferingOutputDir/Dir2/OutputDir2/FSharp.Core.dll and b/tests/service/data/DifferingOutputDir/Dir2/OutputDir2/FSharp.Core.dll differ diff --git a/tests/service/data/DifferingOutputDir/Dir2/Test2.fsproj b/tests/service/data/DifferingOutputDir/Dir2/Test2.fsproj index 8641aa79d4..acbb5896d9 100644 --- a/tests/service/data/DifferingOutputDir/Dir2/Test2.fsproj +++ b/tests/service/data/DifferingOutputDir/Dir2/Test2.fsproj @@ -11,7 +11,6 @@ Test2 Test2 False - 4.3.0.0 11 @@ -37,8 +36,8 @@ False - - True + + ..\..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -54,26 +53,7 @@ Test1 - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/FSharp.Data.DesignTime.dll b/tests/service/data/FSharp.Data.DesignTime.dll new file mode 100644 index 0000000000..fca7289ce5 Binary files /dev/null and b/tests/service/data/FSharp.Data.DesignTime.dll differ diff --git a/tests/service/data/FSharp.Data.dll b/tests/service/data/FSharp.Data.dll new file mode 100644 index 0000000000..39353541ee Binary files /dev/null and b/tests/service/data/FSharp.Data.dll differ diff --git a/tests/service/data/MultiLanguageProject/ConsoleApplication1.fsproj b/tests/service/data/MultiLanguageProject/ConsoleApplication1.fsproj index 9dd21cfec7..47cb586c54 100644 --- a/tests/service/data/MultiLanguageProject/ConsoleApplication1.fsproj +++ b/tests/service/data/MultiLanguageProject/ConsoleApplication1.fsproj @@ -11,7 +11,6 @@ ConsoleApplication1 v4.5 true - 4.3.1.0 ConsoleApplication1 @@ -39,8 +38,8 @@ - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -64,26 +63,7 @@ 11 - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/MultiLanguageProject/ConsoleApplication2.fsproj b/tests/service/data/MultiLanguageProject/ConsoleApplication2.fsproj index 4656ec88d6..8272c08527 100644 --- a/tests/service/data/MultiLanguageProject/ConsoleApplication2.fsproj +++ b/tests/service/data/MultiLanguageProject/ConsoleApplication2.fsproj @@ -11,7 +11,6 @@ ConsoleApplication2 v4.5 true - 4.3.1.0 ConsoleApplication2 @@ -39,8 +38,8 @@ - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -56,29 +55,7 @@ True - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/Space in name.fsproj b/tests/service/data/Space in name.fsproj index 8b98da133e..90dcd2ca1f 100644 --- a/tests/service/data/Space in name.fsproj +++ b/tests/service/data/Space in name.fsproj @@ -11,15 +11,13 @@ Test2 Test2 False - 4.3.0.0 - 11 + ..\..\..\$(Configuration)\net40\bin True full False False - Test2\bin\Debug\ DEBUG;TRACE 3 x86 @@ -29,7 +27,6 @@ pdbonly True True - Test2\bin\Release\ TRACE 3 x86 @@ -37,8 +34,8 @@ False - - True + + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -54,26 +51,7 @@ Test1 - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/System.Data.dll b/tests/service/data/System.Data.dll new file mode 100644 index 0000000000..6c657f1212 Binary files /dev/null and b/tests/service/data/System.Data.dll differ diff --git a/tests/service/data/Test1.fsproj b/tests/service/data/Test1.fsproj index 49ba26e345..b20f9e1b98 100644 --- a/tests/service/data/Test1.fsproj +++ b/tests/service/data/Test1.fsproj @@ -9,9 +9,8 @@ Library Test1 Test1 - Test1 + bin\$(Configuration)\ False - 4.3.0.0 11 @@ -19,7 +18,6 @@ full False False - Test1\bin\Debug\ DEBUG;TRACE 3 x86 @@ -29,7 +27,6 @@ pdbonly True True - Test1\bin\Release\ TRACE 3 x86 @@ -37,8 +34,8 @@ False - - True + + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -48,26 +45,7 @@ - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/Test2.fsproj b/tests/service/data/Test2.fsproj index 8b98da133e..542c3f1773 100644 --- a/tests/service/data/Test2.fsproj +++ b/tests/service/data/Test2.fsproj @@ -6,12 +6,12 @@ 8.0.30703 2.0 {116cc2f9-f987-4b3d-915a-34cac04a73db} + ..\..\..\$(Configuration)\net40\bin Exe Test2 Test2 Test2 False - 4.3.0.0 11 @@ -19,7 +19,6 @@ full False False - Test2\bin\Debug\ DEBUG;TRACE 3 x86 @@ -29,7 +28,6 @@ pdbonly True True - Test2\bin\Release\ TRACE 3 x86 @@ -37,8 +35,8 @@ False - - True + + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -54,26 +52,7 @@ Test1 - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/TestProject/TestProject.fsproj b/tests/service/data/TestProject/TestProject.fsproj index e57dbfd706..df1d31bc0f 100644 --- a/tests/service/data/TestProject/TestProject.fsproj +++ b/tests/service/data/TestProject/TestProject.fsproj @@ -10,7 +10,6 @@ TestProject TestProject v4.5 - 4.3.0.0 true TestProject @@ -35,8 +34,11 @@ - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + + + ..\TestTP\TestTP.dll @@ -52,35 +54,8 @@ {887630a3-4b1d-40ea-b8b3-2d842e9c40db} True - - TestTP - {ff76bd3c-5e0a-4752-b6c3-044f6e15719b} - True - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/TestTP/ProvidedTypes.fs b/tests/service/data/TestTP/ProvidedTypes.fs index 5cf2954749..51cdb0bddd 100644 --- a/tests/service/data/TestTP/ProvidedTypes.fs +++ b/tests/service/data/TestTP/ProvidedTypes.fs @@ -494,7 +494,7 @@ module internal Misc = else Some (args.[1], args.[1]) ) - |> Seq.nth (n - 1) + |> Seq.item (n - 1) let adaptMethod = getFastFuncType args resultType let adapted = E.Call(adaptMethod, [loop applicable]) diff --git a/tests/service/data/TestTP/TestTP.dll b/tests/service/data/TestTP/TestTP.dll new file mode 100644 index 0000000000..0b3e3fd7a1 Binary files /dev/null and b/tests/service/data/TestTP/TestTP.dll differ diff --git a/tests/service/data/TestTP/TestTP.fsproj b/tests/service/data/TestTP/TestTP.fsproj index a91944fbcd..c43781066b 100644 --- a/tests/service/data/TestTP/TestTP.fsproj +++ b/tests/service/data/TestTP/TestTP.fsproj @@ -1,6 +1,9 @@  - + + $(MSBuildProjectDirectory)\..\..\..\..\src + + Debug AnyCPU @@ -11,9 +14,8 @@ TestTP v4.5 true - 4.3.0.0 TestTP - ..\..\..\..\bin\$(TargetFrameworkVersion)\ + ..\..\..\..\$(Configuration)\net40\bin @@ -37,22 +39,6 @@ bin\Release\TestTP.xml true - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - @@ -60,8 +46,8 @@ - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -74,13 +60,6 @@ True - @@ -92,4 +71,5 @@ + \ No newline at end of file diff --git a/tests/service/data/ToolsVersion12.fsproj b/tests/service/data/ToolsVersion12.fsproj index 05147ba3cd..6ed8fdc84a 100644 --- a/tests/service/data/ToolsVersion12.fsproj +++ b/tests/service/data/ToolsVersion12.fsproj @@ -10,7 +10,6 @@ Main Main v4.5.1 - 4.3.1.0 Main @@ -44,26 +43,7 @@ 11 - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/TypeProviderConsole/TypeProviderConsole.fsproj b/tests/service/data/TypeProviderConsole/TypeProviderConsole.fsproj index 06f3710c4d..152b3b4050 100644 --- a/tests/service/data/TypeProviderConsole/TypeProviderConsole.fsproj +++ b/tests/service/data/TypeProviderConsole/TypeProviderConsole.fsproj @@ -11,7 +11,6 @@ TypeProviderConsole v4.5 true - 4.3.1.0 TypeProviderConsole @@ -39,8 +38,8 @@ - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll @@ -56,29 +55,7 @@ True - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - + diff --git a/tests/service/data/TypeProviderLibrary/FSharp.Core.dll b/tests/service/data/TypeProviderLibrary/FSharp.Core.dll index 86b505d20c..ae969cedb0 100644 Binary files a/tests/service/data/TypeProviderLibrary/FSharp.Core.dll and b/tests/service/data/TypeProviderLibrary/FSharp.Core.dll differ diff --git a/tests/service/data/TypeProviderLibrary/Library1.fs b/tests/service/data/TypeProviderLibrary/Library1.fs index e6fb2da6a6..ae9e9a1d78 100644 --- a/tests/service/data/TypeProviderLibrary/Library1.fs +++ b/tests/service/data/TypeProviderLibrary/Library1.fs @@ -4,7 +4,22 @@ open Microsoft.FSharp.Core.CompilerServices open System [] -type FakeTypeProvider() = class end +type FakeTypeProvider() = + interface ITypeProvider with + member this.GetStaticParameters _ = [||] + member this.ApplyStaticArguments(_,_,_) = raise <| System.InvalidOperationException() + member this.GetNamespaces() = [| |] + member this.GetInvokerExpression(_,_) = failwith "GetInvokerExpression" + [] + member this.Invalidate = (new Event<_,_>()).Publish + member this.GetGeneratedAssemblyContents(assembly) = failwith "GetGeneratedAssemblyContents" + + interface ITypeProvider2 with + member this.GetStaticParametersForMethod _ = [||] + member this.ApplyStaticArgumentsForMethod(_,_,_) = raise <| System.InvalidOperationException() + + interface IDisposable with + member __.Dispose() = () [] do() diff --git a/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.dll b/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.dll new file mode 100644 index 0000000000..7dd893d01f Binary files /dev/null and b/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.dll differ diff --git a/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.fsproj b/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.fsproj index e7e04e5496..97a31290bf 100644 --- a/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.fsproj +++ b/tests/service/data/TypeProviderLibrary/TypeProviderLibrary.fsproj @@ -10,7 +10,6 @@ TypeProviderLibrary TypeProviderLibrary v4.5 - 4.3.1.0 TypeProviderLibrary @@ -33,50 +32,16 @@ bin\Release\TypeProviderLibrary.xml - + + + - - True + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll - - - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - ..\..\..\..\packages\NUnit\lib\nunit.framework.dll - True - True - - - - + \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TestConsole/App.config b/tests/service/data/TypeProvidersBug/TestConsole/App.config new file mode 100644 index 0000000000..8324aa6ff1 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TestConsole/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TestConsole/AssemblyInfo.fs b/tests/service/data/TypeProvidersBug/TestConsole/AssemblyInfo.fs new file mode 100644 index 0000000000..7f520374db --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TestConsole/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace TestConsole.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TestConsole/Program.fs b/tests/service/data/TypeProvidersBug/TestConsole/Program.fs new file mode 100644 index 0000000000..9b1e9f0ce9 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TestConsole/Program.fs @@ -0,0 +1,5 @@ + +[] +let main _ = + let foo: string = TypeProvidersBug.Test.config.Foo + 0 \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TestConsole/TestConsole.fsproj b/tests/service/data/TypeProvidersBug/TestConsole/TestConsole.fsproj new file mode 100644 index 0000000000..62b286c394 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TestConsole/TestConsole.fsproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + 2.0 + 247653e8-fba7-419b-8b7a-8b17ebfe2969 + Exe + TestConsole + TestConsole + v4.6 + true + TestConsole + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + AnyCPU + bin\Debug\TestConsole.XML + true + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + AnyCPU + bin\Release\TestConsole.XML + true + + + + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + + + TypeProvidersBug + {7b36cdd5-14f3-42f0-8118-c279d2315a22} + True + + + ..\..\..\..\..\packages\FSharp.Configuration.1.3.0\lib\net45\FSharp.Configuration.dll + True + + + + \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TypeProvidersBug/AssemblyInfo.fs b/tests/service/data/TypeProvidersBug/TypeProvidersBug/AssemblyInfo.fs new file mode 100644 index 0000000000..5552b38496 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TypeProvidersBug/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace TypeProvidersBug.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TypeProvidersBug/Library1.fs b/tests/service/data/TypeProvidersBug/TypeProvidersBug/Library1.fs new file mode 100644 index 0000000000..531e89d846 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TypeProvidersBug/Library1.fs @@ -0,0 +1,7 @@ +module TypeProvidersBug.Test + +open FSharp.Configuration + +type Configuration = YamlConfig + +let config = Configuration() diff --git a/tests/service/data/TypeProvidersBug/TypeProvidersBug/TypeProvidersBug.fsproj b/tests/service/data/TypeProvidersBug/TypeProvidersBug/TypeProvidersBug.fsproj new file mode 100644 index 0000000000..269197b153 --- /dev/null +++ b/tests/service/data/TypeProvidersBug/TypeProvidersBug/TypeProvidersBug.fsproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + 2.0 + 7b36cdd5-14f3-42f0-8118-c279d2315a22 + Library + TypeProvidersBug + TypeProvidersBug + v4.6 + true + TypeProvidersBug + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\TypeProvidersBug.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\TypeProvidersBug.XML + + + + + + + + + + + + ..\..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + + + ..\..\..\..\..\packages\FSharp.Configuration.1.3.0\lib\net45\FSharp.Configuration.dll + True + + + + \ No newline at end of file diff --git a/tests/service/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll b/tests/service/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll new file mode 100644 index 0000000000..8e73750a86 Binary files /dev/null and b/tests/service/data/TypeProvidersBug/TypeProvidersBug/bin/Debug/TypeProvidersBug.dll differ diff --git a/tests/service/data/sqlite-net-spike/sqlite-net-spike.fsproj b/tests/service/data/sqlite-net-spike/sqlite-net-spike.fsproj index 8a51f486cc..f44347902b 100644 --- a/tests/service/data/sqlite-net-spike/sqlite-net-spike.fsproj +++ b/tests/service/data/sqlite-net-spike/sqlite-net-spike.fsproj @@ -36,7 +36,9 @@ - + + ..\..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + @@ -44,7 +46,7 @@ - +