diff --git a/.gitignore b/.gitignore
index 1c8ca3d8c9c..b1a739b148d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,8 @@ src/fsharp/FSharp.Compiler/*.userprefs
src/*.log
Debug
Release
+vsdebug
+vsrelease
Proto
.libs
Makefile
@@ -94,4 +96,10 @@ tests/fsharpqa/Source/CodeGen/EmittedIL/QueryExpressionStepping/Utils.dll
tests/fsharpqa/Source/CodeGen/EmittedIL/ComputationExpressions/ComputationExprLibrary.dll
*.csproj.user
+
+*.ide
+*.log
+*.jrs
+*.chk
+*.bak
*.orig
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1ec7018de4f..ae07beb021a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,51 +4,186 @@
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] - 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`
+ 
+* 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
-* Ship versions FSharp.Core.dll built on portable profiles 78 and 259
* Bugfix [#91](https://visualfsharp.codeplex.com/workitem/91): String module documentation is false
-* Support "shebang" (`#!`) in F# source files
* Bugfix [#78](https://visualfsharp.codeplex.com/workitem/78): Allow space characters in active pattern case identifiers
-* Vertical pipes disallowed 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
-* Enable non-locking shadow copy of reference assemblies in fsi/fsianycpu
-* Inline codegen optimization using structs
-* Perf improvement for `Seq.windowed`
* 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
-* exe.config files for fsc, fsi, fsianycpu now use simple version range instead of long set of explicit version redirects
* 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
-* Project templates for F# portable libraries targeting profiles 78 and 259
* Bugfix: Typos in tutorial project script
-* 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: Required C# event members do not appear in intellisense when signature is (object, byref)
@@ -63,12 +198,12 @@ All notable changes to this project will be documented in this file.
#### Visual Studio
-* Bugfix: Errors when attempting to add reference to .NET core library
-* Bugfix: Crash in `FSComp.SR.RunStartupValidation()`
* 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
index 8d9bb430d06..257bceef898 100644
--- a/DEVGUIDE.md
+++ b/DEVGUIDE.md
@@ -10,7 +10,7 @@ To get a free F# environment, go to [fsharp.org](http://fsharp.org/use/windows).
> Contributions made to this repo are subject to terms and conditions of the Apache License, Version 2.0. A copy of the license can be found in the [License.txt](License.txt) 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.
-**Questions?** If you have questions about the source code, please ask in the issues and discussion forums.
+**Questions?** If you have questions about the source code, please ask in the issues.
## 0. A Shortcut to Build and Smoke Test
@@ -33,10 +33,8 @@ Note that you need the .NET framework 3.5 installed on your machine in order to
This uses the proto compiler to build `FSharp.Core.dll`, `FSharp.Compiler.dll`, `fsc.exe`, and `fsi.exe`.
-```
-msbuild src/fsharp-library-build.proj
-msbuild src/fsharp-compiler-build.proj
-```
+ msbuild src/fsharp-library-build.proj
+ msbuild src/fsharp-compiler-build.proj
You can now use the updated F# compiler in `debug\net40\bin\fsc.exe` and F# Interactive in `debug\net40\bin\fsi.exe` to develop and test basic language and tool features.
@@ -48,73 +46,81 @@ See [TESTGUIDE.md](TESTGUIDE.md) for full details on how to run tests.
Prior to a **Debug** test run, you need to complete **all** of these steps:
-```
-msbuild src/fsharp-library-build.proj
-msbuild src/fsharp-compiler-build.proj
-msbuild src/fsharp-typeproviders-build.proj
-msbuild src/fsharp-library-build.proj /p:TargetFramework=net20
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259
-msbuild src/fsharp-library-unittests-build.proj
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259
-src\update.cmd debug -ngen
-tests\BuildTestTools.cmd debug
-```
+ msbuild src/fsharp-library-build.proj
+ msbuild src/fsharp-compiler-build.proj
+ msbuild src/fsharp-typeproviders-build.proj
+ msbuild src/fsharp-compiler-unittests-build.proj
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=net20
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259
+ msbuild src/fsharp-library-unittests-build.proj
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259
+ src\update.cmd debug -ngen
+ tests\BuildTestTools.cmd debug
+
[Optional] If testing the Visual Studio bits (see below) you will also need:
-```
-msbuild vsintegration\fsharp-vsintegration-build.proj
-msbuild vsintegration\fsharp-vsintegration-unittests-build.proj
-```
+ msbuild vsintegration\fsharp-vsintegration-build.proj
+ msbuild vsintegration\fsharp-vsintegration-unittests-build.proj
Prior to a **Release** test run, you need to do **all** of these:
-```
-msbuild src/fsharp-library-build.proj /p:Configuration=Release
-msbuild src/fsharp-compiler-build.proj /p:Configuration=Release
-msbuild src/fsharp-typeproviders-build.proj /p:Configuration=Release
-msbuild src/fsharp-library-build.proj /p:TargetFramework=net20 /p:Configuration=Release
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
-msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
-msbuild src/fsharp-library-unittests-build.proj /p:Configuration=Release
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
-msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
-src\update.cmd release -ngen
-tests\BuildTestTools.cmd release
-```
-
-[Optional] If testing the Visual F# IDE Tools (see below) you will also need:
-
-```
-msbuild vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Release
-msbuild vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Release
-```
-
-## 4. [Optional] Build and Install the Visual F# IDE Tools
-
-To build the VS components:
-
-```
-msbuild vsintegration\fsharp-vsintegration-build.proj
-```
-
-To install the VS components:
-
-1. Ensure that the VSIX package is uninstalled.
- - In VS, select Tools/Extensions and Updates
- - If the package `VisualStudio.FSharp.EnableOpenSource` is installed, select Uninstall
-1. Run ```debug\net40\bin\EnableOpenSource.vsix```
-1. Restart Visual Studio, it should now be running your freshly-built Visual F# IDE Tools.
+ msbuild src/fsharp-library-build.proj /p:Configuration=Release
+ msbuild src/fsharp-compiler-build.proj /p:Configuration=Release
+ msbuild src/fsharp-typeproviders-build.proj /p:Configuration=Release
+ msbuild src/fsharp-compiler-unittests-build.proj /p:Configuration=Release
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=net20 /p:Configuration=Release
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
+ msbuild src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
+ msbuild src/fsharp-library-unittests-build.proj /p:Configuration=Release
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable47 /p:Configuration=Release
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable7 /p:Configuration=Release
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable78 /p:Configuration=Release
+ msbuild src/fsharp-library-unittests-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
+ src\update.cmd release -ngen
+ tests\BuildTestTools.cmd release
+
+
+[Optional] If testing **Release** build of the Visual F# IDE Tools (see below) you will also need:
+
+ msbuild vsintegration\fsharp-vsintegration-build.proj /p:Configuration=Release
+ msbuild vsintegration\fsharp-vsintegration-unittests-build.proj /p:Configuration=Release
+
+## 4. [Optional] Install the Visual F# IDE Tools and Clobber the F# 4.0 SDK on the machine
+
+**Note:** Step #3 will install a VSIX extension into Visual Studio 2015 that changes the Visual F# IDE Tools
+components installed into Visual Studio 2015. You can revert this step by disabling or uninstalling the addin.
+
+**Note:** Step #4 will clobber the machine-wide installed F# 4.0 SDK on your machine. This replaces the ``fsi.exe``/``fsiAnyCpu.exe`` used
+by Visual F# Interactive and the ``fsc.exe`` used by ``Microsoft.FSharp.targets``. Repairing Visual Studio 2015 is currently the
+only way to revert this step.
+
+**Note:** After you complete the install, the FSharp.Core referenced by your projects will not be updated. If you want to make
+a project that references your updated FSharp.Core, you must explicitly change the ``TargetFSharpCoreVersion`` in the .fsproj
+file to ``4.4.0.5099`` (or a corresponding portable version number with suffix ``5099``).
+
+For **Debug**:
+
+1. Ensure that the VSIX package is uninstalled. In VS, select Tools/Extensions and Updates and if the package `VisualStudio.FSharp.EnableOpenSource` is installed, select Uninstall
+1. Run ``debug\net40\bin\EnableOpenSource.vsix``
+1. Run ``vsintegration\update-vsintegration.cmd debug`` (clobbers the installed F# 4.0 SDK)
+
+For **Release**:
+
+1. Ensure that the VSIX package is uninstalled. In VS, select Tools/Extensions and Updates and if the package `VisualStudio.FSharp.EnableOpenSource` is installed, select Uninstall
+1. Run ``release\net40\bin\EnableOpenSource.vsix``
+1. Run ``vsintegration\update-vsintegration.cmd release`` (clobbers the installed F# 4.0 SDK)
+
+Restart Visual Studio, it should now be running your freshly-built Visual F# IDE Tools with updated F# Interactive.
+
### Notes on the build
diff --git a/README.md b/README.md
index 72268334db6..cf7dccba927 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
[](http://issuestats.com/github/microsoft/visualfsharp)
[](http://issuestats.com/github/microsoft/visualfsharp)
-[](https://ci.appveyor.com/project/KevinRansom/visualfsharp-radou/branch/master)
+[](https://ci.appveyor.com/project/KevinRansom/visualfsharp-radou/branch/fsharp4)
+
+[](https://gitter.im/Microsoft/visualfsharp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
#Visual F# Tools
@@ -41,3 +43,4 @@ Although the primary focus of this repo is F# for Windows and the Visual Studio
###Get In Touch
Keep up with the Visual F# Team and the development of the Visual F# Tools by following us [@VisualFSharp](https://twitter.com/VisualFSharp) or subscribing to our [team blog](http://blogs.msdn.com/b/fsharpteam/).
+
diff --git a/TESTGUIDE.md b/TESTGUIDE.md
index 23cb45213ab..c676493d187 100644
--- a/TESTGUIDE.md
+++ b/TESTGUIDE.md
@@ -11,8 +11,8 @@ The test cases for this suite reside under `tests\fsharp`. This suite dates back
The test cases for this suite reside under `tests\fsharpqa\source`.
This suite was first created when F# 2.0 was being added to Visual Studio 2010. Tests for this suite are driven by the "RunAll" framework, implemented in Perl. This suite is rather large and has broad and deep coverage of a variety of compiler, runtime, and syntax scenarios.
-### Compiler and Library Core Unit Test Suite
-The test cases for this suite reside next to the F# core library code, at `src\fsharp\FSharp.Core.Unittests`. This suite is a set of standard NUnit test cases, implemented in F#. This suite focuses on validation of the core F# types and the public surface area of `FSharp.Core.dll`.
+### Compiler and Library Core Unit Test Suites
+The test cases for these suites reside next to the F# core library code, at `src\fsharp\FSharp.Core.Unittests` and `src\fsharp\FSharp.Compiler.Unittests`. These suites are standard NUnit test cases, implemented in F#. The FSharp.Core.Unittests suite focuses on validation of the core F# types and the public surface area of `FSharp.Core.dll`, and the FSharp.Compiler.Unittests suite focuses on validation of compiler internals.
### Visual F# Tools IDE Unit Test Suite
The test cases for this suite reside next to the Visual F# Tools code, at `vsintegration\src\unittests`. This suite is a set of standard NUnit test cases, implemented in F#. This suite exercises a wide range of behaviors in the F# Visual Studio project system and language service.
@@ -38,6 +38,7 @@ The script `tests\RunTests.cmd` has been provided to make execution of the above
```
RunTests.cmd fsharp [tags to run] [tags not to run]
RunTests.cmd fsharpqa [tags to run] [tags not to run]
+RunTests.cmd compilerunit
RunTests.cmd coreunit
RunTests.cmd coreunitportable47
RunTests.cmd coreunitportable7
@@ -48,7 +49,7 @@ RunTests.cmd ideunit
`RunTests.cmd` sets a handful of environment variables which allow for the tests to work, then puts together and executes the appropriate command line to start the specified test suite.
-All test execution logs and result files will be dropped into the `tests\TestResults` folder, and have file names matching `FSharp_*.*`, `FSharpQA_*.*`, `CoreUnit_*.*`, `IDEUnit_*.*`, e.g. `FSharpQA_Results.log` or `FSharp_Failures.log`.
+All test execution logs and result files will be dropped into the `tests\TestResults` folder, and have file names matching `FSharp_*.*`, `FSharpQA_*.*`, `CompilerUnit_*.*`, `CoreUnit_*.*`, `IDEUnit_*.*`, e.g. `FSharpQA_Results.log` or `FSharp_Failures.log`.
For the FSharp and FSharpQA suites, the list of test areas and their associated "tags" is stored at
@@ -93,9 +94,14 @@ Test area directories in this suite will contain a number of source code files a
Test cases will run an optional "pre command," compile some set of source files using some set of flags, optionally run the resulting binary, then optionally run a final "post command."
If all of these steps complete without issue, the test is considered to have passed.
-### Core Unit Test Suite
+### FSharp.Compiler and FSharp.Core Unit Test Suites
-To build the unit test binary, call `msbuild fsharp-library-unittests-build.proj` from the `src` directory. Tests are contained in the binary `FSharp.Core.Unittests.dll`.
+To build these unit test binaries, from the `src` directory call
+
+- `msbuild fsharp-compiler-unittests-build.proj`
+ - Output binary is `FSharp.Compiler.Unittests.dll`
+- `msbuild fsharp-library-unittests-build.proj`
+ - Output binary is `FSharp.Core.Unittests.dll`
You can execute and re-run these tests using any standard NUnit approach - via graphical `nunit.exe` or on the command line via `nunit-console.exe`.
@@ -123,4 +129,4 @@ You can execute and re-run these tests using any standard NUnit approach - via g
* Making the tests run faster
* NGen-ing the F# bits (fsc, fsi, FSharp.Core, etc) will result in tests executing much faster. Make sure you run `src\update.cmd` with the `-ngen` flag before running tests.
* The Fsharp and FsharpQA suites will run test cases in parallel by default. You can comment out the relevant line in `RunTests.cmd` (look for `PARALLEL_ARG`) to disable this.
- * By default, tests from the FSharpQA suite are run using a persistent, hosted version of the compiler. This speeds up test execution, as there is no need for the `fsc.exe` process to spin up repeatedly. To disable this, uncomment the relevant line in `RunTests.cmd` (look for `HOSTED_COMPILER`).
\ No newline at end of file
+ * By default, tests from the FSharpQA suite are run using a persistent, hosted version of the compiler. This speeds up test execution, as there is no need for the `fsc.exe` process to spin up repeatedly. To disable this, uncomment the relevant line in `RunTests.cmd` (look for `HOSTED_COMPILER`).
diff --git a/appveyor-build.cmd b/appveyor-build.cmd
index 56d019dea12..c6039fa1148 100644
--- a/appveyor-build.cmd
+++ b/appveyor-build.cmd
@@ -3,9 +3,19 @@
set APPVEYOR_CI=1
:: Check prerequisites
-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 :failure
+if not '%VisualStudioVersion%' == '' goto vsversionset
+if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
+if exist "%ProgramFiles%\Microsoft Visual Studio 14.0\common7\ide\devenv.exe" set VisualStudioVersion=14.0
+if not '%VisualStudioVersion%' == '' goto vsversionset
+if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0
+if exist "%ProgramFiles%\Microsoft Visual Studio 12.0\common7\ide\devenv.exe" set VisualStudioVersion=12.0
+
+:vsversionset
+if '%VisualStudioVersion%' == '' echo Error: Could not find an installation of Visual Studio && goto :eof
+
+if exist "%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe" set _msbuildexe="%ProgramFiles(x86)%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
+if exist "%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe" set _msbuildexe="%ProgramFiles%\MSBuild\%VisualStudioVersion%\Bin\MSBuild.exe"
+if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. && goto :eof
set _ngenexe="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\ngen.exe"
if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure
@@ -13,7 +23,7 @@ if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure
.\.nuget\NuGet.exe restore packages.config -PackagesDirectory packages
@if ERRORLEVEL 1 echo Error: Nuget restore failed && goto :failure
-::Build
+:: Build
%_msbuildexe% src\fsharp-proto-build.proj
@if ERRORLEVEL 1 echo Error: compiler proto build failed && goto :failure
@@ -38,6 +48,9 @@ if not exist %_ngenexe% echo Error: Could not find ngen.exe. && goto :failure
%_msbuildexe% src/fsharp-library-build.proj /p:TargetFramework=portable259 /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library portable259 build failed && goto :failure
+%_msbuildexe% src/fsharp-compiler-unittests-build.proj /p:Configuration=Release
+@if ERRORLEVEL 1 echo Error: compiler unittests build failed && goto :failure
+
%_msbuildexe% src/fsharp-library-unittests-build.proj /p:Configuration=Release
@if ERRORLEVEL 1 echo Error: library unittests build failed && goto :failure
@@ -67,7 +80,6 @@ call tests\BuildTestTools.cmd release
@if ERRORLEVEL 1 echo Error: 'tests\BuildTestTools.cmd release' failed && goto :failure
@echo on
-
pushd tests
call RunTests.cmd release fsharp Smoke
@@ -76,6 +88,9 @@ call RunTests.cmd release fsharp Smoke
call RunTests.cmd release fsharpqa Smoke
@if ERRORLEVEL 1 type testresults\fsharpqa_failures.log && echo Error: 'RunTests.cmd release fsharpqa Smoke' failed && goto :failure
+call RunTests.cmd release compilerunit
+@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release compilerunit' failed && goto :failure
+
call RunTests.cmd release coreunit
@if ERRORLEVEL 1 echo Error: 'RunTests.cmd release coreunit' failed && goto :failure
@@ -84,4 +99,4 @@ popd
goto :eof
:failure
-exit /b 1
\ No newline at end of file
+exit /b 1
diff --git a/appveyor.yml b/appveyor.yml
index f5c58edda01..0dbbaa64802 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,6 +1,14 @@
+os: Windows Server 2012 R2
+
init:
build_script:
- cmd: appveyor-build.cmd
+
+# scripts that run after cloning repository
+install:
+ # by default, all script lines are interpreted as batch
+ - set PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%PATH%
+
test: off
version: 0.0.1.{build}
artifacts:
diff --git a/src/FSharpSource.Settings.targets b/src/FSharpSource.Settings.targets
index 5ad8a11bbb5..75ceab8fd90 100644
--- a/src/FSharpSource.Settings.targets
+++ b/src/FSharpSource.Settings.targets
@@ -1,4 +1,4 @@
-
+
@@ -26,7 +26,7 @@
falsepromptAnyCPU
- $(OtherFlags) --no-jit-optimize --jit-tracking
+ $(OtherFlags) --no-jit-optimize --jit-tracking /warnon:3180DEBUG;TRACE;CODE_ANALYSIS;$(DefineConstants)DEBUG=True,TRACE=True,CODE_ANALYSIS=True,$(DefineConstants)false
@@ -71,4 +71,14 @@
bin\$(Configuration)3
+
+
+ $(DefineConstants),VS_VERSION_DEV12=True
+ $(DefineConstants);VS_VERSION_DEV12
+
+
+
+ core
+ V12.0
+
\ No newline at end of file
diff --git a/src/FSharpSource.targets b/src/FSharpSource.targets
index 84b6e0db5ef..27b47b1c008 100644
--- a/src/FSharpSource.targets
+++ b/src/FSharpSource.targets
@@ -11,12 +11,12 @@
true
- $(OtherFlags) --version:4.3.1.9055
- $(OtherFlags) --version:2.3.1.9055
- $(OtherFlags) --version:3.3.1.9055
- $(OtherFlags) --version:2.3.5.9055
- $(OtherFlags) --version:3.78.3.9055
- $(OtherFlags) --version:3.259.3.9055
+ $(OtherFlags) --version:4.4.0.9055
+ $(OtherFlags) --version:2.4.0.9055
+ $(OtherFlags) --version:3.7.4.9055
+ $(OtherFlags) --version:3.47.4.9055
+ $(OtherFlags) --version:3.78.4.9055
+ $(OtherFlags) --version:3.259.4.9055$(OtherFlags) --delaysign+ --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey"STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY;$(DefineConstants)true
@@ -24,19 +24,19 @@
- $(OtherFlags) --version:12.0.0.9055 --delaysign+ --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey"
+ $(OtherFlags) --version:14.0.0.9055 --delaysign+ --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey"STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY;$(DefineConstants)true
- $(OtherFlags) --version:4.3.1.9055 --delaysign+ --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey"
+ $(OtherFlags) --version:4.4.0.9055 --delaysign+ --keyfile:"$(FSharpSourcesRoot)\fsharp\msft.pubkey"STRONG_NAME_AND_DELAY_SIGN_FSHARP_COMPILER_WITH_MSFT_KEY;$(DefineConstants)true
- $(OtherFlags) --version:4.3.1.9055 --keyfile:"$(FSharpSourcesRoot)\fsharp\test.snk"
+ $(OtherFlags) --version:4.4.0.9055 --keyfile:"$(FSharpSourcesRoot)\fsharp\test.snk"STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY;$(DefineConstants)true
@@ -58,7 +58,7 @@
- $(OtherFlags) --version:4.3.1.9055
+ $(OtherFlags) --version:4.4.0.9055NO_STRONG_NAMES;$(DefineConstants)
@@ -112,6 +112,7 @@
$(DefineConstants);FX_ATLEAST_35$(DefineConstants);FX_NO_STRUCTURAL_EQUALITY$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);FX_NO_IOBSERVABLE$(DefineConstants);FX_NO_LAZY
@@ -120,13 +121,14 @@
$(DefineConstants);FX_NO_TPL_PARALLEL$(DefineConstants);FX_NO_CUSTOMATTRIBUTEDATA$(DefineConstants);FX_NO_BIGINT
+ $(DefineConstants);FX_NO_CONDITIONAL_WEAK_TABLE$(OtherFlags) --simpleresolutionv4.5$(DefineConstants);FSHARP_CORE_4_5
- $(DefineConstants);FX_ATLEAST_45
+ $(DefineConstants);FX_ATLEAST_45$(DefineConstants);FX_ATLEAST_40$(DefineConstants);FX_ATLEAST_35$(DefineConstants);BE_SECURITY_TRANSPARENT
@@ -180,6 +182,7 @@
$(DefineConstants);FX_NO_PARAMETERIZED_THREAD_START$(DefineConstants);FX_EVENTWAITHANDLE_NO_IDISPOSABLE$(DefineConstants);FX_NO_REGISTERED_WAIT_HANDLES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_ATLEAST_LINQ$(DefineConstants);FX_NO_THREAD$(DefineConstants);FX_NO_THREADPOOL
@@ -306,6 +309,7 @@
v3.0$(DefineConstants);SILVERLIGHT$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH$(DefineConstants);FX_NO_DEBUG_PROXIES
@@ -347,6 +351,7 @@
$(DefineConstants);SILVERLIGHT$(DefineConstants);FX_NO_ISIN_ON_PARAMETER_INFO$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);FX_NO_BIGINT$(DefineConstants);FX_NO_CUSTOMATTRIBUTEDATA
@@ -436,6 +441,7 @@
Silverlight$(DefineConstants);SILVERLIGHT$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH$(DefineConstants);FX_NO_DEBUG_PROXIES
@@ -482,6 +488,7 @@
CompactFramework$(DefineConstants);FX_ATLEAST_COMPACT_FRAMEWORK_20$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);COMPACT_FRAMEWORK$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH
@@ -521,6 +528,7 @@
$(DefineConstants);FX_NO_LAZY$(DefineConstants);FX_NO_TUPLE$(DefineConstants);FX_NO_DELEGATE_CREATE_DELEGATE_FROM_STATIC_METHOD
+ $(DefineConstants);FX_NO_CONDITIONAL_WEAK_TABLE$(DefineConstants)$(OtherFlags) --simpleresolution -r:"C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\mscorlib.dll" -r:"C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\System.dll"
@@ -569,6 +577,7 @@
CompactFramework$(DefineConstants);FX_ATLEAST_COMPACT_FRAMEWORK_35$(DefineConstants);FX_NO_CANCELLATIONTOKEN_CLASSES
+ $(DefineConstants);FX_NO_EXCEPTIONDISPATCHINFO$(DefineConstants);FX_NO_TASK$(DefineConstants);COMPACT_FRAMEWORK$(DefineConstants);FX_NO_ARRAY_LONG_LENGTH
@@ -720,7 +729,7 @@
Outputs="@(CustomCopyLocal->'$(OutDir)%(TargetFilename)')"
Condition="'$(targetCLIDir)'!='Silverlight/4.0/'"
>
-
+
diff --git a/src/absil/il.fs b/src/absil/il.fs
index abf2097f33e..f1d827216f5 100644
--- a/src/absil/il.fs
+++ b/src/absil/il.fs
@@ -3,6 +3,7 @@
module internal Microsoft.FSharp.Compiler.AbstractIL.IL
#nowarn "49"
+#nowarn "44" // This construct is deprecated. please use List.item
#nowarn "343" // The type 'ILAssemblyRef' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'.
#nowarn "346" // The struct, record or union type 'IlxExtensionType' has an explicit implementation of 'Object.Equals'. ...
@@ -214,22 +215,18 @@ module SHA1 =
else k60to79
- type chan = SHABytes of byte[]
- type sha_instream =
- { stream: chan;
+ type SHAStream =
+ { stream: byte[];
mutable pos: int;
mutable eof: bool; }
- let rot_left32 x n = (x <<< n) ||| (x >>>& (32-n))
+ let rotLeft32 x n = (x <<< n) ||| (x >>>& (32-n))
- let inline sha_eof sha = sha.eof
-
- (* padding and length (in bits!) recorded at end *)
- let sha_after_eof sha =
+
+ // padding and length (in bits!) recorded at end
+ let shaAfterEof sha =
let n = sha.pos
- let len =
- (match sha.stream with
- | SHABytes s -> s.Length)
+ let len = sha.stream.Length
if n = len then 0x80
else
let padded_len = (((len + 9 + 63) / 64) * 64) - 8
@@ -244,22 +241,21 @@ module SHA1 =
elif (n &&& 63) = 63 then (sha.eof <- true; int32 (int64 len * int64 8) &&& 0xff)
else 0x0
- let sha_read8 sha =
- let b =
- match sha.stream with
- | SHABytes s -> if sha.pos >= s.Length then sha_after_eof sha else int32 s.[sha.pos]
- sha.pos <- sha.pos + 1;
+ let shaRead8 sha =
+ let s = sha.stream
+ let b = if sha.pos >= s.Length then shaAfterEof sha else int32 s.[sha.pos]
+ sha.pos <- sha.pos + 1
b
- let sha_read32 sha =
- let b0 = sha_read8 sha
- let b1 = sha_read8 sha
- let b2 = sha_read8 sha
- let b3 = sha_read8 sha
+ let shaRead32 sha =
+ let b0 = shaRead8 sha
+ let b1 = shaRead8 sha
+ let b2 = shaRead8 sha
+ let b3 = shaRead8 sha
let res = (b0 <<< 24) ||| (b1 <<< 16) ||| (b2 <<< 8) ||| b3
res
- let sha1_hash sha =
+ let sha1Hash sha =
let mutable h0 = 0x67452301
let mutable h1 = 0xEFCDAB89
let mutable h2 = 0x98BADCFE
@@ -271,21 +267,21 @@ module SHA1 =
let mutable d = 0
let mutable e = 0
let w = Array.create 80 0x00
- while (not (sha_eof sha)) do
+ while (not sha.eof) do
for i = 0 to 15 do
- w.[i] <- sha_read32 sha
+ w.[i] <- shaRead32 sha
for t = 16 to 79 do
- w.[t] <- rot_left32 (w.[t-3] ^^^ w.[t-8] ^^^ w.[t-14] ^^^ w.[t-16]) 1
+ w.[t] <- rotLeft32 (w.[t-3] ^^^ w.[t-8] ^^^ w.[t-14] ^^^ w.[t-16]) 1
a <- h0
b <- h1
c <- h2
d <- h3
e <- h4
for t = 0 to 79 do
- let temp = (rot_left32 a 5) + f(t,b,c,d) + e + w.[t] + k(t)
+ let temp = (rotLeft32 a 5) + f(t,b,c,d) + e + w.[t] + k(t)
e <- d
d <- c
- c <- rot_left32 b 30
+ c <- rotLeft32 b 30
b <- a
a <- temp
h0 <- h0 + a
@@ -296,7 +292,7 @@ module SHA1 =
h0,h1,h2,h3,h4
let sha1HashBytes s =
- let (_h0,_h1,_h2,h3,h4) = sha1_hash { stream = SHABytes s; pos = 0; eof = false } // the result of the SHA algorithm is stored in registers 3 and 4
+ let (_h0,_h1,_h2,h3,h4) = sha1Hash { stream = s; pos = 0; eof = false } // the result of the SHA algorithm is stored in registers 3 and 4
Array.map byte [| b0 h4; b1 h4; b2 h4; b3 h4; b0 h3; b1 h3; b2 h3; b3 h3; |]
@@ -677,8 +673,8 @@ type ILTypeRef =
member tref.FullName = String.concat "." (tref.Enclosing @ [tref.Name])
- member tref.BasicQualifiedName =
- String.concat "+" (tref.Enclosing @ [ tref.Name ])
+ member tref.BasicQualifiedName =
+ (String.concat "+" (tref.Enclosing @ [ tref.Name ] )).Replace(",", @"\,")
member tref.AddQualifiedNameExtensionWithNoShortPrimaryAssembly(basic) =
let sco = tref.Scope.QualifiedNameWithNoShortPrimaryAssembly
@@ -1184,7 +1180,8 @@ and ILFilterBlock =
[]
type ILLocal =
{ Type: ILType;
- IsPinned: bool }
+ IsPinned: bool;
+ DebugInfo: (string * int * int) option }
type ILLocals = ILList
let emptyILLocals = (ILList.empty : ILLocals)
@@ -3021,9 +3018,10 @@ let mkILReturn ty : ILReturn =
Type=ty;
CustomAttrs=emptyILCustomAttrs }
-let mkILLocal ty =
+let mkILLocal ty dbgInfo =
{ IsPinned=false;
- Type=ty; }
+ Type=ty;
+ DebugInfo=dbgInfo }
type ILFieldSpec with
member fr.ActualType =
@@ -4385,6 +4383,8 @@ and encodeCustomAttrValue ilg ty c =
match ty, c with
| ILType.Boxed tspec, _ when tspec.Name = tname_Object ->
[| yield! encodeCustomAttrElemTypeForObject c; yield! encodeCustomAttrPrimValue ilg c |]
+ | ILType.Array (shape, _), ILAttribElem.Null when shape = ILArrayShape.SingleDimensional ->
+ [| yield! i32AsBytes 0xFFFFFFFF |]
| ILType.Array (shape, elemType), ILAttribElem.Array (_,elems) when shape = ILArrayShape.SingleDimensional ->
[| yield! i32AsBytes elems.Length; for elem in elems do yield! encodeCustomAttrValue ilg elemType elem |]
| _ ->
@@ -4685,7 +4685,7 @@ type ILTypeSigParser(tstring : string) =
let ilty = x.ParseType()
ILAttribElem.Type(Some(ilty))
-let decodeILAttribData ilg (ca: ILAttribute) scope =
+let decodeILAttribData ilg (ca: ILAttribute) =
let bytes = ca.Data
let sigptr = 0
let bb0,sigptr = sigptr_get_byte bytes sigptr
@@ -4752,6 +4752,7 @@ let decodeILAttribData ilg (ca: ILAttribute) scope =
parseVal ty sigptr
| ILType.Array(shape,elemTy) when shape = ILArrayShape.SingleDimensional ->
let n,sigptr = sigptr_get_i32 bytes sigptr
+ if n = 0xFFFFFFFF then ILAttribElem.Null,sigptr else
let rec parseElems acc n sigptr =
if n = 0 then List.rev acc else
let v,sigptr = parseVal elemTy sigptr
@@ -4778,15 +4779,19 @@ let decodeILAttribData ilg (ca: ILAttribute) scope =
let et,sigptr = sigptr_get_u8 bytes sigptr
// We have a named value
let ty,sigptr =
- // REVIEW: Post-M3, consider removing the restriction for scope - it's unnecessary
- // because you can reconstruct scope using the qualified name from the CA Blob
- if (0x50 = (int et) || 0x55 = (int et)) && Option.isSome scope then
+ if (0x50 = (int et) || 0x55 = (int et)) then
let qualified_tname,sigptr = sigptr_get_serstring bytes sigptr
- // we're already getting the qualified name from the binary blob
- // if we don't split out the unqualified name from the qualified name,
- // we'll write the qualified assembly reference string twice to the binary blob
- let unqualified_tname = qualified_tname.Split([|','|]).[0]
- let scoref = Option.get scope
+ let unqualified_tname, rest =
+ let pieces = qualified_tname.Split(',')
+ if pieces.Length > 1 then
+ pieces.[0], Some (String.concat "," pieces.[1..])
+ else
+ pieces.[0], None
+ let scoref =
+ match rest with
+ | Some aname -> ILScopeRef.Assembly(ILAssemblyRef.FromAssemblyName(System.Reflection.AssemblyName(aname)))
+ | None -> ilg.traits.ScopeRef
+
let tref = mkILTyRef (scoref,unqualified_tname)
let tspec = mkILNonGenericTySpec tref
ILType.Value(tspec),sigptr
diff --git a/src/absil/il.fsi b/src/absil/il.fsi
index c141a6267f0..0d27c0c764e 100644
--- a/src/absil/il.fsi
+++ b/src/absil/il.fsi
@@ -970,7 +970,8 @@ type ILNativeType =
[]
type ILLocal =
{ Type: ILType;
- IsPinned: bool }
+ IsPinned: bool;
+ DebugInfo: (string * int * int) option }
type ILLocals = ILList
@@ -1796,11 +1797,9 @@ val destTypeDefsWithGlobalFunctionsFirst: ILGlobals -> ILTypeDefs -> ILTypeDef l
/// Note: not all custom attribute data can be decoded without binding types. In particular
/// enums must be bound in order to discover the size of the underlying integer.
/// The following assumes enums have size int32.
-/// It also does not completely decode System.Type attributes
val decodeILAttribData:
ILGlobals ->
ILAttribute ->
- ILScopeRef option ->
ILAttribElem list * (* fixed args *)
ILAttributeNamedArg list (* named args: values and flags indicating if they are fields or properties *)
@@ -1955,7 +1954,7 @@ val mkILParam: string option * ILType -> ILParameter
val mkILParamAnon: ILType -> ILParameter
val mkILParamNamed: string * ILType -> ILParameter
val mkILReturn: ILType -> ILReturn
-val mkILLocal: ILType -> ILLocal
+val mkILLocal: ILType -> (string * int * int) option -> ILLocal
val mkILLocals : ILLocal list -> ILLocals
val emptyILLocals : ILLocals
diff --git a/src/absil/ilascii.fs b/src/absil/ilascii.fs
index f2bd0a4b2d3..bd4e1e8c354 100644
--- a/src/absil/ilascii.fs
+++ b/src/absil/ilascii.fs
@@ -12,7 +12,7 @@ open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types
open Microsoft.FSharp.Compiler.AbstractIL.IL
-// set to the proper value at build.fs (BuildFrameworkTcImports)
+// set to the proper value at CompileOps.fs (BuildFrameworkTcImports)
let parseILGlobals = ref EcmaILGlobals
// --------------------------------------------------------------------
diff --git a/src/absil/illib.fs b/src/absil/illib.fs
index 7f2cb63dd4f..ae7d81e0652 100644
--- a/src/absil/illib.fs
+++ b/src/absil/illib.fs
@@ -465,6 +465,7 @@ module Dictionary =
// FUTURE CLEANUP: remove this adhoc collection
type Hashset<'T> = Dictionary<'T,int>
+
[]
module Hashset =
let create (n:int) = new Hashset<'T>(n, HashIdentity.Structural)
@@ -498,6 +499,28 @@ type ResultOrException<'TResult> =
| Result of 'TResult
| Exception of System.Exception
+[]
+module ResultOrException =
+
+ let success a = Result a
+ let raze (b:exn) = Exception b
+
+ // map
+ let (|?>) res f =
+ match res with
+ | Result x -> Result(f x )
+ | Exception err -> Exception err
+
+ let ForceRaise res =
+ match res with
+ | Result x -> x
+ | Exception err -> raise err
+
+ let otherwise f x =
+ match x with
+ | Result x -> success x
+ | Exception _err -> f()
+
//-------------------------------------------------------------------------
// Library: extensions to flat list (immutable arrays)
diff --git a/src/absil/ilmorph.fs b/src/absil/ilmorph.fs
index 8df078b7db6..396db5de82a 100644
--- a/src/absil/ilmorph.fs
+++ b/src/absil/ilmorph.fs
@@ -292,7 +292,7 @@ let cattr_typ2typ ilg f c =
// dev11 M3 defensive coding: if anything goes wrong with attribute decoding or encoding, then back out.
if morphCustomAttributeData then
try
- let elems,namedArgs = IL.decodeILAttribData ilg c (Some(meth.MethodRef.EnclosingTypeRef.Scope))
+ let elems,namedArgs = IL.decodeILAttribData ilg c
let elems = elems |> List.map (celem_typ2typ f)
let namedArgs = namedArgs |> List.map (cnamedarg_typ2typ f)
IL.mkILCustomAttribMethRef ilg (meth, elems, namedArgs)
diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs
index 3905acda34f..11acfcee40c 100644
--- a/src/absil/ilread.fs
+++ b/src/absil/ilread.fs
@@ -8,6 +8,7 @@
module internal Microsoft.FSharp.Compiler.AbstractIL.ILBinaryReader
#nowarn "42" // This construct is deprecated: it is only for use in the F# library
+#nowarn "44" // This construct is deprecated. please use List.item
open System
open System.IO
@@ -2205,7 +2206,8 @@ and sigptrGetLocal ctxt numtypars bytes sigptr =
false, sigptr
let typ, sigptr = sigptrGetTy ctxt numtypars bytes sigptr
{ IsPinned = pinned;
- Type = typ }, sigptr
+ Type = typ;
+ DebugInfo = None }, sigptr
and readBlobHeapAsMethodSig ctxt numtypars blobIdx =
ctxt.readBlobHeapAsMethodSig (BlobAsMethodSigIdx (numtypars,blobIdx))
diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs
index bd1e1ec1a6d..efc6b644d83 100644
--- a/src/absil/ilreflect.fs
+++ b/src/absil/ilreflect.fs
@@ -323,26 +323,8 @@ type cenv =
// [] ,name -> name
// [ns] ,name -> ns+name
// [ns;typeA;typeB],name -> ns+typeA+typeB+name
-let getTRefType (cenv:cenv) (tref:ILTypeRef) =
-
- // If an inner nested type's name contains a space, the proper encoding is "\+" on both sides - otherwise,
- // we use "+"
- let rec collectPrefixParts (l : string list) (acc : string list) =
- match l with
- | h1 :: (h2 :: _ as tl) ->
- collectPrefixParts tl
- (List.append
- acc
- [ yield h1
- if h1.Contains(" ") || h2.Contains(" ") then
- yield "\\+"
- else
- yield "+"])
- | h :: [] -> List.append acc [h]
- | _ -> acc
-
- let prefix = collectPrefixParts tref.Enclosing [] |> List.fold (fun (s1 : string) (s2 : string) -> s1 + s2) ""
- let qualifiedName = prefix + (if prefix <> "" then (if tref.Name.Contains(" ") then "\\+" else "+") else "") + tref.Name // e.g. Name.Space.Class+NestedClass
+let convTypeRefAux (cenv:cenv) (tref:ILTypeRef) =
+ let qualifiedName = (String.concat "+" (tref.Enclosing @ [ tref.Name ])).Replace(",", @"\,")
match tref.Scope with
| ILScopeRef.Assembly asmref ->
let assembly =
@@ -355,11 +337,11 @@ let getTRefType (cenv:cenv) (tref:ILTypeRef) =
let asmName = convAssemblyRef asmref
FileSystem.AssemblyLoad(asmName)
let typT = assembly.GetType(qualifiedName)
- typT |> nonNull "GetTRefType"
+ typT |> nonNull "convTypeRefAux"
| ILScopeRef.Module _
| ILScopeRef.Local _ ->
let typT = Type.GetType(qualifiedName,true)
- typT |> nonNull "GetTRefType"
+ typT |> nonNull "convTypeRefAux"
@@ -425,11 +407,11 @@ let envUpdateCreatedTypeRef emEnv (tref:ILTypeRef) =
#endif
emEnv
-let envGetTypT cenv emEnv preferCreated (tref:ILTypeRef) =
+let convTypeRef cenv emEnv preferCreated (tref:ILTypeRef) =
match Zmap.tryFind tref emEnv.emTypMap with
- | Some (_typT,_typB,_typeDef,Some createdTyp) when preferCreated -> createdTyp |> nonNull "envGetTypT: null create type table?"
- | Some (typT,_typB,_typeDef,_) -> typT |> nonNull "envGetTypT: null type table?"
- | None -> getTRefType cenv tref
+ | Some (_typT,_typB,_typeDef,Some createdTyp) when preferCreated -> createdTyp |> nonNull "convTypeRef: null create type table?"
+ | Some (typT,_typB,_typeDef,_) -> typT |> nonNull "convTypeRef: null type table?"
+ | None -> convTypeRefAux cenv tref
let envBindConsRef emEnv (mref:ILMethodRef) consB =
{emEnv with emConsMap = Zmap.add mref consB emEnv.emConsMap}
@@ -512,7 +494,7 @@ let convCallConv (Callconv (hasThis,basic)) =
//----------------------------------------------------------------------------
let rec convTypeSpec cenv emEnv preferCreated (tspec:ILTypeSpec) =
- let typT = envGetTypT cenv emEnv preferCreated tspec.TypeRef
+ let typT = convTypeRef cenv emEnv preferCreated tspec.TypeRef
let tyargs = ILList.map (convTypeAux cenv emEnv preferCreated) tspec.GenericArgs
match ILList.isEmpty tyargs,typT.IsGenericType with
| _ ,true -> typT.MakeGenericType(ILList.toArray tyargs) |> nonNull "convTypeSpec: generic"
@@ -565,12 +547,20 @@ and convTypeAux cenv emEnv preferCreated typ =
/// Uses TypeBuilder/TypeBuilderInstantiation for emitted types
let convType cenv emEnv typ = convTypeAux cenv emEnv false typ
+// Used for ldtoken
+let convTypeOrTypeDef cenv emEnv typ =
+ match typ with
+ // represents an uninstantiated "TypeDef" or "TypeRef"
+ | ILType.Boxed tspec when tspec.GenericArgs.IsEmpty -> convTypeRef cenv emEnv false tspec.TypeRef
+ | _ -> convType cenv emEnv typ
+
let convTypes cenv emEnv (typs:ILTypes) = ILList.map (convType cenv emEnv) typs
let convTypesToArray cenv emEnv (typs:ILTypes) = convTypes cenv emEnv typs |> ILList.toArray
/// Uses the .CreateType() for emitted type (if available)
let convCreatedType cenv emEnv typ = convTypeAux cenv emEnv true typ
+let convCreatedTypeRef cenv emEnv typ = convTypeRef cenv emEnv true typ
//----------------------------------------------------------------------------
@@ -601,7 +591,14 @@ let convFieldInit x =
// This is gross. TypeBuilderInstantiation should really be a public type, since we
// have to use alternative means for various Method/Field/Constructor lookups. However since
// it isn't we resort to this technique...
-let TypeBuilderInstantiationT = Type.GetType("System.Reflection.Emit.TypeBuilderInstantiation" )
+let TypeBuilderInstantiationT =
+ let ty =
+ if runningOnMono then
+ Type.GetType("System.Reflection.MonoGenericClass")
+ else
+ Type.GetType("System.Reflection.Emit.TypeBuilderInstantiation")
+ assert (not (isNull ty))
+ ty
let typeIsNotQueryable (typ : Type) =
(typ :? TypeBuilder) || ((typ.GetType()).Equals(TypeBuilderInstantiationT))
@@ -1043,7 +1040,7 @@ let rec emitInstr cenv (modB : ModuleBuilder) emEnv (ilG:ILGenerator) instr =
| I_ldstr s -> ilG.EmitAndLog(OpCodes.Ldstr ,s)
| I_isinst typ -> ilG.EmitAndLog(OpCodes.Isinst ,convType cenv emEnv typ)
| I_castclass typ -> ilG.EmitAndLog(OpCodes.Castclass,convType cenv emEnv typ)
- | I_ldtoken (ILToken.ILType typ) -> ilG.EmitAndLog(OpCodes.Ldtoken ,convType cenv emEnv typ)
+ | I_ldtoken (ILToken.ILType typ) -> ilG.EmitAndLog(OpCodes.Ldtoken ,convTypeOrTypeDef cenv emEnv typ)
| I_ldtoken (ILToken.ILMethod mspec) -> ilG.EmitAndLog(OpCodes.Ldtoken ,convMethodSpec cenv emEnv mspec)
| I_ldtoken (ILToken.ILField fspec) -> ilG.EmitAndLog(OpCodes.Ldtoken ,convFieldSpec cenv emEnv fspec)
| I_ldvirtftn mspec -> ilG.EmitAndLog(OpCodes.Ldvirtftn,convMethodSpec cenv emEnv mspec)
@@ -1237,7 +1234,11 @@ let emitCode cenv modB emEnv (ilG:ILGenerator) code =
let emitLocal cenv emEnv (ilG : ILGenerator) (local: ILLocal) =
let ty = convType cenv emEnv local.Type
- ilG.DeclareLocalAndLog(ty,local.IsPinned)
+ let locBuilder = ilG.DeclareLocalAndLog(ty, local.IsPinned)
+ match local.DebugInfo with
+ | Some(nm, start, finish) -> locBuilder.SetLocalSymInfo(nm, start, finish)
+ | None -> ()
+ locBuilder
let emitILMethodBody cenv modB emEnv (ilG:ILGenerator) ilmbody =
// XXX - REVIEW:
@@ -1658,20 +1659,20 @@ let typeAttributesOfTypeEncoding x =
let typeAttributesOfTypeLayout cenv emEnv x =
- let attr p =
+ let attr x p =
if p.Size =None && p.Pack = None then None
else
Some(convCustomAttr cenv emEnv
(IL.mkILCustomAttribute cenv.ilg
(mkILTyRef (cenv.ilg.traits.ScopeRef,"System.Runtime.InteropServices.StructLayoutAttribute"),
[mkILNonGenericValueTy (mkILTyRef (cenv.ilg.traits.ScopeRef,"System.Runtime.InteropServices.LayoutKind")) ],
- [ ILAttribElem.Int32 0x02 ],
+ [ ILAttribElem.Int32 x ],
(p.Pack |> Option.toList |> List.map (fun x -> ("Pack", cenv.ilg.typ_int32, false, ILAttribElem.Int32 (int32 x)))) @
(p.Size |> Option.toList |> List.map (fun x -> ("Size", cenv.ilg.typ_int32, false, ILAttribElem.Int32 x)))))) in
match x with
| ILTypeDefLayout.Auto -> TypeAttributes.AutoLayout,None
- | ILTypeDefLayout.Explicit p -> TypeAttributes.ExplicitLayout,(attr p)
- | ILTypeDefLayout.Sequential p -> TypeAttributes.SequentialLayout, (attr p)
+ | ILTypeDefLayout.Explicit p -> TypeAttributes.ExplicitLayout,(attr 0x02 p)
+ | ILTypeDefLayout.Sequential p -> TypeAttributes.SequentialLayout, (attr 0x00 p)
//----------------------------------------------------------------------------
@@ -1999,7 +2000,7 @@ let emitModuleFragment (ilg, emEnv, asmB : AssemblyBuilder, modB : ModuleBuilder
// The emEnv stores (typT:Type) for each tref.
// Once the emitted type is created this typT is updated to ensure it is the Type proper.
// So Type lookup will return the proper Type not TypeBuilder.
-let LookupTypeRef emEnv tref = Zmap.tryFind tref emEnv.emTypMap |> Option.map (function (_typ,_,_,Some createdTyp) -> createdTyp | (typ,_,_,None) -> typ)
+let LookupTypeRef cenv emEnv tref = convCreatedTypeRef cenv emEnv tref
let LookupType cenv emEnv typ = convCreatedType cenv emEnv typ
// Lookups of ILFieldRef and MethodRef may require a similar non-Builder-fixup post Type-creation.
diff --git a/src/absil/ilsupp.fs b/src/absil/ilsupp.fs
index 95043734b7d..e419537b66b 100644
--- a/src/absil/ilsupp.fs
+++ b/src/absil/ilsupp.fs
@@ -1048,7 +1048,7 @@ let pdbCloseDocument(documentWriter : PdbDocumentWriter) =
|> ignore
[]
-let pdbClose (writer:PdbWriter) =
+let pdbClose (writer:PdbWriter) dllFilename pdbFilename =
writer.symWriter.Close()
// CorSymWriter objects (ISymUnmanagedWriter) lock the files they're operating
// on (both the pdb and the binary). The locks are released only when their ref
@@ -1061,18 +1061,21 @@ let pdbClose (writer:PdbWriter) =
let rc = Marshal.ReleaseComObject(writer.symWriter)
for i = 0 to (rc - 1) do
Marshal.ReleaseComObject(writer.symWriter) |> ignore
-
- System.GC.Collect();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers();
-
- System.GC.Collect();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers();
-
- System.GC.Collect();
- System.GC.Collect();
- System.GC.WaitForPendingFinalizers()
+
+ let isLocked filename =
+ try
+ use x = File.Open (filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
+ false
+ with
+ | _ -> true
+
+ let mutable attempts = 0
+ while (isLocked dllFilename || isLocked pdbFilename) && attempts < 3 do
+ // Need to induce two full collections for finalizers to run
+ System.GC.Collect()
+ System.GC.Collect()
+ System.GC.WaitForPendingFinalizers()
+ attempts <- attempts + 1
let pdbSetUserEntryPoint (writer:PdbWriter) (entryMethodToken:int32) =
writer.symWriter.SetUserEntryPoint((uint32)entryMethodToken)
diff --git a/src/absil/ilsupp.fsi b/src/absil/ilsupp.fsi
index db6e059c56e..5e54476a072 100644
--- a/src/absil/ilsupp.fsi
+++ b/src/absil/ilsupp.fsi
@@ -95,7 +95,7 @@ val pdbInitialize:
string (* .exe/.dll already written and closed *) ->
string (* .pdb to write *) ->
PdbWriter
-val pdbClose: PdbWriter -> unit
+val pdbClose: PdbWriter -> string -> string -> unit
val pdbCloseDocument : PdbDocumentWriter -> unit
val pdbSetUserEntryPoint: PdbWriter -> int32 -> unit
val pdbDefineDocument: PdbWriter -> string -> PdbDocumentWriter
diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs
index 1ea6925fb12..b6aaa862c3f 100644
--- a/src/absil/ilwrite.fs
+++ b/src/absil/ilwrite.fs
@@ -35,7 +35,7 @@ let reportTime =
let t = System.Diagnostics.Process.GetCurrentProcess().UserProcessorTime.TotalSeconds
let prev = match !tPrev with None -> 0.0 | Some t -> t
let first = match !tFirst with None -> (tFirst := Some t; t) | Some t -> t
- dprintf "ilwrite: TIME %10.3f (total) %10.3f (delta) - %s\n" (t - first) (t - prev) descr;
+ dprintf "ilwrite: TIME %10.3f (total) %10.3f (delta) - %s\n" (t - first) (t - prev) descr
tPrev := Some t
//---------------------------------------------------------------------
@@ -85,12 +85,12 @@ type ByteBuffer with
if n >= 0 && n <= 0x7F then
buf.EmitIntAsByte n
elif n >= 0x80 && n <= 0x3FFF then
- buf.EmitIntAsByte (0x80 ||| (n >>> 8));
+ buf.EmitIntAsByte (0x80 ||| (n >>> 8))
buf.EmitIntAsByte (n &&& 0xFF)
else
- buf.EmitIntAsByte (0xc0l ||| ((n >>> 24) &&& 0xFF));
- buf.EmitIntAsByte ( (n >>> 16) &&& 0xFF);
- buf.EmitIntAsByte ( (n >>> 8) &&& 0xFF);
+ buf.EmitIntAsByte (0xc0l ||| ((n >>> 24) &&& 0xFF))
+ buf.EmitIntAsByte ( (n >>> 16) &&& 0xFF)
+ buf.EmitIntAsByte ( (n >>> 8) &&& 0xFF)
buf.EmitIntAsByte ( n &&& 0xFF)
member buf.EmitPadding n =
@@ -142,15 +142,15 @@ let markerForUnicodeBytes (b:byte[]) =
/// Check that the data held at a fixup is some special magic value, as a sanity check
/// to ensure the fixup is being placed at a ood lcoation.
let checkFixup32 (data: byte[]) offset exp =
- if data.[offset + 3] <> b3 exp then failwith "fixup sanity check failed";
- if data.[offset + 2] <> b2 exp then failwith "fixup sanity check failed";
- if data.[offset + 1] <> b1 exp then failwith "fixup sanity check failed";
+ if data.[offset + 3] <> b3 exp then failwith "fixup sanity check failed"
+ if data.[offset + 2] <> b2 exp then failwith "fixup sanity check failed"
+ if data.[offset + 1] <> b1 exp then failwith "fixup sanity check failed"
if data.[offset] <> b0 exp then failwith "fixup sanity check failed"
let applyFixup32 (data:byte[]) offset v =
- data.[offset] <- b0 v;
- data.[offset+1] <- b1 v;
- data.[offset+2] <- b2 v;
+ data.[offset] <- b0 v
+ data.[offset+1] <- b1 v
+ data.[offset+2] <- b2 v
data.[offset+3] <- b3 v
// --------------------------------------------------------------------
@@ -160,39 +160,39 @@ let applyFixup32 (data:byte[]) offset v =
type PdbDocumentData = ILSourceDocument
type PdbLocalVar =
- { Name: string;
- Signature: byte[];
+ { Name: string
+ Signature: byte[]
/// the local index the name corresponds to
Index: int32 }
type PdbMethodScope =
- { Children: PdbMethodScope array;
- StartOffset: int;
- EndOffset: int;
- Locals: PdbLocalVar array;
- (* REVIEW open_namespaces: pdb_namespace array; *) }
+ { Children: PdbMethodScope array
+ StartOffset: int
+ EndOffset: int
+ Locals: PdbLocalVar array
+ (* REVIEW open_namespaces: pdb_namespace array *) }
type PdbSourceLoc =
- { Document: int;
- Line: int;
- Column: int; }
+ { Document: int
+ Line: int
+ Column: int }
type PdbSequencePoint =
- { Document: int;
- Offset: int;
- Line: int;
- Column: int;
- EndLine: int;
- EndColumn: int; }
+ { Document: int
+ Offset: int
+ Line: int
+ Column: int
+ EndLine: int
+ EndColumn: int }
override x.ToString() = sprintf "(%d,%d)-(%d,%d)" x.Line x.Column x.EndLine x.EndColumn
type PdbMethodData =
- { MethToken: int32;
- MethName:string;
- Params: PdbLocalVar array;
- RootScope: PdbMethodScope;
- Range: (PdbSourceLoc * PdbSourceLoc) option;
- SequencePoints: PdbSequencePoint array; }
+ { MethToken: int32
+ MethName:string
+ Params: PdbLocalVar array
+ RootScope: PdbMethodScope
+ Range: (PdbSourceLoc * PdbSourceLoc) option
+ SequencePoints: PdbSequencePoint array }
module SequencePoint =
let orderBySource sp1 sp2 =
@@ -210,10 +210,10 @@ let sizeof_IMAGE_DEBUG_DIRECTORY = 28
[]
type PdbData =
- { EntryPoint: int32 option;
+ { EntryPoint: int32 option
// MVID of the generated .NET module (used by MDB files to identify debug info)
- ModuleID: byte[];
- Documents: PdbDocumentData[];
+ ModuleID: byte[]
+ Documents: PdbDocumentData[]
Methods: PdbMethodData[] }
//---------------------------------------------------------------------
@@ -222,7 +222,7 @@ type PdbData =
//---------------------------------------------------------------------
let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
- (try FileSystem.FileDelete fpdb with _ -> ());
+ (try FileSystem.FileDelete fpdb with _ -> ())
let pdbw = ref Unchecked.defaultof
try
@@ -235,12 +235,12 @@ let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
let docs = info.Documents |> Array.map (fun doc -> pdbDefineDocument !pdbw doc.File)
let getDocument i =
- if i < 0 || i > docs.Length then failwith "getDocument: bad doc number";
+ if i < 0 || i > docs.Length then failwith "getDocument: bad doc number"
docs.[i]
- reportTime showTimes (sprintf "PDB: Defined %d documents" info.Documents.Length);
- Array.sortInPlaceBy (fun x -> x.MethToken) info.Methods;
+ reportTime showTimes (sprintf "PDB: Defined %d documents" info.Documents.Length)
+ Array.sortInPlaceBy (fun x -> x.MethToken) info.Methods
- reportTime showTimes (sprintf "PDB: Sorted %d methods" info.Methods.Length);
+ reportTime showTimes (sprintf "PDB: Sorted %d methods" info.Methods.Length)
// This next bit is a workaround. The sequence points we get
// from F# (which has nothing to do with this module) are actually expression
@@ -258,7 +258,7 @@ let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
let allSps = Array.mapi (fun i sp -> (i,sp)) allSps
if fixupOverlappingSequencePoints then
// sort the sequence points into source order
- Array.sortInPlaceWith (fun (_,sp1) (_,sp2) -> SequencePoint.orderBySource sp1 sp2) allSps;
+ Array.sortInPlaceWith (fun (_,sp1) (_,sp2) -> SequencePoint.orderBySource sp1 sp2) allSps
// shorten the ranges of any that overlap with following sequence points
// sort the sequence points back into offset order
for i = 0 to Array.length allSps - 2 do
@@ -269,9 +269,9 @@ let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
(sp1.EndLine = sp2.Line &&
sp1.EndColumn >= sp2.Column)) then
let adjustToPrevLine = (sp1.Line < sp2.Line)
- allSps.[i] <- n,{sp1 with EndLine = (if adjustToPrevLine then sp2.Line-1 else sp2.Line);
- EndColumn = (if adjustToPrevLine then 80 else sp2.Column); }
- Array.sortInPlaceBy fst allSps;
+ allSps.[i] <- n,{sp1 with EndLine = (if adjustToPrevLine then sp2.Line-1 else sp2.Line)
+ EndColumn = (if adjustToPrevLine then 80 else sp2.Column) }
+ Array.sortInPlaceBy fst allSps
@@ -279,15 +279,15 @@ let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
info.Methods |> Array.iteri (fun i minfo ->
let sps = Array.sub allSps !spOffset spCounts.[i]
- spOffset := !spOffset + spCounts.[i];
+ spOffset := !spOffset + spCounts.[i]
begin match minfo.Range with
| None -> ()
| Some (a,b) ->
- pdbOpenMethod !pdbw minfo.MethToken;
+ pdbOpenMethod !pdbw minfo.MethToken
pdbSetMethodRange !pdbw
(getDocument a.Document) a.Line a.Column
- (getDocument b.Document) b.Line b.Column;
+ (getDocument b.Document) b.Line b.Column
// Partition the sequence points by document
let spsets =
@@ -304,34 +304,34 @@ let WritePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info =
spsets |> List.iter (fun spset ->
if spset.Length > 0 then
- Array.sortInPlaceWith SequencePoint.orderByOffset spset;
+ Array.sortInPlaceWith SequencePoint.orderByOffset spset
let sps =
spset |> Array.map (fun sp ->
- // Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset;
+ // Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset
(sp.Offset, sp.Line, sp.Column,sp.EndLine, sp.EndColumn))
// Use of alloca in implementation of pdbDefineSequencePoints can give stack overflow here
if sps.Length < 5000 then
- pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps;);
+ pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps)
// Write the scopes
let rec writePdbScope top sco =
if top || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
- pdbOpenScope !pdbw sco.StartOffset;
- sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index);
- sco.Children |> Array.iter (writePdbScope false);
- pdbCloseScope !pdbw sco.EndOffset;
- writePdbScope true minfo.RootScope;
+ pdbOpenScope !pdbw sco.StartOffset
+ sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
+ sco.Children |> Array.iter (writePdbScope false)
+ pdbCloseScope !pdbw sco.EndOffset
+ writePdbScope true minfo.RootScope
pdbCloseMethod !pdbw
- end);
- reportTime showTimes "PDB: Wrote methods";
+ end)
+ reportTime showTimes "PDB: Wrote methods"
let res = pdbGetDebugInfo !pdbw
for pdbDoc in docs do
pdbCloseDocument pdbDoc
- pdbClose !pdbw;
- reportTime showTimes "PDB: Closed";
+ pdbClose !pdbw f fpdb;
+ reportTime showTimes "PDB: Closed"
res
//---------------------------------------------------------------------
@@ -383,7 +383,7 @@ let createWriter (f:string) =
let WriteMdbInfo fmdb f info =
// Note, if we cant delete it code will fail later
- (try FileSystem.FileDelete fmdb with _ -> ());
+ (try FileSystem.FileDelete fmdb with _ -> ())
// Try loading the MDB symbol writer from an assembly available on Mono dynamically
// Report an error if the assembly is not available.
@@ -514,7 +514,7 @@ type ILStrongNameSigner =
member s.SignatureSize =
try Support.signerSignatureSize(s.PublicKey)
with e ->
- failwith ("A call to StrongNameSignatureSize failed ("+e.Message+")");
+ failwith ("A call to StrongNameSignatureSize failed ("+e.Message+")")
0x80
member s.SignFile file =
@@ -755,48 +755,48 @@ let envForOverrideSpec (ospec:ILOverridesSpec) = { EnclosingTyparCount=ospec.Enc
[]
type MetadataTable<'T> =
- { name: string;
- dict: Dictionary<'T, int>; // given a row, find its entry number
+ { name: string
+ dict: Dictionary<'T, int> // given a row, find its entry number
#if DEBUG
- mutable lookups: int;
+ mutable lookups: int
#endif
- mutable rows: ResizeArray<'T> ; }
+ mutable rows: ResizeArray<'T> }
member x.Count = x.rows.Count
static member New(nm,hashEq) =
- { name=nm;
+ { name=nm
#if DEBUG
- lookups=0;
+ lookups=0
#endif
- dict = new Dictionary<_,_>(100, hashEq);
- rows= new ResizeArray<_>(); }
+ dict = new Dictionary<_,_>(100, hashEq)
+ rows= new ResizeArray<_>() }
member tbl.EntriesAsArray =
#if DEBUG
- if showEntryLookups then dprintf "--> table %s had %d entries and %d lookups\n" tbl.name tbl.Count tbl.lookups;
+ if showEntryLookups then dprintf "--> table %s had %d entries and %d lookups\n" tbl.name tbl.Count tbl.lookups
#endif
tbl.rows |> ResizeArray.toArray
member tbl.Entries =
#if DEBUG
- if showEntryLookups then dprintf "--> table %s had %d entries and %d lookups\n" tbl.name tbl.Count tbl.lookups;
+ if showEntryLookups then dprintf "--> table %s had %d entries and %d lookups\n" tbl.name tbl.Count tbl.lookups
#endif
tbl.rows |> ResizeArray.toList
member tbl.AddSharedEntry x =
let n = tbl.rows.Count + 1
- tbl.dict.[x] <- n;
- tbl.rows.Add(x);
+ tbl.dict.[x] <- n
+ tbl.rows.Add(x)
n
member tbl.AddUnsharedEntry x =
let n = tbl.rows.Count + 1
- tbl.rows.Add(x);
+ tbl.rows.Add(x)
n
member tbl.FindOrAddSharedEntry x =
#if DEBUG
- tbl.lookups <- tbl.lookups + 1;
+ tbl.lookups <- tbl.lookups + 1
#endif
let mutable res = Unchecked.defaultof<_>
let ok = tbl.dict.TryGetValue(x,&res)
@@ -806,9 +806,9 @@ type MetadataTable<'T> =
/// This is only used in one special place - see further below.
member tbl.SetRowsOfTable t =
- tbl.rows <- ResizeArray.ofArray t;
+ tbl.rows <- ResizeArray.ofArray t
let h = tbl.dict
- h.Clear();
+ h.Clear()
t |> Array.iteri (fun i x -> h.[x] <- (i+1))
member tbl.AddUniqueEntry nm geterr x =
@@ -877,52 +877,52 @@ type TypeDefTableKey = TdKey of string list (* enclosing *) * string (* type nam
[]
type cenv =
- { primaryAssembly: ILScopeRef;
- ilg: ILGlobals;
- emitTailcalls: bool;
- showTimes: bool;
- desiredMetadataVersion: ILVersionInfo;
- requiredDataFixups: (int32 * (int * bool)) list ref;
+ { primaryAssembly: ILScopeRef
+ ilg: ILGlobals
+ emitTailcalls: bool
+ showTimes: bool
+ desiredMetadataVersion: ILVersionInfo
+ requiredDataFixups: (int32 * (int * bool)) list ref
/// References to strings in codestreams: offset of code and a (fixup-location , string token) list)
- mutable requiredStringFixups: (int32 * (int * int) list) list;
- codeChunks: ByteBuffer;
- mutable nextCodeAddr: int32;
+ mutable requiredStringFixups: (int32 * (int * int) list) list
+ codeChunks: ByteBuffer
+ mutable nextCodeAddr: int32
// Collected debug information
mutable moduleGuid: byte[]
- generatePdb: bool;
- pdbinfo: ResizeArray;
- documents: MetadataTable;
+ generatePdb: bool
+ pdbinfo: ResizeArray
+ documents: MetadataTable
/// Raw data, to go into the data section
- data: ByteBuffer;
+ data: ByteBuffer
/// Raw resource data, to go into the data section
- resources: ByteBuffer;
- mutable entrypoint: (bool * int) option;
+ resources: ByteBuffer
+ mutable entrypoint: (bool * int) option
/// Caches
- trefCache: Dictionary;
+ trefCache: Dictionary
/// The following are all used to generate unique items in the output
- tables: array>;
- AssemblyRefs: MetadataTable;
- fieldDefs: MetadataTable;
- methodDefIdxsByKey: MetadataTable;
- methodDefIdxs: Dictionary;
- propertyDefs: MetadataTable;
- eventDefs: MetadataTable;
- typeDefs: MetadataTable;
- guids: MetadataTable;
- blobs: MetadataTable;
- strings: MetadataTable;
- userStrings: MetadataTable;
+ tables: array>
+ AssemblyRefs: MetadataTable
+ fieldDefs: MetadataTable
+ methodDefIdxsByKey: MetadataTable
+ methodDefIdxs: Dictionary
+ propertyDefs: MetadataTable
+ eventDefs: MetadataTable
+ typeDefs: MetadataTable
+ guids: MetadataTable
+ blobs: MetadataTable
+ strings: MetadataTable
+ userStrings: MetadataTable
}
member cenv.GetTable (tab:TableName) = cenv.tables.[tab.Index]
member cenv.AddCode ((reqdStringFixupsOffset,requiredStringFixups),code) =
- if align 4 cenv.nextCodeAddr <> cenv.nextCodeAddr then dprintn "warning: code not 4-byte aligned";
- cenv.requiredStringFixups <- (cenv.nextCodeAddr + reqdStringFixupsOffset, requiredStringFixups) :: cenv.requiredStringFixups;
- cenv.codeChunks.EmitBytes code;
+ if align 4 cenv.nextCodeAddr <> cenv.nextCodeAddr then dprintn "warning: code not 4-byte aligned"
+ cenv.requiredStringFixups <- (cenv.nextCodeAddr + reqdStringFixupsOffset, requiredStringFixups) :: cenv.requiredStringFixups
+ cenv.codeChunks.EmitBytes code
cenv.nextCodeAddr <- cenv.nextCodeAddr + code.Length
member cenv.GetCode() = cenv.codeChunks.Close()
@@ -964,14 +964,14 @@ let peOptionalHeaderByteByCLRVersion v =
// returned by writeBinaryAndReportMappings
[]
type ILTokenMappings =
- { TypeDefTokenMap: ILTypeDef list * ILTypeDef -> int32;
- FieldDefTokenMap: ILTypeDef list * ILTypeDef -> ILFieldDef -> int32;
- MethodDefTokenMap: ILTypeDef list * ILTypeDef -> ILMethodDef -> int32;
- PropertyTokenMap: ILTypeDef list * ILTypeDef -> ILPropertyDef -> int32;
+ { TypeDefTokenMap: ILTypeDef list * ILTypeDef -> int32
+ FieldDefTokenMap: ILTypeDef list * ILTypeDef -> ILFieldDef -> int32
+ MethodDefTokenMap: ILTypeDef list * ILTypeDef -> ILMethodDef -> int32
+ PropertyTokenMap: ILTypeDef list * ILTypeDef -> ILPropertyDef -> int32
EventTokenMap: ILTypeDef list * ILTypeDef -> ILEventDef -> int32 }
let recordRequiredDataFixup requiredDataFixups (buf: ByteBuffer) pos lab =
- requiredDataFixups := (pos,lab) :: !requiredDataFixups;
+ requiredDataFixups := (pos,lab) :: !requiredDataFixups
// Write a special value in that we check later when applying the fixup
buf.EmitInt32 0xdeaddddd
@@ -1007,7 +1007,7 @@ let GetTypeNameAsElemPair cenv n =
//=====================================================================
let rec GenTypeDefPass1 enc cenv (td:ILTypeDef) =
- ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_,n)) -> n) (TdKey (enc,td.Name)));
+ ignore (cenv.typeDefs.AddUniqueEntry "type index" (fun (TdKey (_,n)) -> n) (TdKey (enc,td.Name)))
GenTypeDefsPass1 (enc@[td.Name]) cenv td.NestedTypes.AsList
and GenTypeDefsPass1 enc cenv tds = List.iter (GenTypeDefPass1 enc cenv) tds
@@ -1053,9 +1053,9 @@ and GetModuleRefAsRow cenv (mref:ILModuleRef) =
and GetModuleRefAsFileRow cenv (mref:ILModuleRef) =
SimpleSharedRow
- [| ULong (if mref.HasMetadata then 0x0000 else 0x0001);
- StringE (GetStringHeapIdx cenv mref.Name);
- (match mref.Hash with None -> Blob 0 | Some s -> Blob (GetBytesAsBlobIdx cenv s)); |]
+ [| ULong (if mref.HasMetadata then 0x0000 else 0x0001)
+ StringE (GetStringHeapIdx cenv mref.Name)
+ (match mref.Hash with None -> Blob 0 | Some s -> Blob (GetBytesAsBlobIdx cenv s)) |]
and GetModuleRefAsIdx cenv mref =
FindOrAddRow cenv TableNames.ModuleRef (GetModuleRefAsRow cenv mref)
@@ -1094,7 +1094,7 @@ and GetTypeRefAsTypeRefIdx cenv tref =
let mutable res = 0
if cenv.trefCache.TryGetValue(tref,&res) then res else
let res = FindOrAddRow cenv TableNames.TypeRef (GetTypeRefAsTypeRefRow cenv tref)
- cenv.trefCache.[tref] <- res;
+ cenv.trefCache.[tref] <- res
res
and GetTypeDescAsTypeRefIdx cenv (scoref,enc,n) =
@@ -1131,10 +1131,10 @@ let getTypeDefOrRefAsUncodedToken (tag,idx) =
let EmitArrayShape (bb: ByteBuffer) (ILArrayShape shape) =
let sized = List.filter (function (_,Some _) -> true | _ -> false) shape
let lobounded = List.filter (function (Some _,_) -> true | _ -> false) shape
- bb.EmitZ32 shape.Length;
- bb.EmitZ32 sized.Length;
- sized |> List.iter (function (_,Some sz) -> bb.EmitZ32 sz | _ -> failwith "?");
- bb.EmitZ32 lobounded.Length;
+ bb.EmitZ32 shape.Length
+ bb.EmitZ32 sized.Length
+ sized |> List.iter (function (_,Some sz) -> bb.EmitZ32 sz | _ -> failwith "?")
+ bb.EmitZ32 lobounded.Length
lobounded |> List.iter (function (Some low,_) -> bb.EmitZ32 low | _ -> failwith "?")
let hasthisToByte hasthis =
@@ -1158,13 +1158,13 @@ let callconvToByte ntypars (Callconv (hasthis,bcc)) =
// REVIEW: write into an accumuating buffer
let rec EmitTypeSpec cenv env (bb: ByteBuffer) (et,tspec:ILTypeSpec) =
if ILList.isEmpty tspec.GenericArgs then
- bb.EmitByte et;
+ bb.EmitByte et
emitTypeInfoAsTypeDefOrRefEncoded cenv bb (tspec.Scope,tspec.Enclosing,tspec.Name)
else
- bb.EmitByte et_WITH;
- bb.EmitByte et;
- emitTypeInfoAsTypeDefOrRefEncoded cenv bb (tspec.Scope,tspec.Enclosing,tspec.Name);
- bb.EmitZ32 tspec.GenericArgs.Length;
+ bb.EmitByte et_WITH
+ bb.EmitByte et
+ emitTypeInfoAsTypeDefOrRefEncoded cenv bb (tspec.Scope,tspec.Enclosing,tspec.Name)
+ bb.EmitZ32 tspec.GenericArgs.Length
EmitTypes cenv env bb tspec.GenericArgs
and GetTypeAsTypeDefOrRef cenv env (ty:ILType) =
@@ -1218,41 +1218,41 @@ and EmitType cenv env bb ty =
| ILType.TypeVar tv ->
let cgparams = env.EnclosingTyparCount
if int32 tv < cgparams then
- bb.EmitByte et_VAR;
+ bb.EmitByte et_VAR
bb.EmitZ32 (int32 tv)
else
- bb.EmitByte et_MVAR;
+ bb.EmitByte et_MVAR
bb.EmitZ32 (int32 tv - cgparams)
| ILType.Byref typ ->
- bb.EmitByte et_BYREF;
+ bb.EmitByte et_BYREF
EmitType cenv env bb typ
| ILType.Ptr typ ->
- bb.EmitByte et_PTR;
+ bb.EmitByte et_PTR
EmitType cenv env bb typ
| ILType.Void ->
bb.EmitByte et_VOID
| ILType.FunctionPointer x ->
- bb.EmitByte et_FNPTR;
+ bb.EmitByte et_FNPTR
EmitCallsig cenv env bb (x.CallingConv,x.ArgTypes,x.ReturnType,None,0)
| ILType.Modified (req,tref,ty) ->
- bb.EmitByte (if req then et_CMOD_REQD else et_CMOD_OPT);
- emitTypeInfoAsTypeDefOrRefEncoded cenv bb (tref.Scope, tref.Enclosing,tref.Name);
+ bb.EmitByte (if req then et_CMOD_REQD else et_CMOD_OPT)
+ emitTypeInfoAsTypeDefOrRefEncoded cenv bb (tref.Scope, tref.Enclosing,tref.Name)
EmitType cenv env bb ty
| _ -> failwith "EmitType"
and EmitCallsig cenv env bb (callconv,args:ILTypes,ret,varargs:ILVarArgs,genarity) =
- bb.EmitByte (callconvToByte genarity callconv);
- if genarity > 0 then bb.EmitZ32 genarity;
- bb.EmitZ32 ((args.Length + (match varargs with None -> 0 | Some l -> l.Length)));
- EmitType cenv env bb ret;
- args |> ILList.iter (EmitType cenv env bb);
+ bb.EmitByte (callconvToByte genarity callconv)
+ if genarity > 0 then bb.EmitZ32 genarity
+ bb.EmitZ32 ((args.Length + (match varargs with None -> 0 | Some l -> l.Length)))
+ EmitType cenv env bb ret
+ args |> ILList.iter (EmitType cenv env bb)
match varargs with
| None -> ()// no extra arg = no sentinel
| Some tys ->
if ILList.isEmpty tys then () // no extra arg = no sentinel
else
- bb.EmitByte et_SENTINEL;
+ bb.EmitByte et_SENTINEL
ILList.iter (EmitType cenv env bb) tys
and GetCallsigAsBytes cenv env x = emitBytesViaBuffer (fun bb -> EmitCallsig cenv env bb x)
@@ -1300,41 +1300,41 @@ and EmitNativeType bb ty =
let u1 = System.Text.Encoding.UTF8.GetBytes nativeTypeName
let u2 = System.Text.Encoding.UTF8.GetBytes custMarshallerName
let u3 = cookieString
- bb.EmitByte nt_CUSTOMMARSHALER;
- bb.EmitZ32 guid.Length;
- bb.EmitBytes guid;
- bb.EmitZ32 u1.Length; bb.EmitBytes u1;
- bb.EmitZ32 u2.Length; bb.EmitBytes u2;
+ bb.EmitByte nt_CUSTOMMARSHALER
+ bb.EmitZ32 guid.Length
+ bb.EmitBytes guid
+ bb.EmitZ32 u1.Length; bb.EmitBytes u1
+ bb.EmitZ32 u2.Length; bb.EmitBytes u2
bb.EmitZ32 u3.Length; bb.EmitBytes u3
| ILNativeType.FixedSysString i ->
- bb.EmitByte nt_FIXEDSYSSTRING;
+ bb.EmitByte nt_FIXEDSYSSTRING
bb.EmitZ32 i
| ILNativeType.FixedArray i ->
- bb.EmitByte nt_FIXEDARRAY;
+ bb.EmitByte nt_FIXEDARRAY
bb.EmitZ32 i
| (* COM interop *) ILNativeType.SafeArray (vt,name) ->
- bb.EmitByte nt_SAFEARRAY;
- bb.EmitZ32 (GetVariantTypeAsInt32 vt);
+ bb.EmitByte nt_SAFEARRAY
+ bb.EmitZ32 (GetVariantTypeAsInt32 vt)
match name with
| None -> ()
| Some n ->
let u1 = Bytes.stringAsUtf8NullTerminated n
bb.EmitZ32 (Array.length u1) ; bb.EmitBytes u1
| ILNativeType.Array (nt,sizeinfo) -> (* REVIEW: check if this corresponds to the ECMA spec *)
- bb.EmitByte nt_ARRAY;
+ bb.EmitByte nt_ARRAY
match nt with
| None -> bb.EmitZ32 (int nt_MAX)
| Some ntt ->
(if ntt = ILNativeType.Empty then
bb.EmitZ32 (int nt_MAX)
else
- EmitNativeType bb ntt);
+ EmitNativeType bb ntt)
match sizeinfo with
| None -> () // chunk out with zeroes because some tools (e.g. asmmeta) read these poorly and expect further elements.
| Some (pnum,additive) ->
// ParamNum
- bb.EmitZ32 pnum;
+ bb.EmitZ32 pnum
(* ElemMul *) (* z_u32 0x1l *)
match additive with
| None -> ()
@@ -1450,11 +1450,11 @@ let rec GetTypeDefAsRow cenv env _enc (td:ILTypeDef) =
let tdorTag, tdorRow = GetTypeOptionAsTypeDefOrRef cenv env td.Extends
UnsharedRow
- [| ULong flags ;
- nelem;
- nselem;
- TypeDefOrRefOrSpec (tdorTag, tdorRow);
- SimpleIndex (TableNames.Field, cenv.fieldDefs.Count + 1);
+ [| ULong flags
+ nelem
+ nselem
+ TypeDefOrRefOrSpec (tdorTag, tdorRow)
+ SimpleIndex (TableNames.Field, cenv.fieldDefs.Count + 1)
SimpleIndex (TableNames.Method,cenv.methodDefIdxsByKey.Count + 1) |]
and GetTypeOptionAsTypeDefOrRef cenv env tyOpt =
@@ -1464,12 +1464,12 @@ and GetTypeOptionAsTypeDefOrRef cenv env tyOpt =
and GetTypeDefAsPropertyMapRow cenv tidx =
UnsharedRow
- [| SimpleIndex (TableNames.TypeDef, tidx);
+ [| SimpleIndex (TableNames.TypeDef, tidx)
SimpleIndex (TableNames.Property, cenv.propertyDefs.Count + 1) |]
and GetTypeDefAsEventMapRow cenv tidx =
UnsharedRow
- [| SimpleIndex (TableNames.TypeDef, tidx);
+ [| SimpleIndex (TableNames.TypeDef, tidx)
SimpleIndex (TableNames.Event, cenv.eventDefs.Count + 1) |]
and GetKeyForFieldDef tidx (fd: ILFieldDef) =
@@ -1486,10 +1486,10 @@ and GenMethodDefPass2 cenv tidx md =
cenv.methodDefIdxsByKey.AddUniqueEntry
"method"
(fun (key:MethodDefKey) ->
- dprintn "Duplicate in method table is:";
- dprintn (" Type index: "+string key.TypeIdx);
- dprintn (" Method name: "+key.Name);
- dprintn (" Method arity (num generic params): "+string key.GenericArity);
+ dprintn "Duplicate in method table is:"
+ dprintn (" Type index: "+string key.TypeIdx)
+ dprintn (" Method name: "+key.Name)
+ dprintn (" Method arity (num generic params): "+string key.GenericArity)
key.Name
)
(GetKeyForMethodDef tidx md)
@@ -1505,7 +1505,7 @@ and GenPropertyDefPass2 cenv tidx x =
and GetTypeAsImplementsRow cenv env tidx ty =
let tdorTag,tdorRow = GetTypeAsTypeDefOrRef cenv env ty
UnsharedRow
- [| SimpleIndex (TableNames.TypeDef, tidx);
+ [| SimpleIndex (TableNames.TypeDef, tidx)
TypeDefOrRefOrSpec (tdorTag,tdorRow) |]
and GenImplementsPass2 cenv env tidx ty =
@@ -1522,33 +1522,33 @@ and GenTypeDefPass2 pidx enc cenv (td:ILTypeDef) =
let env = envForTypeDef td
let tidx = GetIdxForTypeDef cenv (TdKey(enc,td.Name))
let tidx2 = AddUnsharedRow cenv TableNames.TypeDef (GetTypeDefAsRow cenv env enc td)
- if tidx <> tidx2 then failwith "index of typedef on second pass does not match index on first pass";
+ if tidx <> tidx2 then failwith "index of typedef on second pass does not match index on first pass"
// Add entries to auxiliary mapping tables, e.g. Nested, PropertyMap etc.
// Note Nested is organised differntly to the others...
if nonNil enc then
AddUnsharedRow cenv TableNames.Nested
(UnsharedRow
- [| SimpleIndex (TableNames.TypeDef, tidx);
- SimpleIndex (TableNames.TypeDef, pidx) |]) |> ignore;
+ [| SimpleIndex (TableNames.TypeDef, tidx)
+ SimpleIndex (TableNames.TypeDef, pidx) |]) |> ignore
let props = td.Properties.AsList
if nonNil props then
- AddUnsharedRow cenv TableNames.PropertyMap (GetTypeDefAsPropertyMapRow cenv tidx) |> ignore;
+ AddUnsharedRow cenv TableNames.PropertyMap (GetTypeDefAsPropertyMapRow cenv tidx) |> ignore
let events = td.Events.AsList
if nonNil events then
- AddUnsharedRow cenv TableNames.EventMap (GetTypeDefAsEventMapRow cenv tidx) |> ignore;
+ AddUnsharedRow cenv TableNames.EventMap (GetTypeDefAsEventMapRow cenv tidx) |> ignore
// Now generate or assign index numbers for tables referenced by the maps.
// Don't yet generate contents of these tables - leave that to pass3, as
// code may need to embed these entries.
- td.Implements |> ILList.iter (GenImplementsPass2 cenv env tidx);
- props |> List.iter (GenPropertyDefPass2 cenv tidx);
- events |> List.iter (GenEventDefPass2 cenv tidx);
- td.Fields.AsList |> List.iter (GenFieldDefPass2 cenv tidx);
- td.Methods |> Seq.iter (GenMethodDefPass2 cenv tidx);
+ td.Implements |> ILList.iter (GenImplementsPass2 cenv env tidx)
+ props |> List.iter (GenPropertyDefPass2 cenv tidx)
+ events |> List.iter (GenEventDefPass2 cenv tidx)
+ td.Fields.AsList |> List.iter (GenFieldDefPass2 cenv tidx)
+ td.Methods |> Seq.iter (GenMethodDefPass2 cenv tidx)
td.NestedTypes.AsList |> GenTypeDefsPass2 tidx (enc@[td.Name]) cenv
with e ->
- failwith ("Error in pass2 for type "+td.Name+", error: "+e.Message);
+ failwith ("Error in pass2 for type "+td.Name+", error: "+e.Message)
and GenTypeDefsPass2 pidx enc cenv tds =
List.iter (GenTypeDefPass2 pidx enc cenv) tds
@@ -1575,14 +1575,14 @@ let FindMethodDefIdx cenv mdkey =
| Some x -> x
| None -> raise MethodDefNotFound
let (TdKey (tenc,tname)) = typeNameOfIdx mdkey.TypeIdx
- dprintn ("The local method '"+(String.concat "." (tenc@[tname]))+"'::'"+mdkey.Name+"' was referenced but not declared");
- dprintn ("generic arity: "+string mdkey.GenericArity);
+ dprintn ("The local method '"+(String.concat "." (tenc@[tname]))+"'::'"+mdkey.Name+"' was referenced but not declared")
+ dprintn ("generic arity: "+string mdkey.GenericArity)
cenv.methodDefIdxsByKey.dict |> Seq.iter (fun (KeyValue(mdkey2,_)) ->
if mdkey2.TypeIdx = mdkey.TypeIdx && mdkey.Name = mdkey2.Name then
let (TdKey (tenc2,tname2)) = typeNameOfIdx mdkey2.TypeIdx
- dprintn ("A method in '"+(String.concat "." (tenc2@[tname2]))+"' had the right name but the wrong signature:");
- dprintn ("generic arity: "+string mdkey2.GenericArity) ;
- dprintn (sprintf "mdkey2: %A" mdkey2)) ;
+ dprintn ("A method in '"+(String.concat "." (tenc2@[tname2]))+"' had the right name but the wrong signature:")
+ dprintn ("generic arity: "+string mdkey2.GenericArity)
+ dprintn (sprintf "mdkey2: %A" mdkey2))
raise MethodDefNotFound
@@ -1592,7 +1592,7 @@ let rec GetMethodDefIdx cenv md =
and FindFieldDefIdx cenv fdkey =
try cenv.fieldDefs.GetTableEntry fdkey
with :? KeyNotFoundException ->
- errorR(InternalError("The local field "+fdkey.Name+" was referenced but not declared",range0));
+ errorR(InternalError("The local field "+fdkey.Name+" was referenced but not declared",range0))
1
and GetFieldDefAsFieldDefIdx cenv tidx fd =
@@ -1609,12 +1609,12 @@ let GetMethodRefAsMethodDefIdx cenv (mref:ILMethodRef) =
let tref = mref.EnclosingTypeRef
try
if not (isTypeRefLocal tref) then
- failwithf "method referred to by method impl, event or property is not in a type defined in this module, method ref is %A" mref;
+ failwithf "method referred to by method impl, event or property is not in a type defined in this module, method ref is %A" mref
let tidx = GetIdxForTypeDef cenv (TdKey(tref.Enclosing,tref.Name))
let mdkey = MethodDefKey (tidx,mref.GenericArity, mref.Name, mref.ReturnType, mref.ArgTypes, mref.CallingConv.IsStatic)
FindMethodDefIdx cenv mdkey
with e ->
- failwithf "Error in GetMethodRefAsMethodDefIdx for mref = %A, error: %s" (mref.Name, tref.Name) e.Message;
+ failwithf "Error in GetMethodRefAsMethodDefIdx for mref = %A, error: %s" (mref.Name, tref.Name) e.Message
let rec MethodRefInfoAsMemberRefRow cenv env fenv (nm,typ,callconv,args,ret,varargs,genarity) =
MemberRefRow(GetTypeAsMemberRefParent cenv env typ,
@@ -1631,7 +1631,7 @@ let GetMethodRefInfoAsMemberRefIdx cenv env ((_,typ,_,_,_,_,_) as minfo) =
let GetMethodRefInfoAsMethodRefOrDef isAlwaysMethodDef cenv env ((nm,typ:ILType,cc,args,ret,varargs,genarity) as minfo) =
if isNone varargs && (isAlwaysMethodDef || isTypeLocal typ) then
- if not typ.IsNominal then failwith "GetMethodRefInfoAsMethodRefOrDef: unexpected local tref-typ";
+ if not typ.IsNominal then failwith "GetMethodRefInfoAsMethodRefOrDef: unexpected local tref-typ"
try (mdor_MethodDef, GetMethodRefAsMethodDefIdx cenv (mkILMethRefRaw(typ.TypeRef, cc, nm, genarity, args,ret)))
with MethodDefNotFound -> (mdor_MemberRef, GetMethodRefInfoAsMemberRefIdx cenv env minfo)
else (mdor_MemberRef, GetMethodRefInfoAsMemberRefIdx cenv env minfo)
@@ -1645,12 +1645,12 @@ let rec GetMethodSpecInfoAsMethodSpecIdx cenv env (nm,typ,cc,args,ret,varargs,mi
let mdorTag,mdorRow = GetMethodRefInfoAsMethodRefOrDef false cenv env (nm,typ,cc,args,ret,varargs,minst.Length)
let blob =
emitBytesViaBuffer (fun bb ->
- bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_GENERICINST;
- bb.EmitZ32 minst.Length;
+ bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_GENERICINST
+ bb.EmitZ32 minst.Length
minst |> ILList.iter (EmitType cenv env bb))
FindOrAddRow cenv TableNames.MethodSpec
(SimpleSharedRow
- [| MethodDefOrRef (mdorTag,mdorRow);
+ [| MethodDefOrRef (mdorTag,mdorRow)
Blob (GetBytesAsBlobIdx cenv blob) |])
and GetMethodDefOrRefAsUncodedToken (tag,idx) =
@@ -1709,7 +1709,7 @@ let rec GetOverridesSpecAsMemberRefIdx cenv env ospec =
and GetOverridesSpecAsMethodDefOrRef cenv env (ospec:ILOverridesSpec) =
let typ = ospec.EnclosingType
if isTypeLocal typ then
- if not typ.IsNominal then failwith "GetOverridesSpecAsMethodDefOrRef: unexpected local tref-typ";
+ if not typ.IsNominal then failwith "GetOverridesSpecAsMethodDefOrRef: unexpected local tref-typ"
try (mdor_MethodDef, GetMethodRefAsMethodDefIdx cenv ospec.MethodRef)
with MethodDefNotFound -> (mdor_MemberRef, GetOverridesSpecAsMemberRefIdx cenv env ospec)
else
@@ -1752,9 +1752,9 @@ let rec GetCustomAttrDataAsBlobIdx cenv (data:byte[]) =
and GetCustomAttrRow cenv hca attr =
let cat = GetMethodRefAsCustomAttribType cenv attr.Method.MethodRef
UnsharedRow
- [| HasCustomAttribute (fst hca, snd hca);
- CustomAttributeType (fst cat, snd cat);
- Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data); |]
+ [| HasCustomAttribute (fst hca, snd hca)
+ CustomAttributeType (fst cat, snd cat)
+ Blob (GetCustomAttrDataAsBlobIdx cenv attr.Data) |]
and GenCustomAttrPass3Or4 cenv hca attr =
AddUnsharedRow cenv TableNames.CustomAttribute (GetCustomAttrRow cenv hca attr) |> ignore
@@ -1768,9 +1768,9 @@ and GenCustomAttrsPass3Or4 cenv hca (attrs: ILAttributes) =
let rec GetSecurityDeclRow cenv hds (PermissionSet (action, s)) =
UnsharedRow
- [| UShort (uint16 (List.assoc action (Lazy.force ILSecurityActionMap)));
- HasDeclSecurity (fst hds, snd hds);
- Blob (GetBytesAsBlobIdx cenv s); |]
+ [| UShort (uint16 (List.assoc action (Lazy.force ILSecurityActionMap)))
+ HasDeclSecurity (fst hds, snd hds)
+ Blob (GetBytesAsBlobIdx cenv s) |]
and GenSecurityDeclPass3 cenv hds attr =
AddUnsharedRow cenv TableNames.Permission (GetSecurityDeclRow cenv hds attr) |> ignore
@@ -1793,7 +1793,7 @@ and GetFieldSpecAsMemberRefIdx cenv env fspec =
// REVIEW: write into an accumuating buffer
and EmitFieldSpecSig cenv env (bb: ByteBuffer) (fspec:ILFieldSpec) =
- bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD;
+ bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD
EmitType cenv env bb fspec.FormalType
and GetFieldSpecSigAsBytes cenv env x =
@@ -1805,7 +1805,7 @@ and GetFieldSpecSigAsBlobIdx cenv env x =
and GetFieldSpecAsFieldDefOrRef cenv env (fspec:ILFieldSpec) =
let typ = fspec.EnclosingType
if isTypeLocal typ then
- if not typ.IsNominal then failwith "GetFieldSpecAsFieldDefOrRef: unexpected local tref-typ";
+ if not typ.IsNominal then failwith "GetFieldSpecAsFieldDefOrRef: unexpected local tref-typ"
let tref = typ.TypeRef
let tidx = GetIdxForTypeDef cenv (TdKey(tref.Enclosing,tref.Name))
let fdkey = FieldDefKey (tidx,fspec.Name, fspec.FormalType)
@@ -1838,8 +1838,8 @@ let GetCallsigAsStandAloneSigIdx cenv env info =
// --------------------------------------------------------------------
let EmitLocalSig cenv env (bb: ByteBuffer) (locals: ILLocals) =
- bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_LOCAL_SIG;
- bb.EmitZ32 locals.Length;
+ bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_LOCAL_SIG
+ bb.EmitZ32 locals.Length
locals |> ILList.iter (fun l -> EmitType cenv env bb l.Type)
let GetLocalSigAsBlobHeapIdx cenv env locals =
@@ -1867,21 +1867,21 @@ type CodeBuffer =
// - locations of embedded handles into the string table
// - the exception table
// --------------------------------------------------------------------
- { code: ByteBuffer;
+ { code: ByteBuffer
/// (instruction; optional short form); start of instr in code buffer; code loc for the end of the instruction the fixup resides in ; where is the destination of the fixup
- mutable reqdBrFixups: ((int * int option) * int * ILCodeLabel list) list;
- availBrFixups: Dictionary ;
+ mutable reqdBrFixups: ((int * int option) * int * ILCodeLabel list) list
+ availBrFixups: Dictionary
/// code loc to fixup in code buffer
- mutable reqdStringFixupsInMethod: (int * int) list;
+ mutable reqdStringFixupsInMethod: (int * int) list
/// data for exception handling clauses
- mutable seh: ExceptionClauseSpec list;
- seqpoints: ResizeArray; }
+ mutable seh: ExceptionClauseSpec list
+ seqpoints: ResizeArray }
static member Create _nm =
- { seh = [];
- code= ByteBuffer.Create 200;
- reqdBrFixups=[];
- reqdStringFixupsInMethod=[];
+ { seh = []
+ code= ByteBuffer.Create 200
+ reqdBrFixups=[]
+ reqdStringFixupsInMethod=[]
availBrFixups = Dictionary<_,_>(10, HashIdentity.Structural)
seqpoints = new ResizeArray<_>(10)
}
@@ -1893,12 +1893,12 @@ type CodeBuffer =
// table indexes are 1-based, document array indexes are 0-based
let doc = (cenv.documents.FindOrAddSharedEntry m.Document) - 1
codebuf.seqpoints.Add
- { Document=doc;
- Offset= codebuf.code.Position;
- Line=m.Line;
- Column=m.Column;
- EndLine=m.EndLine;
- EndColumn=m.EndColumn; }
+ { Document=doc
+ Offset= codebuf.code.Position
+ Line=m.Line
+ Column=m.Column
+ EndLine=m.EndLine
+ EndColumn=m.EndColumn }
member codebuf.EmitByte x = codebuf.code.EmitIntAsByte x
member codebuf.EmitUInt16 x = codebuf.code.EmitUInt16 x
@@ -1908,17 +1908,17 @@ type CodeBuffer =
member codebuf.EmitUncodedToken u = codebuf.EmitInt32 u
member codebuf.RecordReqdStringFixup stringidx =
- codebuf.reqdStringFixupsInMethod <- (codebuf.code.Position, stringidx) :: codebuf.reqdStringFixupsInMethod;
+ codebuf.reqdStringFixupsInMethod <- (codebuf.code.Position, stringidx) :: codebuf.reqdStringFixupsInMethod
// Write a special value in that we check later when applying the fixup
codebuf.EmitInt32 0xdeadbeef
member codebuf.RecordReqdBrFixups i tgs =
- codebuf.reqdBrFixups <- (i, codebuf.code.Position, tgs) :: codebuf.reqdBrFixups;
+ codebuf.reqdBrFixups <- (i, codebuf.code.Position, tgs) :: codebuf.reqdBrFixups
// Write a special value in that we check later when applying the fixup
// Value is 0x11 {deadbbbb}* where 11 is for the instruction and deadbbbb is for each target
- codebuf.EmitByte 0x11; // for the instruction
+ codebuf.EmitByte 0x11 // for the instruction
(if fst i = i_switch then
- codebuf.EmitInt32 tgs.Length);
+ codebuf.EmitInt32 tgs.Length)
List.iter (fun _ -> codebuf.EmitInt32 0xdeadbbbb) tgs
member codebuf.RecordReqdBrFixup i tg = codebuf.RecordReqdBrFixups i [tg]
@@ -1973,25 +1973,25 @@ module Codebuf = begin
// Copy over a chunk of non-branching code
let nobranch_len = origEndOfNoBranchBlock - origStartOfNoBranchBlock
- newCode.EmitBytes origCode.[origStartOfNoBranchBlock..origStartOfNoBranchBlock+nobranch_len-1];
+ newCode.EmitBytes origCode.[origStartOfNoBranchBlock..origStartOfNoBranchBlock+nobranch_len-1]
// Record how to adjust addresses in this range, including the branch instruction
// we write below, or the end of the method if we're doing the last bblock
- adjustments := (origStartOfNoBranchBlock,origEndOfNoBranchBlock,newStartOfNoBranchBlock) :: !adjustments;
+ adjustments := (origStartOfNoBranchBlock,origEndOfNoBranchBlock,newStartOfNoBranchBlock) :: !adjustments
// Increment locations to the branch instruction we're really interested in
- origWhere := origEndOfNoBranchBlock;
- newWhere := !newWhere + nobranch_len;
+ origWhere := origEndOfNoBranchBlock
+ newWhere := !newWhere + nobranch_len
// Now do the branch instruction. Decide whether the fixup will be short or long in the new code
if doingLast then
doneLast := true
else
let (i,origStartOfInstr,tgs:ILCodeLabel list) = List.head !remainingReqdFixups
- remainingReqdFixups := List.tail !remainingReqdFixups;
- if origCode.[origStartOfInstr] <> 0x11uy then failwith "br fixup sanity check failed (1)";
+ remainingReqdFixups := List.tail !remainingReqdFixups
+ if origCode.[origStartOfInstr] <> 0x11uy then failwith "br fixup sanity check failed (1)"
let i_length = if fst i = i_switch then 5 else 1
- origWhere := !origWhere + i_length;
+ origWhere := !origWhere + i_length
let origEndOfInstr = origStartOfInstr + i_length + 4 * tgs.Length
let newEndOfInstrIfSmall = !newWhere + i_length + 1
@@ -2005,7 +2005,7 @@ module Codebuf = begin
// Use the original offsets to compute if the branch is small or large. This is
// a safe approximation because code only gets smaller.
if not (origAvailBrFixups.ContainsKey tg) then
- dprintn ("branch target " + formatCodeLabel tg + " not found in code");
+ dprintn ("branch target " + formatCodeLabel tg + " not found in code")
let origDest =
if origAvailBrFixups.ContainsKey tg then origAvailBrFixups.[tg]
else 666666
@@ -2013,33 +2013,33 @@ module Codebuf = begin
-128 <= origRelOffset && origRelOffset <= 127
end
->
- newCode.EmitIntAsByte i_short;
+ newCode.EmitIntAsByte i_short
true
| (i_long,_),_ ->
- newCode.EmitIntAsByte i_long;
+ newCode.EmitIntAsByte i_long
(if i_long = i_switch then
- newCode.EmitInt32 tgs.Length);
+ newCode.EmitInt32 tgs.Length)
false
- newWhere := !newWhere + i_length;
- if !newWhere <> newCode.Position then dprintn "mismatch between newWhere and newCode";
+ newWhere := !newWhere + i_length
+ if !newWhere <> newCode.Position then dprintn "mismatch between newWhere and newCode"
tgs |> List.iter (fun tg ->
let origFixupLoc = !origWhere
- checkFixup32 origCode origFixupLoc 0xdeadbbbb;
+ checkFixup32 origCode origFixupLoc 0xdeadbbbb
if short then
- newReqdBrFixups := (!newWhere, newEndOfInstrIfSmall, tg, true) :: !newReqdBrFixups;
- newCode.EmitIntAsByte 0x98; (* sanity check *)
- newWhere := !newWhere + 1;
+ newReqdBrFixups := (!newWhere, newEndOfInstrIfSmall, tg, true) :: !newReqdBrFixups
+ newCode.EmitIntAsByte 0x98 (* sanity check *)
+ newWhere := !newWhere + 1
else
- newReqdBrFixups := (!newWhere, newEndOfInstrIfBig, tg, false) :: !newReqdBrFixups;
- newCode.EmitInt32 0xf00dd00f; (* sanity check *)
- newWhere := !newWhere + 4;
- if !newWhere <> newCode.Position then dprintn "mismatch between newWhere and newCode";
- origWhere := !origWhere + 4);
+ newReqdBrFixups := (!newWhere, newEndOfInstrIfBig, tg, false) :: !newReqdBrFixups
+ newCode.EmitInt32 0xf00dd00f (* sanity check *)
+ newWhere := !newWhere + 4
+ if !newWhere <> newCode.Position then dprintn "mismatch between newWhere and newCode"
+ origWhere := !origWhere + 4)
- if !origWhere <> origEndOfInstr then dprintn "mismatch between origWhere and origEndOfInstr";
+ if !origWhere <> origEndOfInstr then dprintn "mismatch between origWhere and origEndOfInstr"
let adjuster =
let arr = Array.ofList (List.rev !adjustments)
@@ -2074,25 +2074,25 @@ module Codebuf = begin
let newScopes =
let rec remap scope =
- {scope with StartOffset = adjuster scope.StartOffset;
- EndOffset = adjuster scope.EndOffset;
+ {scope with StartOffset = adjuster scope.StartOffset
+ EndOffset = adjuster scope.EndOffset
Children = Array.map remap scope.Children }
List.map remap origScopes
// Now apply the adjusted fixups in the new code
newReqdBrFixups |> List.iter (fun (newFixupLoc,endOfInstr,tg, small) ->
if not (newAvailBrFixups.ContainsKey tg) then
- failwith ("target "+formatCodeLabel tg+" not found in new fixups");
+ failwith ("target "+formatCodeLabel tg+" not found in new fixups")
try
let n = newAvailBrFixups.[tg]
let relOffset = (n - endOfInstr)
if small then
- if Bytes.get newCode newFixupLoc <> 0x98 then failwith "br fixupsanity check failed";
- newCode.[newFixupLoc] <- b0 relOffset;
+ if Bytes.get newCode newFixupLoc <> 0x98 then failwith "br fixupsanity check failed"
+ newCode.[newFixupLoc] <- b0 relOffset
else
- checkFixup32 newCode newFixupLoc 0xf00dd00fl;
+ checkFixup32 newCode newFixupLoc 0xf00dd00fl
applyFixup32 newCode newFixupLoc relOffset
- with :? KeyNotFoundException -> ());
+ with :? KeyNotFoundException -> ())
newCode, newReqdStringFixups, newExnClauses, newSeqPoints, newScopes
@@ -2129,44 +2129,44 @@ module Codebuf = begin
/// Emit the code for an instruction
let emitInstrCode (codebuf: CodeBuffer) i =
if i > 0xFF then
- assert (i >>> 8 = 0xFE);
- codebuf.EmitByte ((i >>> 8) &&& 0xFF);
- codebuf.EmitByte (i &&& 0xFF);
+ assert (i >>> 8 = 0xFE)
+ codebuf.EmitByte ((i >>> 8) &&& 0xFF)
+ codebuf.EmitByte (i &&& 0xFF)
else
codebuf.EmitByte i
let emitTypeInstr cenv codebuf env i ty =
- emitInstrCode codebuf i;
+ emitInstrCode codebuf i
codebuf.EmitUncodedToken (getTypeDefOrRefAsUncodedToken (GetTypeAsTypeDefOrRef cenv env ty))
let emitMethodSpecInfoInstr cenv codebuf env i mspecinfo =
- emitInstrCode codebuf i;
+ emitInstrCode codebuf i
codebuf.EmitUncodedToken (GetMethodSpecInfoAsUncodedToken cenv env mspecinfo)
let emitMethodSpecInstr cenv codebuf env i mspec =
- emitInstrCode codebuf i;
+ emitInstrCode codebuf i
codebuf.EmitUncodedToken (GetMethodSpecAsUncodedToken cenv env mspec)
let emitFieldSpecInstr cenv codebuf env i fspec =
- emitInstrCode codebuf i;
+ emitInstrCode codebuf i
codebuf.EmitUncodedToken (GetFieldDefOrRefAsUncodedToken (GetFieldSpecAsFieldDefOrRef cenv env fspec))
let emitShortUInt16Instr codebuf (i_short,i) x =
let n = int32 x
if n <= 255 then
- emitInstrCode codebuf i_short;
- codebuf.EmitByte n;
+ emitInstrCode codebuf i_short
+ codebuf.EmitByte n
else
- emitInstrCode codebuf i;
- codebuf.EmitUInt16 x;
+ emitInstrCode codebuf i
+ codebuf.EmitUInt16 x
let emitShortInt32Instr codebuf (i_short,i) x =
if x >= (-128) && x <= 127 then
- emitInstrCode codebuf i_short;
- codebuf.EmitByte (if x < 0x0 then x + 256 else x);
+ emitInstrCode codebuf i_short
+ codebuf.EmitByte (if x < 0x0 then x + 256 else x)
else
- emitInstrCode codebuf i;
- codebuf.EmitInt32 x;
+ emitInstrCode codebuf i
+ codebuf.EmitInt32 x
let emitTailness (cenv: cenv) codebuf tl =
if tl = Tailcall && cenv.emitTailcalls then emitInstrCode codebuf i_tail
@@ -2178,7 +2178,7 @@ module Codebuf = begin
if tl = Volatile then emitInstrCode codebuf i_volatile
let emitConstrained cenv codebuf env ty =
- emitInstrCode codebuf i_constrained;
+ emitInstrCode codebuf i_constrained
codebuf.EmitUncodedToken (getTypeDefOrRefAsUncodedToken (GetTypeAsTypeDefOrRef cenv env ty))
let emitAlignment codebuf tl =
@@ -2198,17 +2198,17 @@ module Codebuf = begin
| I_seqpoint s -> codebuf.EmitSeqPoint cenv s
| I_leave tg -> codebuf.RecordReqdBrFixup (i_leave,Some i_leave_s) tg
| I_call (tl,mspec,varargs) ->
- emitTailness cenv codebuf tl;
- emitMethodSpecInstr cenv codebuf env i_call (mspec,varargs);
+ emitTailness cenv codebuf tl
+ emitMethodSpecInstr cenv codebuf env i_call (mspec,varargs)
emitAfterTailcall codebuf tl
| I_callvirt (tl,mspec,varargs) ->
- emitTailness cenv codebuf tl;
- emitMethodSpecInstr cenv codebuf env i_callvirt (mspec,varargs);
+ emitTailness cenv codebuf tl
+ emitMethodSpecInstr cenv codebuf env i_callvirt (mspec,varargs)
emitAfterTailcall codebuf tl
| I_callconstraint (tl,ty,mspec,varargs) ->
- emitTailness cenv codebuf tl;
- emitConstrained cenv codebuf env ty;
- emitMethodSpecInstr cenv codebuf env i_callvirt (mspec,varargs);
+ emitTailness cenv codebuf tl
+ emitConstrained cenv codebuf env ty
+ emitMethodSpecInstr cenv codebuf env i_callvirt (mspec,varargs)
emitAfterTailcall codebuf tl
| I_newobj (mspec,varargs) ->
emitMethodSpecInstr cenv codebuf env i_newobj (mspec,varargs)
@@ -2218,9 +2218,9 @@ module Codebuf = begin
emitMethodSpecInstr cenv codebuf env i_ldvirtftn (mspec,None)
| I_calli (tl,callsig,varargs) ->
- emitTailness cenv codebuf tl;
- emitInstrCode codebuf i_calli;
- codebuf.EmitUncodedToken (getUncodedToken TableNames.StandAloneSig (GetCallsigAsStandAloneSigIdx cenv env (callsig,varargs)));
+ emitTailness cenv codebuf tl
+ emitInstrCode codebuf i_calli
+ codebuf.EmitUncodedToken (getUncodedToken TableNames.StandAloneSig (GetCallsigAsStandAloneSigIdx cenv env (callsig,varargs)))
emitAfterTailcall codebuf tl
| I_ldarg u16 -> emitShortUInt16Instr codebuf (i_ldarg_s,i_ldarg) u16
@@ -2231,29 +2231,29 @@ module Codebuf = begin
| I_ldloca u16 -> emitShortUInt16Instr codebuf (i_ldloca_s,i_ldloca) u16
| I_cpblk (al,vol) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitInstrCode codebuf i_cpblk
| I_initblk (al,vol) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitInstrCode codebuf i_initblk
| (AI_ldc (DT_I4, ILConst.I4 x)) ->
emitShortInt32Instr codebuf (i_ldc_i4_s,i_ldc_i4) x
| (AI_ldc (DT_I8, ILConst.I8 x)) ->
- emitInstrCode codebuf i_ldc_i8;
- codebuf.EmitInt64 x;
+ emitInstrCode codebuf i_ldc_i8
+ codebuf.EmitInt64 x
| (AI_ldc (_, ILConst.R4 x)) ->
- emitInstrCode codebuf i_ldc_r4;
+ emitInstrCode codebuf i_ldc_r4
codebuf.EmitInt32 (bitsOfSingle x)
| (AI_ldc (_, ILConst.R8 x)) ->
- emitInstrCode codebuf i_ldc_r8;
+ emitInstrCode codebuf i_ldc_r8
codebuf.EmitInt64 (bitsOfDouble x)
| I_ldind (al,vol,dt) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitInstrCode codebuf
(match dt with
| DT_I -> i_ldind_i
@@ -2299,8 +2299,8 @@ module Codebuf = begin
| _ -> failwith "ldelem")
| I_stind (al,vol,dt) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitInstrCode codebuf
(match dt with
| DT_U | DT_I -> i_stind_i
@@ -2316,26 +2316,26 @@ module Codebuf = begin
| I_switch (labs,_) -> codebuf.RecordReqdBrFixups (i_switch,None) labs
| I_ldfld (al,vol,fspec) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitFieldSpecInstr cenv codebuf env i_ldfld fspec
| I_ldflda fspec ->
emitFieldSpecInstr cenv codebuf env i_ldflda fspec
| I_ldsfld (vol,fspec) ->
- emitVolatility codebuf vol;
+ emitVolatility codebuf vol
emitFieldSpecInstr cenv codebuf env i_ldsfld fspec
| I_ldsflda fspec ->
emitFieldSpecInstr cenv codebuf env i_ldsflda fspec
| I_stfld (al,vol,fspec) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitFieldSpecInstr cenv codebuf env i_stfld fspec
| I_stsfld (vol,fspec) ->
- emitVolatility codebuf vol;
+ emitVolatility codebuf vol
emitFieldSpecInstr cenv codebuf env i_stsfld fspec
| I_ldtoken tok ->
- emitInstrCode codebuf i_ldtoken;
+ emitInstrCode codebuf i_ldtoken
codebuf.EmitUncodedToken
(match tok with
| ILToken.ILType typ ->
@@ -2355,7 +2355,7 @@ module Codebuf = begin
| (true,idx) -> getUncodedToken TableNames.Field idx
| (false,idx) -> getUncodedToken TableNames.MemberRef idx)
| I_ldstr s ->
- emitInstrCode codebuf i_ldstr;
+ emitInstrCode codebuf i_ldstr
codebuf.RecordReqdStringFixup (GetUserStringHeapIdx cenv s)
| I_box ty -> emitTypeInstr cenv codebuf env i_box ty
@@ -2385,7 +2385,7 @@ module Codebuf = begin
| I_ldelema (ro,_isNativePtr,shape,ty) ->
if (ro = ReadonlyAddress) then
- emitInstrCode codebuf i_readonly;
+ emitInstrCode codebuf i_readonly
if (shape = ILArrayShape.SingleDimensional) then
emitTypeInstr cenv codebuf env i_ldelema ty
else
@@ -2398,17 +2398,17 @@ module Codebuf = begin
| I_mkrefany ty -> emitTypeInstr cenv codebuf env i_mkrefany ty
| I_initobj ty -> emitTypeInstr cenv codebuf env i_initobj ty
| I_ldobj (al,vol,ty) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitTypeInstr cenv codebuf env i_ldobj ty
| I_stobj (al,vol,ty) ->
- emitAlignment codebuf al;
- emitVolatility codebuf vol;
+ emitAlignment codebuf al
+ emitVolatility codebuf vol
emitTypeInstr cenv codebuf env i_stobj ty
| I_cpobj ty -> emitTypeInstr cenv codebuf env i_cpobj ty
| I_sizeof ty -> emitTypeInstr cenv codebuf env i_sizeof ty
| EI_ldlen_multi (_,m) ->
- emitShortInt32Instr codebuf (i_ldc_i4_s,i_ldc_i4) m;
+ emitShortInt32Instr codebuf (i_ldc_i4_s,i_ldc_i4) m
emitInstr cenv codebuf env (mkNormalCall(mkILNonGenericMethSpecInTy(cenv.ilg.typ_Array, ILCallingConv.Instance, "GetLength", [(cenv.ilg.typ_int32)], (cenv.ilg.typ_int32))))
| _ -> failwith "an IL instruction cannot be emitted"
@@ -2417,31 +2417,31 @@ module Codebuf = begin
let mkScopeNode cenv (localSigs: _[]) (a,b,ls,ch) =
if (isNil ls || not cenv.generatePdb) then ch
else
- [ { Children= Array.ofList ch;
- StartOffset=a;
- EndOffset=b;
+ [ { Children= Array.ofList ch
+ StartOffset=a
+ EndOffset=b
Locals=
Array.ofList
(List.map
- (fun x -> { Name=x.LocalName;
- Signature= (try localSigs.[x.LocalIndex] with _ -> failwith ("local variable index "+string x.LocalIndex+"in debug info does not reference a valid local"));
+ (fun x -> { Name=x.LocalName
+ Signature= (try localSigs.[x.LocalIndex] with _ -> failwith ("local variable index "+string x.LocalIndex+"in debug info does not reference a valid local"))
Index= x.LocalIndex } )
(List.filter (fun v -> v.LocalName <> "") ls)) } ]
let rec emitCode cenv localSigs codebuf env (susp,code) =
match code with
| TryBlock (c,seh) ->
- commitSusp codebuf susp (uniqueEntryOfCode c);
+ commitSusp codebuf susp (uniqueEntryOfCode c)
let tryStart = codebuf.code.Position
let susp,child1,scope1 = emitCode cenv localSigs codebuf env (None,c)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let tryFinish = codebuf.code.Position
let exnBranches =
match seh with
| FaultBlock flt ->
let handlerStart = codebuf.code.Position
let susp,child2,scope2 = emitCode cenv localSigs codebuf env (None,flt)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let handlerFinish = codebuf.code.Position
[ Some (tryStart,(tryFinish - tryStart),
handlerStart,(handlerFinish - handlerStart),
@@ -2451,7 +2451,7 @@ module Codebuf = begin
| FinallyBlock flt ->
let handlerStart = codebuf.code.Position
let susp,child2,scope2 = emitCode cenv localSigs codebuf env (None,flt)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let handlerFinish = codebuf.code.Position
[ Some (tryStart,(tryFinish - tryStart),
handlerStart,(handlerFinish - handlerStart),
@@ -2464,7 +2464,7 @@ module Codebuf = begin
| TypeFilter typ ->
let handlerStart = codebuf.code.Position
let susp,child2,scope2 = emitCode cenv localSigs codebuf env (None,ctch)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let handlerFinish = codebuf.code.Position
Some (tryStart,(tryFinish - tryStart),
handlerStart,(handlerFinish - handlerStart),
@@ -2474,10 +2474,10 @@ module Codebuf = begin
let filterStart = codebuf.code.Position
let susp,child2,scope2 = emitCode cenv localSigs codebuf env (None,fltcode)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let handlerStart = codebuf.code.Position
let susp,child3,scope3 = emitCode cenv localSigs codebuf env (None,ctch)
- commitSuspNoDest codebuf susp;
+ commitSuspNoDest codebuf susp
let handlerFinish = codebuf.code.Position
Some (tryStart,
@@ -2506,8 +2506,8 @@ module Codebuf = begin
let childScopes = ref []
// Push the results of collecting one sub-block into the reference cells
let collect (susp,seh,scopes) =
- newSusp := susp;
- childSEH := seh :: !childSEH;
+ newSusp := susp
+ childSEH := seh :: !childSEH
childScopes := scopes :: !childScopes
// Close the collection by generating the (susp,node,scope-node) triple
let close () =
@@ -2520,12 +2520,12 @@ module Codebuf = begin
| [c] ->
// emitCodeLinear sequence of nested blocks
emitCodeLinear (!newSusp,c) (fun results ->
- collect results;
+ collect results
cont (close()))
| codes ->
// Multiple blocks: leave the linear sequence and process each seperately
- codes |> List.iter (fun c -> collect (emitCode cenv localSigs codebuf env (!newSusp,c)));
+ codes |> List.iter (fun c -> collect (emitCode cenv localSigs codebuf env (!newSusp,c)))
cont(close())
| c ->
// leave the linear sequence
@@ -2536,11 +2536,11 @@ module Codebuf = begin
| ILBasicBlock bb ->
// Leaf case: one basic block
- commitSusp codebuf susp bb.Label;
- codebuf.RecordAvailBrFixup bb.Label;
+ commitSusp codebuf susp bb.Label
+ codebuf.RecordAvailBrFixup bb.Label
let instrs = bb.Instructions
for i = 0 to instrs.Length - 1 do
- emitInstr cenv codebuf env instrs.[i];
+ emitInstr cenv codebuf env instrs.[i]
bb.Fallthrough, Tip, []
and brToSusp (codebuf: CodeBuffer) dest = codebuf.RecordReqdBrFixup (i_br,Some i_br_s) dest
@@ -2562,7 +2562,7 @@ module Codebuf = begin
| Node clauses -> List.iter (emitExceptionHandlerTree2 codebuf) clauses
and emitExceptionHandlerTree2 (codebuf: CodeBuffer) (x,childSEH) =
- List.iter (emitExceptionHandlerTree codebuf) childSEH; // internal first
+ List.iter (emitExceptionHandlerTree codebuf) childSEH // internal first
match x with
| None -> ()
| Some clause -> codebuf.EmitExceptionClause clause
@@ -2571,8 +2571,8 @@ module Codebuf = begin
let codebuf = CodeBuffer.Create nm
let finalSusp, SEHTree, origScopes =
emitCode cenv localSigs codebuf env (Some (uniqueEntryOfCode code),code)
- (match finalSusp with Some dest -> brToSusp codebuf dest | _ -> ());
- emitExceptionHandlerTree codebuf SEHTree;
+ (match finalSusp with Some dest -> brToSusp codebuf dest | _ -> ())
+ emitExceptionHandlerTree codebuf SEHTree
let origCode = codebuf.code.Close()
let origExnClauses = List.rev codebuf.seh
let origReqdStringFixups = codebuf.reqdStringFixupsInMethod
@@ -2584,10 +2584,10 @@ module Codebuf = begin
applyBrFixups origCode origExnClauses origReqdStringFixups origAvailBrFixups origReqdBrFixups origSeqPoints origScopes
let rootScope =
- { Children= Array.ofList newScopes;
- StartOffset=0;
- EndOffset=newCode.Length;
- Locals=[| |]; }
+ { Children= Array.ofList newScopes
+ StartOffset=0
+ EndOffset=newCode.Length
+ Locals=[| |] }
(newReqdStringFixups,newExnClauses, newCode, newSeqPoints, rootScope)
@@ -2597,7 +2597,7 @@ end
// ILMethodBody --> bytes
// --------------------------------------------------------------------
let GetFieldDefTypeAsBlobIdx cenv env ty =
- let bytes = emitBytesViaBuffer (fun bb -> bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD;
+ let bytes = emitBytesViaBuffer (fun bb -> bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD
EmitType cenv env bb ty)
GetBytesAsBlobIdx cenv bytes
@@ -2606,7 +2606,7 @@ let GenILMethodBody mname cenv env (il: ILMethodBody) =
if cenv.generatePdb then
il.Locals |> ILList.toArray |> Array.map (fun l ->
// Write a fake entry for the local signature headed by e_IMAGE_CEE_CS_CALLCONV_FIELD. This is referenced by the PDB file
- ignore (FindOrAddRow cenv TableNames.StandAloneSig (SimpleSharedRow [| Blob (GetFieldDefTypeAsBlobIdx cenv env l.Type) |]));
+ ignore (FindOrAddRow cenv TableNames.StandAloneSig (SimpleSharedRow [| Blob (GetFieldDefTypeAsBlobIdx cenv env l.Type) |]))
// Now write the type
GetTypeAsBytes cenv env l.Type)
else
@@ -2621,9 +2621,9 @@ let GenILMethodBody mname cenv env (il: ILMethodBody) =
let alignedCodeSize = align 4 (codeSize + 1)
let codePadding = (alignedCodeSize - (codeSize + 1))
let requiredStringFixups' = (1,requiredStringFixups)
- methbuf.EmitByte (byte codeSize <<< 2 ||| e_CorILMethod_TinyFormat);
- methbuf.EmitBytes code;
- methbuf.EmitPadding codePadding;
+ methbuf.EmitByte (byte codeSize <<< 2 ||| e_CorILMethod_TinyFormat)
+ methbuf.EmitBytes code
+ methbuf.EmitPadding codePadding
(requiredStringFixups', methbuf.Close()), seqpoints, scopes
else
// Use Fat format
@@ -2640,13 +2640,13 @@ let GenILMethodBody mname cenv env (il: ILMethodBody) =
let alignedCodeSize = align 0x4 codeSize
let codePadding = (alignedCodeSize - codeSize)
- methbuf.EmitByte flags;
- methbuf.EmitByte 0x30uy; // last four bits record size of fat header in 4 byte chunks - this is always 12 bytes = 3 four word chunks
- methbuf.EmitUInt16 (uint16 il.MaxStack);
- methbuf.EmitInt32 codeSize;
- methbuf.EmitInt32 localToken;
- methbuf.EmitBytes code;
- methbuf.EmitPadding codePadding;
+ methbuf.EmitByte flags
+ methbuf.EmitByte 0x30uy // last four bits record size of fat header in 4 byte chunks - this is always 12 bytes = 3 four word chunks
+ methbuf.EmitUInt16 (uint16 il.MaxStack)
+ methbuf.EmitInt32 codeSize
+ methbuf.EmitInt32 localToken
+ methbuf.EmitBytes code
+ methbuf.EmitPadding codePadding
if nonNil seh then
// Can we use the small exception handling table format?
@@ -2669,31 +2669,31 @@ let GenILMethodBody mname cenv env (il: ILMethodBody) =
| TypeFilterClause uncoded -> uncoded
if canUseSmall then
- methbuf.EmitByte e_CorILMethod_Sect_EHTable;
- methbuf.EmitByte (b0 smallSize);
- methbuf.EmitByte 0x00uy;
- methbuf.EmitByte 0x00uy;
+ methbuf.EmitByte e_CorILMethod_Sect_EHTable
+ methbuf.EmitByte (b0 smallSize)
+ methbuf.EmitByte 0x00uy
+ methbuf.EmitByte 0x00uy
seh |> List.iter (fun (st1,sz1,st2,sz2,kind) ->
let k32 = kindAsInt32 kind
- methbuf.EmitInt32AsUInt16 k32;
- methbuf.EmitInt32AsUInt16 st1;
- methbuf.EmitByte (b0 sz1);
- methbuf.EmitInt32AsUInt16 st2;
- methbuf.EmitByte (b0 sz2);
+ methbuf.EmitInt32AsUInt16 k32
+ methbuf.EmitInt32AsUInt16 st1
+ methbuf.EmitByte (b0 sz1)
+ methbuf.EmitInt32AsUInt16 st2
+ methbuf.EmitByte (b0 sz2)
methbuf.EmitInt32 (kindAsExtraInt32 kind))
else
let bigSize = (seh.Length * 24 + 4)
- methbuf.EmitByte (e_CorILMethod_Sect_EHTable ||| e_CorILMethod_Sect_FatFormat);
- methbuf.EmitByte (b0 bigSize);
- methbuf.EmitByte (b1 bigSize);
- methbuf.EmitByte (b2 bigSize);
+ methbuf.EmitByte (e_CorILMethod_Sect_EHTable ||| e_CorILMethod_Sect_FatFormat)
+ methbuf.EmitByte (b0 bigSize)
+ methbuf.EmitByte (b1 bigSize)
+ methbuf.EmitByte (b2 bigSize)
seh |> List.iter (fun (st1,sz1,st2,sz2,kind) ->
let k32 = kindAsInt32 kind
- methbuf.EmitInt32 k32;
- methbuf.EmitInt32 st1;
- methbuf.EmitInt32 sz1;
- methbuf.EmitInt32 st2;
- methbuf.EmitInt32 sz2;
+ methbuf.EmitInt32 k32
+ methbuf.EmitInt32 st1
+ methbuf.EmitInt32 sz1
+ methbuf.EmitInt32 st2
+ methbuf.EmitInt32 sz2
methbuf.EmitInt32 (kindAsExtraInt32 kind))
let requiredStringFixups' = (12,requiredStringFixups)
@@ -2717,21 +2717,21 @@ let rec GetFieldDefAsFieldDefRow cenv env (fd: ILFieldDef) =
(if (fd.Marshal <> None) then 0x1000 else 0x0) |||
(if (fd.Data <> None) then 0x0100 else 0x0)
UnsharedRow
- [| UShort (uint16 flags);
- StringE (GetStringHeapIdx cenv fd.Name);
- Blob (GetFieldDefSigAsBlobIdx cenv env fd ); |]
+ [| UShort (uint16 flags)
+ StringE (GetStringHeapIdx cenv fd.Name)
+ Blob (GetFieldDefSigAsBlobIdx cenv env fd ) |]
and GetFieldDefSigAsBlobIdx cenv env fd = GetFieldDefTypeAsBlobIdx cenv env fd.Type
and GenFieldDefPass3 cenv env fd =
let fidx = AddUnsharedRow cenv TableNames.Field (GetFieldDefAsFieldDefRow cenv env fd)
- GenCustomAttrsPass3Or4 cenv (hca_FieldDef,fidx) fd.CustomAttrs;
+ GenCustomAttrsPass3Or4 cenv (hca_FieldDef,fidx) fd.CustomAttrs
// Write FieldRVA table - fixups into data section done later
match fd.Data with
| None -> ()
| Some b ->
let offs = cenv.data.Position
- cenv.data.EmitBytes b;
+ cenv.data.EmitBytes b
AddUnsharedRow cenv TableNames.FieldRVA
(UnsharedRow [| Data (offs, false); SimpleIndex (TableNames.Field,fidx) |]) |> ignore
// Write FieldMarshal table
@@ -2739,7 +2739,7 @@ and GenFieldDefPass3 cenv env fd =
| None -> ()
| Some ntyp ->
AddUnsharedRow cenv TableNames.FieldMarshal
- (UnsharedRow [| HasFieldMarshal (hfm_FieldDef, fidx);
+ (UnsharedRow [| HasFieldMarshal (hfm_FieldDef, fidx)
Blob (GetNativeTypeAsBlobIdx cenv ntyp) |]) |> ignore
// Write Contant table
match fd.LiteralValue with
@@ -2747,16 +2747,15 @@ and GenFieldDefPass3 cenv env fd =
| Some i ->
AddUnsharedRow cenv TableNames.Constant
(UnsharedRow
- [| GetFieldInitFlags i;
- HasConstant (hc_FieldDef, fidx);
+ [| GetFieldInitFlags i
+ HasConstant (hc_FieldDef, fidx)
Blob (GetFieldInitAsBlobIdx cenv i) |]) |> ignore
// Write FieldLayout table
match fd.Offset with
| None -> ()
| Some offset ->
AddUnsharedRow cenv TableNames.FieldLayout
- (UnsharedRow [| ULong offset;
- SimpleIndex (TableNames.Field, fidx) |]) |> ignore
+ (UnsharedRow [| ULong offset; SimpleIndex (TableNames.Field, fidx) |]) |> ignore
// --------------------------------------------------------------------
@@ -2776,22 +2775,22 @@ let rec GetGenericParamAsGenericParamRow cenv _env idx owner gp =
let mdVersionMajor,_ = metadataSchemaVersionSupportedByCLRVersion cenv.desiredMetadataVersion
if (mdVersionMajor = 1) then
SimpleSharedRow
- [| UShort (uint16 idx);
- UShort (uint16 flags);
- TypeOrMethodDef (fst owner, snd owner);
- StringE (GetStringHeapIdx cenv gp.Name);
- TypeDefOrRefOrSpec (tdor_TypeDef, 0); (* empty kind field in deprecated metadata *) |]
+ [| UShort (uint16 idx)
+ UShort (uint16 flags)
+ TypeOrMethodDef (fst owner, snd owner)
+ StringE (GetStringHeapIdx cenv gp.Name)
+ TypeDefOrRefOrSpec (tdor_TypeDef, 0) (* empty kind field in deprecated metadata *) |]
else
SimpleSharedRow
- [| UShort (uint16 idx);
- UShort (uint16 flags);
- TypeOrMethodDef (fst owner, snd owner);
+ [| UShort (uint16 idx)
+ UShort (uint16 flags)
+ TypeOrMethodDef (fst owner, snd owner)
StringE (GetStringHeapIdx cenv gp.Name) |]
and GenTypeAsGenericParamConstraintRow cenv env gpidx ty =
let tdorTag,tdorRow = GetTypeAsTypeDefOrRef cenv env ty
UnsharedRow
- [| SimpleIndex (TableNames.GenericParam, gpidx);
+ [| SimpleIndex (TableNames.GenericParam, gpidx)
TypeDefOrRefOrSpec (tdorTag,tdorRow) |]
and GenGenericParamConstraintPass4 cenv env gpidx ty =
@@ -2822,8 +2821,8 @@ let rec GetParamAsParamRow cenv _env seq param =
(if param.Marshal <> None then 0x2000 else 0x0000)
UnsharedRow
- [| UShort (uint16 flags);
- UShort (uint16 seq);
+ [| UShort (uint16 flags)
+ UShort (uint16 seq)
StringE (GetStringHeapIdxOption cenv param.Name) |]
and GenParamPass3 cenv env seq param =
@@ -2831,32 +2830,31 @@ and GenParamPass3 cenv env seq param =
then ()
else
let pidx = AddUnsharedRow cenv TableNames.Param (GetParamAsParamRow cenv env seq param)
- GenCustomAttrsPass3Or4 cenv (hca_ParamDef,pidx) param.CustomAttrs;
+ GenCustomAttrsPass3Or4 cenv (hca_ParamDef,pidx) param.CustomAttrs
// Write FieldRVA table - fixups into data section done later
match param.Marshal with
| None -> ()
| Some ntyp ->
AddUnsharedRow cenv TableNames.FieldMarshal
- (UnsharedRow [| HasFieldMarshal (hfm_ParamDef, pidx);
- Blob (GetNativeTypeAsBlobIdx cenv ntyp) |]) |> ignore
+ (UnsharedRow [| HasFieldMarshal (hfm_ParamDef, pidx); Blob (GetNativeTypeAsBlobIdx cenv ntyp) |]) |> ignore
let GenReturnAsParamRow (returnv : ILReturn) =
let flags = (if returnv.Marshal <> None then 0x2000 else 0x0000)
UnsharedRow
- [| UShort (uint16 flags);
- UShort 0us; (* sequence num. *)
+ [| UShort (uint16 flags)
+ UShort 0us (* sequence num. *)
StringE 0 |]
let GenReturnPass3 cenv (returnv: ILReturn) =
if isSome returnv.Marshal || nonNil returnv.CustomAttrs.AsList then
let pidx = AddUnsharedRow cenv TableNames.Param (GenReturnAsParamRow returnv)
- GenCustomAttrsPass3Or4 cenv (hca_ParamDef,pidx) returnv.CustomAttrs;
+ GenCustomAttrsPass3Or4 cenv (hca_ParamDef,pidx) returnv.CustomAttrs
match returnv.Marshal with
| None -> ()
| Some ntyp ->
AddUnsharedRow cenv TableNames.FieldMarshal
(UnsharedRow
- [| HasFieldMarshal (hfm_ParamDef, pidx);
+ [| HasFieldMarshal (hfm_ParamDef, pidx)
Blob (GetNativeTypeAsBlobIdx cenv ntyp) |]) |> ignore
// --------------------------------------------------------------------
@@ -2865,10 +2863,10 @@ let GenReturnPass3 cenv (returnv: ILReturn) =
let GetMethodDefSigAsBytes cenv env (mdef: ILMethodDef) =
emitBytesViaBuffer (fun bb ->
- bb.EmitByte (callconvToByte mdef.GenericParams.Length mdef.CallingConv);
- if mdef.GenericParams.Length > 0 then bb.EmitZ32 mdef.GenericParams.Length;
- bb.EmitZ32 mdef.Parameters.Length;
- EmitType cenv env bb mdef.Return.Type;
+ bb.EmitByte (callconvToByte mdef.GenericParams.Length mdef.CallingConv)
+ if mdef.GenericParams.Length > 0 then bb.EmitZ32 mdef.GenericParams.Length
+ bb.EmitZ32 mdef.Parameters.Length
+ EmitType cenv env bb mdef.Return.Type
mdef.ParameterTypes |> ILList.iter (EmitType cenv env bb))
let GenMethodDefSigAsBlobIdx cenv env mdef =
@@ -2910,7 +2908,7 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
if md.IsEntryPoint then
if cenv.entrypoint <> None then failwith "duplicate entrypoint"
- else cenv.entrypoint <- Some (true, midx);
+ else cenv.entrypoint <- Some (true, midx)
let codeAddr =
(match md.mdBody.Contents with
| MethodBody.IL ilmbody ->
@@ -2920,37 +2918,37 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
// Now record the PDB record for this method - we write this out later.
if cenv.generatePdb then
cenv.pdbinfo.Add
- { MethToken=getUncodedToken TableNames.Method midx;
- MethName=md.Name;
- Params= [| |]; (* REVIEW *)
- RootScope = rootScope;
+ { MethToken=getUncodedToken TableNames.Method midx
+ MethName=md.Name
+ Params= [| |] (* REVIEW *)
+ RootScope = rootScope
Range=
match ilmbody.SourceMarker with
| Some m when cenv.generatePdb ->
// table indexes are 1-based, document array indexes are 0-based
let doc = (cenv.documents.FindOrAddSharedEntry m.Document) - 1
- Some ({ Document=doc;
- Line=m.Line;
- Column=m.Column; },
- { Document=doc;
- Line=m.EndLine;
- Column=m.EndColumn; })
+ Some ({ Document=doc
+ Line=m.Line
+ Column=m.Column },
+ { Document=doc
+ Line=m.EndLine
+ Column=m.EndColumn })
| _ -> None
- SequencePoints=seqpoints; };
+ SequencePoints=seqpoints }
- cenv.AddCode code;
+ cenv.AddCode code
addr
| MethodBody.Native ->
- failwith "cannot write body of native method - Abstract IL cannot roundtrip mixed native/managed binaries";
+ failwith "cannot write body of native method - Abstract IL cannot roundtrip mixed native/managed binaries"
| _ -> 0x0000)
UnsharedRow
- [| ULong codeAddr ;
- UShort (uint16 implflags);
- UShort (uint16 flags);
- StringE (GetStringHeapIdx cenv md.Name);
- Blob (GenMethodDefSigAsBlobIdx cenv env md);
+ [| ULong codeAddr
+ UShort (uint16 implflags)
+ UShort (uint16 flags)
+ StringE (GetStringHeapIdx cenv md.Name)
+ Blob (GenMethodDefSigAsBlobIdx cenv env md)
SimpleIndex(TableNames.Param,cenv.GetTable(TableNames.Param).Count + 1) |]
let GenMethodImplPass3 cenv env _tgparams tidx mimpl =
@@ -2958,19 +2956,19 @@ let GenMethodImplPass3 cenv env _tgparams tidx mimpl =
let midx2Tag, midx2Row = GetOverridesSpecAsMethodDefOrRef cenv env mimpl.Overrides
AddUnsharedRow cenv TableNames.MethodImpl
(UnsharedRow
- [| SimpleIndex (TableNames.TypeDef, tidx);
- MethodDefOrRef (midxTag, midxRow);
+ [| SimpleIndex (TableNames.TypeDef, tidx)
+ MethodDefOrRef (midxTag, midxRow)
MethodDefOrRef (midx2Tag, midx2Row) |]) |> ignore
let GenMethodDefPass3 cenv env (md:ILMethodDef) =
let midx = GetMethodDefIdx cenv md
let idx2 = AddUnsharedRow cenv TableNames.Method (GenMethodDefAsRow cenv env midx md)
- if midx <> idx2 then failwith "index of method def on pass 3 does not match index on pass 2";
- GenReturnPass3 cenv md.Return;
- md.Parameters |> ILList.iteri (fun n param -> GenParamPass3 cenv env (n+1) param) ;
- md.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_MethodDef,midx) ;
- md.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_MethodDef,midx);
- md.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_MethodDef, midx) gp) ;
+ if midx <> idx2 then failwith "index of method def on pass 3 does not match index on pass 2"
+ GenReturnPass3 cenv md.Return
+ md.Parameters |> ILList.iteri (fun n param -> GenParamPass3 cenv env (n+1) param)
+ md.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_MethodDef,midx)
+ md.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_MethodDef,midx)
+ md.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_MethodDef, midx) gp)
match md.mdBody.Contents with
| MethodBody.PInvoke attr ->
let flags =
@@ -3002,10 +3000,10 @@ let GenMethodDefPass3 cenv env (md:ILMethodDef) =
(if attr.LastError then 0x0040 else 0x0000)
AddUnsharedRow cenv TableNames.ImplMap
(UnsharedRow
- [| UShort (uint16 flags);
- MemberForwarded (mf_MethodDef,midx);
- StringE (GetStringHeapIdx cenv attr.Name);
- SimpleIndex (TableNames.ModuleRef, GetModuleRefAsIdx cenv attr.Where); |]) |> ignore
+ [| UShort (uint16 flags)
+ MemberForwarded (mf_MethodDef,midx)
+ StringE (GetStringHeapIdx cenv attr.Name)
+ SimpleIndex (TableNames.ModuleRef, GetModuleRefAsIdx cenv attr.Where) |]) |> ignore
| _ -> ()
let GenMethodDefPass4 cenv env md =
@@ -3017,8 +3015,8 @@ let GenPropertyMethodSemanticsPass3 cenv pidx kind mref =
let midx = try GetMethodRefAsMethodDefIdx cenv mref with MethodDefNotFound -> 1
AddUnsharedRow cenv TableNames.MethodSemantics
(UnsharedRow
- [| UShort (uint16 kind);
- SimpleIndex (TableNames.Method,midx);
+ [| UShort (uint16 kind)
+ SimpleIndex (TableNames.Method,midx)
HasSemantics (hs_Property, pidx) |]) |> ignore
let rec GetPropertySigAsBlobIdx cenv env prop =
@@ -3027,9 +3025,9 @@ let rec GetPropertySigAsBlobIdx cenv env prop =
and GetPropertySigAsBytes cenv env prop =
emitBytesViaBuffer (fun bb ->
let b = ((hasthisToByte prop.CallingConv) ||| e_IMAGE_CEE_CS_CALLCONV_PROPERTY)
- bb.EmitByte b;
- bb.EmitZ32 prop.Args.Length;
- EmitType cenv env bb prop.Type;
+ bb.EmitByte b
+ bb.EmitZ32 prop.Args.Length
+ EmitType cenv env bb prop.Type
prop.Args |> ILList.iter (EmitType cenv env bb))
and GetPropertyAsPropertyRow cenv env (prop:ILPropertyDef) =
@@ -3038,23 +3036,23 @@ and GetPropertyAsPropertyRow cenv env (prop:ILPropertyDef) =
(if prop.IsRTSpecialName then 0x0400 else 0x0) |||
(if prop.Init <> None then 0x1000 else 0x0)
UnsharedRow
- [| UShort (uint16 flags);
- StringE (GetStringHeapIdx cenv prop.Name);
- Blob (GetPropertySigAsBlobIdx cenv env prop); |]
+ [| UShort (uint16 flags)
+ StringE (GetStringHeapIdx cenv prop.Name)
+ Blob (GetPropertySigAsBlobIdx cenv env prop) |]
/// ILPropertyDef --> Property Row + MethodSemantics entries
and GenPropertyPass3 cenv env prop =
let pidx = AddUnsharedRow cenv TableNames.Property (GetPropertyAsPropertyRow cenv env prop)
- prop.SetMethod |> Option.iter (GenPropertyMethodSemanticsPass3 cenv pidx 0x0001) ;
- prop.GetMethod |> Option.iter (GenPropertyMethodSemanticsPass3 cenv pidx 0x0002) ;
+ prop.SetMethod |> Option.iter (GenPropertyMethodSemanticsPass3 cenv pidx 0x0001)
+ prop.GetMethod |> Option.iter (GenPropertyMethodSemanticsPass3 cenv pidx 0x0002)
// Write Constant table
match prop.Init with
| None -> ()
| Some i ->
AddUnsharedRow cenv TableNames.Constant
(UnsharedRow
- [| GetFieldInitFlags i;
- HasConstant (hc_Property, pidx);
+ [| GetFieldInitFlags i
+ HasConstant (hc_Property, pidx)
Blob (GetFieldInitAsBlobIdx cenv i) |]) |> ignore
GenCustomAttrsPass3Or4 cenv (hca_Property,pidx) prop.CustomAttrs
@@ -3062,8 +3060,8 @@ let rec GenEventMethodSemanticsPass3 cenv eidx kind mref =
let addIdx = try GetMethodRefAsMethodDefIdx cenv mref with MethodDefNotFound -> 1
AddUnsharedRow cenv TableNames.MethodSemantics
(UnsharedRow
- [| UShort (uint16 kind);
- SimpleIndex (TableNames.Method,addIdx);
+ [| UShort (uint16 kind)
+ SimpleIndex (TableNames.Method,addIdx)
HasSemantics (hs_Event, eidx) |]) |> ignore
/// ILEventDef --> Event Row + MethodSemantics entries
@@ -3073,8 +3071,8 @@ and GenEventAsEventRow cenv env (md: ILEventDef) =
(if md.IsRTSpecialName then 0x0400 else 0x0)
let tdorTag, tdorRow = GetTypeOptionAsTypeDefOrRef cenv env md.Type
UnsharedRow
- [| UShort (uint16 flags);
- StringE (GetStringHeapIdx cenv md.Name);
+ [| UShort (uint16 flags)
+ StringE (GetStringHeapIdx cenv md.Name)
TypeDefOrRefOrSpec (tdorTag,tdorRow) |]
and GenEventPass3 cenv env (md: ILEventDef) =
@@ -3082,7 +3080,7 @@ and GenEventPass3 cenv env (md: ILEventDef) =
md.AddMethod |> GenEventMethodSemanticsPass3 cenv eidx 0x0008
md.RemoveMethod |> GenEventMethodSemanticsPass3 cenv eidx 0x0010
Option.iter (GenEventMethodSemanticsPass3 cenv eidx 0x0020) md.FireMethod
- List.iter (GenEventMethodSemanticsPass3 cenv eidx 0x0004) md.OtherMethods;
+ List.iter (GenEventMethodSemanticsPass3 cenv eidx 0x0004) md.OtherMethods
GenCustomAttrsPass3Or4 cenv (hca_Event,eidx) md.CustomAttrs
@@ -3101,17 +3099,17 @@ let rec GetResourceAsManifestResourceRow cenv r =
let alignedOffset = (align 0x8 offset)
let pad = alignedOffset - offset
let resourceSize = b.Length
- cenv.resources.EmitPadding pad;
- cenv.resources.EmitInt32 resourceSize;
- cenv.resources.EmitBytes b;
+ cenv.resources.EmitPadding pad
+ cenv.resources.EmitInt32 resourceSize
+ cenv.resources.EmitBytes b
Data (alignedOffset,true), (i_File, 0)
| ILResourceLocation.File (mref,offset) -> ULong offset, (i_File, GetModuleRefAsFileIdx cenv mref)
| ILResourceLocation.Assembly aref -> ULong 0x0, (i_AssemblyRef, GetAssemblyRefAsIdx cenv aref)
UnsharedRow
- [| data;
- ULong (match r.Access with ILResourceAccess.Public -> 0x01 | ILResourceAccess.Private -> 0x02);
- StringE (GetStringHeapIdx cenv r.Name);
- Implementation (fst impl, snd impl); |]
+ [| data
+ ULong (match r.Access with ILResourceAccess.Public -> 0x01 | ILResourceAccess.Private -> 0x02)
+ StringE (GetStringHeapIdx cenv r.Name)
+ Implementation (fst impl, snd impl) |]
and GenResourcePass3 cenv r =
let idx = AddUnsharedRow cenv TableNames.ManifestResource (GetResourceAsManifestResourceRow cenv r)
@@ -3125,11 +3123,11 @@ let rec GenTypeDefPass3 enc cenv (td:ILTypeDef) =
try
let env = envForTypeDef td
let tidx = GetIdxForTypeDef cenv (TdKey(enc,td.Name))
- td.Properties.AsList |> List.iter (GenPropertyPass3 cenv env);
- td.Events.AsList |> List.iter (GenEventPass3 cenv env);
- td.Fields.AsList |> List.iter (GenFieldDefPass3 cenv env);
- td.Methods |> Seq.iter (GenMethodDefPass3 cenv env);
- td.MethodImpls.AsList |> List.iter (GenMethodImplPass3 cenv env td.GenericParams.Length tidx);
+ td.Properties.AsList |> List.iter (GenPropertyPass3 cenv env)
+ td.Events.AsList |> List.iter (GenEventPass3 cenv env)
+ td.Fields.AsList |> List.iter (GenFieldDefPass3 cenv env)
+ td.Methods |> Seq.iter (GenMethodDefPass3 cenv env)
+ td.MethodImpls.AsList |> List.iter (GenMethodImplPass3 cenv env td.GenericParams.Length tidx)
// ClassLayout entry if needed
match td.Layout with
| ILTypeDefLayout.Auto -> ()
@@ -3137,16 +3135,16 @@ let rec GenTypeDefPass3 enc cenv (td:ILTypeDef) =
if isSome layout.Pack || 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 (match layout.Pack with None -> uint16 0x0 | Some p -> p)
+ ULong (match layout.Size with None -> 0x0 | Some p -> p)
SimpleIndex (TableNames.TypeDef, tidx) |]) |> ignore
- td.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_TypeDef,tidx);
- td.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_TypeDef,tidx);
- td.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_TypeDef,tidx) gp) ;
- td.NestedTypes.AsList |> GenTypeDefsPass3 (enc@[td.Name]) cenv;
+ td.SecurityDecls.AsList |> GenSecurityDeclsPass3 cenv (hds_TypeDef,tidx)
+ td.CustomAttrs |> GenCustomAttrsPass3Or4 cenv (hca_TypeDef,tidx)
+ td.GenericParams |> List.iteri (fun n gp -> GenGenericParamPass3 cenv env n (tomd_TypeDef,tidx) gp)
+ td.NestedTypes.AsList |> GenTypeDefsPass3 (enc@[td.Name]) cenv
with e ->
- failwith ("Error in pass3 for type "+td.Name+", error: "+e.Message);
+ failwith ("Error in pass3 for type "+td.Name+", error: "+e.Message)
reraise()
raise e
@@ -3160,11 +3158,11 @@ let rec GenTypeDefPass4 enc cenv (td:ILTypeDef) =
try
let env = envForTypeDef td
let tidx = GetIdxForTypeDef cenv (TdKey(enc,td.Name))
- td.Methods |> Seq.iter (GenMethodDefPass4 cenv env) ;
- List.iteri (fun n gp -> GenGenericParamPass4 cenv env n (tomd_TypeDef,tidx) gp) td.GenericParams;
- GenTypeDefsPass4 (enc@[td.Name]) cenv td.NestedTypes.AsList;
+ td.Methods |> Seq.iter (GenMethodDefPass4 cenv env)
+ List.iteri (fun n gp -> GenGenericParamPass4 cenv env n (tomd_TypeDef,tidx) gp) td.GenericParams
+ GenTypeDefsPass4 (enc@[td.Name]) cenv td.NestedTypes.AsList
with e ->
- failwith ("Error in pass4 for type "+td.Name+", error: "+e.Message);
+ failwith ("Error in pass4 for type "+td.Name+", error: "+e.Message)
reraise()
raise e
@@ -3180,12 +3178,12 @@ let rec GenNestedExportedTypePass3 cenv cidx (ce: ILNestedExportedType) =
let nidx =
AddUnsharedRow cenv TableNames.ExportedType
(UnsharedRow
- [| ULong flags ;
- ULong 0x0;
- StringE (GetStringHeapIdx cenv ce.Name);
- StringE 0;
+ [| ULong flags
+ ULong 0x0
+ StringE (GetStringHeapIdx cenv ce.Name)
+ StringE 0
Implementation (i_ExportedType, cidx) |])
- GenCustomAttrsPass3Or4 cenv (hca_ExportedType,nidx) ce.CustomAttrs;
+ GenCustomAttrsPass3Or4 cenv (hca_ExportedType,nidx) ce.CustomAttrs
GenNestedExportedTypesPass3 cenv nidx ce.Nested
and GenNestedExportedTypesPass3 cenv nidx (nce: ILNestedExportedTypes) =
@@ -3199,16 +3197,16 @@ and GenExportedTypePass3 cenv (ce: ILExportedTypeOrForwarder) =
let cidx =
AddUnsharedRow cenv TableNames.ExportedType
(UnsharedRow
- [| ULong flags ;
- ULong 0x0;
- nelem;
- nselem;
- Implementation (fst impl, snd impl); |])
- GenCustomAttrsPass3Or4 cenv (hca_ExportedType,cidx) ce.CustomAttrs;
+ [| ULong flags
+ ULong 0x0
+ nelem
+ nselem
+ Implementation (fst impl, snd impl) |])
+ GenCustomAttrsPass3Or4 cenv (hca_ExportedType,cidx) ce.CustomAttrs
GenNestedExportedTypesPass3 cenv cidx ce.Nested
and GenExportedTypesPass3 cenv (ce: ILExportedTypesAndForwarders) =
- List.iter (GenExportedTypePass3 cenv) ce.AsList;
+ List.iter (GenExportedTypePass3 cenv) ce.AsList
// --------------------------------------------------------------------
// manifest --> generate Assembly row
@@ -3216,11 +3214,11 @@ and GenExportedTypesPass3 cenv (ce: ILExportedTypesAndForwarders) =
and GetManifsetAsAssemblyRow cenv m =
UnsharedRow
- [|ULong m.AuxModuleHashAlgorithm;
- UShort (match m.Version with None -> 0us | Some (x,_,_,_) -> x);
- UShort (match m.Version with None -> 0us | Some (_,y,_,_) -> y);
- UShort (match m.Version with None -> 0us | Some (_,_,z,_) -> z);
- UShort (match m.Version with None -> 0us | Some (_,_,_,w) -> w);
+ [|ULong m.AuxModuleHashAlgorithm
+ UShort (match m.Version with None -> 0us | Some (x,_,_,_) -> x)
+ UShort (match m.Version with None -> 0us | Some (_,y,_,_) -> y)
+ UShort (match m.Version with None -> 0us | Some (_,_,z,_) -> z)
+ UShort (match m.Version with None -> 0us | Some (_,_,_,w) -> w)
ULong
( (match m.AssemblyLongevity with
| ILAssemblyLongevity.Unspecified -> 0x0000
@@ -3235,21 +3233,21 @@ and GetManifsetAsAssemblyRow cenv m =
(if m.JitTracking then 0x8000 else 0x0) |||
(if m.DisableJitOptimizations then 0x4000 else 0x0) |||
(match m.PublicKey with None -> 0x0000 | Some _ -> 0x0001) |||
- 0x0000);
- (match m.PublicKey with None -> Blob 0 | Some x -> Blob (GetBytesAsBlobIdx cenv x));
- StringE (GetStringHeapIdx cenv m.Name);
- (match m.Locale with None -> StringE 0 | Some x -> StringE (GetStringHeapIdx cenv x)); |]
+ 0x0000)
+ (match m.PublicKey with None -> Blob 0 | Some x -> Blob (GetBytesAsBlobIdx cenv x))
+ StringE (GetStringHeapIdx cenv m.Name)
+ (match m.Locale with None -> StringE 0 | Some x -> StringE (GetStringHeapIdx cenv x)) |]
and GenManifestPass3 cenv m =
let aidx = AddUnsharedRow cenv TableNames.Assembly (GetManifsetAsAssemblyRow cenv m)
- GenSecurityDeclsPass3 cenv (hds_Assembly,aidx) m.SecurityDecls.AsList;
- GenCustomAttrsPass3Or4 cenv (hca_Assembly,aidx) m.CustomAttrs;
- GenExportedTypesPass3 cenv m.ExportedTypes;
+ GenSecurityDeclsPass3 cenv (hds_Assembly,aidx) m.SecurityDecls.AsList
+ GenCustomAttrsPass3Or4 cenv (hca_Assembly,aidx) m.CustomAttrs
+ GenExportedTypesPass3 cenv m.ExportedTypes
// Record the entrypoint decl if needed.
match m.EntrypointElsewhere with
| Some mref ->
if cenv.entrypoint <> None then failwith "duplicate entrypoint"
- else cenv.entrypoint <- Some (false, GetModuleRefAsIdx cenv mref);
+ else cenv.entrypoint <- Some (false, GetModuleRefAsIdx cenv mref)
| None -> ()
and newGuid (modul: ILModuleDef) =
@@ -3263,10 +3261,10 @@ and GetModuleAsRow cenv (modul: ILModuleDef) =
let modulGuid = newGuid modul
cenv.moduleGuid <- modulGuid
UnsharedRow
- [| UShort (uint16 0x0);
- StringE (GetStringHeapIdx cenv modul.Name);
- Guid (GetGuidIdx cenv modulGuid);
- Guid 0;
+ [| UShort (uint16 0x0)
+ StringE (GetStringHeapIdx cenv modul.Name)
+ Guid (GetGuidIdx cenv modulGuid)
+ Guid 0
Guid 0 |]
@@ -3290,63 +3288,63 @@ let SortTableRows tab (rows:IGenericRow[]) =
let GenModule (cenv : cenv) (modul: ILModuleDef) =
let midx = AddUnsharedRow cenv TableNames.Module (GetModuleAsRow cenv modul)
- List.iter (GenResourcePass3 cenv) modul.Resources.AsList;
+ List.iter (GenResourcePass3 cenv) modul.Resources.AsList
let tds = destTypeDefsWithGlobalFunctionsFirst cenv.ilg modul.TypeDefs
- reportTime cenv.showTimes "Module Generation Preparation";
- GenTypeDefsPass1 [] cenv tds;
- reportTime cenv.showTimes "Module Generation Pass 1";
- GenTypeDefsPass2 0 [] cenv tds;
- reportTime cenv.showTimes "Module Generation Pass 2";
- (match modul.Manifest with None -> () | Some m -> GenManifestPass3 cenv m);
- GenTypeDefsPass3 [] cenv tds;
- reportTime cenv.showTimes "Module Generation Pass 3";
- GenCustomAttrsPass3Or4 cenv (hca_Module,midx) modul.CustomAttrs;
+ reportTime cenv.showTimes "Module Generation Preparation"
+ GenTypeDefsPass1 [] cenv tds
+ reportTime cenv.showTimes "Module Generation Pass 1"
+ GenTypeDefsPass2 0 [] cenv tds
+ reportTime cenv.showTimes "Module Generation Pass 2"
+ (match modul.Manifest with None -> () | Some m -> GenManifestPass3 cenv m)
+ GenTypeDefsPass3 [] cenv tds
+ reportTime cenv.showTimes "Module Generation Pass 3"
+ GenCustomAttrsPass3Or4 cenv (hca_Module,midx) modul.CustomAttrs
// GenericParam is the only sorted table indexed by Columns in other tables (GenericParamConstraint\CustomAttributes).
// Hence we need to sort it before we emit any entries in GenericParamConstraint\CustomAttributes that are attached to generic params.
// Note this mutates the rows in a table. 'SetRowsOfTable' clears
// the key --> index map since it is no longer valid
- cenv.GetTable(TableNames.GenericParam).SetRowsOfTable (SortTableRows TableNames.GenericParam (cenv.GetTable(TableNames.GenericParam).EntriesAsArray));
- GenTypeDefsPass4 [] cenv tds;
+ cenv.GetTable(TableNames.GenericParam).SetRowsOfTable (SortTableRows TableNames.GenericParam (cenv.GetTable(TableNames.GenericParam).EntriesAsArray))
+ GenTypeDefsPass4 [] cenv tds
reportTime cenv.showTimes "Module Generation Pass 4"
let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILGlobals, emitTailcalls,showTimes) (m : ILModuleDef) noDebugData cilStartAddress =
let isDll = m.IsDLL
let cenv =
- { primaryAssembly=ilg.traits.ScopeRef;
- emitTailcalls=emitTailcalls;
- showTimes=showTimes;
- ilg = mkILGlobals ilg.traits None noDebugData; // assumes mscorlib is Scope_assembly _ ILScopeRef
- desiredMetadataVersion=desiredMetadataVersion;
- requiredDataFixups= requiredDataFixups;
- requiredStringFixups = [];
- codeChunks=ByteBuffer.Create 40000;
- nextCodeAddr = cilStartAddress;
- data = ByteBuffer.Create 200;
- resources = ByteBuffer.Create 200;
- tables= Array.init 64 (fun i -> MetadataTable<_>.New ("row table "+string i,System.Collections.Generic.EqualityComparer.Default));
- AssemblyRefs = MetadataTable<_>.New("ILAssemblyRef",System.Collections.Generic.EqualityComparer.Default);
- documents=MetadataTable<_>.New("pdbdocs",System.Collections.Generic.EqualityComparer.Default);
- trefCache=new Dictionary<_,_>(100);
- pdbinfo= new ResizeArray<_>(200);
- moduleGuid= Array.zeroCreate 16;
- fieldDefs= MetadataTable<_>.New("field defs",System.Collections.Generic.EqualityComparer.Default);
- methodDefIdxsByKey = MetadataTable<_>.New("method defs",System.Collections.Generic.EqualityComparer.Default);
+ { primaryAssembly=ilg.traits.ScopeRef
+ emitTailcalls=emitTailcalls
+ showTimes=showTimes
+ ilg = mkILGlobals ilg.traits None noDebugData // assumes mscorlib is Scope_assembly _ ILScopeRef
+ desiredMetadataVersion=desiredMetadataVersion
+ requiredDataFixups= requiredDataFixups
+ requiredStringFixups = []
+ codeChunks=ByteBuffer.Create 40000
+ nextCodeAddr = cilStartAddress
+ data = ByteBuffer.Create 200
+ resources = ByteBuffer.Create 200
+ tables= Array.init 64 (fun i -> MetadataTable<_>.New ("row table "+string i,System.Collections.Generic.EqualityComparer.Default))
+ AssemblyRefs = MetadataTable<_>.New("ILAssemblyRef",System.Collections.Generic.EqualityComparer.Default)
+ documents=MetadataTable<_>.New("pdbdocs",System.Collections.Generic.EqualityComparer.Default)
+ trefCache=new Dictionary<_,_>(100)
+ pdbinfo= new ResizeArray<_>(200)
+ moduleGuid= Array.zeroCreate 16
+ fieldDefs= MetadataTable<_>.New("field defs",System.Collections.Generic.EqualityComparer.Default)
+ methodDefIdxsByKey = MetadataTable<_>.New("method defs",System.Collections.Generic.EqualityComparer.Default)
// This uses reference identity on ILMethodDef objects
- methodDefIdxs = new Dictionary<_,_>(100, HashIdentity.Reference);
- propertyDefs = MetadataTable<_>.New("property defs",System.Collections.Generic.EqualityComparer.Default);
- eventDefs = MetadataTable<_>.New("event defs",System.Collections.Generic.EqualityComparer.Default);
- typeDefs = MetadataTable<_>.New("type defs",System.Collections.Generic.EqualityComparer.Default);
- entrypoint=None;
- generatePdb=generatePdb;
+ methodDefIdxs = new Dictionary<_,_>(100, HashIdentity.Reference)
+ propertyDefs = MetadataTable<_>.New("property defs",System.Collections.Generic.EqualityComparer.Default)
+ eventDefs = MetadataTable<_>.New("event defs",System.Collections.Generic.EqualityComparer.Default)
+ typeDefs = MetadataTable<_>.New("type defs",System.Collections.Generic.EqualityComparer.Default)
+ entrypoint=None
+ generatePdb=generatePdb
// These must use structural comparison since they are keyed by arrays
- guids=MetadataTable<_>.New("guids",HashIdentity.Structural);
- blobs= MetadataTable<_>.New("blobs",HashIdentity.Structural);
- strings= MetadataTable<_>.New("strings",System.Collections.Generic.EqualityComparer.Default);
- userStrings= MetadataTable<_>.New("user strings",System.Collections.Generic.EqualityComparer.Default); }
+ guids=MetadataTable<_>.New("guids",HashIdentity.Structural)
+ blobs= MetadataTable<_>.New("blobs",HashIdentity.Structural)
+ strings= MetadataTable<_>.New("strings",System.Collections.Generic.EqualityComparer.Default)
+ userStrings= MetadataTable<_>.New("user strings",System.Collections.Generic.EqualityComparer.Default) }
// Now the main compilation step
- GenModule cenv m;
+ GenModule cenv m
// Fetch out some of the results
let entryPointToken =
@@ -3354,13 +3352,13 @@ let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILG
| Some (epHere,tok) ->
getUncodedToken (if epHere then TableNames.Method else TableNames.File) tok
| None ->
- if not isDll then dprintn "warning: no entrypoint specified in executable binary";
+ if not isDll then dprintn "warning: no entrypoint specified in executable binary"
0x0
let pdbData =
- { EntryPoint= (if isDll then None else Some entryPointToken);
- ModuleID = cenv.moduleGuid;
- Documents = cenv.documents.EntriesAsArray;
+ { EntryPoint= (if isDll then None else Some entryPointToken)
+ ModuleID = cenv.moduleGuid
+ Documents = cenv.documents.EntriesAsArray
Methods= cenv.pdbinfo.ToArray() }
let idxForNextedTypeDef (tds:ILTypeDef list, td:ILTypeDef) =
@@ -3376,20 +3374,20 @@ let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILG
// turn idx tbls into token maps
let mappings =
{ TypeDefTokenMap = (fun t ->
- getUncodedToken TableNames.TypeDef (idxForNextedTypeDef t));
+ getUncodedToken TableNames.TypeDef (idxForNextedTypeDef t))
FieldDefTokenMap = (fun t fd ->
let tidx = idxForNextedTypeDef t
- getUncodedToken TableNames.Field (GetFieldDefAsFieldDefIdx cenv tidx fd));
+ getUncodedToken TableNames.Field (GetFieldDefAsFieldDefIdx cenv tidx fd))
MethodDefTokenMap = (fun t md ->
let tidx = idxForNextedTypeDef t
- getUncodedToken TableNames.Method (FindMethodDefIdx cenv (GetKeyForMethodDef tidx md)));
+ getUncodedToken TableNames.Method (FindMethodDefIdx cenv (GetKeyForMethodDef tidx md)))
PropertyTokenMap = (fun t pd ->
let tidx = idxForNextedTypeDef t
- getUncodedToken TableNames.Property (cenv.propertyDefs.GetTableEntry (GetKeyForPropertyDef tidx pd)));
+ getUncodedToken TableNames.Property (cenv.propertyDefs.GetTableEntry (GetKeyForPropertyDef tidx pd)))
EventTokenMap = (fun t ed ->
let tidx = idxForNextedTypeDef t
getUncodedToken TableNames.Event (cenv.eventDefs.GetTableEntry (EventKey (tidx, ed.Name)))) }
- reportTime cenv.showTimes "Finalize Module Generation Results";
+ reportTime cenv.showTimes "Finalize Module Generation Results"
// New return the results
let data = cenv.data.Close()
let resources = cenv.resources.Close()
@@ -3401,7 +3399,7 @@ let generateIL requiredDataFixups (desiredMetadataVersion,generatePdb, ilg : ILG
//=====================================================================
type BinaryChunk =
- { size: int32;
+ { size: int32
addr: int32 }
let chunk sz next = ({addr=next; size=sz},next + sz)
@@ -3418,14 +3416,14 @@ module FileSystemUtilites =
if runningOnMono then
try
let monoPosix = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756")
- if progress then eprintf "loading type Mono.Unix.UnixFileInfo...\n";
+ if progress then eprintf "loading type Mono.Unix.UnixFileInfo...\n"
let monoUnixFileInfo = monoPosix.GetType("Mono.Unix.UnixFileSystemInfo")
let fileEntry = monoUnixFileInfo.InvokeMember("GetFileSystemEntry", (BindingFlags.InvokeMethod ||| BindingFlags.Static ||| BindingFlags.Public), null, null, [| box filename |],System.Globalization.CultureInfo.InvariantCulture)
let prevPermissions = monoUnixFileInfo.InvokeMember("get_FileAccessPermissions", (BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| BindingFlags.Public), null, fileEntry, [| |],System.Globalization.CultureInfo.InvariantCulture) |> unbox
// Add 0x000001ED (UserReadWriteExecute, GroupReadExecute, OtherReadExecute) to the access permissions on Unix
monoUnixFileInfo.InvokeMember("set_FileAccessPermissions", (BindingFlags.InvokeMethod ||| BindingFlags.Instance ||| BindingFlags.Public), null, fileEntry, [| box (prevPermissions ||| 0x000001ED) |],System.Globalization.CultureInfo.InvariantCulture) |> ignore
with e ->
- if progress then eprintf "failure: %s...\n" (e.ToString());
+ if progress then eprintf "failure: %s...\n" (e.ToString())
// Fail silently
let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls,showTimes) modul noDebugData cilStartAddress =
@@ -3439,7 +3437,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
let strings,userStrings,blobs,guids,tables,entryPointToken,code,requiredStringFixups,data,resources,pdbData,mappings =
generateIL requiredDataFixups (desiredMetadataVersion,generatePdb,ilg,emitTailcalls,showTimes) modul noDebugData cilStartAddress
- reportTime showTimes "Generated Tables and Code";
+ reportTime showTimes "Generated Tables and Code"
let tableSize (tab: TableName) = tables.[tab.Index].Length
// Now place the code
@@ -3512,7 +3510,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
(if tableSize (TableNames.GenericParamConstraint) > 0 then 0x00001000 else 0x00000000) |||
0x00000200
- reportTime showTimes "Layout Header of Tables";
+ reportTime showTimes "Layout Header of Tables"
let guidAddress n = (if n = 0 then 0 else (n - 1) * 0x10 + 0x01)
@@ -3520,48 +3518,48 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
let tab = Array.create (strings.Length + 1) 0
let pos = ref 1
for i = 1 to strings.Length do
- tab.[i] <- !pos;
+ tab.[i] <- !pos
let s = strings.[i - 1]
pos := !pos + s.Length
tab
let stringAddress n =
- if n >= Array.length stringAddressTable then failwith ("string index "+string n+" out of range");
+ if n >= Array.length stringAddressTable then failwith ("string index "+string n+" out of range")
stringAddressTable.[n]
let userStringAddressTable =
let tab = Array.create (Array.length userStrings + 1) 0
let pos = ref 1
for i = 1 to Array.length userStrings do
- tab.[i] <- !pos;
+ tab.[i] <- !pos
let s = userStrings.[i - 1]
let n = s.Length + 1
pos := !pos + n + ByteBuffer.Z32Size n
tab
let userStringAddress n =
- if n >= Array.length userStringAddressTable then failwith "userString index out of range";
+ if n >= Array.length userStringAddressTable then failwith "userString index out of range"
userStringAddressTable.[n]
let blobAddressTable =
let tab = Array.create (blobs.Length + 1) 0
let pos = ref 1
for i = 1 to blobs.Length do
- tab.[i] <- !pos;
+ tab.[i] <- !pos
let blob = blobs.[i - 1]
pos := !pos + blob.Length + ByteBuffer.Z32Size blob.Length
tab
let blobAddress n =
- if n >= blobAddressTable.Length then failwith "blob index out of range";
+ if n >= blobAddressTable.Length then failwith "blob index out of range"
blobAddressTable.[n]
- reportTime showTimes "Build String/Blob Address Tables";
+ reportTime showTimes "Build String/Blob Address Tables"
let sortedTables =
Array.init 64 (fun i -> tables.[i] |> SortTableRows (TableName.FromIndex i))
- reportTime showTimes "Sort Tables";
+ reportTime showTimes "Sort Tables"
let codedTables =
@@ -3657,18 +3655,18 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
// Now the coded tables themselves - first the schemata header
tablesBuf.EmitIntsAsBytes
[| 0x00; 0x00; 0x00; 0x00;
- mdtableVersionMajor; // major version of table schemata
- mdtableVersionMinor; // minor version of table schemata
+ mdtableVersionMajor // major version of table schemata
+ mdtableVersionMinor // minor version of table schemata
- ((if stringsBig then 0x01 else 0x00) ||| // bit vector for heap size
- (if guidsBig then 0x02 else 0x00) |||
- (if blobsBig then 0x04 else 0x00));
- 0x01; (* reserved, always 1 *) |];
+ ((if stringsBig then 0x01 else 0x00) ||| // bit vector for heap size
+ (if guidsBig then 0x02 else 0x00) |||
+ (if blobsBig then 0x04 else 0x00))
+ 0x01 (* reserved, always 1 *) |]
- tablesBuf.EmitInt32 valid1;
- tablesBuf.EmitInt32 valid2;
- tablesBuf.EmitInt32 sorted1;
- tablesBuf.EmitInt32 sorted2;
+ tablesBuf.EmitInt32 valid1
+ tablesBuf.EmitInt32 valid2
+ tablesBuf.EmitInt32 sorted1
+ tablesBuf.EmitInt32 sorted2
// Numbers of rows in various tables
for rows in sortedTables do
@@ -3676,7 +3674,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
tablesBuf.EmitInt32 rows.Length
- reportTime showTimes "Write Header of tablebuf";
+ reportTime showTimes "Write Header of tablebuf"
// The tables themselves
for rows in sortedTables do
@@ -3712,7 +3710,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
tablesBuf.Close()
- reportTime showTimes "Write Tables to tablebuf";
+ reportTime showTimes "Write Tables to tablebuf"
let tablesStreamUnpaddedSize = codedTables.Length
// QUERY: extra 4 empty bytes in array.exe - why? Include some extra padding after
@@ -3729,7 +3727,7 @@ let writeILMetadataAndCode (generatePdb,desiredMetadataVersion,ilg,emitTailcalls
let blobsChunk,_next = chunk blobsStreamPaddedSize next
let blobsStreamPadding = blobsChunk.size - blobsStreamUnpaddedSize
- reportTime showTimes "Layout Metadata";
+ reportTime showTimes "Layout Metadata"
let metadata =
let mdbuf = ByteBuffer.Create 500000
@@ -4217,117 +4215,117 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
// Note that the defaults differ between x86 and x64
if modul.Is64Bit then
let size = defaultArg modul.StackReserveSize 0x400000 |> int64
- writeInt64 os size; // Stack Reserve Size Always 0x400000 (4Mb) (see Section 23.1).
- writeInt64 os 0x4000L; // Stack Commit Size Always 0x4000 (16Kb) (see Section 23.1).
- writeInt64 os 0x100000L; // Heap Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
+ writeInt64 os size // Stack Reserve Size Always 0x400000 (4Mb) (see Section 23.1).
+ writeInt64 os 0x4000L // Stack Commit Size Always 0x4000 (16Kb) (see Section 23.1).
+ writeInt64 os 0x100000L // Heap Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
writeInt64 os 0x2000L // Heap Commit Size Always 0x800 (8Kb) (see Section 23.1).
else
let size = defaultArg modul.StackReserveSize 0x100000
- writeInt32 os size; // Stack Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
- writeInt32 os 0x1000; // Stack Commit Size Always 0x1000 (4Kb) (see Section 23.1).
- writeInt32 os 0x100000; // Heap Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
- writeInt32 os 0x1000; // Heap Commit Size Always 0x1000 (4Kb) (see Section 23.1).
+ writeInt32 os size // Stack Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
+ writeInt32 os 0x1000 // Stack Commit Size Always 0x1000 (4Kb) (see Section 23.1).
+ writeInt32 os 0x100000 // Heap Reserve Size Always 0x100000 (1Mb) (see Section 23.1).
+ writeInt32 os 0x1000 // Heap Commit Size Always 0x1000 (4Kb) (see Section 23.1).
// 000000f0 - x86 location, moving on, for x64, add 0x10
- writeInt32 os 0x00; // Loader Flags Always 0 (see Section 23.1)
- writeInt32 os 0x10; // Number of Data Directories: Always 0x10 (see Section 23.1).
- writeInt32 os 0x00;
- writeInt32 os 0x00; // Export Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Loader Flags Always 0 (see Section 23.1)
+ writeInt32 os 0x10 // Number of Data Directories: Always 0x10 (see Section 23.1).
+ writeInt32 os 0x00
+ writeInt32 os 0x00 // Export Table Always 0 (see Section 23.1).
// 00000100
- writeDirectory os importTableChunk; // Import Table RVA of Import Table, (see clause 24.3.1). e.g. 0000b530
+ writeDirectory os importTableChunk // Import Table RVA of Import Table, (see clause 24.3.1). e.g. 0000b530
// Native Resource Table: ECMA says Always 0 (see Section 23.1), but mscorlib and other files with resources bound into executable do not. For the moment assume the resources table is always the first resource in the file.
- writeDirectory os nativeResourcesChunk;
+ writeDirectory os nativeResourcesChunk
// 00000110
- writeInt32 os 0x00; // Exception Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Exception Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Certificate Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Certificate Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Exception Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Exception Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Certificate Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Certificate Table Always 0 (see Section 23.1).
// 00000120
- writeDirectory os baseRelocTableChunk;
- writeDirectory os debugDirectoryChunk; // Debug Directory
+ writeDirectory os baseRelocTableChunk
+ writeDirectory os debugDirectoryChunk // Debug Directory
// 00000130
- writeInt32 os 0x00; // Copyright Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Copyright Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Global Ptr Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Global Ptr Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Copyright Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Copyright Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Global Ptr Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Global Ptr Always 0 (see Section 23.1).
// 00000140
- writeInt32 os 0x00; // Load Config Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Load Config Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // TLS Table Always 0 (see Section 23.1).
- writeInt32 os 0x00; // TLS Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Load Config Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Load Config Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // TLS Table Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // TLS Table Always 0 (see Section 23.1).
// 00000150
- writeInt32 os 0x00; // Bound Import Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Bound Import Always 0 (see Section 23.1).
- writeDirectory os importAddrTableChunk; // Import Addr Table, (see clause 24.3.1). e.g. 0x00002000
+ writeInt32 os 0x00 // Bound Import Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Bound Import Always 0 (see Section 23.1).
+ writeDirectory os importAddrTableChunk // Import Addr Table, (see clause 24.3.1). e.g. 0x00002000
// 00000160
- writeInt32 os 0x00; // Delay Import Descriptor Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Delay Import Descriptor Always 0 (see Section 23.1).
- writeDirectory os cliHeaderChunk;
+ writeInt32 os 0x00 // Delay Import Descriptor Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Delay Import Descriptor Always 0 (see Section 23.1).
+ writeDirectory os cliHeaderChunk
// 00000170
- writeInt32 os 0x00; // Reserved Always 0 (see Section 23.1).
- writeInt32 os 0x00; // Reserved Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Reserved Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // Reserved Always 0 (see Section 23.1).
- write (Some textSectionHeaderChunk.addr) os "text section header" [| |];
+ write (Some textSectionHeaderChunk.addr) os "text section header" [| |]
// 00000178
- writeBytes os [| 0x2euy; 0x74uy; 0x65uy; 0x78uy; 0x74uy; 0x00uy; 0x00uy; 0x00uy; |]; // ".text\000\000\000"
+ writeBytes os [| 0x2euy; 0x74uy; 0x65uy; 0x78uy; 0x74uy; 0x00uy; 0x00uy; 0x00uy; |] // ".text\000\000\000"
// 00000180
- writeInt32 os textSectionSize; // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x00009584
- writeInt32 os textSectionAddr; // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x00020000
- writeInt32 os textSectionPhysSize; // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. 0x00009600
- writeInt32 os textSectionPhysLoc; // PointerToRawData RVA to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 00000200
+ writeInt32 os textSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x00009584
+ writeInt32 os textSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x00020000
+ writeInt32 os textSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. 0x00009600
+ writeInt32 os textSectionPhysLoc // PointerToRawData RVA to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 00000200
// 00000190
- writeInt32 os 0x00; // PointerToRelocations RVA of Relocation section.
- writeInt32 os 0x00; // PointerToLinenumbers Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section.
+ writeInt32 os 0x00 // PointerToLinenumbers Always 0 (see Section 23.1).
// 00000198
- writeInt32AsUInt16 os 0x00;// NumberOfRelocations Number of relocations, set to 0 if unused.
- writeInt32AsUInt16 os 0x00; // NumberOfLinenumbers Always 0 (see Section 23.1).
- writeBytes os [| 0x20uy; 0x00uy; 0x00uy; 0x60uy |]; // Characteristics Flags describing sections characteristics, see below. IMAGE_SCN_CNT_CODE || IMAGE_SCN_MEM_EXECUTE || IMAGE_SCN_MEM_READ
+ writeInt32AsUInt16 os 0x00// NumberOfRelocations Number of relocations, set to 0 if unused.
+ writeInt32AsUInt16 os 0x00 // NumberOfLinenumbers Always 0 (see Section 23.1).
+ writeBytes os [| 0x20uy; 0x00uy; 0x00uy; 0x60uy |] // Characteristics Flags describing sections characteristics, see below. IMAGE_SCN_CNT_CODE || IMAGE_SCN_MEM_EXECUTE || IMAGE_SCN_MEM_READ
- write (Some dataSectionHeaderChunk.addr) os "data section header" [| |];
+ write (Some dataSectionHeaderChunk.addr) os "data section header" [| |]
// 000001a0
- writeBytes os [| 0x2euy; 0x72uy; 0x73uy; 0x72uy; 0x63uy; 0x00uy; 0x00uy; 0x00uy; |]; // ".rsrc\000\000\000"
- // writeBytes os [| 0x2e; 0x73; 0x64; 0x61; 0x74; 0x61; 0x00; 0x00; |]; // ".sdata\000\000"
- writeInt32 os dataSectionSize; // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c
- writeInt32 os dataSectionAddr; // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000
+ writeBytes os [| 0x2euy; 0x72uy; 0x73uy; 0x72uy; 0x63uy; 0x00uy; 0x00uy; 0x00uy; |] // ".rsrc\000\000\000"
+ // writeBytes os [| 0x2e; 0x73; 0x64; 0x61; 0x74; 0x61; 0x00; 0x00; |] // ".sdata\000\000"
+ writeInt32 os dataSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c
+ writeInt32 os dataSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000
// 000001b0
- writeInt32 os dataSectionPhysSize; // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. e.g. 0x00000200
- writeInt32 os dataSectionPhysLoc; // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 0x00009800
+ writeInt32 os dataSectionPhysSize // SizeOfRawData Size of the initialized data on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be 0. e.g. 0x00000200
+ writeInt32 os dataSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized data, this field should be 0. e.g. 0x00009800
// 000001b8
- writeInt32 os 0x00; // PointerToRelocations RVA of Relocation section.
- writeInt32 os 0x00; // PointerToLinenumbers Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section.
+ writeInt32 os 0x00 // PointerToLinenumbers Always 0 (see Section 23.1).
// 000001c0
- writeInt32AsUInt16 os 0x00; // NumberOfRelocations Number of relocations, set to 0 if unused.
- writeInt32AsUInt16 os 0x00; // NumberOfLinenumbers Always 0 (see Section 23.1).
- writeBytes os [| 0x40uy; 0x00uy; 0x00uy; 0x40uy |]; // Characteristics Flags: IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA
+ writeInt32AsUInt16 os 0x00 // NumberOfRelocations Number of relocations, set to 0 if unused.
+ writeInt32AsUInt16 os 0x00 // NumberOfLinenumbers Always 0 (see Section 23.1).
+ writeBytes os [| 0x40uy; 0x00uy; 0x00uy; 0x40uy |] // Characteristics Flags: IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA
- write (Some relocSectionHeaderChunk.addr) os "reloc section header" [| |];
+ write (Some relocSectionHeaderChunk.addr) os "reloc section header" [| |]
// 000001a0
- writeBytes os [| 0x2euy; 0x72uy; 0x65uy; 0x6cuy; 0x6fuy; 0x63uy; 0x00uy; 0x00uy; |]; // ".reloc\000\000"
- writeInt32 os relocSectionSize; // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c
- writeInt32 os relocSectionAddr; // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000
+ writeBytes os [| 0x2euy; 0x72uy; 0x65uy; 0x6cuy; 0x6fuy; 0x63uy; 0x00uy; 0x00uy; |] // ".reloc\000\000"
+ writeInt32 os relocSectionSize // VirtualSize: Total size of the section when loaded into memory in bytes rounded to Section Alignment. If this value is greater than Size of Raw Data, the section is zero-padded. e.g. 0x0000000c
+ writeInt32 os relocSectionAddr // VirtualAddress For executable images this is the address of the first byte of the section, when loaded into memory, relative to the image base. e.g. 0x0000c000
// 000001b0
- writeInt32 os relocSectionPhysSize; // SizeOfRawData Size of the initialized reloc on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00000200
- writeInt32 os relocSectionPhysLoc; // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00009800
+ writeInt32 os relocSectionPhysSize // SizeOfRawData Size of the initialized reloc on disk in bytes, shall be a multiple of FileAlignment from the PE header. If this is less than VirtualSize the remainder of the section is zero filled. Because this field is rounded while the VirtualSize field is not it is possible for this to be greater than VirtualSize as well. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00000200
+ writeInt32 os relocSectionPhysLoc // PointerToRawData QUERY: Why does ECMA say "RVA" here? Offset to sections first page within the PE file. This shall be a multiple of FileAlignment from the optional header. When a section contains only uninitialized reloc, this field should be 0. e.g. 0x00009800
// 000001b8
- writeInt32 os 0x00; // PointerToRelocations RVA of Relocation section.
- writeInt32 os 0x00; // PointerToLinenumbers Always 0 (see Section 23.1).
+ writeInt32 os 0x00 // PointerToRelocations RVA of Relocation section.
+ writeInt32 os 0x00 // PointerToLinenumbers Always 0 (see Section 23.1).
// 000001c0
- writeInt32AsUInt16 os 0x00; // NumberOfRelocations Number of relocations, set to 0 if unused.
- writeInt32AsUInt16 os 0x00; // NumberOfLinenumbers Always 0 (see Section 23.1).
- writeBytes os [| 0x40uy; 0x00uy; 0x00uy; 0x42uy |]; // Characteristics Flags: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+ writeInt32AsUInt16 os 0x00 // NumberOfRelocations Number of relocations, set to 0 if unused.
+ writeInt32AsUInt16 os 0x00 // NumberOfLinenumbers Always 0 (see Section 23.1).
+ writeBytes os [| 0x40uy; 0x00uy; 0x00uy; 0x42uy |] // Characteristics Flags: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
- writePadding os "pad to text begin" (textSectionPhysLoc - headerSize);
+ writePadding os "pad to text begin" (textSectionPhysLoc - headerSize)
// TEXT SECTION: e.g. 0x200
let textV2P v = v - textSectionAddr + textSectionPhysLoc
// e.g. 0x0200
- write (Some (textV2P importAddrTableChunk.addr)) os "import addr table" [| |];
- writeInt32 os importNameHintTableChunk.addr;
- writeInt32 os 0x00; // QUERY 4 bytes of zeros not 2 like ECMA 24.3.1 says
+ write (Some (textV2P importAddrTableChunk.addr)) os "import addr table" [| |]
+ writeInt32 os importNameHintTableChunk.addr
+ writeInt32 os 0x00 // QUERY 4 bytes of zeros not 2 like ECMA 24.3.1 says
// e.g. 0x0208
@@ -4340,106 +4338,106 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
let headerVersionMajor,headerVersionMinor = headerVersionSupportedByCLRVersion desiredMetadataVersion
writePadding os "pad to cli header" cliHeaderPadding
- write (Some (textV2P cliHeaderChunk.addr)) os "cli header" [| |];
- writeInt32 os 0x48; // size of header
- writeInt32AsUInt16 os headerVersionMajor; // Major part of minimum version of CLR reqd.
- writeInt32AsUInt16 os headerVersionMinor; // Minor part of minimum version of CLR reqd. ...
+ write (Some (textV2P cliHeaderChunk.addr)) os "cli header" [| |]
+ writeInt32 os 0x48 // size of header
+ writeInt32AsUInt16 os headerVersionMajor // Major part of minimum version of CLR reqd.
+ writeInt32AsUInt16 os headerVersionMinor // Minor part of minimum version of CLR reqd. ...
// e.g. 0x0210
- writeDirectory os metadataChunk;
- writeInt32 os flags;
+ writeDirectory os metadataChunk
+ writeInt32 os flags
- writeInt32 os entryPointToken;
- write None os "rest of cli header" [| |];
+ writeInt32 os entryPointToken
+ write None os "rest of cli header" [| |]
// e.g. 0x0220
- writeDirectory os resourcesChunk;
- writeDirectory os strongnameChunk;
+ writeDirectory os resourcesChunk
+ writeDirectory os strongnameChunk
// e.g. 0x0230
- writeInt32 os 0x00; // code manager table, always 0
- writeInt32 os 0x00; // code manager table, always 0
- writeDirectory os vtfixupsChunk;
+ writeInt32 os 0x00 // code manager table, always 0
+ writeInt32 os 0x00 // code manager table, always 0
+ writeDirectory os vtfixupsChunk
// e.g. 0x0240
- writeInt32 os 0x00; // export addr table jumps, always 0
- writeInt32 os 0x00; // export addr table jumps, always 0
- writeInt32 os 0x00; // managed native header, always 0
- writeInt32 os 0x00; // managed native header, always 0
+ writeInt32 os 0x00 // export addr table jumps, always 0
+ writeInt32 os 0x00 // export addr table jumps, always 0
+ writeInt32 os 0x00 // managed native header, always 0
+ writeInt32 os 0x00 // managed native header, always 0
- writeBytes os code;
- write None os "code padding" codePadding;
+ writeBytes os code
+ write None os "code padding" codePadding
- writeBytes os metadata;
+ writeBytes os metadata
// write 0x80 bytes of empty space for encrypted SHA1 hash, written by SN.EXE or call to signing API
if signer <> None then
- write (Some (textV2P strongnameChunk.addr)) os "strongname" (Array.create strongnameChunk.size 0x0uy);
+ write (Some (textV2P strongnameChunk.addr)) os "strongname" (Array.create strongnameChunk.size 0x0uy)
- write (Some (textV2P resourcesChunk.addr)) os "raw resources" [| |];
- writeBytes os resources;
- write (Some (textV2P rawdataChunk.addr)) os "raw data" [| |];
- writeBytes os data;
+ write (Some (textV2P resourcesChunk.addr)) os "raw resources" [| |]
+ writeBytes os resources
+ write (Some (textV2P rawdataChunk.addr)) os "raw data" [| |]
+ writeBytes os data
writePadding os "start of import table" importTableChunkPrePadding
// vtfixups would go here
- write (Some (textV2P importTableChunk.addr)) os "import table" [| |];
+ write (Some (textV2P importTableChunk.addr)) os "import table" [| |]
- writeInt32 os importLookupTableChunk.addr;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os mscoreeStringChunk.addr;
- writeInt32 os importAddrTableChunk.addr;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
+ writeInt32 os importLookupTableChunk.addr
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os mscoreeStringChunk.addr
+ writeInt32 os importAddrTableChunk.addr
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os 0x00
- write (Some (textV2P importLookupTableChunk.addr)) os "import lookup table" [| |];
- writeInt32 os importNameHintTableChunk.addr;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
- writeInt32 os 0x00;
+ write (Some (textV2P importLookupTableChunk.addr)) os "import lookup table" [| |]
+ writeInt32 os importNameHintTableChunk.addr
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os 0x00
+ writeInt32 os 0x00
- write (Some (textV2P importNameHintTableChunk.addr)) os "import name hint table" [| |];
+ write (Some (textV2P importNameHintTableChunk.addr)) os "import name hint table" [| |]
// Two zero bytes of hint, then Case sensitive, null-terminated ASCII string containing name to import.
// Shall _CorExeMain a .exe file _CorDllMain for a .dll file.
if isDll then
writeBytes os [| 0x00uy; 0x00uy; 0x5fuy; 0x43uy ; 0x6fuy; 0x72uy; 0x44uy; 0x6cuy; 0x6cuy; 0x4duy; 0x61uy; 0x69uy; 0x6euy; 0x00uy |]
else
- writeBytes os [| 0x00uy; 0x00uy; 0x5fuy; 0x43uy; 0x6fuy; 0x72uy; 0x45uy; 0x78uy; 0x65uy; 0x4duy; 0x61uy; 0x69uy; 0x6euy; 0x00uy |];
+ writeBytes os [| 0x00uy; 0x00uy; 0x5fuy; 0x43uy; 0x6fuy; 0x72uy; 0x45uy; 0x78uy; 0x65uy; 0x4duy; 0x61uy; 0x69uy; 0x6euy; 0x00uy |]
write (Some (textV2P mscoreeStringChunk.addr)) os "mscoree string"
- [| 0x6duy; 0x73uy; 0x63uy; 0x6fuy ; 0x72uy; 0x65uy ; 0x65uy; 0x2euy ; 0x64uy; 0x6cuy ; 0x6cuy; 0x00uy ; |];
+ [| 0x6duy; 0x73uy; 0x63uy; 0x6fuy ; 0x72uy; 0x65uy ; 0x65uy; 0x2euy ; 0x64uy; 0x6cuy ; 0x6cuy; 0x00uy ; |]
- writePadding os "end of import tab" importTableChunkPadding;
+ writePadding os "end of import tab" importTableChunkPadding
- writePadding os "head of entrypoint" 0x03;
+ writePadding os "head of entrypoint" 0x03
let ep = (imageBaseReal + textSectionAddr)
write (Some (textV2P entrypointCodeChunk.addr)) os " entrypoint code"
- [| 0xFFuy; 0x25uy; (* x86 Instructions for entry *) b0 ep; b1 ep; b2 ep; b3 ep |];
+ [| 0xFFuy; 0x25uy; (* x86 Instructions for entry *) b0 ep; b1 ep; b2 ep; b3 ep |]
if isItanium then
write (Some (textV2P globalpointerCodeChunk.addr)) os " itanium global pointer"
- [| 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy |];
+ [| 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy; 0x0uy |]
if pdbfile.IsSome then
- write (Some (textV2P debugDirectoryChunk.addr)) os "debug directory" (Array.create sizeof_IMAGE_DEBUG_DIRECTORY 0x0uy);
- write (Some (textV2P debugDataChunk.addr)) os "debug data" (Array.create debugDataChunk.size 0x0uy);
+ write (Some (textV2P debugDirectoryChunk.addr)) os "debug directory" (Array.create sizeof_IMAGE_DEBUG_DIRECTORY 0x0uy)
+ write (Some (textV2P debugDataChunk.addr)) os "debug data" (Array.create debugDataChunk.size 0x0uy)
- writePadding os "end of .text" (dataSectionPhysLoc - textSectionPhysLoc - textSectionSize);
+ writePadding os "end of .text" (dataSectionPhysLoc - textSectionPhysLoc - textSectionSize)
// DATA SECTION
match nativeResources with
| [||] -> ()
| resources ->
- write (Some (dataSectionVirtToPhys nativeResourcesChunk.addr)) os "raw native resources" [| |];
- writeBytes os resources;
+ write (Some (dataSectionVirtToPhys nativeResourcesChunk.addr)) os "raw native resources" [| |]
+ writeBytes os resources
if dummydatap.size <> 0x0 then
- write (Some (dataSectionVirtToPhys dummydatap.addr)) os "dummy data" [| 0x0uy |];
+ write (Some (dataSectionVirtToPhys dummydatap.addr)) os "dummy data" [| 0x0uy |]
- writePadding os "end of .rsrc" (relocSectionPhysLoc - dataSectionPhysLoc - dataSectionSize);
+ writePadding os "end of .rsrc" (relocSectionPhysLoc - dataSectionPhysLoc - dataSectionSize)
// RELOC SECTION
@@ -4461,10 +4459,10 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
[| b0 entrypointFixupBlock; b1 entrypointFixupBlock; b2 entrypointFixupBlock; b3 entrypointFixupBlock;
0x0cuy; 0x00uy; 0x00uy; 0x00uy;
b0 reloc; b1 reloc;
- b0 reloc2; b1 reloc2; |];
- writePadding os "end of .reloc" (imageEndSectionPhysLoc - relocSectionPhysLoc - relocSectionSize);
+ b0 reloc2; b1 reloc2; |]
+ writePadding os "end of .reloc" (imageEndSectionPhysLoc - relocSectionPhysLoc - relocSectionSize)
- os.Close();
+ os.Close()
try
FileSystemUtilites.setExecutablePermission outfile
@@ -4475,13 +4473,13 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
// Looks like a finally...
with e ->
(try
- os.Close();
+ os.Close()
FileSystem.FileDelete outfile
- with _ -> ());
+ with _ -> ())
reraise()
- reportTime showTimes "Writing Image";
+ reportTime showTimes "Writing Image"
if dumpDebugInfo then
DumpDebugInfo outfile pdbData
@@ -4495,113 +4493,74 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
| Some fpdb ->
try
let idd = WritePdbInfo fixupOverlappingSequencePoints showTimes outfile fpdb pdbData
- reportTime showTimes "Generate PDB Info";
+ reportTime showTimes "Generate PDB Info"
// Now we have the debug data we can go back and fill in the debug directory in the image
let fs2 = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, 0x1000, false)
let os2 = new BinaryWriter(fs2)
try
// write the IMAGE_DEBUG_DIRECTORY
- os2.BaseStream.Seek (int64 (textV2P debugDirectoryChunk.addr), SeekOrigin.Begin) |> ignore;
- writeInt32 os2 idd.iddCharacteristics; // IMAGE_DEBUG_DIRECTORY.Characteristics
- writeInt32 os2 timestamp;
- writeInt32AsUInt16 os2 idd.iddMajorVersion;
- writeInt32AsUInt16 os2 idd.iddMinorVersion;
- writeInt32 os2 idd.iddType;
- writeInt32 os2 idd.iddData.Length; // IMAGE_DEBUG_DIRECTORY.SizeOfData
- writeInt32 os2 debugDataChunk.addr; // IMAGE_DEBUG_DIRECTORY.AddressOfRawData
- writeInt32 os2 (textV2P debugDataChunk.addr);// IMAGE_DEBUG_DIRECTORY.PointerToRawData
-
- (* dprintf "idd.iddCharacteristics = %ld\n" idd.iddCharacteristics;
- dprintf "iddMajorVersion = %ld\n" idd.iddMajorVersion;
- dprintf "iddMinorVersion = %ld\n" idd.iddMinorVersion;
- dprintf "iddType = %ld\n" idd.iddType;
- dprintf "iddData = (%A) = %s\n" idd.iddData (System.Text.Encoding.UTF8.GetString idd.iddData); *)
+ os2.BaseStream.Seek (int64 (textV2P debugDirectoryChunk.addr), SeekOrigin.Begin) |> ignore
+ writeInt32 os2 idd.iddCharacteristics // IMAGE_DEBUG_DIRECTORY.Characteristics
+ writeInt32 os2 timestamp
+ writeInt32AsUInt16 os2 idd.iddMajorVersion
+ writeInt32AsUInt16 os2 idd.iddMinorVersion
+ writeInt32 os2 idd.iddType
+ writeInt32 os2 idd.iddData.Length // IMAGE_DEBUG_DIRECTORY.SizeOfData
+ writeInt32 os2 debugDataChunk.addr // IMAGE_DEBUG_DIRECTORY.AddressOfRawData
+ writeInt32 os2 (textV2P debugDataChunk.addr)// IMAGE_DEBUG_DIRECTORY.PointerToRawData
+
+ (* dprintf "idd.iddCharacteristics = %ld\n" idd.iddCharacteristics
+ dprintf "iddMajorVersion = %ld\n" idd.iddMajorVersion
+ dprintf "iddMinorVersion = %ld\n" idd.iddMinorVersion
+ dprintf "iddType = %ld\n" idd.iddType
+ dprintf "iddData = (%A) = %s\n" idd.iddData (System.Text.Encoding.UTF8.GetString idd.iddData) *)
// write the debug raw data as given us by the PDB writer
- os2.BaseStream.Seek (int64 (textV2P debugDataChunk.addr), SeekOrigin.Begin) |> ignore;
+ os2.BaseStream.Seek (int64 (textV2P debugDataChunk.addr), SeekOrigin.Begin) |> ignore
if debugDataChunk.size < idd.iddData.Length then
- failwith "Debug data area is not big enough. Debug info may not be usable";
- writeBytes os2 idd.iddData;
+ failwith "Debug data area is not big enough. Debug info may not be usable"
+ writeBytes os2 idd.iddData
os2.Close()
with e ->
- failwith ("Error while writing debug directory entry: "+e.Message);
- (try os2.Close(); FileSystem.FileDelete outfile with _ -> ());
+ failwith ("Error while writing debug directory entry: "+e.Message)
+ (try os2.Close(); FileSystem.FileDelete outfile with _ -> ())
reraise()
with e ->
reraise()
- end;
- reportTime showTimes "Finalize PDB";
+ end
+ reportTime showTimes "Finalize PDB"
/// Sign the binary. No further changes to binary allowed past this point!
match signer with
| None -> ()
| Some s ->
try
- s.SignFile outfile;
+ s.SignFile outfile
s.Close()
with e ->
- failwith ("Warning: A call to StrongNameSignatureGeneration failed ("+e.Message+")");
- (try s.Close() with _ -> ());
- (try FileSystem.FileDelete outfile with _ -> ());
+ failwith ("Warning: A call to StrongNameSignatureGeneration failed ("+e.Message+")")
+ (try s.Close() with _ -> ())
+ (try FileSystem.FileDelete outfile with _ -> ())
()
- reportTime showTimes "Signing Image";
+ reportTime showTimes "Signing Image"
//Finished writing and signing the binary and debug info...
mappings
type options =
- { ilg: ILGlobals;
- pdbfile: string option;
- signer: ILStrongNameSigner option;
- fixupOverlappingSequencePoints: bool;
- emitTailcalls : bool;
- showTimes: bool;
+ { ilg: ILGlobals
+ pdbfile: string option
+ signer: ILStrongNameSigner option
+ fixupOverlappingSequencePoints: bool
+ emitTailcalls : bool
+ showTimes: bool
dumpDebugInfo:bool }
-let WriteILBinary outfile (args: options) modul noDebugData =
- ignore (writeBinaryAndReportMappings (outfile, args.ilg, args.pdbfile, args.signer, args.fixupOverlappingSequencePoints, args.emitTailcalls, args.showTimes, args.dumpDebugInfo) modul noDebugData)
-
-
-
-(******************************************************
-** Notes on supporting the Itanium **
-*******************************************************
-IA64 codegen on the CLR isnt documented, and getting it working involved a certain amount of reverse-engineering
-peverify.exe and various binaries generated by ILAsm and other managed compiles. Here are some lessons learned,
-documented for posterity and the 0 other people writing managed compilers for the Itanium:
-
-- Even if youre not utilizing the global pointer in your Itanium binary,
-you should be setting aside space for it in .text. (Preferably near the native stub.)
-- PEVerify checks for two .reloc table entries on the Itanium - one for the native stub, and one
-for the global pointer RVA. It doesnt matter what you set these values to -
-their addresses can be zeroed out, but they must have IMAGE_REL_BASED_DIR64 set!
-(So, yes, you may find yourself setting this flag on an empty, unnecessary table slot!)
-- On the Itanium, its best to have your tables qword aligned. (Though, peverify checks for dword alignment.)
-- A different, weird set of DLL characteristics are necessary for the Itanium.
-I wont detail them here, but its interesting given that this field isnt supposed to vary between platforms,
-and is supposedly marked as deprecated.
-- There are two schools to generating CLR binaries on for the Itanium - Ill call them the ALink school
-and the ILAsm school.
- - The ALink school relies on some quirks in the CLR to omit a lot of stuff that, admittedly, isnt necessary. The binaries are basically IL-only, with some flags set to make them nominally Itanium:
- - It omits the .reloc table
- - It doesnt set aside memory for global pointer storage
- - Theres no native stub
- - Theres no import table, mscoree reference / startup symbol hint
- - A manifest is inserted by default.
- These omissions are understandable, given the platform/jitting/capabilities of the language,
- but theyre basically relying on an idiosyncracy of the runtime to get away with creating a bad binary.
-
- - The ILAsm school actually writes everything out:
- - It has a reloc table with the requisite two entries
- - It sets aside memory for a global pointer, even if it doesnt utilize one
- - It actually inserts a native stub for the Itanium! (Though, I have no idea what
- instructions, specifically, are emitted, and I couldnt dig up the sources to ILAsm to
- find out)
- - Theres the requisite mscoree reference, etc.
- - No manifest is inserted
-*******************************************************)
+let WriteILBinary (outfile, args, ilModule, noDebugData) =
+ ignore (writeBinaryAndReportMappings (outfile, args.ilg, args.pdbfile, args.signer, args.fixupOverlappingSequencePoints, args.emitTailcalls, args.showTimes, args.dumpDebugInfo) ilModule noDebugData)
+
diff --git a/src/absil/ilwrite.fsi b/src/absil/ilwrite.fsi
index f63a65278ec..2d9f6e4385e 100644
--- a/src/absil/ilwrite.fsi
+++ b/src/absil/ilwrite.fsi
@@ -16,21 +16,16 @@ type ILStrongNameSigner =
static member OpenKeyContainer: string -> ILStrongNameSigner
type options =
- { ilg: ILGlobals
- pdbfile: string option;
- signer : ILStrongNameSigner option;
- fixupOverlappingSequencePoints : bool;
- emitTailcalls: bool;
- showTimes : bool;
- dumpDebugInfo : bool }
+ { ilg: ILGlobals
+ pdbfile: string option
+ signer : ILStrongNameSigner option
+ fixupOverlappingSequencePoints : bool
+ emitTailcalls: bool
+ showTimes : bool
+ dumpDebugInfo : bool }
/// Write a binary to the file system. Extra configuration parameters can also be specified.
-val WriteILBinary:
- filename: string ->
- options: options ->
- input: ILModuleDef ->
- noDebugData: bool ->
- unit
+val WriteILBinary: filename: string * options: options * input: ILModuleDef * noDebugData: bool -> unit
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
index 7300c8cb287..d61c245918f 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Interactive.Settings.dll.fs
@@ -3,11 +3,14 @@
#light
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
+
[]
[]
[]
[]
[]
+[]
#if NO_STRONG_NAMES
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Server.Shared.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Server.Shared.dll.fs
index ada202bb2b6..9db04753d19 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Server.Shared.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.Server.Shared.dll.fs
@@ -3,12 +3,14 @@
#light
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
[]
[]
[]
[]
[]
+[]
#if NO_STRONG_NAMES
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.dll.fs
index 957bb6ca5fa..3aec47e8c96 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Compiler.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Compiler.dll.fs
@@ -3,12 +3,15 @@
#light
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
[]
[]
[]
[]
[]
+[]
+
#if NO_STRONG_NAMES
[]
[]
@@ -22,6 +25,7 @@ open System.Reflection
// Note: internals visible to unit test DLLs in Retail (and all) builds.
[]
+[]
[]
[]
[]
@@ -45,6 +49,7 @@ open System.Reflection
[]
[]
[]
+[]
#endif
#if STRONG_NAME_FSHARP_COMPILER_WITH_TEST_KEY
@@ -62,6 +67,7 @@ open System.Reflection
[]
[]
[]
+[]
#endif
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs
index e3bd3389965..c88d9d117b5 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Core.dll.fs
@@ -2,11 +2,16 @@
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
+
[]
[]
[]
[]
[]
+#if !FSHARP_CORE_PORTABLE
+[]
+#endif
#if PORTABLE
[]
diff --git a/src/assemblyinfo/assemblyinfo.FSharp.Data.TypeProviders.dll.fs b/src/assemblyinfo/assemblyinfo.FSharp.Data.TypeProviders.dll.fs
index e761eaebd56..f5a4f3d1ab1 100644
--- a/src/assemblyinfo/assemblyinfo.FSharp.Data.TypeProviders.dll.fs
+++ b/src/assemblyinfo/assemblyinfo.FSharp.Data.TypeProviders.dll.fs
@@ -3,11 +3,14 @@
#light
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
+
[]
[]
[]
[]
[]
+[]
do()
#if NO_STRONG_NAMES
diff --git a/src/assemblyinfo/assemblyinfo.fsc.exe.fs b/src/assemblyinfo/assemblyinfo.fsc.exe.fs
index 7d0af2c39d6..d74fb629294 100644
--- a/src/assemblyinfo/assemblyinfo.fsc.exe.fs
+++ b/src/assemblyinfo/assemblyinfo.fsc.exe.fs
@@ -3,11 +3,14 @@
#light
namespace Microsoft.FSharp
open System.Reflection
+open System.Runtime.InteropServices
+
[]
[]
[]
[]
[]
+[]
[]
do()
diff --git a/src/fsharp-compiler-unittests-build.proj b/src/fsharp-compiler-unittests-build.proj
new file mode 100644
index 00000000000..200c883d9a0
--- /dev/null
+++ b/src/fsharp-compiler-unittests-build.proj
@@ -0,0 +1,18 @@
+
+
+
+
+ net40
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/fsharp.sln b/src/fsharp.sln
index 5c92f68583f..0e9eb059b59 100644
--- a/src/fsharp.sln
+++ b/src/fsharp.sln
@@ -31,6 +31,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Data.TypeProviders",
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiAnyCPU", "fsharp\fsiAnyCpu\FsiAnyCPU.fsproj", "{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}"
EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Unittests", "fsharp\FSharp.Compiler.Unittests\FSharp.Compiler.Unittests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -75,6 +77,10 @@ Global
{CB7D20C4-6506-406D-9144-5342C3595F03}.Release|Any CPU.Build.0 = Release|Any CPU
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}.Debug|Any CPU.ActiveCfg = Debug|x86
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}.Release|Any CPU.ActiveCfg = Release|x86
+ {A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/fsharp/augment.fs b/src/fsharp/AugmentWithHashCompare.fs
similarity index 98%
rename from src/fsharp/augment.fs
rename to src/fsharp/AugmentWithHashCompare.fs
index bff1b0d38d7..5b750bc75ff 100644
--- a/src/fsharp/augment.fs
+++ b/src/fsharp/AugmentWithHashCompare.fs
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
/// Generate the hash/compare functions we add to user-defined types by default.
-module internal Microsoft.FSharp.Compiler.Augment
+module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare
+
open Internal.Utilities
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.AbstractIL
@@ -14,7 +15,7 @@ open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.PrettyNaming
open Microsoft.FSharp.Compiler.Lib
-open Microsoft.FSharp.Compiler.Env
+open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.Infos
let mkIComparableCompareToSlotSig g =
@@ -189,7 +190,7 @@ let mkRecdCompare g tcref (tycon:Tycon) =
let compe = mkILCallGetComparer g m
let mkTest (fspec:RecdField) =
let fty = fspec.FormalType
- let fref = mkNestedRecdFieldRef tcref fspec
+ let fref = tcref.MakeNestedRecdFieldRef fspec
let m = fref.Range
mkCallGenericComparisonWithComparerOuter g m fty
compe
@@ -213,7 +214,7 @@ let mkRecdCompareWithComparer g tcref (tycon:Tycon) (_thisv,thise) (_,thate) com
let mkTest (fspec:RecdField) =
let fty = fspec.FormalType
- let fref = mkNestedRecdFieldRef tcref fspec
+ let fref = tcref.MakeNestedRecdFieldRef fspec
let m = fref.Range
mkCallGenericComparisonWithComparerOuter g m fty
compe
@@ -229,7 +230,7 @@ let mkRecdCompareWithComparer g tcref (tycon:Tycon) (_thisv,thise) (_,thate) com
expr
-/// Build the equality implementation wrapper for a record type
+/// Build the .Equals(that) equality implementation wrapper for a record type
let mkRecdEquality g tcref (tycon:Tycon) =
let m = tycon.Range
let fields = tycon.AllInstanceFieldsAsList
@@ -237,7 +238,7 @@ let mkRecdEquality g tcref (tycon:Tycon) =
let thisv,thatv,thise,thate = mkThisVarThatVar g m ty
let mkTest (fspec:RecdField) =
let fty = fspec.FormalType
- let fref = mkNestedRecdFieldRef tcref fspec
+ let fref = tcref.MakeNestedRecdFieldRef fspec
let m = fref.Range
mkCallGenericEqualityEROuter g m fty
(mkRecdFieldGetViaExprAddr(thise, fref, tinst, m))
@@ -258,7 +259,7 @@ let mkRecdEqualityWithComparer g tcref (tycon:Tycon) (_thisv,thise) thatobje (th
let mkTest (fspec:RecdField) =
let fty = fspec.FormalType
- let fref = mkNestedRecdFieldRef tcref fspec
+ let fref = tcref.MakeNestedRecdFieldRef fspec
let m = fref.Range
mkCallGenericEqualityWithComparerOuter g m fty
@@ -338,7 +339,7 @@ let mkUnionCompare g tcref (tycon:Tycon) =
let expr =
let mbuilder = new MatchBuilder(NoSequencePointAtInvisibleBinding,m )
let mkCase ucase =
- let cref = mkNestedUnionCaseRef tcref ucase
+ let cref = tcref.MakeNestedUnionCaseRef ucase
let m = cref.Range
let thisucv,thisucve = mkCompGenLocal m "thisCast" (mkProvenUnionCaseTy cref tinst)
let thatucv,thatucve = mkCompGenLocal m "objCast" (mkProvenUnionCaseTy cref tinst)
@@ -395,7 +396,7 @@ let mkUnionCompareWithComparer g tcref (tycon:Tycon) (_thisv,thise) (thatv,thate
let expr =
let mbuilder = new MatchBuilder(NoSequencePointAtInvisibleBinding,m )
let mkCase ucase =
- let cref = mkNestedUnionCaseRef tcref ucase
+ let cref = tcref.MakeNestedUnionCaseRef ucase
let m = cref.Range
let thisucv,thisucve = mkCompGenLocal m "thisCastu" (mkProvenUnionCaseTy cref tinst)
let thatucv,thatucve = mkCompGenLocal m "thatCastu" (mkProvenUnionCaseTy cref tinst)
@@ -454,7 +455,7 @@ let mkUnionEquality g tcref (tycon:Tycon) =
let expr =
let mbuilder = new MatchBuilder(NoSequencePointAtInvisibleBinding,m )
let mkCase ucase =
- let cref = mkNestedUnionCaseRef tcref ucase
+ let cref = tcref.MakeNestedUnionCaseRef ucase
let m = cref.Range
let thisucv,thisucve = mkCompGenLocal m "thisCast" (mkProvenUnionCaseTy cref tinst)
let thatucv,thatucve = mkCompGenLocal m "objCast" (mkProvenUnionCaseTy cref tinst)
@@ -509,7 +510,7 @@ let mkUnionEqualityWithComparer g tcref (tycon:Tycon) (_thisv,thise) thatobje (t
let expr =
let mbuilder = new MatchBuilder(NoSequencePointAtInvisibleBinding,m )
let mkCase ucase =
- let cref = mkNestedUnionCaseRef tcref ucase
+ let cref = tcref.MakeNestedUnionCaseRef ucase
let m = cref.Range
let thisucv,thisucve = mkCompGenLocal m "thisCastu" (mkProvenUnionCaseTy cref tinst)
let thatucv,thatucve = mkCompGenLocal m "thatCastu" (mkProvenUnionCaseTy cref tinst)
@@ -566,7 +567,7 @@ let mkRecdHashWithComparer g tcref (tycon:Tycon) compe =
let thisv,thise = mkThisVar g m ty
let mkFieldHash (fspec:RecdField) =
let fty = fspec.FormalType
- let fref = mkNestedRecdFieldRef tcref fspec
+ let fref = tcref.MakeNestedRecdFieldRef fspec
let m = fref.Range
let e = mkRecdFieldGetViaExprAddr(thise, fref, tinst, m)
@@ -604,7 +605,7 @@ let mkUnionHashWithComparer g tcref (tycon:Tycon) compe =
let mbuilder = new MatchBuilder(NoSequencePointAtInvisibleBinding,m )
let accv,acce = mkMutableCompGenLocal m "i" g.int_ty
let mkCase i ucase1 =
- let c1ref = mkNestedUnionCaseRef tcref ucase1
+ let c1ref = tcref.MakeNestedUnionCaseRef ucase1
let ucv,ucve = mkCompGenLocal m "unionCase" (mkProvenUnionCaseTy c1ref tinst)
let m = c1ref.Range
let mkHash j (rfield:RecdField) =
@@ -817,7 +818,7 @@ let TyconIsCandidateForAugmentationWithHash g tycon = TyconIsCandidateForAugment
// IComparable semantics associated with F# types.
//-------------------------------------------------------------------------
-let slotImplMethod (final,c,slotsig) =
+let slotImplMethod (final,c,slotsig) : ValMemberInfo =
{ ImplementedSlotSigs=[slotsig];
MemberFlags=
{ IsInstance=true;
@@ -828,7 +829,7 @@ let slotImplMethod (final,c,slotsig) =
IsImplemented=false;
ApparentParent=c}
-let nonVirtualMethod c =
+let nonVirtualMethod c : ValMemberInfo =
{ ImplementedSlotSigs=[];
MemberFlags={ IsInstance=true;
IsDispatchSlot=false;
diff --git a/src/fsharp/augment.fsi b/src/fsharp/AugmentWithHashCompare.fsi
similarity index 94%
rename from src/fsharp/augment.fsi
rename to src/fsharp/AugmentWithHashCompare.fsi
index 602c0cc2bc0..5d0e7220be1 100644
--- a/src/fsharp/augment.fsi
+++ b/src/fsharp/AugmentWithHashCompare.fsi
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
/// Generate the hash/compare functions we add to user-defined types by default.
-module internal Microsoft.FSharp.Compiler.Augment
+module internal Microsoft.FSharp.Compiler.AugmentWithHashCompare
open Internal.Utilities
open Microsoft.FSharp.Compiler.AbstractIL
@@ -9,7 +9,7 @@ open Microsoft.FSharp.Compiler.AbstractIL.Internal
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Tast
-open Microsoft.FSharp.Compiler.Env
+open Microsoft.FSharp.Compiler.TcGlobals
val CheckAugmentationAttribs : bool -> TcGlobals -> Import.ImportMap -> Tycon -> unit
val TyconIsCandidateForAugmentationWithCompare : TcGlobals -> Tycon -> bool
diff --git a/src/fsharp/formats.fs b/src/fsharp/CheckFormatStrings.fs
similarity index 98%
rename from src/fsharp/formats.fs
rename to src/fsharp/CheckFormatStrings.fs
index 12e79af2674..b5bc537745c 100644
--- a/src/fsharp/formats.fs
+++ b/src/fsharp/CheckFormatStrings.fs
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. 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.Formats
+module internal Microsoft.FSharp.Compiler.CheckFormatStrings
open Internal.Utilities
open Microsoft.FSharp.Compiler
@@ -11,7 +11,7 @@ open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.ErrorLogger
open Microsoft.FSharp.Compiler.Tast
open Microsoft.FSharp.Compiler.Tastops
-open Microsoft.FSharp.Compiler.Env
+open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.ConstraintSolver
type FormatItem = Simple of TType | FuncAndVal
diff --git a/src/fsharp/formats.fsi b/src/fsharp/CheckFormatStrings.fsi
similarity index 72%
rename from src/fsharp/formats.fsi
rename to src/fsharp/CheckFormatStrings.fsi
index 1016ef34cc4..0773039671a 100644
--- a/src/fsharp/formats.fsi
+++ b/src/fsharp/CheckFormatStrings.fsi
@@ -5,11 +5,12 @@
///
/// Must be updated if the Printf runtime component is updated.
-module internal Microsoft.FSharp.Compiler.Formats
+module internal Microsoft.FSharp.Compiler.CheckFormatStrings
open Internal.Utilities
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Tast
+open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.AbstractIL.Internal
-val ParseFormatString : Range.range -> Env.TcGlobals -> string -> TType -> TType -> TType -> TType * TType
+val ParseFormatString : Range.range -> TcGlobals -> string -> TType -> TType -> TType -> TType * TType
diff --git a/src/fsharp/build.fs b/src/fsharp/CompileOps.fs
similarity index 90%
rename from src/fsharp/build.fs
rename to src/fsharp/CompileOps.fs
index 098a2963697..99ea401e774 100644
--- a/src/fsharp/build.fs
+++ b/src/fsharp/CompileOps.fs
@@ -1,28 +1,28 @@
// Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-/// Loading initial context, reporting errors etc.
-module internal Microsoft.FSharp.Compiler.Build
+/// Coordinating compiler operations - configuration, loading initial context, reporting errors etc.
+module internal Microsoft.FSharp.Compiler.CompileOps
+
open System
open System.Text
open System.IO
open System.Collections.Generic
open Internal.Utilities
open Internal.Utilities.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.Extensions.ILX
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
-open Microsoft.FSharp.Compiler.Pickle
+open Microsoft.FSharp.Compiler.TastPickle
open Microsoft.FSharp.Compiler.Range
-open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.TypeChecker
open Microsoft.FSharp.Compiler.SR
open Microsoft.FSharp.Compiler.DiagnosticMessage
module Tc = Microsoft.FSharp.Compiler.TypeChecker
-module SR = Microsoft.FSharp.Compiler.SR
open Microsoft.FSharp.Compiler.AbstractIL.IL
open Microsoft.FSharp.Compiler.Range
@@ -31,14 +31,14 @@ 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.Env
+open Microsoft.FSharp.Compiler.TcGlobals
open Microsoft.FSharp.Compiler.Lexhelp
open Microsoft.FSharp.Compiler.Lib
open Microsoft.FSharp.Compiler.Infos
open Microsoft.FSharp.Compiler.ConstraintSolver
open Microsoft.FSharp.Compiler.MSBuildResolver
-open Microsoft.FSharp.Compiler.Typrelns
-open Microsoft.FSharp.Compiler.Nameres
+open Microsoft.FSharp.Compiler.TypeRelations
+open Microsoft.FSharp.Compiler.NameResolution
open Microsoft.FSharp.Compiler.PrettyNaming
open Internal.Utilities.FileSystem
open Internal.Utilities.Collections
@@ -71,13 +71,13 @@ open FullCompiler
// Some Globals
//--------------------------------------------------------------------------
-let sigSuffixes = [".mli";".fsi"]
+let FSharpSigFileSuffixes = [".mli";".fsi"]
let mlCompatSuffixes = [".mli";".ml"]
-let implSuffixes = [".ml";".fs";".fsscript";".fsx"]
+let FSharpImplFileSuffixes = [".ml";".fs";".fsscript";".fsx"]
let resSuffixes = [".resx"]
-let scriptSuffixes = [".fsscript";".fsx"]
-let doNotRequireNamespaceOrModuleSuffixes = [".mli";".ml"] @ scriptSuffixes
-let lightSyntaxDefaultExtensions : string list = [ ".fs";".fsscript";".fsx";".fsi" ]
+let FSharpScriptFileSuffixes = [".fsscript";".fsx"]
+let doNotRequireNamespaceOrModuleSuffixes = [".mli";".ml"] @ FSharpScriptFileSuffixes
+let FSharpLightSyntaxFileSuffixes : string list = [ ".fs";".fsscript";".fsx";".fsi" ]
//----------------------------------------------------------------------------
@@ -102,7 +102,7 @@ exception HashLoadedScriptConsideredSource of range
exception InvalidInternalsVisibleToAssemblyName of (*badName*)string * (*fileName option*) string option
-let RangeOfError(err:PhasedError) =
+let GetRangeOfError(err:PhasedError) =
let rec RangeFromException = function
| ErrorFromAddingConstraint(_,err2,_) -> RangeFromException err2
#if EXTENSIONTYPING
@@ -154,8 +154,8 @@ let RangeOfError(err:PhasedError) =
| FullAbstraction(_,m)
| InterfaceNotRevealed(_,_,m)
| WrappedError (_,m)
- | Patcompile.MatchIncomplete (_,_,m)
- | Patcompile.RuleNeverMatched m
+ | PatternMatchCompilation.MatchIncomplete (_,_,m)
+ | PatternMatchCompilation.RuleNeverMatched m
| ValNotMutable(_,_,m)
| ValNotLocal(_,_,m)
| MissingFields(_,m)
@@ -191,7 +191,6 @@ let RangeOfError(err:PhasedError) =
| UnresolvedOverloading(_,_,_,m)
| UnresolvedConversionOperator (_,_,_,m)
| PossibleOverload(_,_,_, m)
- //| PossibleBestOverload(_,_,m)
| VirtualAugmentationOnNullValuedType(m)
| NonVirtualAugmentationOnNullValuedType(m)
| NonRigidTypar(_,_,_,_,_,m)
@@ -266,8 +265,8 @@ let GetErrorNumber(err:PhasedError) =
| LetRecEvaluatedOutOfOrder _ -> 22
| NameClash _ -> 23
// 24 cannot be reused
- | Patcompile.MatchIncomplete _ -> 25
- | Patcompile.RuleNeverMatched _ -> 26
+ | PatternMatchCompilation.MatchIncomplete _ -> 25
+ | PatternMatchCompilation.RuleNeverMatched _ -> 26
| ValNotMutable _ -> 27
| ValNotLocal _ -> 28
| MissingFields _ -> 29
@@ -390,7 +389,8 @@ let warningOn err level specificWarnOn =
List.mem n specificWarnOn ||
// Some specific warnings are never on by default, i.e. unused variable warnings
match n with
- | 1182 -> false
+ | 1182 -> false // chkUnusedValue - off by default
+ | 3180 -> false // abImplicitHeapAllocation - off by default
| _ -> level >= GetWarningLevel err
let SplitRelatedErrors(err:PhasedError) =
@@ -722,13 +722,9 @@ let OutputPhasedErrorR (os:System.Text.StringBuilder) (err:PhasedError) =
os.Append(Duplicate2E().Format k (DecompileOpName s)) |> ignore
| UndefinedName(_,k,id,_) ->
os.Append(k (DecompileOpName id.idText)) |> ignore
-
- | InternalUndefinedTyconItem(f,tcref,s) ->
- let _, errs = f((fullDisplayTextOfTyconRef tcref), s)
- os.Append(errs) |> ignore
- | InternalUndefinedItemRef(f,smr,ccuName,s) ->
- let _, errs = f(smr, ccuName, s)
- os.Append(errs) |> ignore
+ | InternalUndefinedItemRef(f,smr,ccuName,s) ->
+ let _, errs = f(smr, ccuName, s)
+ os.Append(errs) |> ignore
| FieldNotMutable _ ->
os.Append(FieldNotMutableE().Format) |> ignore
| FieldsFromDifferentTypes (_,fref1,fref2,_) ->
@@ -1202,7 +1198,7 @@ let OutputPhasedErrorR (os:System.Text.StringBuilder) (err:PhasedError) =
#endif
| FullAbstraction(s,_) -> os.Append(FullAbstractionE().Format s) |> ignore
| WrappedError (exn,_) -> OutputExceptionR os exn
- | Patcompile.MatchIncomplete (isComp,cexOpt,_) ->
+ | PatternMatchCompilation.MatchIncomplete (isComp,cexOpt,_) ->
os.Append(MatchIncomplete1E().Format) |> ignore
match cexOpt with
| None -> ()
@@ -1210,7 +1206,7 @@ let OutputPhasedErrorR (os:System.Text.StringBuilder) (err:PhasedError) =
| Some (cex,true) -> os.Append(MatchIncomplete3E().Format cex) |> ignore
if isComp then
os.Append(MatchIncomplete4E().Format) |> ignore
- | Patcompile.RuleNeverMatched _ -> os.Append(RuleNeverMatchedE().Format) |> ignore
+ | PatternMatchCompilation.RuleNeverMatched _ -> os.Append(RuleNeverMatchedE().Format) |> ignore
| ValNotMutable _ -> os.Append(ValNotMutableE().Format) |> ignore
| ValNotLocal _ -> os.Append(ValNotLocalE().Format) |> ignore
| ObsoleteError (s, _)
@@ -1370,35 +1366,33 @@ let SanitizeFileName fileName implicitIncludeDir =
with _ ->
fileName
+[]
type ErrorLocation =
- {
- Range : range
- File : string
- TextRepresentation : string
- IsEmpty : bool
- }
+ { Range : range
+ File : string
+ TextRepresentation : string
+ IsEmpty : bool }
+[]
type CanonicalInformation =
- {
- ErrorNumber : int
- Subcategory : string
- TextRepresentation : string
- }
+ { ErrorNumber : int
+ Subcategory : string
+ TextRepresentation : string }
+[]
type DetailedIssueInfo =
- {
- Location : ErrorLocation option
- Canonical : CanonicalInformation
- Message : string
- }
+ { Location : ErrorLocation option
+ Canonical : CanonicalInformation
+ Message : string }
+[]
type ErrorOrWarning =
| Short of bool * string
| Long of bool * DetailedIssueInfo
/// returns sequence that contains ErrorOrWarning for the given error + ErrorOrWarning for all related errors
let CollectErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,errorStyle,warn, err:PhasedError) =
- let outputWhere (showFullPaths,errorStyle) m =
+ let outputWhere (showFullPaths,errorStyle) m : ErrorLocation =
if m = rangeStartup || m = rangeCmdArgs then
{ Range = m; TextRepresentation = ""; IsEmpty = true; File = "" }
else
@@ -1448,11 +1442,11 @@ let CollectErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,errorS
let errors = ResizeArray()
let report err =
let OutputWhere(err) =
- match RangeOfError err with
+ match GetRangeOfError err with
| Some m -> Some(outputWhere (showFullPaths,errorStyle) m)
| None -> None
- let OutputCanonicalInformation(err:PhasedError,subcategory, errorNumber) =
+ let OutputCanonicalInformation(err:PhasedError,subcategory, errorNumber) : CanonicalInformation =
let text =
match errorStyle with
// Show the subcategory for --vserrors so that we can fish it out in Visual Studio and use it to determine error stickiness.
@@ -1468,7 +1462,7 @@ let CollectErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,errorS
OutputPhasedError os mainError flattenErrors;
os.ToString()
- let entry = { Location = where; Canonical = canonical; Message = message }
+ let entry : DetailedIssueInfo = { Location = where; Canonical = canonical; Message = message }
errors.Add ( ErrorOrWarning.Long( not warn, entry ) )
@@ -1483,7 +1477,7 @@ let CollectErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,errorS
OutputPhasedError os err flattenErrors
os.ToString()
- let entry = { Location = relWhere; Canonical = relCanonical; Message = relMessage}
+ let entry : DetailedIssueInfo = { Location = relWhere; Canonical = relCanonical; Message = relMessage}
errors.Add( ErrorOrWarning.Long (not warn, entry) )
| _ ->
@@ -1513,9 +1507,9 @@ let rec OutputErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,err
for e in errors do
Printf.bprintf os "\n"
match e with
- | Short(_, txt) ->
+ | ErrorOrWarning.Short(_, txt) ->
os.Append txt |> ignore
- | Long(_, details) ->
+ | ErrorOrWarning.Long(_, details) ->
match details.Location with
| Some l when not l.IsEmpty -> os.Append(l.TextRepresentation) |> ignore
| _ -> ()
@@ -1523,7 +1517,7 @@ let rec OutputErrorOrWarning (implicitIncludeDir,showFullPaths,flattenErrors,err
os.Append( details.Message ) |> ignore
let OutputErrorOrWarningContext prefix fileLineFn os err =
- match RangeOfError err with
+ match GetRangeOfError err with
| None -> ()
| Some m ->
let filename = m.FileName
@@ -1574,9 +1568,12 @@ let DefaultBasicReferencesForOutOfProjectSources =
// Note: this is not a partiuclarly good technique as it relying on the environment the compiler is executing in
// to determine the default references. However, System.Core will only fail to load on machines with only .NET 2.0,
// in which case the compiler will also be running as a .NET 2.0 process.
+ //
+ // NOTE: it seems this can now be removed now that .NET 4.x is minimally assumed when using this toolchain
if (try System.Reflection.Assembly.Load "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" |> ignore; true with _ -> false) then
yield "System.Core"
+ yield "System.Runtime"
yield "System.Web"
yield "System.Web.Services"
yield "System.Windows.Forms" ]
@@ -1603,6 +1600,7 @@ let SystemAssemblies primaryAssemblyName =
yield "System.Web.Services"
yield "System.Windows.Forms"
yield "System.Core"
+ yield "System.Runtime"
yield "System.Observable"
yield "System.Numerics"]
@@ -1676,6 +1674,7 @@ type CompilerTarget =
type ResolveAssemblyReferenceMode = Speculative | ReportErrors
+/// Represents the file or string used for the --version flag
type VersionFlag =
| VersionString of string
| VersionFile of string
@@ -1736,7 +1735,7 @@ type ImportedAssembly =
IsProviderGenerated: bool
mutable TypeProviders: Tainted list;
#endif
- FSharpOptimizationData : Microsoft.FSharp.Control.Lazy