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

@@ -52,10 +52,10 @@ class BoundArrayAccessorsTest : public testing::Test {
BoundArrayAccessorsTest() : td_(&ctx_, &mod_), transform_(&ctx_, &mod_) {}
ast::BlockStatement* SetupFunctionAndBody() {
auto func = create<ast::Function>("func", ast::VariableList{}, &void_type_);
auto block = create<ast::BlockStatement>();
body_ = block.get();
func->set_body(std::move(block));
auto func = create<ast::Function>("func", ast::VariableList{}, &void_type_,
std::move(block));
mod_.AddFunction(std::move(func));
return body_;
}

View File

@@ -43,7 +43,8 @@ class VertexPullingTransformHelper {
void InitBasicModule() {
auto func = create<ast::Function>(
"main", ast::VariableList{},
ctx_.type_mgr().Get(std::make_unique<ast::type::VoidType>()));
ctx_.type_mgr().Get(std::make_unique<ast::type::VoidType>()),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage ::kVertex, Source{}));
mod()->AddFunction(std::move(func));
@@ -118,7 +119,8 @@ TEST_F(VertexPullingTransformTest, Error_InvalidEntryPoint) {
TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
auto func = create<ast::Function>(
"main", ast::VariableList{},
ctx()->type_mgr().Get(std::make_unique<ast::type::VoidType>()));
ctx()->type_mgr().Get(std::make_unique<ast::type::VoidType>()),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
mod()->AddFunction(std::move(func));