GetBaseClass() 공개 메소드

public GetBaseClass ( ) : AggregateType
리턴 AggregateType
예제 #1
0
파일: SymbolLoader.cs 프로젝트: jnm2/corefx
        private bool HasAnyBaseInterfaceConversion(CType pDerived, CType pBase)
        {
            if (!pBase.isInterfaceType())
            {
                return(false);
            }
            if (!pDerived.IsAggregateType())
            {
                return(false);
            }
            AggregateType atsDer = pDerived.AsAggregateType();

            while (atsDer != null)
            {
                TypeArray ifacesAll = atsDer.GetIfacesAll();
                for (int i = 0; i < ifacesAll.Count; i++)
                {
                    if (HasInterfaceConversion(ifacesAll[i].AsAggregateType(), pBase.AsAggregateType()))
                    {
                        return(true);
                    }
                }
                atsDer = atsDer.GetBaseClass();
            }
            return(false);
        }
예제 #2
0
        private bool IsBaseClass(CType pDerived, CType pBase)
        {
            Debug.Assert(pDerived != null);
            Debug.Assert(pBase != null);
            // A base class has got to be a class. The derived type might be a struct.

            if (!(pBase is AggregateType atsBase && atsBase.isClassType()))
            {
                return(false);
            }
            if (pDerived is NullableType derivedNub)
            {
                pDerived = derivedNub.GetAts();
            }

            if (!(pDerived is AggregateType atsDer))
            {
                return(false);
            }

            AggregateType atsCur = atsDer.GetBaseClass();

            while (atsCur != null)
            {
                if (atsCur == atsBase)
                {
                    return(true);
                }
                atsCur = atsCur.GetBaseClass();
            }
            return(false);
        }
예제 #3
0
파일: SymbolLoader.cs 프로젝트: jnm2/corefx
        private bool IsBaseInterface(CType pDerived, CType pBase)
        {
            Debug.Assert(pDerived != null);
            Debug.Assert(pBase != null);
            if (!pBase.isInterfaceType())
            {
                return(false);
            }
            if (!pDerived.IsAggregateType())
            {
                return(false);
            }
            AggregateType atsDer = pDerived.AsAggregateType();

            while (atsDer != null)
            {
                TypeArray ifacesAll = atsDer.GetIfacesAll();
                for (int i = 0; i < ifacesAll.Count; i++)
                {
                    if (AreTypesEqualForConversion(ifacesAll[i], pBase))
                    {
                        return(true);
                    }
                }
                atsDer = atsDer.GetBaseClass();
            }
            return(false);
        }
예제 #4
0
        private static IEnumerable <AggregateType> TypeAndBaseClasses(this AggregateType type)
        {
            Debug.Assert(type != null);
            AggregateType t = type;

            while (t != null)
            {
                yield return(t);

                t = t.GetBaseClass();
            }
        }
예제 #5
0
파일: SymbolLoader.cs 프로젝트: jnm2/corefx
        private bool IsBaseClass(CType pDerived, CType pBase)
        {
            Debug.Assert(pDerived != null);
            Debug.Assert(pBase != null);
            // A base class has got to be a class. The derived type might be a struct.

            if (!pBase.isClassType())
            {
                return(false);
            }
            if (pDerived.IsNullableType())
            {
                pDerived = pDerived.AsNullableType().GetAts(ErrorContext);
                if (pDerived == null)
                {
                    return(false);
                }
            }

            if (!pDerived.IsAggregateType())
            {
                return(false);
            }

            AggregateType atsDer  = pDerived.AsAggregateType();
            AggregateType atsBase = pBase.AsAggregateType();
            AggregateType atsCur  = atsDer.GetBaseClass();

            while (atsCur != null)
            {
                if (atsCur == atsBase)
                {
                    return(true);
                }
                atsCur = atsCur.GetBaseClass();
            }
            return(false);
        }
