Skip to content

Commit e6d3010

Browse files
committed
Merge pull request #389 from dsyme/cleanup-oob
Integrate F# 4.x OOB cleanup
2 parents 56e10a2 + 6a278ae commit e6d3010

File tree

103 files changed

+4699
-4925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+4699
-4925
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,7 @@ FSharp.Core.Nuget/*.nupkg
123123
*.jrs
124124
*.chk
125125
*.bak
126+
FSharp.Compiler.Tools.Nuget/*.nupkg
127+
FSharp.Core.Nuget/*.nupkg
126128
*.orig
127129
.paket/paket.exe

README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,3 @@ All AppVeyor builds are available using the NuGet feed: https://ci.appveyor.com/
3131

3232
If using Paket, add the source at the top of `paket.dependencies`.
3333

34-
```
35-
source https://www.nuget.org/api/v2
36-
source https://ci.appveyor.com/nuget/fsgit-fsharp-compiler-service
37-
```
38-
39-
See the build history for a list of available versions: https://ci.appveyor.com/project/fsgit/fsharp-compiler-service/history
40-
41-
Here are some options for specifying the dependency:
42-
43-
```
44-
nuget FSharp.Compiler.Service
45-
nuget FSharp.Compiler.Service prerelease
46-
nuget FSharp.Compiler.Service 1.3.1.0
47-
nuget FSharp.Compiler.Service 1.3.1.1-b402
48-
```
49-
50-
Dev Guide
51-
----------
52-
53-
To integrate latest changes from http://github.com/fsharp/fsharp, use
54-
55-
git remote add fsc https://github.com/fsharp/fsharp
56-
git pull fsc master

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 1.4.0.3 -
2+
* integrate Microsoft/visualfsharp OOB cleanup via fsharp/fsharp
3+
14
#### 1.4.0.2 -
25
* #387 - types and arrays in F# attribute contructor arguments
36

build.fsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,10 @@ Target "BuildVersion" (fun _ ->
5656
// Generate assembly info files with the right version & up-to-date information
5757
Target "AssemblyInfo" (fun _ ->
5858
let fileName = "src/assemblyinfo/assemblyinfo.shared.fs"
59-
// add json info to the informational version
60-
let iv = Text.StringBuilder() // json
61-
iv.Appendf "{\\\"buildVersion\\\":\\\"%s\\\"" buildVersion
62-
iv.Appendf ",\\\"buildDate\\\":\\\"%s\\\"" (buildDate.ToString "yyyy'-'MM'-'dd'T'HH':'mm':'sszzz")
63-
if isAppVeyorBuild then
64-
iv.Appendf ",\\\"gitCommit\\\":\\\"%s\\\"" AppVeyor.AppVeyorEnvironment.RepoCommit
65-
iv.Appendf ",\\\"gitBranch\\\":\\\"%s\\\"" AppVeyor.AppVeyorEnvironment.RepoBranch
66-
iv.Appendf "}"
6759
CreateFSharpAssemblyInfo fileName
6860
[ Attribute.Version assemblyVersion
6961
Attribute.FileVersion assemblyVersion
70-
Attribute.InformationalVersion iv.String ]
62+
Attribute.InformationalVersion assemblyVersion ]
7163
)
7264

7365
// --------------------------------------------------------------------------------------

lib/bootstrap/4.0/FSharp.SRGen.targets

100755100644
File mode changed.

lib/bootstrap/4.0/FsLexYacc.Build.Tasks.dll

100644100755
File mode changed.

samples/FscExe/FscMain.fs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
module internal Microsoft.FSharp.Compiler.CommandLineMain
44

5+
open System
6+
open System.Diagnostics
7+
open System.IO
8+
open System.Reflection
9+
open System.Runtime.CompilerServices
510
open Microsoft.FSharp.Compiler
611
open Microsoft.FSharp.Compiler.AbstractIL.IL // runningOnMono
712
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library
813
open Microsoft.FSharp.Compiler.ErrorLogger
914
open Microsoft.FSharp.Compiler.SimpleSourceCodeServices
10-
open System.Runtime.CompilerServices
15+
open Microsoft.FSharp.Compiler.Range
1116

1217
type TypeInThisAssembly() = member x.Dummy = 1
1318

@@ -16,10 +21,6 @@ let progress = ref false
1621
/// Implement the optional resident compilation service
1722
module FSharpResidentCompiler =
1823

19-
open System
20-
open System.Diagnostics
21-
open System.IO
22-
open System.Reflection
2324
open System.Runtime.Remoting.Channels
2425
open System.Runtime.Remoting
2526
open System.Runtime.Remoting.Lifetime
@@ -31,10 +32,10 @@ module FSharpResidentCompiler =
3132
let output = ResizeArray()
3233
let outWriter isOut =
3334
{ new TextWriter() with
34-
member x.Write(c:char) = lock output (fun () -> output.Add (isOut, (try Some System.Console.ForegroundColor with _ -> None) ,c))
35+
member x.Write(c:char) = lock output (fun () -> output.Add (isOut, (try Some Console.ForegroundColor with _ -> None) ,c))
3536
member x.Encoding = Encoding.UTF8 }
36-
do System.Console.SetOut (outWriter true)
37-
do System.Console.SetError (outWriter false)
37+
do Console.SetOut (outWriter true)
38+
do Console.SetError (outWriter false)
3839
member x.GetTextAndClear() = lock output (fun () -> let res = output.ToArray() in output.Clear(); res)
3940

4041
/// The compilation server, which runs in the server process. Accessed by clients using .NET remoting.
@@ -235,7 +236,7 @@ module FSharpResidentCompiler =
235236
Console.ForegroundColor <- consoleColor;
236237
| None -> ()
237238
with _ -> ()
238-
c |> (if isOut then System.Console.Out.Write else System.Console.Error.Write)
239+
c |> (if isOut then Console.Out.Write else Console.Error.Write)
239240
Some exitCode
240241
with err ->
241242
eprintfn "%s" (err.ToString())

src/absil/il.fs

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,18 @@ module SHA1 =
215215
else k60to79
216216

217217

218-
type chan = SHABytes of byte[]
219-
type sha_instream =
220-
{ stream: chan;
218+
type SHAStream =
219+
{ stream: byte[];
221220
mutable pos: int;
222221
mutable eof: bool; }
223222

224-
let rot_left32 x n = (x <<< n) ||| (x >>>& (32-n))
223+
let rotLeft32 x n = (x <<< n) ||| (x >>>& (32-n))
225224

226-
let inline sha_eof sha = sha.eof
227-
228-
(* padding and length (in bits!) recorded at end *)
229-
let sha_after_eof sha =
225+
226+
// padding and length (in bits!) recorded at end
227+
let shaAfterEof sha =
230228
let n = sha.pos
231-
let len =
232-
(match sha.stream with
233-
| SHABytes s -> s.Length)
229+
let len = sha.stream.Length
234230
if n = len then 0x80
235231
else
236232
let padded_len = (((len + 9 + 63) / 64) * 64) - 8
@@ -245,22 +241,21 @@ module SHA1 =
245241
elif (n &&& 63) = 63 then (sha.eof <- true; int32 (int64 len * int64 8) &&& 0xff)
246242
else 0x0
247243

248-
let sha_read8 sha =
249-
let b =
250-
match sha.stream with
251-
| SHABytes s -> if sha.pos >= s.Length then sha_after_eof sha else int32 s.[sha.pos]
252-
sha.pos <- sha.pos + 1;
244+
let shaRead8 sha =
245+
let s = sha.stream
246+
let b = if sha.pos >= s.Length then shaAfterEof sha else int32 s.[sha.pos]
247+
sha.pos <- sha.pos + 1
253248
b
254249

255-
let sha_read32 sha =
256-
let b0 = sha_read8 sha
257-
let b1 = sha_read8 sha
258-
let b2 = sha_read8 sha
259-
let b3 = sha_read8 sha
250+
let shaRead32 sha =
251+
let b0 = shaRead8 sha
252+
let b1 = shaRead8 sha
253+
let b2 = shaRead8 sha
254+
let b3 = shaRead8 sha
260255
let res = (b0 <<< 24) ||| (b1 <<< 16) ||| (b2 <<< 8) ||| b3
261256
res
262257

263-
let sha1_hash sha =
258+
let sha1Hash sha =
264259
let mutable h0 = 0x67452301
265260
let mutable h1 = 0xEFCDAB89
266261
let mutable h2 = 0x98BADCFE
@@ -272,21 +267,21 @@ module SHA1 =
272267
let mutable d = 0
273268
let mutable e = 0
274269
let w = Array.create 80 0x00
275-
while (not (sha_eof sha)) do
270+
while (not sha.eof) do
276271
for i = 0 to 15 do
277-
w.[i] <- sha_read32 sha
272+
w.[i] <- shaRead32 sha
278273
for t = 16 to 79 do
279-
w.[t] <- rot_left32 (w.[t-3] ^^^ w.[t-8] ^^^ w.[t-14] ^^^ w.[t-16]) 1
274+
w.[t] <- rotLeft32 (w.[t-3] ^^^ w.[t-8] ^^^ w.[t-14] ^^^ w.[t-16]) 1
280275
a <- h0
281276
b <- h1
282277
c <- h2
283278
d <- h3
284279
e <- h4
285280
for t = 0 to 79 do
286-
let temp = (rot_left32 a 5) + f(t,b,c,d) + e + w.[t] + k(t)
281+
let temp = (rotLeft32 a 5) + f(t,b,c,d) + e + w.[t] + k(t)
287282
e <- d
288283
d <- c
289-
c <- rot_left32 b 30
284+
c <- rotLeft32 b 30
290285
b <- a
291286
a <- temp
292287
h0 <- h0 + a
@@ -297,7 +292,7 @@ module SHA1 =
297292
h0,h1,h2,h3,h4
298293

299294
let sha1HashBytes s =
300-
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
295+
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
301296
Array.map byte [| b0 h4; b1 h4; b2 h4; b3 h4; b0 h3; b1 h3; b2 h3; b3 h3; |]
302297

303298

src/absil/ilascii.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
1212
open Microsoft.FSharp.Compiler.AbstractIL.Extensions.ILX.Types
1313
open Microsoft.FSharp.Compiler.AbstractIL.IL
1414

15-
// set to the proper value at build.fs (BuildFrameworkTcImports)
15+
// set to the proper value at CompileOps.fs (BuildFrameworkTcImports)
1616
let parseILGlobals = ref EcmaILGlobals
1717

1818
// --------------------------------------------------------------------

src/absil/illib.fs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ module Dictionary =
472472

473473
// FUTURE CLEANUP: remove this adhoc collection
474474
type Hashset<'T> = Dictionary<'T,int>
475+
475476
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
476477
module Hashset =
477478
let create (n:int) = new Hashset<'T>(n, HashIdentity.Structural)
@@ -505,6 +506,28 @@ type ResultOrException<'TResult> =
505506
| Result of 'TResult
506507
| Exception of System.Exception
507508

509+
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
510+
module ResultOrException =
511+
512+
let success a = Result a
513+
let raze (b:exn) = Exception b
514+
515+
// map
516+
let (|?>) res f =
517+
match res with
518+
| Result x -> Result(f x )
519+
| Exception err -> Exception err
520+
521+
let ForceRaise res =
522+
match res with
523+
| Result x -> x
524+
| Exception err -> raise err
525+
526+
let otherwise f x =
527+
match x with
528+
| Result x -> success x
529+
| Exception _err -> f()
530+
508531

509532
//-------------------------------------------------------------------------
510533
// Library: extensions to flat list (immutable arrays)
@@ -1088,4 +1111,4 @@ module Shim =
10881111
System.Text.Encoding.GetEncoding(n)
10891112
#endif
10901113

1091-
let mutable FileSystem = DefaultFileSystem() :> IFileSystem
1114+
let mutable FileSystem = DefaultFileSystem() :> IFileSystem

0 commit comments

Comments
 (0)