mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 21:00:14 +01:00
* [executable semantics] class-ify Declaration NFC (no functional change). Proof of concept that we can simplify code by replacing unions with safer, more regular types. Hand-rolled existentials (type-erasing CoW wrappers) are a follow-on step that will further simplify usage. Began adding `const` where possible, and replacing `std::string*` with `std::string`. Most `const`s can disappear as we replace reference semantics with value semantics, but in the meantime it's an important step in the right direction.
29 lines
897 B
C++
29 lines
897 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
|
|
|
|
#ifndef EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
|
|
#define EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
|
|
|
|
#include "executable_semantics/ast/expression.h"
|
|
#include "executable_semantics/ast/statement.h"
|
|
|
|
namespace Carbon {
|
|
|
|
struct FunctionDefinition {
|
|
int line_num;
|
|
std::string name;
|
|
Expression* param_pattern;
|
|
Expression* return_type;
|
|
Statement* body;
|
|
};
|
|
|
|
auto MakeFunDef(int line_num, std::string name, Expression* ret_type,
|
|
Expression* param, Statement* body) -> FunctionDefinition*;
|
|
void PrintFunDef(const FunctionDefinition*);
|
|
void PrintFunDefDepth(const FunctionDefinition*, int);
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // EXECUTABLE_SEMANTICS_AST_FUNCTION_DEFINITION_H_
|