BCSYM_Container* Bindable::BasesIter::GetNextBase ( BCSYM_GenericTypeBinding **BaseGenericBinding ) { BCSYM *Base; if (!m_IteratorStarted) { m_IteratorStarted = true; Base = GetFirst(); } else { Base = GetNext(); } if (BaseGenericBinding) { if (Base && Base->IsGenericTypeBinding()) { *BaseGenericBinding = Base->PGenericTypeBinding(); } else { *BaseGenericBinding = NULL; } } return Base->PContainer(); }
bool CLSComplianceChecker::IsTypeCLSCompliant( BCSYM * RawType, BCSYM_NamedRoot * NamedContext) { BCSYM *ActualType = RawType->ChaseToType(); if (!ActualType || (ActualType->IsNamedRoot() && ActualType->PNamedRoot()->IsBadNamedRoot())) { return true; } // Return true for generic params because its constraints are anyway verified separately // if (ActualType->IsGenericParam()) { return true; } VSASSERT( ActualType->IsContainer(), "What else can a chased type be ?"); if (ActualType->IsGenericBinding()) { NameTypeArguments **RawTypeArgumentsSets = RawType->IsNamedType() ? RawType->PNamedType()->GetArgumentsArray() : NULL; unsigned CountOfRawTypeArgumentsSets = RawType->IsNamedType() ? RawType->PNamedType()->GetNameCount() : 0; NameTypeArguments *CurrentRawTypeArgumentsSet = NULL; unsigned CurrentRawTypeArgumentsSetIndex = CountOfRawTypeArgumentsSets; for(BCSYM_GenericTypeBinding *GenericBinding = ActualType->PGenericTypeBinding(); GenericBinding; GenericBinding = GenericBinding->GetParentBinding()) { if (RawTypeArgumentsSets && CurrentRawTypeArgumentsSetIndex > 0) { CurrentRawTypeArgumentsSet = RawTypeArgumentsSets[--CurrentRawTypeArgumentsSetIndex]; if (CurrentRawTypeArgumentsSet && CurrentRawTypeArgumentsSet->m_BoundGenericBinding != GenericBinding) { // Lost the one to one mapping between actual type and raw type, so // invalidate and do not use the raw type argument locations. CurrentRawTypeArgumentsSet = NULL; } } unsigned GenericArgumentCount = GenericBinding->GetArgumentCount(); for(unsigned Index = 0; Index < GenericArgumentCount; Index++) { BCSYM *ArgumentType = GenericBinding->GetArgument(Index); if (!IsTypeCLSCompliant(ArgumentType, NamedContext)) { Location *ErrorLocation = NULL; if (CurrentRawTypeArgumentsSet && CurrentRawTypeArgumentsSet->m_ArgumentCount > 0) { ErrorLocation = CurrentRawTypeArgumentsSet->GetArgumentLocation(Index); } if (!ErrorLocation) { ErrorLocation = RawType->IsNamedType() ? RawType->GetLocation() : NamedContext->GetLocation(); } ReportErrorAtLocation( WRNID_TypeNotCLSCompliant1, ErrorLocation, NamedContext, ArgumentType->ChaseToType()->GetErrorName(m_Compiler)); } } } return IsTypeCLSCompliant(ActualType->PGenericTypeBinding()->GetGeneric(), NamedContext); } return ActualType->PContainer()->IsCLSCompliant(); }