Program: Remove deprecated function methods

Fixup all usages

Bug: tint:390
Change-Id: I949235908e50702d6c8b2e7e2299594879653e01
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38547
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2021-01-26 16:57:10 +00:00
parent 1b3d6e460c
commit 83158f214f
34 changed files with 250 additions and 256 deletions

View File

@ -50,7 +50,7 @@ Inspector::~Inspector() = default;
std::vector<EntryPoint> Inspector::GetEntryPoints() {
std::vector<EntryPoint> result;
for (auto* func : program_.Functions()) {
for (auto* func : program_.AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -283,7 +283,7 @@ std::vector<ResourceBinding> Inspector::GetMultisampledTextureResourceBindings(
}
ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
auto* func = program_.Functions().Find(program_.GetSymbol(name));
auto* func = program_.AST().Functions().Find(program_.GetSymbol(name));
if (!func) {
error_ += name + " was not found!";
return nullptr;

View File

@ -701,7 +701,7 @@ TEST_F(InspectorGetEntryPointTest, NoFunctions) {
}
TEST_F(InspectorGetEntryPointTest, NoEntryPoints) {
mod->Functions().Add(MakeEmptyBodyFunction("foo", {}));
mod->AST().Functions().Add(MakeEmptyBodyFunction("foo", {}));
auto result = inspector()->GetEntryPoints();
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -714,7 +714,7 @@ TEST_F(InspectorGetEntryPointTest, OneEntryPoint) {
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
// TODO(dsinclair): Update to run the namer transform when available.
@ -732,13 +732,13 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) {
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto* bar = MakeEmptyBodyFunction(
"bar", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(bar);
mod->AST().Functions().Add(bar);
// TODO(dsinclair): Update to run the namer transform when available.
@ -756,21 +756,21 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) {
TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) {
auto* func = MakeEmptyBodyFunction("func", {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto* bar = MakeCallerBodyFunction(
"bar", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(bar);
mod->AST().Functions().Add(bar);
// TODO(dsinclair): Update to run the namer transform when available.
@ -792,7 +792,7 @@ TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto result = inspector()->GetEntryPoints();
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -811,7 +811,7 @@ TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) {
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
create<ast::WorkgroupDecoration>(8u, 2u, 1u),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto result = inspector()->GetEntryPoints();
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -826,14 +826,14 @@ TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) {
TEST_F(InspectorGetEntryPointTest, NoInOutVariables) {
auto* func = MakeEmptyBodyFunction("func", {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto result = inspector()->GetEntryPoints();
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -851,7 +851,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointInOutVariables) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -875,14 +875,14 @@ TEST_F(InspectorGetEntryPointTest, FunctionInOutVariables) {
auto* func =
MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -906,14 +906,14 @@ TEST_F(InspectorGetEntryPointTest, RepeatedInOutVariables) {
auto* func =
MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeInOutVariableCallerBodyFunction(
"foo", "func", {{"in_var", "out_var"}},
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -940,7 +940,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointMultipleInOutVariables) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -970,14 +970,14 @@ TEST_F(InspectorGetEntryPointTest, FunctionMultipleInOutVariables) {
auto* func = MakeInOutVariableBodyFunction(
"func", {{"in_var", "out_var"}, {"in2_var", "out2_var"}}, {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1011,14 +1011,14 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto* bar = MakeInOutVariableBodyFunction(
"bar", {{"in2_var", "out_var"}},
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(bar);
mod->AST().Functions().Add(bar);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1057,21 +1057,21 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) {
auto* func =
MakeInOutVariableBodyFunction("func", {{"in2_var", "out2_var"}}, {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeInOutVariableCallerBodyFunction(
"foo", "func", {{"in_var", "out_var"}},
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto* bar = MakeCallerBodyFunction(
"bar", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(bar);
mod->AST().Functions().Add(bar);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1123,14 +1123,14 @@ TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) {
ast::VariableDecorationList{create<ast::LocationDecoration>(0)}));
auto* func =
MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* foo = MakeCallerBodyFunction(
"foo", "func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1162,7 +1162,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoFunctions) {
// TODO(rharrison): Reenable once GetRemappedNameForEntryPoint isn't a pass
// through
TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoEntryPoints) {
mod->Functions().Add(MakeEmptyBodyFunction("foo", {}));
mod->AST().Functions().Add(MakeEmptyBodyFunction("foo", {}));
auto result = inspector()->GetRemappedNameForEntryPoint("foo");
ASSERT_TRUE(inspector()->has_error());
@ -1177,7 +1177,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_OneEntryPoint) {
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
// TODO(dsinclair): Update to run the namer transform when available.
@ -1195,7 +1195,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest,
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
// TODO(dsinclair): Update to run the namer transform when available.
@ -1203,7 +1203,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest,
"bar", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(bar);
mod->AST().Functions().Add(bar);
{
auto result = inspector()->GetRemappedNameForEntryPoint("foo");
@ -1321,14 +1321,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
{{0, ty.i32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "ub_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1349,14 +1349,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) {
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
{{0, ty.i32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "ub_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1374,14 +1374,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
{{0, ty.i32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "ub_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1403,14 +1403,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
auto* ub_func = MakeStructVariableReferenceBodyFunction(
"ub_func", "foo_ub", {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "ub_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1436,7 +1436,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
const std::string& var_name) {
auto* ub_func = MakeStructVariableReferenceBodyFunction(
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
};
AddReferenceFunc("ub_foo_func", "ub_foo");
AddReferenceFunc("ub_bar_func", "ub_bar");
@ -1454,7 +1454,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1484,14 +1484,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
{{0, ty.i32}});
mod->Functions().Add(ub_func);
mod->AST().Functions().Add(ub_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "ub_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1513,14 +1513,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1542,14 +1542,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
auto* sb_func = MakeStructVariableReferenceBodyFunction(
"sb_func", "foo_sb", {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1575,7 +1575,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
const std::string& var_name) {
auto* sb_func = MakeStructVariableReferenceBodyFunction(
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
};
AddReferenceFunc("sb_foo_func", "sb_foo");
AddReferenceFunc("sb_bar_func", "sb_bar");
@ -1596,7 +1596,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1626,14 +1626,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1655,14 +1655,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1684,14 +1684,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1709,14 +1709,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1744,7 +1744,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
const std::string& var_name) {
auto* sb_func = MakeStructVariableReferenceBodyFunction(
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
};
AddReferenceFunc("sb_foo_func", "sb_foo");
AddReferenceFunc("sb_bar_func", "sb_bar");
@ -1765,7 +1765,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1796,14 +1796,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1827,14 +1827,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1857,14 +1857,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
{{0, ty.i32}});
mod->Functions().Add(sb_func);
mod->AST().Functions().Add(sb_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "sb_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1886,7 +1886,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1903,7 +1903,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
"ep_func", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1922,14 +1922,14 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
auto* foo_func = MakeSamplerReferenceBodyFunction(
"foo_func", "foo_texture", "foo_sampler", "foo_coords", ty.f32, {});
mod->Functions().Add(foo_func);
mod->AST().Functions().Add(foo_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "foo_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1953,7 +1953,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1973,7 +1973,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -1995,7 +1995,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2012,7 +2012,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
"ep_func", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2032,14 +2032,14 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
auto* foo_func = MakeComparisonSamplerReferenceBodyFunction(
"foo_func", "foo_texture", "foo_sampler", "foo_coords", "foo_depth",
ty.f32, {});
mod->Functions().Add(foo_func);
mod->AST().Functions().Add(foo_func);
auto* ep_func = MakeCallerBodyFunction(
"ep_func", "foo_func",
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(ep_func);
mod->AST().Functions().Add(ep_func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2063,7 +2063,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2083,7 +2083,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2098,7 +2098,7 @@ TEST_F(InspectorGetSampledTextureResourceBindingsTest, Empty) {
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto result = inspector()->GetSampledTextureResourceBindings("foo");
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -2121,7 +2121,7 @@ TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2212,7 +2212,7 @@ TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2283,7 +2283,7 @@ TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();
@ -2338,7 +2338,7 @@ TEST_F(InspectorGetMultisampledArrayTextureResourceBindingsTest, Empty) {
"foo", ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(foo);
mod->AST().Functions().Add(foo);
auto result = inspector()->GetSampledTextureResourceBindings("foo");
ASSERT_FALSE(inspector()->has_error()) << inspector()->error();
@ -2363,7 +2363,7 @@ TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td()->Determine()) << td()->error();

View File

@ -118,14 +118,6 @@ class Program {
return types_.Get<T>(std::forward<ARGS>(args)...);
}
/// @returns the functions declared in the translation unit
/// [DEPRECATED]: Use AST().Functions()
const ast::FunctionList& Functions() const { return AST().Functions(); }
/// @returns the functions declared in the translation unit
/// [DEPRECATED]: Use AST().Functions()
ast::FunctionList& Functions() { return AST().Functions(); }
/// Returns all the declared types in the program
/// [DEPRECATED]: Use AST().Types().types()
/// @returns the mapping from name string to type.

View File

@ -31,7 +31,7 @@ namespace {
using ProgramTest = ast::TestHelper;
TEST_F(ProgramTest, Creation) {
EXPECT_EQ(mod->Functions().size(), 0u);
EXPECT_EQ(mod->AST().Functions().size(), 0u);
}
TEST_F(ProgramTest, ToStrEmitsPreambleAndPostamble) {
@ -90,12 +90,12 @@ TEST_F(ProgramTest, IsValid_Function) {
auto* func = Func("main", ast::VariableList(), ty.f32, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(mod->IsValid());
}
TEST_F(ProgramTest, IsValid_Null_Function) {
mod->Functions().Add(nullptr);
mod->AST().Functions().Add(nullptr);
EXPECT_FALSE(mod->IsValid());
}
@ -103,7 +103,7 @@ TEST_F(ProgramTest, IsValid_Invalid_Function) {
auto* func = Func("main", ast::VariableList{}, nullptr, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_FALSE(mod->IsValid());
}

View File

@ -859,7 +859,7 @@ bool FunctionEmitter::Emit() {
auto& statements = statements_stack_[0].GetStatements();
auto* body = create<ast::BlockStatement>(Source{}, statements);
program_.Functions().Add(create<ast::Function>(
program_.AST().Functions().Add(create<ast::Function>(
decl.source, program_.RegisterSymbol(decl.name), std::move(decl.params),
decl.return_type, body, std::move(decl.decorations)));

View File

@ -378,7 +378,7 @@ Expect<bool> ParserImpl::expect_global_decl() {
if (func.errored)
errored = true;
if (func.matched) {
program_.Functions().Add(func.value);
program_.AST().Functions().Add(func.value);
return true;
}

View File

@ -135,8 +135,8 @@ TEST_F(ParserImplTest, GlobalDecl_Function) {
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
ASSERT_EQ(m.Functions().size(), 1u);
EXPECT_EQ(m.SymbolToName(m.Functions()[0]->symbol()), "main");
ASSERT_EQ(m.AST().Functions().size(), 1u);
EXPECT_EQ(m.SymbolToName(m.AST().Functions()[0]->symbol()), "main");
}
TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) {
@ -145,8 +145,8 @@ TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) {
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
ASSERT_EQ(m.Functions().size(), 1u);
EXPECT_EQ(m.SymbolToName(m.Functions()[0]->symbol()), "main");
ASSERT_EQ(m.AST().Functions().size(), 1u);
EXPECT_EQ(m.SymbolToName(m.AST().Functions()[0]->symbol()), "main");
}
TEST_F(ParserImplTest, GlobalDecl_Function_Invalid) {

View File

@ -40,7 +40,7 @@ fn main() -> void {
ASSERT_TRUE(p->Parse()) << p->error();
auto& m = p->get_program();
ASSERT_EQ(1u, m.Functions().size());
ASSERT_EQ(1u, m.AST().Functions().size());
ASSERT_EQ(1u, m.AST().GlobalVariables().size());
}

View File

@ -42,7 +42,7 @@ fn main() -> void {
ASSERT_TRUE(p.Parse()) << p.error();
auto m = p.program();
ASSERT_EQ(1u, m.Functions().size());
ASSERT_EQ(1u, m.AST().Functions().size());
ASSERT_EQ(1u, m.AST().GlobalVariables().size());
}

View File

@ -41,7 +41,7 @@ EmitVertexPointSize::~EmitVertexPointSize() = default;
Transform::Output EmitVertexPointSize::Run(const Program* in) {
Output out;
if (!in->Functions().HasStage(ast::PipelineStage::kVertex)) {
if (!in->AST().Functions().HasStage(ast::PipelineStage::kVertex)) {
// If the module doesn't have any vertex stages, then there's nothing to do.
out.program = in->Clone();
return out;

View File

@ -85,7 +85,7 @@ Transform::Output VertexPulling::Run(const Program* in) {
}
// Find entry point
auto* func = in->Functions().Find(in->GetSymbol(cfg.entry_point_name),
auto* func = in->AST().Functions().Find(in->GetSymbol(cfg.entry_point_name),
ast::PipelineStage::kVertex);
if (func == nullptr) {
diag::Diagnostic err;

View File

@ -126,13 +126,13 @@ bool TypeDeterminer::Determine() {
}
}
if (!DetermineFunctions(program_->Functions())) {
if (!DetermineFunctions(program_->AST().Functions())) {
return false;
}
// Walk over the caller to callee information and update functions with which
// entry points call those functions.
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -404,7 +404,7 @@ bool TypeDeterminer::DetermineCall(ast::CallExpression* expr) {
caller_to_callee_[current_function_->symbol()].push_back(
ident->symbol());
auto* callee_func = program_->Functions().Find(ident->symbol());
auto* callee_func = program_->AST().Functions().Find(ident->symbol());
if (callee_func == nullptr) {
set_error(expr->source(),
"unable to find called function: " +

View File

@ -292,7 +292,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call) {
ast::VariableList params;
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -319,14 +319,14 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
create<ast::ReturnStatement>(),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func_main);
mod->AST().Functions().Add(func_main);
auto* func = Func("func", params0, ty.f32,
ast::StatementList{
create<ast::ReturnStatement>(),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_FALSE(td()->Determine()) << td()->error();
EXPECT_EQ(td()->error(),
@ -472,7 +472,7 @@ TEST_F(TypeDeterminerTest, Expr_Call) {
ast::VariableList params;
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -487,7 +487,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) {
ast::VariableList params;
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -626,7 +626,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
TEST_F(TypeDeterminerTest, Expr_Identifier_Function) {
auto* func = Func("my_func", ast::VariableList{}, ty.f32,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -665,7 +665,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -702,7 +702,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* func2 = Func(
"func", ast::VariableList{}, ty.f32,
@ -711,7 +711,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func2);
mod->AST().Functions().Add(func2);
// Register the function
EXPECT_TRUE(td()->Determine());
@ -736,7 +736,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* v = Var("var", ast::StorageClass::kFunction, ty.f32);
td()->RegisterVariableForTesting(v);
@ -1589,7 +1589,7 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
auto* func = Func("func", ast::VariableList{}, ty.i32,
ast::StatementList{stmt}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_EQ(var->storage_class(), ast::StorageClass::kFunction);
@ -1601,7 +1601,7 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
auto* func = Func("func", ast::VariableList{}, ty.i32,
ast::StatementList{stmt}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_EQ(var->storage_class(), ast::StorageClass::kNone);
@ -1614,7 +1614,7 @@ TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) {
auto* func = Func("func", ast::VariableList{}, ty.i32,
ast::StatementList{stmt}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_FALSE(td()->Determine());
EXPECT_EQ(td()->error(),
@ -2760,11 +2760,11 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func_b);
mod->Functions().Add(func_c);
mod->Functions().Add(func_a);
mod->Functions().Add(ep_1);
mod->Functions().Add(ep_2);
mod->AST().Functions().Add(func_b);
mod->AST().Functions().Add(func_c);
mod->AST().Functions().Add(func_a);
mod->AST().Functions().Add(ep_1);
mod->AST().Functions().Add(ep_2);
mod->AST().AddGlobalVariable(
Var("first", ast::StorageClass::kPrivate, ty.f32));

View File

@ -49,7 +49,7 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -68,7 +68,7 @@ TEST_F(ValidateFunctionTest,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -89,7 +89,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
create<ast::VariableDeclStatement>(var),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -105,7 +105,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
auto* func =
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
ty.i32, ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -127,13 +127,14 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->DetermineFunctions(mod->Functions())) << td()->error();
EXPECT_TRUE(td()->DetermineFunctions(mod->AST().Functions()))
<< td()->error();
ValidatorImpl& v = Build();
EXPECT_TRUE(v.ValidateFunctions(mod->Functions())) << v.error();
EXPECT_TRUE(v.ValidateFunctions(mod->AST().Functions())) << v.error();
}
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
@ -144,7 +145,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
Source{Source::Location{12, 34}}, Expr(2)),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -165,7 +166,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
Source{Source::Location{12, 34}}, Expr(2)),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -194,8 +195,8 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->Functions().Add(func_copy);
mod->AST().Functions().Add(func);
mod->AST().Functions().Add(func_copy);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -217,7 +218,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
create<ast::ReturnStatement>(),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func0);
mod->AST().Functions().Add(func0);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -241,7 +242,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
create<ast::ReturnStatement>(Expr(2)),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func0);
mod->AST().Functions().Add(func0);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -263,7 +264,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
ValidatorImpl& v = Build();
@ -288,7 +289,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
ValidatorImpl& v = Build();
@ -313,7 +314,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
ValidatorImpl& v = Build();
@ -335,7 +336,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -351,7 +352,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
create<ast::ReturnStatement>(),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();

View File

@ -71,10 +71,10 @@ bool ValidatorImpl::Validate() {
if (!ValidateConstructedTypes(program_->AST().ConstructedTypes())) {
return false;
}
if (!ValidateFunctions(program_->Functions())) {
if (!ValidateFunctions(program_->AST().Functions())) {
return false;
}
if (!ValidateEntryPoint(program_->Functions())) {
if (!ValidateEntryPoint(program_->AST().Functions())) {
return false;
}
function_stack_.pop_scope();

View File

@ -394,7 +394,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
Source{Source::Location{12, 34}}, lhs, rhs),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ValidatorImpl& v = Build();
@ -423,7 +423,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -582,7 +582,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error();
@ -612,7 +612,7 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error();
@ -711,8 +711,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func0);
mod->Functions().Add(func1);
mod->AST().Functions().Add(func0);
mod->AST().Functions().Add(func1);
EXPECT_TRUE(td()->Determine()) << td()->error();

View File

@ -172,7 +172,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
EXPECT_TRUE(td()->Determine()) << td()->error();
@ -197,7 +197,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) {
create<ast::ReturnStatement>(),
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* main =
Func("main", ast::VariableList{}, ty.void_,
@ -207,7 +207,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(main);
mod->AST().Functions().Add(main);
EXPECT_TRUE(td()->Determine()) << td()->error();

View File

@ -160,7 +160,7 @@ bool GeneratorImpl::Generate(std::ostream& out) {
std::unordered_set<Symbol> emitted_globals;
// Make sure all entry point data is emitted before the entry point functions
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -170,13 +170,13 @@ bool GeneratorImpl::Generate(std::ostream& out) {
}
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!EmitFunction(out, func)) {
return false;
}
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -631,7 +631,7 @@ bool GeneratorImpl::EmitCall(std::ostream& pre,
name = it->second;
}
auto* func = program_->Functions().Find(ident->symbol());
auto* func = program_->AST().Functions().Find(ident->symbol());
if (func == nullptr) {
error_ =
"Unable to find function: " + program_->SymbolToName(ident->symbol());

View File

@ -507,7 +507,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
auto* func = Func("foo", ast::VariableList{}, ty.void_, ast::StatementList{},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ast::ExpressionList params;
params.push_back(create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd,

View File

@ -34,7 +34,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -47,7 +47,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -60,7 +60,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();

View File

@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -123,7 +123,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -176,7 +176,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -229,7 +229,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -279,7 +279,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -324,7 +324,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;
@ -377,7 +377,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
std::unordered_set<Symbol> globals;

View File

@ -59,7 +59,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -80,7 +80,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -105,7 +105,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -169,7 +169,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -325,7 +325,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -378,7 +378,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -431,7 +431,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -481,7 +481,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -528,7 +528,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -582,7 +582,7 @@ TEST_F(
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* func_1 = Func(
"ep_1", ast::VariableList{}, ty.void_,
@ -594,7 +594,7 @@ TEST_F(
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -646,7 +646,7 @@ TEST_F(HlslGeneratorImplTest_Function,
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* func_1 =
Func("ep_1", ast::VariableList{}, ty.void_,
@ -659,7 +659,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -715,7 +715,7 @@ TEST_F(
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* func_1 =
Func("ep_1", ast::VariableList{}, ty.void_,
@ -728,7 +728,7 @@ TEST_F(
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -779,7 +779,7 @@ TEST_F(HlslGeneratorImplTest_Function,
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
Call("sub_func", 1.0f), ast::VariableDecorationList{});
@ -794,7 +794,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -839,7 +839,7 @@ TEST_F(HlslGeneratorImplTest_Function,
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
Call("sub_func", 1.0f), ast::VariableDecorationList{});
@ -854,7 +854,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -902,7 +902,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -933,7 +933,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -956,7 +956,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -983,7 +983,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::WorkgroupDecoration>(2u, 4u, 6u),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -1008,7 +1008,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -1071,7 +1071,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
{
@ -1088,7 +1088,7 @@ TEST_F(HlslGeneratorImplTest_Function,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -30,7 +30,7 @@ using HlslGeneratorImplTest = TestHelper;
TEST_F(HlslGeneratorImplTest, Generate) {
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();

View File

@ -138,7 +138,7 @@ bool GeneratorImpl::Generate() {
}
// Make sure all entry point data is emitted before the entry point functions
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -148,13 +148,13 @@ bool GeneratorImpl::Generate() {
}
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!EmitFunction(func)) {
return false;
}
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!func->IsEntryPoint()) {
continue;
}
@ -525,7 +525,7 @@ bool GeneratorImpl::EmitCall(ast::CallExpression* expr) {
name = it->second;
}
auto* func = program_->Functions().Find(ident->symbol());
auto* func = program_->AST().Functions().Find(ident->symbol());
if (func == nullptr) {
error_ =
"Unable to find function: " + program_->SymbolToName(ident->symbol());

View File

@ -35,7 +35,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
auto* call = Call("my_func");
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -47,7 +47,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
auto* call = Call("my_func", "param1", "param2");
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -59,7 +59,7 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
auto* call = Call("my_func", "param1", "param2");
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{}, ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
auto* expr = create<ast::CallStatement>(call);

View File

@ -71,7 +71,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -119,7 +119,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) {
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -167,7 +167,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -215,7 +215,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -260,7 +260,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) {
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -300,7 +300,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) {
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -345,7 +345,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -62,7 +62,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -85,7 +85,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -112,7 +112,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -134,7 +134,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_NoReturn_Void) {
ast::FunctionDecorationList{create<ast::StageDecoration>(
ast::PipelineStage::kFragment)});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kFragment)});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -223,7 +223,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
ast::FunctionDecorationList{create<ast::StageDecoration>(
ast::PipelineStage::kFragment)});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -278,7 +278,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -323,7 +323,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -374,7 +374,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -428,7 +428,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -483,7 +483,7 @@ TEST_F(
auto* sub_func =
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
body = ast::StatementList{
create<ast::AssignmentStatement>(Expr("bar"), Call("sub_func", 1.0f)),
@ -495,7 +495,7 @@ TEST_F(
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -547,7 +547,7 @@ TEST_F(MslGeneratorImplTest,
},
ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto body = ast::StatementList{
create<ast::AssignmentStatement>(Expr("depth"), Call("sub_func", 1.0f)),
@ -560,7 +560,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -616,7 +616,7 @@ TEST_F(
auto* sub_func =
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
body = ast::StatementList{
create<ast::AssignmentStatement>(Expr("depth"), Call("sub_func", 1.0f)),
@ -628,7 +628,7 @@ TEST_F(
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -674,7 +674,7 @@ TEST_F(MslGeneratorImplTest,
auto* sub_func =
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
ast::ExpressionList expr;
expr.push_back(Expr(1.0f));
@ -692,7 +692,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -741,7 +741,7 @@ TEST_F(MslGeneratorImplTest,
auto* sub_func =
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
Call("sub_func", 1.0f), ast::VariableDecorationList{});
@ -756,7 +756,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -810,7 +810,7 @@ TEST_F(MslGeneratorImplTest,
auto* sub_func =
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
mod->Functions().Add(sub_func);
mod->AST().Functions().Add(sub_func);
ast::ExpressionList expr;
expr.push_back(Expr(1.0f));
@ -828,7 +828,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
ASSERT_TRUE(td.Determine()) << td.error();
@ -881,7 +881,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(func_1);
mod->AST().Functions().Add(func_1);
ASSERT_TRUE(td.Determine()) << td.error();
@ -914,7 +914,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -938,7 +938,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
},
ast::FunctionDecorationList{});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();
@ -1004,7 +1004,7 @@ TEST_F(MslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
{
@ -1018,7 +1018,7 @@ TEST_F(MslGeneratorImplTest,
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute)});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Generate) {
ast::FunctionDecorationList{
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
GeneratorImpl& gen = Build();

View File

@ -303,7 +303,7 @@ bool Builder::Build() {
}
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!GenerateFunction(func)) {
return false;
}

View File

@ -261,7 +261,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
{
@ -278,7 +278,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -4165,7 +4165,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) {
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
});
mod->Functions().Add(main);
mod->AST().Functions().Add(main);
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -101,7 +101,7 @@ bool GeneratorImpl::Generate() {
out_ << std::endl;
}
for (auto* func : program_->Functions()) {
for (auto* func : program_->AST().Functions()) {
if (!EmitFunction(func)) {
return false;
}
@ -113,7 +113,8 @@ bool GeneratorImpl::Generate() {
bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage,
const std::string& name) {
auto* func = program_->Functions().Find(program_->GetSymbol(name), stage);
auto* func =
program_->AST().Functions().Find(program_->GetSymbol(name), stage);
if (func == nullptr) {
error_ = "Unable to find requested entry point: " + name;
return false;
@ -152,7 +153,7 @@ bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage,
out_ << std::endl;
}
for (auto* f : program_->Functions()) {
for (auto* f : program_->AST().Functions()) {
if (!f->HasAncestorEntryPoint(program_->GetSymbol(name))) {
continue;
}

View File

@ -212,7 +212,7 @@ TEST_F(WgslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
{
@ -231,7 +231,7 @@ TEST_F(WgslGeneratorImplTest,
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
});
mod->Functions().Add(func);
mod->AST().Functions().Add(func);
}
ASSERT_TRUE(td.Determine()) << td.error();

View File

@ -30,7 +30,7 @@ namespace {
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Generate) {
mod->Functions().Add(Func("my_func", ast::VariableList{}, ty.void_,
mod->AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_,
ast::StatementList{},
ast::FunctionDecorationList{}));