public INamedType Find(NameSearchSpace searchSpace, Position position, string name, IEnumerable<IBoundDecl> typeArgs) { // look through the namespaces foreach (var potentialName in searchSpace.SearchFor(name)) { // look for a concrete type var type = Find(potentialName, typeArgs); if (type != null) return type; // look for a generic foreach (var structure in mGenericStructs) { // names must match if (structure.Name != potentialName) continue; // number of type args must match if (typeArgs.Count() != structure.TypeParameters.Count) continue; return structure.Instantiate(mCompiler, typeArgs); } //### bob: gross copy/paste of above // look for a generic foreach (var union in mGenericUnions) { // names must match if (union.Name != potentialName) continue; // number of type args must match if (typeArgs.Count() != union.TypeParameters.Count) continue; return union.Instantiate(mCompiler, typeArgs); } } // not found throw new CompileException(position, "Could not find a type named " + name + "."); }
/// <summary> /// Binds the definition to the name context in which it is defined. /// </summary> /// <param name="searchSpace"></param> public void BindSearchSpace(NameSearchSpace searchSpace) { SearchSpace = searchSpace; }