コード例 #1
0
        public static MethodWrapper Make(DynamicType pt, SymbolId name)
        {
            MethodWrapper ret = new MethodWrapper(pt, name);
            object meth;
            if (pt.dict.TryGetValue(name, out meth)) {
                object otherMeth;
                if (!pt.TryLookupSlotInBases(DefaultContext.Default, name, out otherMeth) || otherMeth != meth) {
                    ret.SetDeclaredMethod(meth);
                } else {
                    // they did __foo__ = myBase.__foo__, we'll just ignore it...
                    ret.UpdateFromBases(pt.MethodResolutionOrder);
                }
            } else {
                ret.UpdateFromBases(pt.MethodResolutionOrder);
            }

            //pt.dict[name] = ret; //???

            return ret;
        }
コード例 #2
0
        private static void CheckInitArgs(ICallerContext context, Dict dict, object[] args, DynamicType pt)
        {
            object initMethod;
            if (((args != null && args.Length > 0) || (dict != null && dict.Count > 0)) &&
                (pt.TryGetSlot(context, SymbolTable.Init, out initMethod) ||
                pt.TryLookupSlotInBases(context, SymbolTable.Init, out initMethod)) &&
                initMethod == Init) {

                throw Ops.TypeError("default __new__ does not take parameters");
            }
        }