Skip to content

Commit 4f39331

Browse files
committed
Revert "Misc. code alignment for FCS"
This reverts commit 0214e3b.
1 parent f2d1cba commit 4f39331

Some content is hidden

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

56 files changed

+677
-361
lines changed

src/absil/il.fsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ type PublicKey =
118118
member IsKeyToken: bool
119119
member Key: byte[]
120120
member KeyToken: byte[]
121-
static member KeyAsToken: byte[] -> PublicKey
122121

123122
type ILVersionInfo = uint16 * uint16 * uint16 * uint16
124123

src/absil/illib.fs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ module Eventually =
620620

621621
let force e = Option.get (forceWhile (fun () -> true) e)
622622

623-
/// Keep running the computation bit by bit until a time limit is reached.
623+
/// Keep running the computation bit by bit until a time limit is reached.
624624
/// The runner gets called each time the computation is restarted
625625
let repeatedlyProgressUntilDoneOrTimeShareOver timeShareInMilliseconds runner e =
626626
let sw = new System.Diagnostics.Stopwatch()
@@ -942,63 +942,64 @@ type LayeredMultiMap<'Key,'Value when 'Key : equality and 'Key : comparison>(con
942942
module Shim =
943943

944944
open System.IO
945-
946-
type IFileSystem =
945+
[<AbstractClass>]
946+
type FileSystem() =
947947
abstract ReadAllBytesShim: fileName:string -> byte[]
948+
default this.ReadAllBytesShim (fileName:string) =
949+
use stream = this.FileStreamReadShim fileName
950+
let len = stream.Length
951+
let buf = Array.zeroCreate<byte> (int len)
952+
stream.Read(buf, 0, (int len)) |> ignore
953+
buf
954+
948955
abstract FileStreamReadShim: fileName:string -> System.IO.Stream
949956
abstract FileStreamCreateShim: fileName:string -> System.IO.Stream
950-
abstract FileStreamWriteExistingShim: fileName:string -> System.IO.Stream
957+
abstract GetFullPathShim: fileName:string -> string
951958
/// Take in a filename with an absolute path, and return the same filename
952959
/// but canonicalized with respect to extra path separators (e.g. C:\\\\foo.txt)
953960
/// and '..' portions
954-
abstract GetFullPathShim: fileName:string -> string
961+
abstract SafeGetFullPath: fileName:string -> string
955962
abstract IsPathRootedShim: path:string -> bool
956-
abstract IsInvalidPathShim: filename:string -> bool
963+
964+
abstract IsInvalidFilename: filename:string -> bool
957965
abstract GetTempPathShim : unit -> string
958966
abstract GetLastWriteTimeShim: fileName:string -> System.DateTime
959967
abstract SafeExists: fileName:string -> bool
960968
abstract FileDelete: fileName:string -> unit
961969
abstract AssemblyLoadFrom: fileName:string -> System.Reflection.Assembly
962970
abstract AssemblyLoad: assemblyName:System.Reflection.AssemblyName -> System.Reflection.Assembly
963971

964-
type DefaultFileSystem() =
965-
interface IFileSystem with
966-
member __.AssemblyLoadFrom(fileName:string) =
967-
#if FX_ATLEAST_40_COMPILER_LOCATION
968-
System.Reflection.Assembly.UnsafeLoadFrom fileName
969-
#else
970-
System.Reflection.Assembly.LoadFrom fileName
971-
#endif
972-
member __.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName
973-
974-
member __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
972+
default this.AssemblyLoadFrom(fileName:string) =
973+
#if FX_ATLEAST_40_COMPILER_LOCATION
974+
System.Reflection.Assembly.UnsafeLoadFrom fileName
975+
#else
976+
System.Reflection.Assembly.LoadFrom fileName
977+
#endif
978+
default this.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName
979+
980+
981+
let mutable FileSystem =
982+
{ new FileSystem() with
983+
override __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
975984
member __.FileStreamReadShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite) :> Stream
976985
member __.FileStreamCreateShim (fileName:string) = new FileStream(fileName,FileMode.Create,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
977-
member __.FileStreamWriteExistingShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
978986
member __.GetFullPathShim (fileName:string) = System.IO.Path.GetFullPath fileName
987+
member __.SafeGetFullPath (fileName:string) =
988+
//System.Diagnostics.Debug.Assert(Path.IsPathRooted(fileName), sprintf "SafeGetFullPath: '%s' is not absolute" fileName)
989+
Path.GetFullPath fileName
979990

980991
member __.IsPathRootedShim (path:string) = Path.IsPathRooted path
981992

982-
member __.IsInvalidPathShim(path:string) =
983-
let isInvalidPath(p:string) =
984-
String.IsNullOrEmpty(p) || p.IndexOfAny(System.IO.Path.GetInvalidPathChars()) <> -1
985-
986-
let isInvalidDirectory(d:string) =
987-
d=null || d.IndexOfAny(Path.GetInvalidPathChars()) <> -1
988-
989-
isInvalidPath (path) ||
990-
let directory = Path.GetDirectoryName(path)
991-
let filename = Path.GetFileName(path)
992-
isInvalidDirectory(directory) || isInvalidPath(filename)
993+
member __.IsInvalidFilename(filename:string) =
994+
String.IsNullOrEmpty(filename) || filename.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1
993995

994996
member __.GetTempPathShim() = System.IO.Path.GetTempPath()
995997

996998
member __.GetLastWriteTimeShim (fileName:string) = File.GetLastWriteTime fileName
997999
member __.SafeExists (fileName:string) = System.IO.File.Exists fileName
998-
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName
1000+
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName }
9991001

10001002
type System.Text.Encoding with
10011003
static member GetEncodingShim(n:int) =
10021004
System.Text.Encoding.GetEncoding(n)
10031005

1004-
let mutable FileSystem = DefaultFileSystem() :> IFileSystem

src/absil/ilsupp.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,10 @@ let linkNativeResources (unlinkedResources:byte[] list) (ulLinkedResourceBaseRV
676676
// Conversion was successful, so read the object file
677677
objBytes <- FileSystem.ReadAllBytesShim(tempObjFileName) ;
678678
//Array.Copy(objBytes, pbUnlinkedResource, pbUnlinkedResource.Length)
679-
FileSystem.FileDelete(tempObjFileName)
679+
System.IO.File.Delete(tempObjFileName)
680680
finally
681681
// clean up the temp files
682-
List.iter (fun tempResFileName -> FileSystem.FileDelete(tempResFileName)) tempResFiles
682+
List.iter (fun tempResFileName -> System.IO.File.Delete(tempResFileName)) tempResFiles
683683

684684
// Part 2: Read the COFF file held in pbUnlinkedResource, spit it out into pResBuffer and apply the COFF fixups
685685
// pResBuffer will become the .rsrc section of the PE file
@@ -1090,7 +1090,7 @@ let hashSizeOfMD5 = 16
10901090
// In this case, catch the failure, and not set a checksum.
10911091
let internal setCheckSum (url:string, writer:ISymUnmanagedDocumentWriter) =
10921092
try
1093-
use file = FileSystem.FileStreamReadShim(url)
1093+
use file = new FileStream(url, FileMode.Open, FileAccess.Read, FileShare.Read)
10941094
use md5 = System.Security.Cryptography.MD5.Create()
10951095
let checkSum = md5.ComputeHash(file)
10961096
if (checkSum.Length = hashSizeOfMD5) then

src/absil/ilwrite.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4496,7 +4496,7 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
44964496
reportTime showTimes "Generate PDB Info"
44974497

44984498
// Now we have the debug data we can go back and fill in the debug directory in the image
4499-
let fs2 = FileSystem.FileStreamWriteExistingShim(outfile)
4499+
let fs2 = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, 0x1000, false)
45004500
let os2 = new BinaryWriter(fs2)
45014501
try
45024502
// write the IMAGE_DEBUG_DIRECTORY

src/fsharp/CompileOps.fs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ open Microsoft.FSharp.Compiler.MSBuildResolver
4040
open Microsoft.FSharp.Compiler.TypeRelations
4141
open Microsoft.FSharp.Compiler.NameResolution
4242
open Microsoft.FSharp.Compiler.PrettyNaming
43+
open Internal.Utilities.FileSystem
4344
open Internal.Utilities.Collections
4445
open Internal.Utilities.Filename
4546
open Microsoft.FSharp.Compiler.Import
@@ -1352,7 +1353,7 @@ let SanitizeFileName fileName implicitIncludeDir =
13521353
// - if you have a #line directive, e.g.
13531354
// # 1000 "Line01.fs"
13541355
// then it also asserts. But these are edge cases that can be fixed later, e.g. in bug 4651.
1355-
//System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(fileName), sprintf "filename should be absolute: '%s'" fileName)
1356+
//System.Diagnostics.Debug.Assert(System.IO.Path.IsPathRooted(fileName), sprintf "filename should be absolute: '%s'" fileName)
13561357
try
13571358
let fullPath = FileSystem.GetFullPathShim(fileName)
13581359
let currentDir = implicitIncludeDir
@@ -2219,7 +2220,7 @@ type TcConfigBuilder =
22192220
tcConfigB.includes <- tcConfigB.includes ++ absolutePath
22202221

22212222
member tcConfigB.AddLoadedSource(m,path,pathLoadedFrom) =
2222-
if FileSystem.IsInvalidPathShim(path) then
2223+
if Path.IsInvalidPath(path) then
22232224
warning(Error(FSComp.SR.buildInvalidFilename(path),m))
22242225
else
22252226
let path =
@@ -2236,7 +2237,7 @@ type TcConfigBuilder =
22362237
tcConfigB.embedResources <- tcConfigB.embedResources ++ filename
22372238

22382239
member tcConfigB.AddReferencedAssemblyByPath (m,path) =
2239-
if FileSystem.IsInvalidPathShim(path) then
2240+
if Path.IsInvalidPath(path) then
22402241
warning(Error(FSComp.SR.buildInvalidAssemblyName(path),m))
22412242
elif not (List.mem (AssemblyReference(m,path)) tcConfigB.referencedDLLs) then // NOTE: We keep same paths if range is different.
22422243
tcConfigB.referencedDLLs <- tcConfigB.referencedDLLs ++ AssemblyReference(m,path)
@@ -2613,8 +2614,16 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
26132614
| Some x ->
26142615
[tcConfig.MakePathAbsolute x]
26152616
| None ->
2617+
// When running on Mono we lead everyone to believe we're doing .NET 2.0 compilation
2618+
// by default.
26162619
if runningOnMono then
2617-
[System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()]
2620+
let mono10SysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2621+
assert(mono10SysDir.EndsWith("1.0",StringComparison.Ordinal));
2622+
let mono20SysDir = Path.Combine(Path.GetDirectoryName mono10SysDir, "2.0")
2623+
if Directory.Exists(mono20SysDir) then
2624+
[mono20SysDir]
2625+
else
2626+
[mono10SysDir]
26182627
else
26192628
try
26202629
match tcConfig.resolutionEnvironment with
@@ -3829,7 +3838,7 @@ type TcImports(tcConfigP:TcConfigProvider, initialResolutions:TcAssemblyResoluti
38293838
outputFile = tcConfig.outputFile
38303839
showResolutionMessages = tcConfig.showExtensionTypeMessages
38313840
referencedAssemblies = [| for r in resolutions.GetAssemblyResolutions() -> r.resolvedPath |]
3832-
temporaryFolder = FileSystem.GetTempPathShim() }
3841+
temporaryFolder = Path.GetTempPath() }
38333842

