DWORD TypeName::AddRef()
-{
- LIMITED_METHOD_CONTRACT;
+{
+ LIMITED_METHOD_CONTRACT;
- m_count++;
+ m_count++;
- return m_count;
+ return m_count;
}
DWORD TypeName::Release()
-{
+{
CONTRACTL
{
THROWS;
}
CONTRACTL_END;
- m_count--;
+ m_count--;
DWORD dwCount = m_count;
- if (dwCount == 0)
- delete this;
-
- return dwCount;
+ if (dwCount == 0)
+ delete this;
+
+ return dwCount;
}
-TypeName::~TypeName()
-{
+TypeName::~TypeName()
+{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
}
CONTRACTL_END;
-
+
for(COUNT_T i = 0; i < m_genericArguments.GetCount(); i ++)
m_genericArguments[i]->Release();
}
}
pNames.Set(pReturnNames);
-
+
GCPROTECT_END();
}
else
GCPROTECT_BEGIN(pReturnModifiers);
- //TODO: how do we Get
+ //TODO: how do we Get
pReturnModifiers = (I4ARRAYREF)AllocatePrimitiveArray(ELEMENT_TYPE_I4, count);
INT32 *pToArray = pReturnModifiers->GetDirectPointerToNonObjectElements();
#undef IfFailGo
#define IfFailGo(P) if (!P) return FALSE;
-TypeName* TypeName::AddGenericArgument()
-{
+TypeName* TypeName::AddGenericArgument()
+{
WRAPPER_NO_CONTRACT;
TypeName* pGenArg = new TypeName();
if (*m_itr == W('\0'))
return TypeNameEnd;
-
+
if (COMCharacter::nativeIsWhiteSpace(*m_itr))
{
m_itr++;
}
WCHAR c = *m_itr;
- m_itr++;
+ m_itr++;
switch(c)
{
case W(','): return TypeNameComma;
case W('&'): return TypeNameAmpersand;
case W('*'): return TypeNameAstrix;
case W('+'): if (!ignorePlus) return TypeNamePlus;
- case W('\\'):
+ case W('\\'):
m_itr--;
return TypeNameIdentifier;
}
LPCWSTR start = m_currentItr;
InlineSArray<LPCWSTR, 32> m_escape;
-
+
if (identifierType == TypeNameId)
{
do
case W('\0'):
goto done;
- case W('\\'):
+ case W('\\'):
m_escape.Append(m_currentItr - 1);
-
+
if (! IsTypeNameReservedChar(*m_currentItr) || *m_currentItr == '\0')
return FALSE;
m_currentItr--;
}
else if (identifierType == TypeNameFusionName)
- {
+ {
while(*m_currentItr != W('\0'))
m_currentItr++;
}
continue;
}
}
-
+
if (*m_currentItr == '\0')
return FALSE;
}
return FALSE;
}
}
- else
+ else
return FALSE;
-
+
sszId->Set(start, (COUNT_T)(m_currentItr - start));
for (SCOUNT_T i = m_escape.GetCount() - 1; i >= 0; i--)
GetIdentifier(m_pTypeName->GetAssembly(), TypeNameFusionName);
NextToken();
-
+
return TRUE;
}
}
// *empty*
-// '[' GENARGS ']'
+// '[' GENARGS ']'
BOOL TypeName::TypeNameParser::GENPARAMS()
{
CONTRACTL
CONTRACTL_END;
if (!TokenIs(TypeNameGENPARAM))
- return TRUE;
+ return TRUE;
if (!NextTokenIs(TypeNameGENARGS))
return TRUE;
return TRUE;
}
-
+
// '[' EAQN ']'
// FULLNAME
BOOL TypeName::TypeNameParser::GENARG()
GetIdentifier(m_pTypeName->GetAssembly(), TypeNameEmbeddedFusionName);
NextToken();
-
+
return TRUE;
}
if (TokenIs(TypeNameAstrix))
{
m_pTypeName->SetArray(1);
-
+
NextToken();
}
else
BOOL TypeName::TypeNameParser::RANK(DWORD* pdwRank)
{
WRAPPER_NO_CONTRACT;
-
+
if (!TokenIs(TypeNameRANK))
return TRUE;
if (pTypeName->GetAssembly()->IsEmpty())
*pfNameIsAsmQualified = FALSE;
}
-
+
th = pTypeName->GetTypeWorker(
- /*bThrowIfNotFound = */ TRUE,
- /*bIgnoreCase = */ FALSE,
- /*pAssemblyGetType =*/ NULL,
- /*fEnableCASearchRules = */ TRUE,
- /*fProhibitAsmQualifiedName = */ FALSE,
- pRequestingAssembly,
+ /*bThrowIfNotFound = */ TRUE,
+ /*bIgnoreCase = */ FALSE,
+ /*pAssemblyGetType =*/ NULL,
+ /*fEnableCASearchRules = */ TRUE,
+ /*fProhibitAsmQualifiedName = */ FALSE,
+ pRequestingAssembly,
nullptr,
FALSE,
- &keepAlive);
+ &keepAlive);
ASSERT(!th.IsNull());
LoaderAllocator *pLoaderAllocator = th.GetLoaderAllocator();
// funky knobs needed for implementing the specific requirements of the managed Type.GetType() apis and friends.
//--------------------------------------------------------------------------------------------------------------
/*public static */ TypeHandle TypeName::GetTypeManaged(
- LPCWSTR szTypeName,
- DomainAssembly* pAssemblyGetType,
- BOOL bThrowIfNotFound,
- BOOL bIgnoreCase,
+ LPCWSTR szTypeName,
+ DomainAssembly* pAssemblyGetType,
+ BOOL bThrowIfNotFound,
+ BOOL bIgnoreCase,
BOOL bProhibitAsmQualifiedName,
- Assembly* pRequestingAssembly,
+ Assembly* pRequestingAssembly,
BOOL bLoadTypeFromPartialNameHack,
OBJECTREF *pKeepAlive,
ICLRPrivBinder * pPrivHostBinder)
/* Partial name workaround loading must not load a collectible type */
if (bLoadTypeFromPartialNameHack)
pKeepAlive = NULL;
-
+
#ifdef __GNUC__
// When compiling under GCC we have to use the -fstack-check option to ensure we always spot stack
// overflow. But this option is intolerant of locals growing too large, so we have to cut back a bit
{
if (!bThrowIfNotFound)
return TypeHandle();
-
+
StackSString buf;
StackSString msg(W("typeName@"));
COUNT_T size = buf.GetUnicodeAllocation();
}
BOOL bPeriodPrefix = szTypeName[0] == W('.');
-
+
TypeHandle result = pTypeName->GetTypeWorker(
bPeriodPrefix ? FALSE : bThrowIfNotFound,
bIgnoreCase,
{
if (!bThrowIfNotFound)
return TypeHandle();
-
+
StackSString buf;
StackSString msg(W("typeName@"));
COUNT_T size = buf.GetUnicodeAllocation();
msg.Append(buf);
COMPlusThrowArgumentException(msg.GetUnicode(), NULL);
}
-
+
result = pTypeName->GetTypeWorker(
bThrowIfNotFound,
bIgnoreCase,
COMPlusThrow(kArgumentException, W("Format_StringZeroLength"));
DWORD error = (DWORD)-1;
-
+
#ifdef __GNUC__
// When compiling under GCC we have to use the -fstack-check option to ensure we always spot stack
// overflow. But this option is intolerant of locals growing too large, so we have to cut back a bit
TypeName typeName(szTypeName, &error);
TypeName *pTypeName = &typeName;
#endif // __GNUC__
-
+
if (error != (DWORD)-1)
{
StackSString buf;
COMPlusThrow(kArgumentException, IDS_EE_CANNOT_HAVE_ASSEMBLY_SPEC);
}
- return pTypeName->GetTypeWorker(bThrowIfNotFound, /*bIgnoreCase = */FALSE, pAssembly, /*fEnableCASearchRules = */FALSE, FALSE, NULL,
+ return pTypeName->GetTypeWorker(bThrowIfNotFound, /*bIgnoreCase = */FALSE, pAssembly, /*fEnableCASearchRules = */FALSE, FALSE, NULL,
nullptr, // pPrivHostBinder
FALSE, NULL /* cannot find a collectible type unless it is in assembly */);
}
COMPlusThrow(kArgumentException, W("Format_StringZeroLength"));
DWORD error = (DWORD)-1;
-
+
#ifdef __GNUC__
// When compiling under GCC we have to use the -fstack-check option to ensure we always spot stack
// overflow. But this option is intolerant of locals growing too large, so we have to cut back a bit
TypeName typeName(szFullyQualifiedName, &error);
TypeName *pTypeName = &typeName;
#endif // __GNUC__
-
+
if (error != (DWORD)-1)
{
StackSString buf;
}
return this->GetTypeWorker(
- /*bThrowIfNotFound =*/TRUE,
- /*bIgnoreCase = */FALSE,
- NULL,
- /*fEnableCASearchRules = */FALSE,
- FALSE,
- NULL,
+ /*bThrowIfNotFound =*/TRUE,
+ /*bIgnoreCase = */FALSE,
+ NULL,
+ /*fEnableCASearchRules = */FALSE,
+ FALSE,
+ NULL,
nullptr, // pPrivHostBinder
- FALSE,
+ FALSE,
NULL /* cannot find a collectible type */);
}
// for all of the possible GetTypes.
// -------------------------------------------------------------------------------------------------------------
/* private instance */ TypeHandle TypeName::GetTypeWorker(
- BOOL bThrowIfNotFound,
- BOOL bIgnoreCase,
+ BOOL bThrowIfNotFound,
+ BOOL bIgnoreCase,
Assembly* pAssemblyGetType,
BOOL fEnableCASearchRules,
BOOL bProhibitAsmQualifiedName,
- Assembly* pRequestingAssembly,
+ Assembly* pRequestingAssembly,
ICLRPrivBinder * pPrivHostBinder,
BOOL bLoadTypeFromPartialNameHack,
OBJECTREF *pKeepAlive)
pAsmRef = NULL;
// An explicit assembly has been specified so look for the type there
- if (!GetAssembly()->IsEmpty())
+ if (!GetAssembly()->IsEmpty())
{
-
+
if (bProhibitAsmQualifiedName && !m_bIsGenericArgument)
{
if (bThrowIfNotFound)
{
pssOuterTypeName = GetNames()[0];
}
-
+
// We want to catch the exception if we're going to later try a partial bind.
if (bLoadTypeFromPartialNameHack)
{
EX_TRY
{
- DomainAssembly *pDomainAssembly = LoadDomainAssembly(GetAssembly(), pRequestingAssembly,
+ DomainAssembly *pDomainAssembly = LoadDomainAssembly(GetAssembly(), pRequestingAssembly,
pPrivHostBinder,
bThrowIfNotFound, pssOuterTypeName);
if (pDomainAssembly)
}
else
{
- DomainAssembly *pDomainAssembly = LoadDomainAssembly(GetAssembly(), pRequestingAssembly,
+ DomainAssembly *pDomainAssembly = LoadDomainAssembly(GetAssembly(), pRequestingAssembly,
pPrivHostBinder,
bThrowIfNotFound, pssOuterTypeName);
if (pDomainAssembly)
}
// There's no explicit assembly so look in the assembly specified by the original caller (Assembly.GetType)
- else if (pAssemblyGetType)
+ else if (pAssemblyGetType)
{
th = GetTypeHaveAssembly(pAssemblyGetType, bThrowIfNotFound, bIgnoreCase, pKeepAlive);
}
-
+
// Otherwise look in the caller's assembly then the system assembly
else if (fEnableCASearchRules)
{
// Look for type in caller's assembly
if (pRequestingAssembly)
th = GetTypeHaveAssembly(pRequestingAssembly, bThrowIfNotFound, bIgnoreCase, pKeepAlive);
-
+
// Look for type in system assembly
if (th.IsNull())
{
if (pRequestingAssembly != SystemDomain::SystemAssembly())
th = GetTypeHaveAssembly(SystemDomain::SystemAssembly(), bThrowIfNotFound, bIgnoreCase, pKeepAlive);
}
-
+
// Raise AssemblyResolveEvent to try to resolve assembly
- if (th.IsNull())
+ if (th.IsNull())
{
AppDomain *pDomain = (AppDomain *)SystemDomain::GetCurrentDomain();
if ((BaseDomain*)pDomain != SystemDomain::System())
{
- TypeNameBuilder tnb;
+ TypeNameBuilder tnb;
for (COUNT_T i = 0; i < GetNames().GetCount(); i ++)
tnb.AddName(GetNames()[i]->GetUnicode());
-
+
StackScratchBuffer bufFullName;
DomainAssembly* pDomainAssembly = pDomain->RaiseTypeResolveEventThrowing(pRequestingAssembly?pRequestingAssembly->GetDomainAssembly():NULL,tnb.GetString()->GetANSI(bufFullName), pAsmRef);
if (pDomainAssembly)
th = GetTypeHaveAssembly(pDomainAssembly->GetAssembly(), bThrowIfNotFound, bIgnoreCase, pKeepAlive);
- }
- }
+ }
+ }
}
else
{
{
TypeHandle thGenericArg = m_genericArguments[i]->GetTypeWorker(
bThrowIfNotFound, bIgnoreCase,
- pAssemblyGetType, fEnableCASearchRules, bProhibitAsmQualifiedName, pRequestingAssembly,
+ pAssemblyGetType, fEnableCASearchRules, bProhibitAsmQualifiedName, pRequestingAssembly,
pPrivHostBinder,
- bLoadTypeFromPartialNameHack,
+ bLoadTypeFromPartialNameHack,
(pKeepAlive != NULL) ? &gc.keepAlive : NULL /* Only pass a keepalive parameter if we were passed a keepalive parameter */);
if (thGenericArg.IsNull())
gc.refGenericArguments->SetAt(i, gc.refGenericArg);
}
-
- MethodDescCallSite getTypeHelper(METHOD__RT_TYPE_HANDLE__GET_TYPE_HELPER);
-
+
+ MethodDescCallSite getTypeHelper(METHOD__RT_TYPE_HANDLE__GET_TYPE_HELPER);
+
ARG_SLOT args[5] = {
(ARG_SLOT)OBJECTREFToObject(th.GetManagedClassObject()),
(ARG_SLOT)OBJECTREFToObject(gc.refGenericArguments),
};
REFLECTCLASSBASEREF refType = NULL;
-
+
if (!abortCall)
refType = (REFLECTCLASSBASEREF)getTypeHelper.Call_RetOBJECTREF(args);
GCPROTECT_END();
#endif // CROSSGEN_COMPILE
}
-
- if (th.IsNull() && bThrowIfNotFound)
+
+ if (th.IsNull() && bThrowIfNotFound)
{
StackSString buf;
LPCWSTR wszName = ToString(&buf)->GetUnicode();
if (GetAssembly() && !GetAssembly()->IsEmpty())
{
ThrowTypeLoadException(NULL, szName, GetAssembly()->GetUnicode(), NULL, IDS_CLASSLOAD_GENERAL);
- }
- else if (pAssemblyGetType)
+ }
+ else if (pAssemblyGetType)
{
pAssemblyGetType->ThrowTypeLoadException(NULL, szName, IDS_CLASSLOAD_GENERAL);
}
// This is the one that actually loads the type once we've pinned down the Assembly it's in.
//----------------------------------------------------------------------------------------------------------------
/* private */
-TypeHandle
+TypeHandle
TypeName::GetTypeHaveAssemblyHelper(
- Assembly * pAssembly,
- BOOL bThrowIfNotFound,
- BOOL bIgnoreCase,
- OBJECTREF * pKeepAlive,
+ Assembly * pAssembly,
+ BOOL bThrowIfNotFound,
+ BOOL bIgnoreCase,
+ OBJECTREF * pKeepAlive,
BOOL bRecurse)
{
WRAPPER_NO_CONTRACT;
-
+
TypeHandle th = TypeHandle();
SArray<SString *> & names = GetNames();
Module * pManifestModule = pAssembly->GetManifestModule();
*pKeepAlive = pAssembly->GetLoaderAllocator()->GetExposedObject();
}
#endif
-
+
// Set up the name handle
if (bIgnoreCase)
typeName.SetCaseInsensitive();
// DDB 117395: if we didn't find a type, don't bother looking for its nested type
if (th.IsNull())
break;
-
+
if (th.GetAssembly() != pAssembly)
{ // It is forwarded type
-
+
// Use the found assembly class loader for potential nested types search
- // The nested type has to be in the same module as the nesting type, so it doesn't make
+ // The nested type has to be in the same module as the nesting type, so it doesn't make
// sense to follow the same chain of type forwarders again for the nested type
pClassLoader = th.GetAssembly()->GetLoader();
}
-
+
// Nested types must live in the module of the nesting type
if ((i == 0) && (names.GetCount() > 1) && (pLookOnlyInModule == NULL))
{
// Ensure that the bucket in the NameHandle is set to a valid bucket for all cases.
- // If the type is in the manifest module, it will always be set correctly,
+ // If the type is in the manifest module, it will always be set correctly,
// or if the type is forwarded always lookup via the standard logic
if ((pFoundModule == pManifestModule) || (pFoundModule->GetAssembly() != pAssembly))
continue;
HENUMInternalHolder phEnum(pManifestImport);
phEnum.EnumInit(mdtFile, mdTokenNil);
mdToken mdFile;
-
- while (pManifestImport->EnumNext(&phEnum, &mdFile))
+
+ while (pManifestImport->EnumNext(&phEnum, &mdFile))
{
if (pManifestModule->LookupFile(mdFile))
continue;
-
+
pManifestModule->LoadModule(GetAppDomain(), mdFile, FALSE);
th = GetTypeHaveAssemblyHelper(pAssembly, bThrowIfNotFound, bIgnoreCase, NULL, FALSE);
-
+
if (!th.IsNull())
- break;
+ break;
}
}
}
{
if (bThrowIfNotFound)
EX_RETHROW;
-
+
Exception * ex = GET_EXCEPTION();
-
+
// Let non-File-not-found exceptions propagate
if (EEFileLoadException::GetFileLoadKind(ex->GetHR()) != kFileNotFoundException)
EX_RETHROW;
DomainAssembly * LoadDomainAssembly(
- SString * psszAssemblySpec,
- Assembly * pRequestingAssembly,
+ SString * psszAssemblySpec,
+ Assembly * pRequestingAssembly,
ICLRPrivBinder * pPrivHostBinder,
- BOOL bThrowIfNotFound,
+ BOOL bThrowIfNotFound,
SString * pssOuterTypeName)
{
CONTRACTL
StackScratchBuffer buffer;
LPCUTF8 szAssemblySpec = psszAssemblySpec->GetUTF8(buffer);
IfFailThrow(spec.Init(szAssemblySpec));
-
+
if (spec.IsContentType_WindowsRuntime())
{
_ASSERTE(pssOuterTypeName != NULL);
spec.SetWindowsRuntimeType(*pssOuterTypeName);
}
-
+
if (pPrivHostBinder)
{
spec.SetHostBinder(pPrivHostBinder);
GCX_PREEMP();
spec.SetParentAssembly(pRequestingAssembly->GetDomainAssembly());
}
-
+
// If the requesting assembly has Fallback LoadContext binder available,
// then set it up in the AssemblySpec.
if (pRequestingAssembly != NULL)
}
EX_END_CATCH(RethrowTerminalExceptions);
}
-
+
return pDomainAssembly;
}