提交 7f89ce63 编写于 作者: D Don Syme

whitespace normalization and cleanup

上级 f58ff39b
此差异已折叠。
......@@ -495,10 +495,10 @@ module ValueOptionInternal =
let inline bind f x = match x with ValueSome x -> f x | ValueNone -> ValueNone
type String with
member inline x.StartsWithOrdinal(value) =
member inline x.StartsWithOrdinal value =
x.StartsWith(value, StringComparison.Ordinal)
member inline x.EndsWithOrdinal(value) =
member inline x.EndsWithOrdinal value =
x.EndsWith(value, StringComparison.Ordinal)
module String =
......@@ -508,7 +508,7 @@ module String =
let sub (s: string) (start: int) (len: int) = s.Substring(start, len)
let contains (s: string) (c: char) = s.IndexOf(c) <> -1
let contains (s: string) (c: char) = s.IndexOf c <> -1
let order = LanguagePrimitives.FastGenericComparer<string>
......@@ -543,7 +543,7 @@ module String =
| None -> str
| Some c ->
strArr.[0] <- Char.ToLower c
String (strArr)
String strArr
let extractTrailingIndex (str: string) =
match str with
......@@ -569,7 +569,7 @@ module String =
let (|StartsWith|_|) pattern value =
if String.IsNullOrWhiteSpace value then
None
elif value.StartsWithOrdinal(pattern) then
elif value.StartsWithOrdinal pattern then
Some()
else None
......@@ -583,14 +583,14 @@ module String =
let getLines (str: string) =
use reader = new StringReader(str)
[|
let line = ref (reader.ReadLine())
while not (isNull !line) do
yield !line
line := reader.ReadLine()
if str.EndsWithOrdinal("\n") then
// last trailing space not returned
// http://stackoverflow.com/questions/19365404/stringreader-omits-trailing-linebreak
yield String.Empty
let line = ref (reader.ReadLine())
while not (isNull !line) do
yield !line
line := reader.ReadLine()
if str.EndsWithOrdinal("\n") then
// last trailing space not returned
// http://stackoverflow.com/questions/19365404/stringreader-omits-trailing-linebreak
yield String.Empty
|]
module Dictionary =
......@@ -810,9 +810,9 @@ type CancellableBuilder() =
member x.Bind(e, k) = Cancellable.bind k e
member x.Return(v) = Cancellable.ret v
member x.Return v = Cancellable.ret v
member x.ReturnFrom(v) = v
member x.ReturnFrom v = v
member x.Combine(e1, e2) = e1 |> Cancellable.bind (fun () -> e2)
......@@ -822,7 +822,7 @@ type CancellableBuilder() =
member x.TryFinally(e, compensation) = Cancellable.tryFinally e compensation
member x.Delay(f) = Cancellable.delay f
member x.Delay f = Cancellable.delay f
member x.Zero() = Cancellable.ret ()
......@@ -850,12 +850,12 @@ module Eventually =
let rec box e =
match e with
| Done x -> Done (Operators.box x)
| NotYetDone (work) -> NotYetDone (fun ctok -> box (work ctok))
| NotYetDone work -> NotYetDone (fun ctok -> box (work ctok))
let rec forceWhile ctok check e =
match e with
| Done x -> Some(x)
| NotYetDone (work) ->
| Done x -> Some x
| NotYetDone work ->
if not(check())
then None
else forceWhile ctok check (work ctok)
......@@ -918,7 +918,7 @@ module Eventually =
let delay (f: unit -> Eventually<'T>) = NotYetDone (fun _ctok -> f())
let tryFinally e compensation =
catch (e)
catch e
|> bind (fun res ->
compensation()
match res with
......@@ -937,9 +937,9 @@ type EventuallyBuilder() =
member x.Bind(e, k) = Eventually.bind k e
member x.Return(v) = Eventually.Done v
member x.Return v = Eventually.Done v
member x.ReturnFrom(v) = v
member x.ReturnFrom v = v
member x.Combine(e1, e2) = e1 |> Eventually.bind (fun () -> e2)
......@@ -947,7 +947,7 @@ type EventuallyBuilder() =
member x.TryFinally(e, compensation) = Eventually.tryFinally e compensation
member x.Delay(f) = Eventually.delay f
member x.Delay f = Eventually.delay f
member x.Zero() = Eventually.Done ()
......@@ -966,7 +966,7 @@ type UniqueStampGenerator<'T when 'T : equality>() =
let encodeTab = new Dictionary<'T, int>(HashIdentity.Structural)
let mutable nItems = 0
let encode str =
match encodeTab.TryGetValue(str) with
match encodeTab.TryGetValue str with
| true, idx -> idx
| _ ->
let idx = nItems
......@@ -974,7 +974,7 @@ type UniqueStampGenerator<'T when 'T : equality>() =
nItems <- nItems + 1
idx
member this.Encode(str) = encode str
member this.Encode str = encode str
member this.Table = encodeTab.Keys
......@@ -983,7 +983,7 @@ type MemoizationTable<'T, 'U>(compute: 'T -> 'U, keyComparer: IEqualityComparer<
let table = new Dictionary<'T, 'U>(keyComparer)
member t.Apply(x) =
member t.Apply x =
if (match canMemoize with None -> true | Some f -> f x) then
let mutable res = Unchecked.defaultof<'U>
let ok = table.TryGetValue(x, &res)
......@@ -1044,13 +1044,13 @@ type LazyWithContext<'T, 'ctxt> =
| null -> x.value
| _ ->
// Enter the lock in case another thread is in the process of evaluating the result
Monitor.Enter(x);
Monitor.Enter x;
try
x.UnsynchronizedForce(ctxt)
x.UnsynchronizedForce ctxt
finally
Monitor.Exit(x)
Monitor.Exit x
member x.UnsynchronizedForce(ctxt) =
member x.UnsynchronizedForce ctxt =
match x.funcOrException with
| null -> x.value
| :? LazyWithContextFailure as res ->
......@@ -1104,15 +1104,15 @@ module IPartialEqualityComparer =
let partialDistinctBy (per: IPartialEqualityComparer<'T>) seq =
let wper =
{ new IPartialEqualityComparer<WrapType<'T>> with
member __.InEqualityRelation (Wrap x) = per.InEqualityRelation (x)
member __.InEqualityRelation (Wrap x) = per.InEqualityRelation x
member __.Equals(Wrap x, Wrap y) = per.Equals(x, y)
member __.GetHashCode (Wrap x) = per.GetHashCode(x) }
member __.GetHashCode (Wrap x) = per.GetHashCode x }
// Wrap a Wrap _ around all keys in case the key type is itself a type using null as a representation
let dict = Dictionary<WrapType<'T>, obj>(wper)
seq |> List.filter (fun v ->
let key = Wrap(v)
if (per.InEqualityRelation(v)) then
if dict.ContainsKey(key) then false else (dict.[key] <- null; true)
let key = Wrap v
if (per.InEqualityRelation v) then
if dict.ContainsKey key then false else (dict.[key] <- null; true)
else true)
//-------------------------------------------------------------------------
......@@ -1350,18 +1350,18 @@ module Shim =
member __.IsInvalidPathShim(path: string) =
let isInvalidPath(p: string) =
String.IsNullOrEmpty(p) || p.IndexOfAny(Path.GetInvalidPathChars()) <> -1
String.IsNullOrEmpty p || p.IndexOfAny(Path.GetInvalidPathChars()) <> -1
let isInvalidFilename(p: string) =
String.IsNullOrEmpty(p) || p.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1
String.IsNullOrEmpty p || p.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1
let isInvalidDirectory(d: string) =
d=null || d.IndexOfAny(Path.GetInvalidPathChars()) <> -1
isInvalidPath (path) ||
let directory = Path.GetDirectoryName(path)
let filename = Path.GetFileName(path)
isInvalidDirectory(directory) || isInvalidFilename(filename)
isInvalidPath path ||
let directory = Path.GetDirectoryName path
let filename = Path.GetFileName path
isInvalidDirectory directory || isInvalidFilename filename
member __.GetTempPathShim() = Path.GetTempPath()
......@@ -1372,7 +1372,7 @@ module Shim =
member __.FileDelete (fileName: string) = File.Delete fileName
member __.IsStableFileHeuristic (fileName: string) =
let directory = Path.GetDirectoryName(fileName)
let directory = Path.GetDirectoryName fileName
directory.Contains("Reference Assemblies/") ||
directory.Contains("Reference Assemblies\\") ||
directory.Contains("packages/") ||
......
......@@ -39,8 +39,8 @@ let alwaysMemoryMapFSC = try (System.Environment.GetEnvironmentVariable("FSharp_
let stronglyHeldReaderCacheSizeDefault = 30
let stronglyHeldReaderCacheSize = try (match System.Environment.GetEnvironmentVariable("FSharp_StronglyHeldBinaryReaderCacheSize") with null -> stronglyHeldReaderCacheSizeDefault | s -> int32 s) with _ -> stronglyHeldReaderCacheSizeDefault
let singleOfBits (x: int32) = System.BitConverter.ToSingle(System.BitConverter.GetBytes(x), 0)
let doubleOfBits (x: int64) = System.BitConverter.Int64BitsToDouble(x)
let singleOfBits (x: int32) = System.BitConverter.ToSingle(System.BitConverter.GetBytes x, 0)
let doubleOfBits (x: int64) = System.BitConverter.Int64BitsToDouble x
//---------------------------------------------------------------------
// Utilities.
......@@ -164,7 +164,7 @@ type RawMemoryView(obj: obj, start: nativeint, len: int) =
if nativeint i > nativeint len then failwithf "RawMemoryView overrun, i = %d, obj = %A" i obj
let pStart = start + nativeint i
let mutable p = start
while Marshal.ReadByte(p) <> 0uy do
while Marshal.ReadByte p <> 0uy do
p <- p + 1n
int (p - pStart)
......@@ -258,7 +258,7 @@ type MemoryMapView(start: nativeint) =
override m.CountUtf8String i =
let pStart = start + nativeint i
let mutable p = start
while Marshal.ReadByte(p) <> 0uy do
while Marshal.ReadByte p <> 0uy do
p <- p + 1n
int (p - pStart)
......@@ -280,7 +280,7 @@ type MemoryMapFile(fileName: string, view: MemoryMapView, hMap: MemoryMapping.HA
failwithf "CreateFile(0x%08x)" (Marshal.GetHRForLastWin32Error())
let protection = 0x00000002
let hMap = MemoryMapping.CreateFileMapping (hFile, IntPtr.Zero, protection, 0, 0, null )
ignore(MemoryMapping.CloseHandle(hFile))
ignore(MemoryMapping.CloseHandle hFile)
if hMap.Equals(MemoryMapping.NULL_HANDLE) then
failwithf "CreateFileMapping(0x%08x)" (Marshal.GetHRForLastWin32Error())
......@@ -289,7 +289,7 @@ type MemoryMapFile(fileName: string, view: MemoryMapView, hMap: MemoryMapping.HA
if hView.Equals(IntPtr.Zero) then
failwithf "MapViewOfFile(0x%08x)" (Marshal.GetHRForLastWin32Error())
let view = MemoryMapView(hView)
let view = MemoryMapView hView
MemoryMapFile(fileName, view, hMap, hView)
......@@ -338,7 +338,7 @@ type ByteView(bytes: byte[]) =
/// A BinaryFile backed by an array of bytes held strongly as managed memory
[<DebuggerDisplay("{FileName}")>]
type ByteFile(fileName: string, bytes: byte[]) =
let view = ByteView(bytes)
let view = ByteView bytes
do stats.byteFileCount <- stats.byteFileCount + 1
member __.FileName = fileName
interface BinaryFile with
......@@ -353,7 +353,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) =
do stats.weakByteFileCount <- stats.weakByteFileCount + 1
/// Used to check that the file hasn't changed
let fileStamp = FileSystem.GetLastWriteTimeShim(fileName)
let fileStamp = FileSystem.GetLastWriteTimeShim fileName
/// The weak handle to the bytes for the file
let weakBytes = new WeakReference<byte[]> (null)
......@@ -367,7 +367,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) =
let strongBytes =
let mutable tg = null
if not (weakBytes.TryGetTarget(&tg)) then
if FileSystem.GetLastWriteTimeShim(fileName) <> fileStamp then
if FileSystem.GetLastWriteTimeShim fileName <> fileStamp then
error (Error (FSComp.SR.ilreadFileChanged fileName, range0))
let bytes =
......@@ -381,7 +381,7 @@ type WeakByteFile(fileName: string, chunk: (int * int) option) =
tg
(ByteView(strongBytes) :> BinaryView)
(ByteView strongBytes :> BinaryView)
let seekReadByte (mdv: BinaryView) addr = mdv.ReadByte addr
......@@ -671,8 +671,8 @@ let instrs () =
i_ldc_i4_s, I_i32_i8_instr (noPrefixes mkLdcInt32)
i_ldc_r4, I_r4_instr (noPrefixes (fun x -> (AI_ldc (DT_R4, ILConst.R4 x))))
i_ldc_r8, I_r8_instr (noPrefixes (fun x -> (AI_ldc (DT_R8, ILConst.R8 x))))
i_ldfld, I_field_instr (volatileOrUnalignedPrefix(fun (x, y) fspec -> I_ldfld(x, y, fspec)))
i_stfld, I_field_instr (volatileOrUnalignedPrefix(fun (x, y) fspec -> I_stfld(x, y, fspec)))
i_ldfld, I_field_instr (volatileOrUnalignedPrefix(fun (x, y) fspec -> I_ldfld (x, y, fspec)))
i_stfld, I_field_instr (volatileOrUnalignedPrefix(fun (x, y) fspec -> I_stfld (x, y, fspec)))
i_ldsfld, I_field_instr (volatilePrefix (fun x fspec -> I_ldsfld (x, fspec)))
i_stsfld, I_field_instr (volatilePrefix (fun x fspec -> I_stsfld (x, fspec)))
i_ldflda, I_field_instr (noPrefixes I_ldflda)
......@@ -925,7 +925,7 @@ let mkCacheGeneric lowMem _inbase _nm _sz =
| null -> cache := new Dictionary<_, _>(11 (* sz: int *) )
| _ -> ()
!cache
match cache.TryGetValue(idx) with
match cache.TryGetValue idx with
| true, v ->
incr count
v
......@@ -1708,7 +1708,7 @@ and seekReadAssemblyRefUncached ctxtH idx =
locale = readStringHeapOption ctxt localeIdx)
and seekReadModuleRef (ctxt: ILMetadataReader) mdv idx =
let (nameIdx) = seekReadModuleRefRow ctxt mdv idx
let nameIdx = seekReadModuleRefRow ctxt mdv idx
ILModuleRef.Create(name = readStringHeap ctxt nameIdx, hasMetadata=true, hash=None)
and seekReadFile (ctxt: ILMetadataReader) mdv idx =
......@@ -2137,7 +2137,7 @@ and sigptrGetArgTys (ctxt: ILMetadataReader) n numtypars bytes sigptr acc =
let b0, sigptr2 = sigptrGetByte bytes sigptr
if b0 = et_SENTINEL then
let varargs, sigptr = sigptrGetVarArgTys ctxt n numtypars bytes sigptr2
(List.rev acc, Some(varargs)), sigptr
(List.rev acc, Some varargs), sigptr
else
let x, sigptr = sigptrGetTy ctxt numtypars bytes sigptr
sigptrGetArgTys ctxt (n-1) numtypars bytes sigptr (x::acc)
......@@ -2602,7 +2602,7 @@ and seekReadConstant (ctxt: ILMetadataReader) idx =
| x when x = uint16 et_STRING ->
let blobHeap = readBlobHeap ctxt vidx
let s = System.Text.Encoding.Unicode.GetString(blobHeap, 0, blobHeap.Length)
ILFieldInit.String (s)
ILFieldInit.String s
| x when x = uint16 et_BOOLEAN -> ILFieldInit.Bool (readBlobHeapAsBool ctxt vidx)
| x when x = uint16 et_CHAR -> ILFieldInit.Char (readBlobHeapAsUInt16 ctxt vidx)
| x when x = uint16 et_I1 -> ILFieldInit.Int8 (readBlobHeapAsSByte ctxt vidx)
......@@ -2676,7 +2676,7 @@ and seekReadTopCode (ctxt: ILMetadataReader) pev mdv numtypars (sz: int) start s
let labelsOfRawOffsets = new Dictionary<_, _>(sz/2)
let ilOffsetsOfLabels = new Dictionary<_, _>(sz/2)
let tryRawToLabel rawOffset =
match labelsOfRawOffsets.TryGetValue(rawOffset) with
match labelsOfRawOffsets.TryGetValue rawOffset with
| true, v -> Some v
| _ -> None
......@@ -2843,7 +2843,7 @@ and seekReadTopCode (ctxt: ILMetadataReader) pev mdv numtypars (sz: int) start s
let (tab, idx) = seekReadUncodedToken pev (start + (!curr))
curr := !curr + 4
if tab <> TableNames.UserStrings then dprintn "warning: bad table in user string for ldstr"
f prefixes (readUserStringHeap ctxt (idx))
f prefixes (readUserStringHeap ctxt idx)
| I_conditional_i32_instr f ->
let offsDest = (seekReadInt32 pev (start + (!curr)))
......@@ -3114,7 +3114,7 @@ and seekReadMethodRVA (pectxt: PEReader) (ctxt: ILMetadataReader) (idx, nm, _int
end
let key = (tryStart, tryFinish)
match sehMap.TryGetValue(key) with
match sehMap.TryGetValue key with
| true, prev -> sehMap.[key] <- prev @ [clause]
| _ -> sehMap.[key] <- [clause])
clauses
......@@ -3163,24 +3163,24 @@ and sigptrGetILNativeType ctxt bytes sigptr =
List.assoc ntbyte (Lazy.force ILNativeTypeMap), sigptr
elif ntbyte = 0x0uy then ILNativeType.Empty, sigptr
elif ntbyte = nt_CUSTOMMARSHALER then
// reading native type blob (CM1), sigptr= "+string sigptr+ ", bytes.Length = "+string bytes.Length)
// reading native type blob CM1, sigptr= "+string sigptr+ ", bytes.Length = "+string bytes.Length)
let guidLen, sigptr = sigptrGetZInt32 bytes sigptr
// reading native type blob (CM2), sigptr= "+string sigptr+", guidLen = "+string ( guidLen))
// reading native type blob CM2, sigptr= "+string sigptr+", guidLen = "+string ( guidLen))
let guid, sigptr = sigptrGetBytes ( guidLen) bytes sigptr
// reading native type blob (CM3), sigptr= "+string sigptr)
// reading native type blob CM3, sigptr= "+string sigptr)
let nativeTypeNameLen, sigptr = sigptrGetZInt32 bytes sigptr
// reading native type blob (CM4), sigptr= "+string sigptr+", nativeTypeNameLen = "+string ( nativeTypeNameLen))
// reading native type blob CM4, sigptr= "+string sigptr+", nativeTypeNameLen = "+string ( nativeTypeNameLen))
let nativeTypeName, sigptr = sigptrGetString ( nativeTypeNameLen) bytes sigptr
// reading native type blob (CM4), sigptr= "+string sigptr+", nativeTypeName = "+nativeTypeName)
// reading native type blob (CM5), sigptr= "+string sigptr)
// reading native type blob CM4, sigptr= "+string sigptr+", nativeTypeName = "+nativeTypeName)
// reading native type blob CM5, sigptr= "+string sigptr)
let custMarshallerNameLen, sigptr = sigptrGetZInt32 bytes sigptr
// reading native type blob (CM6), sigptr= "+string sigptr+", custMarshallerNameLen = "+string ( custMarshallerNameLen))
// reading native type blob CM6, sigptr= "+string sigptr+", custMarshallerNameLen = "+string ( custMarshallerNameLen))
let custMarshallerName, sigptr = sigptrGetString ( custMarshallerNameLen) bytes sigptr
// reading native type blob (CM7), sigptr= "+string sigptr+", custMarshallerName = "+custMarshallerName)
// reading native type blob CM7, sigptr= "+string sigptr+", custMarshallerName = "+custMarshallerName)
let cookieStringLen, sigptr = sigptrGetZInt32 bytes sigptr
// reading native type blob (CM8), sigptr= "+string sigptr+", cookieStringLen = "+string ( cookieStringLen))
// reading native type blob CM8, sigptr= "+string sigptr+", cookieStringLen = "+string ( cookieStringLen))
let cookieString, sigptr = sigptrGetBytes ( cookieStringLen) bytes sigptr
// reading native type blob (CM9), sigptr= "+string sigptr)
// reading native type blob CM9, sigptr= "+string sigptr)
ILNativeType.Custom (guid, nativeTypeName, custMarshallerName, cookieString), sigptr
elif ntbyte = nt_FIXEDSYSSTRING then
let i, sigptr = sigptrGetZInt32 bytes sigptr
......@@ -3220,7 +3220,7 @@ and sigptrGetILNativeType ctxt bytes sigptr =
let additive, sigptr =
if sigptr >= bytes.Length then 0, sigptr
else sigptrGetZInt32 bytes sigptr
ILNativeType.Array (Some nt, Some(pnum, Some(additive))), sigptr
ILNativeType.Array (Some nt, Some(pnum, Some additive)), sigptr
else (ILNativeType.Empty, sigptr)
// Note, pectxtEager and pevEager must not be captured by the results of this function
......@@ -3320,7 +3320,7 @@ let getPdbReader pdbDirPath fileName =
file = url))
let docfun url =
match tab.TryGetValue(url) with
match tab.TryGetValue url with
| true, doc -> doc
| _ -> failwith ("Document with URL " + url + " not found in list of documents in the PDB file")
Some (pdbr, docfun)
......@@ -3735,7 +3735,7 @@ let openPEFileReader (fileName, pefile: BinaryFile, pdbDirPath, noFileOnDisk) =
optHeaderSize <> 0xf0 then failwith "not a PE file - bad optional header size"
let x64adjust = optHeaderSize - 0xe0
let only64 = (optHeaderSize = 0xf0) (* May want to read in the optional header Magic number and check that as well... *)
let platform = match machine with | 0x8664 -> Some(AMD64) | 0x200 -> Some(IA64) | _ -> Some(X86)
let platform = match machine with | 0x8664 -> Some AMD64 | 0x200 -> Some IA64 | _ -> Some X86
let sectionHeadersStartPhysLoc = peOptionalHeaderPhysLoc + optHeaderSize
let flags = seekReadUInt16AsInt32 pev (peFileHeaderPhysLoc + 18)
......@@ -4007,8 +4007,8 @@ let OpenILModuleReader fileName opts =
// Pseudo-normalize the paths.
let (ILModuleReaderCacheKey (fullPath,writeStamp,_,_,_,_) as key), keyOk =
try
let fullPath = FileSystem.GetFullPathShim(fileName)
let writeTime = FileSystem.GetLastWriteTimeShim(fileName)
let fullPath = FileSystem.GetFullPathShim fileName
let writeTime = FileSystem.GetLastWriteTimeShim fileName
let key = ILModuleReaderCacheKey (fullPath, writeTime, opts.ilGlobals.primaryAssemblyScopeRef, opts.pdbDirPath.IsSome, opts.reduceMemoryUsage, opts.metadataOnly)
key, true
with exn ->
......
此差异已折叠。
......@@ -11,43 +11,43 @@ open System.Reflection.PortableExecutable
open System.Security.Cryptography
open System.Runtime.InteropServices
type KeyType =
type KeyType =
| Public
| KeyPair
let ALG_TYPE_RSA = int (2 <<< 9)
let ALG_CLASS_KEY_EXCHANGE = int (5 <<< 13)
let ALG_CLASS_SIGNATURE = int(1 <<< 13)
let CALG_RSA_KEYX = int(ALG_CLASS_KEY_EXCHANGE ||| ALG_TYPE_RSA)
let CALG_RSA_SIGN = int(ALG_CLASS_SIGNATURE ||| ALG_TYPE_RSA)
let ALG_CLASS_HASH = int(4 <<< 13)
let ALG_TYPE_ANY = int(0)
let CALG_SHA1 = int(ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 4)
let CALG_SHA_256 = int(ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 12)
let CALG_SHA_384 = int(ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 13)
let CALG_SHA_512 = int(ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 14)
let PUBLICKEYBLOB = int(0x6)
let PRIVATEKEYBLOB = int(0x7)
let BLOBHEADER_CURRENT_BVERSION = int(0x2)
let BLOBHEADER_LENGTH = int(20)
let RSA_PUB_MAGIC = int(0x31415352)
let RSA_PRIV_MAGIC = int(0x32415352)
let ALG_CLASS_SIGNATURE = int (1 <<< 13)
let CALG_RSA_KEYX = int (ALG_CLASS_KEY_EXCHANGE ||| ALG_TYPE_RSA)
let CALG_RSA_SIGN = int (ALG_CLASS_SIGNATURE ||| ALG_TYPE_RSA)
let ALG_CLASS_HASH = int (4 <<< 13)
let ALG_TYPE_ANY = int 0
let CALG_SHA1 = int (ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 4)
let CALG_SHA_256 = int (ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 12)
let CALG_SHA_384 = int (ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 13)
let CALG_SHA_512 = int (ALG_CLASS_HASH ||| ALG_TYPE_ANY ||| 14)
let PUBLICKEYBLOB = int 0x6
let PRIVATEKEYBLOB = int 0x7
let BLOBHEADER_CURRENT_BVERSION = int 0x2
let BLOBHEADER_LENGTH = int 20
let RSA_PUB_MAGIC = int 0x31415352
let RSA_PRIV_MAGIC = int 0x32415352
let getResourceString (_, str) = str
[<StructLayout(LayoutKind.Explicit)>]
type ByteArrayUnion =
struct
[<FieldOffset(0)>]
val UnderlyingArray: byte[]
[<Struct; StructLayout(LayoutKind.Explicit)>]
type ByteArrayUnion =
[<FieldOffset(0)>]
val UnderlyingArray: byte[]
[<FieldOffset(0)>]val ImmutableArray: ImmutableArray<byte>
new (immutableArray:ImmutableArray<byte>) = { UnderlyingArray = Array.empty<byte>; ImmutableArray = immutableArray}
end
[<FieldOffset(0)>]
val ImmutableArray: ImmutableArray<byte>
let getUnderlyingArray (array:ImmutableArray<byte>) =ByteArrayUnion(array).UnderlyingArray
new (immutableArray: ImmutableArray<byte>) = { UnderlyingArray = Array.empty<byte>; ImmutableArray = immutableArray}
let getUnderlyingArray (array: ImmutableArray<byte>) =ByteArrayUnion(array).UnderlyingArray
// Compute a hash over the elements of an assembly manifest file that should
// remain static (skip checksum, Authenticode signatures and strong name signature blob)
......@@ -64,8 +64,8 @@ open System.Runtime.InteropServices
| PEMagic.PE32Plus -> peHeaderOffset + 0x90,0xF0 // offsetof(IMAGE_OPTIONAL_HEADER64, DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]), sizeof(IMAGE_OPTIONAL_HEADER64)
| _ -> raise (BadImageFormatException(getResourceString(FSComp.SR.ilSignInvalidMagicValue())))
let allHeadersSize = peHeaderOffset + peHeaderSize + int(peHeaders.CoffHeader.NumberOfSections) * 0x28; // sizeof(IMAGE_SECTION_HEADER)
let allHeaders =
let allHeadersSize = peHeaderOffset + peHeaderSize + int (peHeaders.CoffHeader.NumberOfSections) * 0x28; // sizeof(IMAGE_SECTION_HEADER)
let allHeaders =
let array:byte[] = Array.zeroCreate<byte> allHeadersSize
peReader.GetEntireImage().GetContent().CopyTo(0, array, 0, allHeadersSize)
array
......@@ -78,7 +78,7 @@ open System.Runtime.InteropServices
// Hash content of all sections
let signatureDirectory = peHeaders.CorHeader.StrongNameSignatureDirectory
let signatureStart =
match peHeaders.TryGetDirectoryOffset(signatureDirectory) with
match peHeaders.TryGetDirectoryOffset signatureDirectory with
| true, value -> value
| _ -> raise (BadImageFormatException(getResourceString(FSComp.SR.ilSignBadImageFormat())))
let signatureEnd = signatureStart + signatureDirectory.Size
......@@ -104,7 +104,7 @@ open System.Runtime.InteropServices
()
hashAlgorithm.GetHashAndReset()
type BlobReader =
type BlobReader =
val mutable _blob:byte[]
val mutable _offset:int
new (blob:byte[]) = { _blob = blob; _offset = 0; }
......@@ -112,7 +112,7 @@ open System.Runtime.InteropServices
member x.ReadInt32:int =
let offset = x._offset
x._offset <- offset + 4
int(x._blob.[offset]) ||| (int (x._blob.[offset + 1]) <<< 8) ||| (int (x._blob.[offset + 2]) <<< 16) ||| (int (x._blob.[offset + 3]) <<< 24)
int (x._blob.[offset]) ||| (int (x._blob.[offset + 1]) <<< 8) ||| (int (x._blob.[offset + 2]) <<< 16) ||| (int (x._blob.[offset + 3]) <<< 24)
member x.ReadBigInteger (length:int):byte[] =
let arr:byte[] = Array.zeroCreate<byte> length
......@@ -121,35 +121,35 @@ open System.Runtime.InteropServices
arr |> Array.rev
let RSAParamatersFromBlob (blob:byte[]) keyType =
let mutable reader = BlobReader(blob)
let mutable reader = BlobReader blob
if reader.ReadInt32 <> 0x00000207 && keyType = KeyType.KeyPair then raise (CryptographicException(getResourceString(FSComp.SR.ilSignPrivateKeyExpected())))
reader.ReadInt32 |>ignore // ALG_ID
if reader.ReadInt32 <> RSA_PRIV_MAGIC then raise (CryptographicException(getResourceString(FSComp.SR.ilSignRsaKeyExpected()))) // 'RSA2'
let byteLen, halfLen =
let byteLen, halfLen =
let bitLen = reader.ReadInt32
match bitLen % 16 with
| 0 -> (bitLen / 8, bitLen / 16)
| _ -> raise (CryptographicException(getResourceString(FSComp.SR.ilSignInvalidBitLen())))
let mutable key = RSAParameters()
key.Exponent <- reader.ReadBigInteger(4)
key.Modulus <- reader.ReadBigInteger(byteLen)
key.P <- reader.ReadBigInteger(halfLen)
key.Q <- reader.ReadBigInteger(halfLen)
key.DP <- reader.ReadBigInteger(halfLen)
key.DQ <- reader.ReadBigInteger(halfLen)
key.InverseQ <- reader.ReadBigInteger(halfLen)
key.D <- reader.ReadBigInteger(byteLen)
key.Exponent <- reader.ReadBigInteger 4
key.Modulus <- reader.ReadBigInteger byteLen
key.P <- reader.ReadBigInteger halfLen
key.Q <- reader.ReadBigInteger halfLen
key.DP <- reader.ReadBigInteger halfLen
key.DQ <- reader.ReadBigInteger halfLen
key.InverseQ <- reader.ReadBigInteger halfLen
key.D <- reader.ReadBigInteger byteLen
key
let toCLRKeyBlob (rsaParameters:RSAParameters) (algId:int) : byte[] =
let toCLRKeyBlob (rsaParameters:RSAParameters) (algId:int) : byte[] =
let validateRSAField (field:byte[]) expected (name:string) =
if field <> null && field.Length <> expected then
if field <> null && field.Length <> expected then
raise (CryptographicException(String.Format(getResourceString(FSComp.SR.ilSignInvalidRSAParams()), name)))
// The original FCall this helper emulates supports other algId's - however, the only algid we need to support is CALG_RSA_KEYX. We will not port the codepaths dealing with other algid's.
// The original FCall this helper emulates supports other algId's - however, the only algid we need to support is CALG_RSA_KEYX. We will not port the codepaths dealing with other algid's.
if algId <> CALG_RSA_KEYX then raise (CryptographicException(getResourceString(FSComp.SR.ilSignInvalidAlgId())))
// Validate the RSA structure first.
// Validate the RSA structure first.
if rsaParameters.Modulus = null then raise (CryptographicException(String.Format(getResourceString(FSComp.SR.ilSignInvalidRSAParams()), "Modulus")))
if rsaParameters.Exponent = null || rsaParameters.Exponent.Length > 4 then raise (CryptographicException(String.Format(getResourceString(FSComp.SR.ilSignInvalidRSAParams()), "Exponent")))
......@@ -159,11 +159,11 @@ open System.Runtime.InteropServices
// We assume that if P != null, then so are Q, DP, DQ, InverseQ and D and indicate KeyPair RSA Parameters
let isPrivate =
if rsaParameters.P <> null then
validateRSAField (rsaParameters.P) halfModulusLength "P"
validateRSAField (rsaParameters.Q) halfModulusLength "Q"
validateRSAField (rsaParameters.DP) halfModulusLength "DP"
validateRSAField (rsaParameters.InverseQ) halfModulusLength "InverseQ"
validateRSAField (rsaParameters.D) halfModulusLength "D"
validateRSAField rsaParameters.P halfModulusLength "P"
validateRSAField rsaParameters.Q halfModulusLength "Q"
validateRSAField rsaParameters.DP halfModulusLength "DP"
validateRSAField rsaParameters.InverseQ halfModulusLength "InverseQ"
validateRSAField rsaParameters.D halfModulusLength "D"
true
else false
......@@ -171,33 +171,33 @@ open System.Runtime.InteropServices
use ms = new MemoryStream()
use bw = new BinaryWriter(ms)
bw.Write(int(CALG_RSA_SIGN)) // CLRHeader.aiKeyAlg
bw.Write(int(CALG_SHA1)) // CLRHeader.aiHashAlg
bw.Write(int(modulusLength + BLOBHEADER_LENGTH)) // CLRHeader.KeyLength
bw.Write(int CALG_RSA_SIGN) // CLRHeader.aiKeyAlg
bw.Write(int CALG_SHA1) // CLRHeader.aiHashAlg
bw.Write(int (modulusLength + BLOBHEADER_LENGTH)) // CLRHeader.KeyLength
// Write out the BLOBHEADER
bw.Write(byte(if isPrivate = true then PRIVATEKEYBLOB else PUBLICKEYBLOB)) // BLOBHEADER.bType
bw.Write(byte(BLOBHEADER_CURRENT_BVERSION)) // BLOBHEADER.bVersion
bw.Write(int16(0)) // BLOBHEADER.wReserved
bw.Write(int(CALG_RSA_SIGN)) // BLOBHEADER.aiKeyAlg
// Write out the BLOBHEADER
bw.Write(byte (if isPrivate = true then PRIVATEKEYBLOB else PUBLICKEYBLOB)) // BLOBHEADER.bType
bw.Write(byte BLOBHEADER_CURRENT_BVERSION) // BLOBHEADER.bVersion
bw.Write(int16 0) // BLOBHEADER.wReserved
bw.Write(int CALG_RSA_SIGN) // BLOBHEADER.aiKeyAlg
// Write the RSAPubKey header
bw.Write(int(if isPrivate then RSA_PRIV_MAGIC else RSA_PUB_MAGIC)) // RSAPubKey.magic
bw.Write(int(modulusLength * 8)) // RSAPubKey.bitLen
// Write the RSAPubKey header
bw.Write(int (if isPrivate then RSA_PRIV_MAGIC else RSA_PUB_MAGIC)) // RSAPubKey.magic
bw.Write(int (modulusLength * 8)) // RSAPubKey.bitLen
let expAsDword =
let mutable buffer = int(0)
let mutable buffer = int 0
for i in 0 .. rsaParameters.Exponent.Length - 1 do
buffer <- (buffer <<< 8) ||| int(rsaParameters.Exponent.[i])
buffer <- (buffer <<< 8) ||| int (rsaParameters.Exponent.[i])
buffer
bw.Write(expAsDword) // RSAPubKey.pubExp
bw.Write(rsaParameters.Modulus |> Array.rev) // Copy over the modulus for both public and private
bw.Write expAsDword // RSAPubKey.pubExp
bw.Write(rsaParameters.Modulus |> Array.rev) // Copy over the modulus for both public and private
if isPrivate = true then do
bw.Write(rsaParameters.P |> Array.rev)
bw.Write(rsaParameters.Q |> Array.rev)
bw.Write(rsaParameters.DP |> Array.rev)
bw.Write(rsaParameters.DQ |> Array.rev)
bw.Write(rsaParameters.Q |> Array.rev)
bw.Write(rsaParameters.DP |> Array.rev)
bw.Write(rsaParameters.DQ |> Array.rev)
bw.Write(rsaParameters.InverseQ |> Array.rev)
bw.Write(rsaParameters.D |> Array.rev)
......@@ -216,15 +216,15 @@ open System.Runtime.InteropServices
let signatureDirectory = peHeaders.CorHeader.StrongNameSignatureDirectory
let signatureOffset =
if signatureDirectory.Size > signature.Length then raise (BadImageFormatException(getResourceString(FSComp.SR.ilSignInvalidSignatureSize())))
match peHeaders.TryGetDirectoryOffset(signatureDirectory) with
| false, _ -> raise (BadImageFormatException(getResourceString(FSComp.SR.ilSignNoSignatureDirectory())))
| true, signatureOffset -> int64(signatureOffset)
match peHeaders.TryGetDirectoryOffset signatureDirectory with
| false, _ -> raise (BadImageFormatException(getResourceString(FSComp.SR.ilSignNoSignatureDirectory())))
| true, signatureOffset -> int64 signatureOffset
stream.Seek(signatureOffset, SeekOrigin.Begin) |>ignore
stream.Write(signature, 0, signature.Length)
let corHeaderFlagsOffset = int64(peHeaders.CorHeaderStartOffset + 16) // offsetof(IMAGE_COR20_HEADER, Flags)
stream.Seek(corHeaderFlagsOffset, SeekOrigin.Begin) |>ignore
stream.WriteByte((byte)(peHeaders.CorHeader.Flags ||| CorFlags.StrongNameSigned))
stream.WriteByte (byte (peHeaders.CorHeader.Flags ||| CorFlags.StrongNameSigned))
()
let signStream stream keyBlob =
......@@ -241,11 +241,11 @@ open System.Runtime.InteropServices
let signatureSize (pk:byte[]) =
if pk.Length < 25 then raise (CryptographicException(getResourceString(FSComp.SR.ilSignInvalidPKBlob())))
let mutable reader = BlobReader(pk)
reader.ReadBigInteger(12) |> ignore // Skip CLRHeader
reader.ReadBigInteger(8) |> ignore // Skip BlobHeader
let mutable reader = BlobReader pk
reader.ReadBigInteger 12 |> ignore // Skip CLRHeader
reader.ReadBigInteger 8 |> ignore // Skip BlobHeader
let magic = reader.ReadInt32 // Read magic
if not (magic = RSA_PRIV_MAGIC || magic = RSA_PUB_MAGIC) then // RSAPubKey.magic
if not (magic = RSA_PRIV_MAGIC || magic = RSA_PUB_MAGIC) then // RSAPubKey.magic
raise (CryptographicException(getResourceString(FSComp.SR.ilSignInvalidPKBlob())))
let x = reader.ReadInt32 / 8
x
......@@ -254,5 +254,5 @@ open System.Runtime.InteropServices
let getPublicKeyForKeyPair keyBlob =
use rsa = RSA.Create()
rsa.ImportParameters(RSAParamatersFromBlob keyBlob KeyType.KeyPair)
let rsaParameters = rsa.ExportParameters(false)
let rsaParameters = rsa.ExportParameters false
toCLRKeyBlob rsaParameters CALG_RSA_KEYX
此差异已折叠。
......@@ -49,8 +49,8 @@ let dw2 n = byte ((n >>> 16) &&& 0xFFL)
let dw1 n = byte ((n >>> 8) &&& 0xFFL)
let dw0 n = byte (n &&& 0xFFL)
let bitsOfSingle (x: float32) = System.BitConverter.ToInt32(System.BitConverter.GetBytes(x), 0)
let bitsOfDouble (x: float) = System.BitConverter.DoubleToInt64Bits(x)
let bitsOfSingle (x: float32) = System.BitConverter.ToInt32(System.BitConverter.GetBytes x, 0)
let bitsOfDouble (x: float) = System.BitConverter.DoubleToInt64Bits x
let emitBytesViaBuffer f = let bb = ByteBuffer.Create 10 in f bb; bb.Close()
......@@ -161,18 +161,18 @@ type ILStrongNameSigner =
static member OpenPublicKeyOptions s p = PublicKeyOptionsSigner((Support.signerOpenPublicKeyFile s), p)
static member OpenPublicKey pubkey = PublicKeySigner(pubkey)
static member OpenPublicKey pubkey = PublicKeySigner pubkey
static member OpenKeyPairFile s = KeyPair(Support.signerOpenKeyPairFile s)
static member OpenKeyContainer s = KeyContainer(s)
static member OpenKeyContainer s = KeyContainer s
member s.Close() =
match s with
| PublicKeySigner _
| PublicKeyOptionsSigner _
| KeyPair _ -> ()
| KeyContainer containerName -> Support.signerCloseKeyContainer(containerName)
| KeyContainer containerName -> Support.signerCloseKeyContainer containerName
member s.IsFullySigned =
match s with
......@@ -191,7 +191,7 @@ type ILStrongNameSigner =
member s.SignatureSize =
let pkSignatureSize pk =
try Support.signerSignatureSize(pk)
try Support.signerSignatureSize pk
with e ->
failwith ("A call to StrongNameSignatureSize failed ("+e.Message+")")
0x80
......@@ -452,12 +452,12 @@ type MetadataTable<'T> =
member tbl.AddSharedEntry x =
let n = tbl.rows.Count + 1
tbl.dict.[x] <- n
tbl.rows.Add(x)
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 =
......@@ -545,9 +545,9 @@ type TypeDefTableKey = TdKey of string list (* enclosing *) * string (* type nam
type MetadataTable =
| Shared of MetadataTable<SharedRow>
| Unshared of MetadataTable<UnsharedRow>
member t.FindOrAddSharedEntry(x) = match t with Shared u -> u.FindOrAddSharedEntry(x) | Unshared u -> failwithf "FindOrAddSharedEntry: incorrect table kind, u.name = %s" u.name
member t.AddSharedEntry(x) = match t with | Shared u -> u.AddSharedEntry(x) | Unshared u -> failwithf "AddSharedEntry: incorrect table kind, u.name = %s" u.name
member t.AddUnsharedEntry(x) = match t with Unshared u -> u.AddUnsharedEntry(x) | Shared u -> failwithf "AddUnsharedEntry: incorrect table kind, u.name = %s" u.name
member t.FindOrAddSharedEntry x = match t with Shared u -> u.FindOrAddSharedEntry x | Unshared u -> failwithf "FindOrAddSharedEntry: incorrect table kind, u.name = %s" u.name
member t.AddSharedEntry x = match t with | Shared u -> u.AddSharedEntry x | Unshared u -> failwithf "AddSharedEntry: incorrect table kind, u.name = %s" u.name
member t.AddUnsharedEntry x = match t with Unshared u -> u.AddUnsharedEntry x | Shared u -> failwithf "AddUnsharedEntry: incorrect table kind, u.name = %s" u.name
member t.GenericRowsOfTable = match t with Unshared u -> u.EntriesAsArray |> Array.map (fun x -> x.GenericRow) | Shared u -> u.EntriesAsArray |> Array.map (fun x -> x.GenericRow)
member t.SetRowsOfSharedTable rows = match t with Shared u -> u.SetRowsOfTable (Array.map SharedRow rows) | Unshared u -> failwithf "SetRowsOfSharedTable: incorrect table kind, u.name = %s" u.name
member t.Count = match t with Unshared u -> u.Count | Shared u -> u.Count
......@@ -709,10 +709,10 @@ let rec GetIdxForTypeDef cenv key =
let rec GetAssemblyRefAsRow cenv (aref: ILAssemblyRef) =
AssemblyRefRow
((match aref.Version with None -> 0us | Some (version) -> version.Major),
(match aref.Version with None -> 0us | Some (version) -> version.Minor),
(match aref.Version with None -> 0us | Some (version) -> version.Build),
(match aref.Version with None -> 0us | Some (version) -> version.Revision),
((match aref.Version with None -> 0us | Some version -> version.Major),
(match aref.Version with None -> 0us | Some version -> version.Minor),
(match aref.Version with None -> 0us | Some version -> version.Build),
(match aref.Version with None -> 0us | Some version -> version.Revision),
((match aref.PublicKey with Some (PublicKey _) -> 0x0001 | _ -> 0x0000)
||| (if aref.Retargetable then 0x0100 else 0x0000)),
BlobIndex (match aref.PublicKey with
......@@ -1727,7 +1727,7 @@ module Codebuf =
// Now apply the adjusted fixups in the new code
newReqdBrFixups |> List.iter (fun (newFixupLoc, endOfInstr, tg, small) ->
match newAvailBrFixups.TryGetValue(tg) with
match newAvailBrFixups.TryGetValue tg with
| true, n ->
let relOffset = n - endOfInstr
if small then
......@@ -2170,17 +2170,17 @@ module Codebuf =
let pc2pos = Array.zeroCreate (instrs.Length+1)
let pc2labs = Dictionary()
for KeyValue (lab, pc) in code.Labels do
match pc2labs.TryGetValue(pc) with
match pc2labs.TryGetValue pc with
| true, labels ->
pc2labs.[pc] <- lab :: labels
| _ -> pc2labs.[pc] <- [lab]
// Emit the instructions
for pc = 0 to instrs.Length do
match pc2labs.TryGetValue(pc) with
match pc2labs.TryGetValue pc with
| true, labels ->
for lab in labels do
codebuf.RecordAvailBrFixup(lab)
codebuf.RecordAvailBrFixup lab
| _ -> ()
pc2pos.[pc] <- codebuf.code.Position
if pc < instrs.Length then
......@@ -2822,10 +2822,10 @@ and GenExportedTypesPass3 cenv (ce: ILExportedTypesAndForwarders) =
and GetManifsetAsAssemblyRow cenv m =
UnsharedRow
[|ULong m.AuxModuleHashAlgorithm
UShort (match m.Version with None -> 0us | Some (version) -> version.Major)
UShort (match m.Version with None -> 0us | Some (version) -> version.Minor)
UShort (match m.Version with None -> 0us | Some (version) -> version.Build)
UShort (match m.Version with None -> 0us | Some (version) -> version.Revision)
UShort (match m.Version with None -> 0us | Some version -> version.Major)
UShort (match m.Version with None -> 0us | Some version -> version.Minor)
UShort (match m.Version with None -> 0us | Some version -> version.Build)
UShort (match m.Version with None -> 0us | Some version -> version.Revision)
ULong
( (match m.AssemblyLongevity with
| ILAssemblyLongevity.Unspecified -> 0x0000
......@@ -3563,9 +3563,9 @@ let writeBinaryAndReportMappings (outfile,
let os =
try
// Ensure the output directory exists otherwise it will fail
let dir = Path.GetDirectoryName(outfile)
if not (Directory.Exists(dir)) then Directory.CreateDirectory(dir) |>ignore
new BinaryWriter(FileSystem.FileStreamCreateShim(outfile))
let dir = Path.GetDirectoryName outfile
if not (Directory.Exists dir) then Directory.CreateDirectory dir |>ignore
new BinaryWriter(FileSystem.FileStreamCreateShim outfile)
with e ->
failwith ("Could not open file for writing (binary mode): " + outfile)
......@@ -3576,7 +3576,7 @@ let writeBinaryAndReportMappings (outfile,
let alignVirt = modul.VirtualAlignment // FIXED CHOICE
let alignPhys = modul.PhysicalAlignment // FIXED CHOICE
let isItanium = modul.Platform = Some(IA64)
let isItanium = modul.Platform = Some IA64
let numSections = 3 // .text, .sdata, .reloc
......@@ -3631,9 +3631,9 @@ let writeBinaryAndReportMappings (outfile,
match ilg.primaryAssemblyScopeRef with
| ILScopeRef.Local -> failwith "Expected mscorlib to be ILScopeRef.Assembly was ILScopeRef.Local"
| ILScopeRef.Module(_) -> failwith "Expected mscorlib to be ILScopeRef.Assembly was ILScopeRef.Module"
| ILScopeRef.Assembly(aref) ->
| ILScopeRef.Assembly aref ->
match aref.Version with
| Some (version) when version.Major = 2us -> parseILVersion "2.0.50727.0"
| Some version when version.Major = 2us -> parseILVersion "2.0.50727.0"
| Some v -> v
| None -> failwith "Expected msorlib to have a version number"
......@@ -3678,7 +3678,7 @@ let writeBinaryAndReportMappings (outfile,
generatePortablePdb embedAllSource embedSourceList sourceLink showTimes pdbData deterministic
if embeddedPDB then Some (compressPortablePdbStream uncompressedLength contentId stream)
else Some (pdbStream)
else Some pdbStream
| _ -> None
......@@ -3699,7 +3699,7 @@ let writeBinaryAndReportMappings (outfile,
chunk (align 0x4 (match pdbfile with
| None -> 0
| Some f -> (24
+ System.Text.Encoding.Unicode.GetByteCount(f) // See bug 748444
+ System.Text.Encoding.Unicode.GetByteCount f // See bug 748444
+ debugDataJustInCase))) next
let debugEmbeddedPdbChunk, next =
......@@ -3745,7 +3745,7 @@ let writeBinaryAndReportMappings (outfile,
unlinkResource linkedResourceBase linkedResource)
begin
try linkNativeResources unlinkedResources next resourceFormat (Path.GetDirectoryName(outfile))
try linkNativeResources unlinkedResources next resourceFormat (Path.GetDirectoryName outfile)
with e -> failwith ("Linking a native resource failed: "+e.Message+"")
end
#endif
......@@ -3824,7 +3824,7 @@ let writeBinaryAndReportMappings (outfile,
write (Some peFileHeaderChunk.addr) os "pe file header" [| |]
if (modul.Platform = Some(AMD64)) then
if (modul.Platform = Some AMD64) then
writeInt32AsUInt16 os 0x8664 // Machine - IMAGE_FILE_MACHINE_AMD64
elif isItanium then
writeInt32AsUInt16 os 0x200
......@@ -4225,7 +4225,7 @@ let writeBinaryAndReportMappings (outfile,
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 = FileSystem.FileStreamWriteExistingShim(outfile)
let fs2 = FileSystem.FileStreamWriteExistingShim outfile
let os2 = new BinaryWriter(fs2)
try
// write the IMAGE_DEBUG_DIRECTORY
......
此差异已折叠。
......@@ -52,7 +52,7 @@ let rec private evalILAttribElem e =
let rec private evalFSharpAttribArg g e =
match e with
| Expr.Const(c, _, _) ->
| Expr.Const (c, _, _) ->
match c with
| Const.Bool b -> box b
| Const.SByte i -> box i
......
此差异已折叠。
此差异已折叠。
......@@ -1480,8 +1480,8 @@ and MemberConstraintSolutionOfMethInfo css m minfo minst =
// This is important for calls to operators on generated provided types. There is an (unchecked) condition
// that generative providers do not re=order arguments or insert any more information into operator calls.
match callMethInfoOpt, callExpr with
| Some methInfo, Expr.Op(TOp.ILCall(_useCallVirt, _isProtected, _, _isNewObj, NormalValUse, _isProp, _noTailCall, ilMethRef, _actualTypeInst, actualMethInst, _ilReturnTys), [], args, m)
when (args, (objArgVars@allArgVars)) ||> List.lengthsEqAndForall2 (fun a b -> match a with Expr.Val(v, _, _) -> valEq v.Deref b | _ -> false) ->
| Some methInfo, Expr.Op (TOp.ILCall (_useCallVirt, _isProtected, _, _isNewObj, NormalValUse, _isProp, _noTailCall, ilMethRef, _actualTypeInst, actualMethInst, _ilReturnTys), [], args, m)
when (args, (objArgVars@allArgVars)) ||> List.lengthsEqAndForall2 (fun a b -> match a with Expr.Val (v, _, _) -> valEq v.Deref b | _ -> false) ->
let declaringType = Import.ImportProvidedType amap m (methInfo.PApply((fun x -> x.DeclaringType), m))
if isILAppTy g declaringType then
let extOpt = None // EXTENSION METHODS FROM TYPE PROVIDERS: for extension methods coming from the type providers we would have something here.
......@@ -2817,7 +2817,7 @@ let CodegenWitnessThatTypeSupportsTraitConstraint tcVal g amap m (traitInfo: Tra
if minfo.IsStruct && minfo.IsInstance && (match argExprs with [] -> false | h :: _ -> not (isByrefTy g (tyOfExpr g h))) then
let h, t = List.headAndTail argExprs
let wrap, h', _readonly, _writeonly = mkExprAddrOfExpr g true false PossiblyMutates h None m
ResultD (Some (wrap (Expr.Op(TOp.TraitCall(traitInfo), [], (h' :: t), m))))
ResultD (Some (wrap (Expr.Op (TOp.TraitCall (traitInfo), [], (h' :: t), m))))
else
ResultD (Some (MakeMethInfoCall amap m minfo methArgTys argExprs ))
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -201,7 +201,7 @@ let IterativelySubstituteTyparSolutions g tps solutions =
let ChooseTyparSolutionsForFreeChoiceTypars g amap e =
match e with
| Expr.TyChoose(tps, e1, _m) ->
| Expr.TyChoose (tps, e1, _m) ->
/// Only make choices for variables that are actually used in the expression
let ftvs = (freeInExpr CollectTyparsNoCaching e1).FreeTyvars.FreeTypars
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -127,7 +127,7 @@ module NavigationImpl =
let processBinding isMember enclosingEntityKind isAbstract (Binding(_, _, _, _, _, _, SynValData(memebrOpt, _, _), synPat, _, synExpr, _, _)) =
let m =
match synExpr with
| SynExpr.Typed(e, _, _) -> e.Range // fix range for properties with type annotations
| SynExpr.Typed (e, _, _) -> e.Range // fix range for properties with type annotations
| _ -> synExpr.Range
match synPat, memebrOpt with
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册