Esempio n. 1
0
        internal bool TryLookupSlotInBases(ICallerContext context, SymbolId name, out object ret)
        {
            Tuple resOrder = MethodResolutionOrder;

            for (int i = 1; i < resOrder.Count; i++)    // skip our own type...
            {
                object type = resOrder[i];

                PythonType pt = type as PythonType;
                if (pt != null)
                {
                    if (pt.TryGetSlot(context, name, out ret))
                    {
                        // respect MRO for base class lookups: method wrappers are
                        // logically a member of a super type, but are available on
                        // derived types for quick access.  We only want to return a method
                        // wrapper here if it's actually exposed on our type.

                        MethodWrapper mw = ret as MethodWrapper;
                        if (mw == null || !mw.IsSuperTypeMethod())
                        {
                            return(true);
                        }
                    }
                }
                else if (Ops.TryGetAttr(context, type, name, out ret))
                {
                    return(true);
                }
            }
            ret = null;
            return(false);
        }