Пример #1
0
        void SetupMRO(P6how k)
        {
            foreach (MethodInfo m in k.lmethods)
            {
                DispatchEnt de;
                if ((m.flags & V_MASK) != V_PUBLIC)
                {
                    continue;
                }
                string n = m.Name();
                inherit_methods.TryGetValue(n, out de);
                inherit_methods[n] = new DispatchEnt(de, m.impl);
            }

            foreach (DispatchSet ds in k.here_protos)
            {
                List <MethodInfo> cands;
                if (!multimethods.TryGetValue(ds, out cands))
                {
                    cands = new List <MethodInfo>();
                }
                P6any[] cl = new P6any[cands.Count];
                for (int ix = 0; ix < cl.Length; ix++)
                {
                    cl[ix] = cands[ix].impl;
                }
                P6any       disp = Kernel.MakeDispatcher(ds.name, ds.proto, cl);
                DispatchEnt de;
                inherit_methods.TryGetValue(ds.name, out de);
                inherit_methods[ds.name] = new DispatchEnt(de, disp);
            }
        }
Пример #2
0
        internal static P6how Thaw(ThawBuffer tb)
        {
            P6how n = new P6how();

            tb.Register(n);
            n.stable = (STable)tb.ObjRef();
            int state = tb.Byte();

            n.isComposing = state >= 1;
            n.isComposed  = state >= 2;
            n.rtype       = tb.String();
            n.type        =
                n.rtype == "package" ? P6how.PACKAGE :
                n.rtype == "module" ? P6how.MODULE :
                n.rtype == "class" ? P6how.CLASS :
                n.rtype == "grammar" ? P6how.GRAMMAR :
                n.rtype == "role" ? P6how.ROLE :
                n.rtype == "prole" ? P6how.PARAMETRIZED_ROLE :
                n.rtype == "subset" ? P6how.SUBSET :
                n.rtype == "crole" ? P6how.CURRIED_ROLE :
                -1;
            n.roleFactory      = (P6any)tb.ObjRef();
            n.subsetWhereThunk = (P6any)tb.ObjRef();
            n.subsetFilter     = (Variable)tb.ObjRef();
            n.curriedArgs      = tb.RefsA <Variable>();
            n.rolePun          = tb.ObjRef();

            int mcount = tb.Int();

            while (mcount-- > 0)
            {
                MethodInfo mi = default(MethodInfo);
                mi.short_name = tb.String();
                mi.long_name  = tb.String();
                mi.impl       = (P6any)tb.ObjRef();
                mi.flags      = tb.Byte();
                n.lmethods.Add(mi);
            }

            int acount = tb.Int();

            while (acount-- > 0)
            {
                AttrInfo ai = default(AttrInfo);
                ai.name  = tb.String();
                ai.init  = (P6any)tb.ObjRef();
                ai.flags = tb.Byte();
                ai.type  = (STable)tb.ObjRef();
                n.local_attr.Add(ai);
            }

            n.superclasses        = tb.RefsL <STable>();
            n.local_roles         = tb.RefsL <STable>();
            n.role_typecheck_list = tb.RefsL <STable>();
            n.mro = tb.RefsA <STable>();
            tb.PushFixup(n);
            return(n);
        }
Пример #3
0
        internal static P6how Thaw(ThawBuffer tb)
        {
            P6how n = new P6how();

            tb.Register(n);
            n.stable = (STable)tb.ObjRef();
            int state = tb.Byte();

            n.isComposing      = state >= 1;
            n.isComposed       = state >= 2;
            n.rtype            = tb.String();
            n.isRole           = n.rtype == "role" || n.rtype == "prole";
            n.isSubset         = n.rtype == "subset";
            n.isPackage        = n.rtype == "package";
            n.roleFactory      = (P6any)tb.ObjRef();
            n.subsetWhereThunk = (P6any)tb.ObjRef();
            n.subsetFilter     = (Variable)tb.ObjRef();

            // local_does not yet used
            int mcount = tb.Int();

            while (mcount-- > 0)
            {
                MethodInfo mi = default(MethodInfo);
                mi.short_name = tb.String();
                mi.long_name  = tb.String();
                mi.impl       = (P6any)tb.ObjRef();
                mi.flags      = tb.Byte();
                n.lmethods.Add(mi);
            }

            int acount = tb.Int();

            while (acount-- > 0)
            {
                AttrInfo ai = default(AttrInfo);
                ai.name  = tb.String();
                ai.init  = (P6any)tb.ObjRef();
                ai.flags = tb.Byte();
                ai.type  = (STable)tb.ObjRef();
                n.local_attr.Add(ai);
            }

            n.superclasses = tb.RefsL <STable>();
            n.mro          = tb.RefsA <STable>();
            tb.PushFixup(n);
            return(n);
        }
Пример #4
0
 public STable(string name)
 {
     this.name = name;
     mo        = new P6how();
     mo.stable = this;
 }