Skip to content

Commit bd676c2

Browse files
committed
2 parents 94b1c4c + 48a703f commit bd676c2

File tree

13 files changed

+840
-131
lines changed

13 files changed

+840
-131
lines changed

FSharp.Compiler.Service.sln

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 14
3-
VisualStudioVersion = 14.0.25123.0
3+
VisualStudioVersion = 14.0.25420.1
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}"
66
ProjectSection(SolutionItems) = preProject
@@ -63,6 +63,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.Pro
6363
EndProject
6464
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker", "src\fsharp\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj", "{893C3CD9-5AF8-4027-A667-21E62FC2C703}"
6565
EndProject
66+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "TestTP", "tests\service\data\TestTP\TestTP.fsproj", "{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}"
67+
EndProject
6668
Global
6769
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6870
Debug|Any CPU = Debug|Any CPU
@@ -247,6 +249,24 @@ Global
247249
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
248250
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.Build.0 = Release|Any CPU
249251
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|x86.ActiveCfg = Release|Any CPU
252+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
253+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Any CPU.Build.0 = Debug|Any CPU
254+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
255+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
256+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|x86.ActiveCfg = Debug|Any CPU
257+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Debug|x86.Build.0 = Debug|Any CPU
258+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|Any CPU.ActiveCfg = Release|Any CPU
259+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|Any CPU.Build.0 = Release|Any CPU
260+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
261+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
262+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|x86.ActiveCfg = Release|Any CPU
263+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Proto|x86.Build.0 = Release|Any CPU
264+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Any CPU.ActiveCfg = Release|Any CPU
265+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Any CPU.Build.0 = Release|Any CPU
266+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
267+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
268+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|x86.ActiveCfg = Release|Any CPU
269+
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B}.Release|x86.Build.0 = Release|Any CPU
250270
EndGlobalSection
251271
GlobalSection(SolutionProperties) = preSolution
252272
HideSolutionNode = FALSE

src/absil/il.fs

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4254,20 +4254,74 @@ let compareILVersions (a1,a2,a3,a4) ((b1,b2,b3,b4) : ILVersionInfo) =
42544254
if c <> 0 then c else
42554255
0
42564256

4257+
let qunscope_scoref scoref_old =
4258+
match scoref_old with
4259+
| ILScopeRef.Local -> None
4260+
| _ -> Some ILScopeRef.Local
4261+
4262+
let qunscope_tref (x:ILTypeRef) =
4263+
match qunscope_scoref x.Scope with
4264+
| None -> None
4265+
| Some s -> Some (ILTypeRef.Create(s,x.Enclosing,x.Name))
4266+
4267+
let unscopeILScopeRef y = match qunscope_scoref y with Some x -> x | None -> y
4268+
let unscopeILTypeRef y = match qunscope_tref y with Some x -> x | None -> y
4269+
4270+
let rec unscopeILTypeSpecQuick (tspec:ILTypeSpec) =
4271+
let tref = tspec.TypeRef
4272+
let tinst = tspec.GenericArgs
4273+
let qtref = qunscope_tref tref
4274+
if ILList.isEmpty tinst && isNone qtref then
4275+
None (* avoid reallocation in the common case *)
4276+
else
4277+
match qtref with
4278+
| None -> Some (ILTypeSpec.Create (tref, unscopeILTypes tinst))
4279+
| Some tref -> Some (ILTypeSpec.Create (tref, unscopeILTypes tinst))
4280+
4281+
and unscopeILTypeSpec x y =
4282+
match rescopeILTypeSpecQuick x y with
4283+
| Some x -> x
4284+
| None -> y
4285+
4286+
and unscopeILType typ =
4287+
match typ with
4288+
| ILType.Ptr t -> ILType.Ptr (unscopeILType t)
4289+
| ILType.FunctionPointer t -> ILType.FunctionPointer (unscopeILCallSig t)
4290+
| ILType.Byref t -> ILType.Byref (unscopeILType t)
4291+
| ILType.Boxed cr ->
4292+
match unscopeILTypeSpecQuick cr with
4293+
| Some res -> mkILBoxedType res
4294+
| None -> typ // avoid reallocation in the common case
4295+
| ILType.Array (s,ty) -> ILType.Array (s,unscopeILType ty)
4296+
| ILType.Value cr ->
4297+
match unscopeILTypeSpecQuick cr with
4298+
| Some res -> ILType.Value res
4299+
| None -> typ // avoid reallocation in the common case
4300+
| ILType.Modified(b,tref,ty) -> ILType.Modified(b,unscopeILTypeRef tref, unscopeILType ty)
4301+
| x -> x
4302+
4303+
and unscopeILTypes i =
4304+
if ILList.isEmpty i then i
4305+
else ILList.map unscopeILType i
4306+
4307+
and unscopeILCallSig csig =
4308+
mkILCallSigRaw (csig.CallingConv,unscopeILTypes csig.ArgTypes,unscopeILType csig.ReturnType)
42574309

42584310
let resolveILMethodRefWithRescope r td (mref:ILMethodRef) =
42594311
let args = mref.ArgTypes
42604312
let nargs = args.Length
42614313
let nm = mref.Name
42624314
let possibles = td.Methods.FindByNameAndArity (nm,nargs)
42634315
if isNil possibles then failwith ("no method named "+nm+" found in type "+td.Name);
4316+
let argTypes = mref.ArgTypes |> List.map r
4317+
let retType : ILType = r mref.ReturnType
42644318
match
42654319
possibles |> List.filter (fun md ->
42664320
mref.CallingConv = md.CallingConv &&
42674321
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
4268-
(md.Parameters,mref.ArgTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2) &&
4322+
(md.Parameters,argTypes) ||> ILList.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2) &&
42694323
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
4270-
r md.Return.Type = mref.ReturnType) with
4324+
r md.Return.Type = retType) with
42714325
| [] -> failwith ("no method named "+nm+" with appropriate argument types found in type "+td.Name)
42724326
| [mdef] -> mdef
42734327
| _ -> failwith ("multiple methods named "+nm+" appear with identical argument types in type "+td.Name)

src/absil/il.fsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,9 @@ val rescopeILMethodRef: ILScopeRef -> ILMethodRef -> ILMethodRef
19731973
/// the new scope.
19741974
val rescopeILFieldRef: ILScopeRef -> ILFieldRef -> ILFieldRef
19751975

1976+
/// Unscoping. Clears every scope information, use for looking up IL method references only.
1977+
val unscopeILType: ILType -> ILType
1978+
19761979

19771980
//-----------------------------------------------------------------------
19781981
// The ILCode Builder utility.

0 commit comments

Comments
 (0)