expression_statement.h 966 B

12345678910111213141516171819202122232425262728293031
  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_EXPRESSION_STATEMENT_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_NODES_EXPRESSION_STATEMENT_H_
  6. #include "common/ostream.h"
  7. #include "toolchain/parser/parse_tree.h"
  8. #include "toolchain/semantics/meta_node.h"
  9. namespace Carbon::Semantics {
  10. // Represents a statement that is only an expression, such as `Call()`.
  11. class ExpressionStatement {
  12. public:
  13. static constexpr StatementKind MetaNodeKind =
  14. StatementKind::ExpressionStatement;
  15. explicit ExpressionStatement(Expression expression)
  16. : expression_(expression) {}
  17. auto expression() const -> Expression { return expression_; }
  18. private:
  19. Expression expression_;
  20. };
  21. } // namespace Carbon::Semantics
  22. #endif // CARBON_TOOLCHAIN_SEMANTICS_NODES_EXPRESSION_STATEMENT_H_