type() public method

public type ( string name ) : Type
name string
return Type
示例#1
0
        //////////////////////////////////////////////////////////////////////////
        // Init Types
        //////////////////////////////////////////////////////////////////////////

        static Type initType(string name)
        {
            try
            {
                return(m_sysPod.type(name, true));
            }
            catch (Exception e)
            {
                throw initFail("type " + name, e);
            }
        }
示例#2
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;
        }
示例#3
0
文件: Fant.cs 项目: nomit007/f4
        private Type[] tests(Pod pod, string testName)
        {
            // named test
              if (testName != "*") return new Type[] { pod.type(testName, true) };

              // all types which subclass Test
              List all = pod.types();
              ArrayList acc = new ArrayList();
              for (int i=0; i<all.sz(); i++)
              {
            Type x = (Type)all.get(i);
            if (x.@is(Sys.TestType) && !x.isAbstract()) acc.Add(x);
              }
              return (Type[])acc.ToArray(System.Type.GetType("Fan.Sys.Type"));
        }
示例#4
0
文件: TypeParser.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Factory
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Parse the signature into a loaded type.
        /// </summary>
        public static Type load(string sig, bool check, Pod loadingPod)
        {
            // if last character is ?, then parse a nullable
              int len = sig.Length;
              int last = len > 1 ? sig[len-1] : 0;
              if (last == '?')
            return load(sig.Substring(0, len-1), check, loadingPod).toNullable();

              // if the last character isn't ] or |, then this a non-generic
              // type and we don't even need to allocate a parser
              if (last != ']' && last != '|')
              {
            string podName, typeName;
            try
            {
              int colon = sig.IndexOf(':');
              if (sig[colon+1] != ':') throw new System.Exception();
              podName  = sig.Substring(0, colon);
              typeName = sig.Substring(colon+2);
              if (podName.Length == 0 || typeName.Length == 0) throw new System.Exception();
            }
            catch (System.Exception)
            {
              throw ArgErr.make("Invalid type signature '" + sig + "', use <pod>::<type>").val;
            }

            // if the type is from the pod being loaded then return to the pod
            if (loadingPod != null && podName == loadingPod.name())
              return loadingPod.type(typeName, check);

            // do a straight lookup
            return find(podName, typeName, check);
              }

              // we got our work cut out for us - create parser
              try
              {
            return new TypeParser(sig, check, loadingPod).LoadTop();
              }
              catch (Err.Val e)
              {
            throw e;
              }
              catch (System.Exception)
              {
            throw Err(sig).val;
              }
        }