mapFacets() public static method

public static mapFacets ( Pod pod, FAttrs ffacets ) : Facets
pod Pod
ffacets Fanx.Fcode.FAttrs
return Facets
Exemplo n.º 1
0
        /// <summary>
        /// Map fcode field to a sys::Field.
        /// </summary>
        private Field map(FPod fpod, FField f)
        {
            string name      = String.Intern(f.m_name);
            Type   fieldType = m_pod.findType(f.m_type);
            Facets facets    = Facets.mapFacets(m_pod, f.m_attrs.m_facets);

            return(new Field(this, name, f.m_flags, facets, f.m_attrs.m_lineNum, fieldType));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Map fcode method to a sys::Method.
        /// </summary>
        private Method map(FPod fpod, FMethod m)
        {
            string name                = String.Intern(m.m_name);
            Type   returnType          = m_pod.findType(m.m_ret);
            Type   inheritedReturnType = m_pod.findType(m.m_inheritedRet);
            List   pars                = new List(Sys.ParamType, m.m_paramCount);

            for (int j = 0; j < m.m_paramCount; j++)
            {
                FMethodVar p      = m.m_vars[j];
                int        pflags = (p.def == null) ? 0 : Param.HAS_DEFAULT;
                pars.add(new Param(String.Intern(p.name), m_pod.findType(p.type), pflags));
            }
            Facets facets = Facets.mapFacets(m_pod, m.m_attrs.m_facets);

            return(new Method(this, name, m.m_flags, facets, m.m_attrs.m_lineNum, returnType, inheritedReturnType, pars));
        }
Exemplo n.º 3
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;
        }