semantics_ir_factory.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #ifndef TOOLCHAIN_SEMANTICS_SEMANTICS_IR_FACTORY_H_
  5. #define TOOLCHAIN_SEMANTICS_SEMANTICS_IR_FACTORY_H_
  6. #include <optional>
  7. #include "llvm/ADT/StringMap.h"
  8. #include "toolchain/parser/parse_tree.h"
  9. #include "toolchain/semantics/semantics_ir.h"
  10. namespace Carbon {
  11. // The main semantic analysis entry.
  12. class SemanticsIRFactory {
  13. public:
  14. // Builds the SemanticsIR without doing any substantial semantic analysis.
  15. static auto Build(const ParseTree& parse_tree) -> SemanticsIR;
  16. private:
  17. explicit SemanticsIRFactory(const ParseTree& parse_tree)
  18. : semantics_(parse_tree) {}
  19. // Processes the roots of the ParseTree into semantics_, transitively
  20. // handling children.
  21. void ProcessRoots();
  22. // Turns a function node from the parse tree into a semantic function node,
  23. // adding it to the containing scope.
  24. void ProcessFunctionNode(SemanticsIR::Block& block,
  25. ParseTree::Node decl_node);
  26. SemanticsIR semantics_;
  27. };
  28. } // namespace Carbon
  29. #endif // TOOLCHAIN_SEMANTICS_SEMANTICS_IR_FACTORY_H_