Skip to content

Commit

Permalink
Revert "Misc. code alignment for FCS"
Browse files Browse the repository at this point in the history
This reverts commit 0214e3b.
  • Loading branch information
KevinRansom committed Oct 12, 2015
1 parent f2d1cba commit 4f39331
Show file tree
Hide file tree
Showing 56 changed files with 677 additions and 361 deletions.
1 change: 0 additions & 1 deletion src/absil/il.fsi
Expand Up @@ -118,7 +118,6 @@ type PublicKey =
member IsKeyToken: bool
member Key: byte[]
member KeyToken: byte[]
static member KeyAsToken: byte[] -> PublicKey

type ILVersionInfo = uint16 * uint16 * uint16 * uint16

Expand Down
63 changes: 32 additions & 31 deletions src/absil/illib.fs
Expand Up @@ -620,7 +620,7 @@ module Eventually =

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

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

open System.IO

type IFileSystem =
[<AbstractClass>]
type FileSystem() =
abstract ReadAllBytesShim: fileName:string -> byte[]
default this.ReadAllBytesShim (fileName:string) =
use stream = this.FileStreamReadShim fileName
let len = stream.Length
let buf = Array.zeroCreate<byte> (int len)
stream.Read(buf, 0, (int len)) |> ignore
buf

abstract FileStreamReadShim: fileName:string -> System.IO.Stream
abstract FileStreamCreateShim: fileName:string -> System.IO.Stream
abstract FileStreamWriteExistingShim: fileName:string -> System.IO.Stream
abstract GetFullPathShim: fileName:string -> string
/// Take in a filename with an absolute path, and return the same filename
/// but canonicalized with respect to extra path separators (e.g. C:\\\\foo.txt)
/// and '..' portions
abstract GetFullPathShim: fileName:string -> string
abstract SafeGetFullPath: fileName:string -> string
abstract IsPathRootedShim: path:string -> bool
abstract IsInvalidPathShim: filename:string -> bool

abstract IsInvalidFilename: filename:string -> bool
abstract GetTempPathShim : unit -> string
abstract GetLastWriteTimeShim: fileName:string -> System.DateTime
abstract SafeExists: fileName:string -> bool
abstract FileDelete: fileName:string -> unit
abstract AssemblyLoadFrom: fileName:string -> System.Reflection.Assembly
abstract AssemblyLoad: assemblyName:System.Reflection.AssemblyName -> System.Reflection.Assembly

type DefaultFileSystem() =
interface IFileSystem with
member __.AssemblyLoadFrom(fileName:string) =
#if FX_ATLEAST_40_COMPILER_LOCATION
System.Reflection.Assembly.UnsafeLoadFrom fileName
#else
System.Reflection.Assembly.LoadFrom fileName
#endif
member __.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName

member __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
default this.AssemblyLoadFrom(fileName:string) =
#if FX_ATLEAST_40_COMPILER_LOCATION
System.Reflection.Assembly.UnsafeLoadFrom fileName
#else
System.Reflection.Assembly.LoadFrom fileName
#endif
default this.AssemblyLoad(assemblyName:System.Reflection.AssemblyName) = System.Reflection.Assembly.Load assemblyName


let mutable FileSystem =
{ new FileSystem() with
override __.ReadAllBytesShim (fileName:string) = File.ReadAllBytes fileName
member __.FileStreamReadShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite) :> Stream
member __.FileStreamCreateShim (fileName:string) = new FileStream(fileName,FileMode.Create,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
member __.FileStreamWriteExistingShim (fileName:string) = new FileStream(fileName,FileMode.Open,FileAccess.Write,FileShare.Read ,0x1000,false) :> Stream
member __.GetFullPathShim (fileName:string) = System.IO.Path.GetFullPath fileName
member __.SafeGetFullPath (fileName:string) =
//System.Diagnostics.Debug.Assert(Path.IsPathRooted(fileName), sprintf "SafeGetFullPath: '%s' is not absolute" fileName)
Path.GetFullPath fileName

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

member __.IsInvalidPathShim(path:string) =
let isInvalidPath(p:string) =
String.IsNullOrEmpty(p) || p.IndexOfAny(System.IO.Path.GetInvalidPathChars()) <> -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) || isInvalidPath(filename)
member __.IsInvalidFilename(filename:string) =
String.IsNullOrEmpty(filename) || filename.IndexOfAny(Path.GetInvalidFileNameChars()) <> -1

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

