[shuffle] Move glsl writer to new structure.
This CL moves the `glsl/ast_writer` to `glsl/writer/ast_printer/` and
renames the `GeneratorImpl` to `ASTPrinter`.
Bug: tint:1988
Change-Id: Ieaf6b67885e942abb853c68777e9547e93ff98dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/143141
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/include/tint/tint.h b/include/tint/tint.h
index 77cd7ab..be6270f 100644
--- a/include/tint/tint.h
+++ b/include/tint/tint.h
@@ -60,7 +60,7 @@
#endif // TINT_BUILD_HLSL_WRITER
#if TINT_BUILD_GLSL_WRITER
-#include "src/tint/lang/glsl/ast_writer/generator.h"
+#include "src/tint/lang/glsl/writer/writer.h"
#endif // TINT_BUILD_GLSL_WRITER
namespace tint {
diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp
index d541f0b..d0ca586 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.cpp
+++ b/src/dawn/native/opengl/ShaderModuleGL.cpp
@@ -45,12 +45,12 @@
UNREACHABLE();
}
-tint::writer::glsl::Version::Standard ToTintGLStandard(opengl::OpenGLVersion::Standard standard) {
+tint::glsl::writer::Version::Standard ToTintGLStandard(opengl::OpenGLVersion::Standard standard) {
switch (standard) {
case opengl::OpenGLVersion::Standard::Desktop:
- return tint::writer::glsl::Version::Standard::kDesktop;
+ return tint::glsl::writer::Version::Standard::kDesktop;
case opengl::OpenGLVersion::Standard::ES:
- return tint::writer::glsl::Version::Standard::kES;
+ return tint::glsl::writer::Version::Standard::kES;
}
UNREACHABLE();
}
@@ -219,8 +219,8 @@
program, r.entryPointName.c_str(), r.limits));
}
- tint::writer::glsl::Options tintOptions;
- tintOptions.version = tint::writer::glsl::Version(ToTintGLStandard(r.glVersionStandard),
+ tint::glsl::writer::Options tintOptions;
+ tintOptions.version = tint::glsl::writer::Version(ToTintGLStandard(r.glVersionStandard),
r.glVersionMajor, r.glVersionMinor);
// TODO(crbug.com/dawn/1686): Robustness causes shader compilation failures.
@@ -264,7 +264,7 @@
tintOptions.binding_points = std::move(r.glBindings);
tintOptions.allow_collisions = true;
- auto result = tint::writer::glsl::Generate(&program, tintOptions, r.entryPointName);
+ auto result = tint::glsl::writer::Generate(&program, tintOptions, r.entryPointName);
DAWN_INVALID_IF(!result.success, "An error occured while generating GLSL: %s.",
result.error);
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index 1281bbf..2a10c63 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -1162,12 +1162,15 @@
libtint_source_set("libtint_glsl_writer_src") {
sources = [
- "lang/glsl/ast_writer/generator.cc",
- "lang/glsl/ast_writer/generator.h",
- "lang/glsl/ast_writer/generator_impl.cc",
- "lang/glsl/ast_writer/generator_impl.h",
- "lang/glsl/ast_writer/options.h",
- "lang/glsl/ast_writer/version.h",
+ "lang/glsl/writer/ast_printer/ast_printer.cc",
+ "lang/glsl/writer/ast_printer/ast_printer.h",
+ "lang/glsl/writer/options.cc",
+ "lang/glsl/writer/options.h",
+ "lang/glsl/writer/result.cc",
+ "lang/glsl/writer/result.h",
+ "lang/glsl/writer/version.h",
+ "lang/glsl/writer/writer.cc",
+ "lang/glsl/writer/writer.h",
]
deps = [
@@ -2283,38 +2286,38 @@
tint_unittests_source_set("tint_unittests_glsl_writer_src") {
sources = [
- "lang/glsl/ast_writer/generator_impl_array_accessor_test.cc",
- "lang/glsl/ast_writer/generator_impl_assign_test.cc",
- "lang/glsl/ast_writer/generator_impl_binary_test.cc",
- "lang/glsl/ast_writer/generator_impl_bitcast_test.cc",
- "lang/glsl/ast_writer/generator_impl_block_test.cc",
- "lang/glsl/ast_writer/generator_impl_break_test.cc",
- "lang/glsl/ast_writer/generator_impl_builtin_test.cc",
- "lang/glsl/ast_writer/generator_impl_builtin_texture_test.cc",
- "lang/glsl/ast_writer/generator_impl_call_test.cc",
- "lang/glsl/ast_writer/generator_impl_case_test.cc",
- "lang/glsl/ast_writer/generator_impl_cast_test.cc",
- "lang/glsl/ast_writer/generator_impl_constructor_test.cc",
- "lang/glsl/ast_writer/generator_impl_continue_test.cc",
- "lang/glsl/ast_writer/generator_impl_discard_test.cc",
- "lang/glsl/ast_writer/generator_impl_function_test.cc",
- "lang/glsl/ast_writer/generator_impl_identifier_test.cc",
- "lang/glsl/ast_writer/generator_impl_if_test.cc",
- "lang/glsl/ast_writer/generator_impl_import_test.cc",
- "lang/glsl/ast_writer/generator_impl_loop_test.cc",
- "lang/glsl/ast_writer/generator_impl_member_accessor_test.cc",
- "lang/glsl/ast_writer/generator_impl_module_constant_test.cc",
- "lang/glsl/ast_writer/generator_impl_return_test.cc",
- "lang/glsl/ast_writer/generator_impl_sanitizer_test.cc",
- "lang/glsl/ast_writer/generator_impl_storage_buffer_test.cc",
- "lang/glsl/ast_writer/generator_impl_switch_test.cc",
- "lang/glsl/ast_writer/generator_impl_test.cc",
- "lang/glsl/ast_writer/generator_impl_type_test.cc",
- "lang/glsl/ast_writer/generator_impl_unary_op_test.cc",
- "lang/glsl/ast_writer/generator_impl_uniform_buffer_test.cc",
- "lang/glsl/ast_writer/generator_impl_variable_decl_statement_test.cc",
- "lang/glsl/ast_writer/generator_impl_workgroup_var_test.cc",
- "lang/glsl/ast_writer/test_helper.h",
+ "lang/glsl/writer/ast_printer/array_accessor_test.cc",
+ "lang/glsl/writer/ast_printer/assign_test.cc",
+ "lang/glsl/writer/ast_printer/ast_printer_test.cc",
+ "lang/glsl/writer/ast_printer/binary_test.cc",
+ "lang/glsl/writer/ast_printer/bitcast_test.cc",
+ "lang/glsl/writer/ast_printer/block_test.cc",
+ "lang/glsl/writer/ast_printer/break_test.cc",
+ "lang/glsl/writer/ast_printer/builtin_test.cc",
+ "lang/glsl/writer/ast_printer/builtin_texture_test.cc",
+ "lang/glsl/writer/ast_printer/call_test.cc",
+ "lang/glsl/writer/ast_printer/case_test.cc",
+ "lang/glsl/writer/ast_printer/cast_test.cc",
+ "lang/glsl/writer/ast_printer/constructor_test.cc",
+ "lang/glsl/writer/ast_printer/continue_test.cc",
+ "lang/glsl/writer/ast_printer/discard_test.cc",
+ "lang/glsl/writer/ast_printer/function_test.cc",
+ "lang/glsl/writer/ast_printer/identifier_test.cc",
+ "lang/glsl/writer/ast_printer/if_test.cc",
+ "lang/glsl/writer/ast_printer/import_test.cc",
+ "lang/glsl/writer/ast_printer/loop_test.cc",
+ "lang/glsl/writer/ast_printer/member_accessor_test.cc",
+ "lang/glsl/writer/ast_printer/module_constant_test.cc",
+ "lang/glsl/writer/ast_printer/return_test.cc",
+ "lang/glsl/writer/ast_printer/sanitizer_test.cc",
+ "lang/glsl/writer/ast_printer/storage_buffer_test.cc",
+ "lang/glsl/writer/ast_printer/switch_test.cc",
+ "lang/glsl/writer/ast_printer/test_helper.h",
+ "lang/glsl/writer/ast_printer/type_test.cc",
+ "lang/glsl/writer/ast_printer/unary_op_test.cc",
+ "lang/glsl/writer/ast_printer/uniform_buffer_test.cc",
+ "lang/glsl/writer/ast_printer/variable_decl_statement_test.cc",
+ "lang/glsl/writer/ast_printer/workgroup_var_test.cc",
]
deps = [
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index e32495e..16cc0db 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -714,12 +714,15 @@
if(${TINT_BUILD_GLSL_WRITER})
list(APPEND TINT_LIB_SRCS
- lang/glsl/ast_writer/generator.cc
- lang/glsl/ast_writer/generator.h
- lang/glsl/ast_writer/generator_impl.cc
- lang/glsl/ast_writer/generator_impl.h
- lang/glsl/ast_writer/options.h
- lang/glsl/ast_writer/version.h
+ lang/glsl/writer/ast_printer/ast_printer.cc
+ lang/glsl/writer/ast_printer/ast_printer.h
+ lang/glsl/writer/writer.cc
+ lang/glsl/writer/writer.h
+ lang/glsl/writer/options.cc
+ lang/glsl/writer/options.h
+ lang/glsl/writer/result.cc
+ lang/glsl/writer/result.h
+ lang/glsl/writer/version.h
)
endif()
@@ -1512,38 +1515,38 @@
if (${TINT_BUILD_GLSL_WRITER})
list(APPEND TINT_TEST_SRCS
- lang/glsl/ast_writer/generator_impl_array_accessor_test.cc
- lang/glsl/ast_writer/generator_impl_assign_test.cc
- lang/glsl/ast_writer/generator_impl_binary_test.cc
- lang/glsl/ast_writer/generator_impl_bitcast_test.cc
- lang/glsl/ast_writer/generator_impl_block_test.cc
- lang/glsl/ast_writer/generator_impl_break_test.cc
- lang/glsl/ast_writer/generator_impl_builtin_test.cc
- lang/glsl/ast_writer/generator_impl_builtin_texture_test.cc
- lang/glsl/ast_writer/generator_impl_call_test.cc
- lang/glsl/ast_writer/generator_impl_case_test.cc
- lang/glsl/ast_writer/generator_impl_cast_test.cc
- lang/glsl/ast_writer/generator_impl_constructor_test.cc
- lang/glsl/ast_writer/generator_impl_continue_test.cc
- lang/glsl/ast_writer/generator_impl_discard_test.cc
- lang/glsl/ast_writer/generator_impl_function_test.cc
- lang/glsl/ast_writer/generator_impl_identifier_test.cc
- lang/glsl/ast_writer/generator_impl_if_test.cc
- lang/glsl/ast_writer/generator_impl_import_test.cc
- lang/glsl/ast_writer/generator_impl_loop_test.cc
- lang/glsl/ast_writer/generator_impl_member_accessor_test.cc
- lang/glsl/ast_writer/generator_impl_module_constant_test.cc
- lang/glsl/ast_writer/generator_impl_return_test.cc
- lang/glsl/ast_writer/generator_impl_sanitizer_test.cc
- lang/glsl/ast_writer/generator_impl_storage_buffer_test.cc
- lang/glsl/ast_writer/generator_impl_switch_test.cc
- lang/glsl/ast_writer/generator_impl_test.cc
- lang/glsl/ast_writer/generator_impl_type_test.cc
- lang/glsl/ast_writer/generator_impl_unary_op_test.cc
- lang/glsl/ast_writer/generator_impl_uniform_buffer_test.cc
- lang/glsl/ast_writer/generator_impl_variable_decl_statement_test.cc
- lang/glsl/ast_writer/generator_impl_workgroup_var_test.cc
- lang/glsl/ast_writer/test_helper.h
+ lang/glsl/writer/ast_printer/array_accessor_test.cc
+ lang/glsl/writer/ast_printer/assign_test.cc
+ lang/glsl/writer/ast_printer/ast_printer_test.cc
+ lang/glsl/writer/ast_printer/binary_test.cc
+ lang/glsl/writer/ast_printer/bitcast_test.cc
+ lang/glsl/writer/ast_printer/block_test.cc
+ lang/glsl/writer/ast_printer/break_test.cc
+ lang/glsl/writer/ast_printer/builtin_test.cc
+ lang/glsl/writer/ast_printer/builtin_texture_test.cc
+ lang/glsl/writer/ast_printer/call_test.cc
+ lang/glsl/writer/ast_printer/case_test.cc
+ lang/glsl/writer/ast_printer/cast_test.cc
+ lang/glsl/writer/ast_printer/constructor_test.cc
+ lang/glsl/writer/ast_printer/continue_test.cc
+ lang/glsl/writer/ast_printer/discard_test.cc
+ lang/glsl/writer/ast_printer/function_test.cc
+ lang/glsl/writer/ast_printer/identifier_test.cc
+ lang/glsl/writer/ast_printer/if_test.cc
+ lang/glsl/writer/ast_printer/import_test.cc
+ lang/glsl/writer/ast_printer/loop_test.cc
+ lang/glsl/writer/ast_printer/member_accessor_test.cc
+ lang/glsl/writer/ast_printer/module_constant_test.cc
+ lang/glsl/writer/ast_printer/return_test.cc
+ lang/glsl/writer/ast_printer/sanitizer_test.cc
+ lang/glsl/writer/ast_printer/storage_buffer_test.cc
+ lang/glsl/writer/ast_printer/switch_test.cc
+ lang/glsl/writer/ast_printer/type_test.cc
+ lang/glsl/writer/ast_printer/unary_op_test.cc
+ lang/glsl/writer/ast_printer/uniform_buffer_test.cc
+ lang/glsl/writer/ast_printer/variable_decl_statement_test.cc
+ lang/glsl/writer/ast_printer/workgroup_var_test.cc
+ lang/glsl/writer/ast_printer/test_helper.h
)
endif()
@@ -1721,7 +1724,7 @@
)
if (${TINT_BUILD_GLSL_WRITER})
- list(APPEND TINT_BENCHMARK_SRCS lang/glsl/ast_writer/generator_bench.cc)
+ list(APPEND TINT_BENCHMARK_SRCS lang/glsl/writer/writer_bench.cc)
endif()
if (${TINT_BUILD_HLSL_WRITER})
list(APPEND TINT_BENCHMARK_SRCS lang/hlsl/writer/writer_bench.cc)
diff --git a/src/tint/cmd/loopy.cc b/src/tint/cmd/loopy.cc
index 0a56bba..4fc07f8 100644
--- a/src/tint/cmd/loopy.cc
+++ b/src/tint/cmd/loopy.cc
@@ -266,10 +266,10 @@
/// @returns true on success
bool GenerateGlsl(const tint::Program* program) {
#if TINT_BUILD_GLSL_WRITER
- tint::writer::glsl::Options gen_options;
+ tint::glsl::writer::Options gen_options;
gen_options.external_texture_options.bindings_map =
tint::cmd::GenerateExternalTextureBindings(program);
- auto result = tint::writer::glsl::Generate(program, gen_options, "");
+ auto result = tint::glsl::writer::Generate(program, gen_options, "");
if (!result.success) {
tint::cmd::PrintWGSL(std::cerr, *program);
std::cerr << "Failed to generate: " << result.error << std::endl;
diff --git a/src/tint/cmd/main.cc b/src/tint/cmd/main.cc
index 5fe63ea..cc7b8ac 100644
--- a/src/tint/cmd/main.cc
+++ b/src/tint/cmd/main.cc
@@ -826,11 +826,11 @@
}
auto generate = [&](const tint::Program* prg, const std::string entry_point_name) -> bool {
- tint::writer::glsl::Options gen_options;
+ tint::glsl::writer::Options gen_options;
gen_options.disable_robustness = !options.enable_robustness;
gen_options.external_texture_options.bindings_map =
tint::cmd::GenerateExternalTextureBindings(prg);
- auto result = tint::writer::glsl::Generate(prg, gen_options, entry_point_name);
+ auto result = tint::glsl::writer::Generate(prg, gen_options, entry_point_name);
if (!result.success) {
tint::cmd::PrintWGSL(std::cerr, *prg);
std::cerr << "Failed to generate: " << result.error << std::endl;
diff --git a/src/tint/fuzzers/tint_concurrency_fuzzer.cc b/src/tint/fuzzers/tint_concurrency_fuzzer.cc
index 3cd7f95..6b3523c 100644
--- a/src/tint/fuzzers/tint_concurrency_fuzzer.cc
+++ b/src/tint/fuzzers/tint_concurrency_fuzzer.cc
@@ -20,7 +20,7 @@
#include <thread>
#include "src/tint/fuzzers/apply_substitute_overrides.h"
-#include "src/tint/lang/glsl/ast_writer/generator.h"
+#include "src/tint/lang/glsl/writer/writer.h"
#include "src/tint/lang/hlsl/writer/writer.h"
#include "src/tint/lang/msl/writer/writer.h"
#include "src/tint/lang/spirv/ast_writer/generator.h"
@@ -103,7 +103,7 @@
#if TINT_BUILD_GLSL_WRITER
case Writer::kGLSL: {
- tint::writer::glsl::Generate(&program, {}, entry_point);
+ tint::glsl::writer::Generate(&program, {}, entry_point);
break;
}
#endif // TINT_BUILD_GLSL_WRITER
diff --git a/src/tint/lang/glsl/ast_writer/generator.h b/src/tint/lang/glsl/ast_writer/generator.h
deleted file mode 100644
index 4340083..0000000
--- a/src/tint/lang/glsl/ast_writer/generator.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2021 The Tint Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_H_
-#define SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-#include "src/tint/lang/core/builtin/access.h"
-#include "src/tint/lang/glsl/ast_writer/options.h"
-#include "src/tint/lang/glsl/ast_writer/version.h"
-#include "src/tint/lang/wgsl/ast/pipeline_stage.h"
-#include "src/tint/lang/wgsl/sem/sampler_texture_pair.h"
-#include "tint/binding_point.h"
-#include "tint/external_texture_options.h"
-
-// Forward declarations
-namespace tint {
-class Program;
-} // namespace tint
-
-namespace tint::writer::glsl {
-
-/// The result produced when generating GLSL.
-struct Result {
- /// Constructor
- Result();
-
- /// Destructor
- ~Result();
-
- /// Copy constructor
- Result(const Result&);
-
- /// True if generation was successful.
- bool success = false;
-
- /// The errors generated during code generation, if any.
- std::string error;
-
- /// The generated GLSL.
- std::string glsl = "";
-
- /// The list of entry points in the generated GLSL.
- std::vector<std::pair<std::string, ast::PipelineStage>> entry_points;
-};
-
-/// Generate GLSL for a program, according to a set of configuration options.
-/// The result will contain the GLSL, as well as success status and diagnostic
-/// information.
-/// @param program the program to translate to GLSL
-/// @param options the configuration options to use when generating GLSL
-/// @param entry_point the entry point to generate GLSL for
-/// @returns the resulting GLSL and supplementary information
-Result Generate(const Program* program, const Options& options, const std::string& entry_point);
-
-} // namespace tint::writer::glsl
-
-#endif // SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_H_
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_array_accessor_test.cc b/src/tint/lang/glsl/writer/ast_printer/array_accessor_test.cc
similarity index 79%
rename from src/tint/lang/glsl/ast_writer/generator_impl_array_accessor_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/array_accessor_test.cc
index 1a02e79..06be52a 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_array_accessor_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/array_accessor_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
@@ -20,17 +20,17 @@
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Expression = TestHelper;
+using GlslASTPrinterTest_Expression = TestHelper;
-TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
+TEST_F(GlslASTPrinterTest_Expression, IndexAccessor) {
GlobalVar("ary", ty.array<i32, 10>(), builtin::AddressSpace::kPrivate);
auto* expr = IndexAccessor("ary", 5_i);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -39,4 +39,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_assign_test.cc b/src/tint/lang/glsl/writer/ast_printer/assign_test.cc
similarity index 79%
rename from src/tint/lang/glsl/ast_writer/generator_impl_assign_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/assign_test.cc
index dc81e26..15f9d88 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_assign_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/assign_test.cc
@@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Assign = TestHelper;
+using GlslASTPrinterTest_Assign = TestHelper;
-TEST_F(GlslGeneratorImplTest_Assign, Emit_Assign) {
+TEST_F(GlslASTPrinterTest_Assign, Emit_Assign) {
GlobalVar("lhs", ty.i32(), builtin::AddressSpace::kPrivate);
GlobalVar("rhs", ty.i32(), builtin::AddressSpace::kPrivate);
auto* assign = Assign("lhs", "rhs");
WrapInFunction(assign);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
@@ -37,4 +37,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
similarity index 91%
rename from src/tint/lang/glsl/ast_writer/generator_impl.cc
rename to src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
index 0681815..5eaf72b 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/generator_impl.h"
+#include "src/tint/lang/glsl/writer/ast_printer/ast_printer.h"
#include <algorithm>
#include <cmath>
@@ -32,7 +32,7 @@
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
-#include "src/tint/lang/glsl/ast_writer/options.h"
+#include "src/tint/lang/glsl/writer/options.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/internal_attribute.h"
@@ -88,7 +88,7 @@
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
const char kTempNamePrefix[] = "tint_tmp";
@@ -131,7 +131,7 @@
} else if (std::isnan(value)) {
out << "0.0f /* nan */";
} else {
- out << FloatToString(value) << "f";
+ out << tint::writer::FloatToString(value) << "f";
}
}
@@ -141,7 +141,7 @@
} else if (std::isnan(value)) {
out << "0.0hf /* nan */";
} else {
- out << FloatToString(value) << "hf";
+ out << tint::writer::FloatToString(value) << "hf";
}
}
@@ -255,12 +255,12 @@
return result;
}
-GeneratorImpl::GeneratorImpl(const Program* program, const Version& version)
+ASTPrinter::ASTPrinter(const Program* program, const Version& version)
: builder_(ProgramBuilder::Wrap(program)), version_(version) {}
-GeneratorImpl::~GeneratorImpl() = default;
+ASTPrinter::~ASTPrinter() = default;
-void GeneratorImpl::Generate() {
+void ASTPrinter::Generate() {
{
auto out = Line();
out << "#version " << version_.major_version << version_.minor_version << "0";
@@ -340,7 +340,7 @@
}
}
-void GeneratorImpl::RecordExtension(const ast::Enable* enable) {
+void ASTPrinter::RecordExtension(const ast::Enable* enable) {
// Deal with extension node here, recording it within the generator for later emition.
if (enable->HasExtension(builtin::Extension::kF16)) {
@@ -348,15 +348,15 @@
}
}
-void GeneratorImpl::EmitIndexAccessor(utils::StringStream& out,
- const ast::IndexAccessorExpression* expr) {
+void ASTPrinter::EmitIndexAccessor(utils::StringStream& out,
+ const ast::IndexAccessorExpression* expr) {
EmitExpression(out, expr->object);
out << "[";
EmitExpression(out, expr->index);
out << "]";
}
-void GeneratorImpl::EmitBitcast(utils::StringStream& out, const ast::BitcastExpression* expr) {
+void ASTPrinter::EmitBitcast(utils::StringStream& out, const ast::BitcastExpression* expr) {
auto* src_type = TypeOf(expr->expr)->UnwrapRef();
auto* dst_type = TypeOf(expr)->UnwrapRef();
@@ -516,7 +516,7 @@
}
}
-void GeneratorImpl::EmitAssign(const ast::AssignmentStatement* stmt) {
+void ASTPrinter::EmitAssign(const ast::AssignmentStatement* stmt) {
auto out = Line();
EmitExpression(out, stmt->lhs);
out << " = ";
@@ -524,8 +524,7 @@
out << ";";
}
-void GeneratorImpl::EmitVectorRelational(utils::StringStream& out,
- const ast::BinaryExpression* expr) {
+void ASTPrinter::EmitVectorRelational(utils::StringStream& out, const ast::BinaryExpression* expr) {
switch (expr->op) {
case ast::BinaryOp::kEqual:
out << "equal";
@@ -554,7 +553,7 @@
EmitExpression(out, expr->rhs);
}
-void GeneratorImpl::EmitBitwiseBoolOp(utils::StringStream& out, const ast::BinaryExpression* expr) {
+void ASTPrinter::EmitBitwiseBoolOp(utils::StringStream& out, const ast::BinaryExpression* expr) {
auto* bool_type = TypeOf(expr->lhs)->UnwrapRef();
auto* uint_type = BoolTypeToUint(bool_type);
@@ -587,7 +586,7 @@
}
}
-void GeneratorImpl::EmitFloatModulo(utils::StringStream& out, const ast::BinaryExpression* expr) {
+void ASTPrinter::EmitFloatModulo(utils::StringStream& out, const ast::BinaryExpression* expr) {
std::string fn;
auto* ret_ty = TypeOf(expr)->UnwrapRef();
auto* lhs_ty = TypeOf(expr->lhs)->UnwrapRef();
@@ -634,7 +633,7 @@
}
}
-void GeneratorImpl::EmitBinary(utils::StringStream& out, const ast::BinaryExpression* expr) {
+void ASTPrinter::EmitBinary(utils::StringStream& out, const ast::BinaryExpression* expr) {
if (IsRelational(expr->op) && !TypeOf(expr->lhs)->UnwrapRef()->Is<type::Scalar>()) {
EmitVectorRelational(out, expr);
return;
@@ -751,35 +750,35 @@
EmitExpression(out, expr->rhs);
}
-void GeneratorImpl::EmitStatements(utils::VectorRef<const ast::Statement*> stmts) {
+void ASTPrinter::EmitStatements(utils::VectorRef<const ast::Statement*> stmts) {
for (auto* s : stmts) {
EmitStatement(s);
}
}
-void GeneratorImpl::EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts) {
+void ASTPrinter::EmitStatementsWithIndent(utils::VectorRef<const ast::Statement*> stmts) {
ScopedIndent si(this);
EmitStatements(stmts);
}
-void GeneratorImpl::EmitBlock(const ast::BlockStatement* stmt) {
+void ASTPrinter::EmitBlock(const ast::BlockStatement* stmt) {
Line() << "{";
EmitStatementsWithIndent(stmt->statements);
Line() << "}";
}
-void GeneratorImpl::EmitBreak(const ast::BreakStatement*) {
+void ASTPrinter::EmitBreak(const ast::BreakStatement*) {
Line() << "break;";
}
-void GeneratorImpl::EmitBreakIf(const ast::BreakIfStatement* b) {
+void ASTPrinter::EmitBreakIf(const ast::BreakIfStatement* b) {
auto out = Line();
out << "if (";
EmitExpression(out, b->condition);
out << ") { break; }";
}
-void GeneratorImpl::EmitCall(utils::StringStream& out, const ast::CallExpression* expr) {
+void ASTPrinter::EmitCall(utils::StringStream& out, const ast::CallExpression* expr) {
auto* call = builder_.Sem().Get<sem::Call>(expr);
Switch(
call->Target(), //
@@ -793,9 +792,9 @@
});
}
-void GeneratorImpl::EmitFunctionCall(utils::StringStream& out,
- const sem::Call* call,
- const sem::Function* fn) {
+void ASTPrinter::EmitFunctionCall(utils::StringStream& out,
+ const sem::Call* call,
+ const sem::Function* fn) {
const auto& args = call->Arguments();
auto* ident = fn->Declaration()->name;
@@ -813,9 +812,9 @@
}
}
-void GeneratorImpl::EmitBuiltinCall(utils::StringStream& out,
- const sem::Call* call,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitBuiltinCall(utils::StringStream& out,
+ const sem::Call* call,
+ const sem::Builtin* builtin) {
auto* expr = call->Declaration();
if (builtin->IsTexture()) {
EmitTextureCall(out, call, builtin);
@@ -877,18 +876,18 @@
}
}
-void GeneratorImpl::EmitValueConversion(utils::StringStream& out,
- const sem::Call* call,
- const sem::ValueConversion* conv) {
+void ASTPrinter::EmitValueConversion(utils::StringStream& out,
+ const sem::Call* call,
+ const sem::ValueConversion* conv) {
EmitType(out, conv->Target(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite,
"");
ScopedParen sp(out);
EmitExpression(out, call->Arguments()[0]->Declaration());
}
-void GeneratorImpl::EmitValueConstructor(utils::StringStream& out,
- const sem::Call* call,
- const sem::ValueConstructor* ctor) {
+void ASTPrinter::EmitValueConstructor(utils::StringStream& out,
+ const sem::Call* call,
+ const sem::ValueConstructor* ctor) {
auto* type = ctor->ReturnType();
// If the value constructor is empty then we need to construct with the zero value for all
@@ -912,9 +911,9 @@
}
}
-void GeneratorImpl::EmitWorkgroupAtomicCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitWorkgroupAtomicCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
auto call = [&](const char* name) {
out << name;
{
@@ -1023,13 +1022,13 @@
TINT_UNREACHABLE(Writer, diagnostics_) << "unsupported atomic builtin: " << builtin->Type();
}
-void GeneratorImpl::EmitArrayLength(utils::StringStream& out, const ast::CallExpression* expr) {
+void ASTPrinter::EmitArrayLength(utils::StringStream& out, const ast::CallExpression* expr) {
out << "uint(";
EmitExpression(out, expr->args[0]);
out << ".length())";
}
-void GeneratorImpl::EmitExtractBits(utils::StringStream& out, const ast::CallExpression* expr) {
+void ASTPrinter::EmitExtractBits(utils::StringStream& out, const ast::CallExpression* expr) {
out << "bitfieldExtract(";
EmitExpression(out, expr->args[0]);
out << ", int(";
@@ -1039,7 +1038,7 @@
out << "))";
}
-void GeneratorImpl::EmitInsertBits(utils::StringStream& out, const ast::CallExpression* expr) {
+void ASTPrinter::EmitInsertBits(utils::StringStream& out, const ast::CallExpression* expr) {
out << "bitfieldInsert(";
EmitExpression(out, expr->args[0]);
out << ", ";
@@ -1051,7 +1050,7 @@
out << "))";
}
-void GeneratorImpl::EmitEmulatedFMA(utils::StringStream& out, const ast::CallExpression* expr) {
+void ASTPrinter::EmitEmulatedFMA(utils::StringStream& out, const ast::CallExpression* expr) {
out << "((";
EmitExpression(out, expr->args[0]);
out << ") * (";
@@ -1061,8 +1060,7 @@
out << "))";
}
-void GeneratorImpl::EmitCountOneBitsCall(utils::StringStream& out,
- const ast::CallExpression* expr) {
+void ASTPrinter::EmitCountOneBitsCall(utils::StringStream& out, const ast::CallExpression* expr) {
// GLSL's bitCount returns an integer type, so cast it to the appropriate
// unsigned type.
EmitType(out, TypeOf(expr)->UnwrapRef(), builtin::AddressSpace::kUndefined,
@@ -1072,9 +1070,9 @@
out << "))";
}
-void GeneratorImpl::EmitSelectCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitSelectCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
// GLSL does not support ternary expressions with a bool vector conditional,
// so polyfill with a helper.
if (auto* vec = builtin->Parameters()[2]->Type()->As<type::Vector>()) {
@@ -1112,9 +1110,9 @@
EmitExpression(out, expr_false);
}
-void GeneratorImpl::EmitDotCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitDotCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
auto* vec_ty = builtin->Parameters()[0]->Type()->As<type::Vector>();
std::string fn = "dot";
if (vec_ty->type()->is_integer_scalar()) {
@@ -1167,9 +1165,9 @@
EmitExpression(out, expr->args[1]);
}
-void GeneratorImpl::EmitModfCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitModfCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
TINT_ASSERT(Writer, expr->args.Length() == 1);
CallBuiltinHelper(out, expr, builtin,
[&](TextBuffer* b, const std::vector<std::string>& params) {
@@ -1188,9 +1186,9 @@
});
}
-void GeneratorImpl::EmitFrexpCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitFrexpCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
TINT_ASSERT(Writer, expr->args.Length() == 1);
CallBuiltinHelper(out, expr, builtin,
[&](TextBuffer* b, const std::vector<std::string>& params) {
@@ -1209,9 +1207,9 @@
});
}
-void GeneratorImpl::EmitDegreesCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitDegreesCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
auto* return_elem_type = builtin->ReturnType()->DeepestElement();
const std::string suffix = Is<type::F16>(return_elem_type) ? "hf" : "f";
CallBuiltinHelper(out, expr, builtin,
@@ -1221,9 +1219,9 @@
});
}
-void GeneratorImpl::EmitRadiansCall(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitRadiansCall(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
auto* return_elem_type = builtin->ReturnType()->DeepestElement();
const std::string suffix = Is<type::F16>(return_elem_type) ? "hf" : "f";
CallBuiltinHelper(out, expr, builtin,
@@ -1233,9 +1231,9 @@
});
}
-void GeneratorImpl::EmitQuantizeToF16Call(utils::StringStream& out,
- const ast::CallExpression* expr,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitQuantizeToF16Call(utils::StringStream& out,
+ const ast::CallExpression* expr,
+ const sem::Builtin* builtin) {
// Emulate by casting to f16 and back again.
CallBuiltinHelper(
out, expr, builtin, [&](TextBuffer* b, const std::vector<std::string>& params) {
@@ -1264,7 +1262,7 @@
});
}
-void GeneratorImpl::EmitBarrierCall(utils::StringStream& out, const sem::Builtin* builtin) {
+void ASTPrinter::EmitBarrierCall(utils::StringStream& out, const sem::Builtin* builtin) {
// TODO(crbug.com/tint/661): Combine sequential barriers to a single
// instruction.
if (builtin->Type() == builtin::Function::kWorkgroupBarrier) {
@@ -1277,7 +1275,7 @@
}
}
-const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
+const ast::Expression* ASTPrinter::CreateF32Zero(const sem::Statement* stmt) {
auto* zero = builder_.Expr(0_f);
auto* f32 = builder_.create<type::F32>();
auto* sem_zero = builder_.create<sem::ValueExpression>(
@@ -1287,9 +1285,9 @@
return zero;
}
-void GeneratorImpl::EmitTextureCall(utils::StringStream& out,
- const sem::Call* call,
- const sem::Builtin* builtin) {
+void ASTPrinter::EmitTextureCall(utils::StringStream& out,
+ const sem::Call* call,
+ const sem::Builtin* builtin) {
using Usage = sem::ParameterUsage;
auto& signature = builtin->Signature();
@@ -1495,7 +1493,8 @@
if (auto* array_index = arg(Usage::kArrayIndex)) {
// Array index needs to be appended to the coordinates.
- param_coords = AppendVector(&builder_, param_coords, array_index)->Declaration();
+ param_coords =
+ tint::writer::AppendVector(&builder_, param_coords, array_index)->Declaration();
}
// GLSL requires Dref to be appended to the coordinates, *unless* it's
@@ -1512,7 +1511,8 @@
// append zero here.
depth_ref = CreateF32Zero(builder_.Sem().Get(param_coords)->Stmt());
}
- param_coords = AppendVector(&builder_, param_coords, depth_ref)->Declaration();
+ param_coords =
+ tint::writer::AppendVector(&builder_, param_coords, depth_ref)->Declaration();
}
emit_expr_as_signed(param_coords);
@@ -1585,7 +1585,7 @@
}
}
-std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
+std::string ASTPrinter::generate_builtin_name(const sem::Builtin* builtin) {
switch (builtin->Type()) {
case builtin::Function::kAbs:
case builtin::Function::kAcos:
@@ -1704,7 +1704,7 @@
return "";
}
-void GeneratorImpl::EmitCase(const ast::CaseStatement* stmt) {
+void ASTPrinter::EmitCase(const ast::CaseStatement* stmt) {
auto* sem = builder_.Sem().Get<sem::CaseStatement>(stmt);
for (auto* selector : sem->Selectors()) {
auto out = Line();
@@ -1732,20 +1732,20 @@
Line() << "}";
}
-void GeneratorImpl::EmitContinue(const ast::ContinueStatement*) {
+void ASTPrinter::EmitContinue(const ast::ContinueStatement*) {
if (emit_continuing_) {
emit_continuing_();
}
Line() << "continue;";
}
-void GeneratorImpl::EmitDiscard(const ast::DiscardStatement*) {
+void ASTPrinter::EmitDiscard(const ast::DiscardStatement*) {
// TODO(dsinclair): Verify this is correct when the discard semantics are
// defined for WGSL (https://github.com/gpuweb/gpuweb/issues/361)
Line() << "discard;";
}
-void GeneratorImpl::EmitExpression(utils::StringStream& out, const ast::Expression* expr) {
+void ASTPrinter::EmitExpression(utils::StringStream& out, const ast::Expression* expr) {
if (auto* sem = builder_.Sem().GetVal(expr)) {
if (auto* constant = sem->ConstantValue()) {
EmitConstant(out, constant);
@@ -1768,12 +1768,11 @@
});
}
-void GeneratorImpl::EmitIdentifier(utils::StringStream& out,
- const ast::IdentifierExpression* expr) {
+void ASTPrinter::EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr) {
out << expr->identifier->symbol.Name();
}
-void GeneratorImpl::EmitIf(const ast::IfStatement* stmt) {
+void ASTPrinter::EmitIf(const ast::IfStatement* stmt) {
{
auto out = Line();
out << "if (";
@@ -1793,7 +1792,7 @@
Line() << "}";
}
-void GeneratorImpl::EmitFunction(const ast::Function* func) {
+void ASTPrinter::EmitFunction(const ast::Function* func) {
auto* sem = builder_.Sem().Get(func);
if (ast::HasAttribute<ast::InternalAttribute>(func->attributes)) {
@@ -1844,7 +1843,7 @@
Line();
}
-void GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) {
+void ASTPrinter::EmitGlobalVariable(const ast::Variable* global) {
Switch(
global, //
[&](const ast::Var* var) {
@@ -1897,7 +1896,7 @@
});
}
-void GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable* sem) {
+void ASTPrinter::EmitUniformVariable(const ast::Var* var, const sem::Variable* sem) {
auto* type = sem->Type()->UnwrapRef();
auto* str = type->As<type::Struct>();
if (TINT_UNLIKELY(!str)) {
@@ -1916,7 +1915,7 @@
Line();
}
-void GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable* sem) {
+void ASTPrinter::EmitStorageVariable(const ast::Var* var, const sem::Variable* sem) {
auto* type = sem->Type()->UnwrapRef();
auto* str = type->As<type::Struct>();
if (TINT_UNLIKELY(!str)) {
@@ -1932,7 +1931,7 @@
Line();
}
-void GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* sem) {
+void ASTPrinter::EmitHandleVariable(const ast::Var* var, const sem::Variable* sem) {
auto out = Line();
auto name = var->name->symbol.Name();
@@ -2007,7 +2006,7 @@
out << ";";
}
-void GeneratorImpl::EmitPrivateVariable(const sem::Variable* var) {
+void ASTPrinter::EmitPrivateVariable(const sem::Variable* var) {
auto* decl = var->Declaration();
auto out = Line();
@@ -2024,7 +2023,7 @@
out << ";";
}
-void GeneratorImpl::EmitWorkgroupVariable(const sem::Variable* var) {
+void ASTPrinter::EmitWorkgroupVariable(const sem::Variable* var) {
auto* decl = var->Declaration();
auto out = Line();
@@ -2042,7 +2041,7 @@
out << ";";
}
-void GeneratorImpl::EmitIOVariable(const sem::GlobalVariable* var) {
+void ASTPrinter::EmitIOVariable(const sem::GlobalVariable* var) {
auto* decl = var->Declaration();
if (auto* attr = ast::GetAttribute<ast::BuiltinAttribute>(decl->attributes)) {
@@ -2070,9 +2069,8 @@
out << ";";
}
-void GeneratorImpl::EmitInterpolationQualifiers(
- utils::StringStream& out,
- utils::VectorRef<const ast::Attribute*> attributes) {
+void ASTPrinter::EmitInterpolationQualifiers(utils::StringStream& out,
+ utils::VectorRef<const ast::Attribute*> attributes) {
for (auto* attr : attributes) {
if (auto* interpolate = attr->As<ast::InterpolateAttribute>()) {
auto& sem = builder_.Sem();
@@ -2107,9 +2105,9 @@
}
}
-void GeneratorImpl::EmitAttributes(utils::StringStream& out,
- const sem::GlobalVariable* var,
- utils::VectorRef<const ast::Attribute*> attributes) {
+void ASTPrinter::EmitAttributes(utils::StringStream& out,
+ const sem::GlobalVariable* var,
+ utils::VectorRef<const ast::Attribute*> attributes) {
if (attributes.IsEmpty()) {
return;
}
@@ -2130,7 +2128,7 @@
}
}
-void GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
+void ASTPrinter::EmitEntryPointFunction(const ast::Function* func) {
auto* func_sem = builder_.Sem().Get(func);
if (func->PipelineStage() == ast::PipelineStage::kFragment) {
@@ -2209,7 +2207,7 @@
Line() << "}";
}
-void GeneratorImpl::EmitConstant(utils::StringStream& out, const constant::Value* constant) {
+void ASTPrinter::EmitConstant(utils::StringStream& out, const constant::Value* constant) {
Switch(
constant->Type(), //
[&](const type::Bool*) { out << (constant->ValueAs<AInt>() ? "true" : "false"); },
@@ -2285,7 +2283,7 @@
});
}
-void GeneratorImpl::EmitLiteral(utils::StringStream& out, const ast::LiteralExpression* lit) {
+void ASTPrinter::EmitLiteral(utils::StringStream& out, const ast::LiteralExpression* lit) {
Switch(
lit, //
[&](const ast::BoolLiteralExpression* l) { out << (l->value ? "true" : "false"); },
@@ -2313,7 +2311,7 @@
[&](Default) { diagnostics_.add_error(diag::System::Writer, "unknown literal type"); });
}
-void GeneratorImpl::EmitZeroValue(utils::StringStream& out, const type::Type* type) {
+void ASTPrinter::EmitZeroValue(utils::StringStream& out, const type::Type* type) {
if (type->Is<type::Bool>()) {
out << "false";
} else if (type->Is<type::F32>()) {
@@ -2376,7 +2374,7 @@
}
}
-void GeneratorImpl::EmitLoop(const ast::LoopStatement* stmt) {
+void ASTPrinter::EmitLoop(const ast::LoopStatement* stmt) {
auto emit_continuing = [this, stmt] {
if (stmt->continuing && !stmt->continuing->Empty()) {
EmitBlock(stmt->continuing);
@@ -2393,7 +2391,7 @@
Line() << "}";
}
-void GeneratorImpl::EmitForLoop(const ast::ForLoopStatement* stmt) {
+void ASTPrinter::EmitForLoop(const ast::ForLoopStatement* stmt) {
// Nest a for loop with a new block. In HLSL the initializer scope is not
// nested by the for-loop, so we may get variable redefinitions.
Line() << "{";
@@ -2484,7 +2482,7 @@
}
}
-void GeneratorImpl::EmitWhile(const ast::WhileStatement* stmt) {
+void ASTPrinter::EmitWhile(const ast::WhileStatement* stmt) {
TextBuffer cond_pre;
utils::StringStream cond_buf;
{
@@ -2527,8 +2525,8 @@
}
}
-void GeneratorImpl::EmitMemberAccessor(utils::StringStream& out,
- const ast::MemberAccessorExpression* expr) {
+void ASTPrinter::EmitMemberAccessor(utils::StringStream& out,
+ const ast::MemberAccessorExpression* expr) {
EmitExpression(out, expr->object);
out << ".";
@@ -2549,7 +2547,7 @@
});
}
-void GeneratorImpl::EmitReturn(const ast::ReturnStatement* stmt) {
+void ASTPrinter::EmitReturn(const ast::ReturnStatement* stmt) {
if (stmt->value) {
auto out = Line();
out << "return ";
@@ -2560,7 +2558,7 @@
}
}
-void GeneratorImpl::EmitStatement(const ast::Statement* stmt) {
+void ASTPrinter::EmitStatement(const ast::Statement* stmt) {
Switch(
stmt, //
[&](const ast::AssignmentStatement* a) { EmitAssign(a); },
@@ -2602,7 +2600,7 @@
});
}
-void GeneratorImpl::EmitSwitch(const ast::SwitchStatement* stmt) {
+void ASTPrinter::EmitSwitch(const ast::SwitchStatement* stmt) {
{ // switch(expr) {
auto out = Line();
out << "switch(";
@@ -2620,12 +2618,12 @@
Line() << "}";
}
-void GeneratorImpl::EmitType(utils::StringStream& out,
- const type::Type* type,
- builtin::AddressSpace address_space,
- builtin::Access access,
- const std::string& name,
- bool* name_printed /* = nullptr */) {
+void ASTPrinter::EmitType(utils::StringStream& out,
+ const type::Type* type,
+ builtin::AddressSpace address_space,
+ builtin::Access access,
+ const std::string& name,
+ bool* name_printed /* = nullptr */) {
if (name_printed) {
*name_printed = false;
}
@@ -2789,11 +2787,11 @@
}
}
-void GeneratorImpl::EmitTypeAndName(utils::StringStream& out,
- const type::Type* type,
- builtin::AddressSpace address_space,
- builtin::Access access,
- const std::string& name) {
+void ASTPrinter::EmitTypeAndName(utils::StringStream& out,
+ const type::Type* type,
+ builtin::AddressSpace address_space,
+ builtin::Access access,
+ const std::string& name) {
bool printed_name = false;
EmitType(out, type, address_space, access, name, &printed_name);
if (!name.empty() && !printed_name) {
@@ -2801,7 +2799,7 @@
}
}
-void GeneratorImpl::EmitStructType(TextBuffer* b, const type::Struct* str) {
+void ASTPrinter::EmitStructType(TextBuffer* b, const type::Struct* str) {
auto it = emitted_structs_.emplace(str);
if (!it.second) {
return;
@@ -2814,7 +2812,7 @@
Line(b);
}
-void GeneratorImpl::EmitStructMembers(TextBuffer* b, const type::Struct* str) {
+void ASTPrinter::EmitStructMembers(TextBuffer* b, const type::Struct* str) {
ScopedIndent si(b);
for (auto* mem : str->Members()) {
auto name = mem->Name().Name();
@@ -2827,7 +2825,7 @@
}
}
-void GeneratorImpl::EmitUnaryOp(utils::StringStream& out, const ast::UnaryOpExpression* expr) {
+void ASTPrinter::EmitUnaryOp(utils::StringStream& out, const ast::UnaryOpExpression* expr) {
switch (expr->op) {
case ast::UnaryOp::kIndirection:
case ast::UnaryOp::kAddressOf:
@@ -2852,7 +2850,7 @@
EmitExpression(out, expr->expr);
}
-void GeneratorImpl::EmitVar(const ast::Var* var) {
+void ASTPrinter::EmitVar(const ast::Var* var) {
auto* sem = builder_.Sem().Get(var);
auto* type = sem->Type()->UnwrapRef();
@@ -2869,7 +2867,7 @@
out << ";";
}
-void GeneratorImpl::EmitLet(const ast::Let* let) {
+void ASTPrinter::EmitLet(const ast::Let* let) {
auto* sem = builder_.Sem().Get(let);
auto* type = sem->Type()->UnwrapRef();
@@ -2883,7 +2881,7 @@
out << ";";
}
-void GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
+void ASTPrinter::EmitProgramConstVariable(const ast::Variable* var) {
auto* sem = builder_.Sem().Get(var);
auto* type = sem->Type();
@@ -2897,10 +2895,10 @@
}
template <typename F>
-void GeneratorImpl::CallBuiltinHelper(utils::StringStream& out,
- const ast::CallExpression* call,
- const sem::Builtin* builtin,
- F&& build) {
+void ASTPrinter::CallBuiltinHelper(utils::StringStream& out,
+ const ast::CallExpression* call,
+ const sem::Builtin* builtin,
+ F&& build) {
// Generate the helper function if it hasn't been created already
auto fn = utils::GetOrCreate(builtins_, builtin, [&]() -> std::string {
TextBuffer b;
@@ -2955,7 +2953,7 @@
}
}
-type::Type* GeneratorImpl::BoolTypeToUint(const type::Type* type) {
+type::Type* ASTPrinter::BoolTypeToUint(const type::Type* type) {
auto* u32 = builder_.create<type::U32>();
if (type->Is<type::Bool>()) {
return u32;
@@ -2966,8 +2964,8 @@
}
}
-std::string GeneratorImpl::UniqueIdentifier(const std::string& prefix /* = "" */) {
+std::string ASTPrinter::UniqueIdentifier(const std::string& prefix /* = "" */) {
return builder_.Symbols().New(prefix).Name();
}
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl.h b/src/tint/lang/glsl/writer/ast_printer/ast_printer.h
similarity index 97%
rename from src/tint/lang/glsl/ast_writer/generator_impl.h
rename to src/tint/lang/glsl/writer/ast_printer/ast_printer.h
index 2cb0269..54d7228 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl.h
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer.h
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_IMPL_H_
-#define SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_IMPL_H_
+#ifndef SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_AST_PRINTER_H_
+#define SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_AST_PRINTER_H_
#include <string>
#include <tuple>
@@ -22,7 +22,7 @@
#include <utility>
#include "src/tint/lang/core/builtin/builtin_value.h"
-#include "src/tint/lang/glsl/ast_writer/version.h"
+#include "src/tint/lang/glsl/writer/version.h"
#include "src/tint/lang/wgsl/program/program_builder.h"
#include "src/tint/utils/containers/scope_stack.h"
#include "src/tint/utils/math/hash.h"
@@ -36,11 +36,11 @@
class ValueConstructor;
class ValueConversion;
} // namespace tint::sem
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
struct Options;
}
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
/// The result of sanitizing a program for generation.
struct SanitizedResult {
@@ -65,13 +65,13 @@
const std::string& entry_point);
/// Implementation class for GLSL generator
-class GeneratorImpl : public utils::TextGenerator {
+class ASTPrinter : public utils::TextGenerator {
public:
/// Constructor
/// @param program the program to generate
/// @param version the GLSL version to use
- GeneratorImpl(const Program* program, const Version& version);
- ~GeneratorImpl() override;
+ ASTPrinter(const Program* program, const Version& version);
+ ~ASTPrinter() override;
/// Generates the GLSL shader
void Generate();
@@ -470,6 +470,6 @@
Version version_;
};
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
-#endif // SRC_TINT_LANG_GLSL_AST_WRITER_GENERATOR_IMPL_H_
+#endif // SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_AST_PRINTER_H_
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_test.cc b/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator_impl_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
index d9a38a7..d3fed8d 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/ast_printer_test.cc
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest = TestHelper;
+using GlslASTPrinterTest = TestHelper;
-TEST_F(GlslGeneratorImplTest, InvalidProgram) {
+TEST_F(GlslASTPrinterTest, InvalidProgram) {
Diagnostics().add_error(diag::System::Writer, "make the program invalid");
ASSERT_FALSE(IsValid());
auto program = std::make_unique<Program>(std::move(*this));
@@ -30,10 +30,10 @@
EXPECT_EQ(result.error, "input program is not valid");
}
-TEST_F(GlslGeneratorImplTest, Generate) {
+TEST_F(GlslASTPrinterTest, Generate) {
Func("my_func", utils::Empty, ty.void_(), utils::Empty);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -44,10 +44,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest, GenerateDesktop) {
+TEST_F(GlslASTPrinterTest, GenerateDesktop) {
Func("my_func", utils::Empty, ty.void_(), utils::Empty);
- GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
+ ASTPrinter& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 440
@@ -58,7 +58,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) {
+TEST_F(GlslASTPrinterTest, GenerateSampleIndexES) {
GlobalVar("gl_SampleID", ty.i32(),
utils::Vector{
Builtin(builtin::BuiltinValue::kSampleIndex),
@@ -70,7 +70,7 @@
Return(Expr("gl_SampleID")),
});
- GeneratorImpl& gen = Build(Version(Version::Standard::kES, 3, 1));
+ ASTPrinter& gen = Build(Version(Version::Standard::kES, 3, 1));
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -83,7 +83,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) {
+TEST_F(GlslASTPrinterTest, GenerateSampleIndexDesktop) {
GlobalVar("gl_SampleID", ty.i32(),
utils::Vector{
Builtin(builtin::BuiltinValue::kSampleIndex),
@@ -95,7 +95,7 @@
Return(Expr("gl_SampleID")),
});
- GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
+ ASTPrinter& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 440
@@ -108,4 +108,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_binary_test.cc b/src/tint/lang/glsl/writer/ast_printer/binary_test.cc
similarity index 87%
rename from src/tint/lang/glsl/ast_writer/generator_impl_binary_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/binary_test.cc
index dd88dd0..0a793b4 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_binary_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/binary_test.cc
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Binary = TestHelper;
+using GlslASTPrinterTest_Binary = TestHelper;
struct BinaryData {
const char* result;
@@ -59,7 +59,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -88,7 +88,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -108,7 +108,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -133,7 +133,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -141,7 +141,7 @@
EXPECT_EQ(out.str(), params.result);
}
INSTANTIATE_TEST_SUITE_P(
- GlslGeneratorImplTest,
+ GlslASTPrinterTest,
GlslBinaryTest,
testing::Values(BinaryData{"(left & right)", ast::BinaryOp::kAnd},
BinaryData{"(left | right)", ast::BinaryOp::kOr},
@@ -160,7 +160,7 @@
BinaryData{"(left / right)", ast::BinaryOp::kDivide},
BinaryData{"(left % right)", ast::BinaryOp::kModulo}));
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_VectorScalar_f32) {
GlobalVar("a", Call<vec3<f32>>(1_f, 1_f, 1_f), builtin::AddressSpace::kPrivate);
auto* lhs = Expr("a");
auto* rhs = Expr(1_f);
@@ -169,7 +169,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -177,7 +177,7 @@
EXPECT_EQ(out.str(), "(a * 1.0f)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_VectorScalar_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", Call<vec3<f16>>(1_h, 1_h, 1_h), builtin::AddressSpace::kPrivate);
@@ -188,7 +188,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -196,7 +196,7 @@
EXPECT_EQ(out.str(), "(a * 1.0hf)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_ScalarVector_f32) {
GlobalVar("a", Call<vec3<f32>>(1_f, 1_f, 1_f), builtin::AddressSpace::kPrivate);
auto* lhs = Expr(1_f);
auto* rhs = Expr("a");
@@ -205,7 +205,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -213,7 +213,7 @@
EXPECT_EQ(out.str(), "(1.0f * a)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_ScalarVector_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", Call<vec3<f16>>(1_h, 1_h, 1_h), builtin::AddressSpace::kPrivate);
@@ -224,7 +224,7 @@
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -232,7 +232,7 @@
EXPECT_EQ(out.str(), "(1.0hf * a)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixScalar_f32) {
GlobalVar("mat", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = Expr(1_f);
@@ -240,7 +240,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -248,7 +248,7 @@
EXPECT_EQ(out.str(), "(mat * 1.0f)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixScalar_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("mat", ty.mat3x3<f16>(), builtin::AddressSpace::kPrivate);
@@ -258,7 +258,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -266,7 +266,7 @@
EXPECT_EQ(out.str(), "(mat * 1.0hf)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_ScalarMatrix_f32) {
GlobalVar("mat", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* lhs = Expr(1_f);
auto* rhs = Expr("mat");
@@ -274,7 +274,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -282,7 +282,7 @@
EXPECT_EQ(out.str(), "(1.0f * mat)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_ScalarMatrix_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("mat", ty.mat3x3<f16>(), builtin::AddressSpace::kPrivate);
@@ -292,7 +292,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -300,7 +300,7 @@
EXPECT_EQ(out.str(), "(1.0hf * mat)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixVector_f32) {
GlobalVar("mat", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = Call<vec3<f32>>(1_f, 1_f, 1_f);
@@ -308,7 +308,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -316,7 +316,7 @@
EXPECT_EQ(out.str(), "(mat * vec3(1.0f))");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixVector_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("mat", ty.mat3x3<f16>(), builtin::AddressSpace::kPrivate);
@@ -326,7 +326,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -334,7 +334,7 @@
EXPECT_EQ(out.str(), "(mat * f16vec3(1.0hf))");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_VectorMatrix_f32) {
GlobalVar("mat", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* lhs = Call<vec3<f32>>(1_f, 1_f, 1_f);
auto* rhs = Expr("mat");
@@ -342,7 +342,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -350,7 +350,7 @@
EXPECT_EQ(out.str(), "(vec3(1.0f) * mat)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_VectorMatrix_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("mat", ty.mat3x3<f16>(), builtin::AddressSpace::kPrivate);
@@ -360,7 +360,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -368,14 +368,14 @@
EXPECT_EQ(out.str(), "(f16vec3(1.0hf) * mat)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f32) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixMatrix_f32) {
GlobalVar("lhs", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
GlobalVar("rhs", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -383,7 +383,7 @@
EXPECT_EQ(out.str(), "(lhs * rhs)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix_f16) {
+TEST_F(GlslASTPrinterTest_Binary, Multiply_MatrixMatrix_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("lhs", ty.mat3x3<f16>(), builtin::AddressSpace::kPrivate);
@@ -392,7 +392,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -400,14 +400,14 @@
EXPECT_EQ(out.str(), "(lhs * rhs)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModF32) {
+TEST_F(GlslASTPrinterTest_Binary, ModF32) {
GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -415,7 +415,7 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModF16) {
+TEST_F(GlslASTPrinterTest_Binary, ModF16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.f16(), builtin::AddressSpace::kPrivate);
@@ -424,7 +424,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -432,14 +432,14 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) {
+TEST_F(GlslASTPrinterTest_Binary, ModVec3F32) {
GlobalVar("a", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -447,7 +447,7 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16) {
+TEST_F(GlslASTPrinterTest_Binary, ModVec3F16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.vec3<f16>(), builtin::AddressSpace::kPrivate);
@@ -456,7 +456,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -464,14 +464,14 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32ScalarF32) {
+TEST_F(GlslASTPrinterTest_Binary, ModVec3F32ScalarF32) {
GlobalVar("a", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -479,7 +479,7 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModVec3F16ScalarF16) {
+TEST_F(GlslASTPrinterTest_Binary, ModVec3F16ScalarF16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.vec3<f16>(), builtin::AddressSpace::kPrivate);
@@ -488,7 +488,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -496,14 +496,14 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModScalarF32Vec3F32) {
+TEST_F(GlslASTPrinterTest_Binary, ModScalarF32Vec3F32) {
GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -511,7 +511,7 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModScalarF16Vec3F16) {
+TEST_F(GlslASTPrinterTest_Binary, ModScalarF16Vec3F16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.f16(), builtin::AddressSpace::kPrivate);
@@ -520,7 +520,7 @@
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -528,7 +528,7 @@
EXPECT_EQ(out.str(), "tint_float_modulo(a, b)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF32) {
+TEST_F(GlslASTPrinterTest_Binary, ModMixedVec3ScalarF32) {
GlobalVar("a", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.f32(), builtin::AddressSpace::kPrivate);
@@ -540,7 +540,7 @@
create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("b"), Expr("a"));
WrapInFunction(expr_vec_mod_vec, expr_vec_mod_scalar, expr_scalar_mod_vec);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -571,7 +571,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, ModMixedVec3ScalarF16) {
+TEST_F(GlslASTPrinterTest_Binary, ModMixedVec3ScalarF16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.vec3<f16>(), builtin::AddressSpace::kPrivate);
@@ -585,7 +585,7 @@
create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("b"), Expr("a"));
WrapInFunction(expr_vec_mod_vec, expr_vec_mod_scalar, expr_scalar_mod_vec);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -617,14 +617,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Logical_And) {
+TEST_F(GlslASTPrinterTest_Binary, Logical_And) {
GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -637,7 +637,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Logical_Multi) {
+TEST_F(GlslASTPrinterTest_Binary, Logical_Multi) {
// (a && b) || (c || d)
GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -650,7 +650,7 @@
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("c"), Expr("d")));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -671,14 +671,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Logical_Or) {
+TEST_F(GlslASTPrinterTest_Binary, Logical_Or) {
GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate);
GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b"));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, expr);
@@ -691,7 +691,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
+TEST_F(GlslASTPrinterTest_Binary, If_WithLogical) {
// if (a && b) {
// return 1i;
// } else if (b || c) {
@@ -711,7 +711,7 @@
Block(Return(2_i)), Else(Block(Return(3_i))))));
Func("func", utils::Empty, ty.i32(), utils::Vector{WrapInStatement(expr)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -735,7 +735,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Return_WithLogical) {
+TEST_F(GlslASTPrinterTest_Binary, Return_WithLogical) {
// return (a && b) || c;
GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -748,7 +748,7 @@
Expr("c")));
Func("func", utils::Empty, ty.bool_(), utils::Vector{WrapInStatement(expr)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -764,7 +764,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Assign_WithLogical) {
+TEST_F(GlslASTPrinterTest_Binary, Assign_WithLogical) {
// a = (b || c) && d;
GlobalVar("a", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -780,7 +780,7 @@
Expr("d")));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -796,7 +796,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Decl_WithLogical) {
+TEST_F(GlslASTPrinterTest_Binary, Decl_WithLogical) {
// var a : bool = (b && c) || d;
GlobalVar("b", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -813,7 +813,7 @@
auto* decl = Decl(var);
WrapInFunction(decl);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(decl);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -829,7 +829,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) {
+TEST_F(GlslASTPrinterTest_Binary, Call_WithLogical) {
// foo(a && b, c || d, (a || c) && (b || d))
Func("foo",
@@ -856,7 +856,7 @@
auto* expr = CallStmt(Call("foo", params));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -885,4 +885,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_bitcast_test.cc b/src/tint/lang/glsl/writer/ast_printer/bitcast_test.cc
similarity index 87%
rename from src/tint/lang/glsl/ast_writer/generator_impl_bitcast_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/bitcast_test.cc
index 8ec4194..e8b4c9d 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_bitcast_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/bitcast_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
@@ -21,17 +21,17 @@
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Bitcast = TestHelper;
+using GlslASTPrinterTest_Bitcast = TestHelper;
-TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
+TEST_F(GlslASTPrinterTest_Bitcast, EmitExpression_Bitcast_Float) {
auto* a = Let("a", Expr(1_i));
auto* bitcast = Bitcast<f32>(Expr("a"));
WrapInFunction(a, bitcast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, bitcast);
@@ -39,12 +39,12 @@
EXPECT_EQ(out.str(), "intBitsToFloat(a)");
}
-TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
+TEST_F(GlslASTPrinterTest_Bitcast, EmitExpression_Bitcast_Int) {
auto* a = Let("a", Expr(1_u));
auto* bitcast = Bitcast<i32>(Expr("a"));
WrapInFunction(a, bitcast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, bitcast);
@@ -52,12 +52,12 @@
EXPECT_EQ(out.str(), "int(a)");
}
-TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
+TEST_F(GlslASTPrinterTest_Bitcast, EmitExpression_Bitcast_Uint) {
auto* a = Let("a", Expr(1_i));
auto* bitcast = Bitcast<u32>(Expr("a"));
WrapInFunction(a, bitcast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, bitcast);
@@ -65,7 +65,7 @@
EXPECT_EQ(out.str(), "uint(a)");
}
-TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_F16_Vec2) {
+TEST_F(GlslASTPrinterTest_Bitcast, EmitExpression_Bitcast_F16_Vec2) {
Enable(builtin::Extension::kF16);
auto* a = Let("a", Call<vec2<f16>>(1_h, 2_h));
@@ -77,7 +77,7 @@
auto* g = Let("g", Bitcast<vec2<f16>>(Expr("f")));
WrapInFunction(a, b, c, d, e, f, g);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -123,7 +123,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_F16_Vec4) {
+TEST_F(GlslASTPrinterTest_Bitcast, EmitExpression_Bitcast_F16_Vec4) {
Enable(builtin::Extension::kF16);
auto* a = Let("a", Call<vec4<f16>>(1_h, 2_h, 3_h, 4_h));
@@ -135,7 +135,7 @@
auto* g = Let("g", Bitcast<vec4<f16>>(Expr("f")));
WrapInFunction(a, b, c, d, e, f, g);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -188,4 +188,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_block_test.cc b/src/tint/lang/glsl/writer/ast_printer/block_test.cc
similarity index 77%
rename from src/tint/lang/glsl/ast_writer/generator_impl_block_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/block_test.cc
index 90bf130..a8e4669 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_block_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/block_test.cc
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Block = TestHelper;
+using GlslASTPrinterTest_Block = TestHelper;
-TEST_F(GlslGeneratorImplTest_Block, Emit_Block) {
+TEST_F(GlslASTPrinterTest_Block, Emit_Block) {
auto* b = Block(Return());
WrapInFunction(b);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(b);
@@ -37,4 +37,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_break_test.cc b/src/tint/lang/glsl/writer/ast_printer/break_test.cc
similarity index 77%
rename from src/tint/lang/glsl/ast_writer/generator_impl_break_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/break_test.cc
index ea14381..c9db340 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_break_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/break_test.cc
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Break = TestHelper;
+using GlslASTPrinterTest_Break = TestHelper;
-TEST_F(GlslGeneratorImplTest_Break, Emit_Break) {
+TEST_F(GlslASTPrinterTest_Break, Emit_Break) {
auto* b = create<ast::BreakStatement>();
WrapInFunction(Loop(Block(b)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(b);
@@ -34,4 +34,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_builtin_test.cc b/src/tint/lang/glsl/writer/ast_printer/builtin_test.cc
similarity index 89%
rename from src/tint/lang/glsl/ast_writer/generator_impl_builtin_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/builtin_test.cc
index ba7d257..a5b0083 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_builtin_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/builtin_test.cc
@@ -13,20 +13,20 @@
// limitations under the License.
#include "gmock/gmock.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/sem/call.h"
#include "src/tint/utils/text/string_stream.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using ::testing::HasSubstr;
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Builtin = TestHelper;
+using GlslASTPrinterTest_Builtin = TestHelper;
enum class CallParamType {
kF32,
@@ -219,7 +219,7 @@
},
utils::Vector{create<ast::StageAttribute>(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
auto* sem = program->Sem().Get<sem::Call>(call);
ASSERT_NE(sem, nullptr);
@@ -231,7 +231,7 @@
EXPECT_EQ(gen.generate_builtin_name(builtin), param.glsl_name);
}
INSTANTIATE_TEST_SUITE_P(
- GlslGeneratorImplTest_Builtin,
+ GlslASTPrinterTest_Builtin,
GlslBuiltinTest,
testing::
Values(/* Logical built-in */
@@ -339,7 +339,7 @@
BuiltinData{builtin::Function::kFwidthCoarse, CallParamType::kF32, "fwidth"},
BuiltinData{builtin::Function::kFwidthFine, CallParamType::kF32, "fwidth"}));
-TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) {
+TEST_F(GlslASTPrinterTest_Builtin, Builtin_Call) {
auto* call = Call("dot", "param1", "param2");
GlobalVar("param1", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
@@ -347,7 +347,7 @@
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
utils::StringStream out;
@@ -356,12 +356,12 @@
EXPECT_EQ(out.str(), "dot(param1, param2)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
+TEST_F(GlslASTPrinterTest_Builtin, Select_Scalar) {
GlobalVar("a", Expr(1_f), builtin::AddressSpace::kPrivate);
GlobalVar("b", Expr(2_f), builtin::AddressSpace::kPrivate);
auto* call = Call("select", "a", "b", true);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
utils::StringStream out;
@@ -370,12 +370,12 @@
EXPECT_EQ(out.str(), "(true ? b : a)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Select_Vector) {
+TEST_F(GlslASTPrinterTest_Builtin, Select_Vector) {
GlobalVar("a", Call<vec2<i32>>(1_i, 2_i), builtin::AddressSpace::kPrivate);
GlobalVar("b", Call<vec2<i32>>(3_i, 4_i), builtin::AddressSpace::kPrivate);
auto* call = Call("select", "a", "b", Call<vec2<bool>>(true, false));
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
utils::StringStream out;
@@ -384,7 +384,7 @@
EXPECT_EQ(out.str(), "tint_select(a, b, bvec2(true, false))");
}
-TEST_F(GlslGeneratorImplTest_Builtin, FMA_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, FMA_f32) {
auto* call = Call("fma", "a", "b", "c");
GlobalVar("a", ty.vec3<f32>(), builtin::AddressSpace::kPrivate);
@@ -393,7 +393,7 @@
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
utils::StringStream out;
@@ -402,7 +402,7 @@
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
}
-TEST_F(GlslGeneratorImplTest_Builtin, FMA_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, FMA_f16) {
Enable(builtin::Extension::kF16);
GlobalVar("a", ty.vec3<f16>(), builtin::AddressSpace::kPrivate);
@@ -412,7 +412,7 @@
auto* call = Call("fma", "a", "b", "c");
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
utils::StringStream out;
@@ -421,11 +421,11 @@
EXPECT_EQ(out.str(), "((a) * (b) + (c))");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Modf_Scalar_f32) {
WrapInFunction(Decl(Let("f", Expr(1.5_f))), //
Decl(Let("v", Call("modf", "f"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -456,13 +456,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Modf_Scalar_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("f", Expr(1.5_h))), //
Decl(Let("v", Call("modf", "f"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -494,11 +494,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Modf_Vector_f32) {
WrapInFunction(Decl(Let("f", Call<vec3<f32>>(1.5_f, 2.5_f, 3.5_f))), //
Decl(Let("v", Call("modf", "f"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -529,13 +529,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Modf_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Modf_Vector_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("f", Call<vec3<f16>>(1.5_h, 2.5_h, 3.5_h))), //
Decl(Let("v", Call("modf", "f"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -567,10 +567,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Modf_Scalar_f32) {
WrapInFunction(Decl(Let("v", Call("modf", 1.5_f))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -594,12 +594,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Modf_Scalar_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("v", Call("modf", 1.5_h))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -624,10 +624,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Modf_Vector_f32) {
WrapInFunction(Decl(Let("v", Call("modf", Call<vec3<f32>>(1.5_f, 2.5_f, 3.5_f)))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -651,12 +651,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Modf_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Modf_Vector_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("v", Call("modf", Call<vec3<f16>>(1.5_h, 2.5_h, 3.5_h)))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -681,11 +681,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Frexp_Scalar_f32) {
WrapInFunction(Var("f", Expr(1_f)), //
Var("v", Call("frexp", "f")));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -716,13 +716,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Frexp_Scalar_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Var("f", Expr(1_h)), //
Var("v", Call("frexp", "f")));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -754,11 +754,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Frexp_Vector_f32) {
WrapInFunction(Var("f", Call<vec3<f32>>()), //
Var("v", Call("frexp", "f")));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -789,13 +789,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Runtime_Frexp_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Runtime_Frexp_Vector_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Var("f", Call<vec3<f16>>()), //
Var("v", Call("frexp", "f")));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -827,10 +827,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Frexp_Scalar_f32) {
WrapInFunction(Decl(Let("v", Call("frexp", 1_f))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -854,12 +854,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Frexp_Scalar_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("v", Call("frexp", 1_h))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -884,10 +884,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Frexp_Vector_f32) {
WrapInFunction(Decl(Let("v", Call("frexp", Call<vec3<f32>>()))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -911,12 +911,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Const_Frexp_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Const_Frexp_Vector_f16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Decl(Let("v", Call("frexp", Call<vec3<f16>>()))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -941,12 +941,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Degrees_Scalar_f32) {
auto* val = Var("val", ty.f32());
auto* call = Call("degrees", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -970,12 +970,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Degrees_Vector_f32) {
auto* val = Var("val", ty.vec3<f32>());
auto* call = Call("degrees", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -999,14 +999,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Degrees_Scalar_f16) {
Enable(builtin::Extension::kF16);
auto* val = Var("val", ty.f16());
auto* call = Call("degrees", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1031,14 +1031,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Degrees_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Degrees_Vector_f16) {
Enable(builtin::Extension::kF16);
auto* val = Var("val", ty.vec3<f16>());
auto* call = Call("degrees", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1063,12 +1063,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Radians_Scalar_f32) {
auto* val = Var("val", ty.f32());
auto* call = Call("radians", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1092,12 +1092,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f32) {
+TEST_F(GlslASTPrinterTest_Builtin, Radians_Vector_f32) {
auto* val = Var("val", ty.vec3<f32>());
auto* call = Call("radians", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1121,14 +1121,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Radians_Scalar_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Radians_Scalar_f16) {
Enable(builtin::Extension::kF16);
auto* val = Var("val", ty.f16());
auto* call = Call("radians", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1153,14 +1153,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Radians_Vector_f16) {
+TEST_F(GlslASTPrinterTest_Builtin, Radians_Vector_f16) {
Enable(builtin::Extension::kF16);
auto* val = Var("val", ty.vec3<f16>());
auto* call = Call("radians", val);
WrapInFunction(val, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1185,14 +1185,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, ExtractBits) {
+TEST_F(GlslASTPrinterTest_Builtin, ExtractBits) {
auto* v = Var("v", ty.vec3<u32>());
auto* offset = Var("offset", ty.u32());
auto* count = Var("count", ty.u32());
auto* call = Call("extractBits", v, offset, count);
WrapInFunction(v, offset, count, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1219,7 +1219,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, InsertBits) {
+TEST_F(GlslASTPrinterTest_Builtin, InsertBits) {
auto* v = Var("v", ty.vec3<u32>());
auto* n = Var("n", ty.vec3<u32>());
auto* offset = Var("offset", ty.u32());
@@ -1227,7 +1227,7 @@
auto* call = Call("insertBits", v, n, offset, count);
WrapInFunction(v, n, offset, count, call);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1255,11 +1255,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Pack4x8Snorm) {
auto* call = Call("pack4x8snorm", "p1");
GlobalVar("p1", ty.vec4<f32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1274,11 +1274,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Pack4x8Unorm) {
auto* call = Call("pack4x8unorm", "p1");
GlobalVar("p1", ty.vec4<f32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1293,11 +1293,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Pack2x16Snorm) {
auto* call = Call("pack2x16snorm", "p1");
GlobalVar("p1", ty.vec2<f32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1312,11 +1312,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Pack2x16Unorm) {
auto* call = Call("pack2x16unorm", "p1");
GlobalVar("p1", ty.vec2<f32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1331,11 +1331,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Float) {
+TEST_F(GlslASTPrinterTest_Builtin, Pack2x16Float) {
auto* call = Call("pack2x16float", "p1");
GlobalVar("p1", ty.vec2<f32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1350,11 +1350,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Unpack4x8Snorm) {
auto* call = Call("unpack4x8snorm", "p1");
GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1369,11 +1369,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Unpack4x8Unorm) {
auto* call = Call("unpack4x8unorm", "p1");
GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1388,11 +1388,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Unpack2x16Snorm) {
auto* call = Call("unpack2x16snorm", "p1");
GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1407,11 +1407,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
+TEST_F(GlslASTPrinterTest_Builtin, Unpack2x16Unorm) {
auto* call = Call("unpack2x16unorm", "p1");
GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1426,11 +1426,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) {
+TEST_F(GlslASTPrinterTest_Builtin, Unpack2x16Float) {
auto* call = Call("unpack2x16float", "p1");
GlobalVar("p1", ty.u32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", call)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1445,7 +1445,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, StorageBarrier) {
+TEST_F(GlslASTPrinterTest_Builtin, StorageBarrier) {
Func("main", utils::Empty, ty.void_(),
utils::Vector{
CallStmt(Call("storageBarrier")),
@@ -1455,7 +1455,7 @@
WorkgroupSize(1_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1469,7 +1469,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, WorkgroupBarrier) {
+TEST_F(GlslASTPrinterTest_Builtin, WorkgroupBarrier) {
Func("main", utils::Empty, ty.void_(),
utils::Vector{
CallStmt(Call("workgroupBarrier")),
@@ -1479,7 +1479,7 @@
WorkgroupSize(1_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1493,11 +1493,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, DotI32) {
+TEST_F(GlslASTPrinterTest_Builtin, DotI32) {
GlobalVar("v", ty.vec3<i32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", Call("dot", "v", "v"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1520,11 +1520,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, DotU32) {
+TEST_F(GlslASTPrinterTest_Builtin, DotU32) {
GlobalVar("v", ty.vec3<u32>(), builtin::AddressSpace::kPrivate);
WrapInFunction(Decl(Var("r", Call("dot", "v", "v"))));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1547,11 +1547,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Scalar) {
+TEST_F(GlslASTPrinterTest_Builtin, QuantizeToF16_Scalar) {
GlobalVar("v", Expr(2_f), builtin::AddressSpace::kPrivate);
WrapInFunction(Call("quantizeToF16", "v"));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1575,11 +1575,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec2) {
+TEST_F(GlslASTPrinterTest_Builtin, QuantizeToF16_Vec2) {
GlobalVar("v", Call<vec2<f32>>(2_f), builtin::AddressSpace::kPrivate);
WrapInFunction(Call("quantizeToF16", "v"));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1603,11 +1603,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec3) {
+TEST_F(GlslASTPrinterTest_Builtin, QuantizeToF16_Vec3) {
GlobalVar("v", Call<vec3<f32>>(2_f), builtin::AddressSpace::kPrivate);
WrapInFunction(Call("quantizeToF16", "v"));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1633,11 +1633,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Builtin, QuantizeToF16_Vec4) {
+TEST_F(GlslASTPrinterTest_Builtin, QuantizeToF16_Vec4) {
GlobalVar("v", Call<vec4<f32>>(2_f), builtin::AddressSpace::kPrivate);
WrapInFunction(Call("quantizeToF16", "v"));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -1664,4 +1664,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_builtin_texture_test.cc b/src/tint/lang/glsl/writer/ast_printer/builtin_texture_test.cc
similarity index 98%
rename from src/tint/lang/glsl/ast_writer/generator_impl_builtin_texture_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/builtin_texture_test.cc
index f6cdaa0..320b45c 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_builtin_texture_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/builtin_texture_test.cc
@@ -13,12 +13,12 @@
// limitations under the License.
#include "gmock/gmock.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/builtin_texture_helper_test.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using ::testing::HasSubstr;
@@ -286,7 +286,7 @@
Func("main", utils::Empty, ty.void_(), utils::Vector{stmt},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -302,4 +302,4 @@
testing::ValuesIn(ast::test::TextureOverloadCase::ValidCases()));
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_call_test.cc b/src/tint/lang/glsl/writer/ast_printer/call_test.cc
similarity index 82%
rename from src/tint/lang/glsl/ast_writer/generator_impl_call_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/call_test.cc
index 9abe085..fb1cfbf 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_call_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/call_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/utils/text/string_stream.h"
@@ -20,18 +20,18 @@
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Call = TestHelper;
+using GlslASTPrinterTest_Call = TestHelper;
-TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
+TEST_F(GlslASTPrinterTest_Call, EmitExpression_Call_WithoutParams) {
Func("my_func", utils::Empty, ty.f32(), utils::Vector{Return(1.23_f)});
auto* call = Call("my_func");
WrapInFunction(call);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, call);
@@ -39,7 +39,7 @@
EXPECT_EQ(out.str(), "my_func()");
}
-TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
+TEST_F(GlslASTPrinterTest_Call, EmitExpression_Call_WithParams) {
Func("my_func",
utils::Vector{
Param(Sym(), ty.f32()),
@@ -52,7 +52,7 @@
auto* call = Call("my_func", "param1", "param2");
WrapInFunction(call);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, call);
@@ -60,7 +60,7 @@
EXPECT_EQ(out.str(), "my_func(param1, param2)");
}
-TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) {
+TEST_F(GlslASTPrinterTest_Call, EmitStatement_Call) {
Func("my_func",
utils::Vector{
Param(Sym(), ty.f32()),
@@ -73,7 +73,7 @@
auto* call = CallStmt(Call("my_func", "param1", "param2"));
WrapInFunction(call);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(call);
@@ -82,4 +82,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_case_test.cc b/src/tint/lang/glsl/writer/ast_printer/case_test.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator_impl_case_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/case_test.cc
index a3b8b83..cee46db 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_case_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/case_test.cc
@@ -12,23 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Case = TestHelper;
+using GlslASTPrinterTest_Case = TestHelper;
-TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
+TEST_F(GlslASTPrinterTest_Case, Emit_Case) {
auto* s =
Switch(1_i, Case(CaseSelector(5_i), Block(create<ast::BreakStatement>())), DefaultCase());
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitCase(s->body[0]);
@@ -38,11 +38,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
+TEST_F(GlslASTPrinterTest_Case, Emit_Case_BreaksByDefault) {
auto* s = Switch(1_i, Case(CaseSelector(5_i), Block()), DefaultCase());
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitCase(s->body[0]);
@@ -53,7 +53,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
+TEST_F(GlslASTPrinterTest_Case, Emit_Case_MultipleSelectors) {
auto* s = Switch(1_i,
Case(
utils::Vector{
@@ -64,7 +64,7 @@
DefaultCase());
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitCase(s->body[0]);
@@ -76,11 +76,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Case, Emit_Case_Default) {
+TEST_F(GlslASTPrinterTest_Case, Emit_Case_Default) {
auto* s = Switch(1_i, DefaultCase(Block(create<ast::BreakStatement>())));
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitCase(s->body[0]);
@@ -92,4 +92,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_cast_test.cc b/src/tint/lang/glsl/writer/ast_printer/cast_test.cc
similarity index 77%
rename from src/tint/lang/glsl/ast_writer/generator_impl_cast_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/cast_test.cc
index 2a147ec..3393b65 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_cast_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/cast_test.cc
@@ -12,24 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Cast = TestHelper;
+using GlslASTPrinterTest_Cast = TestHelper;
-TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) {
+TEST_F(GlslASTPrinterTest_Cast, EmitExpression_Cast_Scalar) {
auto* cast = Call<f32>(1_i);
WrapInFunction(cast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, cast);
@@ -37,11 +37,11 @@
EXPECT_EQ(out.str(), "1.0f");
}
-TEST_F(GlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) {
+TEST_F(GlslASTPrinterTest_Cast, EmitExpression_Cast_Vector) {
auto* cast = Call<vec3<f32>>(Call<vec3<i32>>(1_i, 2_i, 3_i));
WrapInFunction(cast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, cast);
@@ -50,4 +50,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_constructor_test.cc b/src/tint/lang/glsl/writer/ast_printer/constructor_test.cc
similarity index 76%
rename from src/tint/lang/glsl/ast_writer/generator_impl_constructor_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/constructor_test.cc
index 436205b..a717356 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_constructor_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/constructor_test.cc
@@ -13,250 +13,250 @@
// limitations under the License.
#include "gmock/gmock.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using ::testing::HasSubstr;
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Constructor = TestHelper;
+using GlslASTPrinterTest_Constructor = TestHelper;
-TEST_F(GlslGeneratorImplTest_Constructor, Bool) {
+TEST_F(GlslASTPrinterTest_Constructor, Bool) {
WrapInFunction(Expr(false));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("false"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Int) {
+TEST_F(GlslASTPrinterTest_Constructor, Int) {
WrapInFunction(Expr(-12345_i));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("-12345"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, UInt) {
+TEST_F(GlslASTPrinterTest_Constructor, UInt) {
WrapInFunction(Expr(56779_u));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("56779u"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Float) {
+TEST_F(GlslASTPrinterTest_Constructor, Float) {
// Use a number close to 1<<30 but whose decimal representation ends in 0.
WrapInFunction(Expr(f32((1 << 30) - 4)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("1073741824.0f"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, F16) {
+TEST_F(GlslASTPrinterTest_Constructor, F16) {
Enable(builtin::Extension::kF16);
// Use a number close to 1<<16 but whose decimal representation ends in 0.
WrapInFunction(Expr(f16((1 << 15) - 8)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("32752.0hf"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Float) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Float) {
WrapInFunction(Call<f32>(-1.2e-5_f));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("-0.00001200000042445026f"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_F16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Call<f16>(-1.2e-3_h));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("-0.0011997222900390625hf"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Bool) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Bool) {
WrapInFunction(Call<bool>(true));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("true"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Int) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Int) {
WrapInFunction(Call<i32>(-12345_i));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("-12345"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Uint) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Uint) {
WrapInFunction(Call<u32>(12345_u));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("12345u"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_F32) {
WrapInFunction(Call<vec3<f32>>(1_f, 2_f, 3_f));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("vec3(1.0f, 2.0f, 3.0f)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_F16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Call<vec3<f16>>(1_h, 2_h, 3_h));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("f16vec3(1.0hf, 2.0hf, 3.0hf)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_Empty_F32) {
WrapInFunction(Call<vec3<f32>>());
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("vec3(0.0f)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_Empty_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_Empty_F16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Call<vec3<f16>>());
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("f16vec3(0.0hf)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_F32_Literal) {
WrapInFunction(Call<vec3<f32>>(2_f));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("vec3(2.0f)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_F16_Literal) {
Enable(builtin::Extension::kF16);
WrapInFunction(Call<vec3<f16>>(2_h));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("f16vec3(2.0hf)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_F32_Var) {
auto* var = Var("v", Expr(2_f));
auto* cast = Call<vec3<f32>>(var);
WrapInFunction(var, cast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(R"(float v = 2.0f;
vec3 tint_symbol = vec3(v);)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_F16_Var) {
Enable(builtin::Extension::kF16);
auto* var = Var("v", Expr(2_h));
auto* cast = Call<vec3<f16>>(var);
WrapInFunction(var, cast);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(R"(float16_t v = 2.0hf;
f16vec3 tint_symbol = f16vec3(v);)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Bool) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_Bool) {
WrapInFunction(Call<vec3<bool>>(true));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("bvec3(true)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_Int) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_Int) {
WrapInFunction(Call<vec3<i32>>(2_i));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("ivec3(2)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Vec_SingleScalar_UInt) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Vec_SingleScalar_UInt) {
WrapInFunction(Call<vec3<u32>>(2_u));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("uvec3(2u)"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_F32) {
WrapInFunction(
Call<mat2x3<f32>>(Call<vec3<f32>>(1_f, 2_f, 3_f), Call<vec3<f32>>(3_f, 4_f, 5_f)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(3.0f, 4.0f, 5.0f))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_F16) {
Enable(builtin::Extension::kF16);
WrapInFunction(
Call<mat2x3<f16>>(Call<vec3<f16>>(1_h, 2_h, 3_h), Call<vec3<f16>>(3_h, 4_h, 5_h)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(),
HasSubstr("f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(3.0hf, 4.0hf, 5.0hf))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Complex_F32) {
// mat4x4<f32>(
// vec4<f32>(2.0f, 3.0f, 4.0f, 8.0f),
// vec4<f32>(),
@@ -275,14 +275,14 @@
WrapInFunction(ctor);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("mat4(vec4(2.0f, 3.0f, 4.0f, 8.0f), vec4(0.0f), "
"vec4(7.0f), vec4(42.0f, 21.0f, 6.0f, -5.0f))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Complex_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Complex_F16) {
// mat4x4<f16>(
// vec4<f16>(2.0h, 3.0h, 4.0h, 8.0h),
// vec4<f16>(),
@@ -303,7 +303,7 @@
WrapInFunction(ctor);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(),
@@ -311,28 +311,28 @@
"f16vec4(7.0hf), f16vec4(42.0hf, 21.0hf, 6.0hf, -5.0hf))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Empty_F32) {
WrapInFunction(Call<mat2x3<f32>>());
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("mat2x3 tint_symbol = mat2x3(vec3(0.0f), vec3(0.0f))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Empty_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Empty_F16) {
Enable(builtin::Extension::kF16);
WrapInFunction(Call<mat2x3<f16>>());
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(),
HasSubstr("f16mat2x3 tint_symbol = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F32) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Identity_F32) {
// fn f() {
// var m_1: mat4x4<f32> = mat4x4<f32>();
// var m_2: mat4x4<f32> = mat4x4<f32>(m_1);
@@ -343,13 +343,13 @@
WrapInFunction(m_1, m_2);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("mat4 m_2 = mat4(m_1);"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Mat_Identity_F16) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Mat_Identity_F16) {
// fn f() {
// var m_1: mat4x4<f16> = mat4x4<f16>();
// var m_2: mat4x4<f16> = mat4x4<f16>(m_1);
@@ -362,18 +362,18 @@
WrapInFunction(m_1, m_2);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("f16mat4 m_2 = f16mat4(m_1);"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Array) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Array) {
WrapInFunction(Call<array<vec3<f32>, 3>>(Call<vec3<f32>>(1_f, 2_f, 3_f),
Call<vec3<f32>>(4_f, 5_f, 6_f),
Call<vec3<f32>>(7_f, 8_f, 9_f)));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("vec3[3](vec3(1.0f, 2.0f, 3.0f), "
@@ -381,16 +381,16 @@
"vec3(7.0f, 8.0f, 9.0f))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Array_Empty) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Array_Empty) {
WrapInFunction(Call<array<vec3<f32>, 3>>());
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("vec3[3](vec3(0.0f), vec3(0.0f), vec3(0.0f))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Struct) {
auto* str = Structure("S", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -399,13 +399,13 @@
WrapInFunction(Call(ty.Of(str), 1_i, 2_f, Call<vec3<i32>>(3_i, 4_i, 5_i)));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("S(1, 2.0f, ivec3(3, 4, 5))"));
}
-TEST_F(GlslGeneratorImplTest_Constructor, Type_Struct_Empty) {
+TEST_F(GlslASTPrinterTest_Constructor, Type_Struct_Empty) {
auto* str = Structure("S", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -414,11 +414,11 @@
WrapInFunction(Call(ty.Of(str)));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("S(0"));
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_continue_test.cc b/src/tint/lang/glsl/writer/ast_printer/continue_test.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator_impl_continue_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/continue_test.cc
index cde403b..e689af6 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_continue_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/continue_test.cc
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Continue = TestHelper;
+using GlslASTPrinterTest_Continue = TestHelper;
-TEST_F(GlslGeneratorImplTest_Continue, Emit_Continue) {
+TEST_F(GlslASTPrinterTest_Continue, Emit_Continue) {
auto* loop = Loop(Block(If(false, Block(Break())), Continue()));
WrapInFunction(loop);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
@@ -41,4 +41,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_discard_test.cc b/src/tint/lang/glsl/writer/ast_printer/discard_test.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator_impl_discard_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/discard_test.cc
index 68a3b94..34c543a 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_discard_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/discard_test.cc
@@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Discard = TestHelper;
+using GlslASTPrinterTest_Discard = TestHelper;
-TEST_F(GlslGeneratorImplTest_Discard, Emit_Discard) {
+TEST_F(GlslASTPrinterTest_Discard, Emit_Discard) {
auto* stmt = Discard();
Func("F", utils::Empty, ty.void_(), utils::Vector{stmt},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(stmt);
@@ -36,4 +36,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_function_test.cc b/src/tint/lang/glsl/writer/ast_printer/function_test.cc
similarity index 86%
rename from src/tint/lang/glsl/ast_writer/generator_impl_function_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/function_test.cc
index 23e91a2..672ba84 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_function_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/function_test.cc
@@ -13,28 +13,28 @@
// limitations under the License.
#include "gmock/gmock.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/ast/workgroup_attribute.h"
using ::testing::HasSubstr;
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Function = TestHelper;
+using GlslASTPrinterTest_Function = TestHelper;
-TEST_F(GlslGeneratorImplTest_Function, Emit_Function) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Function) {
Func("my_func", utils::Empty, ty.void_(),
utils::Vector{
Return(),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.Generate();
@@ -48,13 +48,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Function_Name_Collision) {
Func("centroid", utils::Empty, ty.void_(),
utils::Vector{
Return(),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.IncrementIndent();
gen.Generate();
@@ -64,7 +64,7 @@
})"));
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithParams) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Function_WithParams) {
Func("my_func",
utils::Vector{
Param("a", ty.f32()),
@@ -75,7 +75,7 @@
Return(),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.Generate();
@@ -89,13 +89,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_NoReturn_Void) {
Func("func", utils::Empty, ty.void_(), utils::Empty /* no explicit return */,
utils::Vector{
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -107,14 +107,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, PtrParameter) {
+TEST_F(GlslASTPrinterTest_Function, PtrParameter) {
// fn f(foo : ptr<function, f32>) -> f32 {
// return *foo;
// }
Func("f", utils::Vector{Param("foo", ty.ptr<function, f32>())}, ty.f32(),
utils::Vector{Return(Deref("foo"))});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(R"(float f(inout float foo) {
@@ -123,7 +123,7 @@
)"));
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOutVars) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_WithInOutVars) {
// fn frag_main(@location(0) foo : f32) -> @location(1) f32 {
// return foo;
// }
@@ -142,7 +142,7 @@
Location(1_a),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -162,7 +162,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithInOut_Builtins) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_WithInOut_Builtins) {
// fn frag_main(@position(0) coord : vec4<f32>) -> @frag_depth f32 {
// return coord.x;
// }
@@ -183,7 +183,7 @@
Builtin(builtin::BuiltinValue::kFragDepth),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -201,7 +201,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_SharedStruct_DifferentStages) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_SharedStruct_DifferentStages) {
// struct Interface {
// @builtin(position) pos : vec4<f32>;
// @location(1) col1 : f32;
@@ -235,7 +235,7 @@
},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -281,7 +281,7 @@
}
#if 0
-TEST_F(GlslGeneratorImplTest_Function,
+TEST_F(GlslASTPrinterTest_Function,
Emit_Attribute_EntryPoint_SharedStruct_HelperFunction) {
// struct VertexOutput {
// @builtin(position) pos : vec4<f32>;
@@ -314,7 +314,7 @@
Expr(Call("foo", Expr(0.25_f)))))},
{Stage(ast::PipelineStage::kVertex)});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
ASSERT_TRUE(gen.Generate()) << gen.Diagnostics();
EXPECT_EQ(gen.Result(), R"(struct VertexOutput {
@@ -349,7 +349,7 @@
}
#endif
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4<f32>())});
auto* ubo =
GlobalVar("ubo", ty.Of(ubo_ty), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a));
@@ -374,7 +374,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -399,7 +399,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) {
auto* s = Structure("Uniforms", utils::Vector{Member("coord", ty.vec4<f32>())});
GlobalVar("uniforms", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a));
@@ -415,7 +415,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -436,7 +436,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_RW_StorageBuffer_Read) {
auto* s = Structure("Data", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -456,7 +456,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -483,7 +483,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_RO_StorageBuffer_Read) {
auto* s = Structure("Data", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -503,7 +503,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(),
@@ -531,7 +531,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_WO_StorageBuffer_Store) {
auto* s = Structure("Data", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -549,7 +549,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -576,7 +576,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuffer_Store) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_With_StorageBuffer_Store) {
auto* s = Structure("Data", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
@@ -594,7 +594,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -621,7 +621,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* s = Structure("S", utils::Vector{Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kUniform, Binding(0_a), Group(1_a));
@@ -641,7 +641,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -666,7 +666,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", utils::Vector{Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), builtin::AddressSpace::kStorage, builtin::Access::kReadWrite,
Binding(0_a), Group(1_a));
@@ -687,7 +687,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(),
@@ -718,13 +718,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_WithNameCollision) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_WithNameCollision) {
Func("centroid", utils::Empty, ty.void_(), {},
utils::Vector{
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -740,7 +740,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_Compute) {
Func("main", utils::Empty, ty.void_(),
utils::Vector{
Return(),
@@ -750,7 +750,7 @@
WorkgroupSize(1_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -762,14 +762,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Literal) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Literal) {
Func("main", utils::Empty, ty.void_(), {},
utils::Vector{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(2_i, 4_i, 6_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -781,7 +781,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
GlobalConst("width", ty.i32(), Call<i32>(2_i));
GlobalConst("height", ty.i32(), Call<i32>(3_i));
GlobalConst("depth", ty.i32(), Call<i32>(4_i));
@@ -791,7 +791,7 @@
WorkgroupSize("width", "height", "depth"),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -803,7 +803,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function,
+TEST_F(GlslASTPrinterTest_Function,
Emit_Attribute_EntryPoint_Compute_WithWorkgroup_OverridableConst) {
Override("width", ty.i32(), Call<i32>(2_i), Id(7_u));
Override("height", ty.i32(), Call<i32>(3_i), Id(8_u));
@@ -814,7 +814,7 @@
WorkgroupSize("width", "height", "depth"),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_EQ(
gen.Diagnostics().str(),
@@ -824,13 +824,13 @@
error: override-expressions should have been removed with the SubstituteOverride transform)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Function_WithArrayParams) {
Func("my_func", utils::Vector{Param("a", ty.array<f32, 5>())}, ty.void_(),
utils::Vector{
Return(),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -842,13 +842,13 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayReturn) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Function_WithArrayReturn) {
Func("my_func", utils::Empty, ty.array<f32, 5>(),
utils::Vector{
Return(Call<array<f32, 5>>()),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -861,7 +861,7 @@
}
// https://crbug.com/tint/297
-TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
+TEST_F(GlslASTPrinterTest_Function, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
// struct Data {
// d : f32;
// };
@@ -912,7 +912,7 @@
});
}
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -949,4 +949,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_identifier_test.cc b/src/tint/lang/glsl/writer/ast_printer/identifier_test.cc
similarity index 77%
rename from src/tint/lang/glsl/ast_writer/generator_impl_identifier_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/identifier_test.cc
index a0583f3..f10aaba 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_identifier_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/identifier_test.cc
@@ -12,23 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Identifier = TestHelper;
+using GlslASTPrinterTest_Identifier = TestHelper;
-TEST_F(GlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
+TEST_F(GlslASTPrinterTest_Identifier, EmitIdentifierExpression) {
GlobalVar("foo", ty.i32(), builtin::AddressSpace::kPrivate);
auto* i = Expr("foo");
WrapInFunction(i);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, i);
@@ -37,4 +37,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_if_test.cc b/src/tint/lang/glsl/writer/ast_printer/if_test.cc
similarity index 83%
rename from src/tint/lang/glsl/ast_writer/generator_impl_if_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/if_test.cc
index 7f11935..562e344 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_if_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/if_test.cc
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_If = TestHelper;
+using GlslASTPrinterTest_If = TestHelper;
-TEST_F(GlslGeneratorImplTest_If, Emit_If) {
+TEST_F(GlslASTPrinterTest_If, Emit_If) {
GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate);
auto* cond = Expr("cond");
@@ -29,7 +29,7 @@
auto* i = If(cond, body);
WrapInFunction(i);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(i);
@@ -40,7 +40,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) {
+TEST_F(GlslASTPrinterTest_If, Emit_IfWithElseIf) {
GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate);
GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -52,7 +52,7 @@
auto* i = If(cond, body, Else(If(else_cond, else_body)));
WrapInFunction(i);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(i);
@@ -67,7 +67,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) {
+TEST_F(GlslASTPrinterTest_If, Emit_IfWithElse) {
GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate);
auto* else_body = Block(Return());
@@ -77,7 +77,7 @@
auto* i = If(cond, body, Else(else_body));
WrapInFunction(i);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(i);
@@ -90,7 +90,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) {
+TEST_F(GlslASTPrinterTest_If, Emit_IfWithMultiple) {
GlobalVar("cond", ty.bool_(), builtin::AddressSpace::kPrivate);
GlobalVar("else_cond", ty.bool_(), builtin::AddressSpace::kPrivate);
@@ -103,7 +103,7 @@
auto* i = If(cond, body, Else(If(else_cond, else_body, Else(else_body_2))));
WrapInFunction(i);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(i);
@@ -121,4 +121,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_import_test.cc b/src/tint/lang/glsl/writer/ast_printer/import_test.cc
similarity index 90%
rename from src/tint/lang/glsl/ast_writer/generator_impl_import_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/import_test.cc
index fa61807..146d67d 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_import_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/import_test.cc
@@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_Import = TestHelper;
+using GlslASTPrinterTest_Import = TestHelper;
struct GlslImportData {
const char* name;
@@ -41,14 +41,14 @@
auto* expr = Call(param.name, 1_f);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_SingleParamTest,
testing::Values(GlslImportData{"abs", "abs"},
GlslImportData{"acos", "acos"},
@@ -81,14 +81,14 @@
auto* expr = Call(param.name, Expr(1_i));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_SingleIntParamTest,
testing::Values(GlslImportData{"abs", "abs"}));
@@ -99,7 +99,7 @@
auto* expr = Call(param.name, Call<vec3<f32>>(0.1_f, 0.2_f, 0.3_f));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
@@ -109,7 +109,7 @@
std::string(param.glsl_name) +
"(vec3(0.10000000149011611938f, 0.20000000298023223877f, 0.30000001192092895508f))");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_SingleVectorParamTest,
testing::Values(GlslImportData{"abs", "abs"},
GlslImportData{"acos", "acos"},
@@ -143,14 +143,14 @@
auto* expr = Call(param.name, 1_f, 2_f);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_DualParam_ScalarTest,
testing::Values(GlslImportData{"atan2", "atan"},
GlslImportData{"distance", "distance"},
@@ -166,7 +166,7 @@
auto* expr = Call(param.name, Call<vec3<f32>>(1_f, 2_f, 3_f), Call<vec3<f32>>(4_f, 5_f, 6_f));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
@@ -174,7 +174,7 @@
EXPECT_EQ(out.str(),
std::string(param.glsl_name) + "(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f))");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_DualParam_VectorTest,
testing::Values(GlslImportData{"atan2", "atan"},
GlslImportData{"cross", "cross"},
@@ -192,14 +192,14 @@
auto* expr = Call(param.name, 1_i, 2_i);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_DualParam_Int_Test,
testing::Values(GlslImportData{"max", "max"},
GlslImportData{"min", "min"}));
@@ -211,14 +211,14 @@
auto* expr = Call(param.name, 1_f, 2_f, 3_f);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1.0f, 2.0f, 3.0f)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_TripleParam_ScalarTest,
testing::Values(GlslImportData{"mix", "mix"},
GlslImportData{"clamp", "clamp"},
@@ -232,7 +232,7 @@
Call<vec3<f32>>(7_f, 8_f, 9_f));
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
@@ -241,7 +241,7 @@
std::string(param.glsl_name) +
R"((vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f), vec3(7.0f, 8.0f, 9.0f)))");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_TripleParam_VectorTest,
testing::Values(GlslImportData{"faceForward", "faceforward"},
GlslImportData{"clamp", "clamp"},
@@ -254,24 +254,24 @@
auto* expr = Call(param.name, 1_i, 2_i, 3_i);
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(out.str(), std::string(param.glsl_name) + "(1, 2, 3)");
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Import,
GlslImportData_TripleParam_Int_Test,
testing::Values(GlslImportData{"clamp", "clamp"}));
-TEST_F(GlslGeneratorImplTest_Import, GlslImportData_Determinant) {
+TEST_F(GlslASTPrinterTest_Import, GlslImportData_Determinant) {
GlobalVar("var", ty.mat3x3<f32>(), builtin::AddressSpace::kPrivate);
auto* expr = Call("determinant", "var");
WrapInFunction(expr);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitCall(out, expr);
@@ -280,4 +280,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_loop_test.cc b/src/tint/lang/glsl/writer/ast_printer/loop_test.cc
similarity index 84%
rename from src/tint/lang/glsl/ast_writer/generator_impl_loop_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/loop_test.cc
index 73b2cad..9642a09 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_loop_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/loop_test.cc
@@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "gmock/gmock.h"
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Loop = TestHelper;
+using GlslASTPrinterTest_Loop = TestHelper;
-TEST_F(GlslGeneratorImplTest_Loop, Emit_Loop) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_Loop) {
auto* body = Block(Break());
auto* continuing = Block();
auto* l = Loop(body, continuing);
@@ -32,7 +32,7 @@
Func("F", utils::Empty, ty.void_(), utils::Vector{l},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(l);
@@ -43,7 +43,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_LoopWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(Break());
@@ -53,7 +53,7 @@
Func("F", utils::Empty, ty.void_(), utils::Vector{l},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(l);
@@ -67,7 +67,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing_BreakIf) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_LoopWithContinuing_BreakIf) {
Func("a_statement", {}, ty.void_(), {});
auto* body = Block(Break());
@@ -77,7 +77,7 @@
Func("F", utils::Empty, ty.void_(), utils::Vector{l},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(l);
@@ -92,7 +92,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_LoopNestedWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
GlobalVar("lhs", ty.f32(), builtin::AddressSpace::kPrivate);
@@ -114,7 +114,7 @@
Func("F", utils::Empty, ty.void_(), utils::Vector{outer},
utils::Vector{Stage(ast::PipelineStage::kFragment)});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(outer);
@@ -134,7 +134,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_LoopWithVarUsedInContinuing) {
// loop {
// var lhs : f32 = 2.5;
// var other : f32;
@@ -153,7 +153,7 @@
auto* outer = Loop(body, continuing);
WrapInFunction(outer);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(outer);
@@ -169,7 +169,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoop) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoop) {
// for(; ; ) {
// return;
// }
@@ -178,7 +178,7 @@
Block(Return()));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -191,7 +191,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithSimpleInit) {
// for(var i : i32; ; ) {
// return;
// }
@@ -200,7 +200,7 @@
Block(Return()));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -213,7 +213,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithMultiStmtInit) {
// let t = true;
// for(var b = t && false; ; ) {
// return;
@@ -224,7 +224,7 @@
auto* f = For(Decl(Var("b", multi_stmt)), nullptr, nullptr, Block(Return()));
WrapInFunction(t, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -242,7 +242,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithSimpleCond) {
// for(; true; ) {
// return;
// }
@@ -252,7 +252,7 @@
auto* f = For(nullptr, true, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -265,7 +265,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithMultiStmtCond) {
// let t = true;
// for(; t && false; ) {
// return;
@@ -277,7 +277,7 @@
auto* f = For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(t, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -295,7 +295,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithSimpleCont) {
// for(; ; i = i + 1i) {
// return;
// }
@@ -305,7 +305,7 @@
Block(Return()));
WrapInFunction(v, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -318,7 +318,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithMultiStmtCont) {
// let t = true;
// for(; ; i = t && false) {
// return;
@@ -331,7 +331,7 @@
Block(Return()));
WrapInFunction(t, v, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -349,7 +349,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
// for(var i : i32; true; i = ii + 1) {
// return;
// }
@@ -357,7 +357,7 @@
auto* f = For(Decl(Var("i", ty.i32())), true, Assign("i", Add("i", 1_i)), Block(Return()));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -370,7 +370,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
// let t = true;
// for(var i = t && false; t && false; i = t && false) {
// return;
@@ -385,7 +385,7 @@
Block(Return()));
WrapInFunction(t, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -413,7 +413,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_While) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_While) {
// while(true) {
// return;
// }
@@ -421,7 +421,7 @@
auto* f = While(Expr(true), Block(Return()));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -432,7 +432,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_While_WithContinue) {
// while(true) {
// continue;
// }
@@ -440,7 +440,7 @@
auto* f = While(Expr(true), Block(Continue()));
WrapInFunction(f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -451,7 +451,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
+TEST_F(GlslASTPrinterTest_Loop, Emit_WhileWithMultiStmtCond) {
// let t = true;
// while(t && false) {
// return;
@@ -464,7 +464,7 @@
auto* f = While(multi_stmt, Block(CallStmt(Call("a_statement"))));
WrapInFunction(t, f);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(f);
@@ -481,4 +481,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_member_accessor_test.cc b/src/tint/lang/glsl/writer/ast_printer/member_accessor_test.cc
similarity index 87%
rename from src/tint/lang/glsl/ast_writer/generator_impl_member_accessor_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/member_accessor_test.cc
index 84a1a97..6d794d2 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_member_accessor_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/member_accessor_test.cc
@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using ::testing::HasSubstr;
@@ -85,7 +85,7 @@
}
template <typename BASE>
-class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
+class GlslASTPrinterTest_MemberAccessorBase : public BASE {
public:
void SetupStorageBuffer(utils::VectorRef<const ast::StructMember*> members) {
ProgramBuilder& b = *this;
@@ -105,20 +105,20 @@
}
};
-using GlslGeneratorImplTest_MemberAccessor = GlslGeneratorImplTest_MemberAccessorBase<TestHelper>;
+using GlslASTPrinterTest_MemberAccessor = GlslASTPrinterTest_MemberAccessorBase<TestHelper>;
template <typename T>
-using GlslGeneratorImplTest_MemberAccessorWithParam =
- GlslGeneratorImplTest_MemberAccessorBase<TestParamHelper<T>>;
+using GlslASTPrinterTest_MemberAccessorWithParam =
+ GlslASTPrinterTest_MemberAccessorBase<TestParamHelper<T>>;
-TEST_F(GlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, EmitExpression_MemberAccessor) {
auto* s = Structure("Data", utils::Vector{Member("mem", ty.f32())});
GlobalVar("str", ty.Of(s), builtin::AddressSpace::kPrivate);
auto* expr = MemberAccessor("str", "mem");
WrapInFunction(Var("expr", ty.f32(), expr));
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -148,9 +148,9 @@
return out << c.expected;
}
-using GlslGeneratorImplTest_MemberAccessor_StorageBufferLoad =
- GlslGeneratorImplTest_MemberAccessorWithParam<TypeCase>;
-TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferLoad, Test) {
+using GlslASTPrinterTest_MemberAccessor_StorageBufferLoad =
+ GlslASTPrinterTest_MemberAccessorWithParam<TypeCase>;
+TEST_P(GlslASTPrinterTest_MemberAccessor_StorageBufferLoad, Test) {
// struct Data {
// a : i32;
// b : <type>;
@@ -169,14 +169,14 @@
Decl(Var("x", MemberAccessor("data", "b"))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(p.expected));
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_MemberAccessor,
- GlslGeneratorImplTest_MemberAccessor_StorageBufferLoad,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_MemberAccessor,
+ GlslASTPrinterTest_MemberAccessor_StorageBufferLoad,
testing::Values(TypeCase{ty_u32, "data.inner.b"},
TypeCase{ty_f32, "data.inner.b"},
TypeCase{ty_i32, "data.inner.b"},
@@ -199,9 +199,9 @@
TypeCase{ty_mat4x3<f32>, "data.inner.b"},
TypeCase{ty_mat4x4<f32>, "data.inner.b"}));
-using GlslGeneratorImplTest_MemberAccessor_StorageBufferStore =
- GlslGeneratorImplTest_MemberAccessorWithParam<TypeCase>;
-TEST_P(GlslGeneratorImplTest_MemberAccessor_StorageBufferStore, Test) {
+using GlslASTPrinterTest_MemberAccessor_StorageBufferStore =
+ GlslASTPrinterTest_MemberAccessorWithParam<TypeCase>;
+TEST_P(GlslASTPrinterTest_MemberAccessor_StorageBufferStore, Test) {
// struct Data {
// a : i32;
// b : <type>;
@@ -221,15 +221,15 @@
Assign(MemberAccessor("data", "b"), Expr("value")),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(p.expected));
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_MemberAccessor,
- GlslGeneratorImplTest_MemberAccessor_StorageBufferStore,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_MemberAccessor,
+ GlslASTPrinterTest_MemberAccessor_StorageBufferStore,
testing::Values(TypeCase{ty_u32, "data.inner.b = value"},
TypeCase{ty_f32, "data.inner.b = value"},
TypeCase{ty_i32, "data.inner.b = value"},
@@ -261,7 +261,7 @@
data.inner.b[3] = value[3u];)"},
TypeCase{ty_mat4x4<f32>, "data.inner.b = value"}));
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) {
// struct Data {
// z : f32;
// a : mat2x3<f32>;
@@ -278,7 +278,7 @@
Assign(MemberAccessor("data", "b"), Call<mat2x3<f32>>()),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -315,7 +315,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_Element) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Load_Matrix_Single_Element) {
// struct Data {
// z : f32;
// a : mat4x3<f32>;
@@ -332,7 +332,7 @@
Decl(Var("x", IndexAccessor(IndexAccessor(MemberAccessor("data", "a"), 2_i), 1_i))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -363,7 +363,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor,
+TEST_F(GlslASTPrinterTest_MemberAccessor,
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) {
// struct Data {
// a : array<i32, 5>;
@@ -380,7 +380,7 @@
Decl(Var("x", IndexAccessor(MemberAccessor("data", "a"), 2_i))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -408,7 +408,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor,
+TEST_F(GlslASTPrinterTest_MemberAccessor,
EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
// struct Data {
// a : array<i32, 5u>;
@@ -428,7 +428,7 @@
Decl(Var("x", IndexAccessor(MemberAccessor("data", "a"), Sub(Add("a", "b"), "c")))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -459,7 +459,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Store_ToArray) {
// struct Data {
// a : array<i32, 5u>;
// };
@@ -475,7 +475,7 @@
Assign(IndexAccessor(MemberAccessor("data", "a"), 2_i), 2_i),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -503,7 +503,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Load_MultiLevel) {
// struct Inner {
// a : vec3<i32>;
// b : vec3<f32>;
@@ -528,7 +528,7 @@
Decl(Var("x", MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -562,7 +562,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizzle) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Swizzle) {
// struct Inner {
// a : vec3<i32>;
// b : vec3<f32>;
@@ -589,7 +589,7 @@
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"), "xy"))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -623,7 +623,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor,
+TEST_F(GlslASTPrinterTest_MemberAccessor,
StorageBuffer_Load_MultiLevel_Swizzle_SingleLetter) { // NOLINT
// struct Inner {
// a : vec3<i32>;
@@ -651,7 +651,7 @@
MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"), "g"))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -685,7 +685,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Load_MultiLevel_Index) {
// struct Inner {
// a : vec3<i32>;
// b : vec3<f32>;
@@ -712,7 +712,7 @@
1_i))),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -746,7 +746,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Store_MultiLevel) {
// struct Inner {
// a : vec3<i32>;
// b : vec3<f32>;
@@ -772,7 +772,7 @@
Call<vec3<f32>>(1_f, 2_f, 3_f)),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -806,7 +806,7 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleLetter) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, StorageBuffer_Store_Swizzle_SingleLetter) {
// struct Inner {
// a : vec3<i32>;
// b : vec3<f32>;
@@ -833,7 +833,7 @@
Expr(1_f)),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
auto* expected =
@@ -867,27 +867,27 @@
EXPECT_EQ(gen.Result(), expected);
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, Swizzle_xyz) {
auto* var = Var("my_vec", ty.vec4<f32>(), Call<vec4<f32>>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "xyz");
WrapInFunction(var, expr);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("my_vec.xyz"));
}
-TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
+TEST_F(GlslASTPrinterTest_MemberAccessor, Swizzle_gbr) {
auto* var = Var("my_vec", ty.vec4<f32>(), Call<vec4<f32>>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "gbr");
WrapInFunction(var, expr);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("my_vec.gbr"));
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_module_constant_test.cc b/src/tint/lang/glsl/writer/ast_printer/module_constant_test.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator_impl_module_constant_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/module_constant_test.cc
index 672d359..d5b531e 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_module_constant_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/module_constant_test.cc
@@ -12,37 +12,37 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_ModuleConstant = TestHelper;
+using GlslASTPrinterTest_ModuleConstant = TestHelper;
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalLet) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalLet) {
auto* var = Let("pos", ty.array<f32, 3>(), Call<array<f32, 3>>(1_f, 2_f, 3_f));
WrapInFunction(Decl(var));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitProgramConstVariable(var);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), "const float pos[3] = float[3](1.0f, 2.0f, 3.0f);\n");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AInt) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_AInt) {
auto* var = GlobalConst("G", Expr(1_a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -54,14 +54,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_AFloat) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_AFloat) {
auto* var = GlobalConst("G", Expr(1._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -73,14 +73,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_i32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_i32) {
auto* var = GlobalConst("G", Expr(1_i));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -92,14 +92,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_u32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_u32) {
auto* var = GlobalConst("G", Expr(1_u));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -111,14 +111,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_f32) {
auto* var = GlobalConst("G", Expr(1_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -130,7 +130,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_f16) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_f16) {
Enable(builtin::Extension::kF16);
auto* var = GlobalConst("G", Expr(1_h));
@@ -139,7 +139,7 @@
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -152,14 +152,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AInt) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_vec3_AInt) {
auto* var = GlobalConst("G", Call<vec3<Infer>>(1_a, 2_a, 3_a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -171,14 +171,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_AFloat) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_vec3_AFloat) {
auto* var = GlobalConst("G", Call<vec3<Infer>>(1._a, 2._a, 3._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -190,14 +190,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_vec3_f32) {
auto* var = GlobalConst("G", Call<vec3<f32>>(1_f, 2_f, 3_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -209,7 +209,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_vec3_f16) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_vec3_f16) {
Enable(builtin::Extension::kF16);
auto* var = GlobalConst("G", Call<vec3<f16>>(1_h, 2_h, 3_h));
@@ -218,7 +218,7 @@
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -231,14 +231,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_AFloat) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_mat2x3_AFloat) {
auto* var = GlobalConst("G", Call<mat2x3<Infer>>(1._a, 2._a, 3._a, 4._a, 5._a, 6._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -250,14 +250,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_mat2x3_f32) {
auto* var = GlobalConst("G", Call<mat2x3<f32>>(1_f, 2_f, 3_f, 4_f, 5_f, 6_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -269,7 +269,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_mat2x3_f16) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_mat2x3_f16) {
Enable(builtin::Extension::kF16);
auto* var = GlobalConst("G", Call<mat2x3<f16>>(1_h, 2_h, 3_h, 4_h, 5_h, 6_h));
@@ -278,7 +278,7 @@
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -291,14 +291,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_f32) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_arr_f32) {
auto* var = GlobalConst("G", Call<array<f32, 3>>(1_f, 2_f, 3_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -310,7 +310,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_GlobalConst_arr_vec2_bool) {
+TEST_F(GlslASTPrinterTest_ModuleConstant, Emit_GlobalConst_arr_vec2_bool) {
auto* var = GlobalConst("G", Call<array<vec2<bool>, 3>>( //
Call<vec2<bool>>(true, false), //
Call<vec2<bool>>(false, true), //
@@ -320,7 +320,7 @@
Decl(Let("l", Expr(var))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -333,4 +333,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_return_test.cc b/src/tint/lang/glsl/writer/ast_printer/return_test.cc
similarity index 76%
rename from src/tint/lang/glsl/ast_writer/generator_impl_return_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/return_test.cc
index 9159b8e..82599a3 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_return_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/return_test.cc
@@ -12,33 +12,33 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Return = TestHelper;
+using GlslASTPrinterTest_Return = TestHelper;
-TEST_F(GlslGeneratorImplTest_Return, Emit_Return) {
+TEST_F(GlslASTPrinterTest_Return, Emit_Return) {
auto* r = Return();
WrapInFunction(r);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(r);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), " return;\n");
}
-TEST_F(GlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
+TEST_F(GlslASTPrinterTest_Return, Emit_ReturnWithValue) {
auto* r = Return(123_i);
Func("f", utils::Empty, ty.i32(), utils::Vector{r});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(r);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -46,4 +46,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_sanitizer_test.cc b/src/tint/lang/glsl/writer/ast_printer/sanitizer_test.cc
similarity index 94%
rename from src/tint/lang/glsl/ast_writer/generator_impl_sanitizer_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/sanitizer_test.cc
index 8e7df8c..e6aac15 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_sanitizer_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/sanitizer_test.cc
@@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::builtin::fluent_types; // NOLINT
@@ -40,7 +40,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -80,7 +80,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -124,7 +124,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -161,7 +161,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -203,7 +203,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -249,7 +249,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -294,7 +294,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -316,4 +316,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_storage_buffer_test.cc b/src/tint/lang/glsl/writer/ast_printer/storage_buffer_test.cc
similarity index 84%
rename from src/tint/lang/glsl/ast_writer/generator_impl_storage_buffer_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/storage_buffer_test.cc
index 7731577..1f0a420 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_storage_buffer_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/storage_buffer_test.cc
@@ -13,17 +13,17 @@
// limitations under the License.
#include "src/tint/lang/core/builtin/number.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
using ::testing::HasSubstr;
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_StorageBuffer = TestHelper;
+using GlslASTPrinterTest_StorageBuffer = TestHelper;
void TestAlign(ProgramBuilder* ctx) {
// struct Nephews {
@@ -42,10 +42,10 @@
ctx->Binding(0_a), ctx->Group(0_a));
}
-TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) {
+TEST_F(GlslASTPrinterTest_StorageBuffer, Align) {
TestAlign(this);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
// TODO(crbug.com/tint/1421) offsets do not currently work on GLSL ES.
// They will likely require manual padding.
@@ -68,10 +68,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_StorageBuffer, Align_Desktop) {
+TEST_F(GlslASTPrinterTest_StorageBuffer, Align_Desktop) {
TestAlign(this);
- GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
+ ASTPrinter& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 440
@@ -92,4 +92,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_switch_test.cc b/src/tint/lang/glsl/writer/ast_printer/switch_test.cc
similarity index 84%
rename from src/tint/lang/glsl/ast_writer/generator_impl_switch_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/switch_test.cc
index 14a450e..2e48773 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_switch_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/switch_test.cc
@@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Switch = TestHelper;
+using GlslASTPrinterTest_Switch = TestHelper;
-TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
+TEST_F(GlslASTPrinterTest_Switch, Emit_Switch) {
GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate);
auto* def_body = Block(create<ast::BreakStatement>());
@@ -36,7 +36,7 @@
auto* s = Switch(cond, utils::Vector{case_stmt, def});
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(s);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -51,7 +51,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch_MixedDefault) {
+TEST_F(GlslASTPrinterTest_Switch, Emit_Switch_MixedDefault) {
GlobalVar("cond", ty.i32(), builtin::AddressSpace::kPrivate);
auto* def_body = Block(create<ast::BreakStatement>());
@@ -62,7 +62,7 @@
auto* s = Switch(cond, utils::Vector{def});
WrapInFunction(s);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(s);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -76,4 +76,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/test_helper.h b/src/tint/lang/glsl/writer/ast_printer/test_helper.h
similarity index 74%
rename from src/tint/lang/glsl/ast_writer/test_helper.h
rename to src/tint/lang/glsl/writer/ast_printer/test_helper.h
index c6d5ce1..95f8a73 100644
--- a/src/tint/lang/glsl/ast_writer/test_helper.h
+++ b/src/tint/lang/glsl/writer/ast_printer/test_helper.h
@@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_GLSL_AST_WRITER_TEST_HELPER_H_
-#define SRC_TINT_LANG_GLSL_AST_WRITER_TEST_HELPER_H_
+#ifndef SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_TEST_HELPER_H_
+#define SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_TEST_HELPER_H_
#include <memory>
#include <string>
#include <utility>
#include "gtest/gtest.h"
-#include "src/tint/lang/glsl/ast_writer/generator.h"
-#include "src/tint/lang/glsl/ast_writer/generator_impl.h"
-#include "src/tint/lang/glsl/ast_writer/version.h"
+#include "src/tint/lang/glsl/writer/ast_printer/ast_printer.h"
+#include "src/tint/lang/glsl/writer/version.h"
+#include "src/tint/lang/glsl/writer/writer.h"
#include "src/tint/lang/wgsl/ast/transform/manager.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
/// Helper class for testing
template <typename BODY>
@@ -42,12 +42,12 @@
return opts;
}
- /// Builds the program and returns a GeneratorImpl from the program.
+ /// Builds the program and returns a ASTPrinter from the program.
/// @note The generator is only built once. Multiple calls to Build() will
- /// return the same GeneratorImpl without rebuilding.
+ /// return the same ASTPrinter without rebuilding.
/// @param version the GLSL version
/// @return the built generator
- GeneratorImpl& Build(Version version = Version()) {
+ ASTPrinter& Build(Version version = Version()) {
if (gen_) {
return *gen_;
}
@@ -59,19 +59,19 @@
[&] {
ASSERT_TRUE(program->IsValid()) << diag::Formatter().format(program->Diagnostics());
}();
- gen_ = std::make_unique<GeneratorImpl>(program.get(), version);
+ gen_ = std::make_unique<ASTPrinter>(program.get(), version);
return *gen_;
}
/// Builds the program, runs the program through the transform::Glsl sanitizer
- /// and returns a GeneratorImpl from the sanitized program.
+ /// and returns a ASTPrinter from the sanitized program.
/// @note The generator is only built once. Multiple calls to Build() will
- /// return the same GeneratorImpl without rebuilding.
+ /// return the same ASTPrinter without rebuilding.
/// @param version the GLSL version
/// @param options the GLSL backend options
/// @return the built generator
- GeneratorImpl& SanitizeAndBuild(Version version = Version(),
- const Options& options = DefaultOptions()) {
+ ASTPrinter& SanitizeAndBuild(Version version = Version(),
+ const Options& options = DefaultOptions()) {
if (gen_) {
return *gen_;
}
@@ -90,7 +90,7 @@
}();
*program = std::move(sanitized_result.program);
- gen_ = std::make_unique<GeneratorImpl>(program.get(), version);
+ gen_ = std::make_unique<ASTPrinter>(program.get(), version);
return *gen_;
}
@@ -98,13 +98,13 @@
std::unique_ptr<Program> program;
private:
- std::unique_ptr<GeneratorImpl> gen_;
+ std::unique_ptr<ASTPrinter> gen_;
};
using TestHelper = TestHelperBase<testing::Test>;
template <typename T>
using TestParamHelper = TestHelperBase<testing::TestWithParam<T>>;
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
-#endif // SRC_TINT_LANG_GLSL_AST_WRITER_TEST_HELPER_H_
+#endif // SRC_TINT_LANG_GLSL_WRITER_AST_PRINTER_TEST_HELPER_H_
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_type_test.cc b/src/tint/lang/glsl/writer/ast_printer/type_test.cc
similarity index 88%
rename from src/tint/lang/glsl/ast_writer/generator_impl_type_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/type_test.cc
index d19b02f..ba488ae 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_type_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/type_test.cc
@@ -18,7 +18,7 @@
#include "src/tint/lang/core/type/sampler.h"
#include "src/tint/lang/core/type/storage_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/utils/text/string_stream.h"
@@ -29,16 +29,16 @@
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_Type = TestHelper;
+using GlslASTPrinterTest_Type = TestHelper;
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Array) {
auto arr = ty.array<bool, 4>();
ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type;
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
@@ -47,11 +47,11 @@
EXPECT_EQ(out.str(), "bool ary[4]");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_ArrayOfArray) {
auto arr = ty.array(ty.array<bool, 4>(), 5_u);
ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type;
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
@@ -60,11 +60,11 @@
EXPECT_EQ(out.str(), "bool ary[5][4]");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_ArrayOfArrayOfArray) {
auto arr = ty.array(ty.array(ty.array<bool, 4>(), 5_u), 6_u);
ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type;
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
@@ -73,11 +73,11 @@
EXPECT_EQ(out.str(), "bool ary[6][5][4]");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Array_WithoutName) {
auto arr = ty.array<bool, 4>();
ast::Type ty = GlobalVar("G", arr, builtin::AddressSpace::kPrivate)->type;
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, program->TypeOf(ty), builtin::AddressSpace::kUndefined,
@@ -86,10 +86,10 @@
EXPECT_EQ(out.str(), "bool[4]");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Bool) {
auto* bool_ = create<type::Bool>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, bool_, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -97,10 +97,10 @@
EXPECT_EQ(out.str(), "bool");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_F32) {
auto* f32 = create<type::F32>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, f32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -108,12 +108,12 @@
EXPECT_EQ(out.str(), "float");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_F16) {
Enable(builtin::Extension::kF16);
auto* f16 = create<type::F16>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, f16, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -121,10 +121,10 @@
EXPECT_EQ(out.str(), "float16_t");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_I32) {
auto* i32 = create<type::I32>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, i32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -132,12 +132,12 @@
EXPECT_EQ(out.str(), "int");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Matrix_F32) {
auto* f32 = create<type::F32>();
auto* vec3 = create<type::Vector>(f32, 3u);
auto* mat2x3 = create<type::Matrix>(vec3, 2u);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -145,14 +145,14 @@
EXPECT_EQ(out.str(), "mat2x3");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Matrix_F16) {
Enable(builtin::Extension::kF16);
auto* f16 = create<type::F16>();
auto* vec3 = create<type::Vector>(f16, 3u);
auto* mat2x3 = create<type::Matrix>(vec3, 2u);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, mat2x3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -160,14 +160,14 @@
EXPECT_EQ(out.str(), "f16mat2x3");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_StructDecl) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_StructDecl) {
auto* s = Structure("S", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
});
GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::TextGenerator::TextBuffer buf;
auto* str = program->TypeOf(s)->As<type::Struct>();
@@ -181,14 +181,14 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Struct) {
auto* s = Structure("S", utils::Vector{
Member("a", ty.i32()),
Member("b", ty.f32()),
});
GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
auto* str = program->TypeOf(s)->As<type::Struct>();
utils::StringStream out;
@@ -197,14 +197,14 @@
EXPECT_EQ(out.str(), "S");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Struct_NameCollision) {
auto* s = Structure("S", utils::Vector{
Member("double", ty.i32()),
Member("float", ty.f32()),
});
GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate);
- GeneratorImpl& gen = SanitizeAndBuild();
+ ASTPrinter& gen = SanitizeAndBuild();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(R"(struct S {
@@ -214,14 +214,14 @@
)"));
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Struct_WithOffsetAttributes) {
auto* s = Structure("S", utils::Vector{
Member("a", ty.i32(), utils::Vector{MemberOffset(0_a)}),
Member("b", ty.f32(), utils::Vector{MemberOffset(8_a)}),
});
GlobalVar("g", ty.Of(s), builtin::AddressSpace::kPrivate);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::TextGenerator::TextBuffer buf;
auto* str = program->TypeOf(s)->As<type::Struct>();
@@ -235,10 +235,10 @@
)");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_U32) {
auto* u32 = create<type::U32>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, u32, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -246,11 +246,11 @@
EXPECT_EQ(out.str(), "uint");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Vector_F32) {
auto* f32 = create<type::F32>();
auto* vec3 = create<type::Vector>(f32, 3u);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -258,13 +258,13 @@
EXPECT_EQ(out.str(), "vec3");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Vector_F16) {
Enable(builtin::Extension::kF16);
auto* f16 = create<type::F16>();
auto* vec3 = create<type::Vector>(f16, 3u);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, vec3, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -272,10 +272,10 @@
EXPECT_EQ(out.str(), "f16vec3");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) {
+TEST_F(GlslASTPrinterTest_Type, EmitType_Void) {
auto* void_ = create<type::Void>();
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, void_, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -283,20 +283,20 @@
EXPECT_EQ(out.str(), "void");
}
-TEST_F(GlslGeneratorImplTest_Type, EmitSampler) {
+TEST_F(GlslASTPrinterTest_Type, EmitSampler) {
auto* sampler = create<type::Sampler>(type::SamplerKind::kSampler);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
}
-TEST_F(GlslGeneratorImplTest_Type, EmitSamplerComparison) {
+TEST_F(GlslASTPrinterTest_Type, EmitSamplerComparison) {
auto* sampler = create<type::Sampler>(type::SamplerKind::kComparisonSampler);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, sampler, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -329,14 +329,14 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(
- GlslGeneratorImplTest_Type,
+ GlslASTPrinterTest_Type,
GlslDepthTexturesTest,
testing::Values(
GlslDepthTextureData{type::TextureDimension::k2d, "sampler2DShadow tex;"},
@@ -358,7 +358,7 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("sampler2DMS tex;"));
@@ -404,12 +404,12 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(params.result));
}
-INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type,
+INSTANTIATE_TEST_SUITE_P(GlslASTPrinterTest_Type,
GlslSampledTexturesTest,
testing::Values(
GlslSampledTextureData{
@@ -503,11 +503,11 @@
"isamplerCubeArray tex;",
}));
-TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) {
+TEST_F(GlslASTPrinterTest_Type, EmitMultisampledTexture) {
auto* f32 = create<type::F32>();
auto* s = create<type::MultisampledTexture>(type::TextureDimension::k2d, f32);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitType(out, s, builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "");
@@ -541,13 +541,13 @@
Stage(ast::PipelineStage::kFragment),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(params.result));
}
INSTANTIATE_TEST_SUITE_P(
- GlslGeneratorImplTest_Type,
+ GlslASTPrinterTest_Type,
GlslStorageTexturesTest,
testing::Values(GlslStorageTextureData{type::TextureDimension::k1d,
builtin::TexelFormat::kRgba8Unorm, "image1D tex;"},
@@ -577,4 +577,4 @@
builtin::TexelFormat::kRgba32Sint, "image1D tex;"}));
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_unary_op_test.cc b/src/tint/lang/glsl/writer/ast_printer/unary_op_test.cc
similarity index 89%
rename from src/tint/lang/glsl/ast_writer/generator_impl_unary_op_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/unary_op_test.cc
index 445d98b..f4507fc 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_unary_op_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/unary_op_test.cc
@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using GlslUnaryOpTest = TestHelper;
@@ -27,7 +27,7 @@
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("expr"));
WrapInFunction(op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -40,7 +40,7 @@
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kComplement, Expr("expr"));
WrapInFunction(op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -54,7 +54,7 @@
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kIndirection, Expr("expr"));
WrapInFunction(p, op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -67,7 +67,7 @@
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, Expr("expr"));
WrapInFunction(op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -80,7 +80,7 @@
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr("expr"));
WrapInFunction(op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -92,7 +92,7 @@
auto* op = Expr(i32(std::numeric_limits<int32_t>::min()));
WrapInFunction(op);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
utils::StringStream out;
gen.EmitExpression(out, op);
@@ -101,4 +101,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_uniform_buffer_test.cc b/src/tint/lang/glsl/writer/ast_printer/uniform_buffer_test.cc
similarity index 79%
rename from src/tint/lang/glsl/ast_writer/generator_impl_uniform_buffer_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/uniform_buffer_test.cc
index 7b9271a..dd08b8c 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_uniform_buffer_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/uniform_buffer_test.cc
@@ -12,24 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
using ::testing::HasSubstr;
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_UniformBuffer = TestHelper;
+using GlslASTPrinterTest_UniformBuffer = TestHelper;
-TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) {
+TEST_F(GlslASTPrinterTest_UniformBuffer, Simple) {
auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())});
GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -45,11 +45,11 @@
)");
}
-TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) {
+TEST_F(GlslASTPrinterTest_UniformBuffer, Simple_Desktop) {
auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())});
GlobalVar("simple", ty.Of(simple), builtin::AddressSpace::kUniform, Group(0_a), Binding(0_a));
- GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
+ ASTPrinter& gen = Build(Version(Version::Standard::kDesktop, 4, 4));
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 440
@@ -66,4 +66,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_variable_decl_statement_test.cc b/src/tint/lang/glsl/writer/ast_printer/variable_decl_statement_test.cc
similarity index 75%
rename from src/tint/lang/glsl/ast_writer/generator_impl_variable_decl_statement_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/variable_decl_statement_test.cc
index ce87f7c..3245378 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_variable_decl_statement_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/variable_decl_statement_test.cc
@@ -12,57 +12,57 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "gmock/gmock.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
using ::testing::HasSubstr;
using namespace tint::builtin::fluent_types; // NOLINT
using namespace tint::number_suffixes; // NOLINT
-using GlslGeneratorImplTest_VariableDecl = TestHelper;
+using GlslASTPrinterTest_VariableDecl = TestHelper;
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement) {
auto* var = Var("a", ty.f32());
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), " float a = 0.0f;\n");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Let) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Let) {
auto* var = Let("a", ty.f32(), Call<f32>());
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), " float a = 0.0f;\n");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const) {
auto* var = Const("a", ty.f32(), Call<f32>());
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), ""); // Not a mistake - 'const' is inlined
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AInt) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_AInt) {
auto* C = Const("C", Expr(1_a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -70,7 +70,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -82,7 +82,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_AFloat) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_AFloat) {
auto* C = Const("C", Expr(1._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -90,7 +90,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -102,7 +102,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_i32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_i32) {
auto* C = Const("C", Expr(1_i));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -110,7 +110,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -122,7 +122,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_u32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_u32) {
auto* C = Const("C", Expr(1_u));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -130,7 +130,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -142,7 +142,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_f32) {
auto* C = Const("C", Expr(1_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -150,7 +150,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -162,7 +162,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_f16) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_f16) {
Enable(builtin::Extension::kF16);
auto* C = Const("C", Expr(1_h));
@@ -172,7 +172,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -185,7 +185,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_AInt) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_AInt) {
auto* C = Const("C", Call<vec3<Infer>>(1_a, 2_a, 3_a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -193,7 +193,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -205,7 +205,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_AFloat) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_AFloat) {
auto* C = Const("C", Call<vec3<Infer>>(1._a, 2._a, 3._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -213,7 +213,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -225,7 +225,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_f32) {
auto* C = Const("C", Call<vec3<f32>>(1_f, 2_f, 3_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -233,7 +233,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -245,7 +245,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_f16) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_vec3_f16) {
Enable(builtin::Extension::kF16);
auto* C = Const("C", Call<vec3<f16>>(1_h, 2_h, 3_h));
@@ -255,7 +255,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -268,7 +268,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_AFloat) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_AFloat) {
auto* C = Const("C", Call<mat2x3<Infer>>(1._a, 2._a, 3._a, 4._a, 5._a, 6._a));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -276,7 +276,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -288,7 +288,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_f32) {
auto* C = Const("C", Call<mat2x3<f32>>(1_f, 2_f, 3_f, 4_f, 5_f, 6_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -296,7 +296,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -308,7 +308,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_f16) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_mat2x3_f16) {
Enable(builtin::Extension::kF16);
auto* C = Const("C", Call<mat2x3<f16>>(1_h, 2_h, 3_h, 4_h, 5_h, 6_h));
@@ -318,7 +318,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -331,7 +331,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_f32) {
auto* C = Const("C", Call<array<f32, 3>>(1_f, 2_f, 3_f));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -339,7 +339,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -351,7 +351,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_f32_zero) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_f32_zero) {
auto* C = Const("C", Call<array<f32, 2>>());
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -359,7 +359,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -371,7 +371,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_arr_f32_zero) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_arr_f32_zero) {
auto* C = Const("C", Call<array<array<f32, 2>, 3>>());
Func("f", utils::Empty, ty.void_(),
utils::Vector{
@@ -379,7 +379,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -391,7 +391,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_struct_zero) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_struct_zero) {
Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())});
auto* C = Const("C", Call(ty.array(ty("S"), 2_i)));
Func("f", utils::Empty, ty.void_(),
@@ -400,7 +400,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -417,7 +417,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_vec2_bool) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_vec2_bool) {
auto* C = Const("C", Call<array<vec2<bool>, 3>>( //
Call<vec2<bool>>(true, false), //
Call<vec2<bool>>(false, true), //
@@ -428,7 +428,7 @@
Decl(Let("l", Expr(C))),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(#version 310 es
@@ -440,12 +440,12 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Array) {
auto* var = Var("a", ty.array<f32, 5>());
WrapInFunction(var, Expr("a"));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
@@ -453,32 +453,32 @@
HasSubstr(" float a[5] = float[5](0.0f, 0.0f, 0.0f, 0.0f, 0.0f);\n"));
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Private) {
GlobalVar("a", ty.f32(), builtin::AddressSpace::kPrivate);
WrapInFunction(Expr("a"));
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.IncrementIndent();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr(" float a = 0.0f;\n"));
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroVec_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroVec_f32) {
auto* var = Var("a", ty.vec3<f32>(), Call<vec3<f32>>());
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(vec3 a = vec3(0.0f);
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroVec_f16) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroVec_f16) {
Enable(builtin::Extension::kF16);
auto* var = Var("a", ty.vec3<f16>(), Call<vec3<f16>>());
@@ -486,20 +486,20 @@
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(), R"(f16vec3 a = f16vec3(0.0hf);
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroMat_f32) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroMat_f32) {
auto* var = Var("a", ty.mat2x3<f32>(), Call<mat2x3<f32>>());
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(),
@@ -507,7 +507,7 @@
)");
}
-TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroMat_f16) {
+TEST_F(GlslASTPrinterTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroMat_f16) {
Enable(builtin::Extension::kF16);
auto* var = Var("a", ty.mat2x3<f16>(), Call<mat2x3<f16>>());
@@ -515,7 +515,7 @@
auto* stmt = Decl(var);
WrapInFunction(stmt);
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.EmitStatement(stmt);
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_EQ(gen.Result(),
@@ -524,4 +524,4 @@
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/generator_impl_workgroup_var_test.cc b/src/tint/lang/glsl/writer/ast_printer/workgroup_var_test.cc
similarity index 82%
rename from src/tint/lang/glsl/ast_writer/generator_impl_workgroup_var_test.cc
rename to src/tint/lang/glsl/writer/ast_printer/workgroup_var_test.cc
index eb95abb..7fb1c04 100644
--- a/src/tint/lang/glsl/ast_writer/generator_impl_workgroup_var_test.cc
+++ b/src/tint/lang/glsl/writer/ast_printer/workgroup_var_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/test_helper.h"
+#include "src/tint/lang/glsl/writer/ast_printer/test_helper.h"
#include "src/tint/lang/wgsl/ast/id_attribute.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
@@ -22,12 +22,12 @@
using namespace tint::number_suffixes; // NOLINT
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
-using GlslGeneratorImplTest_WorkgroupVar = TestHelper;
+using GlslASTPrinterTest_WorkgroupVar = TestHelper;
-TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
+TEST_F(GlslASTPrinterTest_WorkgroupVar, Basic) {
GlobalVar("wg", ty.f32(), builtin::AddressSpace::kWorkgroup);
Func("main", utils::Empty, ty.void_(), utils::Vector{Assign("wg", 1.2_f)},
@@ -35,13 +35,13 @@
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("shared float wg;\n"));
}
-TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) {
+TEST_F(GlslASTPrinterTest_WorkgroupVar, Aliased) {
auto* alias = Alias("F32", ty.f32());
GlobalVar("wg", ty.Of(alias), builtin::AddressSpace::kWorkgroup);
@@ -51,11 +51,11 @@
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
});
- GeneratorImpl& gen = Build();
+ ASTPrinter& gen = Build();
gen.Generate();
EXPECT_THAT(gen.Diagnostics(), testing::IsEmpty());
EXPECT_THAT(gen.Result(), HasSubstr("shared float wg;\n"));
}
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/writer/options.cc b/src/tint/lang/glsl/writer/options.cc
new file mode 100644
index 0000000..2c96297
--- /dev/null
+++ b/src/tint/lang/glsl/writer/options.cc
@@ -0,0 +1,25 @@
+// Copyright 2023 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/tint/lang/glsl/writer/options.h"
+
+namespace tint::glsl::writer {
+
+Options::Options() = default;
+
+Options::~Options() = default;
+
+Options::Options(const Options&) = default;
+
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/ast_writer/options.h b/src/tint/lang/glsl/writer/options.h
similarity index 90%
rename from src/tint/lang/glsl/ast_writer/options.h
rename to src/tint/lang/glsl/writer/options.h
index c1de809..b5f56ea 100644
--- a/src/tint/lang/glsl/ast_writer/options.h
+++ b/src/tint/lang/glsl/writer/options.h
@@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_GLSL_AST_WRITER_OPTIONS_H_
-#define SRC_TINT_LANG_GLSL_AST_WRITER_OPTIONS_H_
+#ifndef SRC_TINT_LANG_GLSL_WRITER_OPTIONS_H_
+#define SRC_TINT_LANG_GLSL_WRITER_OPTIONS_H_
#include <string>
#include <unordered_map>
#include "src/tint/lang/core/builtin/access.h"
-#include "src/tint/lang/glsl/ast_writer/version.h"
+#include "src/tint/lang/glsl/writer/version.h"
#include "src/tint/lang/wgsl/sem/sampler_texture_pair.h"
#include "tint/external_texture_options.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
using BindingMap = std::unordered_map<sem::SamplerTexturePair, std::string>;
@@ -77,6 +77,6 @@
version);
};
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
-#endif // SRC_TINT_LANG_GLSL_AST_WRITER_OPTIONS_H_
+#endif // SRC_TINT_LANG_GLSL_WRITER_OPTIONS_H_
diff --git a/src/tint/lang/glsl/writer/result.cc b/src/tint/lang/glsl/writer/result.cc
new file mode 100644
index 0000000..d891e40
--- /dev/null
+++ b/src/tint/lang/glsl/writer/result.cc
@@ -0,0 +1,25 @@
+// Copyright 2023 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/tint/lang/glsl/writer/result.h"
+
+namespace tint::glsl::writer {
+
+Result::Result() = default;
+
+Result::~Result() = default;
+
+Result::Result(const Result&) = default;
+
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/writer/result.h b/src/tint/lang/glsl/writer/result.h
new file mode 100644
index 0000000..043f664
--- /dev/null
+++ b/src/tint/lang/glsl/writer/result.h
@@ -0,0 +1,52 @@
+// Copyright 2023 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_TINT_LANG_GLSL_WRITER_RESULT_H_
+#define SRC_TINT_LANG_GLSL_WRITER_RESULT_H_
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "src/tint/lang/wgsl/ast/pipeline_stage.h"
+
+namespace tint::glsl::writer {
+
+/// The result produced when generating GLSL.
+struct Result {
+ /// Constructor
+ Result();
+
+ /// Destructor
+ ~Result();
+
+ /// Copy constructor
+ Result(const Result&);
+
+ /// True if generation was successful.
+ bool success = false;
+
+ /// The errors generated during code generation, if any.
+ std::string error;
+
+ /// The generated GLSL.
+ std::string glsl = "";
+
+ /// The list of entry points in the generated GLSL.
+ std::vector<std::pair<std::string, ast::PipelineStage>> entry_points;
+};
+
+} // namespace tint::glsl::writer
+
+#endif // SRC_TINT_LANG_GLSL_WRITER_RESULT_H_
diff --git a/src/tint/lang/glsl/ast_writer/version.h b/src/tint/lang/glsl/writer/version.h
similarity index 87%
rename from src/tint/lang/glsl/ast_writer/version.h
rename to src/tint/lang/glsl/writer/version.h
index 01baa02..98a5f62 100644
--- a/src/tint/lang/glsl/ast_writer/version.h
+++ b/src/tint/lang/glsl/writer/version.h
@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_GLSL_AST_WRITER_VERSION_H_
-#define SRC_TINT_LANG_GLSL_AST_WRITER_VERSION_H_
+#ifndef SRC_TINT_LANG_GLSL_WRITER_VERSION_H_
+#define SRC_TINT_LANG_GLSL_WRITER_VERSION_H_
#include <cstdint>
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
/// A structure representing the version of GLSL to be generated.
struct Version {
@@ -53,6 +53,6 @@
uint32_t minor_version = 1;
};
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
-#endif // SRC_TINT_LANG_GLSL_AST_WRITER_VERSION_H_
+#endif // SRC_TINT_LANG_GLSL_WRITER_VERSION_H_
diff --git a/src/tint/lang/glsl/ast_writer/generator.cc b/src/tint/lang/glsl/writer/writer.cc
similarity index 78%
rename from src/tint/lang/glsl/ast_writer/generator.cc
rename to src/tint/lang/glsl/writer/writer.cc
index 7db15ba..634282b 100644
--- a/src/tint/lang/glsl/ast_writer/generator.cc
+++ b/src/tint/lang/glsl/writer/writer.cc
@@ -12,21 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/tint/lang/glsl/ast_writer/generator.h"
+#include "src/tint/lang/glsl/writer/writer.h"
-#include "src/tint/lang/glsl/ast_writer/generator_impl.h"
+#include <memory>
+
+#include "src/tint/lang/glsl/writer/ast_printer/ast_printer.h"
#include "src/tint/lang/wgsl/ast/transform/binding_remapper.h"
#include "src/tint/lang/wgsl/ast/transform/combine_samplers.h"
-namespace tint::writer::glsl {
-
-Options::Options() = default;
-Options::~Options() = default;
-Options::Options(const Options&) = default;
-
-Result::Result() = default;
-Result::~Result() = default;
-Result::Result(const Result&) = default;
+namespace tint::glsl::writer {
Result Generate(const Program* program, const Options& options, const std::string& entry_point) {
Result result;
@@ -44,7 +38,7 @@
}
// Generate the GLSL code.
- auto impl = std::make_unique<GeneratorImpl>(&sanitized_result.program, options.version);
+ auto impl = std::make_unique<ASTPrinter>(&sanitized_result.program, options.version);
impl->Generate();
result.success = impl->Diagnostics().empty();
result.error = impl->Diagnostics().str();
@@ -61,4 +55,4 @@
return result;
}
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer
diff --git a/src/tint/lang/glsl/writer/writer.h b/src/tint/lang/glsl/writer/writer.h
new file mode 100644
index 0000000..25851dc
--- /dev/null
+++ b/src/tint/lang/glsl/writer/writer.h
@@ -0,0 +1,41 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_TINT_LANG_GLSL_WRITER_WRITER_H_
+#define SRC_TINT_LANG_GLSL_WRITER_WRITER_H_
+
+#include <string>
+
+#include "src/tint/lang/glsl/writer/options.h"
+#include "src/tint/lang/glsl/writer/result.h"
+
+// Forward declarations
+namespace tint {
+class Program;
+} // namespace tint
+
+namespace tint::glsl::writer {
+
+/// Generate GLSL for a program, according to a set of configuration options.
+/// The result will contain the GLSL, as well as success status and diagnostic
+/// information.
+/// @param program the program to translate to GLSL
+/// @param options the configuration options to use when generating GLSL
+/// @param entry_point the entry point to generate GLSL for
+/// @returns the resulting GLSL and supplementary information
+Result Generate(const Program* program, const Options& options, const std::string& entry_point);
+
+} // namespace tint::glsl::writer
+
+#endif // SRC_TINT_LANG_GLSL_WRITER_WRITER_H_
diff --git a/src/tint/lang/glsl/ast_writer/generator_bench.cc b/src/tint/lang/glsl/writer/writer_bench.cc
similarity index 95%
rename from src/tint/lang/glsl/ast_writer/generator_bench.cc
rename to src/tint/lang/glsl/writer/writer_bench.cc
index 43345fb..270e27f 100644
--- a/src/tint/lang/glsl/ast_writer/generator_bench.cc
+++ b/src/tint/lang/glsl/writer/writer_bench.cc
@@ -18,7 +18,7 @@
#include "src/tint/lang/wgsl/ast/identifier.h"
#include "src/tint/lang/wgsl/ast/module.h"
-namespace tint::writer::glsl {
+namespace tint::glsl::writer {
namespace {
void GenerateGLSL(benchmark::State& state, std::string input_name) {
@@ -48,4 +48,4 @@
TINT_BENCHMARK_PROGRAMS(GenerateGLSL);
} // namespace
-} // namespace tint::writer::glsl
+} // namespace tint::glsl::writer