Skip to content

Commit 70e5f02

Browse files
committed
Merge pull request #467 from dsyme/visualfsharp-integrate-01dc
Integrate visualfsharp/OOB --> master
2 parents e51a2a7 + e3877c1 commit 70e5f02

File tree

93 files changed

+4927
-5073
lines changed

Some content is hidden

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

93 files changed

+4927
-5073
lines changed

CHANGELOG.md

Lines changed: 150 additions & 15 deletions
Large diffs are not rendered by default.

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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ module Dictionary =
465465

466466
// FUTURE CLEANUP: remove this adhoc collection
467467
type Hashset<'T> = Dictionary<'T,int>
468+
468469
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
469470
module Hashset =
470471
let create (n:int) = new Hashset<'T>(n, HashIdentity.Structural)
@@ -498,6 +499,28 @@ type ResultOrException<'TResult> =
498499
| Result of 'TResult
499500
| Exception of System.Exception
500501

502+
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
503+
module ResultOrException =
504+
505+
let success a = Result a
506+
let raze (b:exn) = Exception b
507+
508+
// map
509+
let (|?>) res f =
510+
match res with
511+
| Result x -> Result(f x )
512+
| Exception err -> Exception err
513+
514+
let ForceRaise res =
515+
match res with
516+
| Result x -> x
517+
| Exception err -> raise err
518+
519+
let otherwise f x =
520+
match x with
521+
| Result x -> success x
522+
| Exception _err -> f()
523+
501524

502525
//-------------------------------------------------------------------------
503526
// Library: extensions to flat list (immutable arrays)

0 commit comments

Comments
 (0)