pattern_binding.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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 CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_H_
  6. #include "common/ostream.h"
  7. #include "toolchain/parser/parse_tree.h"
  8. #include "toolchain/semantics/meta_node.h"
  9. #include "toolchain/semantics/nodes/declared_name.h"
  10. namespace Carbon::Semantics {
  11. // Represents `name: type`.
  12. class PatternBinding {
  13. public:
  14. PatternBinding(ParseTree::Node node, DeclaredName name, Expression type)
  15. : node_(node), name_(name), type_(type) {}
  16. auto node() const -> ParseTree::Node { return node_; }
  17. auto name() const -> const DeclaredName& { return name_; }
  18. auto type() const -> const Expression& { return type_; }
  19. private:
  20. ParseTree::Node node_;
  21. DeclaredName name_;
  22. Expression type_;
  23. };
  24. } // namespace Carbon::Semantics
  25. #endif // CARBON_TOOLCHAIN_SEMANTICS_NODES_PATTERN_BINDING_H_