semantics_handle_namespace.cpp 950 B

12345678910111213141516171819202122232425
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/semantics/semantics_context.h"
  5. #include "toolchain/semantics/semantics_node.h"
  6. namespace Carbon {
  7. auto SemanticsHandleNamespaceStart(SemanticsContext& context,
  8. ParseTree::Node /*parse_node*/) -> bool {
  9. context.declaration_name_stack().Push();
  10. return true;
  11. }
  12. auto SemanticsHandleNamespace(SemanticsContext& context,
  13. ParseTree::Node parse_node) -> bool {
  14. auto name_context = context.declaration_name_stack().Pop();
  15. auto namespace_id = context.AddNode(SemanticsNode::Namespace::Make(
  16. parse_node, context.semantics_ir().AddNameScope()));
  17. context.declaration_name_stack().AddNameToLookup(name_context, namespace_id);
  18. return true;
  19. }
  20. } // namespace Carbon