CodeType ICodeTypeInitializer.GetInstance(GetInstanceInfo instanceInfo) => GetInstance(new InstanceAnonymousTypeLinker(GenericTypes, instanceInfo.Generics));
public static CodeType GetCodeTypeFromContext(ITypeContextError errorHandler, ParseInfo parseInfo, Scope scope, ITypeContextHandler typeContext) { if (typeContext == null) { return(parseInfo.TranslateInfo.Types.Any()); } CodeType type; if (typeContext.IsDefault) { if (typeContext.Infer) { parseInfo.Script.Diagnostics.Hint("Unable to infer type", typeContext.Identifier.Range); } type = parseInfo.TranslateInfo.Types.Any(); } else { var providers = scope.TypesFromName(typeContext.Identifier.GetText()); // No types found. if (providers.Length == 0) { errorHandler.Nonexistent(); return(parseInfo.TranslateInfo.Types.GetInstance <AnyType>()); } var fallback = providers[0]; // Used when no types match. // Match generics. providers = providers.Where(t => t.GenericsCount == typeContext.TypeArgs.Count).ToArray(); if (providers.Length == 0) // No types match the generics count. { // Add the error. errorHandler.IncorrectTypeArgsCount(fallback); // Return the fallback. return(fallback.GetInstance()); } // TODO: Check ambiguities var provider = providers[0]; // Get the type arguments. var typeArgs = GetAndValidateTypeArgs(parseInfo, scope, provider.GenericTypes, typeContext.TypeArgs); var instanceInfo = new GetInstanceInfo(typeArgs); // Track the type args being used. parseInfo.Script.Elements.AddTypeArgCall(new TypeArgCall(provider, typeArgs)); // Create the type instance and call it. type = provider.GetInstance(instanceInfo); type.Call(parseInfo, typeContext.Identifier.Range); } for (int i = 0; i < typeContext.ArrayCount; i++) { type = new ArrayType(parseInfo.TranslateInfo.Types, type); } return(type); }
public override CodeType GetInstance(GetInstanceInfo instanceInfo) => Instance;
public CodeType GetInstance(GetInstanceInfo instanceInfo) => _type;
public abstract CodeType GetInstance(GetInstanceInfo instanceInfo);
public override CodeType GetInstance(GetInstanceInfo instanceInfo) => new DefinedClass(_parseInfo, this, instanceInfo.Generics);