Пример #1
0
        private void emitMixinRouters(Type type)
        {
            // generate router method for each concrete instance method
            List methods = type.methods();

            for (int i = 0; i < methods.sz(); i++)
            {
                Method m    = (Method)methods.get(i);
                string name = m.name();

                // only emit router for non-abstract instance methods
                if (m.isStatic())
                {
                    continue;
                }
                if (m.isAbstract())
                {
                    // however if abstract, check if a base class
                    // has already implemented this method
                    if (m.parent() == type && parent.slot(name, true).parent() == type)
                    {
                        Type b = parent.@base();
                        while (b != null)
                        {
                            Slot s = b.slot(name, false);
                            if (s != null && s.parent() == b)
                            {
                                new FMethodEmit(this).emitInterfaceRouter(b, m);
                                break;
                            }
                            b = b.@base();
                        }
                    }
                    continue;
                }

                // only emit the router unless this is the exact one I inherit
                if (parent.slot(name, true).parent() != type)
                {
                    continue;
                }

                // do it
                new FMethodEmit(this).emitMixinRouter(m);
            }
        }