예제 #6
0
            private bool FindNextTypeForInstanceMethods()
            {
                // Otherwise, search through other types listed as well as our base class.
                if (_pContainingTypes.Count > 0)
                {
                    if (_nCurrentTypeCount >= _pContainingTypes.Count)
                    {
                        // No more types to check.
                        _pCurrentType = null;
                    }
                    else
                    {
                        _pCurrentType = _pContainingTypes[_nCurrentTypeCount++] as AggregateType;
                    }
                }
                else
                {
                    // We have no more types to consider, so check out the base class.

                    _pCurrentType = _pCurrentType.GetBaseClass();
                }
                return(_pCurrentType != null);
            }
예제 #7
0
            private bool FindNextTypeForInstanceMethods()
            {
                // Otherwise, search through other types listed as well as our base class.
                if (m_pContainingTypes.size > 0)
                {
                    if (m_nCurrentTypeCount >= m_pContainingTypes.size)
                    {
                        // No more types to check.
                        m_pCurrentType = null;
                    }
                    else
                    {
                        m_pCurrentType = m_pContainingTypes.Item(m_nCurrentTypeCount++).AsAggregateType();
                    }
                }
                else
                {
                    // We have no more types to consider, so check out the base class.

                    m_pCurrentType = m_pCurrentType.GetBaseClass();
                }
                return(m_pCurrentType != null);
            }
예제 #8
0
        private static bool IsBaseInterface(AggregateType atsDer, AggregateType pBase)
        {
            Debug.Assert(atsDer != null);
            Debug.Assert(pBase != null);
            if (pBase.isInterfaceType())
            {
                while (atsDer != null)
                {
                    TypeArray ifacesAll = atsDer.GetIfacesAll();
                    for (int i = 0; i < ifacesAll.Count; i++)
                    {
                        if (AreTypesEqualForConversion(ifacesAll[i], pBase))
                        {
                            return(true);
                        }
                    }

                    atsDer = atsDer.GetBaseClass();
                }
            }

            return(false);
        }
예제 #9
0
        /******************************************************************************
        *   Lookup in a class and its bases (until *ptypeEnd is hit).
        *
        *   ptypeEnd [in/out] - *ptypeEnd should be either null or object. If we find
        *       something here that would hide members of object, this sets *ptypeEnd
        *       to null.
        *
        *   Returns true when searching should continue to the interfaces.
        ******************************************************************************/
        private bool LookupInClass(AggregateType typeStart, ref AggregateType ptypeEnd)
        {
            Debug.Assert(!_swtFirst || _fMulti);
            Debug.Assert(typeStart != null && !typeStart.isInterfaceType() && (ptypeEnd == null || typeStart != ptypeEnd));

            AggregateType typeEnd = ptypeEnd;
            AggregateType typeCur;

            // Loop through types. Loop until we hit typeEnd (object or null).
            for (typeCur = typeStart; typeCur != typeEnd && typeCur != null; typeCur = typeCur.GetBaseClass())
            {
                Debug.Assert(!typeCur.isInterfaceType());

                bool fHideByName = false;

                SearchSingleType(typeCur, out fHideByName);
                _flags &= ~MemLookFlags.TypeVarsAllowed;

                if (_swtFirst && !_fMulti)
                {
                    // Everything below this type and in interfaces is hidden.
                    return(false);
                }

                if (fHideByName)
                {
                    // This hides everything below it and in object, but not in the interfaces!
                    ptypeEnd = null;

                    // Return true to indicate that it's ok to search additional types.
                    return(true);
                }

                if ((_flags & MemLookFlags.Ctor) != 0)
                {
                    // If we're looking for a constructor, don't check base classes or interfaces.
                    return(false);
                }
            }

            Debug.Assert(typeCur == typeEnd);
            return(true);
        }
