Fan.Sys.Sys.genericParamType C# (CSharp) Method

genericParamType() public static method

public static genericParamType ( string name ) : Type
name string
return Type
        public static Type genericParamType(string name)
        {
            if (name.Length == 1 && name[0] < m_genericParamTypes.Length)
            return m_genericParamTypes[name[0]];
              else
            return null;
        }

Usage Example

Example #1
0
        /*
         * synchronized Class emit()
         * {
         * if (cls == null)
         *  cls = FPodEmit.emitAndLoad(fpod);
         * return cls;
         * }
         *
         * synchronized void precompiled(Class cls)
         * throws Exception
         * {
         * this.cls = cls;
         * FPodEmit.initFields(fpod, cls);
         * }
         */

        internal Type findType(int qname)
        {
            if (qname == 0xFFFF || qname == -1)
            {
                return(null);
            }

            // lookup type with typeRef index
            FTypeRef reference = fpod.typeRef(qname);

            // if generic instance, then this type must be used in a method
            // signature, not type meta-data (b/c I can't subclass generic types),
            // so it's safe that my pod has been loaded and is now registered (in
            // case the generic type is parameterized via types in my pod)
            if (reference.isGenericInstance())
            {
                return(TypeParser.load(reference.signature, true, this));
            }

            // otherwise I need to handle if I am loading my own pod, because
            // I might not yet be added to the system namespace if I'm just
            // loading my own hollow types
            string podName  = reference.podName;
            string typeName = reference.typeName;
            Pod    pod      = podName == m_name ? this : doFind(podName, true, null);
            Type   type     = pod.type(typeName, false);

            if (type != null)
            {
                if (reference.isNullable())
                {
                    type = type.toNullable();
                }
                return(type);
            }

            // handle generic parameter types (for sys pod only)
            if (m_name == "sys")
            {
                type = Sys.genericParamType(typeName);
                if (type != null)
                {
                    if (reference.isNullable())
                    {
                        type = type.toNullable();
                    }
                    return(type);
                }
            }

            // lost cause
            throw UnknownTypeErr.make(podName + "::" + typeName).val;
        }