function_definition.cpp 667 B

12345678910111213141516171819202122232425
  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. #include "executable_semantics/ast/function_definition.h"
  5. #include <iostream>
  6. namespace Carbon {
  7. void FunctionDefinition::PrintDepth(int depth) const {
  8. std::cout << "fn " << name << " ";
  9. PrintExp(param_pattern);
  10. std::cout << " -> ";
  11. PrintExp(return_type);
  12. if (body) {
  13. std::cout << " {" << std::endl;
  14. PrintStatement(body, depth);
  15. std::cout << std::endl << "}" << std::endl;
  16. } else {
  17. std::cout << ";" << std::endl;
  18. }
  19. }
  20. } // namespace Carbon