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: clsload.inl |
6 | // |
7 | |
8 | // |
9 | |
10 | // |
11 | // ============================================================================ |
12 | |
13 | |
14 | #ifndef _CLSLOAD_INL_ |
15 | #define _CLSLOAD_INL_ |
16 | |
17 | inline PTR_Assembly ClassLoader::GetAssembly() |
18 | { |
19 | LIMITED_METHOD_CONTRACT; |
20 | SUPPORTS_DAC; |
21 | return m_pAssembly; |
22 | } |
23 | |
24 | inline PTR_Module ClassLoader::ComputeLoaderModuleForFunctionPointer(TypeHandle* pRetAndArgTypes, DWORD NumArgsPlusRetType) |
25 | { |
26 | CONTRACTL |
27 | { |
28 | NOTHROW; |
29 | GC_NOTRIGGER; |
30 | MODE_ANY; |
31 | SUPPORTS_DAC; |
32 | } |
33 | CONTRACTL_END; |
34 | return ComputeLoaderModuleWorker(NULL, |
35 | 0, |
36 | Instantiation(pRetAndArgTypes, NumArgsPlusRetType), |
37 | Instantiation()); |
38 | } |
39 | |
40 | inline PTR_Module ClassLoader::ComputeLoaderModuleForParamType(TypeHandle paramType) |
41 | { |
42 | CONTRACTL |
43 | { |
44 | NOTHROW; |
45 | GC_NOTRIGGER; |
46 | MODE_ANY; |
47 | SUPPORTS_DAC; |
48 | } |
49 | CONTRACTL_END; |
50 | |
51 | // |
52 | // Call GetLoaderModule directly instead of ComputeLoaderModuleWorker to avoid exponential recursion for collectible types |
53 | // |
54 | // It is safe to do it even during NGen because of we do not create duplicate copies of arrays and other param types |
55 | // (see code:CEEPreloader::TriageTypeForZap). |
56 | // |
57 | return paramType.GetLoaderModule(); |
58 | } |
59 | |
60 | //****************************************************************************** |
61 | |
62 | inline void AccessCheckOptions::Initialize( |
63 | AccessCheckType accessCheckType, |
64 | BOOL throwIfTargetIsInaccessible, |
65 | MethodTable * pTargetMT, |
66 | MethodDesc * pTargetMethod, |
67 | FieldDesc * pTargetField) |
68 | { |
69 | CONTRACTL |
70 | { |
71 | SO_TOLERANT; |
72 | THROWS; |
73 | GC_TRIGGERS; |
74 | MODE_ANY; |
75 | // At most one of these can be non-NULL. They can all be NULL if: |
76 | // 1. we are doing a normal accessibility check, or |
77 | // 2. we are not going to throw an exception if the accessibility check fails |
78 | PRECONDITION(accessCheckType == kNormalAccessibilityChecks || |
79 | !throwIfTargetIsInaccessible || |
80 | ((pTargetMT ? 1 : 0) + (pTargetMethod ? 1 : 0) + (pTargetField ? 1 : 0)) == 1); |
81 | // m_pAccessContext can only be set for kRestrictedMemberAccess |
82 | PRECONDITION(m_pAccessContext == NULL || |
83 | accessCheckType == AccessCheckOptions::kRestrictedMemberAccess); |
84 | } |
85 | CONTRACTL_END; |
86 | |
87 | m_accessCheckType = accessCheckType; |
88 | m_fThrowIfTargetIsInaccessible = throwIfTargetIsInaccessible; |
89 | m_pTargetMT = pTargetMT; |
90 | m_pTargetMethod = pTargetMethod; |
91 | m_pTargetField = pTargetField; |
92 | } |
93 | |
94 | //****************************************************************************** |
95 | |
96 | inline AccessCheckOptions::AccessCheckOptions( |
97 | AccessCheckType accessCheckType, |
98 | DynamicResolver * pAccessContext, |
99 | BOOL throwIfTargetIsInaccessible, |
100 | MethodTable * pTargetMT) : |
101 | m_pAccessContext(pAccessContext) |
102 | { |
103 | WRAPPER_NO_CONTRACT; |
104 | |
105 | Initialize( |
106 | accessCheckType, |
107 | throwIfTargetIsInaccessible, |
108 | pTargetMT, |
109 | NULL, |
110 | NULL); |
111 | } |
112 | |
113 | inline AccessCheckOptions::AccessCheckOptions( |
114 | AccessCheckType accessCheckType, |
115 | DynamicResolver * pAccessContext, |
116 | BOOL throwIfTargetIsInaccessible, |
117 | MethodDesc * pTargetMethod) : |
118 | m_pAccessContext(pAccessContext) |
119 | { |
120 | WRAPPER_NO_CONTRACT; |
121 | |
122 | Initialize( |
123 | accessCheckType, |
124 | throwIfTargetIsInaccessible, |
125 | NULL, |
126 | pTargetMethod, |
127 | NULL); |
128 | } |
129 | |
130 | inline AccessCheckOptions::AccessCheckOptions( |
131 | AccessCheckType accessCheckType, |
132 | DynamicResolver * pAccessContext, |
133 | BOOL throwIfTargetIsInaccessible, |
134 | FieldDesc * pTargetField) : |
135 | m_pAccessContext(pAccessContext) |
136 | { |
137 | WRAPPER_NO_CONTRACT; |
138 | |
139 | Initialize( |
140 | accessCheckType, |
141 | throwIfTargetIsInaccessible, |
142 | NULL, |
143 | NULL, |
144 | pTargetField); |
145 | } |
146 | |
147 | #endif // _CLSLOAD_INL_ |
148 | |
149 | |