38343843
// The type provider should not hold strong references to disposed
38353844
// TcImport objects. So the callbacks provided in the type provider config
@@ -4628,7 +4637,7 @@ module private ScriptPreprocessClosure =
46284637

46294638
let SourceFileOfFilename(filename,m,inputCodePage:int option) : ClosureDirective list =
46304639
try
4631-
let filename = FileSystem.GetFullPathShim(filename)
4640+
let filename = FileSystem.SafeGetFullPath(filename)
46324641
use stream = FileSystem.FileStreamReadShim filename
46334642
use reader =
46344643
match inputCodePage with
@@ -4667,7 +4676,7 @@ module private ScriptPreprocessClosure =
46674676
match closureDirective with
46684677
| ClosedSourceFile _ as csf -> [csf]
46694678
| SourceFile(filename,m,source) ->
4670-
let filename = FileSystem.GetFullPathShim(filename)
4679+
let filename = FileSystem.SafeGetFullPath(filename)
46714680
if observedSources.HaveSeen(filename) then []
46724681
else
46734682
observedSources.SetSeen(filename)
@@ -4718,7 +4727,7 @@ module private ScriptPreprocessClosure =
47184727
for directive in closureDirectives do
47194728
match directive with
47204729
| ClosedSourceFile(filename,m,input,_,_,noWarns) ->
4721-
let filename = FileSystem.GetFullPathShim(filename)
4730+
let filename = FileSystem.SafeGetFullPath(filename)
47224731
sourceFiles := (filename,m) :: !sourceFiles
47234732
globalNoWarns := (!globalNoWarns @ noWarns)
47244733
sourceInputs := (filename,input) :: !sourceInputs

