Add helper for function creation.

This CL adds a Func helper to the ast builder class. The helper is then
used through the various files to simplify function creation.

Change-Id: Ie93777586e9311d82cff5932dfba2c4ca763ae08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35823
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair
2020-12-16 15:15:40 +00:00
committed by Commit Bot service account
parent 5e5e36e7d2
commit 181d8baf8f
24 changed files with 1186 additions and 1523 deletions

View File

@@ -46,12 +46,10 @@ class VertexPullingHelper : public ast::BuilderWithModule {
// Create basic module with an entry point and vertex function
void InitBasicModule() {
auto* func = create<ast::Function>(
mod->RegisterSymbol("main"), "main", ast::VariableList{},
mod->create<ast::type::Void>(),
create<ast::BlockStatement>(ast::StatementList{}),
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex)});
auto* func =
Func("main", ast::VariableList{}, ty.void_, ast::StatementList{},
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex)});
mod->AddFunction(func);
}
@@ -115,13 +113,11 @@ TEST_F(VertexPullingTest, Error_InvalidEntryPoint) {
}
TEST_F(VertexPullingTest, Error_EntryPointWrongStage) {
auto* func = create<ast::Function>(
mod->RegisterSymbol("main"), "main", ast::VariableList{},
mod->create<ast::type::Void>(),
create<ast::BlockStatement>(ast::StatementList{}),
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
auto* func =
Func("main", ast::VariableList{}, ty.void_, ast::StatementList{},
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->AddFunction(func);
InitTransform({});