Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf33e79f

Browse files
dsymeKevinRansom
authored andcommitted
Fix 3022 - Generate correct names for delegate and object expression arguments (#3523)
* Generate correct names for delegate and object expression arguments* update test baselines
1 parent385ee63 commitf33e79f

File tree

8 files changed

+110
-106
lines changed

8 files changed

+110
-106
lines changed

‎src/fsharp/IlxGen.fs‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,18 +3428,20 @@ and GenFormalSlotsig m cenv eenv (TSlotSig(_,typ,ctps,mtps,paraml,returnTy)) =
34283428
leteenvForSlotSig= EnvForTypars(ctps@ mtps) eenv
34293429
letilParams= paraml|> List.map(GenSlotParam m cenv eenvForSlotSig)
34303430
letilRetTy= GenReturnType cenv.amap m eenvForSlotSig.tyenv returnTy
3431-
letilReturn= mkILReturn ilRetTy
3432-
ilTy, ilParams,ilReturn
3431+
letilRet= mkILReturn ilRetTy
3432+
ilTy, ilParams, ilRet
34333433

34343434
andinstSlotParam inst(TSlotParam(nm,ty,inFlag,fl2,fl3,attrs))= TSlotParam(nm,instType inst ty,inFlag,fl2,fl3,attrs)
34353435

3436-
andGenActualSlotsig m cenv eenv(TSlotSig(_,typ,ctps,mtps,paraml,returnTy))methTyparsOfOverridingMethod=
3437-
letparaml= List.concatparaml
3436+
andGenActualSlotsig m cenv eenv(TSlotSig(_,typ,ctps,mtps,ilSlotParams,ilSlotRetTy))methTyparsOfOverridingMethod(methodParams:Val list)=
3437+
letilSlotParams= List.concatilSlotParams
34383438
letinstForSlotSig= mkTyparInst(ctps@mtps)(argsOfAppTy cenv.g typ@ generalizeTypars methTyparsOfOverridingMethod)
3439-
letilParams= paraml|> List.map(instSlotParam instForSlotSig>> GenSlotParam m cenv eenv)
3440-
letilRetTy= GenReturnType cenv.amap m eenv.tyenv(Option.map(instType instForSlotSig) returnTy)
3441-
letilReturn= mkILReturn ilRetTy
3442-
ilParams,ilReturn
3439+
letilParams= ilSlotParams|> List.map(instSlotParam instForSlotSig>> GenSlotParam m cenv eenv)
3440+
// Use the better names if available
3441+
letilParams=if ilParams.Length= methodParams.Lengththen(ilParams, methodParams)||> List.map2(fun p pv->{ pwith Name= Some(nameOfVal pv)})else ilParams
3442+
letilRetTy= GenReturnType cenv.amap m eenv.tyenv(Option.map(instType instForSlotSig) ilSlotRetTy)
3443+
letiLRet= mkILReturn ilRetTy
3444+
ilParams,iLRet
34433445

34443446
andGenNameOfOverridingMethod cenv(useMethodImpl,(TSlotSig(nameOfOverridenMethod,enclTypOfOverridenMethod,_,_,_,_)))=
34453447
if useMethodImplthen qualifiedMangledNameOfTyconRef(tcrefOfAppTy cenv.g enclTypOfOverridenMethod) nameOfOverridenMethodelse nameOfOverridenMethod
@@ -3453,7 +3455,7 @@ and GenMethodImpl cenv eenv (useMethodImpl,(TSlotSig(nameOfOverridenMethod,_,_,_
34533455
letilOverrideTyRef= ilOverrideTy.TypeRef
34543456
letilOverrideMethRef= mkILMethRef(ilOverrideTyRef, ILCallingConv.Instance, nameOfOverridenMethod, List.length(DropErasedTypars methTyparsOfOverridingMethod),(typesOfILParams ilOverrideParams), ilOverrideRet.Type)
34553457
leteenvForOverrideBy= AddTyparsToEnv methTyparsOfOverridingMethod eenv
3456-
letilParamsOfOverridingMethod,ilReturnOfOverridingMethod= GenActualSlotsig m cenv eenvForOverrideBy slotsig methTyparsOfOverridingMethod
3458+
letilParamsOfOverridingMethod,ilReturnOfOverridingMethod= GenActualSlotsig m cenv eenvForOverrideBy slotsig methTyparsOfOverridingMethod[]
34573459
letilOverrideMethGenericParams= GenGenericParams cenv eenvForOverrideBy methTyparsOfOverridingMethod
34583460
letilOverrideMethGenericArgs= mkILFormalGenericArgs0 ilOverrideMethGenericParams
34593461
letilOverrideBy= mkILInstanceMethSpecInTy(ilTyForOverriding, nameOfOverridingMethod, typesOfILParams ilParamsOfOverridingMethod, ilReturnOfOverridingMethod.Type, ilOverrideMethGenericArgs)
@@ -3500,11 +3502,12 @@ and GenObjectMethod cenv eenvinner (cgbuf:CodeGenBuffer) useMethodImpl tmethod =
35003502
[]
35013503
else
35023504
leteenvUnderTypars= AddTyparsToEnv methTyparsOfOverridingMethod eenvinner
3503-
letilParamsOfOverridingMethod,ilReturnOfOverridingMethod= GenActualSlotsig m cenv eenvUnderTypars slotsig methTyparsOfOverridingMethod
3505+
letmethodParams= List.concat methodParams
3506+
letmethodParamsNonSelf=match methodParamswith[]->[]|_::t-> t// drop the 'this' arg when computing better argument names for IL parameters
3507+
letilParamsOfOverridingMethod,ilReturnOfOverridingMethod= GenActualSlotsig m cenv eenvUnderTypars slotsig methTyparsOfOverridingMethod methodParamsNonSelf
35043508
letilAttribs= GenAttrs cenv eenvinner attribs
35053509

35063510
// Args are stored starting at #1
3507-
letmethodParams= List.concat methodParams
35083511
leteenvForMeth= AddStorageForLocalVals cenv.g(methodParams|> List.mapi(fun i v->(v,Arg i))) eenvUnderTypars
35093512
letilMethodBody= CodeGenMethodForExpr cenv cgbuf.mgbuf(SPAlways,[],nameOfOverridenMethod,eenvForMeth,0,0,methodBodyExpr,(if slotSigHasVoidReturnTy slotsigthen discardAndReturnVoidelse Return))
35103513

@@ -4081,12 +4084,13 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod((TSlotSig(_,delega
40814084

40824085
letenvForDelegeeUnderTypars= AddTyparsToEnv methTyparsOfOverridingMethod eenvinner
40834086

4087+
letnumthis=1
4088+
lettmvs,body= BindUnitVars cenv.g(tmvs, List.replicate(List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1, body)
4089+
40844090
// The slot sig contains a formal instantiation. When creating delegates we're only
40854091
// interested in the actual instantiation since we don't have to emit a method impl.
4086-
letilDelegeeParams,ilDelegeeRet= GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod
4092+
letilDelegeeParams,ilDelegeeRet= GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod tmvs
40874093

4088-
letnumthis=1
4089-
lettmvs,body= BindUnitVars cenv.g(tmvs, List.replicate(List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1, body)
40904094
letenvForDelegeeMeth= AddStorageForLocalVals cenv.g(List.mapi(fun i v->(v,Arg(i+numthis))) tmvs) envForDelegeeUnderTypars
40914095
letilMethodBody= CodeGenMethodForExpr cenv cgbuf.mgbuf(SPAlways,[],delegeeMethName,envForDelegeeMeth,1,0,body,(if slotSigHasVoidReturnTy slotsigthen discardAndReturnVoidelse Return))
40924096
letdelegeeInvokeMeth=
@@ -6482,7 +6486,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon:Tycon) =
64826486
match paramlwith
64836487
|[[tsp]]when isUnitTy cenv.g tsp.Type->[](* suppress unit arg*)
64846488
| paraml-> paraml
6485-
GenActualSlotsig m cenv eenvinner(TSlotSig(nm,typ,ctps,mtps,paraml,returnTy))[]
6489+
GenActualSlotsig m cenv eenvinner(TSlotSig(nm,typ,ctps,mtps,paraml,returnTy))[][]
64866490
for ilMethodDefin mkILDelegateMethods cenv.g.ilg(cenv.g.iltyp_AsyncCallback, cenv.g.iltyp_IAsyncResult)(p,r)do
64876491
yield{ ilMethodDefwith Access=reprAccess}
64886492
|_->

‎tests/fsharpqa/Source/CodeGen/EmittedIL/CompiledNameAttribute/CompiledNameAttribute04.il.netfx4.bsl‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17376
2+
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
33
// Copyright (c) Microsoft Corporation. All rights reserved.
44

55

@@ -13,7 +13,7 @@
1313
.assembly extern FSharp.Core
1414
{
1515
.publickeytoken= (B0 3F 5F 7F11 D5 0A 3A )// .?_....:
16-
.ver4:3:0:0
16+
.ver4:4:1:0
1717
}
1818
.assembly CompiledNameAttribute04
1919
{
@@ -29,20 +29,20 @@
2929
}
3030
.mresource public FSharpSignatureData.CompiledNameAttribute04
3131
{
32-
// Offset: 0x00000000 Length:0x00000D0E
32+
// Offset: 0x00000000 Length:0x00000CE9
3333
}
3434
.mresource public FSharpOptimizationData.CompiledNameAttribute04
3535
{
36-
// Offset:0x00000D18 Length: 0x000002CB
36+
// Offset:0x00000CF0 Length: 0x000002CB
3737
}
3838
.module CompiledNameAttribute04.exe
39-
// MVID: {4F20DC6A-34DF-584F-A745-03836ADC204F}
39+
// MVID: {59A6D79B-34DF-584F-A745-03839BD7A659}
4040
.imagebase 0x00400000
4141
.file alignment 0x00000200
4242
.stackreserve 0x00100000
4343
.subsystem 0x0003// WINDOWS_CUI
4444
.corflags 0x00000001// ILONLY
45-
// Image base:0x000000B84EEF0000
45+
// Image base:0x02D50000
4646

4747

4848
// =============== CLASS MEMBERS DECLARATION ===================
@@ -74,7 +74,7 @@
7474
// Code size 10 (0xa)
7575
.maxstack8
7676
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
77-
.line20,20 :6,7
77+
.line20,20 :6,7'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\CompiledNameAttribute\\CompiledNameAttribute04.fs'
7878
IL_0000: ldarg.0
7979
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor()
8080
IL_0006: ldarg.0
@@ -88,7 +88,7 @@
8888
{
8989
// Code size 3 (0x3)
9090
.maxstack8
91-
.line21,21 :19,20
91+
.line21,21 :19,20''
9292
IL_0000: nop
9393
IL_0001: ldc.i4.1
9494
IL_0002: ret
@@ -101,7 +101,7 @@
101101
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[])= (01000200000001000000010000000000 )
102102
// Code size 5 (0x5)
103103
.maxstack8
104-
.line22,22 :24,29
104+
.line22,22 :24,29''
105105
IL_0000: nop
106106
IL_0001: ldarg.1
107107
IL_0002: ldarg.2
@@ -114,7 +114,7 @@
114114
{
115115
// Code size 3 (0x3)
116116
.maxstack8
117-
.line24,24 :22,23
117+
.line24,24 :22,23''
118118
IL_0000: nop
119119
IL_0001: ldarg.1
120120
IL_0002: ret
@@ -154,7 +154,7 @@
154154
// Code size 6 (0x6)
155155
.maxstack3
156156
.locals init ([0] valuetype CompiledNameAttribute04/S& V_0)
157-
.line37,37 :6,7
157+
.line37,37 :6,7''
158158
IL_0000: nop
159159
IL_0001: ldarga.s obj
160160
IL_0003: stloc.0
@@ -168,7 +168,7 @@
168168
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()= (01000000 )
169169
// Code size 14 (0xe)
170170
.maxstack8
171-
.line37,37 :6,7
171+
.line37,37 :6,7''
172172
IL_0000: nop
173173
IL_0001: ldarg.0
174174
IL_0002: ldarg.1
@@ -186,7 +186,7 @@
186186
.maxstack3
187187
.locals init ([0] valuetype CompiledNameAttribute04/S V_0,
188188
[1] valuetype CompiledNameAttribute04/S& V_1)
189-
.line37,37 :6,7
189+
.line37,37 :6,7''
190190
IL_0000: nop
191191
IL_0001: ldarg.1
192192
IL_0002: unbox.any CompiledNameAttribute04/S
@@ -203,7 +203,7 @@
203203
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()= (01000000 )
204204
// Code size 3 (0x3)
205205
.maxstack8
206-
.line37,37 :6,7
206+
.line37,37 :6,7''
207207
IL_0000: nop
208208
IL_0001: ldc.i4.0
209209
IL_0002: ret
@@ -215,7 +215,7 @@
215215
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()= (01000000 )
216216
// Code size 13 (0xd)
217217
.maxstack8
218-
.line37,37 :6,7
218+
.line37,37 :6,7''
219219
IL_0000: nop
220220
IL_0001: ldarg.0
221221
IL_0002: call class [mscorlib]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer()
@@ -256,7 +256,7 @@
256256
{
257257
// Code size 3 (0x3)
258258
.maxstack8
259-
.line40,40 :24,25
259+
.line40,40 :24,25''
260260
IL_0000: nop
261261
IL_0001: ldarg.1
262262
IL_0002: ret
@@ -269,7 +269,7 @@
269269
// Code size 6 (0x6)
270270
.maxstack3
271271
.locals init ([0] valuetype CompiledNameAttribute04/S& V_0)
272-
.line37,37 :6,7
272+
.line37,37 :6,7''
273273
IL_0000: nop
274274
IL_0001: ldarga.s obj
275275
IL_0003: stloc.0
@@ -334,13 +334,13 @@
334334
}// end of method a@49::.ctor
335335

336336
.method private hidebysig newslot virtual final
337-
instance int32 'CompiledNameAttribute04-ITestInterface-M'(int32A_1) cil managed
337+
instance int32 'CompiledNameAttribute04-ITestInterface-M'(int32x) cil managed
338338
{
339339
.custom instance void [mscorlib]System.Runtime.InteropServices.PreserveSigAttribute::.ctor()= (01000000 )
340340
.override CompiledNameAttribute04/ITestInterface::M
341341
// Code size 5 (0x5)
342342
.maxstack8
343-
.line51,51 :33,38
343+
.line51,51 :33,38''
344344
IL_0000: nop
345345
IL_0001: ldarg.1
346346
IL_0002: ldc.i4.1
@@ -356,7 +356,7 @@
356356
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[])= (01000200000001000000010000000000 )
357357
// Code size 5 (0x5)
358358
.maxstack8
359-
.line16,16 :14,19
359+
.line16,16 :14,19''
360360
IL_0000: nop
361361
IL_0001: ldarg.0
362362
IL_0002: ldarg.1
@@ -368,7 +368,7 @@
368368
{
369369
// Code size 3 (0x3)
370370
.maxstack8
371-
.line17,17 :12,13
371+
.line17,17 :12,13''
372372
IL_0000: nop
373373
IL_0001: ldarg.0
374374
IL_0002: ret

‎tests/fsharpqa/Source/CodeGen/EmittedIL/DoNotBoxStruct/DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth.il.bsl‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.17376
2+
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
33
// Copyright (c) Microsoft Corporation. All rights reserved.
44

55

@@ -13,7 +13,7 @@
1313
.assembly extern FSharp.Core
1414
{
1515
.publickeytoken= (B0 3F 5F 7F11 D5 0A 3A )// .?_....:
16-
.ver4:3:0:0
16+
.ver4:4:1:0
1717
}
1818
.assembly DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth
1919
{
@@ -29,20 +29,20 @@
2929
}
3030
.mresource public FSharpSignatureData.DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth
3131
{
32-
// Offset: 0x00000000 Length:0x000002B5
32+
// Offset: 0x00000000 Length:0x00000291
3333
}
3434
.mresource public FSharpOptimizationData.DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth
3535
{
36-
// Offset:0x000002C0 Length: 0x000000BA
36+
// Offset:0x00000298 Length: 0x000000BA
3737
}
3838
.module DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth.exe
39-
// MVID: {4F20DD34-1475-D984-A745-038334DD204F}
39+
// MVID: {59A6D79B-1475-D984-A745-03839BD7A659}
4040
.imagebase 0x00400000
4141
.file alignment 0x00000200
4242
.stackreserve 0x00100000
4343
.subsystem 0x0003// WINDOWS_CUI
4444
.corflags 0x00000001// ILONLY
45-
// Image base:0x00000031611D0000
45+
// Image base:0x005A0000
4646

4747

4848
// =============== CLASS MEMBERS DECLARATION ===================
@@ -66,14 +66,14 @@
6666
}// end of method F@6::.ctor
6767

6868
.method assembly hidebysig instance void
69-
Invoke(objectsender,
70-
int32args) cil managed
69+
Invoke(objectx,
70+
int32_arg1) cil managed
7171
{
7272
// Code size 4 (0x4)
7373
.maxstack5
7474
.locals init ([0] int32 V_0)
7575
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
76-
.line6,6 :80,82
76+
.line6,6 :80,82'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\DoNotBoxStruct\\DoNotBoxStruct_ArrayOfArray_FSInterface_NoExtMeth.fs'
7777
IL_0000: ldarg.2
7878
IL_0001: stloc.0
7979
IL_0002: nop
@@ -86,7 +86,7 @@
8686
{
8787
// Code size 45 (0x2d)
8888
.maxstack8
89-
.line6,6 :48,83
89+
.line6,6 :48,83''
9090
IL_0000: nop
9191
IL_0001: ldarg.0
9292
IL_0002: ldc.i4.0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp