Files
carbon-lang/executable_semantics/ast/function_definition.cpp
T
Jon Meow ef785bb6e3 Refactor FunctionDefinition towards instance methods (#654)
It felt weird to have a `Make` method in this case.
2021-07-15 14:55:44 -07:00

26 lines
667 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "executable_semantics/ast/function_definition.h"
#include <iostream>
namespace Carbon {
void FunctionDefinition::PrintDepth(int depth) const {
std::cout << "fn " << name << " ";
PrintExp(param_pattern);
std::cout << " -> ";
PrintExp(return_type);
if (body) {
std::cout << " {" << std::endl;
PrintStatement(body, depth);
std::cout << std::endl << "}" << std::endl;
} else {
std::cout << ";" << std::endl;
}
}
} // namespace Carbon