void Interface::updateSuperTypes() { assert( _numSuperTypes == 0 && !_superTypes ); if( !_baseType ) { assert( getFullName() == "co.IService" ); return; } IInterface* base = _baseType; while( base ) { ++_numSuperTypes; base = base->getBaseType(); } _superTypes = new IInterface*[_numSuperTypes]; base = _baseType; for( size_t i = 0; i < _numSuperTypes; ++i ) { _superTypes[i] = base; base = base->getBaseType(); } assert( _superTypes[_numSuperTypes - 1]->getFullName() == "co.IService" ); }
void validate() { // check for cyclic inheritance IInterface* base = _baseType; while( base ) { if( base == _myType ) CORAL_THROW( IllegalStateException, "cyclic inheritance detected'" ); base = base->getBaseType(); } _myType->updateSuperTypes(); // check for member clashes, considering all super types IInterface* type = _myType; Range<IInterface* const> superTypes = type->getSuperTypes(); while( 1 ) { Range<IMember* const> members = type->getMembers(); for( ; members; members.popFirst() ) checkForMemberClashes( members.getFirst() ); if( !superTypes ) break; type = superTypes.getFirst(); superTypes.popFirst(); } }