Skip to content

Commit f072d09

Browse files
committed
Formatting and cleanup
1 parent f54a832 commit f072d09

File tree

5 files changed

+80
-437
lines changed

5 files changed

+80
-437
lines changed

src/coreclr/tools/Common/TypeSystem/Common/AsyncMethodThunk.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public override MethodDesc GetTypicalMethodDefinition()
5151
return _wrappedMethod.GetTypicalMethodDefinition();
5252
}
5353

54-
public override MethodDesc GetAsyncOtherVariant() => _wrappedMethod;
54+
public override MethodDesc GetAsyncOtherVariant()
55+
{
56+
return _wrappedMethod;
57+
}
5558

5659
public override MethodDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
5760
{
@@ -67,9 +70,21 @@ public override MethodSignature Signature
6770
}
6871
}
6972

70-
public override string DiagnosticName => "Async thunk: " + _wrappedMethod.DiagnosticName;
73+
public override string DiagnosticName
74+
{
75+
get
76+
{
77+
return "Async thunk: " + _wrappedMethod.DiagnosticName;
78+
}
79+
}
7180

72-
protected internal override int ClassCode => 0x554d08b9;
81+
protected internal override int ClassCode
82+
{
83+
get
84+
{
85+
return 0x554d08b9;
86+
}
87+
}
7388

7489
protected internal override int CompareToImpl(MethodDesc other, TypeSystemComparer comparer)
7590
{

src/coreclr/tools/Common/TypeSystem/Common/InstantiatedMethod.cs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ private void InitializeSignature()
6666
var template = _methodDef.Signature;
6767
_signature = InstantiateSignature(template);
6868
}
69+
6970
private MethodSignature InstantiateSignature(MethodSignature template)
7071
{
7172
var builder = new MethodSignatureBuilder(template);
@@ -75,46 +76,46 @@ private MethodSignature InstantiateSignature(MethodSignature template)
7576
return builder.ToSignature();
7677
}
7778

79+
public override MethodSignature Signature
80+
{
81+
get
82+
{
83+
if (_signature == null)
84+
InitializeSignature();
85+
86+
return _signature;
87+
}
88+
}
89+
7890
public override AsyncMethodData AsyncMethodData
7991
{
8092
get
8193
{
82-
if (_asyncMethodData.Equals(default(AsyncMethodData)))
94+
if (!_asyncMethodData.Equals(default(AsyncMethodData)))
95+
return _asyncMethodData;
96+
97+
if (Signature.ReturnsTaskOrValueTask())
8398
{
84-
if (Signature.ReturnsTaskOrValueTask())
99+
if (IsAsync)
85100
{
86-
if (IsAsync)
87-
{
88-
// If the method is already async, the template signature should already have been updated to reflect the AsyncCallConv
89-
Debug.Assert(!Signature.ReturnsTaskOrValueTask() && Signature.IsAsyncCallConv);
90-
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.AsyncVariantImpl, Signature = Signature };
91-
}
92-
else
93-
{
94-
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.TaskReturning, Signature = Signature };
95-
}
101+
// If the method is already async, the template signature should already have been updated to reflect the AsyncCallConv
102+
Debug.Assert(!Signature.ReturnsTaskOrValueTask() && Signature.IsAsyncCallConv);
103+
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.AsyncVariantImpl, Signature = Signature };
96104
}
97105
else
98106
{
99-
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.NotAsync, Signature = Signature };
107+
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.TaskReturning, Signature = Signature };
100108
}
101109
}
110+
else
111+
{
112+
_asyncMethodData = new AsyncMethodData() { Kind = AsyncMethodKind.NotAsync, Signature = Signature };
113+
}
102114

103115
return _asyncMethodData;
104116
}
105117
}
106118