src/fsharp/CompileOps.fsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ val IsOptimizationDataResource : ILResource -> bool
578578

579579
/// Determine if an IL resource attached to an F# assemnly is an F# quotation data resource for reflected definitions
580580
val IsReflectedDefinitionsResource : ILResource -> bool
581-
val GetSignatureDataResourceName : ILResource -> string
582581

583582
#if NO_COMPILER_BACKEND
584583
#else

src/fsharp/CompileOptions.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,10 +744,12 @@ let vsSpecificFlags (tcConfigB: TcConfigBuilder) =
744744

745745
let internalFlags (tcConfigB:TcConfigBuilder) =
746746
[
747+
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
747748
CompilerOption("stamps", tagNone, OptionUnit (fun () -> ()), Some(InternalCommandLineOption("--stamps", rangeCmdArgs)), None);
748749
CompilerOption("ranges", tagNone, OptionSet Tastops.DebugPrint.layoutRanges, Some(InternalCommandLineOption("--ranges", rangeCmdArgs)), None);
749750
CompilerOption("terms" , tagNone, OptionUnit (fun () -> tcConfigB.showTerms <- true), Some(InternalCommandLineOption("--terms", rangeCmdArgs)), None);
750751
CompilerOption("termsfile" , tagNone, OptionUnit (fun () -> tcConfigB.writeTermsToFiles <- true), Some(InternalCommandLineOption("--termsfile", rangeCmdArgs)), None);
752+
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
751753
#if DEBUG
752754
CompilerOption("debug-parse", tagNone, OptionUnit (fun () -> Internal.Utilities.Text.Parsing.Flags.debug <- true), Some(InternalCommandLineOption("--debug-parse", rangeCmdArgs)), None);
753755
CompilerOption("ilfiles", tagNone, OptionUnit (fun () -> tcConfigB.writeGeneratedILFiles <- true), Some(InternalCommandLineOption("--ilfiles", rangeCmdArgs)), None);

src/fsharp/CompileOptions.fsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,3 @@ val DoWithErrorColor : bool -> (unit -> 'a) -> 'a
9898
val ReportTime : TcConfig -> string -> unit
9999
val GetAbbrevFlagSet : TcConfigBuilder -> bool -> Set<string>
100100
val PostProcessCompilerArgs : string Set -> string [] -> string list
101-
val ParseCompilerOptions : (string -> unit) * CompilerOptionBlock list * string list -> unit

src/fsharp/ConstraintSolver.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ and CanMemberSigsMatchUpToCheck
18721872
let calledArgTy = rfinfo.FieldType
18731873
rfinfo.Name, calledArgTy
18741874

1875-
subsumeArg (CalledArg((-1, 0), false, NotOptional, false, Some (mkSynId m name), ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
1875+
subsumeArg (CalledArg((-1, 0), false, NotOptional, false, Some name, ReflectedArgInfo.None, calledArgTy)) caller) )) ++ (fun () ->
18761876

18771877
// - Always take the return type into account for
18781878
// -- op_Explicit, op_Implicit
@@ -2004,7 +2004,7 @@ and ReportNoCandidatesError (csenv:ConstraintSolverEnv) (nUnnamedCallerArgs,nNam
20042004
let missingArgs = List.drop nReqd cmeth.AllUnnamedCalledArgs
20052005
match NamesOfCalledArgs missingArgs with
20062006
| [] -> (false, "")
2007-
| names -> (true, String.concat ";" (List.map textOfId names))
2007+
| names -> (true, String.concat ";" names)
20082008
else (false, "")
20092009

20102010
match suggestNamesForMissingArguments with

src/fsharp/ExtensionTyping.fs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace Microsoft.FSharp.Compiler
66

7-
#if EXTENSIONTYPING
8-
97
module internal ExtensionTyping =
108
open System
119
open System.IO
@@ -17,6 +15,7 @@ module internal ExtensionTyping =
1715
open Microsoft.FSharp.Compiler.AbstractIL.IL
1816
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics // dprintfn
1917
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack
18+
open Internal.Utilities.FileSystem
2019

2120
type TypeProviderDesignation = TypeProviderDesignation of string
2221

@@ -1219,4 +1218,3 @@ module internal ExtensionTyping =
12191218
let IsGeneratedTypeDirectReference (st: Tainted<ProvidedType>, m) =
12201219
st.PUntaint((fun st -> st.TryGetTyconRef() |> isNone), m)
12211220

1222-
#endif

0 commit comments

Comments
 (0)