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.
9 // Signature parsing code
12 #include "sigparser.h"
15 HRESULT SigParser::SkipExactlyOne()
28 HRESULT hr = GetElemType(&typ);
32 if (!CorIsPrimitiveType(typ))
37 // _ASSERT(!"Illegal or unimplement type in COM+ sig.");
38 return META_E_BAD_SIGNATURE;
40 case ELEMENT_TYPE_VAR:
41 case ELEMENT_TYPE_MVAR:
42 IfFailRet(GetData(NULL)); // Skip variable number
44 case ELEMENT_TYPE_VAR_ZAPSIG:
45 IfFailRet(GetData(NULL)); // Skip RID
47 case ELEMENT_TYPE_OBJECT:
48 case ELEMENT_TYPE_STRING:
49 case ELEMENT_TYPE_TYPEDBYREF:
50 case ELEMENT_TYPE_CANON_ZAPSIG:
53 case ELEMENT_TYPE_BYREF: //fallthru
54 case ELEMENT_TYPE_PTR:
55 case ELEMENT_TYPE_PINNED:
56 case ELEMENT_TYPE_SZARRAY:
57 case ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG:
58 case ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG:
59 IfFailRet(SkipExactlyOne()); // Skip referenced type
62 case ELEMENT_TYPE_VALUETYPE: //fallthru
63 case ELEMENT_TYPE_CLASS:
64 IfFailRet(GetToken(NULL)); // Skip RID
67 case ELEMENT_TYPE_MODULE_ZAPSIG:
68 IfFailRet(GetData(NULL)); // Skip index
69 IfFailRet(SkipExactlyOne()); // Skip type
72 case ELEMENT_TYPE_FNPTR:
73 IfFailRet(SkipSignature());
76 case ELEMENT_TYPE_ARRAY:
78 IfFailRet(SkipExactlyOne()); // Skip element type
80 IfFailRet(GetData(&rank)); // Get rank
84 IfFailRet(GetData(&nsizes)); // Get # of sizes
87 IfFailRet(GetData(NULL)); // Skip size
91 IfFailRet(GetData(&nlbounds)); // Get # of lower bounds
94 IfFailRet(GetData(NULL)); // Skip lower bounds
101 case ELEMENT_TYPE_SENTINEL:
102 // Should be unreachable since GetElem strips it
105 case ELEMENT_TYPE_INTERNAL:
106 IfFailRet(GetPointer(NULL));
109 case ELEMENT_TYPE_GENERICINST:
110 IfFailRet(SkipExactlyOne()); // Skip generic type
112 IfFailRet(GetData(&argCnt)); // Get number of parameters
115 IfFailRet(SkipExactlyOne()); // Skip the parameters
125 //---------------------------------------------------------------------------------------
127 // Skip only a method header signature - not the sigs of the args to the method.
130 SigParser::SkipMethodHeaderSignature(
145 // Skip calling convention
147 IfFailRet(GetCallingConvInfo(&uCallConv));
149 if ((uCallConv == IMAGE_CEE_CS_CALLCONV_FIELD) ||
150 (uCallConv == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG))
152 return META_E_BAD_SIGNATURE;
155 // Skip type parameter count
156 if (uCallConv & IMAGE_CEE_CS_CALLCONV_GENERIC)
157 IfFailRet(GetData(NULL));
160 IfFailRet(GetData(pcArgs));
163 IfFailRet(SkipExactlyOne());
166 } // SigParser::SkipMethodHeaderSignature
168 //---------------------------------------------------------------------------------------
170 // Skip a sub signature (as immediately follows an ELEMENT_TYPE_FNPTR).
171 HRESULT SigParser::SkipSignature()
187 IfFailRet(SkipMethodHeaderSignature(&cArgs));
191 IfFailRet(SkipExactlyOne());