Example #1
0
        private void doReflect()
        {
            // if the ftype is non-null, that means it was passed in non-hollow
            // ftype (in-memory compile), otherwise we need to read it from the pod
            if (m_ftype.m_hollow)
            {
                try
                {
                    m_ftype.read();
                }
                catch (IOException e)
                {
                    Err.dumpStack(e);
                    throw IOErr.make("Cannot read " + m_qname + " from pod", e).val;
                }
            }

            // these are working accumulators used to build the
            // data structures of my defined and inherited slots
            List      slots       = new List(Sys.SlotType, 64);
            Hashtable nameToSlot  = new Hashtable(); // String -> Slot
            Hashtable nameToIndex = new Hashtable(); // String -> Long

            // merge in base class and mixin classes
            for (int i = 0; i < m_mixins.sz(); i++)
            {
                merge((Type)m_mixins.get(i), slots, nameToSlot, nameToIndex);
            }
            merge(m_base, slots, nameToSlot, nameToIndex);

            // merge in all my slots
            FPod  fpod  = this.m_pod.fpod;
            FType ftype = this.m_ftype;

            for (int i = 0; i < ftype.m_fields.Length; i++)
            {
                Field f = map(fpod, ftype.m_fields[i]);
                merge(f, slots, nameToSlot, nameToIndex);
            }
            for (int i = 0; i < ftype.m_methods.Length; i++)
            {
                Method m = map(fpod, ftype.m_methods[i]);
                merge(m, slots, nameToSlot, nameToIndex);
            }

            // break out into fields and methods
            List fields  = new List(Sys.FieldType, slots.sz());
            List methods = new List(Sys.MethodType, slots.sz());

            for (int i = 0; i < slots.sz(); i++)
            {
                Slot slot = (Slot)slots.get(i);
                if (slot is Field)
                {
                    fields.add(slot);
                }
                else
                {
                    methods.add(slot);
                }
            }
            this.m_slots       = slots.trim();
            this.m_fields      = fields.trim();
            this.m_methods     = methods.trim();
            this.m_slotsByName = nameToSlot;
            this.m_facets      = Facets.mapFacets(m_pod, ftype.m_attrs.m_facets);

            // facets
            this.m_lineNum    = m_ftype.m_attrs.m_lineNum;
            this.m_sourceFile = m_ftype.m_attrs.m_sourceFile;
        }