1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4//
5// File: typedesc.inl
6//
7
8
9//
10
11//
12// ============================================================================
13
14
15#ifndef _TYPEDESC_INL_
16#define _TYPEDESC_INL_
17
18inline PTR_MethodTable TypeDesc::GetMethodTable() {
19
20 LIMITED_METHOD_DAC_CONTRACT;
21
22 if (IsGenericVariable())
23 return NULL;
24
25 if (GetInternalCorElementType() == ELEMENT_TYPE_FNPTR)
26 return MscorlibBinder::GetElementType(ELEMENT_TYPE_U);
27
28 _ASSERTE(HasTypeParam());
29 ParamTypeDesc* asParam = dac_cast<PTR_ParamTypeDesc>(this);
30
31 if (GetInternalCorElementType() == ELEMENT_TYPE_VALUETYPE)
32 return dac_cast<PTR_MethodTable>(asParam->m_Arg.AsMethodTable());
33 else
34 return(asParam->GetTemplateMethodTableInternal());
35}
36
37inline TypeHandle TypeDesc::GetTypeParam() {
38 LIMITED_METHOD_DAC_CONTRACT;
39
40 if (IsGenericVariable() || IsFnPtr())
41 return TypeHandle();
42
43 _ASSERTE(HasTypeParam());
44 ParamTypeDesc* asParam = dac_cast<PTR_ParamTypeDesc>(this);
45 return(asParam->m_Arg);
46}
47
48inline TypeHandle ParamTypeDesc::GetTypeParam() {
49 LIMITED_METHOD_DAC_CONTRACT;
50
51 return(this->m_Arg);
52}
53
54inline Instantiation TypeDesc::GetClassOrArrayInstantiation() {
55 LIMITED_METHOD_DAC_CONTRACT;
56
57 if (GetInternalCorElementType() != ELEMENT_TYPE_FNPTR)
58 {
59 ParamTypeDesc* asParam = dac_cast<PTR_ParamTypeDesc>(this);
60 return Instantiation(&asParam->m_Arg, 1);
61 }
62 else
63 return Instantiation();
64}
65
66
67#endif // _TYPEDESC_INL_
68
69
70
71