ast/function: Remove [set|add]_decorations()

Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-07 20:45:14 +00:00
committed by Commit Bot service account
parent 9838768599
commit 234b7de460
32 changed files with 1154 additions and 698 deletions

View File

@@ -92,8 +92,9 @@ class BoundArrayAccessorsTest : public testing::Test {
struct ModuleBuilder : public ast::BuilderWithModule {
ModuleBuilder() : body_(create<ast::BlockStatement>()) {
mod->AddFunction(
create<ast::Function>("func", ast::VariableList{}, ty.void_, body_));
mod->AddFunction(create<ast::Function>(Source{}, "func",
ast::VariableList{}, ty.void_, body_,
ast::FunctionDecorationList{}));
}
ast::Module Module() {

View File

@@ -59,18 +59,22 @@ TEST_F(EmitVertexPointSizeTest, VertexStageBasic) {
tint::ast::StorageClass::kFunction, ty.f32)));
mod->AddFunction(
create<ast::Function>("non_entry_a", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{})));
create<ast::Function>(Source{}, "non_entry_a", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{}));
auto* entry =
create<ast::Function>("entry", ast::VariableList{}, ty.void_, block);
entry->set_decorations({create<ast::StageDecoration>(
ast::PipelineStage::kVertex, Source{})});
auto* entry = create<ast::Function>(
Source{}, "entry", ast::VariableList{}, ty.void_, block,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex,
Source{}),
});
mod->AddFunction(entry);
mod->AddFunction(
create<ast::Function>("non_entry_b", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{})));
create<ast::Function>(Source{}, "non_entry_b", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{}));
}
};
@@ -120,19 +124,22 @@ TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) {
struct Builder : ModuleBuilder {
void Build() override {
mod->AddFunction(
create<ast::Function>("non_entry_a", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{})));
auto* entry =
create<ast::Function>("entry", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{}));
entry->set_decorations({create<ast::StageDecoration>(
ast::PipelineStage::kVertex, Source{})});
mod->AddFunction(entry);
create<ast::Function>(Source{}, "non_entry_a", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{}));
mod->AddFunction(
create<ast::Function>("non_entry_b", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{})));
create<ast::Function>(Source{}, "entry", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{
create<ast::StageDecoration>(
ast::PipelineStage::kVertex, Source{}),
}));
mod->AddFunction(
create<ast::Function>(Source{}, "non_entry_b", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{}));
}
};
@@ -174,18 +181,22 @@ TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) {
TEST_F(EmitVertexPointSizeTest, NonVertexStage) {
struct Builder : ModuleBuilder {
void Build() override {
auto* fragment_entry =
create<ast::Function>("fragment_entry", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{}));
fragment_entry->set_decorations({create<ast::StageDecoration>(
ast::PipelineStage::kFragment, Source{})});
auto* fragment_entry = create<ast::Function>(
Source{}, "fragment_entry", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment,
Source{}),
});
mod->AddFunction(fragment_entry);
auto* compute_entry =
create<ast::Function>("compute_entry", ast::VariableList{}, ty.void_,
create<ast::BlockStatement>(Source{}));
compute_entry->set_decorations({create<ast::StageDecoration>(
ast::PipelineStage::kCompute, Source{})});
create<ast::Function>(Source{}, "compute_entry", ast::VariableList{},
ty.void_, create<ast::BlockStatement>(Source{}),
ast::FunctionDecorationList{
create<ast::StageDecoration>(
ast::PipelineStage::kCompute, Source{}),
});
mod->AddFunction(compute_entry);
}
};

View File

@@ -46,11 +46,11 @@ class VertexPullingHelper {
// Create basic module with an entry point and vertex function
void InitBasicModule() {
auto* func = create<ast::Function>("main", ast::VariableList{},
mod_->create<ast::type::Void>(),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}));
auto* func = create<ast::Function>(
Source{}, "main", ast::VariableList{}, mod_->create<ast::type::Void>(),
create<ast::BlockStatement>(),
ast::FunctionDecorationList{create<ast::StageDecoration>(
ast::PipelineStage::kVertex, Source{})});
mod()->AddFunction(func);
}
@@ -128,11 +128,12 @@ TEST_F(VertexPullingTest, Error_InvalidEntryPoint) {
}
TEST_F(VertexPullingTest, Error_EntryPointWrongStage) {
auto* func = create<ast::Function>("main", ast::VariableList{},
mod()->create<ast::type::Void>(),
create<ast::BlockStatement>());
func->add_decoration(
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}));
auto* func = create<ast::Function>(
Source{}, "main", ast::VariableList{}, mod()->create<ast::type::Void>(),
create<ast::BlockStatement>(),
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment, Source{}),
});
mod()->AddFunction(func);
InitTransform({});