Files
carbon-lang/toolchain/check/handle_namespace.cpp
T
Jon Ross-Perkins 1d6298290f Add more value store types to File. (#3317)
Finishing what #3316 started, add more bespoke ValueStore-like
structures to File. With this, the things which previously had somewhat
boilerplate Add/Get functions are now all on side classes, giving a
uniform style of API for calling.

Note, I was on the fence about making things public on ValueStore. If
it's preferred that I make some things there protected I certainly can,
there's just a trade-off that may mean more distinct child/wrapper
types.
2023-10-24 18:23:40 +00:00

26 lines
888 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/check/context.h"
#include "toolchain/sem_ir/node.h"
namespace Carbon::Check {
auto HandleNamespaceStart(Context& context, Parse::Node /*parse_node*/)
-> bool {
context.declaration_name_stack().Push();
return true;
}
auto HandleNamespace(Context& context, Parse::Node parse_node) -> bool {
auto name_context = context.declaration_name_stack().Pop();
auto namespace_id = context.AddNode(SemIR::Namespace{
parse_node, context.GetBuiltinType(SemIR::BuiltinKind::NamespaceType),
context.semantics_ir().name_scopes().Add()});
context.declaration_name_stack().AddNameToLookup(name_context, namespace_id);
return true;
}
} // namespace Carbon::Check