protected void doReflect() { // ensure master type is reflected Type master = m_base; master.finish(); List masterSlots = master.slots(); // allocate slot data structures m_fields = new List(Sys.FieldType, master.fields().sz()); m_methods = new List(Sys.MethodType, master.methods().sz()); m_slots = new List(Sys.SlotType, masterSlots.sz()); m_slotsByName = new Hashtable(masterSlots.sz() * 3); // parameterize master's slots for (int i = 0; i < masterSlots.sz(); i++) { Slot slot = (Slot)masterSlots.get(i); if (slot is Method) { slot = parameterize((Method)slot); m_methods.add(slot); } else { slot = parameterize((Field)slot); m_fields.add(slot); } m_slots.add(slot); m_slotsByName[slot.m_name] = slot; } }
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); } }
private Method[] methods(Type type, string methodName) { // named test if (methodName != "*") return new Method[] { type.method(methodName, true) }; // all methods which start with "test" List all = type.methods(); ArrayList acc = new ArrayList(); for (int i=0; i<all.sz(); i++) { Method m = (Method)all.get(i); if (m.name().StartsWith("test") && !m.isAbstract()) acc.Add(m); } return (Method[])acc.ToArray(System.Type.GetType("Fan.Sys.Method")); }