function_definition.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
  5. #define EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
  6. #include "common/ostream.h"
  7. #include "executable_semantics/ast/expression.h"
  8. #include "executable_semantics/ast/statement.h"
  9. namespace Carbon {
  10. struct FunctionDefinition {
  11. FunctionDefinition() = default;
  12. FunctionDefinition(int line_num, std::string name,
  13. const Expression* param_pattern,
  14. const Expression* return_type, const Statement* body)
  15. : line_num(line_num),
  16. name(std::move(name)),
  17. param_pattern(param_pattern),
  18. return_type(return_type),
  19. body(body) {}
  20. void Print(llvm::raw_ostream& out) const { PrintDepth(-1, out); }
  21. void PrintDepth(int depth, llvm::raw_ostream& out) const;
  22. int line_num;
  23. std::string name;
  24. const Expression* param_pattern;
  25. const Expression* return_type;
  26. const Statement* body;
  27. };
  28. } // namespace Carbon
  29. #endif // EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_