107-
public override MethodSignature Signature
108-
{
109-
get
110-
{
111-
if (_signature == null)
112-
InitializeSignature();
113-
114-
return _signature;
115-
}
116-
}
117-
118119
public override MethodDesc GetAsyncOtherVariant()
119120
{
120121
if (_asyncOtherVariant is null)

src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ public sealed partial class EcmaMethod : MethodDesc, EcmaModule.IEntityHandleObj
1515
{
1616
private static class MethodFlags
1717
{
18-
public const int BasicMetadataCache = 0x00001;
19-
public const int Virtual = 0x00002;
20-
public const int NewSlot = 0x00004;
21-
public const int Abstract = 0x00008;
22-
public const int Final = 0x00010;
23-
public const int NoInlining = 0x00020;
24-
public const int AggressiveInlining = 0x00040;
25-
public const int RuntimeImplemented = 0x00080;
26-
public const int InternalCall = 0x00100;
27-
public const int Synchronized = 0x00200;
18+
public const int BasicMetadataCache = 0x00001;
19+
public const int Virtual = 0x00002;
20+
public const int NewSlot = 0x00004;
21+
public const int Abstract = 0x00008;
22+
public const int Final = 0x00010;
23+
public const int NoInlining = 0x00020;
24+
public const int AggressiveInlining = 0x00040;
25+
public const int RuntimeImplemented = 0x00080;
26+
public const int InternalCall = 0x00100;
27+
public const int Synchronized = 0x00200;
2828
public const int AggressiveOptimization = 0x00400;
29-
public const int NoOptimization = 0x00800;
30-
public const int RequireSecObject = 0x01000;
29+
public const int NoOptimization = 0x00800;
30+
public const int RequireSecObject = 0x01000;
3131

3232
public const int AttributeMetadataCache = 0x02000;
33-
public const int Intrinsic = 0x04000;
34-
public const int UnmanagedCallersOnly = 0x08000;
35-
public const int Async = 0x10000;
33+
public const int Intrinsic = 0x04000;
34+
public const int UnmanagedCallersOnly = 0x08000;
35+
public const int Async = 0x10000;
3636
};
3737

3838
private EcmaType _type;
@@ -85,43 +85,8 @@ private MethodSignature InitializeSignature()
8585
EcmaSignatureParser parser = new EcmaSignatureParser(Module, signatureReader, NotFoundBehavior.Throw);
8686
var signature = parser.ParseMethodSignature();
8787

88-
bool returnsTask = signature.ReturnsTaskOrValueTask();
89-
if (!returnsTask && !IsAsync)
90-
{
91-
_asyncMethodData = new AsyncMethodData
92-
{
93-
Kind = AsyncMethodKind.NotAsync,
94-
Signature = signature
95-
};
96-
}
97-
else if (returnsTask && IsAsync)
98-
{
99-
_asyncMethodData = new AsyncMethodData
100-
{
101-
Kind = AsyncMethodKind.AsyncVariantImpl,
102-
Signature = signature.CreateAsyncSignature()
103-
};
104-
}
105-
else if (returnsTask && !IsAsync)
106-
{
107-
_asyncMethodData = new AsyncMethodData
108-
{
109-
Kind = AsyncMethodKind.TaskReturning,
110-
Signature = signature
111-
};
112-
}
113-
else
114-
{
115-
Debug.Assert(IsAsync && !returnsTask);
116-
_asyncMethodData = new AsyncMethodData
117-
{
118-
Kind = AsyncMethodKind.AsyncExplicitImpl,
119-
Signature = signature
120-
};
121-
}
122-
12388
_metadataSignature = signature;
124-
return (_metadataSignature = signature);
89+
return _metadataSignature;
12590
}
12691

12792
public override MethodSignature Signature
@@ -139,19 +104,6 @@ public override MethodSignature Signature
139104
}
140105
}
141106

142-
/// <summary>
143-
/// The method signature as defined in metadata, without any adjustments for async methods.
144-
/// </summary>
145-
public MethodSignature MetadataSignature
146-
{
147-
get
148-
{
149-
if (_metadataSignature == null)
150-
return InitializeSignature();
151-
return _metadataSignature;
152-
}
153-
}
154-
155107
public EcmaModule Module
156108
{
157109
get
@@ -441,7 +393,28 @@ public override AsyncMethodData AsyncMethodData
441393
get
442394
{
443395
if (_asyncMethodData.Equals(default(AsyncMethodData)))
396+
{
444397
InitializeSignature();
398+
bool returnsTask = _metadataSignature.ReturnsTaskOrValueTask();
399+
if (!returnsTask && !IsAsync)
400+
{
401+
_asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind.NotAsync, Signature = _metadataSignature };
402+
}
403+
else if (returnsTask && IsAsync)
404+
{
405+
var asyncSignature = _metadataSignature.CreateAsyncSignature();
406+
_asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind.AsyncVariantImpl, Signature = asyncSignature };
407+
}
408+
else if (returnsTask && !IsAsync)
409+
{
410+
_asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind.TaskReturning, Signature = _metadataSignature };
411+
}
412+
else
413+
{
414+
Debug.Assert(IsAsync && !returnsTask);
415+
_asyncMethodData = new AsyncMethodData { Kind = AsyncMethodKind.AsyncExplicitImpl, Signature = _metadataSignature };
416+
}
417+
}
445418

446419
Debug.Assert(!_asyncMethodData.Equals(default(AsyncMethodData)));
447420
return _asyncMethodData;

0 commit comments

Comments
 (0)