提交 190f7030 编写于 作者: D Don Syme

Integrate FCS API: Changes to src\absil

上级 9635bd0d
......@@ -13,8 +13,9 @@ open Microsoft.FSharp.Compiler.AbstractIL
open Microsoft.FSharp.Compiler.AbstractIL.Internal
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
open System.Collections.Generic
open System.Collections
open System.Collections.Generic
open System.Collections.Concurrent
let logging = false
......@@ -75,10 +76,10 @@ let rec splitNamespaceAux (nm:string) =
/// Global State. All namespace splits ever seen
// ++GLOBAL MUTABLE STATE
let memoizeNamespaceTable = new Dictionary<string,string list>(10)
let memoizeNamespaceTable = new ConcurrentDictionary<string,string list>()
// ++GLOBAL MUTABLE STATE
let memoizeNamespaceRightTable = new Dictionary<string,string option * string>(100)
let memoizeNamespaceRightTable = new ConcurrentDictionary<string,string option * string>()
let splitNamespace nm =
......@@ -92,7 +93,7 @@ let splitNamespaceMemoized nm = splitNamespace nm
// ++GLOBAL MUTABLE STATE
let memoizeNamespaceArrayTable =
Dictionary<string,string[]>(10)
Concurrent.ConcurrentDictionary<string,string[]>()
let splitNamespaceToArray nm =
let mutable res = Unchecked.defaultof<_>
......@@ -5082,7 +5083,7 @@ let compareILVersions (a1,a2,a3,a4) ((b1,b2,b3,b4) : ILVersionInfo) =
0
let resolveILMethodRef td (mref:ILMethodRef) =
let resolveILMethodRefWithRescope r td (mref:ILMethodRef) =
let args = mref.ArgTypes
let nargs = args.Length
let nm = mref.Name
......@@ -5092,15 +5093,17 @@ let resolveILMethodRef td (mref:ILMethodRef) =
possibles |> List.filter (fun md ->
mref.CallingConv = md.CallingConv &&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
(md.Parameters,mref.ArgTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> p1.Type = p2) &&
(md.Parameters,mref.ArgTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2) &&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
md.Return.Type = mref.ReturnType) with
r md.Return.Type = mref.ReturnType) with
| [] ->
failwith ("no method named "+nm+" with appropriate argument types found in type "+td.Name);
| [mdef] -> mdef
| _ ->
failwith ("multiple methods named "+nm+" appear with identical argument types in type "+td.Name)
let resolveILMethodRef td mref = resolveILMethodRefWithRescope id td mref
let mkRefToILModule m =
ILModuleRef.Create(m.Name, true, None)
......
......@@ -1622,6 +1622,7 @@ type ILModuleDef =
/// or event. This is useful especially if your code is not using the Ilbind
/// API to bind references.
val resolveILMethodRef: ILTypeDef -> ILMethodRef -> ILMethodDef
val resolveILMethodRefWithRescope: (ILType -> ILType) -> ILTypeDef -> ILMethodRef -> ILMethodDef
// ------------------------------------------------------------------
// Type Names
......
......@@ -151,6 +151,11 @@ module Option =
| None -> dflt
| Some x -> x
let orElse dflt opt =
match opt with
| None -> dflt()
| res -> res
// REVIEW: systematically eliminate foldMap/mapFold duplication
let foldMap f z l =
match l with
......@@ -961,6 +966,7 @@ module Shim =
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) =
......@@ -1001,7 +1007,7 @@ module Shim =
member __.FileDelete (fileName:string) = System.IO.File.Delete fileName
type System.Text.Encoding with
static member GetEncodingShim(n:int) =
System.Text.Encoding.GetEncoding(n)
static member GetEncodingShim(n:int) =
System.Text.Encoding.GetEncoding(n)
let mutable FileSystem = DefaultFileSystem() :> IFileSystem
......@@ -1950,13 +1950,14 @@ let buildModuleFragment cenv emEnv (asmB : AssemblyBuilder) (modB : ModuleBuilde
// test hook
//----------------------------------------------------------------------------
let mkDynamicAssemblyAndModule (assemblyName, optimize, debugInfo) =
let mkDynamicAssemblyAndModule (assemblyName, optimize, debugInfo, collectible) =
let filename = assemblyName ^ ".dll"
let currentDom = System.AppDomain.CurrentDomain
let asmDir = "."
let asmName = new AssemblyName()
asmName.Name <- assemblyName;
let asmB = currentDom.DefineDynamicAssemblyAndLog(asmName,AssemblyBuilderAccess.RunAndSave,asmDir)
let asmAccess = if collectible then AssemblyBuilderAccess.RunAndCollect else AssemblyBuilderAccess.RunAndSave
let asmB = currentDom.DefineDynamicAssemblyAndLog(asmName,asmAccess,asmDir)
if not optimize then
let daType = typeof<System.Diagnostics.DebuggableAttribute>;
let daCtor = daType.GetConstructor [| typeof<System.Diagnostics.DebuggableAttribute.DebuggingModes> |]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册