function_definition.h 1.1 KB

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