Mono.CSharp.Namespace.LookupType C# (CSharp) Method

LookupType() private method

private LookupType ( string name, int arity ) : System.TypeSpec
name string
arity int
return System.TypeSpec
		TypeSpec LookupType (string name, int arity)
		{
			if (types == null)
				return null;

			IList<TypeSpec> found;
			if (types.TryGetValue (name, out found)) {
				TypeSpec best = null;

				foreach (var ts in found) {
					if (ts.Arity == arity)
						return ts;

					//
					// Lookup for the best candidate with closest arity match
					//
					if (arity < 0) {
						if (best == null) {
							best = ts;
						} else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (best.Arity + arity)) {
							best = ts;
						}
					}
				}
				
				return best;
			}

			return null;
		}

Same methods

Namespace::LookupType ( CompilerContext ctx, string name, int arity, bool silent, Mono.CSharp.Location loc ) : Mono.CSharp.TypeExpr

Usage Example

示例#1
0
        public static TypeSpec Resolve(ModuleContainer module, MemberKind kind, string ns, string name, int arity, Location loc)
        {
            Namespace type_ns = module.GlobalRootNamespace.GetNamespace(ns, true);
            var       te      = type_ns.LookupType(module, name, arity, false, Location.Null);

            if (te == null)
            {
                module.Compiler.Report.Error(518, loc, "The predefined type `{0}.{1}' is not defined or imported", ns, name);
                return(null);
            }

            var type = te.Type;

            if (type.Kind != kind)
            {
                if (type.Kind == MemberKind.Struct && kind == MemberKind.Void && type.MemberDefinition is TypeContainer)
                {
                    // Void is declared as struct but we keep it internally as
                    // special kind, the swap will be done by caller
                }
                else
                {
                    module.Compiler.Report.Error(520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name);
                    return(null);
                }
            }

            return(type);
        }
All Usage Examples Of Mono.CSharp.Namespace::LookupType