Lines Matching refs:name

17 std::vector<T> EnsureNonempty(std::vector<T> list, const std::string& name,
20 ReportError("there is no ", kind, " named ", name);
26 T EnsureUnique(const std::vector<T>& list, const Name& name, const char* kind) {
28 ReportError("there is no ", kind, " named ", name);
31 ReportError("ambiguous reference to ", kind, " ", name);
37 void CheckAlreadyDeclared(const std::string& name, const char* new_type) {
39 FilterDeclarables<T>(Declarations::TryLookupShallow(QualifiedName(name)));
42 ReportError("cannot redeclare ", name, " (type ", *new_type, scope, ")");
49 const QualifiedName& name) {
51 GlobalContext::GetDefaultNamespace()->Lookup(name);
54 s << "cannot find \"" << name << "\" in global scope";
60 const TypeAlias* Declarations::LookupTypeAlias(const QualifiedName& name) {
62 EnsureUnique(FilterDeclarables<TypeAlias>(Lookup(name)), name, "type");
66 const Type* Declarations::LookupType(const QualifiedName& name) {
67 return LookupTypeAlias(name)->type();
70 const Type* Declarations::LookupType(const Identifier* name) {
71 const TypeAlias* alias = LookupTypeAlias(QualifiedName(name->value));
73 LanguageServerData::AddDefinition(name->pos,
80 const QualifiedName& name) {
81 auto decls = FilterDeclarables<TypeAlias>(TryLookup(name));
83 return EnsureUnique(std::move(decls), name, "type")->type();
86 const Type* Declarations::LookupGlobalType(const QualifiedName& name) {
88 FilterDeclarables<TypeAlias>(LookupGlobalScope(name)), name, "type");
107 Value* Declarations::LookupValue(const QualifiedName& name) {
108 return EnsureUnique(FilterDeclarables<Value>(Lookup(name)), name, "value");
111 Macro* Declarations::TryLookupMacro(const std::string& name,
113 std::vector<Macro*> macros = TryLookup<Macro>(QualifiedName(name));
124 const QualifiedName& name) {
125 std::vector<Builtin*> builtins = TryLookup<Builtin>(name);
127 return EnsureUnique(builtins, name.name, "builtin");
131 const std::string& name) {
133 FilterDeclarables<GenericCallable>(Lookup(QualifiedName(name))), name,
137 GenericCallable* Declarations::LookupUniqueGeneric(const QualifiedName& name) {
138 return EnsureUnique(FilterDeclarables<GenericCallable>(Lookup(name)), name,
142 GenericType* Declarations::LookupUniqueGenericType(const QualifiedName& name) {
143 return EnsureUnique(FilterDeclarables<GenericType>(Lookup(name)), name,
148 const std::string& name) {
150 FilterDeclarables<GenericType>(LookupGlobalScope(QualifiedName(name))),
151 name, "generic type");
155 const QualifiedName& name) {
156 std::vector<GenericType*> results = TryLookup<GenericType>(name);
158 return EnsureUnique(results, name.name, "generic type");
161 Namespace* Declarations::DeclareNamespace(const std::string& name) {
162 return Declare(name, std::make_unique<Namespace>(name));
165 TypeAlias* Declarations::DeclareType(const Identifier* name, const Type* type) {
166 CheckAlreadyDeclared<TypeAlias>(name->value, "type");
167 return Declare(name->value, std::unique_ptr<TypeAlias>(
168 new TypeAlias(type, true, name->pos)));
171 TypeAlias* Declarations::PredeclareTypeAlias(const Identifier* name,
174 CheckAlreadyDeclared<TypeAlias>(name->value, "type");
176 new TypeAlias(type, redeclaration, name->pos));
177 return Declare(name->value, std::move(alias_ptr));
193 std::string name, std::string external_assembler_name,
196 new ExternMacro(std::move(name), std::move(external_assembler_name),
201 const std::string& name, bool accessible_from_csa,
206 TryLookupMacro(name, signature.GetExplicitTypes())) {
208 ReportError("cannot redeclare macro ", name,
215 CreateExternMacro(name, std::move(*external_assembler_name), signature);
217 macro = CreateTorqueMacro(name, name, accessible_from_csa, signature, body,
221 Declare(name, macro);
224 ReportError("cannot redeclare operator ", name,
233 const std::string& name, Signature signature,
236 "Method_" + container_type->SimpleName() + "_" + name);
238 container_type, generated_name, name, std::move(signature), body)));
243 Intrinsic* Declarations::CreateIntrinsic(const std::string& name,
246 new Intrinsic(std::move(name), std::move(signature))));
250 Intrinsic* Declarations::DeclareIntrinsic(const std::string& name,
252 Intrinsic* result = CreateIntrinsic(std::move(name), std::move(signature));
253 Declare(name, result);
267 Builtin* Declarations::DeclareBuiltin(const std::string& name,
272 CheckAlreadyDeclared<Builtin>(name, "builtin");
273 return Declare(name, CreateBuiltin(name, name, kind, signature, body));
277 const std::string& name, const Signature& signature) {
278 CheckAlreadyDeclared<RuntimeFunction>(name, "runtime function");
279 return Declare(name, RegisterDeclarable(std::unique_ptr<RuntimeFunction>(
280 new RuntimeFunction(name, signature))));
283 ExternConstant* Declarations::DeclareExternConstant(Identifier* name,
286 CheckAlreadyDeclared<Value>(name->value, "constant");
287 return Declare(name->value, std::unique_ptr<ExternConstant>(
288 new ExternConstant(name, type, value)));
291 NamespaceConstant* Declarations::DeclareNamespaceConstant(Identifier* name,
294 CheckAlreadyDeclared<Value>(name->value, "constant");
295 std::string external_name = GlobalContext::MakeUniqueName(name->value);
297 new NamespaceConstant(name, std::move(external_name), type, body));
299 Declare(name->value, std::move(namespaceConstant));
304 const std::string& name, GenericCallableDeclaration* ast_node) {
305 return Declare(name, std::unique_ptr<GenericCallable>(
306 new GenericCallable(name, ast_node)));
310 const std::string& name, GenericTypeDeclaration* ast_node) {
311 return Declare(name,
312 std::unique_ptr<GenericType>(new GenericType(name, ast_node)));
316 const std::string& name, const TypeVector& specialized_types) {
317 std::string result = name;
324 Macro* Declarations::DeclareOperator(const std::string& name, Macro* m) {
325 GlobalContext::GetDefaultNamespace()->AddDeclarable(name, m);