ast: Add body parameter to ast::Function constructors

In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: Iddb5605b9bc0de80ad2710ced0e429f89410af2f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32675
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-14 01:13:04 +00:00
committed by Commit Bot service account
parent 9a31c641e2
commit b29b09fba6
28 changed files with 545 additions and 567 deletions

View File

@@ -646,7 +646,8 @@ bool FunctionEmitter::EmitFunctionDeclaration() {
}
auto ast_fn =
std::make_unique<ast::Function>(name, std::move(ast_params), ret_ty);
std::make_unique<ast::Function>(name, std::move(ast_params), ret_ty,
std::make_unique<ast::BlockStatement>());
if (ep_info_ != nullptr) {
ast_fn->add_decoration(

View File

@@ -1231,8 +1231,9 @@ Maybe<std::unique_ptr<ast::Function>> ParserImpl::function_header() {
if (errored)
return Failure::kErrored;
return std::make_unique<ast::Function>(source, name.value,
std::move(params.value), type.value);
return std::make_unique<ast::Function>(
source, name.value, std::move(params.value), type.value,
std::make_unique<ast::BlockStatement>());
}
// param_list