public void TryResolveFieldReference(ParserContext context, ResolvedType[] argTypes, VariableScope varScope) { if (this.StaticMethodSource != null) { if (this.StaticMethodSource.CustomType != null) { this.ResolveClassStaticMethodReference(argTypes); } else if (this.StaticMethodSource.FrameworkClass != null) { this.ResolveFrameworkStaticMethodReference(argTypes); } else if (this.StaticMethodSource.PrimitiveType != null) { this.ResolvePrimitiveStaticMethodReference(argTypes); } else { throw new ParserException(this.FirstToken, "Not implemented"); } } else { if (this.RootValue.ResolvedType == null && this.RootValue is VerifiedFieldReference) { this.RootValue.ResolveTypes(context, varScope); } ResolvedType rootType = this.RootValue.ResolvedType; if (this.FileContext.HasLinq && rootType.IsEnumerable(context)) { this.Type = MethodRefType.LINQ; switch (this.Name.Value) { case "OrderBy": { ResolvedType itemType = rootType.GetEnumerableItemType(); ResolvedType functionReturnType = ResolvedType.GetPrimitiveType("object"); // int or string or float or something, but whatever. ResolvedType function = ResolvedType.CreateFunction(functionReturnType, new ResolvedType[] { itemType }); this.ResolvedType = ResolvedType.CreateFunction( ResolvedType.CreateEnumerableType(itemType), new ResolvedType[] { function }); } break; case "ToArray": { ResolvedType itemType = rootType.GetEnumerableItemType(); this.ResolvedType = ResolvedType.CreateFunction( ResolvedType.CreateArray(itemType), new ResolvedType[0]); } break; case "Select": throw new System.NotImplementedException(); case "Where": throw new System.NotImplementedException(); default: this.Type = MethodRefType.UNKNOWN; break; } if (this.Type == MethodRefType.LINQ) { return; } } if (rootType.CustomType != null) { if (argTypes == null) { this.ResolveCustomFieldReference(); } else { this.ResolveCustomMethodReference(argTypes); } } else if (rootType.FrameworkClass != null) { this.ResolveFrameworkMethodReference(argTypes); } else if (rootType.PrimitiveType != null) { this.Type = MethodRefType.PRIMITIVE_METHOD; this.PrimitiveMethod = rootType.PrimitiveType + "." + this.Name.Value; switch (this.PrimitiveMethod) { case "string.ToLowerInvariant": this.ResolvedType = ResolvedType.CreateFunction(ResolvedType.String(), new ResolvedType[0]); break; default: throw new ParserException(this.Name, "string does not have a method called '" + this.Name.Value + "'"); } } else if (rootType.IsArray) { switch (this.Name.Value) { case "Length": this.ResolvedType = ResolvedType.Int(); break; default: throw new ParserException(this.FirstToken, "not implemented"); } } else { throw new ParserException(this.FirstToken, "Not implemented"); } } }