member __.GetLastWriteTimeShim (fileName:string) = File.GetLastWriteTime fileName
member __.SafeExists (fileName:string) = System.IO.File.Exists fileName
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName }

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

let mutable FileSystem = DefaultFileSystem() :> IFileSystem
6 changes: 3 additions & 3 deletions src/absil/ilsupp.fs
Expand Up @@ -676,10 +676,10 @@ let linkNativeResources (unlinkedResources:byte[] list) (ulLinkedResourceBaseRV
// Conversion was successful, so read the object file
objBytes <- FileSystem.ReadAllBytesShim(tempObjFileName) ;
//Array.Copy(objBytes, pbUnlinkedResource, pbUnlinkedResource.Length)
FileSystem.FileDelete(tempObjFileName)
System.IO.File.Delete(tempObjFileName)
finally
// clean up the temp files
List.iter (fun tempResFileName -> FileSystem.FileDelete(tempResFileName)) tempResFiles
List.iter (fun tempResFileName -> System.IO.File.Delete(tempResFileName)) tempResFiles

// Part 2: Read the COFF file held in pbUnlinkedResource, spit it out into pResBuffer and apply the COFF fixups
// pResBuffer will become the .rsrc section of the PE file
Expand Down Expand Up @@ -1090,7 +1090,7 @@ let hashSizeOfMD5 = 16
// In this case, catch the failure, and not set a checksum.
let internal setCheckSum (url:string, writer:ISymUnmanagedDocumentWriter) =
try
use file = FileSystem.FileStreamReadShim(url)
use file = new FileStream(url, FileMode.Open, FileAccess.Read, FileShare.Read)
use md5 = System.Security.Cryptography.MD5.Create()
let checkSum = md5.ComputeHash(file)
if (checkSum.Length = hashSizeOfMD5) then
Expand Down
2 changes: 1 addition & 1 deletion src/absil/ilwrite.fs
Expand Up @@ -4496,7 +4496,7 @@ let writeBinaryAndReportMappings (outfile, ilg, pdbfile: string option, signer:
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 = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read, 0x1000, false)
let os2 = new BinaryWriter(fs2)
try
// write the IMAGE_DEBUG_DIRECTORY
Expand Down
25 changes: 17 additions & 8 deletions src/fsharp/CompileOps.fs
Expand Up @@ -40,6 +40,7 @@ open Microsoft.FSharp.Compiler.MSBuildResolver
open Microsoft.FSharp.Compiler.TypeRelations
open Microsoft.FSharp.Compiler.NameResolution
open Microsoft.FSharp.Compiler.PrettyNaming
open Internal.Utilities.FileSystem
open Internal.Utilities.Collections
open Internal.Utilities.Filename
open Microsoft.FSharp.Compiler.Import
Expand Down Expand Up @@ -1352,7 +1353,7 @@ let SanitizeFileName fileName implicitIncludeDir =
// - if you have a #line directive, e.g.
// # 1000 "Line01.fs"
// then it also asserts. But these are edge cases that can be fixed later, e.g. in bug 4651.
//System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(fileName), sprintf "filename should be absolute: '%s'" fileName)
//System.Diagnostics.Debug.Assert(System.IO.Path.IsPathRooted(fileName), sprintf "filename should be absolute: '%s'" fileName)
try
let fullPath = FileSystem.GetFullPathShim(fileName)
let currentDir = implicitIncludeDir
Expand Down Expand Up @@ -2219,7 +2220,7 @@ type TcConfigBuilder =
tcConfigB.includes <- tcConfigB.includes ++ absolutePath

member tcConfigB.AddLoadedSource(m,path,pathLoadedFrom) =
if FileSystem.IsInvalidPathShim(path) then
if Path.IsInvalidPath(path) then
warning(Error(FSComp.SR.buildInvalidFilename(path),m))
else
let path =
Expand All @@ -2236,7 +2237,7 @@ type TcConfigBuilder =
tcConfigB.embedResources <- tcConfigB.embedResources ++ filename

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

// The type provider should not hold strong references to disposed
// TcImport objects. So the callbacks provided in the type provider config
Expand Down Expand Up @@ -4628,7 +4637,7 @@ module private ScriptPreprocessClosure =
let SourceFileOfFilename(filename,m,inputCodePage:int option) : ClosureDirective list =
try
let filename = FileSystem.GetFullPathShim(filename)
let filename = FileSystem.SafeGetFullPath(filename)
use stream = FileSystem.FileStreamReadShim filename
use reader =
match inputCodePage with
Expand Down Expand Up @@ -4667,7 +4676,7 @@ module private ScriptPreprocessClosure =
match closureDirective with
| ClosedSourceFile _ as csf -> [csf]
| SourceFile(filename,m,source) ->
let filename = FileSystem.GetFullPathShim(filename)
let filename = FileSystem.SafeGetFullPath(filename)
if observedSources.HaveSeen(filename) then []
else
observedSources.SetSeen(filename)
Expand Down Expand Up @@ -4718,7 +4727,7 @@ module private ScriptPreprocessClosure =
for directive in closureDirectives do
match directive with
| ClosedSourceFile(filename,m,input,_,_,noWarns) ->
let filename = FileSystem.GetFullPathShim(filename)
let filename = FileSystem.SafeGetFullPath(filename)
sourceFiles := (filename,m) :: !sourceFiles
globalNoWarns := (!globalNoWarns @ noWarns)
sourceInputs := (filename,input) :: !sourceInputs
Expand Down
1 change: 0 additions & 1 deletion src/fsharp/CompileOps.fsi
Expand Up @@ -578,7 +578,6 @@ val IsOptimizationDataResource : ILResource -> bool

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

#if NO_COMPILER_BACKEND
#else
Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/CompileOptions.fs
Expand Up @@ -744,10 +744,12 @@ let vsSpecificFlags (tcConfigB: TcConfigBuilder) =

let internalFlags (tcConfigB:TcConfigBuilder) =
[
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
CompilerOption("stamps", tagNone, OptionUnit (fun () -> ()), Some(InternalCommandLineOption("--stamps", rangeCmdArgs)), None);
CompilerOption("ranges", tagNone, OptionSet Tastops.DebugPrint.layoutRanges, Some(InternalCommandLineOption("--ranges", rangeCmdArgs)), None);
CompilerOption("terms" , tagNone, OptionUnit (fun () -> tcConfigB.showTerms <- true), Some(InternalCommandLineOption("--terms", rangeCmdArgs)), None);
CompilerOption("termsfile" , tagNone, OptionUnit (fun () -> tcConfigB.writeTermsToFiles <- true), Some(InternalCommandLineOption("--termsfile", rangeCmdArgs)), None);
CompilerOption("use-incremental-build", tagNone, OptionUnit (fun () -> tcConfigB.useIncrementalBuilder <- true), None, None)
#if DEBUG
CompilerOption("debug-parse", tagNone, OptionUnit (fun () -> Internal.Utilities.Text.Parsing.Flags.debug <- true), Some(InternalCommandLineOption("--debug-parse", rangeCmdArgs)), None);
CompilerOption("ilfiles", tagNone, OptionUnit (fun () -> tcConfigB.writeGeneratedILFiles <- true), Some(InternalCommandLineOption("--ilfiles", rangeCmdArgs)), None);
Expand Down
1 change: 0 additions & 1 deletion src/fsharp/CompileOptions.fsi
Expand Up @@ -98,4 +98,3 @@ val DoWithErrorColor : bool -> (unit -> 'a) -> 'a
val ReportTime : TcConfig -> string -> unit
val GetAbbrevFlagSet : TcConfigBuilder -> bool -> Set<string>
val PostProcessCompilerArgs : string Set -> string [] -> string list
val ParseCompilerOptions : (string -> unit) * CompilerOptionBlock list * string list -> unit
4 changes: 2 additions & 2 deletions src/fsharp/ConstraintSolver.fs
Expand Up @@ -1872,7 +1872,7 @@ and CanMemberSigsMatchUpToCheck
let calledArgTy = rfinfo.FieldType
rfinfo.Name, calledArgTy

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

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

match suggestNamesForMissingArguments with
Expand Down
4 changes: 1 addition & 3 deletions src/fsharp/ExtensionTyping.fs
Expand Up @@ -4,8 +4,6 @@

namespace Microsoft.FSharp.Compiler

#if EXTENSIONTYPING

module internal ExtensionTyping =
open System
open System.IO
Expand All @@ -17,6 +15,7 @@ module internal ExtensionTyping =
open Microsoft.FSharp.Compiler.AbstractIL.IL
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics // dprintfn
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack
open Internal.Utilities.FileSystem

type TypeProviderDesignation = TypeProviderDesignation of string

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

#endif
4 changes: 0 additions & 4 deletions src/fsharp/ExtensionTyping.fsi
Expand Up @@ -4,8 +4,6 @@

namespace Microsoft.FSharp.Compiler

#if EXTENSIONTYPING

module internal ExtensionTyping =

open System
Expand Down Expand Up @@ -369,5 +367,3 @@ module internal ExtensionTyping =
/// Check if this is a direct reference to a non-embedded generated type. This is not permitted at any name resolution.
/// We check by seeing if the type is absent from the remapping context.
val IsGeneratedTypeDirectReference : Tainted<ProvidedType> * range -> bool

#endif
6 changes: 6 additions & 0 deletions src/fsharp/FSharp.Compiler-proto/FSharp.Compiler-proto.fsproj
Expand Up @@ -243,6 +243,12 @@
<Compile Include="..\..\ilx\EraseUnions.fs">
<Link>EraseUnions.fs</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fsi">
<Link>InternalFileSystemUtils.fsi</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fs">
<Link>InternalFileSystemUtils.fs</Link>
</Compile>
<Compile Include="..\UnicodeLexing.fsi">
<Link>UnicodeLexing.fsi</Link>
</Compile>
Expand Down
6 changes: 6 additions & 0 deletions src/fsharp/FSharp.Compiler/FSharp.Compiler.fsproj
Expand Up @@ -117,6 +117,12 @@
<Compile Include="..\lib.fs">
<Link>Utilities\lib.fs</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fsi">
<Link>Utilities\InternalFileSystemUtils.fsi</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fs">
<Link>Utilities\InternalFileSystemUtils.fs</Link>
</Compile>
<Compile Include="..\TraceCall.fsi">
<Link>Utilities\TraceCall.fsi</Link>
</Compile>
Expand Down
Expand Up @@ -126,6 +126,12 @@
<Compile Include="..\InternalCollections.fs">
<Link>Utilities\InternalCollections.fs</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fsi">
<Link>Utilities\InternalFileSystemUtils.fsi</Link>
</Compile>
<Compile Include="..\InternalFileSystemUtils.fs">
<Link>Utilities\InternalFileSystemUtils.fs</Link>
</Compile>
<Compile Include="..\rational.fsi">
<Link>Utilities\rational.fsi</Link>
</Compile>
Expand Down

0 comments on commit 4f39331

Please sign in to comment.