mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Refactor FunctionDefinition towards instance methods (#654)
It felt weird to have a `Make` method in this case.
This commit is contained in:
@@ -11,6 +11,19 @@
|
||||
namespace Carbon {
|
||||
|
||||
struct FunctionDefinition {
|
||||
FunctionDefinition() = default;
|
||||
FunctionDefinition(int line_num, std::string name,
|
||||
const Expression* param_pattern,
|
||||
const Expression* return_type, const Statement* body)
|
||||
: line_num(line_num),
|
||||
name(std::move(name)),
|
||||
param_pattern(param_pattern),
|
||||
return_type(return_type),
|
||||
body(body) {}
|
||||
|
||||
void Print() const { PrintDepth(-1); }
|
||||
void PrintDepth(int depth) const;
|
||||
|
||||
int line_num;
|
||||
std::string name;
|
||||
const Expression* param_pattern;
|
||||
@@ -18,12 +31,6 @@ struct FunctionDefinition {
|
||||
const Statement* body;
|
||||
};
|
||||
|
||||
auto MakeFunDef(int line_num, std::string name, const Expression* ret_type,
|
||||
const Expression* param, const Statement* body)
|
||||
-> FunctionDefinition;
|
||||
void PrintFunDef(const FunctionDefinition&);
|
||||
void PrintFunDefDepth(const FunctionDefinition&, int);
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
#endif // EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
|
||||
|
||||
Reference in New Issue
Block a user