예제 #10
0
        public AggregateType GetAggregate(AggregateSymbol agg, AggregateType atsOuter, TypeArray typeArgs)
        {
            Debug.Assert(agg.GetTypeManager() == this);
            Debug.Assert(atsOuter == null || atsOuter.getAggregate() == agg.Parent, "");

            if (typeArgs == null)
            {
                typeArgs = BSYMMGR.EmptyTypeArray();
            }

            Debug.Assert(agg.GetTypeVars().Count == typeArgs.Count);

            Name name = _BSymmgr.GetNameFromPtrs(typeArgs, atsOuter);

            Debug.Assert(name != null);

            AggregateType pAggregate = _typeTable.LookupAggregate(name, agg);

            if (pAggregate == null)
            {
                pAggregate = _typeFactory.CreateAggregateType(
                    name,
                    agg,
                    typeArgs,
                    atsOuter
                    );

                Debug.Assert(!pAggregate.fConstraintsChecked && !pAggregate.fConstraintError);

                pAggregate.SetErrors(false);
                _typeTable.InsertAggregate(name, agg, pAggregate);

                // If we have a generic type definition, then we need to set the
                // base class to be our current base type, and use that to calculate
                // our agg type and its base, then set it to be the generic version of the
                // base type. This is because:
                //
                // Suppose we have Foo<T> : IFoo<T>
                //
                // Initially, the BaseType will be IFoo<Foo.T>, which gives us the substitution
                // that we want to use for our agg type's base type. However, in the Symbol chain,
                // we want the base type to be IFoo<IFoo.T>. Thats why we need to do this little trick.
                //
                // If we don't have a generic type definition, then we just need to set our base
                // class. This is so that if we have a base type that's generic, we'll be
                // getting the correctly instantiated base type.

                var baseType = pAggregate.AssociatedSystemType?.BaseType;
                if (baseType != null)
                {
                    // Store the old base class.

                    AggregateType oldBaseType = agg.GetBaseClass();
                    agg.SetBaseClass(_symbolTable.GetCTypeFromType(baseType) as AggregateType);
                    pAggregate.GetBaseClass(); // Get the base type for the new agg type we're making.

                    agg.SetBaseClass(oldBaseType);
                }
            }
            else
            {
                Debug.Assert(!pAggregate.HasErrors());
            }

            Debug.Assert(pAggregate.getAggregate() == agg);
            Debug.Assert(pAggregate.GetTypeArgsThis() != null && pAggregate.GetTypeArgsAll() != null);
            Debug.Assert(pAggregate.GetTypeArgsThis() == typeArgs);

            return(pAggregate);
        }
예제 #11
0
        /******************************************************************************
            Lookup in a class and its bases (until *ptypeEnd is hit).
            
            ptypeEnd [in/out] - *ptypeEnd should be either null or object. If we find
                something here that would hide members of object, this sets *ptypeEnd
                to null.
         
            Returns true when searching should continue to the interfaces.
        ******************************************************************************/
        private bool LookupInClass(AggregateType typeStart, ref AggregateType ptypeEnd)
        {
            Debug.Assert(!_swtFirst || _fMulti);
            Debug.Assert(typeStart != null && !typeStart.isInterfaceType() && (ptypeEnd == null || typeStart != ptypeEnd));

            AggregateType typeEnd = ptypeEnd;
            AggregateType typeCur;

            // Loop through types. Loop until we hit typeEnd (object or null).
            for (typeCur = typeStart; typeCur != typeEnd && typeCur != null; typeCur = typeCur.GetBaseClass())
            {
                Debug.Assert(!typeCur.isInterfaceType());

                bool fHideByName = false;

                SearchSingleType(typeCur, out fHideByName);
                _flags &= ~MemLookFlags.TypeVarsAllowed;

                if (_swtFirst && !_fMulti)
                {
                    // Everything below this type and in interfaces is hidden.
                    return false;
                }

                if (fHideByName)
                {
                    // This hides everything below it and in object, but not in the interfaces!
                    ptypeEnd = null;

                    // Return true to indicate that it's ok to search additional types.
                    return true;
                }

                if ((_flags & MemLookFlags.Ctor) != 0)
                {
                    // If we're looking for a constructor, don't check base classes or interfaces.
                    return false;
                }
            }

            Debug.Assert(typeCur == typeEnd);
            return true;
        }