Move tint::ast::type to tint::type
Despite `tint::ast::type::Type` being in the AST namespace, these classes are clearly not AST nodes:
* They don't derive from ast::Node
* They're deduplicated by the type manager
* None of the types have an Source - they have no lexical declaration point
* The fact we have `ast::Struct` and `ast::type::Struct` clearly demonstrates what is an AST node, and what is a type.
* We have code scattered in the codebase (TypeDeterminer, writers, etc) that create new types after parsing - so clearly not part of the original syntax tree.
Types in tint are closer to being semantic info, but due to the parse-time generation of types, and tight dependency of ast::Nodes to types, I'd be reluctant to class these as semantic info. Instead, put these into a separate root level `tint::type` namespace and `src/tint` directory.
The fact that types exist in the ast::Module has already caused bugs (https://dawn-review.googlesource.com/c/tint/+/37261). This is a first step in separating out types from the ast::Module.
Bug: tint:390
Change-Id: I8349bbbd1b19597b8e6d51d5cda0890de46ecaec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38002
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 45ceb5e..18beefc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -337,50 +337,10 @@
"src/ast/switch_statement.cc",
"src/ast/switch_statement.h",
"src/ast/traits.h",
- "src/ast/type/access_control_type.cc",
- "src/ast/type/access_control_type.h",
- "src/ast/type/alias_type.cc",
- "src/ast/type/alias_type.h",
- "src/ast/type/array_type.cc",
- "src/ast/type/array_type.h",
- "src/ast/type/bool_type.cc",
- "src/ast/type/bool_type.h",
- "src/ast/type/depth_texture_type.cc",
- "src/ast/type/depth_texture_type.h",
- "src/ast/type/f32_type.cc",
- "src/ast/type/f32_type.h",
- "src/ast/type/i32_type.cc",
- "src/ast/type/i32_type.h",
- "src/ast/type/matrix_type.cc",
- "src/ast/type/matrix_type.h",
- "src/ast/type/multisampled_texture_type.cc",
- "src/ast/type/multisampled_texture_type.h",
- "src/ast/type/pointer_type.cc",
- "src/ast/type/pointer_type.h",
- "src/ast/type/sampled_texture_type.cc",
- "src/ast/type/sampled_texture_type.h",
- "src/ast/type/sampler_type.cc",
- "src/ast/type/sampler_type.h",
- "src/ast/type/storage_texture_type.cc",
- "src/ast/type/storage_texture_type.h",
- "src/ast/type/struct_type.cc",
- "src/ast/type/struct_type.h",
- "src/ast/type/texture_type.cc",
- "src/ast/type/texture_type.h",
- "src/ast/type/type.cc",
- "src/ast/type/type.h",
- "src/ast/type/u32_type.cc",
- "src/ast/type/u32_type.h",
- "src/ast/type/vector_type.cc",
- "src/ast/type/vector_type.h",
- "src/ast/type/void_type.cc",
- "src/ast/type/void_type.h",
"src/ast/type_constructor_expression.cc",
"src/ast/type_constructor_expression.h",
"src/ast/type_decoration.cc",
"src/ast/type_decoration.h",
- "src/ast/type_manager.cc",
- "src/ast/type_manager.h",
"src/ast/uint_literal.cc",
"src/ast/uint_literal.h",
"src/ast/unary_op.cc",
@@ -439,6 +399,46 @@
"src/type_determiner.h",
"src/validator/validator.cc",
"src/validator/validator.h",
+ "src/type/access_control_type.cc",
+ "src/type/access_control_type.h",
+ "src/type/alias_type.cc",
+ "src/type/alias_type.h",
+ "src/type/array_type.cc",
+ "src/type/array_type.h",
+ "src/type/bool_type.cc",
+ "src/type/bool_type.h",
+ "src/type/depth_texture_type.cc",
+ "src/type/depth_texture_type.h",
+ "src/type/f32_type.cc",
+ "src/type/f32_type.h",
+ "src/type/i32_type.cc",
+ "src/type/i32_type.h",
+ "src/type/matrix_type.cc",
+ "src/type/matrix_type.h",
+ "src/type/multisampled_texture_type.cc",
+ "src/type/multisampled_texture_type.h",
+ "src/type/pointer_type.cc",
+ "src/type/pointer_type.h",
+ "src/type/sampled_texture_type.cc",
+ "src/type/sampled_texture_type.h",
+ "src/type/sampler_type.cc",
+ "src/type/sampler_type.h",
+ "src/type/storage_texture_type.cc",
+ "src/type/storage_texture_type.h",
+ "src/type/struct_type.cc",
+ "src/type/struct_type.h",
+ "src/type/texture_type.cc",
+ "src/type/texture_type.h",
+ "src/type/type.cc",
+ "src/type/type.h",
+ "src/type/type_manager.cc",
+ "src/type/type_manager.h",
+ "src/type/u32_type.cc",
+ "src/type/u32_type.h",
+ "src/type/vector_type.cc",
+ "src/type/vector_type.h",
+ "src/type/void_type.cc",
+ "src/type/void_type.h",
"src/validator/validator_impl.cc",
"src/validator/validator_impl.h",
"src/validator/validator_test_helper.cc",
@@ -804,25 +804,7 @@
"src/ast/switch_statement_test.cc",
"src/ast/test_helper.h",
"src/ast/traits_test.cc",
- "src/ast/type/access_control_type_test.cc",
- "src/ast/type/alias_type_test.cc",
- "src/ast/type/array_type_test.cc",
- "src/ast/type/bool_type_test.cc",
- "src/ast/type/depth_texture_type_test.cc",
- "src/ast/type/f32_type_test.cc",
- "src/ast/type/i32_type_test.cc",
- "src/ast/type/matrix_type_test.cc",
- "src/ast/type/multisampled_texture_type_test.cc",
- "src/ast/type/pointer_type_test.cc",
- "src/ast/type/sampled_texture_type_test.cc",
- "src/ast/type/sampler_type_test.cc",
- "src/ast/type/storage_texture_type_test.cc",
- "src/ast/type/struct_type_test.cc",
- "src/ast/type/texture_type_test.cc",
- "src/ast/type/u32_type_test.cc",
- "src/ast/type/vector_type_test.cc",
"src/ast/type_constructor_expression_test.cc",
- "src/ast/type_manager_test.cc",
"src/ast/uint_literal_test.cc",
"src/ast/unary_op_expression_test.cc",
"src/ast/variable_decl_statement_test.cc",
@@ -844,6 +826,24 @@
"src/transform/test_helper.h",
"src/transform/vertex_pulling_test.cc",
"src/type_determiner_test.cc",
+ "src/type/access_control_type_test.cc",
+ "src/type/alias_type_test.cc",
+ "src/type/array_type_test.cc",
+ "src/type/bool_type_test.cc",
+ "src/type/depth_texture_type_test.cc",
+ "src/type/f32_type_test.cc",
+ "src/type/i32_type_test.cc",
+ "src/type/matrix_type_test.cc",
+ "src/type/multisampled_texture_type_test.cc",
+ "src/type/pointer_type_test.cc",
+ "src/type/sampled_texture_type_test.cc",
+ "src/type/sampler_type_test.cc",
+ "src/type/storage_texture_type_test.cc",
+ "src/type/struct_type_test.cc",
+ "src/type/texture_type_test.cc",
+ "src/type/type_manager_test.cc",
+ "src/type/u32_type_test.cc",
+ "src/type/vector_type_test.cc",
"src/validator/validator_control_block_test.cc",
"src/validator/validator_function_test.cc",
"src/validator/validator_test.cc",
diff --git a/fuzzers/tint_ast_clone_fuzzer.cc b/fuzzers/tint_ast_clone_fuzzer.cc
index 6ce94bc..0ccf481 100644
--- a/fuzzers/tint_ast_clone_fuzzer.cc
+++ b/fuzzers/tint_ast_clone_fuzzer.cc
@@ -67,7 +67,7 @@
for (auto* src_node : src.nodes()) {
src_nodes.emplace(src_node);
}
- std::unordered_set<tint::ast::type::Type*> src_types;
+ std::unordered_set<tint::type::Type*> src_types;
for (auto& src_type : src.types()) {
src_types.emplace(src_type.second.get());
}
diff --git a/include/tint/tint.h b/include/tint/tint.h
index e9e7c9d..19c69d1 100644
--- a/include/tint/tint.h
+++ b/include/tint/tint.h
@@ -19,7 +19,6 @@
// headers will need to be moved to include/tint/.
#include "src/ast/pipeline_stage.h"
-#include "src/ast/type_manager.h"
#include "src/demangler.h"
#include "src/diagnostic/printer.h"
#include "src/inspector/inspector.h"
@@ -30,6 +29,7 @@
#include "src/transform/first_index_offset.h"
#include "src/transform/manager.h"
#include "src/transform/vertex_pulling.h"
+#include "src/type/type_manager.h"
#include "src/type_determiner.h"
#include "src/validator/validator.h"
#include "src/writer/writer.h"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c655d71..b7c4fa5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,16 +56,16 @@
ast/bitcast_expression.h
ast/block_statement.cc
ast/block_statement.h
- ast/bool_literal.h
ast/bool_literal.cc
+ ast/bool_literal.h
ast/break_statement.cc
ast/break_statement.h
ast/builder.cc
ast/builder.h
- ast/builtin.cc
- ast/builtin.h
ast/builtin_decoration.cc
ast/builtin_decoration.h
+ ast/builtin.cc
+ ast/builtin.h
ast/call_expression.cc
ast/call_expression.h
ast/call_statement.cc
@@ -106,8 +106,8 @@
ast/int_literal.h
ast/intrinsic.cc
ast/intrinsic.h
- ast/literal.h
ast/literal.cc
+ ast/literal.h
ast/location_decoration.cc
ast/location_decoration.h
ast/loop_statement.cc
@@ -151,50 +151,10 @@
ast/switch_statement.cc
ast/switch_statement.h
ast/traits.h
- ast/type_constructor_expression.h
ast/type_constructor_expression.cc
+ ast/type_constructor_expression.h
ast/type_decoration.cc
ast/type_decoration.h
- ast/type/access_control_type.cc
- ast/type/access_control_type.h
- ast/type/alias_type.cc
- ast/type/alias_type.h
- ast/type/array_type.cc
- ast/type/array_type.h
- ast/type/bool_type.cc
- ast/type/bool_type.h
- ast/type/depth_texture_type.cc
- ast/type/depth_texture_type.h
- ast/type/f32_type.cc
- ast/type/f32_type.h
- ast/type/i32_type.cc
- ast/type/i32_type.h
- ast/type/matrix_type.cc
- ast/type/matrix_type.h
- ast/type/multisampled_texture_type.cc
- ast/type/multisampled_texture_type.h
- ast/type/pointer_type.cc
- ast/type/pointer_type.h
- ast/type/sampled_texture_type.cc
- ast/type/sampled_texture_type.h
- ast/type/sampler_type.cc
- ast/type/sampler_type.h
- ast/type/storage_texture_type.cc
- ast/type/storage_texture_type.h
- ast/type/struct_type.cc
- ast/type/struct_type.h
- ast/type/texture_type.cc
- ast/type/texture_type.h
- ast/type/type.cc
- ast/type/type.h
- ast/type/u32_type.cc
- ast/type/u32_type.h
- ast/type/vector_type.cc
- ast/type/vector_type.h
- ast/type/void_type.cc
- ast/type/void_type.h
- ast/type_manager.cc
- ast/type_manager.h
ast/uint_literal.cc
ast/uint_literal.h
ast/unary_op.cc
@@ -251,6 +211,46 @@
transform/vertex_pulling.h
type_determiner.cc
type_determiner.h
+ type/access_control_type.cc
+ type/access_control_type.h
+ type/alias_type.cc
+ type/alias_type.h
+ type/array_type.cc
+ type/array_type.h
+ type/bool_type.cc
+ type/bool_type.h
+ type/depth_texture_type.cc
+ type/depth_texture_type.h
+ type/f32_type.cc
+ type/f32_type.h
+ type/i32_type.cc
+ type/i32_type.h
+ type/matrix_type.cc
+ type/matrix_type.h
+ type/multisampled_texture_type.cc
+ type/multisampled_texture_type.h
+ type/pointer_type.cc
+ type/pointer_type.h
+ type/sampled_texture_type.cc
+ type/sampled_texture_type.h
+ type/sampler_type.cc
+ type/sampler_type.h
+ type/storage_texture_type.cc
+ type/storage_texture_type.h
+ type/struct_type.cc
+ type/struct_type.h
+ type/texture_type.cc
+ type/texture_type.h
+ type/type.cc
+ type/type.h
+ type/type_manager.cc
+ type/type_manager.h
+ type/u32_type.cc
+ type/u32_type.h
+ type/vector_type.cc
+ type/vector_type.h
+ type/void_type.cc
+ type/void_type.h
validator/validator.cc
validator/validator.h
validator/validator_impl.cc
@@ -391,6 +391,7 @@
ast/access_decoration_test.cc
ast/array_accessor_expression_test.cc
ast/assignment_statement_test.cc
+ ast/binary_expression_test.cc
ast/binding_decoration_test.cc
ast/bitcast_expression_test.cc
ast/block_statement_test.cc
@@ -403,8 +404,8 @@
ast/clone_context_test.cc
ast/constant_id_decoration_test.cc
ast/continue_statement_test.cc
- ast/discard_statement_test.cc
ast/decoration_test.cc
+ ast/discard_statement_test.cc
ast/else_statement_test.cc
ast/expression_test.cc
ast/fallthrough_statement_test.cc
@@ -413,53 +414,34 @@
ast/group_decoration_test.cc
ast/identifier_expression_test.cc
ast/if_statement_test.cc
+ ast/int_literal_test.cc
ast/intrinsic_texture_helper_test.cc
ast/intrinsic_texture_helper_test.h
- ast/int_literal_test.cc
ast/location_decoration_test.cc
ast/loop_statement_test.cc
ast/member_accessor_expression_test.cc
- ast/module_test.cc
ast/module_clone_test.cc
+ ast/module_test.cc
ast/null_literal_test.cc
- ast/binary_expression_test.cc
ast/return_statement_test.cc
ast/scalar_constructor_expression_test.cc
ast/sint_literal_test.cc
ast/stage_decoration_test.cc
ast/stride_decoration_test.cc
- ast/struct_member_test.cc
ast/struct_member_offset_decoration_test.cc
+ ast/struct_member_test.cc
ast/struct_test.cc
ast/switch_statement_test.cc
ast/test_helper.h
- ast/type/access_control_type_test.cc
- ast/type/alias_type_test.cc
- ast/type/array_type_test.cc
- ast/type/bool_type_test.cc
- ast/type/depth_texture_type_test.cc
- ast/type/f32_type_test.cc
- ast/type/i32_type_test.cc
- ast/type/matrix_type_test.cc
- ast/type/multisampled_texture_type_test.cc
- ast/type/pointer_type_test.cc
- ast/type/sampled_texture_type_test.cc
- ast/type/sampler_type_test.cc
- ast/type/storage_texture_type_test.cc
- ast/type/struct_type_test.cc
- ast/type/texture_type_test.cc
- ast/type/u32_type_test.cc
- ast/type/vector_type_test.cc
ast/traits_test.cc
ast/type_constructor_expression_test.cc
- ast/type_manager_test.cc
ast/uint_literal_test.cc
ast/unary_op_expression_test.cc
ast/variable_decl_statement_test.cc
ast/variable_test.cc
ast/workgroup_decoration_test.cc
- castable_test.cc
block_allocator_test.cc
+ castable_test.cc
demangler_test.cc
diagnostic/formatter_test.cc
diagnostic/printer_test.cc
@@ -469,6 +451,24 @@
symbol_table_test.cc
symbol_test.cc
type_determiner_test.cc
+ type/access_control_type_test.cc
+ type/alias_type_test.cc
+ type/array_type_test.cc
+ type/bool_type_test.cc
+ type/depth_texture_type_test.cc
+ type/f32_type_test.cc
+ type/i32_type_test.cc
+ type/matrix_type_test.cc
+ type/multisampled_texture_type_test.cc
+ type/pointer_type_test.cc
+ type/sampled_texture_type_test.cc
+ type/sampler_type_test.cc
+ type/storage_texture_type_test.cc
+ type/struct_type_test.cc
+ type/texture_type_test.cc
+ type/type_manager_test.cc
+ type/u32_type_test.cc
+ type/vector_type_test.cc
validator/validator_control_block_test.cc
validator/validator_function_test.cc
validator/validator_test.cc
diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h
index ccee67e..d1376f2 100644
--- a/src/ast/bitcast_expression.h
+++ b/src/ast/bitcast_expression.h
@@ -20,7 +20,7 @@
#include "src/ast/expression.h"
#include "src/ast/literal.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc
index dcbd774..186e4b7 100644
--- a/src/ast/bitcast_expression_test.cc
+++ b/src/ast/bitcast_expression_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc
index 97a9d5d..e07e66e 100644
--- a/src/ast/bool_literal_test.cc
+++ b/src/ast/bool_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/builder.h b/src/ast/builder.h
index 1ebe604..35a49e1 100644
--- a/src/ast/builder.h
+++ b/src/ast/builder.h
@@ -33,20 +33,20 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc
index ce858df..ae60ba1 100644
--- a/src/ast/case_statement_test.cc
+++ b/src/ast/case_statement_test.cc
@@ -18,9 +18,9 @@
#include "src/ast/if_statement.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc
index 0d3403d..0855fec 100644
--- a/src/ast/else_statement_test.cc
+++ b/src/ast/else_statement_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/if_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/expression.h b/src/ast/expression.h
index 12e038c..853a57c 100644
--- a/src/ast/expression.h
+++ b/src/ast/expression.h
@@ -20,7 +20,7 @@
#include <vector>
#include "src/ast/node.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc
index b48409d..c6887e3 100644
--- a/src/ast/expression_test.cc
+++ b/src/ast/expression_test.cc
@@ -15,8 +15,8 @@
#include "src/ast/expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc
index 1cd4cfe..41be541 100644
--- a/src/ast/float_literal_test.cc
+++ b/src/ast/float_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/function.cc b/src/ast/function.cc
index 822d8cb..47863ca 100644
--- a/src/ast/function.cc
+++ b/src/ast/function.cc
@@ -19,11 +19,11 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
#include "src/ast/stage_decoration.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/texture_type.h"
#include "src/ast/variable.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/texture_type.h"
TINT_INSTANTIATE_CLASS_ID(tint::ast::Function);
diff --git a/src/ast/function.h b/src/ast/function.h
index 19fb034..248dd55 100644
--- a/src/ast/function.h
+++ b/src/ast/function.h
@@ -32,10 +32,10 @@
#include "src/ast/node.h"
#include "src/ast/pipeline_stage.h"
#include "src/ast/statement.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/type.h"
#include "src/ast/variable.h"
#include "src/symbol.h"
+#include "src/type/sampler_type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc
index dfeb534..e207f83 100644
--- a/src/ast/int_literal_test.cc
+++ b/src/ast/int_literal_test.cc
@@ -19,9 +19,9 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/intrinsic_texture_helper_test.cc b/src/ast/intrinsic_texture_helper_test.cc
index 256de22..b1a16c3 100644
--- a/src/ast/intrinsic_texture_helper_test.cc
+++ b/src/ast/intrinsic_texture_helper_test.cc
@@ -15,12 +15,12 @@
#include "src/ast/intrinsic_texture_helper_test.h"
#include "src/ast/builder.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/access_control_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
namespace tint {
namespace ast {
@@ -135,7 +135,7 @@
return out;
}
-ast::type::Type* TextureOverloadCase::resultVectorComponentType(
+type::Type* TextureOverloadCase::resultVectorComponentType(
ast::Builder* b) const {
switch (texture_data_type) {
case ast::intrinsic::test::TextureDataType::kF32:
@@ -162,26 +162,26 @@
case ast::intrinsic::test::TextureKind::kRegular:
return b->Var(
"texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::SampledTexture>(texture_dimension, datatype),
- nullptr, decos);
+ b->create<type::SampledTexture>(texture_dimension, datatype), nullptr,
+ decos);
case ast::intrinsic::test::TextureKind::kDepth:
return b->Var("texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::DepthTexture>(texture_dimension),
- nullptr, decos);
+ b->create<type::DepthTexture>(texture_dimension), nullptr,
+ decos);
case ast::intrinsic::test::TextureKind::kMultisampled:
- return b->Var("texture", ast::StorageClass::kUniformConstant,
- b->create<ast::type::MultisampledTexture>(texture_dimension,
- datatype),
- nullptr, decos);
+ return b->Var(
+ "texture", ast::StorageClass::kUniformConstant,
+ b->create<type::MultisampledTexture>(texture_dimension, datatype),
+ nullptr, decos);
case ast::intrinsic::test::TextureKind::kStorage: {
auto* st =
- b->create<ast::type::StorageTexture>(texture_dimension, image_format);
+ b->create<type::StorageTexture>(texture_dimension, image_format);
st->set_type(datatype);
- auto* ac = b->create<ast::type::AccessControl>(access_control, st);
+ auto* ac = b->create<type::AccessControl>(access_control, st);
return b->Var("texture", ast::StorageClass::kUniformConstant, ac, nullptr,
decos);
}
@@ -198,7 +198,7 @@
b->create<ast::BindingDecoration>(1),
};
return b->Var("sampler", ast::StorageClass::kUniformConstant,
- b->create<ast::type::Sampler>(sampler_kind), nullptr, decos);
+ b->create<type::Sampler>(sampler_kind), nullptr, decos);
}
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
@@ -437,7 +437,7 @@
ValidTextureOverload::kDimensionsStorageRO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
@@ -448,7 +448,7 @@
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
"i32",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -459,7 +459,7 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
@@ -470,7 +470,7 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -481,7 +481,7 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
@@ -491,7 +491,7 @@
ValidTextureOverload::kDimensionsStorageWO1d,
"textureDimensions(t : texture_storage_1d<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureDimensions",
@@ -502,7 +502,7 @@
"textureDimensions(t : texture_storage_1d_array<rgba32float>) -> "
"i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -513,7 +513,7 @@
"textureDimensions(t : texture_storage_2d<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureDimensions",
@@ -524,7 +524,7 @@
"textureDimensions(t : texture_storage_2d_array<rgba32float>) -> "
"vec2<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureDimensions",
@@ -535,7 +535,7 @@
"textureDimensions(t : texture_storage_3d<rgba32float>) -> "
"vec3<i32>",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureDimensions",
@@ -605,7 +605,7 @@
ValidTextureOverload::kNumLayersStorageWO1dArray,
"textureNumLayers(t : texture_storage_1d_array<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureNumLayers",
@@ -615,7 +615,7 @@
ValidTextureOverload::kNumLayersStorageWO2dArray,
"textureNumLayers(t : texture_storage_2d_array<rgba32float>) -> i32",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureNumLayers",
@@ -2240,7 +2240,7 @@
"textureLoad(t : texture_storage_1d<rgba32float>,\n"
" coords : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureLoad",
@@ -2256,7 +2256,7 @@
" coords : i32,\n"
" array_index : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureLoad",
@@ -2271,7 +2271,7 @@
"textureLoad(t : texture_storage_2d<rgba8unorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Unorm,
+ type::ImageFormat::kRgba8Unorm,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2285,7 +2285,7 @@
"textureLoad(t : texture_storage_2d<rgba8snorm>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Snorm,
+ type::ImageFormat::kRgba8Snorm,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2299,7 +2299,7 @@
"textureLoad(t : texture_storage_2d<rgba8uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Uint,
+ type::ImageFormat::kRgba8Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2313,7 +2313,7 @@
"textureLoad(t : texture_storage_2d<rgba8sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba8Sint,
+ type::ImageFormat::kRgba8Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2327,7 +2327,7 @@
"textureLoad(t : texture_storage_2d<rgba16uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Uint,
+ type::ImageFormat::kRgba16Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2341,7 +2341,7 @@
"textureLoad(t : texture_storage_2d<rgba16sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Sint,
+ type::ImageFormat::kRgba16Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2355,7 +2355,7 @@
"textureLoad(t : texture_storage_2d<rgba16float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba16Float,
+ type::ImageFormat::kRgba16Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2369,7 +2369,7 @@
"textureLoad(t : texture_storage_2d<r32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Uint,
+ type::ImageFormat::kR32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2383,7 +2383,7 @@
"textureLoad(t : texture_storage_2d<r32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Sint,
+ type::ImageFormat::kR32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2397,7 +2397,7 @@
"textureLoad(t : texture_storage_2d<r32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kR32Float,
+ type::ImageFormat::kR32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2411,7 +2411,7 @@
"textureLoad(t : texture_storage_2d<rg32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Uint,
+ type::ImageFormat::kRg32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2425,7 +2425,7 @@
"textureLoad(t : texture_storage_2d<rg32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Sint,
+ type::ImageFormat::kRg32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2439,7 +2439,7 @@
"textureLoad(t : texture_storage_2d<rg32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRg32Float,
+ type::ImageFormat::kRg32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2453,7 +2453,7 @@
"textureLoad(t : texture_storage_2d<rgba32uint>,\n"
" coords : vec2<i32>) -> vec4<u32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Uint,
+ type::ImageFormat::kRgba32Uint,
type::TextureDimension::k2d,
TextureDataType::kU32,
"textureLoad",
@@ -2467,7 +2467,7 @@
"textureLoad(t : texture_storage_2d<rgba32sint>,\n"
" coords : vec2<i32>) -> vec4<i32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Sint,
+ type::ImageFormat::kRgba32Sint,
type::TextureDimension::k2d,
TextureDataType::kI32,
"textureLoad",
@@ -2481,7 +2481,7 @@
"textureLoad(t : texture_storage_2d<rgba32float>,\n"
" coords : vec2<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureLoad",
@@ -2497,7 +2497,7 @@
" coords : vec2<i32>,\n"
" array_index : i32) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureLoad",
@@ -2512,7 +2512,7 @@
"textureLoad(t : texture_storage_3d<rgba32float>,\n"
" coords : vec3<i32>) -> vec4<f32>",
ast::AccessControl::kReadOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureLoad",
@@ -2527,7 +2527,7 @@
" coords : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1d,
TextureDataType::kF32,
"textureStore",
@@ -2544,7 +2544,7 @@
" array_index : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k1dArray,
TextureDataType::kF32,
"textureStore",
@@ -2561,7 +2561,7 @@
" coords : vec2<i32>,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2d,
TextureDataType::kF32,
"textureStore",
@@ -2578,7 +2578,7 @@
" array_index : i32,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k2dArray,
TextureDataType::kF32,
"textureStore",
@@ -2595,7 +2595,7 @@
" coords : vec3<i32>,\n"
" value : vec4<T>) -> void",
ast::AccessControl::kWriteOnly,
- ast::type::ImageFormat::kRgba32Float,
+ type::ImageFormat::kRgba32Float,
type::TextureDimension::k3d,
TextureDataType::kF32,
"textureStore",
diff --git a/src/ast/intrinsic_texture_helper_test.h b/src/ast/intrinsic_texture_helper_test.h
index bd67b9f..f8a4b53 100644
--- a/src/ast/intrinsic_texture_helper_test.h
+++ b/src/ast/intrinsic_texture_helper_test.h
@@ -20,9 +20,9 @@
#include "src/ast/access_control.h"
#include "src/ast/builder.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
namespace ast {
@@ -240,7 +240,7 @@
/// @param builder the AST builder used for the test
/// @returns the vector component type of the texture function return value
- ast::type::Type* resultVectorComponentType(ast::Builder* builder) const;
+ type::Type* resultVectorComponentType(ast::Builder* builder) const;
/// @param builder the AST builder used for the test
/// @returns a Variable holding the test texture
ast::Variable* buildTextureVariable(ast::Builder* builder) const;
diff --git a/src/ast/literal.h b/src/ast/literal.h
index f5127ef..2b08eea 100644
--- a/src/ast/literal.h
+++ b/src/ast/literal.h
@@ -18,7 +18,7 @@
#include <string>
#include "src/ast/node.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/module.cc b/src/ast/module.cc
index ac337d0..3561263 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -17,7 +17,7 @@
#include <sstream>
#include "src/ast/clone_context.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/module.h b/src/ast/module.h
index 63fd9c7..76ed92e 100644
--- a/src/ast/module.h
+++ b/src/ast/module.h
@@ -25,11 +25,11 @@
#include "src/ast/function.h"
#include "src/ast/traits.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type_manager.h"
#include "src/ast/variable.h"
#include "src/block_allocator.h"
#include "src/symbol_table.h"
+#include "src/type/alias_type.h"
+#include "src/type/type_manager.h"
namespace tint {
namespace ast {
@@ -181,7 +181,7 @@
std::vector<type::Type*> constructed_types_;
FunctionList functions_;
BlockAllocator<Node> ast_nodes_;
- TypeManager type_mgr_;
+ type::Manager type_mgr_;
};
} // namespace ast
diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc
index 1c7fd7b..e5007b0 100644
--- a/src/ast/module_clone_test.cc
+++ b/src/ast/module_clone_test.cc
@@ -126,7 +126,7 @@
for (auto* src_node : src.nodes()) {
src_nodes.emplace(src_node);
}
- std::unordered_set<ast::type::Type*> src_types;
+ std::unordered_set<type::Type*> src_types;
for (auto& src_type : src.types()) {
src_types.emplace(src_type.second.get());
}
diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc
index d195f32..605bdb8 100644
--- a/src/ast/module_test.cc
+++ b/src/ast/module_test.cc
@@ -20,10 +20,10 @@
#include "gmock/gmock.h"
#include "src/ast/function.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/ast/variable.h"
+#include "src/type/alias_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/node.h b/src/ast/node.h
index b3d5cde..87e2ee9 100644
--- a/src/ast/node.h
+++ b/src/ast/node.h
@@ -23,15 +23,14 @@
#include "src/source.h"
namespace tint {
+namespace type {
+class Type;
+}
namespace ast {
class Module;
class CloneContext;
-namespace type {
-class Type;
-}
-
/// AST base class node
class Node : public Castable<Node> {
public:
diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc
index 025e02c..93b6d44 100644
--- a/src/ast/null_literal_test.cc
+++ b/src/ast/null_literal_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc
index 25fdbd2..563a086 100644
--- a/src/ast/scalar_constructor_expression_test.cc
+++ b/src/ast/scalar_constructor_expression_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/bool_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc
index e4a32d2..3cdb7bb 100644
--- a/src/ast/sint_literal_test.cc
+++ b/src/ast/sint_literal_test.cc
@@ -18,9 +18,9 @@
#include "src/ast/float_literal.h"
#include "src/ast/null_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h
index 52204f8..9f06562 100644
--- a/src/ast/struct_member.h
+++ b/src/ast/struct_member.h
@@ -22,8 +22,8 @@
#include "src/ast/node.h"
#include "src/ast/struct_member_decoration.h"
-#include "src/ast/type/type.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc
index df6758a..2591a64 100644
--- a/src/ast/struct_member_test.cc
+++ b/src/ast/struct_member_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc
index a0af738..a34a2a6 100644
--- a/src/ast/struct_test.cc
+++ b/src/ast/struct_test.cc
@@ -21,7 +21,7 @@
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc
index 1753658..5f05e6a 100644
--- a/src/ast/switch_statement_test.cc
+++ b/src/ast/switch_statement_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc
deleted file mode 100644
index ca5be28..0000000
--- a/src/ast/type/struct_type_test.cc
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright 2020 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/ast/type/struct_type.h"
-
-#include <utility>
-
-#include "src/ast/stride_decoration.h"
-#include "src/ast/struct_member.h"
-#include "src/ast/struct_member_decoration.h"
-#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-
-namespace tint {
-namespace ast {
-namespace type {
-namespace {
-
-using StructTest = TestHelper;
-
-TEST_F(StructTest, Creation) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* ptr = impl;
- auto* s = ty.struct_("S", impl);
- EXPECT_EQ(s->impl(), ptr);
-}
-
-TEST_F(StructTest, Is) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* s = ty.struct_("S", impl);
- type::Type* ty = s;
- EXPECT_FALSE(ty->Is<AccessControl>());
- EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
- EXPECT_FALSE(ty->Is<Bool>());
- EXPECT_FALSE(ty->Is<F32>());
- EXPECT_FALSE(ty->Is<I32>());
- EXPECT_FALSE(ty->Is<Matrix>());
- EXPECT_FALSE(ty->Is<Pointer>());
- EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_TRUE(ty->Is<Struct>());
- EXPECT_FALSE(ty->Is<Texture>());
- EXPECT_FALSE(ty->Is<U32>());
- EXPECT_FALSE(ty->Is<Vector>());
-}
-
-TEST_F(StructTest, TypeName) {
- auto* impl = create<ast::Struct>(StructMemberList{}, StructDecorationList{});
- auto* s = ty.struct_("my_struct", impl);
- EXPECT_EQ(s->type_name(), "__struct_tint_symbol_1");
-}
-
-TEST_F(StructTest, MinBufferBindingSize) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeArray) {
- Array arr(ty.u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
-
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", &arr, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(32u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(24u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
- Array arr(ty.u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
-
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(12u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec2) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec3) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, MinBufferBindingSizeVec4) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignment) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentArray) {
- Array arr(ty.u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", &arr, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentRuntimeArray) {
- Array arr(ty.u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)}),
- Member("bar", ty.u32, {MemberOffset(8)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec2) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(8u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec3) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-TEST_F(StructTest, BaseAlignmentVec4) {
- auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
- StructDecorationList{});
- auto* s_ty = ty.struct_("s_ty", str);
-
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
- EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
-}
-
-} // namespace
-} // namespace type
-} // namespace ast
-} // namespace tint
diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h
index 66f45b1..1fdbeec 100644
--- a/src/ast/type_constructor_expression.h
+++ b/src/ast/type_constructor_expression.h
@@ -19,7 +19,7 @@
#include <utility>
#include "src/ast/constructor_expression.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc
index 9b51d8e..b7bbfb0 100644
--- a/src/ast/type_constructor_expression_test.cc
+++ b/src/ast/type_constructor_expression_test.cc
@@ -20,8 +20,8 @@
#include "src/ast/constructor_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc
index 1197ba7..db3e1bb 100644
--- a/src/ast/uint_literal_test.cc
+++ b/src/ast/uint_literal_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/null_literal.h"
#include "src/ast/sint_literal.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable.h b/src/ast/variable.h
index 88257b2..e721ad0 100644
--- a/src/ast/variable.h
+++ b/src/ast/variable.h
@@ -23,9 +23,9 @@
#include "src/ast/expression.h"
#include "src/ast/node.h"
#include "src/ast/storage_class.h"
-#include "src/ast/type/type.h"
#include "src/ast/variable_decoration.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc
index a432804..60b878b 100644
--- a/src/ast/variable_decl_statement_test.cc
+++ b/src/ast/variable_decl_statement_test.cc
@@ -15,8 +15,8 @@
#include "src/ast/variable_decl_statement.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace ast {
diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc
index 7f19618..331d17f 100644
--- a/src/ast/variable_test.cc
+++ b/src/ast/variable_test.cc
@@ -17,8 +17,8 @@
#include "src/ast/constant_id_decoration.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/test_helper.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace ast {
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index f23e954..91d6cd1 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -25,20 +25,20 @@
#include "src/ast/null_literal.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace inspector {
@@ -183,12 +183,12 @@
ast::Variable* var = nullptr;
ast::Function::BindingInfo binding_info;
std::tie(var, binding_info) = ruv;
- if (!var->type()->Is<ast::type::AccessControl>()) {
+ if (!var->type()->Is<type::AccessControl>()) {
continue;
}
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
- auto* str = unwrapped_type->As<ast::type::Struct>();
+ auto* str = unwrapped_type->As<type::Struct>();
if (str == nullptr) {
continue;
}
@@ -199,8 +199,8 @@
entry.bind_group = binding_info.group->value();
entry.binding = binding_info.binding->value();
- entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
- ast::type::MemoryLayout::kUniformBuffer);
+ entry.min_buffer_binding_size =
+ var->type()->MinBufferBindingSize(type::MemoryLayout::kUniformBuffer);
result.push_back(entry);
}
@@ -307,7 +307,7 @@
ast::Function::BindingInfo binding_info;
std::tie(var, binding_info) = rsv;
- auto* ac_type = var->type()->As<ast::type::AccessControl>();
+ auto* ac_type = var->type()->As<type::AccessControl>();
if (ac_type == nullptr) {
continue;
}
@@ -316,14 +316,14 @@
continue;
}
- if (!var->type()->UnwrapIfNeeded()->Is<ast::type::Struct>()) {
+ if (!var->type()->UnwrapIfNeeded()->Is<type::Struct>()) {
continue;
}
entry.bind_group = binding_info.group->value();
entry.binding = binding_info.binding->value();
- entry.min_buffer_binding_size = var->type()->MinBufferBindingSize(
- ast::type::MemoryLayout::kStorageBuffer);
+ entry.min_buffer_binding_size =
+ var->type()->MinBufferBindingSize(type::MemoryLayout::kStorageBuffer);
result.push_back(entry);
}
@@ -352,28 +352,27 @@
entry.bind_group = binding_info.group->value();
entry.binding = binding_info.binding->value();
- auto* texture_type =
- var->type()->UnwrapIfNeeded()->As<ast::type::Texture>();
+ auto* texture_type = var->type()->UnwrapIfNeeded()->As<type::Texture>();
switch (texture_type->dim()) {
- case ast::type::TextureDimension::k1d:
+ case type::TextureDimension::k1d:
entry.dim = ResourceBinding::TextureDimension::k1d;
break;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
entry.dim = ResourceBinding::TextureDimension::k1dArray;
break;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
entry.dim = ResourceBinding::TextureDimension::k2d;
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
entry.dim = ResourceBinding::TextureDimension::k2dArray;
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
entry.dim = ResourceBinding::TextureDimension::k3d;
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
entry.dim = ResourceBinding::TextureDimension::kCube;
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
entry.dim = ResourceBinding::TextureDimension::kCubeArray;
break;
default:
@@ -381,30 +380,29 @@
break;
}
- ast::type::Type* base_type = nullptr;
+ type::Type* base_type = nullptr;
if (multisampled_only) {
- base_type = texture_type->As<ast::type::MultisampledTexture>()
+ base_type = texture_type->As<type::MultisampledTexture>()
->type()
->UnwrapIfNeeded();
} else {
- base_type = texture_type->As<ast::type::SampledTexture>()
- ->type()
- ->UnwrapIfNeeded();
+ base_type =
+ texture_type->As<type::SampledTexture>()->type()->UnwrapIfNeeded();
}
- if (auto* at = base_type->As<ast::type::Array>()) {
+ if (auto* at = base_type->As<type::Array>()) {
base_type = at->type();
- } else if (auto* mt = base_type->As<ast::type::Matrix>()) {
+ } else if (auto* mt = base_type->As<type::Matrix>()) {
base_type = mt->type();
- } else if (auto* vt = base_type->As<ast::type::Vector>()) {
+ } else if (auto* vt = base_type->As<type::Vector>()) {
base_type = vt->type();
}
- if (base_type->Is<ast::type::F32>()) {
+ if (base_type->Is<type::F32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kFloat;
- } else if (base_type->Is<ast::type::U32>()) {
+ } else if (base_type->Is<type::U32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kUInt;
- } else if (base_type->Is<ast::type::I32>()) {
+ } else if (base_type->Is<type::I32>()) {
entry.sampled_kind = ResourceBinding::SampledKind::kSInt;
} else {
entry.sampled_kind = ResourceBinding::SampledKind::kUnknown;
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 6f6f76c..ae64c86 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -39,27 +39,27 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/variable_decoration.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "tint/tint.h"
@@ -72,8 +72,8 @@
InspectorHelper()
: td_(std::make_unique<TypeDeterminer>(mod)),
inspector_(std::make_unique<Inspector>(*mod)),
- sampler_type_(ast::type::SamplerKind::kSampler),
- comparison_sampler_type_(ast::type::SamplerKind::kComparisonSampler) {}
+ sampler_type_(type::SamplerKind::kSampler),
+ comparison_sampler_type_(type::SamplerKind::kComparisonSampler) {}
/// Generates an empty function
/// @param name name of the function created
@@ -177,10 +177,7 @@
/// @param val value to initialize the variable with, if NULL no initializer
/// will be added.
template <class T>
- void AddConstantID(std::string name,
- uint32_t id,
- ast::type::Type* type,
- T* val) {
+ void AddConstantID(std::string name, uint32_t id, type::Type* type, T* val) {
ast::Expression* constructor = nullptr;
if (val) {
constructor =
@@ -196,28 +193,28 @@
/// @param type AST type of the literal, must resolve to BoolLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(ast::type::Type* type, bool* val) {
+ ast::Literal* MakeLiteral(type::Type* type, bool* val) {
return create<ast::BoolLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to UIntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(ast::type::Type* type, uint32_t* val) {
+ ast::Literal* MakeLiteral(type::Type* type, uint32_t* val) {
return create<ast::UintLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to IntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(ast::type::Type* type, int32_t* val) {
+ ast::Literal* MakeLiteral(type::Type* type, int32_t* val) {
return create<ast::SintLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to FloattLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
- ast::Literal* MakeLiteral(ast::type::Type* type, float* val) {
+ ast::Literal* MakeLiteral(type::Type* type, float* val) {
return create<ast::FloatLiteral>(type, *val);
}
@@ -238,7 +235,7 @@
/// @param idx index of member
/// @param type type of member
/// @returns a string for the member
- std::string StructMemberName(size_t idx, ast::type::Type* type) {
+ std::string StructMemberName(size_t idx, type::Type* type) {
return std::to_string(idx) + type->type_name();
}
@@ -248,13 +245,13 @@
/// type and offset of a member of the struct
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type
- ast::type::Struct* MakeStructType(
+ type::Struct* MakeStructType(
const std::string& name,
- std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info,
+ std::vector<std::tuple<type::Type*, uint32_t>> members_info,
bool is_block) {
ast::StructMemberList members;
for (auto& member_info : members_info) {
- ast::type::Type* type;
+ type::Type* type;
uint32_t offset;
std::tie(type, offset) = member_info;
@@ -278,12 +275,12 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for an uniform buffer, and the control type wraps the
/// struct.
- std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
+ std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
MakeUniformBufferTypes(
const std::string& name,
- std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
+ std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
auto* struct_type = MakeStructType(name, members_info, true);
- auto access_type = std::make_unique<ast::type::AccessControl>(
+ auto access_type = std::make_unique<type::AccessControl>(
ast::AccessControl::kReadOnly, struct_type);
return {struct_type, std::move(access_type)};
}
@@ -295,12 +292,12 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a storage buffer, and the control type wraps the
/// struct.
- std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
+ std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
MakeStorageBufferTypes(
const std::string& name,
- std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
+ std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
auto* struct_type = MakeStructType(name, members_info, false);
- auto access_type = std::make_unique<ast::type::AccessControl>(
+ auto access_type = std::make_unique<type::AccessControl>(
ast::AccessControl::kReadWrite, struct_type);
return {struct_type, std::move(access_type)};
}
@@ -312,12 +309,12 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a read-only storage buffer, and the control type
/// wraps the struct.
- std::tuple<ast::type::Struct*, std::unique_ptr<ast::type::AccessControl>>
+ std::tuple<type::Struct*, std::unique_ptr<type::AccessControl>>
MakeReadOnlyStorageBufferTypes(
const std::string& name,
- std::vector<std::tuple<ast::type::Type*, uint32_t>> members_info) {
+ std::vector<std::tuple<type::Type*, uint32_t>> members_info) {
auto* struct_type = MakeStructType(name, members_info, false);
- auto access_type = std::make_unique<ast::type::AccessControl>(
+ auto access_type = std::make_unique<type::AccessControl>(
ast::AccessControl::kReadOnly, struct_type);
return {struct_type, std::move(access_type)};
}
@@ -329,7 +326,7 @@
/// @param group the binding and group to use for the uniform buffer
/// @param binding the binding number to use for the uniform buffer
void AddBinding(const std::string& name,
- ast::type::Type* type,
+ type::Type* type,
ast::StorageClass storage_class,
uint32_t group,
uint32_t binding) {
@@ -348,7 +345,7 @@
/// @param group the binding/group/ to use for the uniform buffer
/// @param binding the binding number to use for the uniform buffer
void AddUniformBuffer(const std::string& name,
- ast::type::Type* type,
+ type::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniform, group, binding);
@@ -360,7 +357,7 @@
/// @param group the binding/group to use for the storage buffer
/// @param binding the binding number to use for the storage buffer
void AddStorageBuffer(const std::string& name,
- ast::type::Type* type,
+ type::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kStorage, group, binding);
@@ -374,11 +371,11 @@
ast::Function* MakeStructVariableReferenceBodyFunction(
std::string func_name,
std::string struct_name,
- std::vector<std::tuple<size_t, ast::type::Type*>> members) {
+ std::vector<std::tuple<size_t, type::Type*>> members) {
ast::StatementList stmts;
for (auto member : members) {
size_t member_idx;
- ast::type::Type* member_type;
+ type::Type* member_type;
std::tie(member_idx, member_type) = member;
std::string member_name = StructMemberName(member_idx, member_type);
@@ -388,7 +385,7 @@
for (auto member : members) {
size_t member_idx;
- ast::type::Type* member_type;
+ type::Type* member_type;
std::tie(member_idx, member_type) = member;
std::string member_name = StructMemberName(member_idx, member_type);
@@ -427,28 +424,28 @@
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- std::unique_ptr<ast::type::SampledTexture> MakeSampledTextureType(
- ast::type::TextureDimension dim,
- ast::type::Type* type) {
- return std::make_unique<ast::type::SampledTexture>(dim, type);
+ std::unique_ptr<type::SampledTexture> MakeSampledTextureType(
+ type::TextureDimension dim,
+ type::Type* type) {
+ return std::make_unique<type::SampledTexture>(dim, type);
}
/// Generates a DepthTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @returns the generated DepthTexture
- std::unique_ptr<ast::type::DepthTexture> MakeDepthTextureType(
- ast::type::TextureDimension dim) {
- return std::make_unique<ast::type::DepthTexture>(dim);
+ std::unique_ptr<type::DepthTexture> MakeDepthTextureType(
+ type::TextureDimension dim) {
+ return std::make_unique<type::DepthTexture>(dim);
}
/// Generates a MultisampledTexture appropriate for the params
/// @param dim the dimensions of the texture
/// @param type the data type of the sampled texture
/// @returns the generated SampleTextureType
- std::unique_ptr<ast::type::MultisampledTexture> MakeMultisampledTextureType(
- ast::type::TextureDimension dim,
- ast::type::Type* type) {
- return std::make_unique<ast::type::MultisampledTexture>(dim, type);
+ std::unique_ptr<type::MultisampledTexture> MakeMultisampledTextureType(
+ type::TextureDimension dim,
+ type::Type* type) {
+ return std::make_unique<type::MultisampledTexture>(dim, type);
}
/// Adds a sampled texture variable to the module
@@ -457,7 +454,7 @@
/// @param group the binding/group to use for the sampled texture
/// @param binding the binding number to use for the sampled texture
void AddSampledTexture(const std::string& name,
- ast::type::Type* type,
+ type::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
@@ -469,13 +466,13 @@
/// @param group the binding/group to use for the multi-sampled texture
/// @param binding the binding number to use for the multi-sampled texture
void AddMultisampledTexture(const std::string& name,
- ast::type::Type* type,
+ type::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
}
- void AddGlobalVariable(const std::string& name, ast::type::Type* type) {
+ void AddGlobalVariable(const std::string& name, type::Type* type) {
mod->AddGlobalVariable(
Var(name, ast::StorageClass::kUniformConstant, type));
}
@@ -483,7 +480,7 @@
/// Adds a depth texture variable to the module
/// @param name the name of the variable
/// @param type the type to use
- void AddDepthTexture(const std::string& name, ast::type::Type* type) {
+ void AddDepthTexture(const std::string& name, type::Type* type) {
mod->AddGlobalVariable(
Var(name, ast::StorageClass::kUniformConstant, type));
}
@@ -501,7 +498,7 @@
const std::string& texture_name,
const std::string& sampler_name,
const std::string& coords_name,
- ast::type::Type* base_type,
+ type::Type* base_type,
ast::FunctionDecorationList decorations) {
std::string result_name = "sampler_result";
@@ -533,7 +530,7 @@
const std::string& sampler_name,
const std::string& coords_name,
const std::string& array_index,
- ast::type::Type* base_type,
+ type::Type* base_type,
ast::FunctionDecorationList decorations) {
std::string result_name = "sampler_result";
@@ -567,7 +564,7 @@
const std::string& sampler_name,
const std::string& coords_name,
const std::string& depth_name,
- ast::type::Type* base_type,
+ type::Type* base_type,
ast::FunctionDecorationList decorations) {
std::string result_name = "sampler_result";
@@ -586,7 +583,7 @@
/// Gets an appropriate type for the data in a given texture type.
/// @param sampled_kind type of in the texture
/// @returns a pointer to a type appropriate for the coord param
- ast::type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
+ type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
switch (sampled_kind) {
case ResourceBinding::SampledKind::kFloat:
return ty.f32;
@@ -604,15 +601,15 @@
/// @param dim dimensionality of the texture being sampled
/// @param sampled_kind type of data in the texture
/// @returns a pointer to a type appropriate for the coord param
- ast::type::Type* GetCoordsType(ast::type::TextureDimension dim,
- ResourceBinding::SampledKind sampled_kind) {
- ast::type::Type* base_type = GetBaseType(sampled_kind);
- if (dim == ast::type::TextureDimension::k1d) {
+ type::Type* GetCoordsType(type::TextureDimension dim,
+ ResourceBinding::SampledKind sampled_kind) {
+ type::Type* base_type = GetBaseType(sampled_kind);
+ if (dim == type::TextureDimension::k1d) {
return base_type;
- } else if (dim == ast::type::TextureDimension::k1dArray ||
- dim == ast::type::TextureDimension::k2d) {
+ } else if (dim == type::TextureDimension::k1dArray ||
+ dim == type::TextureDimension::k2d) {
return vec_type(base_type, 2);
- } else if (dim == ast::type::TextureDimension::kCubeArray) {
+ } else if (dim == type::TextureDimension::kCubeArray) {
return vec_type(base_type, 4);
}
return vec_type(base_type, 3);
@@ -621,38 +618,35 @@
TypeDeterminer* td() { return td_.get(); }
Inspector* inspector() { return inspector_.get(); }
- ast::type::Array* u32_array_type(uint32_t count) {
+ type::Array* u32_array_type(uint32_t count) {
if (array_type_memo_.find(count) == array_type_memo_.end()) {
array_type_memo_[count] =
- create<ast::type::Array>(ty.u32, count,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(4),
- });
+ create<type::Array>(ty.u32, count,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
+ });
}
return array_type_memo_[count];
}
- ast::type::Vector* vec_type(ast::type::Type* type, uint32_t count) {
+ type::Vector* vec_type(type::Type* type, uint32_t count) {
if (vector_type_memo_.find(std::tie(type, count)) ==
vector_type_memo_.end()) {
vector_type_memo_[std::tie(type, count)] =
- std::make_unique<ast::type::Vector>(ty.u32, count);
+ std::make_unique<type::Vector>(ty.u32, count);
}
return vector_type_memo_[std::tie(type, count)].get();
}
- ast::type::Sampler* sampler_type() { return &sampler_type_; }
- ast::type::Sampler* comparison_sampler_type() {
- return &comparison_sampler_type_;
- }
+ type::Sampler* sampler_type() { return &sampler_type_; }
+ type::Sampler* comparison_sampler_type() { return &comparison_sampler_type_; }
private:
std::unique_ptr<TypeDeterminer> td_;
std::unique_ptr<Inspector> inspector_;
- ast::type::Sampler sampler_type_;
- ast::type::Sampler comparison_sampler_type_;
- std::map<uint32_t, ast::type::Array*> array_type_memo_;
- std::map<std::tuple<ast::type::Type*, uint32_t>,
- std::unique_ptr<ast::type::Vector>>
+ type::Sampler sampler_type_;
+ type::Sampler comparison_sampler_type_;
+ std::map<uint32_t, type::Array*> array_type_memo_;
+ std::map<std::tuple<type::Type*, uint32_t>, std::unique_ptr<type::Vector>>
vector_type_memo_;
};
@@ -680,7 +674,7 @@
: public InspectorHelper,
public testing::Test {};
struct GetSampledTextureTestParams {
- ast::type::TextureDimension type_dim;
+ type::TextureDimension type_dim;
inspector::ResourceBinding::TextureDimension inspector_dim;
inspector::ResourceBinding::SampledKind sampled_kind;
};
@@ -1287,8 +1281,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1340,8 +1334,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1369,8 +1363,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1398,8 +1392,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
- ast::type::Struct* ub_struct_type;
- std::unique_ptr<ast::type::AccessControl> ub_control_type;
+ type::Struct* ub_struct_type;
+ std::unique_ptr<type::AccessControl> ub_control_type;
std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes(
"ub_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
AddUniformBuffer("ub_foo", ub_control_type.get(), 0, 0);
@@ -1450,8 +1444,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0);
@@ -1479,8 +1473,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1508,8 +1502,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1537,8 +1531,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
- ast::type::Struct* sb_struct_type;
- std::unique_ptr<ast::type::AccessControl> sb_control_type;
+ type::Struct* sb_struct_type;
+ std::unique_ptr<type::AccessControl> sb_control_type;
std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes(
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
@@ -1592,8 +1586,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1621,8 +1615,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1650,8 +1644,8 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1675,8 +1669,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1706,8 +1700,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
MultipleStorageBuffers) {
- ast::type::Struct* sb_struct_type;
- std::unique_ptr<ast::type::AccessControl> sb_control_type;
+ type::Struct* sb_struct_type;
+ std::unique_ptr<type::AccessControl> sb_control_type;
std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes(
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0);
@@ -1762,8 +1756,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
"foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1793,8 +1787,8 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
ContainingRuntimeArray) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
"foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1823,8 +1817,8 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
- ast::type::Struct* foo_struct_type;
- std::unique_ptr<ast::type::AccessControl> foo_control_type;
+ type::Struct* foo_struct_type;
+ std::unique_ptr<type::AccessControl> foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0);
@@ -1850,7 +1844,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
auto sampled_texture_type =
- MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
+ MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -1889,7 +1883,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
auto sampled_texture_type =
- MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
+ MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -1917,7 +1911,7 @@
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
auto sampled_texture_type =
- MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
+ MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -1936,8 +1930,7 @@
}
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
- auto depth_texture_type =
- MakeDepthTextureType(ast::type::TextureDimension::k2d);
+ auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type.get());
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -1959,8 +1952,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
- auto depth_texture_type =
- MakeDepthTextureType(ast::type::TextureDimension::k2d);
+ auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type.get());
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -1999,8 +1991,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
- auto depth_texture_type =
- MakeDepthTextureType(ast::type::TextureDimension::k2d);
+ auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type.get());
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -2029,8 +2020,7 @@
}
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
- auto depth_texture_type =
- MakeDepthTextureType(ast::type::TextureDimension::k2d);
+ auto depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
AddDepthTexture("foo_texture", depth_texture_type.get());
AddComparisonSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -2051,7 +2041,7 @@
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
auto sampled_texture_type =
- MakeSampledTextureType(ast::type::TextureDimension::k1d, ty.f32);
+ MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
AddSampledTexture("foo_texture", sampled_texture_type.get(), 0, 0);
AddSampler("foo_sampler", 0, 1);
AddGlobalVariable("foo_coords", ty.f32);
@@ -2125,51 +2115,51 @@
InspectorGetSampledTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kUInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kUInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k3d,
+ type::TextureDimension::k3d,
inspector::ResourceBinding::TextureDimension::k3d,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k3d,
+ type::TextureDimension::k3d,
inspector::ResourceBinding::TextureDimension::k3d,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k3d,
+ type::TextureDimension::k3d,
inspector::ResourceBinding::TextureDimension::k3d,
inspector::ResourceBinding::SampledKind::kUInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCube,
+ type::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCube,
+ type::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCube,
+ type::TextureDimension::kCube,
inspector::ResourceBinding::TextureDimension::kCube,
inspector::ResourceBinding::SampledKind::kUInt}));
@@ -2209,39 +2199,39 @@
InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kUInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kUInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCubeArray,
+ type::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCubeArray,
+ type::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetSampledTextureTestParams{
- ast::type::TextureDimension::kCubeArray,
+ type::TextureDimension::kCubeArray,
inspector::ResourceBinding::TextureDimension::kCubeArray,
inspector::ResourceBinding::SampledKind::kUInt}));
@@ -2287,27 +2277,27 @@
InspectorGetMultisampledTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1d,
+ type::TextureDimension::k1d,
inspector::ResourceBinding::TextureDimension::k1d,
inspector::ResourceBinding::SampledKind::kUInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
inspector::ResourceBinding::TextureDimension::k2d,
inspector::ResourceBinding::SampledKind::kUInt}));
@@ -2360,27 +2350,27 @@
InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
testing::Values(
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k1dArray,
+ type::TextureDimension::k1dArray,
inspector::ResourceBinding::TextureDimension::k1dArray,
inspector::ResourceBinding::SampledKind::kUInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kFloat},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kSInt},
GetMultisampledTextureTestParams{
- ast::type::TextureDimension::k2dArray,
+ type::TextureDimension::k2dArray,
inspector::ResourceBinding::TextureDimension::k2dArray,
inspector::ResourceBinding::SampledKind::kUInt}));
diff --git a/src/reader/spirv/enum_converter.cc b/src/reader/spirv/enum_converter.cc
index 8719140..f53c4a6 100644
--- a/src/reader/spirv/enum_converter.cc
+++ b/src/reader/spirv/enum_converter.cc
@@ -94,85 +94,85 @@
return ast::Builtin::kNone;
}
-ast::type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
+type::TextureDimension EnumConverter::ToDim(SpvDim dim, bool arrayed) {
if (arrayed) {
switch (dim) {
case SpvDim1D:
- return ast::type::TextureDimension::k1dArray;
+ return type::TextureDimension::k1dArray;
case SpvDim2D:
- return ast::type::TextureDimension::k2dArray;
+ return type::TextureDimension::k2dArray;
case SpvDimCube:
- return ast::type::TextureDimension::kCubeArray;
+ return type::TextureDimension::kCubeArray;
default:
break;
}
Fail() << "arrayed dimension must be 1D, 2D, or Cube. Got " << int(dim);
- return ast::type::TextureDimension::kNone;
+ return type::TextureDimension::kNone;
}
// Assume non-arrayed
switch (dim) {
case SpvDim1D:
- return ast::type::TextureDimension::k1d;
+ return type::TextureDimension::k1d;
case SpvDim2D:
- return ast::type::TextureDimension::k2d;
+ return type::TextureDimension::k2d;
case SpvDim3D:
- return ast::type::TextureDimension::k3d;
+ return type::TextureDimension::k3d;
case SpvDimCube:
- return ast::type::TextureDimension::kCube;
+ return type::TextureDimension::kCube;
default:
break;
}
Fail() << "invalid dimension: " << int(dim);
- return ast::type::TextureDimension::kNone;
+ return type::TextureDimension::kNone;
}
-ast::type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
+type::ImageFormat EnumConverter::ToImageFormat(SpvImageFormat fmt) {
switch (fmt) {
case SpvImageFormatUnknown:
- return ast::type::ImageFormat::kNone;
+ return type::ImageFormat::kNone;
// 8 bit channels
case SpvImageFormatRgba8:
- return ast::type::ImageFormat::kRgba8Unorm;
+ return type::ImageFormat::kRgba8Unorm;
case SpvImageFormatRgba8Snorm:
- return ast::type::ImageFormat::kRgba8Snorm;
+ return type::ImageFormat::kRgba8Snorm;
case SpvImageFormatRgba8ui:
- return ast::type::ImageFormat::kRgba8Uint;
+ return type::ImageFormat::kRgba8Uint;
case SpvImageFormatRgba8i:
- return ast::type::ImageFormat::kRgba8Sint;
+ return type::ImageFormat::kRgba8Sint;
// 16 bit channels
case SpvImageFormatRgba16ui:
- return ast::type::ImageFormat::kRgba16Uint;
+ return type::ImageFormat::kRgba16Uint;
case SpvImageFormatRgba16i:
- return ast::type::ImageFormat::kRgba16Sint;
+ return type::ImageFormat::kRgba16Sint;
case SpvImageFormatRgba16f:
- return ast::type::ImageFormat::kRgba16Float;
+ return type::ImageFormat::kRgba16Float;
// 32 bit channels
case SpvImageFormatR32ui:
- return ast::type::ImageFormat::kR32Uint;
+ return type::ImageFormat::kR32Uint;
case SpvImageFormatR32i:
- return ast::type::ImageFormat::kR32Sint;
+ return type::ImageFormat::kR32Sint;
case SpvImageFormatR32f:
- return ast::type::ImageFormat::kR32Float;
+ return type::ImageFormat::kR32Float;
case SpvImageFormatRg32ui:
- return ast::type::ImageFormat::kRg32Uint;
+ return type::ImageFormat::kRg32Uint;
case SpvImageFormatRg32i:
- return ast::type::ImageFormat::kRg32Sint;
+ return type::ImageFormat::kRg32Sint;
case SpvImageFormatRg32f:
- return ast::type::ImageFormat::kRg32Float;
+ return type::ImageFormat::kRg32Float;
case SpvImageFormatRgba32ui:
- return ast::type::ImageFormat::kRgba32Uint;
+ return type::ImageFormat::kRgba32Uint;
case SpvImageFormatRgba32i:
- return ast::type::ImageFormat::kRgba32Sint;
+ return type::ImageFormat::kRgba32Sint;
case SpvImageFormatRgba32f:
- return ast::type::ImageFormat::kRgba32Float;
+ return type::ImageFormat::kRgba32Float;
default:
break;
}
Fail() << "invalid image format: " << int(fmt);
- return ast::type::ImageFormat::kNone;
+ return type::ImageFormat::kNone;
}
} // namespace spirv
diff --git a/src/reader/spirv/enum_converter.h b/src/reader/spirv/enum_converter.h
index fdcef1f..59c7d04 100644
--- a/src/reader/spirv/enum_converter.h
+++ b/src/reader/spirv/enum_converter.h
@@ -19,8 +19,8 @@
#include "src/ast/builtin.h"
#include "src/ast/pipeline_stage.h"
#include "src/ast/storage_class.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/texture_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/texture_type.h"
#include "src/reader/spirv/fail_stream.h"
namespace tint {
@@ -59,13 +59,13 @@
/// @param dim the SPIR-V Dim value
/// @param arrayed true if the texture is arrayed
/// @returns a Tint AST texture dimension
- ast::type::TextureDimension ToDim(SpvDim dim, bool arrayed);
+ type::TextureDimension ToDim(SpvDim dim, bool arrayed);
/// Converts a SPIR-V Image Format to a Tint ImageFormat
/// On failure, logs an error and returns kNone
/// @param fmt the SPIR-V format
/// @returns a Tint AST format
- ast::type::ImageFormat ToImageFormat(SpvImageFormat fmt);
+ type::ImageFormat ToImageFormat(SpvImageFormat fmt);
private:
/// Registers a failure and returns a stream for log diagnostics.
diff --git a/src/reader/spirv/enum_converter_test.cc b/src/reader/spirv/enum_converter_test.cc
index bf4c5c0..ad8adc1 100644
--- a/src/reader/spirv/enum_converter_test.cc
+++ b/src/reader/spirv/enum_converter_test.cc
@@ -236,7 +236,7 @@
SpvDim dim;
bool arrayed;
bool expect_success;
- ast::type::TextureDimension expected;
+ type::TextureDimension expected;
};
inline std::ostream& operator<<(std::ostream& out, DimCase dc) {
out << "DimCase{ SpvDim:" << int(dc.dim) << " arrayed?:" << int(dc.arrayed)
@@ -280,41 +280,39 @@
SpvDimTest,
testing::Values(
// Non-arrayed
- DimCase{SpvDim1D, false, true, ast::type::TextureDimension::k1d},
- DimCase{SpvDim2D, false, true, ast::type::TextureDimension::k2d},
- DimCase{SpvDim3D, false, true, ast::type::TextureDimension::k3d},
- DimCase{SpvDimCube, false, true, ast::type::TextureDimension::kCube},
+ DimCase{SpvDim1D, false, true, type::TextureDimension::k1d},
+ DimCase{SpvDim2D, false, true, type::TextureDimension::k2d},
+ DimCase{SpvDim3D, false, true, type::TextureDimension::k3d},
+ DimCase{SpvDimCube, false, true, type::TextureDimension::kCube},
// Arrayed
- DimCase{SpvDim1D, true, true, ast::type::TextureDimension::k1dArray},
- DimCase{SpvDim2D, true, true, ast::type::TextureDimension::k2dArray},
- DimCase{SpvDimCube, true, true,
- ast::type::TextureDimension::kCubeArray}));
+ DimCase{SpvDim1D, true, true, type::TextureDimension::k1dArray},
+ DimCase{SpvDim2D, true, true, type::TextureDimension::k2dArray},
+ DimCase{SpvDimCube, true, true, type::TextureDimension::kCubeArray}));
INSTANTIATE_TEST_SUITE_P(
EnumConverterBad,
SpvDimTest,
testing::Values(
// Invalid SPIR-V dimensionality.
- DimCase{SpvDimMax, false, false, ast::type::TextureDimension::kNone},
- DimCase{SpvDimMax, true, false, ast::type::TextureDimension::kNone},
+ DimCase{SpvDimMax, false, false, type::TextureDimension::kNone},
+ DimCase{SpvDimMax, true, false, type::TextureDimension::kNone},
// Vulkan non-arrayed dimensionalities not supported by WGSL.
- DimCase{SpvDimRect, false, false, ast::type::TextureDimension::kNone},
- DimCase{SpvDimBuffer, false, false, ast::type::TextureDimension::kNone},
- DimCase{SpvDimSubpassData, false, false,
- ast::type::TextureDimension::kNone},
+ DimCase{SpvDimRect, false, false, type::TextureDimension::kNone},
+ DimCase{SpvDimBuffer, false, false, type::TextureDimension::kNone},
+ DimCase{SpvDimSubpassData, false, false, type::TextureDimension::kNone},
// Arrayed dimensionalities not supported by WGSL
- DimCase{SpvDim3D, true, false, ast::type::TextureDimension::kNone},
- DimCase{SpvDimRect, true, false, ast::type::TextureDimension::kNone},
- DimCase{SpvDimBuffer, true, false, ast::type::TextureDimension::kNone},
+ DimCase{SpvDim3D, true, false, type::TextureDimension::kNone},
+ DimCase{SpvDimRect, true, false, type::TextureDimension::kNone},
+ DimCase{SpvDimBuffer, true, false, type::TextureDimension::kNone},
DimCase{SpvDimSubpassData, true, false,
- ast::type::TextureDimension::kNone}));
+ type::TextureDimension::kNone}));
// ImageFormat
struct ImageFormatCase {
SpvImageFormat format;
bool expect_success;
- ast::type::ImageFormat expected;
+ type::ImageFormat expected;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatCase ifc) {
out << "ImageFormatCase{ SpvImageFormat:" << int(ifc.format)
@@ -358,85 +356,70 @@
SpvImageFormatTest,
testing::Values(
// Unknown. This is used for sampled images.
- ImageFormatCase{SpvImageFormatUnknown, true,
- ast::type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatUnknown, true, type::ImageFormat::kNone},
// 8 bit channels
ImageFormatCase{SpvImageFormatRgba8, true,
- ast::type::ImageFormat::kRgba8Unorm},
+ type::ImageFormat::kRgba8Unorm},
ImageFormatCase{SpvImageFormatRgba8Snorm, true,
- ast::type::ImageFormat::kRgba8Snorm},
+ type::ImageFormat::kRgba8Snorm},
ImageFormatCase{SpvImageFormatRgba8ui, true,
- ast::type::ImageFormat::kRgba8Uint},
+ type::ImageFormat::kRgba8Uint},
ImageFormatCase{SpvImageFormatRgba8i, true,
- ast::type::ImageFormat::kRgba8Sint},
+ type::ImageFormat::kRgba8Sint},
// 16 bit channels
ImageFormatCase{SpvImageFormatRgba16ui, true,
- ast::type::ImageFormat::kRgba16Uint},
+ type::ImageFormat::kRgba16Uint},
ImageFormatCase{SpvImageFormatRgba16i, true,
- ast::type::ImageFormat::kRgba16Sint},
+ type::ImageFormat::kRgba16Sint},
ImageFormatCase{SpvImageFormatRgba16f, true,
- ast::type::ImageFormat::kRgba16Float},
+ type::ImageFormat::kRgba16Float},
// 32 bit channels
// ... 1 channel
- ImageFormatCase{SpvImageFormatR32ui, true,
- ast::type::ImageFormat::kR32Uint},
- ImageFormatCase{SpvImageFormatR32i, true,
- ast::type::ImageFormat::kR32Sint},
- ImageFormatCase{SpvImageFormatR32f, true,
- ast::type::ImageFormat::kR32Float},
+ ImageFormatCase{SpvImageFormatR32ui, true, type::ImageFormat::kR32Uint},
+ ImageFormatCase{SpvImageFormatR32i, true, type::ImageFormat::kR32Sint},
+ ImageFormatCase{SpvImageFormatR32f, true, type::ImageFormat::kR32Float},
// ... 2 channels
ImageFormatCase{SpvImageFormatRg32ui, true,
- ast::type::ImageFormat::kRg32Uint},
+ type::ImageFormat::kRg32Uint},
ImageFormatCase{SpvImageFormatRg32i, true,
- ast::type::ImageFormat::kRg32Sint},
+ type::ImageFormat::kRg32Sint},
ImageFormatCase{SpvImageFormatRg32f, true,
- ast::type::ImageFormat::kRg32Float},
+ type::ImageFormat::kRg32Float},
// ... 4 channels
ImageFormatCase{SpvImageFormatRgba32ui, true,
- ast::type::ImageFormat::kRgba32Uint},
+ type::ImageFormat::kRgba32Uint},
ImageFormatCase{SpvImageFormatRgba32i, true,
- ast::type::ImageFormat::kRgba32Sint},
+ type::ImageFormat::kRgba32Sint},
ImageFormatCase{SpvImageFormatRgba32f, true,
- ast::type::ImageFormat::kRgba32Float}));
+ type::ImageFormat::kRgba32Float}));
-INSTANTIATE_TEST_SUITE_P(EnumConverterBad,
- SpvImageFormatTest,
- testing::Values(
- // Scanning in order from the SPIR-V spec.
- ImageFormatCase{SpvImageFormatRg16f, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR16f, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRgb10A2, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR16, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR8, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRgba16Snorm, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16Snorm, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8Snorm, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16i, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8i, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatR8i, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRgb10a2ui, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg16ui, false,
- ast::type::ImageFormat::kNone},
- ImageFormatCase{SpvImageFormatRg8ui, false,
- ast::type::ImageFormat::kNone}));
+INSTANTIATE_TEST_SUITE_P(
+ EnumConverterBad,
+ SpvImageFormatTest,
+ testing::Values(
+ // Scanning in order from the SPIR-V spec.
+ ImageFormatCase{SpvImageFormatRg16f, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR11fG11fB10f, false,
+ type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR16f, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRgb10A2, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR16, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR8, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRgba16Snorm, false,
+ type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16Snorm, false,
+ type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8Snorm, false,
+ type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16i, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8i, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatR8i, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRgb10a2ui, false,
+ type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg16ui, false, type::ImageFormat::kNone},
+ ImageFormatCase{SpvImageFormatRg8ui, false, type::ImageFormat::kNone}));
} // namespace
} // namespace spirv
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index af6e3b5..a18127f 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -53,18 +53,6 @@
#include "src/ast/stage_decoration.h"
#include "src/ast/storage_class.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op.h"
@@ -74,6 +62,18 @@
#include "src/reader/spirv/construct.h"
#include "src/reader/spirv/fail_stream.h"
#include "src/reader/spirv/parser_impl.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
// Terms:
// CFG: the control flow graph of the function, where basic blocks are the
@@ -725,7 +725,7 @@
fail_stream_(pi->fail_stream()),
namer_(pi->namer()),
function_(function),
- i32_(ast_module_.create<ast::type::I32>()),
+ i32_(ast_module_.create<type::I32>()),
ep_info_(ep_info) {
PushNewStatementBlock(nullptr, 0, nullptr);
}
@@ -929,7 +929,7 @@
return success();
}
-ast::type::Type* FunctionEmitter::GetVariableStoreType(
+type::Type* FunctionEmitter::GetVariableStoreType(
const spvtools::opt::Instruction& var_decl_inst) {
const auto type_id = var_decl_inst.type_id();
auto* var_ref_type = type_mgr_->GetType(type_id);
@@ -1998,7 +1998,7 @@
<< id;
return {};
case SkipReason::kPointSizeBuiltinValue: {
- auto* f32 = create<ast::type::F32>();
+ auto* f32 = create<type::F32>();
return {f32,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, f32, 1.0f))};
@@ -2985,8 +2985,8 @@
}
auto expr = MakeExpression(ptr_id);
// The load result type is the pointee type of its operand.
- assert(expr.type->Is<ast::type::Pointer>());
- expr.type = expr.type->As<ast::type::Pointer>()->type();
+ assert(expr.type->Is<type::Pointer>());
+ expr.type = expr.type->As<type::Pointer>()->type();
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
@@ -3043,7 +3043,7 @@
const auto opcode = inst.opcode();
- ast::type::Type* ast_type =
+ type::Type* ast_type =
inst.type_id() != 0 ? parser_impl_.ConvertType(inst.type_id()) : nullptr;
auto binary_op = ConvertBinaryOp(opcode);
@@ -3181,7 +3181,7 @@
auto* func = create<ast::IdentifierExpression>(
Source{}, ast_module_.RegisterSymbol(name));
ast::ExpressionList operands;
- ast::type::Type* first_operand_type = nullptr;
+ type::Type* first_operand_type = nullptr;
// All parameters to GLSL.std.450 extended instructions are IDs.
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
TypedExpression operand = MakeOperand(inst, iarg);
@@ -3423,7 +3423,7 @@
type_mgr_->FindPointerToType(pointee_type_id, storage_class);
auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id);
assert(ast_pointer_type);
- assert(ast_pointer_type->Is<ast::type::Pointer>());
+ assert(ast_pointer_type->Is<type::Pointer>());
current_expr = TypedExpression{ast_pointer_type, next_expr};
}
return current_expr;
@@ -3443,7 +3443,7 @@
TypedExpression current_expr(MakeOperand(inst, 0));
auto make_index = [this, source](uint32_t literal) {
- auto* type = create<ast::type::U32>();
+ auto* type = create<type::U32>();
return create<ast::ScalarConstructorExpression>(
source, create<ast::UintLiteral>(source, type, literal));
};
@@ -3551,7 +3551,7 @@
}
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
- ast::type::Bool bool_type;
+ type::Bool bool_type;
return create<ast::ScalarConstructorExpression>(
source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
}
@@ -3572,8 +3572,8 @@
// Generate an ast::TypeConstructor expression.
// Assume the literal indices are valid, and there is a valid number of them.
auto source = GetSourceForInst(inst);
- ast::type::Vector* result_type =
- parser_impl_.ConvertType(inst.type_id())->As<ast::type::Vector>();
+ type::Vector* result_type =
+ parser_impl_.ConvertType(inst.type_id())->As<type::Vector>();
ast::ExpressionList values;
for (uint32_t i = 2; i < inst.NumInOperands(); ++i) {
const auto index = inst.GetSingleWordInOperand(i);
@@ -3642,7 +3642,7 @@
if (type) {
if (type->AsPointer()) {
if (const auto* ast_type = parser_impl_.ConvertType(inst.type_id())) {
- if (auto* ptr = ast_type->As<ast::type::Pointer>()) {
+ if (auto* ptr = ast_type->As<type::Pointer>()) {
info->storage_class = ptr->storage_class();
}
}
@@ -3686,21 +3686,21 @@
const auto type_id = def_use_mgr_->GetDef(id)->type_id();
if (type_id) {
auto* ast_type = parser_impl_.ConvertType(type_id);
- if (ast_type && ast_type->Is<ast::type::Pointer>()) {
- return ast_type->As<ast::type::Pointer>()->storage_class();
+ if (ast_type && ast_type->Is<type::Pointer>()) {
+ return ast_type->As<type::Pointer>()->storage_class();
}
}
return ast::StorageClass::kNone;
}
-ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type,
- uint32_t result_id) {
- if (const auto* ast_ptr_type = type->As<ast::type::Pointer>()) {
+type::Type* FunctionEmitter::RemapStorageClass(type::Type* type,
+ uint32_t result_id) {
+ if (const auto* ast_ptr_type = type->As<type::Pointer>()) {
// Remap an old-style storage buffer pointer to a new-style storage
// buffer pointer.
const auto sc = GetStorageClassForPointerValue(result_id);
if (ast_ptr_type->storage_class() != sc) {
- return parser_impl_.get_module().create<ast::type::Pointer>(
+ return parser_impl_.get_module().create<type::Pointer>(
ast_ptr_type->type(), sc);
}
}
@@ -3884,7 +3884,7 @@
return {};
}
- ast::type::Type* expr_type = nullptr;
+ type::Type* expr_type = nullptr;
if ((opcode == SpvOpConvertSToF) || (opcode == SpvOpConvertUToF)) {
if (arg_expr.type->is_integer_scalar_or_vector()) {
expr_type = requested_type;
@@ -3946,7 +3946,7 @@
<< inst.PrettyPrint();
}
- if (result_type->Is<ast::type::Void>()) {
+ if (result_type->Is<type::Void>()) {
return nullptr !=
AddStatement(create<ast::CallStatement>(Source{}, call_expr));
}
@@ -3965,7 +3965,7 @@
ident->set_intrinsic(intrinsic);
ast::ExpressionList params;
- ast::type::Type* first_operand_type = nullptr;
+ type::Type* first_operand_type = nullptr;
for (uint32_t iarg = 0; iarg < inst.NumInOperands(); ++iarg) {
TypedExpression operand = MakeOperand(inst, iarg);
if (first_operand_type == nullptr) {
@@ -3997,8 +3997,8 @@
// - you can't select over pointers or pointer vectors, unless you also have
// a VariablePointers* capability, which is not allowed in by WebGPU.
auto* op_ty = operand1.type;
- if (op_ty->Is<ast::type::Vector>() || op_ty->is_float_scalar() ||
- op_ty->is_integer_scalar() || op_ty->Is<ast::type::Bool>()) {
+ if (op_ty->Is<type::Vector>() || op_ty->is_float_scalar() ||
+ op_ty->is_integer_scalar() || op_ty->Is<type::Bool>()) {
ast::ExpressionList params;
params.push_back(operand1.expr);
params.push_back(operand2.expr);
@@ -4050,13 +4050,12 @@
Source{}, ast_module_.RegisterSymbol(param_name)));
}
- ast::type::Pointer* texture_ptr_type =
- parser_impl_.GetTypeForHandleVar(*image);
+ type::Pointer* texture_ptr_type = parser_impl_.GetTypeForHandleVar(*image);
if (!texture_ptr_type) {
return Fail();
}
- ast::type::Texture* texture_type =
- texture_ptr_type->type()->UnwrapAll()->As<ast::type::Texture>();
+ type::Texture* texture_type =
+ texture_ptr_type->type()->UnwrapAll()->As<type::Texture>();
if (!texture_type) {
return Fail();
}
@@ -4160,7 +4159,7 @@
}
TypedExpression lod = MakeOperand(inst, arg_index);
// When sampling from a depth texture, the Lod operand must be an I32.
- if (texture_type->Is<ast::type::DepthTexture>()) {
+ if (texture_type->Is<type::DepthTexture>()) {
// Convert it to a signed integer type.
lod = ToI32(lod);
}
@@ -4188,9 +4187,9 @@
<< inst.PrettyPrint();
}
switch (texture_type->dim()) {
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k2dArray:
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k2dArray:
+ case type::TextureDimension::k3d:
break;
default:
return Fail() << "ConstOffset is only permitted for 2D, 2D Arrayed, "
@@ -4226,7 +4225,7 @@
// The result type, derived from the SPIR-V instruction.
auto* result_type = parser_impl_.ConvertType(inst.type_id());
auto* result_component_type = result_type;
- if (auto* result_vector_type = result_type->As<ast::type::Vector>()) {
+ if (auto* result_vector_type = result_type->As<type::Vector>()) {
result_component_type = result_vector_type->type();
}
@@ -4241,7 +4240,7 @@
// dref gather vec4 ImageFetch vec4 TODO(dneto)
// Construct a 4-element vector with the result from the builtin in the
// first component.
- if (texture_type->Is<ast::type::DepthTexture>()) {
+ if (texture_type->Is<type::DepthTexture>()) {
if (is_non_dref_sample || (opcode == SpvOpImageFetch)) {
value = create<ast::TypeConstructorExpression>(
Source{},
@@ -4269,7 +4268,7 @@
// or vice versa. Perform a bitcast.
value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
}
- if (!expected_component_type->Is<ast::type::F32>() &&
+ if (!expected_component_type->Is<type::F32>() &&
IsSampledImageAccess(opcode)) {
// WGSL permits sampled image access only on float textures.
// Reject this case in the SPIR-V reader, at least until SPIR-V validation
@@ -4326,22 +4325,21 @@
if (!raw_coords.type) {
return {};
}
- ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
+ type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image);
if (!parser_impl_.success()) {
Fail();
return {};
}
- if (!type || !type->type()->UnwrapAll()->Is<ast::type::Texture>()) {
+ if (!type || !type->type()->UnwrapAll()->Is<type::Texture>()) {
Fail() << "invalid texture type for " << image->PrettyPrint();
return {};
}
auto* unwrapped_type = type->type()->UnwrapAll();
- ast::type::TextureDimension dim =
- unwrapped_type->As<ast::type::Texture>()->dim();
+ type::TextureDimension dim = unwrapped_type->As<type::Texture>()->dim();
// Number of regular coordinates.
- uint32_t num_axes = ast::type::NumCoordinateAxes(dim);
- bool is_arrayed = ast::type::IsTextureArray(dim);
+ uint32_t num_axes = type::NumCoordinateAxes(dim);
+ bool is_arrayed = type::IsTextureArray(dim);
if ((num_axes == 0) || (num_axes > 3)) {
Fail() << "unsupported image dimensionality for " << type->type_name()
<< " prompted by " << inst.PrettyPrint();
@@ -4352,7 +4350,7 @@
if (component_type->is_float_scalar() ||
component_type->is_integer_scalar()) {
num_coords_supplied = 1;
- } else if (auto* vec_type = raw_coords.type->As<ast::type::Vector>()) {
+ } else if (auto* vec_type = raw_coords.type->As<type::Vector>()) {
component_type = vec_type->type();
num_coords_supplied = vec_type->size();
}
@@ -4377,9 +4375,9 @@
// will actually use them.
auto prefix_swizzle_expr = [this, num_axes, component_type,
raw_coords]() -> ast::Expression* {
- auto* swizzle_type =
- (num_axes == 1) ? component_type
- : create<ast::type::Vector>(component_type, num_axes);
+ auto* swizzle_type = (num_axes == 1)
+ ? component_type
+ : create<type::Vector>(component_type, num_axes);
auto* swizzle = create<ast::MemberAccessorExpression>(
Source{}, raw_coords.expr, PrefixSwizzle(num_axes));
return ToSignedIfUnsigned({swizzle_type, swizzle}).expr;
@@ -4413,8 +4411,8 @@
ast::Expression* FunctionEmitter::ConvertTexelForStorage(
const spvtools::opt::Instruction& inst,
TypedExpression texel,
- ast::type::Texture* texture_type) {
- auto* storage_texture_type = texture_type->As<ast::type::StorageTexture>();
+ type::Texture* texture_type) {
+ auto* storage_texture_type = texture_type->As<type::StorageTexture>();
auto* src_type = texel.type;
if (!storage_texture_type) {
Fail() << "writing to other than storage texture: " << inst.PrettyPrint();
@@ -4431,14 +4429,14 @@
}
const uint32_t dest_count =
- dest_type->is_scalar() ? 1 : dest_type->As<ast::type::Vector>()->size();
+ dest_type->is_scalar() ? 1 : dest_type->As<type::Vector>()->size();
if (dest_count == 3) {
Fail() << "3-channel storage textures are not supported: "
<< inst.PrettyPrint();
return nullptr;
}
const uint32_t src_count =
- src_type->is_scalar() ? 1 : src_type->As<ast::type::Vector>()->size();
+ src_type->is_scalar() ? 1 : src_type->As<type::Vector>()->size();
if (src_count < dest_count) {
Fail() << "texel has too few components for storage texture: " << src_count
<< " provided but " << dest_count
@@ -4508,8 +4506,8 @@
if (!value.type || !value.type->is_unsigned_scalar_or_vector()) {
return value;
}
- if (auto* vec_type = value.type->As<ast::type::Vector>()) {
- auto* new_type = create<ast::type::Vector>(i32_, vec_type->size());
+ if (auto* vec_type = value.type->As<type::Vector>()) {
+ auto* new_type = create<type::Vector>(i32_, vec_type->size());
return {new_type, create<ast::TypeConstructorExpression>(
Source{}, new_type, ast::ExpressionList{value.expr})};
}
@@ -4560,10 +4558,10 @@
// Synthesize the result.
auto col = MakeOperand(inst, 0);
auto row = MakeOperand(inst, 1);
- auto* col_ty = col.type->As<ast::type::Vector>();
- auto* row_ty = row.type->As<ast::type::Vector>();
+ auto* col_ty = col.type->As<type::Vector>();
+ auto* row_ty = row.type->As<type::Vector>();
auto* result_ty =
- parser_impl_.ConvertType(inst.type_id())->As<ast::type::Matrix>();
+ parser_impl_.ConvertType(inst.type_id())->As<type::Matrix>();
if (!col_ty || !col_ty || !result_ty || result_ty->type() != col_ty->type() ||
result_ty->type() != row_ty->type() ||
result_ty->columns() != row_ty->size() ||
diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h
index 74dc3ca..6ea6e36 100644
--- a/src/reader/spirv/function.h
+++ b/src/reader/spirv/function.h
@@ -36,12 +36,12 @@
#include "src/ast/module.h"
#include "src/ast/statement.h"
#include "src/ast/storage_class.h"
-#include "src/ast/type/i32_type.h"
#include "src/reader/spirv/construct.h"
#include "src/reader/spirv/entry_point_info.h"
#include "src/reader/spirv/fail_stream.h"
#include "src/reader/spirv/namer.h"
#include "src/reader/spirv/parser_impl.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace reader {
@@ -485,7 +485,7 @@
/// @param type the AST type
/// @param result_id the SPIR-V ID for the locally defined value
/// @returns an possibly updated type
- ast::type::Type* RemapStorageClass(ast::type::Type* type, uint32_t result_id);
+ type::Type* RemapStorageClass(type::Type* type, uint32_t result_id);
/// Marks locally defined values when they should get a 'const'
/// definition in WGSL, or a 'var' definition at an outer scope.
@@ -804,7 +804,7 @@
/// Function parameters
ast::VariableList params;
/// Function return type
- ast::type::Type* return_type;
+ type::Type* return_type;
/// Function decorations
ast::FunctionDecorationList decorations;
};
@@ -817,7 +817,7 @@
/// @returns the store type for the OpVariable instruction, or
/// null on failure.
- ast::type::Type* GetVariableStoreType(
+ type::Type* GetVariableStoreType(
const spvtools::opt::Instruction& var_decl_inst);
/// Returns an expression for an instruction operand. Signedness conversion is
@@ -874,7 +874,7 @@
ast::Expression* ConvertTexelForStorage(
const spvtools::opt::Instruction& inst,
TypedExpression texel,
- ast::type::Texture* texture_type);
+ type::Texture* texture_type);
/// Returns an expression for an OpSelect, if its operands are scalars
/// or vectors. These translate directly to WGSL select. Otherwise, return
@@ -1037,7 +1037,7 @@
FailStream& fail_stream_;
Namer& namer_;
const spvtools::opt::Function& function_;
- ast::type::I32* const i32_; // The unique I32 type object.
+ type::I32* const i32_; // The unique I32 type object.
// A stack of statement lists. Each list is contained in a construct in
// the next deeper element of stack. The 0th entry represents the statements
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index a9b7281..5a3a1d9 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -52,24 +52,6 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
@@ -79,6 +61,24 @@
#include "src/reader/spirv/enum_converter.h"
#include "src/reader/spirv/function.h"
#include "src/reader/spirv/usage.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -255,7 +255,7 @@
: Reader(),
spv_binary_(spv_binary),
fail_stream_(&success_, &errors_),
- bool_type_(ast_module_.create<ast::type::Bool>()),
+ bool_type_(ast_module_.create<type::Bool>()),
namer_(fail_stream_),
enum_converter_(fail_stream_),
tools_context_(kInputEnv) {
@@ -313,7 +313,7 @@
return std::move(ast_module_);
}
-ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) {
+type::Type* ParserImpl::ConvertType(uint32_t type_id) {
if (!success_) {
return nullptr;
}
@@ -334,7 +334,7 @@
return nullptr;
}
- auto save = [this, type_id, spirv_type](ast::type::Type* type) {
+ auto save = [this, type_id, spirv_type](type::Type* type) {
if (type != nullptr) {
id_to_type_[type_id] = type;
MaybeGenerateAlias(type_id, spirv_type);
@@ -344,7 +344,7 @@
switch (spirv_type->kind()) {
case spvtools::opt::analysis::Type::kVoid:
- return save(ast_module_.create<ast::type::Void>());
+ return save(ast_module_.create<type::Void>());
case spvtools::opt::analysis::Type::kBool:
return save(bool_type_);
case spvtools::opt::analysis::Type::kInteger:
@@ -374,7 +374,7 @@
case spvtools::opt::analysis::Type::kImage:
// Fake it for sampler and texture types. These are handled in an
// entirely different way.
- return save(ast_module_.create<ast::type::Void>());
+ return save(ast_module_.create<type::Void>());
default:
break;
}
@@ -710,11 +710,11 @@
return success_;
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Integer* int_ty) {
if (int_ty->width() == 32) {
- ast::type::Type* signed_ty = ast_module_.create<ast::type::I32>();
- ast::type::Type* unsigned_ty = ast_module_.create<ast::type::U32>();
+ type::Type* signed_ty = ast_module_.create<type::I32>();
+ type::Type* unsigned_ty = ast_module_.create<type::U32>();
signed_type_for_[unsigned_ty] = signed_ty;
unsigned_type_for_[signed_ty] = unsigned_ty;
return int_ty->IsSigned() ? signed_ty : unsigned_ty;
@@ -723,31 +723,31 @@
return nullptr;
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Float* float_ty) {
if (float_ty->width() == 32) {
- return ast_module_.create<ast::type::F32>();
+ return ast_module_.create<type::F32>();
}
Fail() << "unhandled float width: " << float_ty->width();
return nullptr;
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Vector* vec_ty) {
const auto num_elem = vec_ty->element_count();
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(vec_ty->element_type()));
if (ast_elem_ty == nullptr) {
return nullptr;
}
- auto* this_ty = ast_module_.create<ast::type::Vector>(ast_elem_ty, num_elem);
+ auto* this_ty = ast_module_.create<type::Vector>(ast_elem_ty, num_elem);
// Generate the opposite-signedness vector type, if this type is integral.
if (unsigned_type_for_.count(ast_elem_ty)) {
- auto* other_ty = ast_module_.create<ast::type::Vector>(
+ auto* other_ty = ast_module_.create<type::Vector>(
unsigned_type_for_[ast_elem_ty], num_elem);
signed_type_for_[other_ty] = this_ty;
unsigned_type_for_[this_ty] = other_ty;
} else if (signed_type_for_.count(ast_elem_ty)) {
- auto* other_ty = ast_module_.create<ast::type::Vector>(
+ auto* other_ty = ast_module_.create<type::Vector>(
signed_type_for_[ast_elem_ty], num_elem);
unsigned_type_for_[other_ty] = this_ty;
signed_type_for_[this_ty] = other_ty;
@@ -755,7 +755,7 @@
return this_ty;
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Matrix* mat_ty) {
const auto* vec_ty = mat_ty->element_type()->AsVector();
const auto* scalar_ty = vec_ty->element_type();
@@ -765,11 +765,10 @@
if (ast_scalar_ty == nullptr) {
return nullptr;
}
- return ast_module_.create<ast::type::Matrix>(ast_scalar_ty, num_rows,
- num_columns);
+ return ast_module_.create<type::Matrix>(ast_scalar_ty, num_rows, num_columns);
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::RuntimeArray* rtarr_ty) {
auto* ast_elem_ty = ConvertType(type_mgr_->GetId(rtarr_ty->element_type()));
if (ast_elem_ty == nullptr) {
@@ -779,10 +778,10 @@
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
return nullptr;
}
- return create<ast::type::Array>(ast_elem_ty, 0, std::move(decorations));
+ return create<type::Array>(ast_elem_ty, 0, std::move(decorations));
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
const spvtools::opt::analysis::Array* arr_ty) {
const auto elem_type_id = type_mgr_->GetId(arr_ty->element_type());
auto* ast_elem_ty = ConvertType(elem_type_id);
@@ -824,8 +823,8 @@
if (remap_buffer_block_type_.count(elem_type_id)) {
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
}
- return create<ast::type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
- std::move(decorations));
+ return create<type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
+ std::move(decorations));
}
bool ParserImpl::ParseArrayDecorations(
@@ -857,7 +856,7 @@
return true;
}
-ast::type::Type* ParserImpl::ConvertType(
+type::Type* ParserImpl::ConvertType(
uint32_t type_id,
const spvtools::opt::analysis::Struct* struct_ty) {
// Compute the struct decoration.
@@ -964,7 +963,7 @@
namer_.SuggestSanitizedName(type_id, "S");
auto name = namer_.GetName(type_id);
- auto* result = ast_module_.create<ast::type::Struct>(
+ auto* result = ast_module_.create<type::Struct>(
ast_module_.RegisterSymbol(name), ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
@@ -974,9 +973,8 @@
return result;
}
-ast::type::Type* ParserImpl::ConvertType(
- uint32_t type_id,
- const spvtools::opt::analysis::Pointer*) {
+type::Type* ParserImpl::ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Pointer*) {
const auto* inst = def_use_mgr_->GetDef(type_id);
const auto pointee_type_id = inst->GetSingleWordInOperand(1);
const auto storage_class = SpvStorageClass(inst->GetSingleWordInOperand(0));
@@ -1005,7 +1003,7 @@
ast_storage_class = ast::StorageClass::kStorage;
remap_buffer_block_type_.insert(type_id);
}
- return ast_module_.create<ast::type::Pointer>(ast_elem_ty, ast_storage_class);
+ return ast_module_.create<type::Pointer>(ast_elem_ty, ast_storage_class);
}
bool ParserImpl::RegisterTypes() {
@@ -1038,7 +1036,7 @@
// that is OpSpecConstantTrue, OpSpecConstantFalse, or OpSpecConstant.
for (auto& inst : module_->types_values()) {
// These will be populated for a valid scalar spec constant.
- ast::type::Type* ast_type = nullptr;
+ type::Type* ast_type = nullptr;
ast::ScalarConstructorExpression* ast_expr = nullptr;
switch (inst.opcode()) {
@@ -1054,17 +1052,17 @@
case SpvOpSpecConstant: {
ast_type = ConvertType(inst.type_id());
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
- if (ast_type->Is<ast::type::I32>()) {
+ if (ast_type->Is<type::I32>()) {
ast_expr = create<ast::ScalarConstructorExpression>(
Source{},
create<ast::SintLiteral>(Source{}, ast_type,
static_cast<int32_t>(literal_value)));
- } else if (ast_type->Is<ast::type::U32>()) {
+ } else if (ast_type->Is<type::U32>()) {
ast_expr = create<ast::ScalarConstructorExpression>(
Source{},
create<ast::UintLiteral>(Source{}, ast_type,
static_cast<uint32_t>(literal_value)));
- } else if (ast_type->Is<ast::type::F32>()) {
+ } else if (ast_type->Is<type::F32>()) {
float float_value;
// Copy the bits so we can read them as a float.
std::memcpy(&float_value, &literal_value, sizeof(float_value));
@@ -1131,7 +1129,7 @@
return;
}
const auto name = namer_.GetName(type_id);
- auto* ast_alias_type = ast_module_.create<ast::type::Alias>(
+ auto* ast_alias_type = ast_module_.create<type::Alias>(
ast_module_.RegisterSymbol(name), ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
@@ -1176,7 +1174,7 @@
if (!success_) {
return false;
}
- ast::type::Type* ast_type = nullptr;
+ type::Type* ast_type = nullptr;
if (spirv_storage_class == SpvStorageClassUniformConstant) {
// These are opaque handles: samplers or textures
ast_type = GetTypeForHandleVar(var);
@@ -1190,15 +1188,14 @@
"SPIR-V type with ID: "
<< var.type_id();
}
- if (!ast_type->Is<ast::type::Pointer>()) {
+ if (!ast_type->Is<type::Pointer>()) {
return Fail() << "variable with ID " << var.result_id()
<< " has non-pointer type " << var.type_id();
}
}
- auto* ast_store_type = ast_type->As<ast::type::Pointer>()->type();
- auto ast_storage_class =
- ast_type->As<ast::type::Pointer>()->storage_class();
+ auto* ast_store_type = ast_type->As<type::Pointer>()->type();
+ auto ast_storage_class = ast_type->As<type::Pointer>()->storage_class();
ast::Expression* ast_constructor = nullptr;
if (var.NumInOperands() > 1) {
// SPIR-V initializers are always constants.
@@ -1237,7 +1234,7 @@
ast::Variable* ParserImpl::MakeVariable(
uint32_t id,
ast::StorageClass sc,
- ast::type::Type* type,
+ type::Type* type,
bool is_const,
ast::Expression* constructor,
ast::VariableDecorationList decorations) {
@@ -1251,7 +1248,7 @@
auto access = read_only_struct_types_.count(type)
? ast::AccessControl::kReadOnly
: ast::AccessControl::kReadWrite;
- type = ast_module_.create<ast::type::AccessControl>(access, type);
+ type = ast_module_.create<type::AccessControl>(access, type);
}
for (auto& deco : GetDecorationsFor(id)) {
@@ -1351,25 +1348,25 @@
// So canonicalization should map that way too.
// Currently "null<type>" is missing from the WGSL parser.
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
- if (ast_type->Is<ast::type::U32>()) {
+ if (ast_type->Is<type::U32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::UintLiteral>(source, ast_type,
spirv_const->GetU32()))};
}
- if (ast_type->Is<ast::type::I32>()) {
+ if (ast_type->Is<type::I32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(source, ast_type,
spirv_const->GetS32()))};
}
- if (ast_type->Is<ast::type::F32>()) {
+ if (ast_type->Is<type::F32>()) {
return {ast_type,
create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(source, ast_type,
spirv_const->GetFloat()))};
}
- if (ast_type->Is<ast::type::Bool>()) {
+ if (ast_type->Is<type::Bool>()) {
const bool value = spirv_const->AsNullConstant()
? false
: spirv_const->AsBoolConstant()->value();
@@ -1413,7 +1410,7 @@
return {};
}
-ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
+ast::Expression* ParserImpl::MakeNullValue(type::Type* type) {
// TODO(dneto): Use the no-operands constructor syntax when it becomes
// available in Tint.
// https://github.com/gpuweb/gpuweb/issues/685
@@ -1427,23 +1424,23 @@
auto* original_type = type;
type = type->UnwrapIfNeeded();
- if (type->Is<ast::type::Bool>()) {
+ if (type->Is<type::Bool>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, type, false));
}
- if (type->Is<ast::type::U32>()) {
+ if (type->Is<type::U32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
}
- if (type->Is<ast::type::I32>()) {
+ if (type->Is<type::I32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, type, 0));
}
- if (type->Is<ast::type::F32>()) {
+ if (type->Is<type::F32>()) {
return create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
}
- if (const auto* vec_ty = type->As<ast::type::Vector>()) {
+ if (const auto* vec_ty = type->As<type::Vector>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < vec_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
@@ -1451,10 +1448,10 @@
return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
- if (const auto* mat_ty = type->As<ast::type::Matrix>()) {
+ if (const auto* mat_ty = type->As<type::Matrix>()) {
// Matrix components are columns
auto* column_ty =
- ast_module_.create<ast::type::Vector>(mat_ty->type(), mat_ty->rows());
+ ast_module_.create<type::Vector>(mat_ty->type(), mat_ty->rows());
ast::ExpressionList ast_components;
for (size_t i = 0; i < mat_ty->columns(); ++i) {
ast_components.emplace_back(MakeNullValue(column_ty));
@@ -1462,7 +1459,7 @@
return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
- if (auto* arr_ty = type->As<ast::type::Array>()) {
+ if (auto* arr_ty = type->As<type::Array>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
@@ -1470,7 +1467,7 @@
return create<ast::TypeConstructorExpression>(Source{}, original_type,
std::move(ast_components));
}
- if (auto* struct_ty = type->As<ast::type::Struct>()) {
+ if (auto* struct_ty = type->As<type::Struct>()) {
ast::ExpressionList ast_components;
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
@@ -1529,9 +1526,8 @@
return std::move(expr);
}
-ast::type::Type* ParserImpl::ForcedResultType(
- const spvtools::opt::Instruction& inst,
- ast::type::Type* first_operand_type) {
+type::Type* ParserImpl::ForcedResultType(const spvtools::opt::Instruction& inst,
+ type::Type* first_operand_type) {
const auto opcode = inst.opcode();
if (AssumesResultSignednessMatchesFirstOperand(opcode)) {
return first_operand_type;
@@ -1546,37 +1542,36 @@
return nullptr;
}
-ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
+type::Type* ParserImpl::GetSignedIntMatchingShape(type::Type* other) {
if (other == nullptr) {
Fail() << "no type provided";
}
- auto* i32 = ast_module_.create<ast::type::I32>();
- if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
- other->Is<ast::type::I32>()) {
+ auto* i32 = ast_module_.create<type::I32>();
+ if (other->Is<type::F32>() || other->Is<type::U32>() ||
+ other->Is<type::I32>()) {
return i32;
}
- auto* vec_ty = other->As<ast::type::Vector>();
+ auto* vec_ty = other->As<type::Vector>();
if (vec_ty) {
- return ast_module_.create<ast::type::Vector>(i32, vec_ty->size());
+ return ast_module_.create<type::Vector>(i32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
}
-ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
- ast::type::Type* other) {
+type::Type* ParserImpl::GetUnsignedIntMatchingShape(type::Type* other) {
if (other == nullptr) {
Fail() << "no type provided";
return nullptr;
}
- auto* u32 = ast_module_.create<ast::type::U32>();
- if (other->Is<ast::type::F32>() || other->Is<ast::type::U32>() ||
- other->Is<ast::type::I32>()) {
+ auto* u32 = ast_module_.create<type::U32>();
+ if (other->Is<type::F32>() || other->Is<type::U32>() ||
+ other->Is<type::I32>()) {
return u32;
}
- auto* vec_ty = other->As<ast::type::Vector>();
+ auto* vec_ty = other->As<type::Vector>();
if (vec_ty) {
- return ast_module_.create<ast::type::Vector>(u32, vec_ty->size());
+ return ast_module_.create<type::Vector>(u32, vec_ty->size());
}
Fail() << "required numeric scalar or vector, but got " << other->type_name();
return nullptr;
@@ -1585,7 +1580,7 @@
TypedExpression ParserImpl::RectifyForcedResultType(
TypedExpression expr,
const spvtools::opt::Instruction& inst,
- ast::type::Type* first_operand_type) {
+ type::Type* first_operand_type) {
auto* forced_result_ty = ForcedResultType(inst, first_operand_type);
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
return expr;
@@ -1764,7 +1759,7 @@
return raw_handle_type;
}
-ast::type::Pointer* ParserImpl::GetTypeForHandleVar(
+type::Pointer* ParserImpl::GetTypeForHandleVar(
const spvtools::opt::Instruction& var) {
auto where = handle_type_.find(&var);
if (where != handle_type_.end()) {
@@ -1848,11 +1843,11 @@
}
// Construct the Tint handle type.
- ast::type::Type* ast_store_type = nullptr;
+ type::Type* ast_store_type = nullptr;
if (usage.IsSampler()) {
- ast_store_type = ast_module_.create<ast::type::Sampler>(
- usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler
- : ast::type::SamplerKind::kSampler);
+ ast_store_type = ast_module_.create<type::Sampler>(
+ usage.IsComparisonSampler() ? type::SamplerKind::kComparisonSampler
+ : type::SamplerKind::kSampler);
} else if (usage.IsTexture()) {
const spvtools::opt::analysis::Image* image_type =
type_mgr_->GetType(raw_handle_type->result_id())->AsImage();
@@ -1862,9 +1857,9 @@
return nullptr;
}
- const ast::type::TextureDimension dim =
+ const type::TextureDimension dim =
enum_converter_.ToDim(image_type->dim(), image_type->is_arrayed());
- if (dim == ast::type::TextureDimension::kNone) {
+ if (dim == type::TextureDimension::kNone) {
return nullptr;
}
@@ -1881,13 +1876,13 @@
// OpImage variable with an OpImage*Dref* instruction. In WGSL we must
// treat that as a depth texture.
if (image_type->depth() || usage.IsDepthTexture()) {
- ast_store_type = ast_module_.create<ast::type::DepthTexture>(dim);
+ ast_store_type = ast_module_.create<type::DepthTexture>(dim);
} else if (image_type->is_multisampled()) {
// Multisampled textures are never depth textures.
- ast_store_type = ast_module_.create<ast::type::MultisampledTexture>(
+ ast_store_type = ast_module_.create<type::MultisampledTexture>(
dim, ast_sampled_component_type);
} else {
- ast_store_type = ast_module_.create<ast::type::SampledTexture>(
+ ast_store_type = ast_module_.create<type::SampledTexture>(
dim, ast_sampled_component_type);
}
} else {
@@ -1895,11 +1890,11 @@
? ast::AccessControl::kReadOnly
: ast::AccessControl::kWriteOnly;
const auto format = enum_converter_.ToImageFormat(image_type->format());
- if (format == ast::type::ImageFormat::kNone) {
+ if (format == type::ImageFormat::kNone) {
return nullptr;
}
- ast_store_type = ast_module_.create<ast::type::AccessControl>(
- access, ast_module_.create<ast::type::StorageTexture>(dim, format));
+ ast_store_type = ast_module_.create<type::AccessControl>(
+ access, ast_module_.create<type::StorageTexture>(dim, format));
}
} else {
Fail() << "unsupported: UniformConstant variable is not a recognized "
@@ -1909,56 +1904,55 @@
}
// Form the pointer type.
- auto* result = ast_module_.create<ast::type::Pointer>(
+ auto* result = ast_module_.create<type::Pointer>(
ast_store_type, ast::StorageClass::kUniformConstant);
// Remember it for later.
handle_type_[&var] = result;
return result;
}
-ast::type::Type* ParserImpl::GetComponentTypeForFormat(
- ast::type::ImageFormat format) {
+type::Type* ParserImpl::GetComponentTypeForFormat(type::ImageFormat format) {
switch (format) {
- case ast::type::ImageFormat::kR8Uint:
- case ast::type::ImageFormat::kR16Uint:
- case ast::type::ImageFormat::kRg8Uint:
- case ast::type::ImageFormat::kR32Uint:
- case ast::type::ImageFormat::kRg16Uint:
- case ast::type::ImageFormat::kRgba8Uint:
- case ast::type::ImageFormat::kRg32Uint:
- case ast::type::ImageFormat::kRgba16Uint:
- case ast::type::ImageFormat::kRgba32Uint:
- return ast_module_.create<ast::type::U32>();
+ case type::ImageFormat::kR8Uint:
+ case type::ImageFormat::kR16Uint:
+ case type::ImageFormat::kRg8Uint:
+ case type::ImageFormat::kR32Uint:
+ case type::ImageFormat::kRg16Uint:
+ case type::ImageFormat::kRgba8Uint:
+ case type::ImageFormat::kRg32Uint:
+ case type::ImageFormat::kRgba16Uint:
+ case type::ImageFormat::kRgba32Uint:
+ return ast_module_.create<type::U32>();
- case ast::type::ImageFormat::kR8Sint:
- case ast::type::ImageFormat::kR16Sint:
- case ast::type::ImageFormat::kRg8Sint:
- case ast::type::ImageFormat::kR32Sint:
- case ast::type::ImageFormat::kRg16Sint:
- case ast::type::ImageFormat::kRgba8Sint:
- case ast::type::ImageFormat::kRg32Sint:
- case ast::type::ImageFormat::kRgba16Sint:
- case ast::type::ImageFormat::kRgba32Sint:
- return ast_module_.create<ast::type::I32>();
+ case type::ImageFormat::kR8Sint:
+ case type::ImageFormat::kR16Sint:
+ case type::ImageFormat::kRg8Sint:
+ case type::ImageFormat::kR32Sint:
+ case type::ImageFormat::kRg16Sint:
+ case type::ImageFormat::kRgba8Sint:
+ case type::ImageFormat::kRg32Sint:
+ case type::ImageFormat::kRgba16Sint:
+ case type::ImageFormat::kRgba32Sint:
+ return ast_module_.create<type::I32>();
- case ast::type::ImageFormat::kR8Unorm:
- case ast::type::ImageFormat::kRg8Unorm:
- case ast::type::ImageFormat::kRgba8Unorm:
- case ast::type::ImageFormat::kRgba8UnormSrgb:
- case ast::type::ImageFormat::kBgra8Unorm:
- case ast::type::ImageFormat::kBgra8UnormSrgb:
- case ast::type::ImageFormat::kRgb10A2Unorm:
- case ast::type::ImageFormat::kR8Snorm:
- case ast::type::ImageFormat::kRg8Snorm:
- case ast::type::ImageFormat::kRgba8Snorm:
- case ast::type::ImageFormat::kR16Float:
- case ast::type::ImageFormat::kR32Float:
- case ast::type::ImageFormat::kRg16Float:
- case ast::type::ImageFormat::kRg11B10Float:
- case ast::type::ImageFormat::kRg32Float:
- case ast::type::ImageFormat::kRgba16Float:
- case ast::type::ImageFormat::kRgba32Float:
- return ast_module_.create<ast::type::F32>();
+ case type::ImageFormat::kR8Unorm:
+ case type::ImageFormat::kRg8Unorm:
+ case type::ImageFormat::kRgba8Unorm:
+ case type::ImageFormat::kRgba8UnormSrgb:
+ case type::ImageFormat::kBgra8Unorm:
+ case type::ImageFormat::kBgra8UnormSrgb:
+ case type::ImageFormat::kRgb10A2Unorm:
+ case type::ImageFormat::kR8Snorm:
+ case type::ImageFormat::kRg8Snorm:
+ case type::ImageFormat::kRgba8Snorm:
+ case type::ImageFormat::kR16Float:
+ case type::ImageFormat::kR32Float:
+ case type::ImageFormat::kRg16Float:
+ case type::ImageFormat::kRg11B10Float:
+ case type::ImageFormat::kRg32Float:
+ case type::ImageFormat::kRgba16Float:
+ case type::ImageFormat::kRgba32Float:
+ return ast_module_.create<type::F32>();
default:
break;
}
@@ -1966,57 +1960,56 @@
return nullptr;
}
-ast::type::Type* ParserImpl::GetTexelTypeForFormat(
- ast::type::ImageFormat format) {
+type::Type* ParserImpl::GetTexelTypeForFormat(type::ImageFormat format) {
auto* component_type = GetComponentTypeForFormat(format);
if (!component_type) {
return nullptr;
}
switch (format) {
- case ast::type::ImageFormat::kR16Float:
- case ast::type::ImageFormat::kR16Sint:
- case ast::type::ImageFormat::kR16Uint:
- case ast::type::ImageFormat::kR32Float:
- case ast::type::ImageFormat::kR32Sint:
- case ast::type::ImageFormat::kR32Uint:
- case ast::type::ImageFormat::kR8Sint:
- case ast::type::ImageFormat::kR8Snorm:
- case ast::type::ImageFormat::kR8Uint:
- case ast::type::ImageFormat::kR8Unorm:
+ case type::ImageFormat::kR16Float:
+ case type::ImageFormat::kR16Sint:
+ case type::ImageFormat::kR16Uint:
+ case type::ImageFormat::kR32Float:
+ case type::ImageFormat::kR32Sint:
+ case type::ImageFormat::kR32Uint:
+ case type::ImageFormat::kR8Sint:
+ case type::ImageFormat::kR8Snorm:
+ case type::ImageFormat::kR8Uint:
+ case type::ImageFormat::kR8Unorm:
// One channel
return component_type;
- case ast::type::ImageFormat::kRg11B10Float:
- case ast::type::ImageFormat::kRg16Float:
- case ast::type::ImageFormat::kRg16Sint:
- case ast::type::ImageFormat::kRg16Uint:
- case ast::type::ImageFormat::kRg32Float:
- case ast::type::ImageFormat::kRg32Sint:
- case ast::type::ImageFormat::kRg32Uint:
- case ast::type::ImageFormat::kRg8Sint:
- case ast::type::ImageFormat::kRg8Snorm:
- case ast::type::ImageFormat::kRg8Uint:
- case ast::type::ImageFormat::kRg8Unorm:
+ case type::ImageFormat::kRg11B10Float:
+ case type::ImageFormat::kRg16Float:
+ case type::ImageFormat::kRg16Sint:
+ case type::ImageFormat::kRg16Uint:
+ case type::ImageFormat::kRg32Float:
+ case type::ImageFormat::kRg32Sint:
+ case type::ImageFormat::kRg32Uint:
+ case type::ImageFormat::kRg8Sint:
+ case type::ImageFormat::kRg8Snorm:
+ case type::ImageFormat::kRg8Uint:
+ case type::ImageFormat::kRg8Unorm:
// Two channels
- return ast_module_.create<ast::type::Vector>(component_type, 2);
+ return ast_module_.create<type::Vector>(component_type, 2);
- case ast::type::ImageFormat::kBgra8Unorm:
- case ast::type::ImageFormat::kBgra8UnormSrgb:
- case ast::type::ImageFormat::kRgb10A2Unorm:
- case ast::type::ImageFormat::kRgba16Float:
- case ast::type::ImageFormat::kRgba16Sint:
- case ast::type::ImageFormat::kRgba16Uint:
- case ast::type::ImageFormat::kRgba32Float:
- case ast::type::ImageFormat::kRgba32Sint:
- case ast::type::ImageFormat::kRgba32Uint:
- case ast::type::ImageFormat::kRgba8Sint:
- case ast::type::ImageFormat::kRgba8Snorm:
- case ast::type::ImageFormat::kRgba8Uint:
- case ast::type::ImageFormat::kRgba8Unorm:
- case ast::type::ImageFormat::kRgba8UnormSrgb:
+ case type::ImageFormat::kBgra8Unorm:
+ case type::ImageFormat::kBgra8UnormSrgb:
+ case type::ImageFormat::kRgb10A2Unorm:
+ case type::ImageFormat::kRgba16Float:
+ case type::ImageFormat::kRgba16Sint:
+ case type::ImageFormat::kRgba16Uint:
+ case type::ImageFormat::kRgba32Float:
+ case type::ImageFormat::kRgba32Sint:
+ case type::ImageFormat::kRgba32Uint:
+ case type::ImageFormat::kRgba8Sint:
+ case type::ImageFormat::kRgba8Snorm:
+ case type::ImageFormat::kRgba8Uint:
+ case type::ImageFormat::kRgba8Unorm:
+ case type::ImageFormat::kRgba8UnormSrgb:
// Four channels
- return ast_module_.create<ast::type::Vector>(component_type, 4);
+ return ast_module_.create<type::Vector>(component_type, 4);
default:
break;
diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h
index c832a05..bc85862 100644
--- a/src/reader/spirv/parser_impl.h
+++ b/src/reader/spirv/parser_impl.h
@@ -34,10 +34,6 @@
#include "src/ast/expression.h"
#include "src/ast/module.h"
#include "src/ast/struct_member_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/type.h"
#include "src/reader/reader.h"
#include "src/reader/spirv/entry_point_info.h"
#include "src/reader/spirv/enum_converter.h"
@@ -45,6 +41,10 @@
#include "src/reader/spirv/namer.h"
#include "src/reader/spirv/usage.h"
#include "src/source.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/type.h"
/// This is the implementation of the SPIR-V parser for Tint.
@@ -77,7 +77,7 @@
/// An AST expression with its type.
struct TypedExpression {
/// The type
- ast::type::Type* type = nullptr;
+ type::Type* type = nullptr;
/// The expression
ast::Expression* expr = nullptr;
};
@@ -147,7 +147,7 @@
/// after the internal representation of the module has been built.
/// @param type_id the SPIR-V ID of a type.
/// @returns a Tint type, or nullptr
- ast::type::Type* ConvertType(uint32_t type_id);
+ type::Type* ConvertType(uint32_t type_id);
/// Emits an alias type declaration for the given type, if necessary, and
/// also updates the mapping of the SPIR-V type ID to the alias type.
@@ -298,7 +298,7 @@
/// in the error case
ast::Variable* MakeVariable(uint32_t id,
ast::StorageClass sc,
- ast::type::Type* type,
+ type::Type* type,
bool is_const,
ast::Expression* constructor,
ast::VariableDecorationList decorations);
@@ -311,7 +311,7 @@
/// Creates an AST expression node for the null value for the given type.
/// @param type the AST type
/// @returns a new expression
- ast::Expression* MakeNullValue(ast::type::Type* type);
+ ast::Expression* MakeNullValue(type::Type* type);
/// Converts a given expression to the signedness demanded for an operand
/// of the given SPIR-V instruction, if required. If the instruction assumes
@@ -334,8 +334,8 @@
/// @param inst the SPIR-V instruction
/// @param first_operand_type the AST type for the first operand.
/// @returns the forced AST result type, or nullptr if no forcing is required.
- ast::type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
- ast::type::Type* first_operand_type);
+ type::Type* ForcedResultType(const spvtools::opt::Instruction& inst,
+ type::Type* first_operand_type);
/// Returns a signed integer scalar or vector type matching the shape (scalar,
/// vector, and component bit width) of another type, which itself is a
@@ -343,7 +343,7 @@
/// requirement.
/// @param other the type whose shape must be matched
/// @returns the signed scalar or vector type
- ast::type::Type* GetSignedIntMatchingShape(ast::type::Type* other);
+ type::Type* GetSignedIntMatchingShape(type::Type* other);
/// Returns a signed integer scalar or vector type matching the shape (scalar,
/// vector, and component bit width) of another type, which itself is a
@@ -351,7 +351,7 @@
/// requirement.
/// @param other the type whose shape must be matched
/// @returns the unsigned scalar or vector type
- ast::type::Type* GetUnsignedIntMatchingShape(ast::type::Type* other);
+ type::Type* GetUnsignedIntMatchingShape(type::Type* other);
/// Wraps the given expression in an as-cast to the given expression's type,
/// when the underlying operation produces a forced result type different
@@ -364,10 +364,10 @@
TypedExpression RectifyForcedResultType(
TypedExpression expr,
const spvtools::opt::Instruction& inst,
- ast::type::Type* first_operand_type);
+ type::Type* first_operand_type);
/// @returns the registered boolean type.
- ast::type::Type* Bool() const { return bool_type_; }
+ type::Type* Bool() const { return bool_type_; }
/// Bookkeeping used for tracking the "position" builtin variable.
struct BuiltInPositionInfo {
@@ -455,19 +455,18 @@
/// @param var the OpVariable instruction
/// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on
/// error
- ast::type::Pointer* GetTypeForHandleVar(
- const spvtools::opt::Instruction& var);
+ type::Pointer* GetTypeForHandleVar(const spvtools::opt::Instruction& var);
/// Returns the channel component type corresponding to the given image
/// format.
/// @param format image texel format
/// @returns the component type, one of f32, i32, u32
- ast::type::Type* GetComponentTypeForFormat(ast::type::ImageFormat format);
+ type::Type* GetComponentTypeForFormat(type::ImageFormat format);
/// Returns texel type corresponding to the given image format.
/// @param format image texel format
/// @returns the texel format
- ast::type::Type* GetTexelTypeForFormat(ast::type::ImageFormat format);
+ type::Type* GetTexelTypeForFormat(type::ImageFormat format);
/// Returns the SPIR-V instruction with the given ID, or nullptr.
/// @param id the SPIR-V result ID
@@ -483,20 +482,20 @@
private:
/// Converts a specific SPIR-V type to a Tint type. Integer case
- ast::type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
+ type::Type* ConvertType(const spvtools::opt::analysis::Integer* int_ty);
/// Converts a specific SPIR-V type to a Tint type. Float case
- ast::type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
+ type::Type* ConvertType(const spvtools::opt::analysis::Float* float_ty);
/// Converts a specific SPIR-V type to a Tint type. Vector case
- ast::type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
+ type::Type* ConvertType(const spvtools::opt::analysis::Vector* vec_ty);
/// Converts a specific SPIR-V type to a Tint type. Matrix case
- ast::type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
+ type::Type* ConvertType(const spvtools::opt::analysis::Matrix* mat_ty);
/// Converts a specific SPIR-V type to a Tint type. RuntimeArray case
/// @param rtarr_ty the Tint type
- ast::type::Type* ConvertType(
+ type::Type* ConvertType(
const spvtools::opt::analysis::RuntimeArray* rtarr_ty);
/// Converts a specific SPIR-V type to a Tint type. Array case
/// @param arr_ty the Tint type
- ast::type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
+ type::Type* ConvertType(const spvtools::opt::analysis::Array* arr_ty);
/// Converts a specific SPIR-V type to a Tint type. Struct case.
/// SPIR-V allows distinct struct type definitions for two OpTypeStruct
/// that otherwise have the same set of members (and struct and member
@@ -508,16 +507,15 @@
/// not significant to the optimizer's module representation.
/// @param type_id the SPIR-V ID for the type.
/// @param struct_ty the Tint type
- ast::type::Type* ConvertType(
- uint32_t type_id,
- const spvtools::opt::analysis::Struct* struct_ty);
+ type::Type* ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Struct* struct_ty);
/// Converts a specific SPIR-V type to a Tint type. Pointer case
/// The pointer to gl_PerVertex maps to nullptr, and instead is recorded
/// in member #builtin_position_.
/// @param type_id the SPIR-V ID for the type.
/// @param ptr_ty the Tint type
- ast::type::Type* ConvertType(uint32_t type_id,
- const spvtools::opt::analysis::Pointer* ptr_ty);
+ type::Type* ConvertType(uint32_t type_id,
+ const spvtools::opt::analysis::Pointer* ptr_ty);
/// Parses the array or runtime-array decorations.
/// @param spv_type the SPIR-V array or runtime-array type.
@@ -549,7 +547,7 @@
spvtools::MessageConsumer message_consumer_;
// The registered boolean type.
- ast::type::Type* bool_type_;
+ type::Type* bool_type_;
// An object used to store and generate names for SPIR-V objects.
Namer namer_;
@@ -582,12 +580,12 @@
std::unordered_set<uint32_t> glsl_std_450_imports_;
// Maps a SPIR-V type ID to the corresponding Tint type.
- std::unordered_map<uint32_t, ast::type::Type*> id_to_type_;
+ std::unordered_map<uint32_t, type::Type*> id_to_type_;
// Maps an unsigned type corresponding to the given signed type.
- std::unordered_map<ast::type::Type*, ast::type::Type*> signed_type_for_;
+ std::unordered_map<type::Type*, type::Type*> signed_type_for_;
// Maps an signed type corresponding to the given unsigned type.
- std::unordered_map<ast::type::Type*, ast::type::Type*> unsigned_type_for_;
+ std::unordered_map<type::Type*, type::Type*> unsigned_type_for_;
// Bookkeeping for the gl_Position builtin.
// In Vulkan SPIR-V, it's the 0 member of the gl_PerVertex structure.
@@ -607,7 +605,7 @@
std::unordered_set<uint32_t> remap_buffer_block_type_;
// The struct types with only read-only members.
- std::unordered_set<ast::type::Type*> read_only_struct_types_;
+ std::unordered_set<type::Type*> read_only_struct_types_;
// The IDs of scalar spec constants
std::unordered_set<uint32_t> scalar_spec_constants_;
@@ -632,7 +630,7 @@
// usages implied by usages of the memory-object-declaration.
std::unordered_map<const spvtools::opt::Instruction*, Usage> handle_usage_;
// The inferred pointer type for the given handle variable.
- std::unordered_map<const spvtools::opt::Instruction*, ast::type::Pointer*>
+ std::unordered_map<const spvtools::opt::Instruction*, type::Pointer*>
handle_type_;
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc
index 99bf393..cc871c0 100644
--- a/src/reader/spirv/parser_impl_convert_type_test.cc
+++ b/src/reader/spirv/parser_impl_convert_type_test.cc
@@ -18,20 +18,20 @@
#include "gmock/gmock.h"
#include "src/ast/struct.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/reader/spirv/parser_impl.h"
#include "src/reader/spirv/parser_impl_test_helper.h"
#include "src/reader/spirv/spirv_tools_helpers_test.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -92,7 +92,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::Void>());
+ EXPECT_TRUE(type->Is<type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -101,7 +101,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(100);
- EXPECT_TRUE(type->Is<ast::type::Bool>());
+ EXPECT_TRUE(type->Is<type::Bool>());
EXPECT_TRUE(p->error().empty());
}
@@ -110,7 +110,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(2);
- EXPECT_TRUE(type->Is<ast::type::I32>());
+ EXPECT_TRUE(type->Is<type::I32>());
EXPECT_TRUE(p->error().empty());
}
@@ -119,7 +119,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::U32>());
+ EXPECT_TRUE(type->Is<type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -128,7 +128,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(4);
- EXPECT_TRUE(type->Is<ast::type::F32>());
+ EXPECT_TRUE(type->Is<type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -172,19 +172,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xf32 = p->ConvertType(20);
- EXPECT_TRUE(v2xf32->Is<ast::type::Vector>());
- EXPECT_TRUE(v2xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(v2xf32->As<ast::type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xf32->Is<type::Vector>());
+ EXPECT_TRUE(v2xf32->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(v2xf32->As<type::Vector>()->size(), 2u);
auto* v3xf32 = p->ConvertType(30);
- EXPECT_TRUE(v3xf32->Is<ast::type::Vector>());
- EXPECT_TRUE(v3xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(v3xf32->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xf32->Is<type::Vector>());
+ EXPECT_TRUE(v3xf32->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(v3xf32->As<type::Vector>()->size(), 3u);
auto* v4xf32 = p->ConvertType(40);
- EXPECT_TRUE(v4xf32->Is<ast::type::Vector>());
- EXPECT_TRUE(v4xf32->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(v4xf32->As<ast::type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xf32->Is<type::Vector>());
+ EXPECT_TRUE(v4xf32->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(v4xf32->As<type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -199,19 +199,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xi32 = p->ConvertType(20);
- EXPECT_TRUE(v2xi32->Is<ast::type::Vector>());
- EXPECT_TRUE(v2xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(v2xi32->As<ast::type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xi32->Is<type::Vector>());
+ EXPECT_TRUE(v2xi32->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_EQ(v2xi32->As<type::Vector>()->size(), 2u);
auto* v3xi32 = p->ConvertType(30);
- EXPECT_TRUE(v3xi32->Is<ast::type::Vector>());
- EXPECT_TRUE(v3xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(v3xi32->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xi32->Is<type::Vector>());
+ EXPECT_TRUE(v3xi32->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_EQ(v3xi32->As<type::Vector>()->size(), 3u);
auto* v4xi32 = p->ConvertType(40);
- EXPECT_TRUE(v4xi32->Is<ast::type::Vector>());
- EXPECT_TRUE(v4xi32->As<ast::type::Vector>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(v4xi32->As<ast::type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xi32->Is<type::Vector>());
+ EXPECT_TRUE(v4xi32->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_EQ(v4xi32->As<type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -226,19 +226,19 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* v2xu32 = p->ConvertType(20);
- EXPECT_TRUE(v2xu32->Is<ast::type::Vector>());
- EXPECT_TRUE(v2xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
- EXPECT_EQ(v2xu32->As<ast::type::Vector>()->size(), 2u);
+ EXPECT_TRUE(v2xu32->Is<type::Vector>());
+ EXPECT_TRUE(v2xu32->As<type::Vector>()->type()->Is<type::U32>());
+ EXPECT_EQ(v2xu32->As<type::Vector>()->size(), 2u);
auto* v3xu32 = p->ConvertType(30);
- EXPECT_TRUE(v3xu32->Is<ast::type::Vector>());
- EXPECT_TRUE(v3xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
- EXPECT_EQ(v3xu32->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_TRUE(v3xu32->Is<type::Vector>());
+ EXPECT_TRUE(v3xu32->As<type::Vector>()->type()->Is<type::U32>());
+ EXPECT_EQ(v3xu32->As<type::Vector>()->size(), 3u);
auto* v4xu32 = p->ConvertType(40);
- EXPECT_TRUE(v4xu32->Is<ast::type::Vector>());
- EXPECT_TRUE(v4xu32->As<ast::type::Vector>()->type()->Is<ast::type::U32>());
- EXPECT_EQ(v4xu32->As<ast::type::Vector>()->size(), 4u);
+ EXPECT_TRUE(v4xu32->Is<type::Vector>());
+ EXPECT_TRUE(v4xu32->As<type::Vector>()->type()->Is<type::U32>());
+ EXPECT_EQ(v4xu32->As<type::Vector>()->size(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -278,58 +278,58 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* m22 = p->ConvertType(22);
- EXPECT_TRUE(m22->Is<ast::type::Matrix>());
- EXPECT_TRUE(m22->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m22->As<ast::type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m22->As<ast::type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m22->Is<type::Matrix>());
+ EXPECT_TRUE(m22->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m22->As<type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m22->As<type::Matrix>()->columns(), 2u);
auto* m23 = p->ConvertType(23);
- EXPECT_TRUE(m23->Is<ast::type::Matrix>());
- EXPECT_TRUE(m23->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m23->As<ast::type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m23->As<ast::type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m23->Is<type::Matrix>());
+ EXPECT_TRUE(m23->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m23->As<type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m23->As<type::Matrix>()->columns(), 3u);
auto* m24 = p->ConvertType(24);
- EXPECT_TRUE(m24->Is<ast::type::Matrix>());
- EXPECT_TRUE(m24->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m24->As<ast::type::Matrix>()->rows(), 2u);
- EXPECT_EQ(m24->As<ast::type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m24->Is<type::Matrix>());
+ EXPECT_TRUE(m24->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m24->As<type::Matrix>()->rows(), 2u);
+ EXPECT_EQ(m24->As<type::Matrix>()->columns(), 4u);
auto* m32 = p->ConvertType(32);
- EXPECT_TRUE(m32->Is<ast::type::Matrix>());
- EXPECT_TRUE(m32->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m32->As<ast::type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m32->As<ast::type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m32->Is<type::Matrix>());
+ EXPECT_TRUE(m32->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m32->As<type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m32->As<type::Matrix>()->columns(), 2u);
auto* m33 = p->ConvertType(33);
- EXPECT_TRUE(m33->Is<ast::type::Matrix>());
- EXPECT_TRUE(m33->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m33->As<ast::type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m33->As<ast::type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m33->Is<type::Matrix>());
+ EXPECT_TRUE(m33->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m33->As<type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m33->As<type::Matrix>()->columns(), 3u);
auto* m34 = p->ConvertType(34);
- EXPECT_TRUE(m34->Is<ast::type::Matrix>());
- EXPECT_TRUE(m34->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m34->As<ast::type::Matrix>()->rows(), 3u);
- EXPECT_EQ(m34->As<ast::type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m34->Is<type::Matrix>());
+ EXPECT_TRUE(m34->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m34->As<type::Matrix>()->rows(), 3u);
+ EXPECT_EQ(m34->As<type::Matrix>()->columns(), 4u);
auto* m42 = p->ConvertType(42);
- EXPECT_TRUE(m42->Is<ast::type::Matrix>());
- EXPECT_TRUE(m42->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m42->As<ast::type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m42->As<ast::type::Matrix>()->columns(), 2u);
+ EXPECT_TRUE(m42->Is<type::Matrix>());
+ EXPECT_TRUE(m42->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m42->As<type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m42->As<type::Matrix>()->columns(), 2u);
auto* m43 = p->ConvertType(43);
- EXPECT_TRUE(m43->Is<ast::type::Matrix>());
- EXPECT_TRUE(m43->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m43->As<ast::type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m43->As<ast::type::Matrix>()->columns(), 3u);
+ EXPECT_TRUE(m43->Is<type::Matrix>());
+ EXPECT_TRUE(m43->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m43->As<type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m43->As<type::Matrix>()->columns(), 3u);
auto* m44 = p->ConvertType(44);
- EXPECT_TRUE(m44->Is<ast::type::Matrix>());
- EXPECT_TRUE(m44->As<ast::type::Matrix>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(m44->As<ast::type::Matrix>()->rows(), 4u);
- EXPECT_EQ(m44->As<ast::type::Matrix>()->columns(), 4u);
+ EXPECT_TRUE(m44->Is<type::Matrix>());
+ EXPECT_TRUE(m44->As<type::Matrix>()->type()->Is<type::F32>());
+ EXPECT_EQ(m44->As<type::Matrix>()->rows(), 4u);
+ EXPECT_EQ(m44->As<type::Matrix>()->columns(), 4u);
EXPECT_TRUE(p->error().empty());
}
@@ -343,8 +343,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Array>());
- auto* arr_type = type->As<ast::type::Array>();
+ EXPECT_TRUE(type->Is<type::Array>());
+ auto* arr_type = type->As<type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 0u);
@@ -352,7 +352,7 @@
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<ast::type::U32>());
+ EXPECT_TRUE(elem_type->Is<type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -379,7 +379,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- auto* arr_type = type->As<ast::type::Array>();
+ auto* arr_type = type->As<type::Array>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->array_stride(), 64u);
@@ -425,8 +425,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Array>());
- auto* arr_type = type->As<ast::type::Array>();
+ EXPECT_TRUE(type->Is<type::Array>());
+ auto* arr_type = type->As<type::Array>();
EXPECT_FALSE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 42u);
@@ -434,7 +434,7 @@
EXPECT_FALSE(arr_type->has_array_stride());
auto* elem_type = arr_type->type();
ASSERT_NE(elem_type, nullptr);
- EXPECT_TRUE(elem_type->Is<ast::type::U32>());
+ EXPECT_TRUE(elem_type->Is<type::U32>());
EXPECT_TRUE(p->error().empty());
}
@@ -513,8 +513,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Array>());
- auto* arr_type = type->As<ast::type::Array>();
+ EXPECT_TRUE(type->Is<type::Array>());
+ auto* arr_type = type->As<type::Array>();
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->array_stride(), 8u);
EXPECT_TRUE(arr_type->has_array_stride());
@@ -563,9 +563,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Struct>());
+ EXPECT_TRUE(type->Is<type::Struct>());
std::stringstream ss;
- type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
+ type->As<type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
StructMember{field0: __u32}
StructMember{field1: __f32}
@@ -584,9 +584,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Struct>());
+ EXPECT_TRUE(type->Is<type::Struct>());
std::stringstream ss;
- type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
+ type->As<type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
[[block]]
StructMember{field0: __u32}
@@ -609,9 +609,9 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Struct>());
+ EXPECT_TRUE(type->Is<type::Struct>());
std::stringstream ss;
- type->As<ast::type::Struct>()->impl()->to_str(ss, 0);
+ type->As<type::Struct>()->impl()->to_str(ss, 0);
EXPECT_THAT(Demangler().Demangle(p->get_module(), ss.str()), Eq(R"(Struct{
StructMember{[[ offset 0 ]] field0: __f32}
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
@@ -658,10 +658,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
EXPECT_TRUE(p->error().empty());
}
@@ -674,10 +674,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput);
EXPECT_TRUE(p->error().empty());
}
@@ -690,10 +690,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform);
EXPECT_TRUE(p->error().empty());
}
@@ -706,10 +706,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(p->error().empty());
}
@@ -722,10 +722,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant);
EXPECT_TRUE(p->error().empty());
}
@@ -738,10 +738,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorage);
EXPECT_TRUE(p->error().empty());
}
@@ -754,10 +754,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage);
EXPECT_TRUE(p->error().empty());
}
@@ -770,10 +770,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate);
EXPECT_TRUE(p->error().empty());
}
@@ -786,10 +786,10 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(3);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ EXPECT_TRUE(type->Is<type::Pointer>());
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::F32>());
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction);
EXPECT_TRUE(p->error().empty());
}
@@ -805,17 +805,17 @@
auto* type = p->ConvertType(3);
EXPECT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<ast::type::Pointer>());
+ EXPECT_TRUE(type->Is<type::Pointer>());
- auto* ptr_ty = type->As<ast::type::Pointer>();
+ auto* ptr_ty = type->As<type::Pointer>();
EXPECT_NE(ptr_ty, nullptr);
EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput);
- EXPECT_TRUE(ptr_ty->type()->Is<ast::type::Pointer>());
+ EXPECT_TRUE(ptr_ty->type()->Is<type::Pointer>());
- auto* ptr_ptr_ty = ptr_ty->type()->As<ast::type::Pointer>();
+ auto* ptr_ptr_ty = ptr_ty->type()->As<type::Pointer>();
EXPECT_NE(ptr_ptr_ty, nullptr);
EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput);
- EXPECT_TRUE(ptr_ptr_ty->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ptr_ptr_ty->type()->Is<type::F32>());
EXPECT_TRUE(p->error().empty());
}
@@ -828,7 +828,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::Void>());
+ EXPECT_TRUE(type->Is<type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -841,7 +841,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::Void>());
+ EXPECT_TRUE(type->Is<type::Void>());
EXPECT_TRUE(p->error().empty());
}
@@ -854,7 +854,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(1);
- EXPECT_TRUE(type->Is<ast::type::Void>());
+ EXPECT_TRUE(type->Is<type::Void>());
EXPECT_TRUE(p->error().empty());
}
diff --git a/src/reader/spirv/parser_impl_named_types_test.cc b/src/reader/spirv/parser_impl_named_types_test.cc
index 26a3e3c..13f9af9 100644
--- a/src/reader/spirv/parser_impl_named_types_test.cc
+++ b/src/reader/spirv/parser_impl_named_types_test.cc
@@ -18,10 +18,10 @@
#include "gmock/gmock.h"
#include "src/ast/struct.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/array_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/demangler.h"
#include "src/reader/spirv/parser_impl.h"
#include "src/reader/spirv/parser_impl_test_helper.h"
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 264f23f..3d56aaf 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -45,22 +45,6 @@
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/type_decoration.h"
#include "src/ast/uint_literal.h"
@@ -70,6 +54,22 @@
#include "src/ast/variable_decl_statement.h"
#include "src/ast/workgroup_decoration.h"
#include "src/reader/wgsl/lexer.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -196,7 +196,7 @@
ParserImpl::FunctionHeader::FunctionHeader(Source src,
std::string n,
ast::VariableList p,
- ast::type::Type* ret_ty)
+ type::Type* ret_ty)
: source(src), name(n), params(p), return_type(ret_ty) {}
ParserImpl::FunctionHeader::~FunctionHeader() = default;
@@ -260,12 +260,12 @@
}
void ParserImpl::register_constructed(const std::string& name,
- ast::type::Type* type) {
+ type::Type* type) {
assert(type);
registered_constructs_[name] = type;
}
-ast::type::Type* ParserImpl::get_constructed(const std::string& name) {
+type::Type* ParserImpl::get_constructed(const std::string& name) {
if (registered_constructs_.find(name) == registered_constructs_.end()) {
return nullptr;
}
@@ -361,7 +361,7 @@
auto* type = module_.unique_type(std::move(str.value));
register_constructed(
- module_.SymbolToName(type->As<ast::type::Struct>()->symbol()), type);
+ module_.SymbolToName(type->As<type::Struct>()->symbol()), type);
module_.AddConstructedType(type);
return true;
}
@@ -497,7 +497,7 @@
// | sampled_texture_type LESS_THAN type_decl GREATER_THAN
// | multisampled_texture_type LESS_THAN type_decl GREATER_THAN
// | storage_texture_type LESS_THAN image_storage_type GREATER_THAN
-Maybe<ast::type::Type*> ParserImpl::texture_sampler_types() {
+Maybe<type::Type*> ParserImpl::texture_sampler_types() {
auto type = sampler_type();
if (type.matched)
return type;
@@ -514,7 +514,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::SampledTexture>(dim.value, subtype.value);
+ return module_.create<type::SampledTexture>(dim.value, subtype.value);
}
auto ms_dim = multisampled_texture_type();
@@ -525,8 +525,8 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::MultisampledTexture>(ms_dim.value,
- subtype.value);
+ return module_.create<type::MultisampledTexture>(ms_dim.value,
+ subtype.value);
}
auto storage = storage_texture_type();
@@ -539,8 +539,7 @@
if (format.errored)
return Failure::kErrored;
- return module_.create<ast::type::StorageTexture>(storage.value,
- format.value);
+ return module_.create<type::StorageTexture>(storage.value, format.value);
}
// DEPRECATED
@@ -554,9 +553,9 @@
if (format.errored)
return Failure::kErrored;
- return module_.create<ast::type::AccessControl>(
- ac_storage->second, module_.create<ast::type::StorageTexture>(
- ac_storage->first, format.value));
+ return module_.create<type::AccessControl>(
+ ac_storage->second,
+ module_.create<type::StorageTexture>(ac_storage->first, format.value));
}
return Failure::kNoMatch;
@@ -565,13 +564,12 @@
// sampler_type
// : SAMPLER
// | SAMPLER_COMPARISON
-Maybe<ast::type::Type*> ParserImpl::sampler_type() {
+Maybe<type::Type*> ParserImpl::sampler_type() {
if (match(Token::Type::kSampler))
- return module_.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
+ return module_.create<type::Sampler>(type::SamplerKind::kSampler);
if (match(Token::Type::kComparisonSampler))
- return module_.create<ast::type::Sampler>(
- ast::type::SamplerKind::kComparisonSampler);
+ return module_.create<type::Sampler>(type::SamplerKind::kComparisonSampler);
return Failure::kNoMatch;
}
@@ -584,36 +582,36 @@
// | TEXTURE_SAMPLED_3D
// | TEXTURE_SAMPLED_CUBE
// | TEXTURE_SAMPLED_CUBE_ARRAY
-Maybe<ast::type::TextureDimension> ParserImpl::sampled_texture_type() {
+Maybe<type::TextureDimension> ParserImpl::sampled_texture_type() {
if (match(Token::Type::kTextureSampled1d))
- return ast::type::TextureDimension::k1d;
+ return type::TextureDimension::k1d;
if (match(Token::Type::kTextureSampled1dArray))
- return ast::type::TextureDimension::k1dArray;
+ return type::TextureDimension::k1dArray;
if (match(Token::Type::kTextureSampled2d))
- return ast::type::TextureDimension::k2d;
+ return type::TextureDimension::k2d;
if (match(Token::Type::kTextureSampled2dArray))
- return ast::type::TextureDimension::k2dArray;
+ return type::TextureDimension::k2dArray;
if (match(Token::Type::kTextureSampled3d))
- return ast::type::TextureDimension::k3d;
+ return type::TextureDimension::k3d;
if (match(Token::Type::kTextureSampledCube))
- return ast::type::TextureDimension::kCube;
+ return type::TextureDimension::kCube;
if (match(Token::Type::kTextureSampledCubeArray))
- return ast::type::TextureDimension::kCubeArray;
+ return type::TextureDimension::kCubeArray;
return Failure::kNoMatch;
}
// multisampled_texture_type
// : TEXTURE_MULTISAMPLED_2D
-Maybe<ast::type::TextureDimension> ParserImpl::multisampled_texture_type() {
+Maybe<type::TextureDimension> ParserImpl::multisampled_texture_type() {
if (match(Token::Type::kTextureMultisampled2d))
- return ast::type::TextureDimension::k2d;
+ return type::TextureDimension::k2d;
return Failure::kNoMatch;
}
@@ -624,17 +622,17 @@
// | TEXTURE_STORAGE_2D
// | TEXTURE_STORAGE_2D_ARRAY
// | TEXTURE_STORAGE_3D
-Maybe<ast::type::TextureDimension> ParserImpl::storage_texture_type() {
+Maybe<type::TextureDimension> ParserImpl::storage_texture_type() {
if (match(Token::Type::kTextureStorage1d))
- return ast::type::TextureDimension::k1d;
+ return type::TextureDimension::k1d;
if (match(Token::Type::kTextureStorage1dArray))
- return ast::type::TextureDimension::k1dArray;
+ return type::TextureDimension::k1dArray;
if (match(Token::Type::kTextureStorage2d))
- return ast::type::TextureDimension::k2d;
+ return type::TextureDimension::k2d;
if (match(Token::Type::kTextureStorage2dArray))
- return ast::type::TextureDimension::k2dArray;
+ return type::TextureDimension::k2dArray;
if (match(Token::Type::kTextureStorage3d))
- return ast::type::TextureDimension::k3d;
+ return type::TextureDimension::k3d;
return Failure::kNoMatch;
}
@@ -661,54 +659,49 @@
// | TEXTURE_STORAGE_WO_2D
// | TEXTURE_STORAGE_WO_2D_ARRAY
// | TEXTURE_STORAGE_WO_3D
-Maybe<std::pair<ast::type::TextureDimension, ast::AccessControl>>
+Maybe<std::pair<type::TextureDimension, ast::AccessControl>>
ParserImpl::storage_texture_type_access_control() {
- using Ret = std::pair<ast::type::TextureDimension, ast::AccessControl>;
+ using Ret = std::pair<type::TextureDimension, ast::AccessControl>;
if (match(Token::Type::kTextureStorageReadonly1d)) {
- return Ret{ast::type::TextureDimension::k1d, ast::AccessControl::kReadOnly};
+ return Ret{type::TextureDimension::k1d, ast::AccessControl::kReadOnly};
}
if (match(Token::Type::kTextureStorageReadonly1dArray)) {
- return Ret{ast::type::TextureDimension::k1dArray,
- ast::AccessControl::kReadOnly};
+ return Ret{type::TextureDimension::k1dArray, ast::AccessControl::kReadOnly};
}
if (match(Token::Type::kTextureStorageReadonly2d)) {
- return Ret{ast::type::TextureDimension::k2d, ast::AccessControl::kReadOnly};
+ return Ret{type::TextureDimension::k2d, ast::AccessControl::kReadOnly};
}
if (match(Token::Type::kTextureStorageReadonly2dArray)) {
- return Ret{ast::type::TextureDimension::k2dArray,
- ast::AccessControl::kReadOnly};
+ return Ret{type::TextureDimension::k2dArray, ast::AccessControl::kReadOnly};
}
if (match(Token::Type::kTextureStorageReadonly3d)) {
- return Ret{ast::type::TextureDimension::k3d, ast::AccessControl::kReadOnly};
+ return Ret{type::TextureDimension::k3d, ast::AccessControl::kReadOnly};
}
if (match(Token::Type::kTextureStorageWriteonly1d)) {
- return Ret{ast::type::TextureDimension::k1d,
- ast::AccessControl::kWriteOnly};
+ return Ret{type::TextureDimension::k1d, ast::AccessControl::kWriteOnly};
}
if (match(Token::Type::kTextureStorageWriteonly1dArray)) {
- return Ret{ast::type::TextureDimension::k1dArray,
+ return Ret{type::TextureDimension::k1dArray,
ast::AccessControl::kWriteOnly};
}
if (match(Token::Type::kTextureStorageWriteonly2d)) {
- return Ret{ast::type::TextureDimension::k2d,
- ast::AccessControl::kWriteOnly};
+ return Ret{type::TextureDimension::k2d, ast::AccessControl::kWriteOnly};
}
if (match(Token::Type::kTextureStorageWriteonly2dArray)) {
- return Ret{ast::type::TextureDimension::k2dArray,
+ return Ret{type::TextureDimension::k2dArray,
ast::AccessControl::kWriteOnly};
}
if (match(Token::Type::kTextureStorageWriteonly3d)) {
- return Ret{ast::type::TextureDimension::k3d,
- ast::AccessControl::kWriteOnly};
+ return Ret{type::TextureDimension::k3d, ast::AccessControl::kWriteOnly};
}
return Failure::kNoMatch;
@@ -719,22 +712,19 @@
// | TEXTURE_DEPTH_2D_ARRAY
// | TEXTURE_DEPTH_CUBE
// | TEXTURE_DEPTH_CUBE_ARRAY
-Maybe<ast::type::Type*> ParserImpl::depth_texture_type() {
+Maybe<type::Type*> ParserImpl::depth_texture_type() {
if (match(Token::Type::kTextureDepth2d))
- return module_.create<ast::type::DepthTexture>(
- ast::type::TextureDimension::k2d);
+ return module_.create<type::DepthTexture>(type::TextureDimension::k2d);
if (match(Token::Type::kTextureDepth2dArray))
- return module_.create<ast::type::DepthTexture>(
- ast::type::TextureDimension::k2dArray);
+ return module_.create<type::DepthTexture>(type::TextureDimension::k2dArray);
if (match(Token::Type::kTextureDepthCube))
- return module_.create<ast::type::DepthTexture>(
- ast::type::TextureDimension::kCube);
+ return module_.create<type::DepthTexture>(type::TextureDimension::kCube);
if (match(Token::Type::kTextureDepthCubeArray))
- return module_.create<ast::type::DepthTexture>(
- ast::type::TextureDimension::kCubeArray);
+ return module_.create<type::DepthTexture>(
+ type::TextureDimension::kCubeArray);
return Failure::kNoMatch;
}
@@ -775,112 +765,112 @@
// | RGBA32UINT
// | RGBA32SINT
// | RGBA32FLOAT
-Expect<ast::type::ImageFormat> ParserImpl::expect_image_storage_type(
+Expect<type::ImageFormat> ParserImpl::expect_image_storage_type(
const std::string& use) {
if (match(Token::Type::kFormatR8Unorm))
- return ast::type::ImageFormat::kR8Unorm;
+ return type::ImageFormat::kR8Unorm;
if (match(Token::Type::kFormatR8Snorm))
- return ast::type::ImageFormat::kR8Snorm;
+ return type::ImageFormat::kR8Snorm;
if (match(Token::Type::kFormatR8Uint))
- return ast::type::ImageFormat::kR8Uint;
+ return type::ImageFormat::kR8Uint;
if (match(Token::Type::kFormatR8Sint))
- return ast::type::ImageFormat::kR8Sint;
+ return type::ImageFormat::kR8Sint;
if (match(Token::Type::kFormatR16Uint))
- return ast::type::ImageFormat::kR16Uint;
+ return type::ImageFormat::kR16Uint;
if (match(Token::Type::kFormatR16Sint))
- return ast::type::ImageFormat::kR16Sint;
+ return type::ImageFormat::kR16Sint;
if (match(Token::Type::kFormatR16Float))
- return ast::type::ImageFormat::kR16Float;
+ return type::ImageFormat::kR16Float;
if (match(Token::Type::kFormatRg8Unorm))
- return ast::type::ImageFormat::kRg8Unorm;
+ return type::ImageFormat::kRg8Unorm;
if (match(Token::Type::kFormatRg8Snorm))
- return ast::type::ImageFormat::kRg8Snorm;
+ return type::ImageFormat::kRg8Snorm;
if (match(Token::Type::kFormatRg8Uint))
- return ast::type::ImageFormat::kRg8Uint;
+ return type::ImageFormat::kRg8Uint;
if (match(Token::Type::kFormatRg8Sint))
- return ast::type::ImageFormat::kRg8Sint;
+ return type::ImageFormat::kRg8Sint;
if (match(Token::Type::kFormatR32Uint))
- return ast::type::ImageFormat::kR32Uint;
+ return type::ImageFormat::kR32Uint;
if (match(Token::Type::kFormatR32Sint))
- return ast::type::ImageFormat::kR32Sint;
+ return type::ImageFormat::kR32Sint;
if (match(Token::Type::kFormatR32Float))
- return ast::type::ImageFormat::kR32Float;
+ return type::ImageFormat::kR32Float;
if (match(Token::Type::kFormatRg16Uint))
- return ast::type::ImageFormat::kRg16Uint;
+ return type::ImageFormat::kRg16Uint;
if (match(Token::Type::kFormatRg16Sint))
- return ast::type::ImageFormat::kRg16Sint;
+ return type::ImageFormat::kRg16Sint;
if (match(Token::Type::kFormatRg16Float))
- return ast::type::ImageFormat::kRg16Float;
+ return type::ImageFormat::kRg16Float;
if (match(Token::Type::kFormatRgba8Unorm))
- return ast::type::ImageFormat::kRgba8Unorm;
+ return type::ImageFormat::kRgba8Unorm;
if (match(Token::Type::kFormatRgba8UnormSrgb))
- return ast::type::ImageFormat::kRgba8UnormSrgb;
+ return type::ImageFormat::kRgba8UnormSrgb;
if (match(Token::Type::kFormatRgba8Snorm))
- return ast::type::ImageFormat::kRgba8Snorm;
+ return type::ImageFormat::kRgba8Snorm;
if (match(Token::Type::kFormatRgba8Uint))
- return ast::type::ImageFormat::kRgba8Uint;
+ return type::ImageFormat::kRgba8Uint;
if (match(Token::Type::kFormatRgba8Sint))
- return ast::type::ImageFormat::kRgba8Sint;
+ return type::ImageFormat::kRgba8Sint;
if (match(Token::Type::kFormatBgra8Unorm))
- return ast::type::ImageFormat::kBgra8Unorm;
+ return type::ImageFormat::kBgra8Unorm;
if (match(Token::Type::kFormatBgra8UnormSrgb))
- return ast::type::ImageFormat::kBgra8UnormSrgb;
+ return type::ImageFormat::kBgra8UnormSrgb;
if (match(Token::Type::kFormatRgb10A2Unorm))
- return ast::type::ImageFormat::kRgb10A2Unorm;
+ return type::ImageFormat::kRgb10A2Unorm;
if (match(Token::Type::kFormatRg11B10Float))
- return ast::type::ImageFormat::kRg11B10Float;
+ return type::ImageFormat::kRg11B10Float;
if (match(Token::Type::kFormatRg32Uint))
- return ast::type::ImageFormat::kRg32Uint;
+ return type::ImageFormat::kRg32Uint;
if (match(Token::Type::kFormatRg32Sint))
- return ast::type::ImageFormat::kRg32Sint;
+ return type::ImageFormat::kRg32Sint;
if (match(Token::Type::kFormatRg32Float))
- return ast::type::ImageFormat::kRg32Float;
+ return type::ImageFormat::kRg32Float;
if (match(Token::Type::kFormatRgba16Uint))
- return ast::type::ImageFormat::kRgba16Uint;
+ return type::ImageFormat::kRgba16Uint;
if (match(Token::Type::kFormatRgba16Sint))
- return ast::type::ImageFormat::kRgba16Sint;
+ return type::ImageFormat::kRgba16Sint;
if (match(Token::Type::kFormatRgba16Float))
- return ast::type::ImageFormat::kRgba16Float;
+ return type::ImageFormat::kRgba16Float;
if (match(Token::Type::kFormatRgba32Uint))
- return ast::type::ImageFormat::kRgba32Uint;
+ return type::ImageFormat::kRgba32Uint;
if (match(Token::Type::kFormatRgba32Sint))
- return ast::type::ImageFormat::kRgba32Sint;
+ return type::ImageFormat::kRgba32Sint;
if (match(Token::Type::kFormatRgba32Float))
- return ast::type::ImageFormat::kRgba32Float;
+ return type::ImageFormat::kRgba32Float;
return add_error(peek().source(), "invalid format", use);
}
@@ -919,7 +909,7 @@
for (auto* deco : access_decos) {
// If we have an access control decoration then we take it and wrap our
// type up with that decoration
- ty = module_.create<ast::type::AccessControl>(
+ ty = module_.create<type::AccessControl>(
deco->As<ast::AccessDecoration>()->value(), ty);
}
@@ -959,7 +949,7 @@
// type_alias
// : TYPE IDENT EQUAL type_decl
-Maybe<ast::type::Type*> ParserImpl::type_alias() {
+Maybe<type::Type*> ParserImpl::type_alias() {
auto t = peek();
if (!t.IsType())
return Failure::kNoMatch;
@@ -981,8 +971,8 @@
if (!type.matched)
return add_error(peek(), "invalid type alias");
- auto* alias = module_.create<ast::type::Alias>(
- module_.RegisterSymbol(name.value), type.value);
+ auto* alias = module_.create<type::Alias>(module_.RegisterSymbol(name.value),
+ type.value);
register_constructed(name.value, alias);
return alias;
@@ -1012,7 +1002,7 @@
// | MAT4x3 LESS_THAN type_decl GREATER_THAN
// | MAT4x4 LESS_THAN type_decl GREATER_THAN
// | texture_sampler_types
-Maybe<ast::type::Type*> ParserImpl::type_decl() {
+Maybe<type::Type*> ParserImpl::type_decl() {
auto decos = decoration_list();
if (decos.errored)
return Failure::kErrored;
@@ -1029,7 +1019,7 @@
return type.value;
}
-Maybe<ast::type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
+Maybe<type::Type*> ParserImpl::type_decl(ast::DecorationList& decos) {
auto t = peek();
if (match(Token::Type::kIdentifier)) {
auto* ty = get_constructed(t.to_str());
@@ -1040,16 +1030,16 @@
}
if (match(Token::Type::kBool))
- return module_.create<ast::type::Bool>();
+ return module_.create<type::Bool>();
if (match(Token::Type::kF32))
- return module_.create<ast::type::F32>();
+ return module_.create<type::F32>();
if (match(Token::Type::kI32))
- return module_.create<ast::type::I32>();
+ return module_.create<type::I32>();
if (match(Token::Type::kU32))
- return module_.create<ast::type::U32>();
+ return module_.create<type::U32>();
if (t.IsVec2() || t.IsVec3() || t.IsVec4()) {
next(); // Consume the peek
@@ -1083,7 +1073,7 @@
return Failure::kNoMatch;
}
-Expect<ast::type::Type*> ParserImpl::expect_type(const std::string& use) {
+Expect<type::Type*> ParserImpl::expect_type(const std::string& use) {
auto type = type_decl();
if (type.errored)
return Failure::kErrored;
@@ -1092,10 +1082,10 @@
return type.value;
}
-Expect<ast::type::Type*> ParserImpl::expect_type_decl_pointer() {
+Expect<type::Type*> ParserImpl::expect_type_decl_pointer() {
const char* use = "ptr declaration";
- return expect_lt_gt_block(use, [&]() -> Expect<ast::type::Type*> {
+ return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
auto sc = expect_storage_class(use);
if (sc.errored)
return Failure::kErrored;
@@ -1107,11 +1097,11 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::Pointer>(subtype.value, sc.value);
+ return module_.create<type::Pointer>(subtype.value, sc.value);
});
}
-Expect<ast::type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
+Expect<type::Type*> ParserImpl::expect_type_decl_vector(Token t) {
uint32_t count = 2;
if (t.IsVec3())
count = 3;
@@ -1124,14 +1114,14 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::Vector>(subtype.value, count);
+ return module_.create<type::Vector>(subtype.value, count);
}
-Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
+Expect<type::Type*> ParserImpl::expect_type_decl_array(
ast::ArrayDecorationList decos) {
const char* use = "array declaration";
- return expect_lt_gt_block(use, [&]() -> Expect<ast::type::Type*> {
+ return expect_lt_gt_block(use, [&]() -> Expect<type::Type*> {
auto subtype = expect_type(use);
if (subtype.errored)
return Failure::kErrored;
@@ -1144,11 +1134,11 @@
size = val.value;
}
- return create<ast::type::Array>(subtype.value, size, std::move(decos));
+ return create<type::Array>(subtype.value, size, std::move(decos));
});
}
-Expect<ast::type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
+Expect<type::Type*> ParserImpl::expect_type_decl_matrix(Token t) {
uint32_t rows = 2;
uint32_t columns = 2;
if (t.IsMat3x2() || t.IsMat3x3() || t.IsMat3x4()) {
@@ -1168,7 +1158,7 @@
if (subtype.errored)
return Failure::kErrored;
- return module_.create<ast::type::Matrix>(subtype.value, rows, columns);
+ return module_.create<type::Matrix>(subtype.value, rows, columns);
}
// storage_class
@@ -1215,7 +1205,7 @@
// struct_decl
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
-Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
+Maybe<std::unique_ptr<type::Struct>> ParserImpl::struct_decl(
ast::DecorationList& decos) {
auto t = peek();
auto source = t.source();
@@ -1235,7 +1225,7 @@
if (struct_decos.errored)
return Failure::kErrored;
- return std::make_unique<ast::type::Struct>(
+ return std::make_unique<type::Struct>(
module_.RegisterSymbol(name.value),
create<ast::Struct>(source, std::move(body.value),
std::move(struct_decos.value)));
@@ -1335,9 +1325,9 @@
// function_type_decl
// : type_decl
// | VOID
-Maybe<ast::type::Type*> ParserImpl::function_type_decl() {
+Maybe<type::Type*> ParserImpl::function_type_decl() {
if (match(Token::Type::kVoid))
- return module_.create<ast::type::Void>();
+ return module_.create<type::Void>();
return type_decl();
}
@@ -2749,19 +2739,19 @@
Maybe<ast::Literal*> ParserImpl::const_literal() {
auto t = peek();
if (match(Token::Type::kTrue)) {
- auto* type = module_.create<ast::type::Bool>();
+ auto* type = module_.create<type::Bool>();
return create<ast::BoolLiteral>(Source{}, type, true);
}
if (match(Token::Type::kFalse)) {
- auto* type = module_.create<ast::type::Bool>();
+ auto* type = module_.create<type::Bool>();
return create<ast::BoolLiteral>(Source{}, type, false);
}
if (match(Token::Type::kSintLiteral)) {
- auto* type = module_.create<ast::type::I32>();
+ auto* type = module_.create<type::I32>();
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
}
if (match(Token::Type::kUintLiteral)) {
- auto* type = module_.create<ast::type::U32>();
+ auto* type = module_.create<type::U32>();
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
}
if (match(Token::Type::kFloatLiteral)) {
@@ -2770,7 +2760,7 @@
next(); // Consume 'f'
add_error(p.source(), "float literals must not be suffixed with 'f'");
}
- auto* type = module_.create<ast::type::F32>();
+ auto* type = module_.create<type::F32>();
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
}
return Failure::kNoMatch;
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 385e890..d4d6a4d 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -48,10 +48,6 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/variable_decoration.h"
@@ -59,6 +55,10 @@
#include "src/diagnostic/formatter.h"
#include "src/reader/wgsl/parser_impl_detail.h"
#include "src/reader/wgsl/token.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/type.h"
namespace tint {
namespace reader {
@@ -222,7 +222,7 @@
/// variable_ident_decl().
struct TypedIdentifier {
/// Parsed type.
- ast::type::Type* type = nullptr;
+ type::Type* type = nullptr;
/// Parsed identifier.
std::string name;
/// Source to the identifier.
@@ -244,7 +244,7 @@
FunctionHeader(Source src,
std::string n,
ast::VariableList p,
- ast::type::Type* ret_ty);
+ type::Type* ret_ty);
/// Destructor
~FunctionHeader();
/// Assignment operator
@@ -259,7 +259,7 @@
/// Function parameters
ast::VariableList params;
/// Function return type
- ast::type::Type* return_type;
+ type::Type* return_type;
};
/// VarDeclInfo contains the parsed information for variable declaration.
@@ -271,7 +271,7 @@
/// Variable storage class
ast::StorageClass storage_class;
/// Variable type
- ast::type::Type* type;
+ type::Type* type;
};
/// Creates a new parser using the given file
@@ -348,11 +348,11 @@
/// Registers a constructed type into the parser
/// @param name the constructed name
/// @param type the constructed type
- void register_constructed(const std::string& name, ast::type::Type* type);
+ void register_constructed(const std::string& name, type::Type* type);
/// Retrieves a constructed type
/// @param name The name to lookup
/// @returns the constructed type for `name` or `nullptr` if not found
- ast::type::Type* get_constructed(const std::string& name);
+ type::Type* get_constructed(const std::string& name);
/// Parses the `translation_unit` grammar element
void translation_unit();
@@ -380,15 +380,15 @@
Maybe<ast::StorageClass> variable_storage_decoration();
/// Parses a `type_alias` grammar element
/// @returns the type alias or nullptr on error
- Maybe<ast::type::Type*> type_alias();
+ Maybe<type::Type*> type_alias();
/// Parses a `type_decl` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<ast::type::Type*> type_decl();
+ Maybe<type::Type*> type_decl();
/// Parses a `type_decl` grammar element with the given pre-parsed
/// decorations.
/// @param decos the list of decorations for the type.
/// @returns the parsed Type or nullptr if none matched.
- Maybe<ast::type::Type*> type_decl(ast::DecorationList& decos);
+ Maybe<type::Type*> type_decl(ast::DecorationList& decos);
/// Parses a `storage_class` grammar element, erroring on parse failure.
/// @param use a description of what was being parsed if an error was raised.
/// @returns the storage class or StorageClass::kNone if none matched
@@ -397,8 +397,7 @@
/// `struct_decoration_decl*` provided as `decos`.
/// @returns the struct type or nullptr on error
/// @param decos the list of decorations for the struct declaration.
- Maybe<std::unique_ptr<ast::type::Struct>> struct_decl(
- ast::DecorationList& decos);
+ Maybe<std::unique_ptr<type::Struct>> struct_decl(ast::DecorationList& decos);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members
Expect<ast::StructMemberList> expect_struct_body_decl();
@@ -415,37 +414,36 @@
Maybe<ast::Function*> function_decl(ast::DecorationList& decos);
/// Parses a `texture_sampler_types` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<ast::type::Type*> texture_sampler_types();
+ Maybe<type::Type*> texture_sampler_types();
/// Parses a `sampler_type` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<ast::type::Type*> sampler_type();
+ Maybe<type::Type*> sampler_type();
/// Parses a `multisampled_texture_type` grammar element
/// @returns returns the multisample texture dimension or kNone if none
/// matched.
- Maybe<ast::type::TextureDimension> multisampled_texture_type();
+ Maybe<type::TextureDimension> multisampled_texture_type();
/// Parses a `sampled_texture_type` grammar element
/// @returns returns the sample texture dimension or kNone if none matched.
- Maybe<ast::type::TextureDimension> sampled_texture_type();
+ Maybe<type::TextureDimension> sampled_texture_type();
/// Parses a `storage_texture_type` grammar element
/// @returns returns the storage texture dimension.
/// Returns kNone if none matched.
- Maybe<ast::type::TextureDimension> storage_texture_type();
+ Maybe<type::TextureDimension> storage_texture_type();
/// Parses a deprecated `storage_texture_type` grammar element
/// @returns returns the storage texture dimension and the storage access.
/// Returns kNone and kRead if none matched.
- Maybe<std::pair<ast::type::TextureDimension, ast::AccessControl>>
+ Maybe<std::pair<type::TextureDimension, ast::AccessControl>>
storage_texture_type_access_control();
/// Parses a `depth_texture_type` grammar element
/// @returns the parsed Type or nullptr if none matched.
- Maybe<ast::type::Type*> depth_texture_type();
+ Maybe<type::Type*> depth_texture_type();
/// Parses a `image_storage_type` grammar element
/// @param use a description of what was being parsed if an error was raised
/// @returns returns the image format or kNone if none matched.
- Expect<ast::type::ImageFormat> expect_image_storage_type(
- const std::string& use);
+ Expect<type::ImageFormat> expect_image_storage_type(const std::string& use);
/// Parses a `function_type_decl` grammar element
/// @returns the parsed type or nullptr otherwise
- Maybe<ast::type::Type*> function_type_decl();
+ Maybe<type::Type*> function_type_decl();
/// Parses a `function_header` grammar element
/// @returns the parsed function header
Maybe<FunctionHeader> function_header();
@@ -811,16 +809,15 @@
/// Used to ensure that all decorations are consumed.
bool expect_decorations_consumed(const ast::DecorationList& list);
- Expect<ast::type::Type*> expect_type_decl_pointer();
- Expect<ast::type::Type*> expect_type_decl_vector(Token t);
- Expect<ast::type::Type*> expect_type_decl_array(
- ast::ArrayDecorationList decos);
- Expect<ast::type::Type*> expect_type_decl_matrix(Token t);
+ Expect<type::Type*> expect_type_decl_pointer();
+ Expect<type::Type*> expect_type_decl_vector(Token t);
+ Expect<type::Type*> expect_type_decl_array(ast::ArrayDecorationList decos);
+ Expect<type::Type*> expect_type_decl_matrix(Token t);
Expect<ast::ConstructorExpression*> expect_const_expr_internal(
uint32_t depth);
- Expect<ast::type::Type*> expect_type(const std::string& use);
+ Expect<type::Type*> expect_type(const std::string& use);
Maybe<ast::Statement*> non_block_statement();
Maybe<ast::Statement*> for_header_initializer();
@@ -841,7 +838,7 @@
bool synchronized_ = true;
std::vector<Token::Type> sync_tokens_;
int silence_errors_ = 0;
- std::unordered_map<std::string, ast::type::Type*> registered_constructs_;
+ std::unordered_map<std::string, type::Type*> registered_constructs_;
ast::Module module_;
size_t max_errors_ = 25;
};
diff --git a/src/reader/wgsl/parser_impl_const_expr_test.cc b/src/reader/wgsl/parser_impl_const_expr_test.cc
index 8dd6068..8930fd2 100644
--- a/src/reader/wgsl/parser_impl_const_expr_test.cc
+++ b/src/reader/wgsl/parser_impl_const_expr_test.cc
@@ -16,10 +16,10 @@
#include "src/ast/bool_literal.h"
#include "src/ast/float_literal.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace reader {
@@ -35,8 +35,8 @@
ASSERT_TRUE(e->Is<ast::TypeConstructorExpression>());
auto* t = e->As<ast::TypeConstructorExpression>();
- ASSERT_TRUE(t->type()->Is<ast::type::Vector>());
- EXPECT_EQ(t->type()->As<ast::type::Vector>()->size(), 2u);
+ ASSERT_TRUE(t->type()->Is<type::Vector>());
+ EXPECT_EQ(t->type()->As<type::Vector>()->size(), 2u);
ASSERT_EQ(t->values().size(), 2u);
auto& v = t->values();
diff --git a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
index 2e12319..05da401 100644
--- a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/depth_texture_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/depth_texture_type.h"
namespace tint {
namespace reader {
@@ -36,10 +36,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::DepthTexture>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -49,10 +48,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2dArray);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::DepthTexture>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -62,10 +60,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::kCube);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::DepthTexture>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -75,10 +72,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::kCubeArray);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::DepthTexture>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_function_decl_test.cc b/src/reader/wgsl/parser_impl_function_decl_test.cc
index 519e408..17b9fd1 100644
--- a/src/reader/wgsl/parser_impl_function_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_decl_test.cc
@@ -14,11 +14,11 @@
#include "gtest/gtest.h"
#include "src/ast/function.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/workgroup_decoration.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -39,14 +39,14 @@
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
ASSERT_EQ(f->params().size(), 2u);
EXPECT_EQ(f->params()[0]->symbol(), p->get_module().RegisterSymbol("a"));
EXPECT_EQ(f->params()[1]->symbol(), p->get_module().RegisterSymbol("b"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
auto* body = f->body();
ASSERT_EQ(body->size(), 1u);
@@ -67,10 +67,10 @@
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 1u);
@@ -105,10 +105,10 @@
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
auto& decorations = f->decorations();
ASSERT_EQ(decorations.size(), 2u);
@@ -150,10 +150,10 @@
EXPECT_EQ(f->symbol(), p->get_module().RegisterSymbol("main"));
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
ASSERT_EQ(f->params().size(), 0u);
ASSERT_NE(f->return_type(), nullptr);
- EXPECT_TRUE(f->return_type()->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type()->Is<type::Void>());
auto& decos = f->decorations();
ASSERT_EQ(decos.size(), 2u);
diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc
index 529de06..1a77313 100644
--- a/src/reader/wgsl/parser_impl_function_header_test.cc
+++ b/src/reader/wgsl/parser_impl_function_header_test.cc
@@ -14,10 +14,10 @@
#include "gtest/gtest.h"
#include "src/ast/function.h"
-#include "src/ast/type/type.h"
-#include "src/ast/type/void_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -35,7 +35,7 @@
ASSERT_EQ(f->params.size(), 2u);
EXPECT_EQ(f->params[0]->symbol(), p->get_module().RegisterSymbol("a"));
EXPECT_EQ(f->params[1]->symbol(), p->get_module().RegisterSymbol("b"));
- EXPECT_TRUE(f->return_type->Is<ast::type::Void>());
+ EXPECT_TRUE(f->return_type->Is<type::Void>());
}
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
diff --git a/src/reader/wgsl/parser_impl_function_type_decl_test.cc b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
index b4160e5..f3f16bf 100644
--- a/src/reader/wgsl/parser_impl_function_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_function_type_decl_test.cc
@@ -15,11 +15,11 @@
#include <memory>
#include "gtest/gtest.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
namespace reader {
@@ -30,7 +30,7 @@
auto p = parser("void");
auto& mod = p->get_module();
- auto* v = mod.create<ast::type::Void>();
+ auto* v = mod.create<type::Void>();
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
@@ -43,8 +43,8 @@
auto p = parser("vec2<f32>");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32>();
- auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
+ auto* f32 = mod.create<type::F32>();
+ auto* vec2 = mod.create<type::Vector>(f32, 2);
auto e = p->function_type_decl();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
index 89864db..149b6d9 100644
--- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
@@ -13,11 +13,11 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decoration.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace reader {
@@ -35,7 +35,7 @@
EXPECT_TRUE(e->is_const());
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(e->type()->Is<type::F32>());
EXPECT_EQ(e->source().range.begin.line, 1u);
EXPECT_EQ(e->source().range.begin.column, 7u);
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index 0aee4bf..7fac54c 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -13,10 +13,10 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/array_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace reader {
@@ -88,10 +88,10 @@
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 1u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Alias>());
- EXPECT_EQ(m.SymbolToName(
- m.constructed_types()[0]->As<ast::type::Alias>()->symbol()),
- "A");
+ ASSERT_TRUE(m.constructed_types()[0]->Is<type::Alias>());
+ EXPECT_EQ(
+ m.SymbolToName(m.constructed_types()[0]->As<type::Alias>()->symbol()),
+ "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
@@ -105,12 +105,12 @@
auto& m = p->get_module();
ASSERT_EQ(m.constructed_types().size(), 2u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Struct>());
- auto* str = m.constructed_types()[0]->As<ast::type::Struct>();
+ ASSERT_TRUE(m.constructed_types()[0]->Is<type::Struct>());
+ auto* str = m.constructed_types()[0]->As<type::Struct>();
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
- ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::Alias>());
- auto* alias = m.constructed_types()[1]->As<ast::type::Alias>();
+ ASSERT_TRUE(m.constructed_types()[1]->Is<type::Alias>());
+ auto* alias = m.constructed_types()[1]->As<type::Alias>();
EXPECT_EQ(alias->symbol(), p->get_module().RegisterSymbol("B"));
EXPECT_EQ(alias->type(), str);
}
@@ -166,9 +166,9 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Struct>());
+ ASSERT_TRUE(t->Is<type::Struct>());
- auto* str = t->As<ast::type::Struct>();
+ auto* str = t->As<type::Struct>();
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -185,16 +185,16 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Struct>());
+ ASSERT_TRUE(t->Is<type::Struct>());
- auto* str = t->As<ast::type::Struct>();
+ auto* str = t->As<type::Struct>();
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
const auto* ty = str->impl()->members()[0]->type();
- ASSERT_TRUE(ty->Is<ast::type::Array>());
- const auto* arr = ty->As<ast::type::Array>();
+ ASSERT_TRUE(ty->Is<type::Array>());
+ const auto* arr = ty->As<type::Array>();
EXPECT_TRUE(arr->has_array_stride());
EXPECT_EQ(arr->array_stride(), 4u);
}
@@ -209,9 +209,9 @@
auto* t = m.constructed_types()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Struct>());
+ ASSERT_TRUE(t->Is<type::Struct>());
- auto* str = t->As<ast::type::Struct>();
+ auto* str = t->As<type::Struct>();
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());
diff --git a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
index f17ceca..84c392d 100644
--- a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc
@@ -14,11 +14,11 @@
#include "gtest/gtest.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decoration.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace reader {
@@ -37,7 +37,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
- EXPECT_TRUE(e->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(e->type()->Is<type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -60,7 +60,7 @@
ASSERT_NE(e.value, nullptr);
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
- EXPECT_TRUE(e->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(e->type()->Is<type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -86,7 +86,7 @@
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(e->type()->Is<type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
@@ -116,7 +116,7 @@
EXPECT_EQ(e->symbol(), p->get_module().RegisterSymbol("a"));
ASSERT_NE(e->type(), nullptr);
- EXPECT_TRUE(e->type()->Is<ast::type::F32>());
+ EXPECT_TRUE(e->type()->Is<type::F32>());
EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput);
EXPECT_EQ(e->source().range.begin.line, 1u);
diff --git a/src/reader/wgsl/parser_impl_image_storage_type_test.cc b/src/reader/wgsl/parser_impl_image_storage_type_test.cc
index 64462f7..7f12549 100644
--- a/src/reader/wgsl/parser_impl_image_storage_type_test.cc
+++ b/src/reader/wgsl/parser_impl_image_storage_type_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/texture_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/texture_type.h"
namespace tint {
namespace reader {
@@ -34,7 +34,7 @@
auto p = parser("r8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kR8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -42,7 +42,7 @@
auto p = parser("r8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Snorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kR8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -50,7 +50,7 @@
auto p = parser("r8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -58,7 +58,7 @@
auto p = parser("r8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR8Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -66,7 +66,7 @@
auto p = parser("r16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -74,7 +74,7 @@
auto p = parser("r16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -82,7 +82,7 @@
auto p = parser("r16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR16Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kR16Float);
EXPECT_FALSE(p->has_error());
}
@@ -90,7 +90,7 @@
auto p = parser("rg8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Unorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -98,7 +98,7 @@
auto p = parser("rg8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Snorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -106,7 +106,7 @@
auto p = parser("rg8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -114,7 +114,7 @@
auto p = parser("rg8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg8Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -122,7 +122,7 @@
auto p = parser("r32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -130,7 +130,7 @@
auto p = parser("r32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kR32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -138,7 +138,7 @@
auto p = parser("r32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kR32Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kR32Float);
EXPECT_FALSE(p->has_error());
}
@@ -146,7 +146,7 @@
auto p = parser("rg16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -154,7 +154,7 @@
auto p = parser("rg16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -162,7 +162,7 @@
auto p = parser("rg16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg16Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg16Float);
EXPECT_FALSE(p->has_error());
}
@@ -170,7 +170,7 @@
auto p = parser("rgba8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Unorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -178,7 +178,7 @@
auto p = parser("rgba8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8UnormSrgb);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@@ -186,7 +186,7 @@
auto p = parser("rgba8snorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Snorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba8Snorm);
EXPECT_FALSE(p->has_error());
}
@@ -194,7 +194,7 @@
auto p = parser("rgba8uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba8Uint);
EXPECT_FALSE(p->has_error());
}
@@ -202,7 +202,7 @@
auto p = parser("rgba8sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba8Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba8Sint);
EXPECT_FALSE(p->has_error());
}
@@ -210,7 +210,7 @@
auto p = parser("bgra8unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8Unorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kBgra8Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -218,7 +218,7 @@
auto p = parser("bgra8unorm_srgb");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kBgra8UnormSrgb);
+ EXPECT_EQ(t.value, type::ImageFormat::kBgra8UnormSrgb);
EXPECT_FALSE(p->has_error());
}
@@ -226,7 +226,7 @@
auto p = parser("rgb10a2unorm");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgb10A2Unorm);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgb10A2Unorm);
EXPECT_FALSE(p->has_error());
}
@@ -234,7 +234,7 @@
auto p = parser("rg11b10float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg11B10Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg11B10Float);
EXPECT_FALSE(p->has_error());
}
@@ -242,7 +242,7 @@
auto p = parser("rg32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -250,7 +250,7 @@
auto p = parser("rg32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -258,7 +258,7 @@
auto p = parser("rg32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRg32Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kRg32Float);
EXPECT_FALSE(p->has_error());
}
@@ -266,7 +266,7 @@
auto p = parser("rgba16uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba16Uint);
EXPECT_FALSE(p->has_error());
}
@@ -274,7 +274,7 @@
auto p = parser("rgba16sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba16Sint);
EXPECT_FALSE(p->has_error());
}
@@ -282,7 +282,7 @@
auto p = parser("rgba16float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba16Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba16Float);
EXPECT_FALSE(p->has_error());
}
@@ -290,7 +290,7 @@
auto p = parser("rgba32uint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Uint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba32Uint);
EXPECT_FALSE(p->has_error());
}
@@ -298,7 +298,7 @@
auto p = parser("rgba32sint");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Sint);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba32Sint);
EXPECT_FALSE(p->has_error());
}
@@ -306,7 +306,7 @@
auto p = parser("rgba32float");
auto t = p->expect_image_storage_type("test");
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::ImageFormat::kRgba32Float);
+ EXPECT_EQ(t.value, type::ImageFormat::kRgba32Float);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_param_list_test.cc b/src/reader/wgsl/parser_impl_param_list_test.cc
index 58b3cbd..a8a9106 100644
--- a/src/reader/wgsl/parser_impl_param_list_test.cc
+++ b/src/reader/wgsl/parser_impl_param_list_test.cc
@@ -15,12 +15,12 @@
#include <memory>
#include "gtest/gtest.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/variable.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace reader {
@@ -31,7 +31,7 @@
auto p = parser("a : i32");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
@@ -52,9 +52,9 @@
auto p = parser("a : i32, b: f32, c: vec2<f32>");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
- auto* f32 = mod.create<ast::type::F32>();
- auto* vec2 = mod.create<ast::type::Vector>(f32, 2);
+ auto* i32 = mod.create<type::I32>();
+ auto* f32 = mod.create<type::F32>();
+ auto* vec2 = mod.create<type::Vector>(f32, 2);
auto e = p->expect_param_list();
ASSERT_FALSE(p->has_error()) << p->error();
diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc
index a6bdb1b..74ddfc3 100644
--- a/src/reader/wgsl/parser_impl_primary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc
@@ -20,12 +20,12 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace reader {
@@ -194,7 +194,7 @@
auto p = parser("f32(1)");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32>();
+ auto* f32 = mod.create<type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
@@ -216,7 +216,7 @@
auto p = parser("bitcast<f32>(1)");
auto& mod = p->get_module();
- auto* f32 = mod.create<ast::type::F32>();
+ auto* f32 = mod.create<type::F32>();
auto e = p->primary_expression();
EXPECT_TRUE(e.matched);
diff --git a/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc b/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
index deda8b7..fc553e3 100644
--- a/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_sampled_texture_type_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/texture_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/texture_type.h"
namespace tint {
namespace reader {
@@ -35,7 +35,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
+ EXPECT_EQ(t.value, type::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@@ -44,7 +44,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
EXPECT_FALSE(p->has_error());
}
@@ -53,7 +53,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
+ EXPECT_EQ(t.value, type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -62,7 +62,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -71,7 +71,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
+ EXPECT_EQ(t.value, type::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
@@ -80,7 +80,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::kCube);
+ EXPECT_EQ(t.value, type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -89,7 +89,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::kCubeArray);
+ EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
@@ -98,7 +98,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
+ EXPECT_EQ(t.value, type::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@@ -107,7 +107,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
EXPECT_FALSE(p->has_error());
}
@@ -116,7 +116,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
+ EXPECT_EQ(t.value, type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -125,7 +125,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -134,7 +134,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
+ EXPECT_EQ(t.value, type::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
@@ -143,7 +143,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::kCube);
+ EXPECT_EQ(t.value, type::TextureDimension::kCube);
EXPECT_FALSE(p->has_error());
}
@@ -152,7 +152,7 @@
auto t = p->sampled_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::kCubeArray);
+ EXPECT_EQ(t.value, type::TextureDimension::kCubeArray);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_sampler_type_test.cc b/src/reader/wgsl/parser_impl_sampler_type_test.cc
index b4303cd..ce98c32 100644
--- a/src/reader/wgsl/parser_impl_sampler_type_test.cc
+++ b/src/reader/wgsl/parser_impl_sampler_type_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/sampler_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/sampler_type.h"
namespace tint {
namespace reader {
@@ -37,8 +37,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Sampler>());
- EXPECT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<type::Sampler>());
+ EXPECT_FALSE(t->As<type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
@@ -48,8 +48,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Sampler>());
- EXPECT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<type::Sampler>());
+ EXPECT_TRUE(t->As<type::Sampler>()->IsComparison());
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_storage_texture_type_test.cc b/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
index 82d97fe..d145af8 100644
--- a/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
+++ b/src/reader/wgsl/parser_impl_storage_texture_type_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/storage_texture_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/storage_texture_type.h"
namespace tint {
namespace reader {
@@ -35,7 +35,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1d);
+ EXPECT_EQ(t.value, type::TextureDimension::k1d);
EXPECT_FALSE(p->has_error());
}
@@ -44,7 +44,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k1dArray);
EXPECT_FALSE(p->has_error());
}
@@ -53,7 +53,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2d);
+ EXPECT_EQ(t.value, type::TextureDimension::k2d);
EXPECT_FALSE(p->has_error());
}
@@ -62,7 +62,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(t.value, type::TextureDimension::k2dArray);
EXPECT_FALSE(p->has_error());
}
@@ -71,7 +71,7 @@
auto t = p->storage_texture_type();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(t.value, ast::type::TextureDimension::k3d);
+ EXPECT_EQ(t.value, type::TextureDimension::k3d);
EXPECT_FALSE(p->has_error());
}
@@ -88,7 +88,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -98,7 +98,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -108,7 +108,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -118,7 +118,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -128,7 +128,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -138,7 +138,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -148,7 +148,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -158,7 +158,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -168,7 +168,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -178,7 +178,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -188,7 +188,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -198,7 +198,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -208,7 +208,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -218,7 +218,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -228,7 +228,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kReadOnly);
EXPECT_FALSE(p->has_error());
}
@@ -238,7 +238,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -248,7 +248,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k1dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k1dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -258,7 +258,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -268,7 +268,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k2dArray);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k2dArray);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
@@ -278,7 +278,7 @@
auto t = p->storage_texture_type_access_control();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
- EXPECT_EQ(std::get<0>(t.value), ast::type::TextureDimension::k3d);
+ EXPECT_EQ(std::get<0>(t.value), type::TextureDimension::k3d);
EXPECT_EQ(std::get<1>(t.value), ast::AccessControl::kWriteOnly);
EXPECT_FALSE(p->has_error());
}
diff --git a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
index a66837b..bbfdce1 100644
--- a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc
@@ -13,9 +13,9 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/i32_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace reader {
@@ -26,7 +26,7 @@
auto p = parser("{a : i32;}");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto m = p->expect_struct_body_decl();
ASSERT_FALSE(p->has_error());
diff --git a/src/reader/wgsl/parser_impl_struct_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decl_test.cc
index b218608..9680c4d 100644
--- a/src/reader/wgsl/parser_impl_struct_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_decl_test.cc
@@ -14,7 +14,7 @@
#include "gtest/gtest.h"
#include "src/ast/struct_block_decoration.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
diff --git a/src/reader/wgsl/parser_impl_struct_member_test.cc b/src/reader/wgsl/parser_impl_struct_member_test.cc
index f5a9fd0..554e1d7 100644
--- a/src/reader/wgsl/parser_impl_struct_member_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_member_test.cc
@@ -14,9 +14,9 @@
#include "gtest/gtest.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/i32_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/i32_type.h"
namespace tint {
namespace reader {
@@ -27,7 +27,7 @@
auto p = parser("a : i32;");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -53,7 +53,7 @@
auto p = parser("[[offset(2)]] a : i32;");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
@@ -84,7 +84,7 @@
[[offset(4)]] a : i32;)");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto decos = p->decoration_list();
EXPECT_FALSE(decos.errored);
diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc
index 95d28cf..1c21208 100644
--- a/src/reader/wgsl/parser_impl_test.cc
+++ b/src/reader/wgsl/parser_impl_test.cc
@@ -15,7 +15,7 @@
#include "src/reader/wgsl/parser_impl.h"
#include "gtest/gtest.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
namespace tint {
diff --git a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
index 88bc7d3..df3f0b6 100644
--- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
+++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
@@ -13,16 +13,16 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/access_control_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/u32_type.h"
namespace tint {
namespace reader {
@@ -45,8 +45,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Sampler>());
- ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<type::Sampler>());
+ ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) {
@@ -56,8 +56,8 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Sampler>());
- ASSERT_TRUE(t->As<ast::type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<type::Sampler>());
+ ASSERT_TRUE(t->As<type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) {
@@ -67,10 +67,9 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::DepthTexture>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::DepthTexture>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) {
@@ -80,11 +79,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k1d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
@@ -94,11 +92,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) {
@@ -108,11 +105,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k3d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid_Old) {
@@ -163,11 +159,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k1d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
@@ -177,11 +172,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::I32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) {
@@ -191,11 +185,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::U32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k3d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::U32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k3d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_Invalid) {
@@ -245,12 +238,10 @@
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::MultisampledTexture>());
- ASSERT_TRUE(
- t->As<ast::type::MultisampledTexture>()->type()->Is<ast::type::I32>());
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::MultisampledTexture>());
+ ASSERT_TRUE(t->As<type::MultisampledTexture>()->type()->Is<type::I32>());
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_Invalid) {
@@ -302,17 +293,16 @@
EXPECT_FALSE(ac.errored);
ASSERT_NE(ac.value, nullptr);
- ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
- EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
+ ASSERT_TRUE(ac->Is<type::AccessControl>());
+ EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
ast::AccessControl::kReadOnly);
- auto* t = ac->As<ast::type::AccessControl>()->type();
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k1d);
+ auto* t = ac->As<type::AccessControl>()->type();
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
}
TEST_F(ParserImplTest,
@@ -324,17 +314,16 @@
EXPECT_FALSE(ac.errored);
ASSERT_NE(ac.value, nullptr);
- ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
- EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
+ ASSERT_TRUE(ac->Is<type::AccessControl>());
+ EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
ast::AccessControl::kWriteOnly);
- auto* t = ac->As<ast::type::AccessControl>()->type();
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ auto* t = ac->As<type::AccessControl>()->type();
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR16Float);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_Old) {
@@ -383,17 +372,16 @@
EXPECT_FALSE(ac.errored);
ASSERT_NE(ac.value, nullptr);
- ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
- EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
+ ASSERT_TRUE(ac->Is<type::AccessControl>());
+ EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
ast::AccessControl::kReadOnly);
- auto* t = ac->As<ast::type::AccessControl>()->type();
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k1d);
+ auto* t = ac->As<type::AccessControl>()->type();
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
}
TEST_F(ParserImplTest,
@@ -405,17 +393,16 @@
EXPECT_FALSE(ac.errored);
ASSERT_NE(ac.value, nullptr);
- ASSERT_TRUE(ac->Is<ast::type::AccessControl>());
- EXPECT_EQ(ac->As<ast::type::AccessControl>()->access_control(),
+ ASSERT_TRUE(ac->Is<type::AccessControl>());
+ EXPECT_EQ(ac->As<type::AccessControl>()->access_control(),
ast::AccessControl::kWriteOnly);
- auto* t = ac->As<ast::type::AccessControl>()->type();
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ auto* t = ac->As<type::AccessControl>()->type();
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR16Float);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType_old) {
@@ -463,12 +450,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR8Unorm);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k1d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR8Unorm);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k1d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) {
@@ -479,12 +465,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::StorageTexture>());
- EXPECT_EQ(t->As<ast::type::StorageTexture>()->image_format(),
- ast::type::ImageFormat::kR16Float);
- EXPECT_EQ(t->As<ast::type::Texture>()->dim(),
- ast::type::TextureDimension::k2d);
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::StorageTexture>());
+ EXPECT_EQ(t->As<type::StorageTexture>()->image_format(),
+ type::ImageFormat::kR16Float);
+ EXPECT_EQ(t->As<type::Texture>()->dim(), type::TextureDimension::k2d);
}
TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_InvalidType) {
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index efe51a0..da890b5 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -13,12 +13,12 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace reader {
@@ -29,23 +29,23 @@
auto p = parser("type a = i32");
auto& mod = p->get_module();
- auto* i32 = mod.create<ast::type::I32>();
+ auto* i32 = mod.create<type::I32>();
auto t = p->type_alias();
EXPECT_FALSE(p->has_error());
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Alias>());
- auto* alias = t->As<ast::type::Alias>();
- ASSERT_TRUE(alias->type()->Is<ast::type::I32>());
+ ASSERT_TRUE(t->Is<type::Alias>());
+ auto* alias = t->As<type::Alias>();
+ ASSERT_TRUE(alias->type()->Is<type::I32>());
ASSERT_EQ(alias->type(), i32);
}
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
auto p = parser("type a = B");
- ast::type::Struct str(p->get_module().RegisterSymbol("B"), {});
+ type::Struct str(p->get_module().RegisterSymbol("B"), {});
p->register_constructed("B", &str);
auto t = p->type_alias();
@@ -53,12 +53,12 @@
EXPECT_FALSE(t.errored);
EXPECT_TRUE(t.matched);
ASSERT_NE(t.value, nullptr);
- ASSERT_TRUE(t->Is<ast::type::Alias>());
- auto* alias = t->As<ast::type::Alias>();
+ ASSERT_TRUE(t->Is<type::Alias>());
+ auto* alias = t->As<type::Alias>();
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "a");
- ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
+ ASSERT_TRUE(alias->type()->Is<type::Struct>());
- auto* s = alias->type()->As<ast::type::Struct>();
+ auto* s = alias->type()->As<type::Struct>();
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
}
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index 5bb6f9f..f82b065 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -14,20 +14,20 @@
#include "gtest/gtest.h"
#include "src/ast/stride_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace reader {
@@ -48,9 +48,8 @@
auto& mod = p->get_module();
- auto* int_type = mod.create<ast::type::I32>();
- auto* alias_type =
- mod.create<ast::type::Alias>(mod.RegisterSymbol("A"), int_type);
+ auto* int_type = mod.create<type::I32>();
+ auto* alias_type = mod.create<type::Alias>(mod.RegisterSymbol("A"), int_type);
p->register_constructed("A", alias_type);
@@ -59,9 +58,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, alias_type);
- ASSERT_TRUE(t->Is<ast::type::Alias>());
+ ASSERT_TRUE(t->Is<type::Alias>());
- auto* alias = t->As<ast::type::Alias>();
+ auto* alias = t->As<type::Alias>();
EXPECT_EQ(p->get_module().SymbolToName(alias->symbol()), "A");
EXPECT_EQ(alias->type(), int_type);
}
@@ -81,56 +80,56 @@
auto p = parser("bool");
auto& mod = p->get_module();
- auto* bool_type = mod.create<ast::type::Bool>();
+ auto* bool_type = mod.create<type::Bool>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, bool_type);
- ASSERT_TRUE(t->Is<ast::type::Bool>());
+ ASSERT_TRUE(t->Is<type::Bool>());
}
TEST_F(ParserImplTest, TypeDecl_F32) {
auto p = parser("f32");
auto& mod = p->get_module();
- auto* float_type = mod.create<ast::type::F32>();
+ auto* float_type = mod.create<type::F32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, float_type);
- ASSERT_TRUE(t->Is<ast::type::F32>());
+ ASSERT_TRUE(t->Is<type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_I32) {
auto p = parser("i32");
auto& mod = p->get_module();
- auto* int_type = mod.create<ast::type::I32>();
+ auto* int_type = mod.create<type::I32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, int_type);
- ASSERT_TRUE(t->Is<ast::type::I32>());
+ ASSERT_TRUE(t->Is<type::I32>());
}
TEST_F(ParserImplTest, TypeDecl_U32) {
auto p = parser("u32");
auto& mod = p->get_module();
- auto* uint_type = mod.create<ast::type::U32>();
+ auto* uint_type = mod.create<type::U32>();
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, uint_type);
- ASSERT_TRUE(t->Is<ast::type::U32>());
+ ASSERT_TRUE(t->Is<type::U32>());
}
struct VecData {
@@ -152,8 +151,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<ast::type::Vector>());
- EXPECT_EQ(t->As<ast::type::Vector>()->size(), params.count);
+ EXPECT_TRUE(t->Is<type::Vector>());
+ EXPECT_EQ(t->As<type::Vector>()->size(), params.count);
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
VecTest,
@@ -240,10 +239,10 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Pointer>());
+ ASSERT_TRUE(t->Is<type::Pointer>());
- auto* ptr = t->As<ast::type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = t->As<type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<type::F32>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
}
@@ -254,15 +253,15 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Pointer>());
+ ASSERT_TRUE(t->Is<type::Pointer>());
- auto* ptr = t->As<ast::type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
+ auto* ptr = t->As<type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<type::Vector>());
ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction);
- auto* vec = ptr->type()->As<ast::type::Vector>();
+ auto* vec = ptr->type()->As<type::Vector>();
ASSERT_EQ(vec->size(), 2u);
- ASSERT_TRUE(vec->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(vec->type()->Is<type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) {
@@ -352,12 +351,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(a->type()->Is<type::F32>());
ASSERT_FALSE(a->has_array_stride());
}
@@ -368,12 +367,12 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
- ASSERT_TRUE(a->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(a->type()->Is<type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -385,11 +384,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(a->type()->Is<type::F32>());
ASSERT_TRUE(a->has_array_stride());
EXPECT_EQ(a->array_stride(), 16u);
}
@@ -401,11 +400,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(a->type()->Is<type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -422,11 +421,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(a->type()->Is<type::F32>());
auto& decos = a->decorations();
ASSERT_EQ(decos.size(), 2u);
@@ -525,11 +524,11 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<ast::type::Array>());
+ ASSERT_TRUE(t->Is<type::Array>());
- auto* a = t->As<ast::type::Array>();
+ auto* a = t->As<type::Array>();
ASSERT_TRUE(a->IsRuntimeArray());
- ASSERT_TRUE(a->type()->Is<ast::type::U32>());
+ ASSERT_TRUE(a->type()->Is<type::U32>());
}
TEST_F(ParserImplTest, TypeDecl_Array_BadType) {
@@ -622,8 +621,8 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- EXPECT_TRUE(t->Is<ast::type::Matrix>());
- auto* mat = t->As<ast::type::Matrix>();
+ EXPECT_TRUE(t->Is<type::Matrix>());
+ auto* mat = t->As<type::Matrix>();
EXPECT_EQ(mat->rows(), params.rows);
EXPECT_EQ(mat->columns(), params.columns);
}
@@ -740,49 +739,49 @@
auto p = parser("sampler");
auto& mod = p->get_module();
- auto* type = mod.create<ast::type::Sampler>(ast::type::SamplerKind::kSampler);
+ auto* type = mod.create<type::Sampler>(type::SamplerKind::kSampler);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::Sampler>());
- ASSERT_FALSE(t->As<ast::type::Sampler>()->IsComparison());
+ ASSERT_TRUE(t->Is<type::Sampler>());
+ ASSERT_FALSE(t->As<type::Sampler>()->IsComparison());
}
TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
auto p = parser("texture_sampled_cube<f32>");
auto& mod = p->get_module();
- auto* type = mod.create<ast::type::SampledTexture>(
- ast::type::TextureDimension::kCube, ty.f32);
+ auto* type =
+ mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
}
TEST_F(ParserImplTest, TypeDecl_Texture) {
auto p = parser("texture_cube<f32>");
auto& mod = p->get_module();
- auto* type = mod.create<ast::type::SampledTexture>(
- ast::type::TextureDimension::kCube, ty.f32);
+ auto* type =
+ mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr);
EXPECT_EQ(t.value, type);
- ASSERT_TRUE(t->Is<ast::type::Texture>());
- ASSERT_TRUE(t->Is<ast::type::SampledTexture>());
- ASSERT_TRUE(t->As<ast::type::SampledTexture>()->type()->Is<ast::type::F32>());
+ ASSERT_TRUE(t->Is<type::Texture>());
+ ASSERT_TRUE(t->Is<type::SampledTexture>());
+ ASSERT_TRUE(t->As<type::SampledTexture>()->type()->Is<type::F32>());
}
} // namespace
diff --git a/src/reader/wgsl/parser_impl_variable_decl_test.cc b/src/reader/wgsl/parser_impl_variable_decl_test.cc
index 3e30af0..51189d5 100644
--- a/src/reader/wgsl/parser_impl_variable_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_decl_test.cc
@@ -13,10 +13,10 @@
// limitations under the License.
#include "gtest/gtest.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace reader {
@@ -31,7 +31,7 @@
EXPECT_FALSE(v.errored);
EXPECT_EQ(v->name, "my_var");
EXPECT_NE(v->type, nullptr);
- EXPECT_TRUE(v->type->Is<ast::type::F32>());
+ EXPECT_TRUE(v->type->Is<type::F32>());
EXPECT_EQ(v->source.range.begin.line, 1u);
EXPECT_EQ(v->source.range.begin.column, 5u);
@@ -66,7 +66,7 @@
EXPECT_FALSE(v.errored);
EXPECT_FALSE(p->has_error());
EXPECT_EQ(v->name, "my_var");
- EXPECT_TRUE(v->type->Is<ast::type::F32>());
+ EXPECT_TRUE(v->type->Is<type::F32>());
EXPECT_EQ(v->storage_class, ast::StorageClass::kPrivate);
EXPECT_EQ(v->source.range.begin.line, 1u);
diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
index b8763fe..86e423c 100644
--- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
@@ -15,12 +15,12 @@
#include "gtest/gtest.h"
#include "src/ast/struct.h"
#include "src/ast/struct_block_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
+#include "src/type/access_control_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
namespace tint {
namespace reader {
@@ -34,7 +34,7 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::F32>());
+ ASSERT_TRUE(decl->type->Is<type::F32>());
ASSERT_EQ(decl->source.range.begin.line, 1u);
ASSERT_EQ(decl->source.range.begin.column, 1u);
@@ -90,11 +90,11 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
- ASSERT_TRUE(decl->type->As<ast::type::AccessControl>()
+ ASSERT_TRUE(decl->type->Is<type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
+ ASSERT_TRUE(decl->type->As<type::AccessControl>()
->type()
- ->Is<ast::type::StorageTexture>());
+ ->Is<type::StorageTexture>());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
@@ -105,11 +105,11 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsWriteOnly());
- ASSERT_TRUE(decl->type->As<ast::type::AccessControl>()
+ ASSERT_TRUE(decl->type->Is<type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsWriteOnly());
+ ASSERT_TRUE(decl->type->As<type::AccessControl>()
->type()
- ->Is<ast::type::StorageTexture>());
+ ->Is<type::StorageTexture>());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
@@ -133,8 +133,8 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadOnly());
+ ASSERT_TRUE(decl->type->Is<type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadOnly());
}
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
@@ -158,8 +158,8 @@
ASSERT_FALSE(decl.errored);
ASSERT_EQ(decl->name, "my_var");
ASSERT_NE(decl->type, nullptr);
- ASSERT_TRUE(decl->type->Is<ast::type::AccessControl>());
- EXPECT_TRUE(decl->type->As<ast::type::AccessControl>()->IsReadWrite());
+ ASSERT_TRUE(decl->type->Is<type::AccessControl>());
+ EXPECT_TRUE(decl->type->As<type::AccessControl>()->IsReadWrite());
}
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
diff --git a/src/scope_stack_test.cc b/src/scope_stack_test.cc
index 7e58c35..f5c9f84 100644
--- a/src/scope_stack_test.cc
+++ b/src/scope_stack_test.cc
@@ -15,9 +15,9 @@
#include "gtest/gtest.h"
#include "src/ast/builder.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/symbol.h"
+#include "src/type/f32_type.h"
namespace tint {
namespace {
diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc
index c7ce85e..bdfb938 100644
--- a/src/transform/bound_array_accessors.cc
+++ b/src/transform/bound_array_accessors.cc
@@ -39,15 +39,15 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace transform {
@@ -71,8 +71,8 @@
ast::CloneContext* ctx,
diag::List* diags) {
auto* ret_type = expr->array()->result_type()->UnwrapAll();
- if (!ret_type->Is<ast::type::Array>() && !ret_type->Is<ast::type::Matrix>() &&
- !ret_type->Is<ast::type::Vector>()) {
+ if (!ret_type->Is<type::Array>() && !ret_type->Is<type::Matrix>() &&
+ !ret_type->Is<type::Vector>()) {
return nullptr;
}
@@ -80,15 +80,15 @@
using u32 = ast::Builder::u32;
uint32_t size = 0;
- bool is_vec = ret_type->Is<ast::type::Vector>();
- bool is_arr = ret_type->Is<ast::type::Array>();
+ bool is_vec = ret_type->Is<type::Vector>();
+ bool is_arr = ret_type->Is<type::Array>();
if (is_vec || is_arr) {
- size = is_vec ? ret_type->As<ast::type::Vector>()->size()
- : ret_type->As<ast::type::Array>()->size();
+ size = is_vec ? ret_type->As<type::Vector>()->size()
+ : ret_type->As<type::Array>()->size();
} else {
// The row accessor would have been an embedded array accessor and already
// handled, so we just need to do columns here.
- size = ret_type->As<ast::type::Matrix>()->columns();
+ size = ret_type->As<type::Matrix>()->columns();
}
auto* const old_idx = expr->idx_expr();
diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc
index 1628d63..a46a958 100644
--- a/src/transform/emit_vertex_point_size.cc
+++ b/src/transform/emit_vertex_point_size.cc
@@ -23,9 +23,9 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type_manager.h"
#include "src/ast/variable.h"
+#include "src/type/f32_type.h"
+#include "src/type/type_manager.h"
namespace tint {
namespace transform {
@@ -47,7 +47,7 @@
return out;
}
- auto* f32 = out.module.create<ast::type::F32>();
+ auto* f32 = out.module.create<type::F32>();
// Declare the pointsize builtin output variable.
auto* pointsize_var = out.module.create<ast::Variable>(
diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc
index 7e6bfda..df878ac 100644
--- a/src/transform/first_index_offset.cc
+++ b/src/transform/first_index_offset.cc
@@ -42,13 +42,13 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/variable_decoration.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
#include "src/type_determiner.h"
namespace tint {
@@ -196,7 +196,7 @@
}
ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
- auto* u32_type = mod->create<ast::type::U32>();
+ auto* u32_type = mod->create<type::U32>();
ast::StructMemberList members;
uint32_t offset = 0;
if (has_vertex_index_) {
@@ -224,7 +224,7 @@
ast::StructDecorationList decos;
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
- auto* struct_type = mod->create<ast::type::Struct>(
+ auto* struct_type = mod->create<type::Struct>(
mod->RegisterSymbol(kStructName),
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
@@ -268,9 +268,9 @@
mod->create<ast::Variable>(Source{}, // source
mod->RegisterSymbol(original_name), // symbol
ast::StorageClass::kNone, // storage_class
- mod->create<ast::type::U32>(), // type
- true, // is_const
- constructor, // constructor
+ mod->create<type::U32>(), // type
+ true, // is_const
+ constructor, // constructor
ast::VariableDecorationList{}); // decorations
return mod->create<ast::VariableDeclStatement>(Source{}, var);
}
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index ae121f4..24f6da6 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -29,16 +29,16 @@
#include "src/ast/struct_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace transform {
@@ -261,7 +261,7 @@
void VertexPulling::State::AddVertexStorageBuffers() {
// TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
// The array inside the struct definition
- auto* internal_array_type = out->create<ast::type::Array>(
+ auto* internal_array_type = out->create<type::Array>(
GetU32Type(), 0,
ast::ArrayDecorationList{
out->create<ast::StrideDecoration>(Source{}, 4u),
@@ -280,7 +280,7 @@
ast::StructDecorationList decos;
decos.push_back(out->create<ast::StructBlockDecoration>(Source{}));
- auto* struct_type = out->create<ast::type::Struct>(
+ auto* struct_type = out->create<type::Struct>(
out->RegisterSymbol(kStructName),
out->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
@@ -463,7 +463,7 @@
ast::Expression* VertexPulling::State::AccessVec(uint32_t buffer,
uint32_t element_stride,
- ast::type::Type* base_type,
+ type::Type* base_type,
VertexFormat base_format,
uint32_t count) const {
ast::ExpressionList expr_list;
@@ -476,20 +476,20 @@
}
return out->create<ast::TypeConstructorExpression>(
- Source{}, out->create<ast::type::Vector>(base_type, count),
+ Source{}, out->create<type::Vector>(base_type, count),
std::move(expr_list));
}
-ast::type::Type* VertexPulling::State::GetU32Type() const {
- return out->create<ast::type::U32>();
+type::Type* VertexPulling::State::GetU32Type() const {
+ return out->create<type::U32>();
}
-ast::type::Type* VertexPulling::State::GetI32Type() const {
- return out->create<ast::type::I32>();
+type::Type* VertexPulling::State::GetI32Type() const {
+ return out->create<type::I32>();
}
-ast::type::Type* VertexPulling::State::GetF32Type() const {
- return out->create<ast::type::F32>();
+type::Type* VertexPulling::State::GetF32Type() const {
+ return out->create<type::F32>();
}
VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
diff --git a/src/transform/vertex_pulling.h b/src/transform/vertex_pulling.h
index a09cf0f..2a75cc5 100644
--- a/src/transform/vertex_pulling.h
+++ b/src/transform/vertex_pulling.h
@@ -254,14 +254,14 @@
/// @param count how many elements the vector has
ast::Expression* AccessVec(uint32_t buffer,
uint32_t element_stride,
- ast::type::Type* base_type,
+ type::Type* base_type,
VertexFormat base_format,
uint32_t count) const;
// Used to grab corresponding types from the type manager
- ast::type::Type* GetU32Type() const;
- ast::type::Type* GetI32Type() const;
- ast::type::Type* GetF32Type() const;
+ type::Type* GetU32Type() const;
+ type::Type* GetI32Type() const;
+ type::Type* GetF32Type() const;
ast::Module* const in;
ast::Module* const out;
diff --git a/src/ast/type/access_control_type.cc b/src/type/access_control_type.cc
similarity index 92%
rename from src/ast/type/access_control_type.cc
rename to src/type/access_control_type.cc
index 44e7cbe..82e0de1 100644
--- a/src/ast/type/access_control_type.cc
+++ b/src/type/access_control_type.cc
@@ -12,17 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/access_control_type.h"
+#include "src/type/access_control_type.h"
#include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::AccessControl);
+TINT_INSTANTIATE_CLASS_ID(tint::type::AccessControl);
namespace tint {
-namespace ast {
namespace type {
AccessControl::AccessControl(ast::AccessControl access, Type* subtype)
@@ -64,5 +63,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/access_control_type.h b/src/type/access_control_type.h
similarity index 92%
rename from src/ast/type/access_control_type.h
rename to src/type/access_control_type.h
index e018b95..3e0da48 100644
--- a/src/ast/type/access_control_type.h
+++ b/src/type/access_control_type.h
@@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
-#define SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
+#ifndef SRC_TYPE_ACCESS_CONTROL_TYPE_H_
+#define SRC_TYPE_ACCESS_CONTROL_TYPE_H_
#include <string>
#include "src/ast/access_control.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// An access control type. Holds an access setting and pointer to another type.
@@ -71,7 +70,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_ACCESS_CONTROL_TYPE_H_
+#endif // SRC_TYPE_ACCESS_CONTROL_TYPE_H_
diff --git a/src/ast/type/access_control_type_test.cc b/src/type/access_control_type_test.cc
similarity index 79%
rename from src/ast/type/access_control_type_test.cc
rename to src/type/access_control_type_test.cc
index 882f144..5392336 100644
--- a/src/ast/type/access_control_type_test.cc
+++ b/src/type/access_control_type_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/access_control_type.h"
+#include "src/type/access_control_type.h"
#include <memory>
#include <utility>
@@ -22,20 +22,19 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -106,23 +105,25 @@
TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
U32 u32;
- Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array array(&u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
- Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array array(&u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)})},
+ ast::StructDecorationList{});
auto* struct_type = ty.struct_("struct_type", str);
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
@@ -138,23 +139,25 @@
TEST_F(AccessControlTest, BaseAlignmentArray) {
U32 u32;
- Array array(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array array(&u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
U32 u32;
- Array array(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array array(&u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, BaseAlignmentStruct) {
auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)})},
+ ast::StructDecorationList{});
auto* struct_type = ty.struct_("struct_type", str);
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
@@ -164,5 +167,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/alias_type.cc b/src/type/alias_type.cc
similarity index 91%
rename from src/ast/type/alias_type.cc
rename to src/type/alias_type.cc
index b8632de..1a21fea 100644
--- a/src/ast/type/alias_type.cc
+++ b/src/type/alias_type.cc
@@ -12,17 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/alias_type.h"
+#include "src/type/alias_type.h"
#include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Alias);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Alias);
namespace tint {
-namespace ast {
namespace type {
Alias::Alias(const Symbol& sym, Type* subtype)
@@ -51,5 +50,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/alias_type.h b/src/type/alias_type.h
similarity index 91%
rename from src/ast/type/alias_type.h
rename to src/type/alias_type.h
index 7bc3bc2..c1f858d 100644
--- a/src/ast/type/alias_type.h
+++ b/src/type/alias_type.h
@@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_ALIAS_TYPE_H_
-#define SRC_AST_TYPE_ALIAS_TYPE_H_
+#ifndef SRC_TYPE_ALIAS_TYPE_H_
+#define SRC_TYPE_ALIAS_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A type alias type. Holds a name and pointer to another type.
@@ -65,7 +64,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_ALIAS_TYPE_H_
+#endif // SRC_TYPE_ALIAS_TYPE_H_
diff --git a/src/ast/type/alias_type_test.cc b/src/type/alias_type_test.cc
similarity index 79%
rename from src/ast/type/alias_type_test.cc
rename to src/type/alias_type_test.cc
index c1c59a4..52430f2 100644
--- a/src/ast/type/alias_type_test.cc
+++ b/src/type/alias_type_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/alias_type.h"
+#include "src/type/alias_type.h"
#include <memory>
#include <utility>
@@ -22,20 +22,19 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -104,7 +103,7 @@
TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
auto* a = ty.alias("a_type", ty.u32);
auto* aa = ty.alias("aa_type", a);
- Pointer paa{aa, StorageClass::kUniform};
+ Pointer paa{aa, ast::StorageClass::kUniform};
auto* apaa = ty.alias("paa_type", &paa);
auto* aapaa = ty.alias("aapaa_type", apaa);
@@ -117,8 +116,8 @@
auto* a = ty.alias("a_type", ty.u32);
auto* aa = ty.alias("aa_type", a);
- Pointer paa{aa, StorageClass::kUniform};
- Pointer ppaa{&paa, StorageClass::kUniform};
+ Pointer paa{aa, ast::StorageClass::kUniform};
+ Pointer ppaa{&paa, ast::StorageClass::kUniform};
auto* appaa = ty.alias("appaa_type", &ppaa);
EXPECT_EQ(appaa->UnwrapAll(), &paa);
}
@@ -126,11 +125,11 @@
TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
auto* a = ty.alias("a_type", ty.u32);
auto* aa = ty.alias("aa_type", a);
- Pointer paa{aa, StorageClass::kUniform};
+ Pointer paa{aa, ast::StorageClass::kUniform};
auto* apaa = ty.alias("apaa_type", &paa);
auto* aapaa = ty.alias("aapaa_type", apaa);
- Pointer paapaa{aapaa, StorageClass::kUniform};
+ Pointer paapaa{aapaa, ast::StorageClass::kUniform};
auto* apaapaa = ty.alias("apaapaa_type", &paapaa);
EXPECT_EQ(apaapaa->UnwrapAll(), &paa);
@@ -138,13 +137,13 @@
TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
- Pointer pa{&a, StorageClass::kUniform};
+ Pointer pa{&a, ast::StorageClass::kUniform};
EXPECT_EQ(pa.type(), &a);
EXPECT_EQ(pa.UnwrapAll(), ty.u32);
}
TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
- Pointer p{ty.u32, StorageClass::kUniform};
+ Pointer p{ty.u32, ast::StorageClass::kUniform};
AccessControl a{ast::AccessControl::kReadOnly, &p};
EXPECT_EQ(a.type(), &p);
@@ -158,8 +157,8 @@
TEST_F(AliasTest, MinBufferBindingSizeArray) {
Array array(ty.u32, 4,
- ArrayDecorationList{
- create<StrideDecoration>(4),
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
});
auto* alias = ty.alias("alias", &array);
EXPECT_EQ(16u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@@ -167,8 +166,8 @@
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
Array array(ty.u32, 0,
- ArrayDecorationList{
- create<StrideDecoration>(4),
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
});
auto* alias = ty.alias("alias", &array);
EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@@ -176,9 +175,9 @@
TEST_F(AliasTest, MinBufferBindingSizeStruct) {
auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)})},
+ ast::StructDecorationList{});
auto* struct_type = ty.struct_("struct_type", str);
auto* alias = ty.alias("alias", struct_type);
@@ -193,8 +192,8 @@
TEST_F(AliasTest, BaseAlignmentArray) {
Array array(ty.u32, 4,
- ArrayDecorationList{
- create<StrideDecoration>(4),
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
});
auto* alias = ty.alias("alias", &array);
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
@@ -202,8 +201,8 @@
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
Array array(ty.u32, 0,
- ArrayDecorationList{
- create<StrideDecoration>(4),
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
});
auto* alias = ty.alias("alias", &array);
EXPECT_EQ(16u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
@@ -211,9 +210,9 @@
TEST_F(AliasTest, BaseAlignmentStruct) {
auto* str = create<ast::Struct>(
- StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
- Member("bar", ty.u32, {MemberOffset(4)})},
- StructDecorationList{});
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)})},
+ ast::StructDecorationList{});
auto* struct_type = ty.struct_("struct_type", str);
auto* alias = ty.alias("alias", struct_type);
@@ -223,5 +222,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/array_type.cc b/src/type/array_type.cc
similarity index 89%
rename from src/ast/type/array_type.cc
rename to src/type/array_type.cc
index be71ad7..7793f03 100644
--- a/src/ast/type/array_type.cc
+++ b/src/type/array_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/array_type.h"
+#include "src/type/array_type.h"
#include <cmath>
#include <memory>
@@ -20,15 +20,14 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
#include "src/ast/stride_decoration.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/vector_type.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Array);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Array);
namespace tint {
-namespace ast {
namespace type {
-Array::Array(Type* subtype, uint32_t size, ArrayDecorationList decorations)
+Array::Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations)
: subtype_(subtype), size_(size), decos_(decorations) {}
Array::Array(Array&&) = default;
@@ -68,7 +67,7 @@
uint32_t Array::array_stride() const {
for (auto* deco : decos_) {
- if (auto* stride = deco->As<StrideDecoration>()) {
+ if (auto* stride = deco->As<ast::StrideDecoration>()) {
return stride->stride();
}
}
@@ -77,7 +76,7 @@
bool Array::has_array_stride() const {
for (auto* deco : decos_) {
- if (deco->Is<StrideDecoration>()) {
+ if (deco->Is<ast::StrideDecoration>()) {
return true;
}
}
@@ -102,5 +101,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/array_type.h b/src/type/array_type.h
similarity index 87%
rename from src/ast/type/array_type.h
rename to src/type/array_type.h
index eafb204..404fa3b 100644
--- a/src/ast/type/array_type.h
+++ b/src/type/array_type.h
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_ARRAY_TYPE_H_
-#define SRC_AST_TYPE_ARRAY_TYPE_H_
+#ifndef SRC_TYPE_ARRAY_TYPE_H_
+#define SRC_TYPE_ARRAY_TYPE_H_
#include <assert.h>
@@ -21,10 +21,9 @@
#include <utility>
#include "src/ast/array_decoration.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// An array type. If size is zero then it is a runtime array.
@@ -35,7 +34,7 @@
/// @param size the number of elements in the array. `0` represents a
/// runtime-sized array.
/// @param decorations the array decorations
- Array(Type* subtype, uint32_t size, ArrayDecorationList decorations);
+ Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations);
/// Move constructor
Array(Array&&);
~Array() override;
@@ -55,7 +54,7 @@
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
/// @returns the array decorations
- const ArrayDecorationList& decorations() const { return decos_; }
+ const ast::ArrayDecorationList& decorations() const { return decos_; }
/// @returns the array stride or 0 if none set.
uint32_t array_stride() const;
@@ -78,11 +77,10 @@
private:
Type* const subtype_;
uint32_t const size_;
- ArrayDecorationList const decos_;
+ ast::ArrayDecorationList const decos_;
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_ARRAY_TYPE_H_
+#endif // SRC_TYPE_ARRAY_TYPE_H_
diff --git a/src/ast/type/array_type_test.cc b/src/type/array_type_test.cc
similarity index 70%
rename from src/ast/type/array_type_test.cc
rename to src/type/array_type_test.cc
index 8d61e27..54bc12a 100644
--- a/src/ast/type/array_type_test.cc
+++ b/src/type/array_type_test.cc
@@ -12,26 +12,25 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/array_type.h"
+#include "src/type/array_type.h"
#include <memory>
#include <utility>
#include "src/ast/stride_decoration.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -39,7 +38,7 @@
TEST_F(ArrayTest, CreateSizedArray) {
U32 u32;
- Array arr{&u32, 3, ArrayDecorationList{}};
+ Array arr{&u32, 3, ast::ArrayDecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 3u);
EXPECT_TRUE(arr.Is<Array>());
@@ -48,7 +47,7 @@
TEST_F(ArrayTest, CreateRuntimeArray) {
U32 u32;
- Array arr{&u32, 0, ArrayDecorationList{}};
+ Array arr{&u32, 0, ast::ArrayDecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 0u);
EXPECT_TRUE(arr.Is<Array>());
@@ -58,7 +57,7 @@
TEST_F(ArrayTest, Is) {
I32 i32;
- Array arr{&i32, 3, ArrayDecorationList{}};
+ Array arr{&i32, 3, ast::ArrayDecorationList{}};
Type* ty = &arr;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@@ -77,55 +76,59 @@
TEST_F(ArrayTest, TypeName) {
I32 i32;
- Array arr{&i32, 0, ArrayDecorationList{}};
+ Array arr{&i32, 0, ast::ArrayDecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32");
}
TEST_F(ArrayTest, TypeName_RuntimeArray) {
I32 i32;
- Array arr{&i32, 3, ArrayDecorationList{}};
+ Array arr{&i32, 3, ast::ArrayDecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32_3");
}
TEST_F(ArrayTest, TypeName_WithStride) {
I32 i32;
- Array arr{&i32, 3, ArrayDecorationList{create<StrideDecoration>(16)}};
+ Array arr{&i32, 3,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(16)}};
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
}
TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{});
+ Array arr(&u32, 4, ast::ArrayDecorationList{});
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, MinBufferBindingSizeArray) {
U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array arr(&u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
- Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array arr(&u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, BaseAlignmentArray) {
U32 u32;
- Array arr(&u32, 4, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array arr(&u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
}
TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
U32 u32;
- Array arr(&u32, 0, ArrayDecorationList{create<StrideDecoration>(4)});
+ Array arr(&u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
}
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/bool_type.cc b/src/type/bool_type.cc
similarity index 88%
rename from src/ast/type/bool_type.cc
rename to src/type/bool_type.cc
index 7c26c86..ead02f8 100644
--- a/src/ast/type/bool_type.cc
+++ b/src/type/bool_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Bool);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Bool);
namespace tint {
-namespace ast {
namespace type {
Bool::Bool() = default;
@@ -38,5 +37,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/bool_type.h b/src/type/bool_type.h
similarity index 86%
rename from src/ast/type/bool_type.h
rename to src/type/bool_type.h
index 11f5338..fa3f01d 100644
--- a/src/ast/type/bool_type.h
+++ b/src/type/bool_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_BOOL_TYPE_H_
-#define SRC_AST_TYPE_BOOL_TYPE_H_
+#ifndef SRC_TYPE_BOOL_TYPE_H_
+#define SRC_TYPE_BOOL_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A boolean type
@@ -42,7 +41,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_BOOL_TYPE_H_
+#endif // SRC_TYPE_BOOL_TYPE_H_
diff --git a/src/ast/type/bool_type_test.cc b/src/type/bool_type_test.cc
similarity index 74%
rename from src/ast/type/bool_type_test.cc
rename to src/type/bool_type_test.cc
index d6c6f25..552857b 100644
--- a/src/ast/type/bool_type_test.cc
+++ b/src/type/bool_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/bool_type.h"
+#include "src/type/bool_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -63,5 +62,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/depth_texture_type.cc b/src/type/depth_texture_type.cc
similarity index 91%
rename from src/ast/type/depth_texture_type.cc
rename to src/type/depth_texture_type.cc
index 95b55aa..770ced4 100644
--- a/src/ast/type/depth_texture_type.cc
+++ b/src/type/depth_texture_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/depth_texture_type.h"
+#include "src/type/depth_texture_type.h"
#include <cassert>
#include <sstream>
@@ -20,10 +20,9 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::DepthTexture);
+TINT_INSTANTIATE_CLASS_ID(tint::type::DepthTexture);
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -57,5 +56,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/depth_texture_type.h b/src/type/depth_texture_type.h
similarity index 85%
rename from src/ast/type/depth_texture_type.h
rename to src/type/depth_texture_type.h
index 02f07d3..43eed57 100644
--- a/src/ast/type/depth_texture_type.h
+++ b/src/type/depth_texture_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
+#ifndef SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
+#define SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
#include <string>
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
-namespace ast {
namespace type {
/// A depth texture type.
@@ -43,7 +42,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_DEPTH_TEXTURE_TYPE_H_
+#endif // SRC_TYPE_DEPTH_TEXTURE_TYPE_H_
diff --git a/src/ast/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc
similarity index 76%
rename from src/ast/type/depth_texture_type_test.cc
rename to src/type/depth_texture_type_test.cc
index b956f89..26be3e9 100644
--- a/src/ast/type/depth_texture_type_test.cc
+++ b/src/type/depth_texture_type_test.cc
@@ -12,25 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/depth_texture_type.h"
+#include "src/type/depth_texture_type.h"
-#include "src/ast/test_helper.h"
+#include "src/type/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -79,5 +78,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/f32_type.cc b/src/type/f32_type.cc
similarity index 89%
rename from src/ast/type/f32_type.cc
rename to src/type/f32_type.cc
index bfcdc69..4961187 100644
--- a/src/ast/type/f32_type.cc
+++ b/src/type/f32_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::F32);
+TINT_INSTANTIATE_CLASS_ID(tint::type::F32);
namespace tint {
-namespace ast {
namespace type {
F32::F32() = default;
@@ -46,5 +45,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/f32_type.h b/src/type/f32_type.h
similarity index 90%
rename from src/ast/type/f32_type.h
rename to src/type/f32_type.h
index 86187f3..55e4224 100644
--- a/src/ast/type/f32_type.h
+++ b/src/type/f32_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_F32_TYPE_H_
-#define SRC_AST_TYPE_F32_TYPE_H_
+#ifndef SRC_TYPE_F32_TYPE_H_
+#define SRC_TYPE_F32_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A float 32 type
@@ -52,7 +51,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_F32_TYPE_H_
+#endif // SRC_TYPE_F32_TYPE_H_
diff --git a/src/ast/type/f32_type_test.cc b/src/type/f32_type_test.cc
similarity index 75%
rename from src/ast/type/f32_type_test.cc
rename to src/type/f32_type_test.cc
index 0570b7e..7a25dc7 100644
--- a/src/ast/type/f32_type_test.cc
+++ b/src/type/f32_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -68,5 +67,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/i32_type.cc b/src/type/i32_type.cc
similarity index 89%
rename from src/ast/type/i32_type.cc
rename to src/type/i32_type.cc
index 6b47eb3..29fee5e 100644
--- a/src/ast/type/i32_type.cc
+++ b/src/type/i32_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::I32);
+TINT_INSTANTIATE_CLASS_ID(tint::type::I32);
namespace tint {
-namespace ast {
namespace type {
I32::I32() = default;
@@ -46,5 +45,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/i32_type.h b/src/type/i32_type.h
similarity index 90%
rename from src/ast/type/i32_type.h
rename to src/type/i32_type.h
index 104d593..cb4421f 100644
--- a/src/ast/type/i32_type.h
+++ b/src/type/i32_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_I32_TYPE_H_
-#define SRC_AST_TYPE_I32_TYPE_H_
+#ifndef SRC_TYPE_I32_TYPE_H_
+#define SRC_TYPE_I32_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A signed int 32 type.
@@ -52,7 +51,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_I32_TYPE_H_
+#endif // SRC_TYPE_I32_TYPE_H_
diff --git a/src/ast/type/i32_type_test.cc b/src/type/i32_type_test.cc
similarity index 75%
rename from src/ast/type/i32_type_test.cc
rename to src/type/i32_type_test.cc
index 0333d01..0fa098a 100644
--- a/src/ast/type/i32_type_test.cc
+++ b/src/type/i32_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -68,5 +67,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/matrix_type.cc b/src/type/matrix_type.cc
similarity index 86%
rename from src/ast/type/matrix_type.cc
rename to src/type/matrix_type.cc
index 12eea45..f151654 100644
--- a/src/ast/type/matrix_type.cc
+++ b/src/type/matrix_type.cc
@@ -12,19 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/matrix_type.h"
+#include "src/type/matrix_type.h"
#include <assert.h>
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/array_type.h"
+#include "src/type/vector_type.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Matrix);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Matrix);
namespace tint {
-namespace ast {
namespace type {
Matrix::Matrix(Type* subtype, uint32_t rows, uint32_t columns)
@@ -52,7 +51,7 @@
uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
Vector vec(subtype_, rows_);
- Array arr(&vec, columns_, ArrayDecorationList{});
+ Array arr(&vec, columns_, ast::ArrayDecorationList{});
return arr.BaseAlignment(mem_layout);
}
@@ -61,5 +60,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/matrix_type.h b/src/type/matrix_type.h
similarity index 92%
rename from src/ast/type/matrix_type.h
rename to src/type/matrix_type.h
index 500f43e..d37a115 100644
--- a/src/ast/type/matrix_type.h
+++ b/src/type/matrix_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_MATRIX_TYPE_H_
-#define SRC_AST_TYPE_MATRIX_TYPE_H_
+#ifndef SRC_TYPE_MATRIX_TYPE_H_
+#define SRC_TYPE_MATRIX_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A matrix type
@@ -67,7 +66,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_MATRIX_TYPE_H_
+#endif // SRC_TYPE_MATRIX_TYPE_H_
diff --git a/src/ast/type/matrix_type_test.cc b/src/type/matrix_type_test.cc
similarity index 86%
rename from src/ast/type/matrix_type_test.cc
rename to src/type/matrix_type_test.cc
index fb4c1a7..c1b6c43 100644
--- a/src/ast/type/matrix_type_test.cc
+++ b/src/type/matrix_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/matrix_type.h"
+#include "src/type/matrix_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -124,5 +123,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/multisampled_texture_type.cc b/src/type/multisampled_texture_type.cc
similarity index 89%
rename from src/ast/type/multisampled_texture_type.cc
rename to src/type/multisampled_texture_type.cc
index 2ec4320..16bb04e 100644
--- a/src/ast/type/multisampled_texture_type.cc
+++ b/src/type/multisampled_texture_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/multisampled_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
#include <cassert>
#include <sstream>
@@ -20,10 +20,9 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::MultisampledTexture);
+TINT_INSTANTIATE_CLASS_ID(tint::type::MultisampledTexture);
namespace tint {
-namespace ast {
namespace type {
MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type)
@@ -46,5 +45,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/multisampled_texture_type.h b/src/type/multisampled_texture_type.h
similarity index 86%
rename from src/ast/type/multisampled_texture_type.h
rename to src/type/multisampled_texture_type.h
index 4fb45e2..afe7d6b 100644
--- a/src/ast/type/multisampled_texture_type.h
+++ b/src/type/multisampled_texture_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
+#ifndef SRC_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
+#define SRC_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
#include <string>
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
-namespace ast {
namespace type {
/// A multisampled texture type.
@@ -50,7 +49,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
+#endif // SRC_TYPE_MULTISAMPLED_TEXTURE_TYPE_H_
diff --git a/src/ast/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc
similarity index 78%
rename from src/ast/type/multisampled_texture_type_test.cc
rename to src/type/multisampled_texture_type_test.cc
index 99bb0e5..788d7df 100644
--- a/src/ast/type/multisampled_texture_type_test.cc
+++ b/src/type/multisampled_texture_type_test.cc
@@ -12,25 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/multisampled_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -91,5 +90,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/pointer_type.cc b/src/type/pointer_type.cc
similarity index 85%
rename from src/ast/type/pointer_type.cc
rename to src/type/pointer_type.cc
index 67c0cfa..5077d33 100644
--- a/src/ast/type/pointer_type.cc
+++ b/src/type/pointer_type.cc
@@ -12,18 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/pointer_type.h"
+#include "src/type/pointer_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Pointer);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Pointer);
namespace tint {
-namespace ast {
namespace type {
-Pointer::Pointer(Type* subtype, StorageClass storage_class)
+Pointer::Pointer(Type* subtype, ast::StorageClass storage_class)
: subtype_(subtype), storage_class_(storage_class) {}
std::string Pointer::type_name() const {
@@ -41,5 +40,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/pointer_type.h b/src/type/pointer_type.h
similarity index 80%
rename from src/ast/type/pointer_type.h
rename to src/type/pointer_type.h
index 7a9a61b..bf64785 100644
--- a/src/ast/type/pointer_type.h
+++ b/src/type/pointer_type.h
@@ -12,17 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_POINTER_TYPE_H_
-#define SRC_AST_TYPE_POINTER_TYPE_H_
+#ifndef SRC_TYPE_POINTER_TYPE_H_
+#define SRC_TYPE_POINTER_TYPE_H_
#include <sstream>
#include <string>
#include "src/ast/storage_class.h"
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A pointer type.
@@ -31,7 +30,7 @@
/// Construtor
/// @param subtype the pointee type
/// @param storage_class the storage class of the pointer
- explicit Pointer(Type* subtype, StorageClass storage_class);
+ explicit Pointer(Type* subtype, ast::StorageClass storage_class);
/// Move constructor
Pointer(Pointer&&);
~Pointer() override;
@@ -39,7 +38,7 @@
/// @returns the pointee type
Type* type() const { return subtype_; }
/// @returns the storage class of the pointer
- StorageClass storage_class() const { return storage_class_; }
+ ast::StorageClass storage_class() const { return storage_class_; }
/// @returns the name for this type
std::string type_name() const override;
@@ -51,11 +50,10 @@
private:
Type* const subtype_;
- StorageClass const storage_class_;
+ ast::StorageClass const storage_class_;
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_POINTER_TYPE_H_
+#endif // SRC_TYPE_POINTER_TYPE_H_
diff --git a/src/ast/type/pointer_type_test.cc b/src/type/pointer_type_test.cc
similarity index 67%
rename from src/ast/type/pointer_type_test.cc
rename to src/type/pointer_type_test.cc
index 95a4c87..7b6c6a8 100644
--- a/src/ast/type/pointer_type_test.cc
+++ b/src/type/pointer_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/pointer_type.h"
+#include "src/type/pointer_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -35,14 +34,14 @@
TEST_F(PointerTest, Creation) {
I32 i32;
- Pointer p{&i32, StorageClass::kStorage};
+ Pointer p{&i32, ast::StorageClass::kStorage};
EXPECT_EQ(p.type(), &i32);
- EXPECT_EQ(p.storage_class(), StorageClass::kStorage);
+ EXPECT_EQ(p.storage_class(), ast::StorageClass::kStorage);
}
TEST_F(PointerTest, Is) {
I32 i32;
- Pointer p{&i32, StorageClass::kFunction};
+ Pointer p{&i32, ast::StorageClass::kFunction};
Type* ty = &p;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@@ -61,11 +60,10 @@
TEST_F(PointerTest, TypeName) {
I32 i32;
- Pointer p{&i32, StorageClass::kWorkgroup};
+ Pointer p{&i32, ast::StorageClass::kWorkgroup};
EXPECT_EQ(p.type_name(), "__ptr_workgroup__i32");
}
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/sampled_texture_type.cc b/src/type/sampled_texture_type.cc
similarity index 89%
rename from src/ast/type/sampled_texture_type.cc
rename to src/type/sampled_texture_type.cc
index 9a95c12..3d5d00a 100644
--- a/src/ast/type/sampled_texture_type.cc
+++ b/src/type/sampled_texture_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/sampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
#include <cassert>
#include <sstream>
@@ -20,10 +20,9 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::SampledTexture);
+TINT_INSTANTIATE_CLASS_ID(tint::type::SampledTexture);
namespace tint {
-namespace ast {
namespace type {
SampledTexture::SampledTexture(TextureDimension dim, Type* type)
@@ -46,5 +45,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/sampled_texture_type.h b/src/type/sampled_texture_type.h
similarity index 87%
rename from src/ast/type/sampled_texture_type.h
rename to src/type/sampled_texture_type.h
index cdc93fa..3211050 100644
--- a/src/ast/type/sampled_texture_type.h
+++ b/src/type/sampled_texture_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
+#ifndef SRC_TYPE_SAMPLED_TEXTURE_TYPE_H_
+#define SRC_TYPE_SAMPLED_TEXTURE_TYPE_H_
#include <string>
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
-namespace ast {
namespace type {
/// A sampled texture type.
@@ -50,7 +49,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_SAMPLED_TEXTURE_TYPE_H_
+#endif // SRC_TYPE_SAMPLED_TEXTURE_TYPE_H_
diff --git a/src/ast/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc
similarity index 78%
rename from src/ast/type/sampled_texture_type_test.cc
rename to src/type/sampled_texture_type_test.cc
index 5c6bcb4..a80312f 100644
--- a/src/ast/type/sampled_texture_type_test.cc
+++ b/src/type/sampled_texture_type_test.cc
@@ -12,24 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/sampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -89,5 +88,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/sampler_type.cc b/src/type/sampler_type.cc
similarity index 91%
rename from src/ast/type/sampler_type.cc
rename to src/type/sampler_type.cc
index f1070d4..d4b0ae7 100644
--- a/src/ast/type/sampler_type.cc
+++ b/src/type/sampler_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/sampler_type.h"
+#include "src/type/sampler_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Sampler);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Sampler);
namespace tint {
-namespace ast {
namespace type {
std::ostream& operator<<(std::ostream& out, SamplerKind kind) {
@@ -51,5 +50,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/sampler_type.h b/src/type/sampler_type.h
similarity index 90%
rename from src/ast/type/sampler_type.h
rename to src/type/sampler_type.h
index 28a60e8..8c71128 100644
--- a/src/ast/type/sampler_type.h
+++ b/src/type/sampler_type.h
@@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_SAMPLER_TYPE_H_
-#define SRC_AST_TYPE_SAMPLER_TYPE_H_
+#ifndef SRC_TYPE_SAMPLER_TYPE_H_
+#define SRC_TYPE_SAMPLER_TYPE_H_
#include <ostream>
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// The different kinds of samplers
@@ -62,7 +61,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_SAMPLER_TYPE_H_
+#endif // SRC_TYPE_SAMPLER_TYPE_H_
diff --git a/src/ast/type/sampler_type_test.cc b/src/type/sampler_type_test.cc
similarity index 79%
rename from src/ast/type/sampler_type_test.cc
rename to src/type/sampler_type_test.cc
index 9641aec..2648300 100644
--- a/src/ast/type/sampler_type_test.cc
+++ b/src/type/sampler_type_test.cc
@@ -12,23 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/sampler_type.h"
+#include "src/type/sampler_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -80,5 +79,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/storage_texture_type.cc b/src/type/storage_texture_type.cc
similarity index 96%
rename from src/ast/type/storage_texture_type.cc
rename to src/type/storage_texture_type.cc
index 3dc432c..1f175fd 100644
--- a/src/ast/type/storage_texture_type.cc
+++ b/src/type/storage_texture_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/storage_texture_type.h"
+#include "src/type/storage_texture_type.h"
#include <cassert>
#include <sstream>
@@ -20,10 +20,9 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::StorageTexture);
+TINT_INSTANTIATE_CLASS_ID(tint::type::StorageTexture);
namespace tint {
-namespace ast {
namespace type {
// Note, these names match the names in the WGSL spec. This behaviour is used
@@ -168,5 +167,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/storage_texture_type.h b/src/type/storage_texture_type.h
similarity index 88%
rename from src/ast/type/storage_texture_type.h
rename to src/type/storage_texture_type.h
index 2723a0f..51b147e 100644
--- a/src/ast/type/storage_texture_type.h
+++ b/src/type/storage_texture_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
+#ifndef SRC_TYPE_STORAGE_TEXTURE_TYPE_H_
+#define SRC_TYPE_STORAGE_TEXTURE_TYPE_H_
#include <string>
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
namespace tint {
-namespace ast {
namespace type {
/// The image format in the storage texture
@@ -70,8 +69,7 @@
/// Constructor
/// @param dim the dimensionality of the texture
/// @param format the image format of the texture
- StorageTexture(TextureDimension dim,
- ImageFormat format);
+ StorageTexture(TextureDimension dim, ImageFormat format);
/// Move constructor
StorageTexture(StorageTexture&&);
@@ -101,7 +99,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_STORAGE_TEXTURE_TYPE_H_
+#endif // SRC_TYPE_STORAGE_TEXTURE_TYPE_H_
diff --git a/src/ast/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc
similarity index 85%
rename from src/ast/type/storage_texture_type_test.cc
rename to src/type/storage_texture_type_test.cc
index d05d53d..7b327da 100644
--- a/src/ast/type/storage_texture_type_test.cc
+++ b/src/type/storage_texture_type_test.cc
@@ -12,28 +12,27 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/storage_texture_type.h"
+#include "src/type/storage_texture_type.h"
#include <memory>
#include "src/ast/identifier_expression.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -120,5 +119,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/struct_type.cc b/src/type/struct_type.cc
similarity index 89%
rename from src/ast/type/struct_type.cc
rename to src/type/struct_type.cc
index 24f5640..39d65db 100644
--- a/src/ast/type/struct_type.cc
+++ b/src/type/struct_type.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
#include <cmath>
#include <utility>
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/vector_type.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Struct);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Struct);
namespace tint {
-namespace ast {
namespace type {
Struct::Struct(const Symbol& sym, ast::Struct* impl)
@@ -88,5 +87,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/struct_type.h b/src/type/struct_type.h
similarity index 92%
rename from src/ast/type/struct_type.h
rename to src/type/struct_type.h
index e340f4bb..63fcaa2 100644
--- a/src/ast/type/struct_type.h
+++ b/src/type/struct_type.h
@@ -12,18 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_STRUCT_TYPE_H_
-#define SRC_AST_TYPE_STRUCT_TYPE_H_
+#ifndef SRC_TYPE_STRUCT_TYPE_H_
+#define SRC_TYPE_STRUCT_TYPE_H_
#include <memory>
#include <string>
#include "src/ast/struct.h"
-#include "src/ast/type/type.h"
#include "src/symbol.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A structure type
@@ -72,7 +71,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_STRUCT_TYPE_H_
+#endif // SRC_TYPE_STRUCT_TYPE_H_
diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc
new file mode 100644
index 0000000..2ed78a1
--- /dev/null
+++ b/src/type/struct_type_test.cc
@@ -0,0 +1,216 @@
+// Copyright 2020 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/type/struct_type.h"
+
+#include <utility>
+
+#include "src/ast/stride_decoration.h"
+#include "src/ast/struct_member.h"
+#include "src/ast/struct_member_decoration.h"
+#include "src/ast/struct_member_offset_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+
+namespace tint {
+namespace type {
+namespace {
+
+using StructTypeTest = TestHelper;
+
+TEST_F(StructTypeTest, Creation) {
+ auto* impl =
+ create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
+ auto* ptr = impl;
+ auto* s = ty.struct_("S", impl);
+ EXPECT_EQ(s->impl(), ptr);
+}
+
+TEST_F(StructTypeTest, Is) {
+ auto* impl =
+ create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
+ auto* s = ty.struct_("S", impl);
+ type::Type* ty = s;
+ EXPECT_FALSE(ty->Is<AccessControl>());
+ EXPECT_FALSE(ty->Is<Alias>());
+ EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<Bool>());
+ EXPECT_FALSE(ty->Is<F32>());
+ EXPECT_FALSE(ty->Is<I32>());
+ EXPECT_FALSE(ty->Is<Matrix>());
+ EXPECT_FALSE(ty->Is<Pointer>());
+ EXPECT_FALSE(ty->Is<Sampler>());
+ EXPECT_TRUE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<Texture>());
+ EXPECT_FALSE(ty->Is<U32>());
+ EXPECT_FALSE(ty->Is<Vector>());
+}
+
+TEST_F(StructTypeTest, TypeName) {
+ auto* impl =
+ create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
+ auto* s = ty.struct_("my_struct", impl);
+ EXPECT_EQ(s->type_name(), "__struct_tint_symbol_1");
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSize) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
+ Array arr(ty.u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
+
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)}),
+ Member("bar", &arr, {MemberOffset(8)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(32u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(24u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
+ Array arr(ty.u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
+
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)}),
+ Member("bar", ty.u32, {MemberOffset(8)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(12u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(8u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignment) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(8)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignmentArray) {
+ Array arr(ty.u32, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)}),
+ Member("bar", &arr, {MemberOffset(8)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
+ Array arr(ty.u32, 0,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
+ Member("bar", ty.u32, {MemberOffset(4)}),
+ Member("bar", ty.u32, {MemberOffset(8)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignmentVec2) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(8u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignmentVec3) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+TEST_F(StructTypeTest, BaseAlignmentVec4) {
+ auto* str = create<ast::Struct>(
+ ast::StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
+ ast::StructDecorationList{});
+ auto* s_ty = ty.struct_("s_ty", str);
+
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
+ EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
+}
+
+} // namespace
+} // namespace type
+} // namespace tint
diff --git a/src/type/test_helper.h b/src/type/test_helper.h
new file mode 100644
index 0000000..e161d04
--- /dev/null
+++ b/src/type/test_helper.h
@@ -0,0 +1,52 @@
+// Copyright 2020 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_TYPE_TEST_HELPER_H_
+#define SRC_TYPE_TEST_HELPER_H_
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "gtest/gtest.h"
+#include "src/ast/builder.h"
+#include "src/ast/module.h"
+#include "src/demangler.h"
+
+namespace tint {
+namespace type {
+
+/// Helper class for testing
+template <typename BASE>
+class TestHelperBase : public BASE, public ast::BuilderWithModule {
+ public:
+ /// Demangles the given string
+ /// @param s the string to demangle
+ /// @returns the demangled string
+ std::string demangle(const std::string& s) {
+ return demanger.Demangle(*mod, s);
+ }
+
+ /// A demangler
+ Demangler demanger;
+};
+using TestHelper = TestHelperBase<testing::Test>;
+
+template <typename T>
+using TestParamHelper = TestHelperBase<testing::TestWithParam<T>>;
+
+} // namespace type
+} // namespace tint
+
+#endif // SRC_TYPE_TEST_HELPER_H_
diff --git a/src/ast/type/texture_type.cc b/src/type/texture_type.cc
similarity index 90%
rename from src/ast/type/texture_type.cc
rename to src/type/texture_type.cc
index 58a0d47..c55c599 100644
--- a/src/ast/type/texture_type.cc
+++ b/src/type/texture_type.cc
@@ -12,18 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
#include <cassert>
#include <ostream>
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Texture);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Texture);
namespace tint {
-namespace ast {
namespace type {
std::ostream& operator<<(std::ostream& out, TextureDimension dim) {
@@ -97,5 +96,4 @@
Texture::~Texture() = default;
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/texture_type.h b/src/type/texture_type.h
similarity index 91%
rename from src/ast/type/texture_type.h
rename to src/type/texture_type.h
index 495afd9..32ea8a0 100644
--- a/src/ast/type/texture_type.h
+++ b/src/type/texture_type.h
@@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_TEXTURE_TYPE_H_
-#define SRC_AST_TYPE_TEXTURE_TYPE_H_
+#ifndef SRC_TYPE_TEXTURE_TYPE_H_
+#define SRC_TYPE_TEXTURE_TYPE_H_
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// The dimensionality of the texture
@@ -73,7 +72,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_TEXTURE_TYPE_H_
+#endif // SRC_TYPE_TEXTURE_TYPE_H_
diff --git a/src/ast/type/texture_type_test.cc b/src/type/texture_type_test.cc
similarity index 94%
rename from src/ast/type/texture_type_test.cc
rename to src/type/texture_type_test.cc
index 3ed1921..33a2c43 100644
--- a/src/ast/type/texture_type_test.cc
+++ b/src/type/texture_type_test.cc
@@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/texture_type.h"
+#include "src/type/texture_type.h"
-#include "src/ast/test_helper.h"
+#include "src/type/test_helper.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -47,5 +46,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/type.cc b/src/type/type.cc
similarity index 79%
rename from src/ast/type/type.cc
rename to src/type/type.cc
index 329812f..623d076 100644
--- a/src/ast/type/type.cc
+++ b/src/type/type.cc
@@ -12,29 +12,28 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
#include <assert.h>
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Type);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Type);
namespace tint {
-namespace ast {
namespace type {
Type::Type() = default;
@@ -121,5 +120,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/type.h b/src/type/type.h
similarity index 94%
rename from src/ast/type/type.h
rename to src/type/type.h
index 536ddd1..adbd9a1 100644
--- a/src/ast/type/type.h
+++ b/src/type/type.h
@@ -12,21 +12,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_TYPE_H_
-#define SRC_AST_TYPE_TYPE_H_
+#ifndef SRC_TYPE_TYPE_H_
+#define SRC_TYPE_TYPE_H_
#include <string>
#include "src/castable.h"
namespace tint {
-namespace ast {
+namespace ast {
class Module;
class CloneContext;
+} // namespace ast
namespace type {
+using CloneContext = ast::CloneContext; // TEMP
+
/// Supported memory layouts for calculating sizes
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
@@ -40,7 +43,7 @@
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
- virtual Type* Clone(CloneContext* ctx) const = 0;
+ virtual Type* Clone(ast::CloneContext* ctx) const = 0;
/// @returns the name for this type. The type name is unique over all types.
virtual std::string type_name() const = 0;
@@ -105,13 +108,12 @@
/// @param t the `Type` to clone (if not null)
/// @return the cloned type
template <typename T>
- static T* Clone(Module* m, const T* t) {
+ static T* Clone(ast::Module* m, const T* t) {
return (t != nullptr) ? static_cast<T*>(t->Clone(m)) : nullptr;
}
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_TYPE_H_
+#endif // SRC_TYPE_TYPE_H_
diff --git a/src/ast/type_manager.cc b/src/type/type_manager.cc
similarity index 70%
rename from src/ast/type_manager.cc
rename to src/type/type_manager.cc
index 39f4e07..235819f 100644
--- a/src/ast/type_manager.cc
+++ b/src/type/type_manager.cc
@@ -12,23 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type_manager.h"
+#include "src/type/type_manager.h"
#include <utility>
namespace tint {
-namespace ast {
+namespace type {
-TypeManager::TypeManager() = default;
-TypeManager::TypeManager(TypeManager&&) = default;
-TypeManager& TypeManager::operator=(TypeManager&& rhs) = default;
-TypeManager::~TypeManager() = default;
+Manager::Manager() = default;
+Manager::Manager(Manager&&) = default;
+Manager& Manager::operator=(Manager&& rhs) = default;
+Manager::~Manager() = default;
-void TypeManager::Reset() {
+void Manager::Reset() {
types_.clear();
}
-type::Type* TypeManager::Get(std::unique_ptr<type::Type> type) {
+type::Type* Manager::Get(std::unique_ptr<type::Type> type) {
auto name = type->type_name();
if (types_.find(name) == types_.end()) {
@@ -37,5 +37,5 @@
return types_.find(name)->second.get();
}
-} // namespace ast
+} // namespace type
} // namespace tint
diff --git a/src/ast/type_manager.h b/src/type/type_manager.h
similarity index 82%
rename from src/ast/type_manager.h
rename to src/type/type_manager.h
index f428ac9..5e28355 100644
--- a/src/ast/type_manager.h
+++ b/src/type/type_manager.h
@@ -12,35 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_MANAGER_H_
-#define SRC_AST_TYPE_MANAGER_H_
+#ifndef SRC_TYPE_TYPE_MANAGER_H_
+#define SRC_TYPE_TYPE_MANAGER_H_
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
+namespace type {
/// The type manager holds all the pointers to the known types.
-class TypeManager {
+class Manager {
public:
/// Constructor
- TypeManager();
+ Manager();
/// Move constructor
- TypeManager(TypeManager&&);
+ Manager(Manager&&);
/// Move assignment operator
- /// @param rhs the TypeManager to move
- /// @return this TypeManager
- TypeManager& operator=(TypeManager&& rhs);
+ /// @param rhs the Manager to move
+ /// @return this Manager
+ Manager& operator=(Manager&& rhs);
/// Destructor
- ~TypeManager();
+ ~Manager();
/// Clears all registered types.
void Reset();
@@ -69,7 +69,7 @@
std::unordered_map<std::string, std::unique_ptr<type::Type>> types_;
};
-} // namespace ast
+} // namespace type
} // namespace tint
-#endif // SRC_AST_TYPE_MANAGER_H_
+#endif // SRC_TYPE_TYPE_MANAGER_H_
diff --git a/src/ast/type_manager_test.cc b/src/type/type_manager_test.cc
similarity index 62%
rename from src/ast/type_manager_test.cc
rename to src/type/type_manager_test.cc
index f78a61f..d8cf495 100644
--- a/src/ast/type_manager_test.cc
+++ b/src/type/type_manager_test.cc
@@ -12,61 +12,60 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type_manager.h"
+#include "src/type/type_manager.h"
#include "gtest/gtest.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
namespace tint {
-namespace ast {
+namespace type {
namespace {
using TypeManagerTest = testing::Test;
TEST_F(TypeManagerTest, GetUnregistered) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
+ Manager tm;
+ auto* t = tm.Get(std::make_unique<I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
+ EXPECT_TRUE(t->Is<I32>());
}
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
+ Manager tm;
+ auto* t = tm.Get(std::make_unique<I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
+ EXPECT_TRUE(t->Is<I32>());
- auto* t2 = tm.Get(std::make_unique<type::I32>());
+ auto* t2 = tm.Get(std::make_unique<I32>());
EXPECT_EQ(t, t2);
}
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
+ Manager tm;
+ auto* t = tm.Get(std::make_unique<I32>());
ASSERT_NE(t, nullptr);
- EXPECT_TRUE(t->Is<type::I32>());
+ EXPECT_TRUE(t->Is<I32>());
- auto* t2 = tm.Get(std::make_unique<type::U32>());
+ auto* t2 = tm.Get(std::make_unique<U32>());
ASSERT_NE(t2, nullptr);
EXPECT_NE(t, t2);
- EXPECT_TRUE(t2->Is<type::U32>());
+ EXPECT_TRUE(t2->Is<U32>());
}
TEST_F(TypeManagerTest, ResetClearsPreviousData) {
- TypeManager tm;
- auto* t = tm.Get(std::make_unique<type::I32>());
+ Manager tm;
+ auto* t = tm.Get(std::make_unique<I32>());
ASSERT_NE(t, nullptr);
EXPECT_FALSE(tm.types().empty());
tm.Reset();
EXPECT_TRUE(tm.types().empty());
- auto* t2 = tm.Get(std::make_unique<type::I32>());
+ auto* t2 = tm.Get(std::make_unique<I32>());
ASSERT_NE(t2, nullptr);
}
} // namespace
-} // namespace ast
+} // namespace type
} // namespace tint
diff --git a/src/ast/type/u32_type.cc b/src/type/u32_type.cc
similarity index 89%
rename from src/ast/type/u32_type.cc
rename to src/type/u32_type.cc
index 37364d7..fd87b36 100644
--- a/src/ast/type/u32_type.cc
+++ b/src/type/u32_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/u32_type.h"
+#include "src/type/u32_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::U32);
+TINT_INSTANTIATE_CLASS_ID(tint::type::U32);
namespace tint {
-namespace ast {
namespace type {
U32::U32() = default;
@@ -46,5 +45,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/u32_type.h b/src/type/u32_type.h
similarity index 90%
rename from src/ast/type/u32_type.h
rename to src/type/u32_type.h
index 9e04155..77d1eda 100644
--- a/src/ast/type/u32_type.h
+++ b/src/type/u32_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_U32_TYPE_H_
-#define SRC_AST_TYPE_U32_TYPE_H_
+#ifndef SRC_TYPE_U32_TYPE_H_
+#define SRC_TYPE_U32_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A unsigned int 32 type.
@@ -52,7 +51,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_U32_TYPE_H_
+#endif // SRC_TYPE_U32_TYPE_H_
diff --git a/src/ast/type/u32_type_test.cc b/src/type/u32_type_test.cc
similarity index 74%
rename from src/ast/type/u32_type_test.cc
rename to src/type/u32_type_test.cc
index bf3a56b..e0390ce 100644
--- a/src/ast/type/u32_type_test.cc
+++ b/src/type/u32_type_test.cc
@@ -12,23 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/u32_type.h"
+#include "src/type/u32_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/vector_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -69,5 +68,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/vector_type.cc b/src/type/vector_type.cc
similarity index 92%
rename from src/ast/type/vector_type.cc
rename to src/type/vector_type.cc
index 3697e4e..b56273b 100644
--- a/src/ast/type/vector_type.cc
+++ b/src/type/vector_type.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/vector_type.h"
+#include "src/type/vector_type.h"
#include <assert.h>
#include <cmath>
@@ -20,10 +20,9 @@
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Vector);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Vector);
namespace tint {
-namespace ast {
namespace type {
Vector::Vector(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {
@@ -58,5 +57,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/vector_type.h b/src/type/vector_type.h
similarity index 91%
rename from src/ast/type/vector_type.h
rename to src/type/vector_type.h
index 4228c59..e9f1af5 100644
--- a/src/ast/type/vector_type.h
+++ b/src/type/vector_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_VECTOR_TYPE_H_
-#define SRC_AST_TYPE_VECTOR_TYPE_H_
+#ifndef SRC_TYPE_VECTOR_TYPE_H_
+#define SRC_TYPE_VECTOR_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A vector type.
@@ -63,7 +62,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_VECTOR_TYPE_H_
+#endif // SRC_TYPE_VECTOR_TYPE_H_
diff --git a/src/ast/type/vector_type_test.cc b/src/type/vector_type_test.cc
similarity index 82%
rename from src/ast/type/vector_type_test.cc
rename to src/type/vector_type_test.cc
index 9b885ae..20656d7 100644
--- a/src/ast/type/vector_type_test.cc
+++ b/src/type/vector_type_test.cc
@@ -12,22 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/vector_type.h"
+#include "src/type/vector_type.h"
-#include "src/ast/test_helper.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/test_helper.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
namespace tint {
-namespace ast {
namespace type {
namespace {
@@ -103,5 +102,4 @@
} // namespace
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/void_type.cc b/src/type/void_type.cc
similarity index 88%
rename from src/ast/type/void_type.cc
rename to src/type/void_type.cc
index 62ce402..aa894a5 100644
--- a/src/ast/type/void_type.cc
+++ b/src/type/void_type.cc
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/ast/clone_context.h"
#include "src/ast/module.h"
-TINT_INSTANTIATE_CLASS_ID(tint::ast::type::Void);
+TINT_INSTANTIATE_CLASS_ID(tint::type::Void);
namespace tint {
-namespace ast {
namespace type {
Void::Void() = default;
@@ -38,5 +37,4 @@
}
} // namespace type
-} // namespace ast
} // namespace tint
diff --git a/src/ast/type/void_type.h b/src/type/void_type.h
similarity index 86%
rename from src/ast/type/void_type.h
rename to src/type/void_type.h
index 8631188..1207808 100644
--- a/src/ast/type/void_type.h
+++ b/src/type/void_type.h
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_TYPE_VOID_TYPE_H_
-#define SRC_AST_TYPE_VOID_TYPE_H_
+#ifndef SRC_TYPE_VOID_TYPE_H_
+#define SRC_TYPE_VOID_TYPE_H_
#include <string>
-#include "src/ast/type/type.h"
+#include "src/type/type.h"
namespace tint {
-namespace ast {
namespace type {
/// A void type
@@ -42,7 +41,6 @@
};
} // namespace type
-} // namespace ast
} // namespace tint
-#endif // SRC_AST_TYPE_VOID_TYPE_H_
+#endif // SRC_TYPE_VOID_TYPE_H_
diff --git a/src/type_determiner.cc b/src/type_determiner.cc
index 7019202..6dcce00 100644
--- a/src/type_determiner.cc
+++ b/src/type_determiner.cc
@@ -38,24 +38,24 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
@@ -89,10 +89,10 @@
}
bool TypeDeterminer::Determine() {
- std::vector<ast::type::StorageTexture*> storage_textures;
+ std::vector<type::StorageTexture*> storage_textures;
for (auto& it : mod_->types()) {
if (auto* storage =
- it.second->UnwrapIfNeeded()->As<ast::type::StorageTexture>()) {
+ it.second->UnwrapIfNeeded()->As<type::StorageTexture>()) {
storage_textures.emplace_back(storage);
}
}
@@ -334,13 +334,13 @@
auto* res = expr->array()->result_type();
auto* parent_type = res->UnwrapAll();
- ast::type::Type* ret = nullptr;
- if (auto* arr = parent_type->As<ast::type::Array>()) {
+ type::Type* ret = nullptr;
+ if (auto* arr = parent_type->As<type::Array>()) {
ret = arr->type();
- } else if (auto* vec = parent_type->As<ast::type::Vector>()) {
+ } else if (auto* vec = parent_type->As<type::Vector>()) {
ret = vec->type();
- } else if (auto* mat = parent_type->As<ast::type::Matrix>()) {
- ret = mod_->create<ast::type::Vector>(mat->type(), mat->rows());
+ } else if (auto* mat = parent_type->As<type::Matrix>()) {
+ ret = mod_->create<type::Vector>(mat->type(), mat->rows());
} else {
set_error(expr->source(), "invalid parent type (" +
parent_type->type_name() +
@@ -349,14 +349,14 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<ast::type::Pointer>()) {
- ret = mod_->create<ast::type::Pointer>(ret, ptr->storage_class());
- } else if (auto* arr = parent_type->As<ast::type::Array>()) {
+ if (auto* ptr = res->As<type::Pointer>()) {
+ ret = mod_->create<type::Pointer>(ret, ptr->storage_class());
+ } else if (auto* arr = parent_type->As<type::Array>()) {
if (!arr->type()->is_scalar()) {
// If we extract a non-scalar from an array then we also get a pointer. We
// will generate a Function storage class variable to store this
// into.
- ret = mod_->create<ast::type::Pointer>(ret, ast::StorageClass::kFunction);
+ ret = mod_->create<type::Pointer>(ret, ast::StorageClass::kFunction);
}
}
expr->set_result_type(ret);
@@ -520,11 +520,11 @@
}
if (ident->intrinsic() == ast::Intrinsic::kAny ||
ident->intrinsic() == ast::Intrinsic::kAll) {
- expr->func()->set_result_type(mod_->create<ast::type::Bool>());
+ expr->func()->set_result_type(mod_->create<type::Bool>());
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kArrayLength) {
- expr->func()->set_result_type(mod_->create<ast::type::U32>());
+ expr->func()->set_result_type(mod_->create<type::U32>());
return true;
}
if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) {
@@ -534,12 +534,12 @@
return false;
}
- auto* bool_type = mod_->create<ast::type::Bool>();
+ auto* bool_type = mod_->create<type::Bool>();
auto* param_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded();
- if (auto* vec = param_type->As<ast::type::Vector>()) {
+ if (auto* vec = param_type->As<type::Vector>()) {
expr->func()->set_result_type(
- mod_->create<ast::type::Vector>(bool_type, vec->size()));
+ mod_->create<type::Vector>(bool_type, vec->size()));
} else {
expr->func()->set_result_type(bool_type);
}
@@ -549,16 +549,16 @@
ast::intrinsic::TextureSignature::Parameters param;
auto* texture_param = expr->params()[0];
- if (!texture_param->result_type()->UnwrapAll()->Is<ast::type::Texture>()) {
+ if (!texture_param->result_type()->UnwrapAll()->Is<type::Texture>()) {
set_error(expr->source(), "invalid first argument for " +
mod_->SymbolToName(ident->symbol()));
return false;
}
- ast::type::Texture* texture =
- texture_param->result_type()->UnwrapAll()->As<ast::type::Texture>();
+ type::Texture* texture =
+ texture_param->result_type()->UnwrapAll()->As<type::Texture>();
- bool is_array = ast::type::IsTextureArray(texture->dim());
- bool is_multisampled = texture->Is<ast::type::MultisampledTexture>();
+ bool is_array = type::IsTextureArray(texture->dim());
+ bool is_multisampled = texture->Is<type::MultisampledTexture>();
switch (ident->intrinsic()) {
case ast::Intrinsic::kTextureDimensions:
param.idx.texture = param.count++;
@@ -673,26 +673,26 @@
std::make_unique<ast::intrinsic::TextureSignature>(param));
// Set the function return type
- ast::type::Type* return_type = nullptr;
+ type::Type* return_type = nullptr;
switch (ident->intrinsic()) {
case ast::Intrinsic::kTextureDimensions: {
- auto* i32 = mod_->create<ast::type::I32>();
+ auto* i32 = mod_->create<type::I32>();
switch (texture->dim()) {
default:
set_error(expr->source(), "invalid texture dimensions");
break;
- case ast::type::TextureDimension::k1d:
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1d:
+ case type::TextureDimension::k1dArray:
return_type = i32;
break;
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k2dArray:
- return_type = mod_->create<ast::type::Vector>(i32, 2);
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k2dArray:
+ return_type = mod_->create<type::Vector>(i32, 2);
break;
- case ast::type::TextureDimension::k3d:
- case ast::type::TextureDimension::kCube:
- case ast::type::TextureDimension::kCubeArray:
- return_type = mod_->create<ast::type::Vector>(i32, 3);
+ case type::TextureDimension::k3d:
+ case type::TextureDimension::kCube:
+ case type::TextureDimension::kCubeArray:
+ return_type = mod_->create<type::Vector>(i32, 3);
break;
}
break;
@@ -700,29 +700,29 @@
case ast::Intrinsic::kTextureNumLayers:
case ast::Intrinsic::kTextureNumLevels:
case ast::Intrinsic::kTextureNumSamples:
- return_type = mod_->create<ast::type::I32>();
+ return_type = mod_->create<type::I32>();
break;
case ast::Intrinsic::kTextureStore:
- return_type = mod_->create<ast::type::Void>();
+ return_type = mod_->create<type::Void>();
break;
default: {
- if (texture->Is<ast::type::DepthTexture>()) {
- return_type = mod_->create<ast::type::F32>();
+ if (texture->Is<type::DepthTexture>()) {
+ return_type = mod_->create<type::F32>();
} else {
- ast::type::Type* type = nullptr;
- if (auto* storage = texture->As<ast::type::StorageTexture>()) {
+ type::Type* type = nullptr;
+ if (auto* storage = texture->As<type::StorageTexture>()) {
type = storage->type();
- } else if (auto* sampled = texture->As<ast::type::SampledTexture>()) {
+ } else if (auto* sampled = texture->As<type::SampledTexture>()) {
type = sampled->type();
} else if (auto* msampled =
- texture->As<ast::type::MultisampledTexture>()) {
+ texture->As<type::MultisampledTexture>()) {
type = msampled->type();
} else {
set_error(expr->source(),
"unknown texture type for texture sampling");
return false;
}
- return_type = mod_->create<ast::type::Vector>(type, 4);
+ return_type = mod_->create<type::Vector>(type, 4);
}
}
}
@@ -731,7 +731,7 @@
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kDot) {
- expr->func()->set_result_type(mod_->create<ast::type::F32>());
+ expr->func()->set_result_type(mod_->create<type::F32>());
return true;
}
if (ident->intrinsic() == ast::Intrinsic::kSelect) {
@@ -770,7 +770,7 @@
return false;
}
- std::vector<ast::type::Type*> result_types;
+ std::vector<type::Type*> result_types;
for (uint32_t i = 0; i < data->param_count; ++i) {
result_types.push_back(
expr->params()[i]->result_type()->UnwrapPtrIfNeeded());
@@ -813,7 +813,7 @@
return false;
}
if (data->vector_size > 0 &&
- result_types.back()->As<ast::type::Vector>()->size() !=
+ result_types.back()->As<type::Vector>()->size() !=
data->vector_size) {
set_error(expr->source(), "incorrect vector size for " +
mod_->SymbolToName(ident->symbol()) +
@@ -824,7 +824,7 @@
}
break;
case IntrinsicDataType::kMatrix:
- if (!result_types.back()->Is<ast::type::Matrix>()) {
+ if (!result_types.back()->Is<type::Matrix>()) {
set_error(expr->source(), "incorrect type for " +
mod_->SymbolToName(ident->symbol()) +
". Requires matrix value");
@@ -850,13 +850,12 @@
expr->func()->set_result_type(
result_types[0]->is_float_scalar()
? result_types[0]
- : result_types[0]->As<ast::type::Vector>()->type());
+ : result_types[0]->As<type::Vector>()->type());
return true;
}
// The determinant returns the component type of the columns
if (ident->intrinsic() == ast::Intrinsic::kDeterminant) {
- expr->func()->set_result_type(
- result_types[0]->As<ast::type::Matrix>()->type());
+ expr->func()->set_result_type(result_types[0]->As<type::Matrix>()->type());
return true;
}
expr->func()->set_result_type(result_types[0]);
@@ -886,11 +885,11 @@
// the pointer around the variable type.
if (var->is_const()) {
expr->set_result_type(var->type());
- } else if (var->type()->Is<ast::type::Pointer>()) {
+ } else if (var->type()->Is<type::Pointer>()) {
expr->set_result_type(var->type());
} else {
expr->set_result_type(
- mod_->create<ast::type::Pointer>(var->type(), var->storage_class()));
+ mod_->create<type::Pointer>(var->type(), var->storage_class()));
}
set_referenced_from_function_if_needed(var, true);
@@ -1073,8 +1072,8 @@
auto* res = expr->structure()->result_type();
auto* data_type = res->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
- ast::type::Type* ret = nullptr;
- if (auto* ty = data_type->As<ast::type::Struct>()) {
+ type::Type* ret = nullptr;
+ if (auto* ty = data_type->As<type::Struct>()) {
auto* strct = ty->impl();
auto symbol = expr->member()->symbol();
@@ -1092,10 +1091,10 @@
}
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<ast::type::Pointer>()) {
- ret = mod_->create<ast::type::Pointer>(ret, ptr->storage_class());
+ if (auto* ptr = res->As<type::Pointer>()) {
+ ret = mod_->create<type::Pointer>(ret, ptr->storage_class());
}
- } else if (auto* vec = data_type->As<ast::type::Vector>()) {
+ } else if (auto* vec = data_type->As<type::Vector>()) {
// TODO(dsinclair): Swizzle, record into the identifier experesion
auto size = mod_->SymbolToName(expr->member()->symbol()).size();
@@ -1103,14 +1102,14 @@
// A single element swizzle is just the type of the vector.
ret = vec->type();
// If we're extracting from a pointer, we return a pointer.
- if (auto* ptr = res->As<ast::type::Pointer>()) {
- ret = mod_->create<ast::type::Pointer>(ret, ptr->storage_class());
+ if (auto* ptr = res->As<type::Pointer>()) {
+ ret = mod_->create<type::Pointer>(ret, ptr->storage_class());
}
} else {
// The vector will have a number of components equal to the length of the
// swizzle. This assumes the validator will check that the swizzle
// is correct.
- ret = mod_->create<ast::type::Vector>(vec->type(), size);
+ ret = mod_->create<type::Vector>(vec->type(), size);
}
} else {
set_error(
@@ -1141,11 +1140,10 @@
if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() ||
expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() ||
expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) {
- auto* bool_type = mod_->create<ast::type::Bool>();
+ auto* bool_type = mod_->create<type::Bool>();
auto* param_type = expr->lhs()->result_type()->UnwrapPtrIfNeeded();
- if (auto* vec = param_type->As<ast::type::Vector>()) {
- expr->set_result_type(
- mod_->create<ast::type::Vector>(bool_type, vec->size()));
+ if (auto* vec = param_type->As<type::Vector>()) {
+ expr->set_result_type(mod_->create<type::Vector>(bool_type, vec->size()));
} else {
expr->set_result_type(bool_type);
}
@@ -1157,19 +1155,19 @@
// Note, the ordering here matters. The later checks depend on the prior
// checks having been done.
- auto* lhs_mat = lhs_type->As<ast::type::Matrix>();
- auto* rhs_mat = rhs_type->As<ast::type::Matrix>();
- auto* lhs_vec = lhs_type->As<ast::type::Vector>();
- auto* rhs_vec = rhs_type->As<ast::type::Vector>();
+ auto* lhs_mat = lhs_type->As<type::Matrix>();
+ auto* rhs_mat = rhs_type->As<type::Matrix>();
+ auto* lhs_vec = lhs_type->As<type::Vector>();
+ auto* rhs_vec = rhs_type->As<type::Vector>();
if (lhs_mat && rhs_mat) {
- expr->set_result_type(mod_->create<ast::type::Matrix>(
+ expr->set_result_type(mod_->create<type::Matrix>(
lhs_mat->type(), lhs_mat->rows(), rhs_mat->columns()));
} else if (lhs_mat && rhs_vec) {
expr->set_result_type(
- mod_->create<ast::type::Vector>(lhs_mat->type(), lhs_mat->rows()));
+ mod_->create<type::Vector>(lhs_mat->type(), lhs_mat->rows()));
} else if (lhs_vec && rhs_mat) {
expr->set_result_type(
- mod_->create<ast::type::Vector>(rhs_mat->type(), rhs_mat->columns()));
+ mod_->create<type::Vector>(rhs_mat->type(), rhs_mat->columns()));
} else if (lhs_mat) {
// matrix * scalar
expr->set_result_type(lhs_type);
@@ -1205,61 +1203,60 @@
return true;
}
-bool TypeDeterminer::DetermineStorageTextureSubtype(
- ast::type::StorageTexture* tex) {
+bool TypeDeterminer::DetermineStorageTextureSubtype(type::StorageTexture* tex) {
if (tex->type() != nullptr) {
return true;
}
switch (tex->image_format()) {
- case ast::type::ImageFormat::kR8Uint:
- case ast::type::ImageFormat::kR16Uint:
- case ast::type::ImageFormat::kRg8Uint:
- case ast::type::ImageFormat::kR32Uint:
- case ast::type::ImageFormat::kRg16Uint:
- case ast::type::ImageFormat::kRgba8Uint:
- case ast::type::ImageFormat::kRg32Uint:
- case ast::type::ImageFormat::kRgba16Uint:
- case ast::type::ImageFormat::kRgba32Uint: {
- tex->set_type(mod_->create<ast::type::U32>());
+ case type::ImageFormat::kR8Uint:
+ case type::ImageFormat::kR16Uint:
+ case type::ImageFormat::kRg8Uint:
+ case type::ImageFormat::kR32Uint:
+ case type::ImageFormat::kRg16Uint:
+ case type::ImageFormat::kRgba8Uint:
+ case type::ImageFormat::kRg32Uint:
+ case type::ImageFormat::kRgba16Uint:
+ case type::ImageFormat::kRgba32Uint: {
+ tex->set_type(mod_->create<type::U32>());
return true;
}
- case ast::type::ImageFormat::kR8Sint:
- case ast::type::ImageFormat::kR16Sint:
- case ast::type::ImageFormat::kRg8Sint:
- case ast::type::ImageFormat::kR32Sint:
- case ast::type::ImageFormat::kRg16Sint:
- case ast::type::ImageFormat::kRgba8Sint:
- case ast::type::ImageFormat::kRg32Sint:
- case ast::type::ImageFormat::kRgba16Sint:
- case ast::type::ImageFormat::kRgba32Sint: {
- tex->set_type(mod_->create<ast::type::I32>());
+ case type::ImageFormat::kR8Sint:
+ case type::ImageFormat::kR16Sint:
+ case type::ImageFormat::kRg8Sint:
+ case type::ImageFormat::kR32Sint:
+ case type::ImageFormat::kRg16Sint:
+ case type::ImageFormat::kRgba8Sint:
+ case type::ImageFormat::kRg32Sint:
+ case type::ImageFormat::kRgba16Sint:
+ case type::ImageFormat::kRgba32Sint: {
+ tex->set_type(mod_->create<type::I32>());
return true;
}
- case ast::type::ImageFormat::kR8Unorm:
- case ast::type::ImageFormat::kRg8Unorm:
- case ast::type::ImageFormat::kRgba8Unorm:
- case ast::type::ImageFormat::kRgba8UnormSrgb:
- case ast::type::ImageFormat::kBgra8Unorm:
- case ast::type::ImageFormat::kBgra8UnormSrgb:
- case ast::type::ImageFormat::kRgb10A2Unorm:
- case ast::type::ImageFormat::kR8Snorm:
- case ast::type::ImageFormat::kRg8Snorm:
- case ast::type::ImageFormat::kRgba8Snorm:
- case ast::type::ImageFormat::kR16Float:
- case ast::type::ImageFormat::kR32Float:
- case ast::type::ImageFormat::kRg16Float:
- case ast::type::ImageFormat::kRg11B10Float:
- case ast::type::ImageFormat::kRg32Float:
- case ast::type::ImageFormat::kRgba16Float:
- case ast::type::ImageFormat::kRgba32Float: {
- tex->set_type(mod_->create<ast::type::F32>());
+ case type::ImageFormat::kR8Unorm:
+ case type::ImageFormat::kRg8Unorm:
+ case type::ImageFormat::kRgba8Unorm:
+ case type::ImageFormat::kRgba8UnormSrgb:
+ case type::ImageFormat::kBgra8Unorm:
+ case type::ImageFormat::kBgra8UnormSrgb:
+ case type::ImageFormat::kRgb10A2Unorm:
+ case type::ImageFormat::kR8Snorm:
+ case type::ImageFormat::kRg8Snorm:
+ case type::ImageFormat::kRgba8Snorm:
+ case type::ImageFormat::kR16Float:
+ case type::ImageFormat::kR32Float:
+ case type::ImageFormat::kRg16Float:
+ case type::ImageFormat::kRg11B10Float:
+ case type::ImageFormat::kRg32Float:
+ case type::ImageFormat::kRgba16Float:
+ case type::ImageFormat::kRgba32Float: {
+ tex->set_type(mod_->create<type::F32>());
return true;
}
- case ast::type::ImageFormat::kNone:
+ case type::ImageFormat::kNone:
break;
}
diff --git a/src/type_determiner.h b/src/type_determiner.h
index 479bbca..f2aa2ba 100644
--- a/src/type_determiner.h
+++ b/src/type_determiner.h
@@ -20,8 +20,8 @@
#include <vector>
#include "src/ast/module.h"
-#include "src/ast/type/storage_texture_type.h"
#include "src/scope_stack.h"
+#include "src/type/storage_texture_type.h"
namespace tint {
namespace ast {
@@ -84,7 +84,7 @@
/// Determines the result type based off a storage texture format
/// @param tex the storage texture
/// @returns false on error
- bool DetermineStorageTextureSubtype(ast::type::StorageTexture* tex);
+ bool DetermineStorageTextureSubtype(type::StorageTexture* tex);
/// Testing method to set a given variable into the type stack
/// @param var the variable to set
@@ -99,11 +99,11 @@
/// @param params the parameters to the method call
/// @param id out parameter for the external call ID. Must not be a nullptr.
/// @returns the return type of `name` in `path` or nullptr on error.
- ast::type::Type* GetImportData(const Source& src,
- const std::string& path,
- const std::string& name,
- const ast::ExpressionList& params,
- uint32_t* id);
+ type::Type* GetImportData(const Source& src,
+ const std::string& path,
+ const std::string& name,
+ const ast::ExpressionList& params,
+ uint32_t* id);
/// Sets the intrinsic data information for the identifier if needed
/// @param ident the identifier expression
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 42c9c7a..1436199 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -47,26 +47,26 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace {
@@ -133,8 +133,8 @@
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Case) {
@@ -151,8 +151,8 @@
EXPECT_TRUE(td()->DetermineResultType(cse));
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Block) {
@@ -166,8 +166,8 @@
EXPECT_TRUE(td()->DetermineResultType(block));
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Else) {
@@ -183,9 +183,9 @@
ASSERT_NE(stmt->condition()->result_type(), nullptr);
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt->condition()->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(stmt->condition()->result_type()->Is<type::I32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_If) {
@@ -213,11 +213,11 @@
ASSERT_NE(else_rhs->result_type(), nullptr);
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt->condition()->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(else_lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(else_rhs->result_type()->Is<ast::type::F32>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(stmt->condition()->result_type()->Is<type::I32>());
+ EXPECT_TRUE(else_lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(else_rhs->result_type()->Is<type::F32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Loop) {
@@ -242,10 +242,10 @@
ASSERT_NE(body_rhs->result_type(), nullptr);
ASSERT_NE(continuing_lhs->result_type(), nullptr);
ASSERT_NE(continuing_rhs->result_type(), nullptr);
- EXPECT_TRUE(body_lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(body_rhs->result_type()->Is<ast::type::F32>());
- EXPECT_TRUE(continuing_lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(continuing_rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(body_lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(body_rhs->result_type()->Is<type::F32>());
+ EXPECT_TRUE(continuing_lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(continuing_rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Return) {
@@ -255,7 +255,7 @@
EXPECT_TRUE(td()->DetermineResultType(ret));
ASSERT_NE(cond->result_type(), nullptr);
- EXPECT_TRUE(cond->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(cond->result_type()->Is<type::I32>());
}
TEST_F(TypeDeterminerTest, Stmt_Return_WithoutValue) {
@@ -283,9 +283,9 @@
ASSERT_NE(lhs->result_type(), nullptr);
ASSERT_NE(rhs->result_type(), nullptr);
- EXPECT_TRUE(stmt->condition()->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(lhs->result_type()->Is<ast::type::I32>());
- EXPECT_TRUE(rhs->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(stmt->condition()->result_type()->Is<type::I32>());
+ EXPECT_TRUE(lhs->result_type()->Is<type::I32>());
+ EXPECT_TRUE(rhs->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Call) {
@@ -302,7 +302,7 @@
auto* call = create<ast::CallStatement>(expr);
EXPECT_TRUE(td()->DetermineResultType(call));
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(expr->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
@@ -342,7 +342,7 @@
EXPECT_TRUE(td()->DetermineResultType(decl));
ASSERT_NE(init->result_type(), nullptr);
- EXPECT_TRUE(init->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(init->result_type()->Is<type::I32>());
}
TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) {
@@ -354,7 +354,7 @@
EXPECT_TRUE(td()->Determine());
ASSERT_NE(init->result_type(), nullptr);
- EXPECT_TRUE(init->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(init->result_type()->Is<type::I32>());
}
TEST_F(TypeDeterminerTest, Expr_Error_Unknown) {
@@ -374,10 +374,10 @@
auto* acc = IndexAccessor("my_var", idx);
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- ASSERT_TRUE(acc->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(acc->result_type()->Is<type::Pointer>());
- auto* ptr = acc->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = acc->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
@@ -390,10 +390,10 @@
auto* acc = IndexAccessor("my_var", 2);
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- ASSERT_TRUE(acc->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(acc->result_type()->Is<type::Pointer>());
- auto* ptr = acc->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = acc->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
@@ -405,7 +405,7 @@
auto* acc = IndexAccessor("my_var", 2);
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- EXPECT_TRUE(acc->result_type()->Is<ast::type::F32>())
+ EXPECT_TRUE(acc->result_type()->Is<type::F32>())
<< acc->result_type()->type_name();
}
@@ -418,11 +418,11 @@
auto* acc = IndexAccessor("my_var", 2);
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- ASSERT_TRUE(acc->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(acc->result_type()->Is<type::Pointer>());
- auto* ptr = acc->result_type()->As<ast::type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::Vector>());
- EXPECT_EQ(ptr->type()->As<ast::type::Vector>()->size(), 3u);
+ auto* ptr = acc->result_type()->As<type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<type::Vector>());
+ EXPECT_EQ(ptr->type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) {
@@ -435,10 +435,10 @@
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- ASSERT_TRUE(acc->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(acc->result_type()->Is<type::Pointer>());
- auto* ptr = acc->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = acc->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) {
@@ -450,10 +450,10 @@
auto* acc = IndexAccessor("my_var", 2);
EXPECT_TRUE(td()->DetermineResultType(acc));
ASSERT_NE(acc->result_type(), nullptr);
- ASSERT_TRUE(acc->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(acc->result_type()->Is<type::Pointer>());
- auto* ptr = acc->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = acc->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Bitcast) {
@@ -464,7 +464,7 @@
EXPECT_TRUE(td()->DetermineResultType(bitcast));
ASSERT_NE(bitcast->result_type(), nullptr);
- EXPECT_TRUE(bitcast->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(bitcast->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call) {
@@ -479,7 +479,7 @@
auto* call = Call("my_func");
EXPECT_TRUE(td()->DetermineResultType(call));
ASSERT_NE(call->result_type(), nullptr);
- EXPECT_TRUE(call->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(call->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call_WithParams) {
@@ -496,7 +496,7 @@
auto* call = Call("my_func", param);
EXPECT_TRUE(td()->DetermineResultType(call));
ASSERT_NE(param->result_type(), nullptr);
- EXPECT_TRUE(param->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(param->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) {
@@ -507,7 +507,7 @@
EXPECT_TRUE(td()->DetermineResultType(call));
ASSERT_NE(call->result_type(), nullptr);
- EXPECT_TRUE(call->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(call->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Cast) {
@@ -518,14 +518,14 @@
EXPECT_TRUE(td()->DetermineResultType(cast));
ASSERT_NE(cast->result_type(), nullptr);
- EXPECT_TRUE(cast->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(cast->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) {
auto* s = Expr(1.0f);
EXPECT_TRUE(td()->DetermineResultType(s));
ASSERT_NE(s->result_type(), nullptr);
- EXPECT_TRUE(s->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(s->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Constructor_Type) {
@@ -533,10 +533,9 @@
EXPECT_TRUE(td()->DetermineResultType(tc));
ASSERT_NE(tc->result_type(), nullptr);
- ASSERT_TRUE(tc->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(
- tc->result_type()->As<ast::type::Vector>()->type()->Is<ast::type::F32>());
- EXPECT_EQ(tc->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(tc->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(tc->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(tc->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
@@ -548,11 +547,9 @@
auto* ident = Expr("my_var");
EXPECT_TRUE(td()->DetermineResultType(ident));
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::Pointer>());
- EXPECT_TRUE(ident->result_type()
- ->As<ast::type::Pointer>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::Pointer>());
+ EXPECT_TRUE(
+ ident->result_type()->As<type::Pointer>()->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) {
@@ -563,7 +560,7 @@
auto* ident = Expr("my_var");
EXPECT_TRUE(td()->DetermineResultType(ident));
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) {
@@ -581,7 +578,7 @@
EXPECT_TRUE(td()->DetermineFunction(f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(my_var->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) {
@@ -598,15 +595,13 @@
EXPECT_TRUE(td()->DetermineFunction(f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::Pointer>());
- EXPECT_TRUE(my_var->result_type()
- ->As<ast::type::Pointer>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(my_var->result_type()->Is<type::Pointer>());
+ EXPECT_TRUE(
+ my_var->result_type()->As<type::Pointer>()->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
- ast::type::Pointer ptr(ty.f32, ast::StorageClass::kFunction);
+ type::Pointer ptr(ty.f32, ast::StorageClass::kFunction);
auto* my_var = Expr("my_var");
@@ -621,11 +616,9 @@
EXPECT_TRUE(td()->DetermineFunction(f));
ASSERT_NE(my_var->result_type(), nullptr);
- EXPECT_TRUE(my_var->result_type()->Is<ast::type::Pointer>());
- EXPECT_TRUE(my_var->result_type()
- ->As<ast::type::Pointer>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(my_var->result_type()->Is<type::Pointer>());
+ EXPECT_TRUE(
+ my_var->result_type()->As<type::Pointer>()->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Function) {
@@ -639,7 +632,7 @@
auto* ident = Expr("my_func");
EXPECT_TRUE(td()->DetermineResultType(ident));
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
@@ -768,10 +761,10 @@
auto* mem = MemberAccessor("my_struct", "second_member");
EXPECT_TRUE(td()->DetermineResultType(mem));
ASSERT_NE(mem->result_type(), nullptr);
- ASSERT_TRUE(mem->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(mem->result_type()->Is<type::Pointer>());
- auto* ptr = mem->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = mem->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
@@ -791,10 +784,10 @@
auto* mem = MemberAccessor("my_struct", "second_member");
EXPECT_TRUE(td()->DetermineResultType(mem));
ASSERT_NE(mem->result_type(), nullptr);
- ASSERT_TRUE(mem->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(mem->result_type()->Is<type::Pointer>());
- auto* ptr = mem->result_type()->As<ast::type::Pointer>();
- EXPECT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = mem->result_type()->As<type::Pointer>();
+ EXPECT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) {
@@ -806,12 +799,9 @@
auto* mem = MemberAccessor("my_vec", "xy");
EXPECT_TRUE(td()->DetermineResultType(mem)) << td()->error();
ASSERT_NE(mem->result_type(), nullptr);
- ASSERT_TRUE(mem->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(mem->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(mem->result_type()->As<ast::type::Vector>()->size(), 2u);
+ ASSERT_TRUE(mem->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(mem->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(mem->result_type()->As<type::Vector>()->size(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
@@ -823,10 +813,10 @@
auto* mem = MemberAccessor("my_vec", "x");
EXPECT_TRUE(td()->DetermineResultType(mem)) << td()->error();
ASSERT_NE(mem->result_type(), nullptr);
- ASSERT_TRUE(mem->result_type()->Is<ast::type::Pointer>());
+ ASSERT_TRUE(mem->result_type()->Is<type::Pointer>());
- auto* ptr = mem->result_type()->As<ast::type::Pointer>();
- ASSERT_TRUE(ptr->type()->Is<ast::type::F32>());
+ auto* ptr = mem->result_type()->As<type::Pointer>();
+ ASSERT_TRUE(ptr->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
@@ -860,7 +850,7 @@
ast::StructDecorationList{});
auto* stB = ty.struct_("B", strctB);
- ast::type::Vector vecB(stB, 3);
+ type::Vector vecB(stB, 3);
auto* strctA = create<ast::Struct>(
ast::StructMemberList{Member("mem", &vecB)}, ast::StructDecorationList{});
@@ -875,12 +865,9 @@
EXPECT_TRUE(td()->DetermineResultType(mem)) << td()->error();
ASSERT_NE(mem->result_type(), nullptr);
- ASSERT_TRUE(mem->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(mem->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(mem->result_type()->As<ast::type::Vector>()->size(), 2u);
+ ASSERT_TRUE(mem->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(mem->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(mem->result_type()->As<type::Vector>()->size(), 2u);
}
using Expr_Binary_BitwiseTest = TypeDeterminerTestWithParam<ast::BinaryOp>;
@@ -897,7 +884,7 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(expr->result_type()->Is<type::I32>());
}
TEST_P(Expr_Binary_BitwiseTest, Vector) {
@@ -913,12 +900,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::I32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::I32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_BitwiseTest,
@@ -946,7 +930,7 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::Bool>());
+ EXPECT_TRUE(expr->result_type()->Is<type::Bool>());
}
TEST_P(Expr_Binary_LogicalTest, Vector) {
@@ -962,12 +946,10 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::Bool>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::Bool>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_LogicalTest,
@@ -988,7 +970,7 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::Bool>());
+ EXPECT_TRUE(expr->result_type()->Is<type::Bool>());
}
TEST_P(Expr_Binary_CompareTest, Vector) {
@@ -1004,12 +986,10 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::Bool>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::Bool>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Expr_Binary_CompareTest,
@@ -1031,7 +1011,7 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(expr->result_type()->Is<type::I32>());
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) {
@@ -1046,12 +1026,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) {
@@ -1066,12 +1043,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) {
@@ -1084,12 +1058,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) {
@@ -1104,10 +1075,10 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Matrix>());
+ ASSERT_TRUE(expr->result_type()->Is<type::Matrix>());
- auto* mat = expr->result_type()->As<ast::type::Matrix>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
+ auto* mat = expr->result_type()->As<type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<type::F32>());
EXPECT_EQ(mat->rows(), 3u);
EXPECT_EQ(mat->columns(), 2u);
}
@@ -1124,10 +1095,10 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Matrix>());
+ ASSERT_TRUE(expr->result_type()->Is<type::Matrix>());
- auto* mat = expr->result_type()->As<ast::type::Matrix>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
+ auto* mat = expr->result_type()->As<type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<type::F32>());
EXPECT_EQ(mat->rows(), 3u);
EXPECT_EQ(mat->columns(), 2u);
}
@@ -1144,12 +1115,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) {
@@ -1164,12 +1132,9 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 2u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 2u);
}
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) {
@@ -1184,10 +1149,10 @@
ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Matrix>());
+ ASSERT_TRUE(expr->result_type()->Is<type::Matrix>());
- auto* mat = expr->result_type()->As<ast::type::Matrix>();
- EXPECT_TRUE(mat->type()->Is<ast::type::F32>());
+ auto* mat = expr->result_type()->As<type::Matrix>();
+ EXPECT_TRUE(mat->type()->Is<type::F32>());
EXPECT_EQ(mat->rows(), 4u);
EXPECT_EQ(mat->columns(), 4u);
}
@@ -1206,7 +1171,7 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::F32>());
+ ASSERT_TRUE(expr->result_type()->Is<type::F32>());
}
TEST_P(IntrinsicDerivativeTest, Vector) {
@@ -1222,12 +1187,9 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 4u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 4u);
}
TEST_P(IntrinsicDerivativeTest, MissingParam) {
@@ -1281,7 +1243,7 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::Bool>());
+ EXPECT_TRUE(expr->result_type()->Is<type::Bool>());
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
Intrinsic,
@@ -1302,12 +1264,10 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::Bool>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::Bool>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(Intrinsic_FloatMethod, Scalar) {
@@ -1323,7 +1283,7 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::Bool>());
+ EXPECT_TRUE(expr->result_type()->Is<type::Bool>());
}
TEST_P(Intrinsic_FloatMethod, MissingParam) {
@@ -1373,9 +1333,9 @@
}
struct TextureTestParams {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
Texture type = Texture::kF32;
- ast::type::ImageFormat format = ast::type::ImageFormat::kR16Float;
+ type::ImageFormat format = type::ImageFormat::kR16Float;
};
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) {
out << data.dim << "_" << data.type;
@@ -1385,43 +1345,42 @@
class Intrinsic_TextureOperation
: public TypeDeterminerTestWithParam<TextureTestParams> {
public:
- std::unique_ptr<ast::type::Type> get_coords_type(
- ast::type::TextureDimension dim,
- ast::type::Type* type) {
- if (dim == ast::type::TextureDimension::k1d) {
- if (type->Is<ast::type::I32>()) {
- return std::make_unique<ast::type::I32>();
- } else if (type->Is<ast::type::U32>()) {
- return std::make_unique<ast::type::U32>();
+ std::unique_ptr<type::Type> get_coords_type(type::TextureDimension dim,
+ type::Type* type) {
+ if (dim == type::TextureDimension::k1d) {
+ if (type->Is<type::I32>()) {
+ return std::make_unique<type::I32>();
+ } else if (type->Is<type::U32>()) {
+ return std::make_unique<type::U32>();
} else {
- return std::make_unique<ast::type::F32>();
+ return std::make_unique<type::F32>();
}
- } else if (dim == ast::type::TextureDimension::k1dArray ||
- dim == ast::type::TextureDimension::k2d) {
- return std::make_unique<ast::type::Vector>(type, 2);
- } else if (dim == ast::type::TextureDimension::kCubeArray) {
- return std::make_unique<ast::type::Vector>(type, 4);
+ } else if (dim == type::TextureDimension::k1dArray ||
+ dim == type::TextureDimension::k2d) {
+ return std::make_unique<type::Vector>(type, 2);
+ } else if (dim == type::TextureDimension::kCubeArray) {
+ return std::make_unique<type::Vector>(type, 4);
} else {
- return std::make_unique<ast::type::Vector>(type, 3);
+ return std::make_unique<type::Vector>(type, 3);
}
}
void add_call_param(std::string name,
- ast::type::Type* type,
+ type::Type* type,
ast::ExpressionList* call_params) {
auto* var = Var(name, ast::StorageClass::kNone, type);
mod->AddGlobalVariable(var);
call_params->push_back(Expr(name));
}
- std::unique_ptr<ast::type::Type> subtype(Texture type) {
+ std::unique_ptr<type::Type> subtype(Texture type) {
if (type == Texture::kF32) {
- return std::make_unique<ast::type::F32>();
+ return std::make_unique<type::F32>();
}
if (type == Texture::kI32) {
- return std::make_unique<ast::type::I32>();
+ return std::make_unique<type::I32>();
}
- return std::make_unique<ast::type::U32>();
+ return std::make_unique<type::U32>();
}
};
@@ -1433,8 +1392,7 @@
auto coords_type = get_coords_type(dim, ty.i32);
- ast::type::Type* texture_type =
- mod->create<ast::type::StorageTexture>(dim, format);
+ type::Type* texture_type = mod->create<type::StorageTexture>(dim, format);
ast::ExpressionList call_params;
@@ -1448,69 +1406,63 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
if (type == Texture::kF32) {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
} else if (type == Texture::kI32) {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::I32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::I32>());
} else {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::U32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::U32>());
}
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 4u);
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
TypeDeterminerTest,
Intrinsic_StorageTextureOperation,
testing::Values(
- TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32,
- ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k1d, Texture::kI32,
- ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32,
- ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32,
- ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kI32,
- ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32,
- ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32,
- ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k2d, Texture::kI32,
- ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32,
- ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32,
- ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kI32,
- ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32,
- ast::type::ImageFormat::kR8Unorm},
- TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32,
- ast::type::ImageFormat::kR16Float},
- TextureTestParams{ast::type::TextureDimension::k3d, Texture::kI32,
- ast::type::ImageFormat::kR16Sint},
- TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32,
- ast::type::ImageFormat::kR8Unorm}));
+ TextureTestParams{type::TextureDimension::k1d, Texture::kF32,
+ type::ImageFormat::kR16Float},
+ TextureTestParams{type::TextureDimension::k1d, Texture::kI32,
+ type::ImageFormat::kR16Sint},
+ TextureTestParams{type::TextureDimension::k1d, Texture::kF32,
+ type::ImageFormat::kR8Unorm},
+ TextureTestParams{type::TextureDimension::k1dArray, Texture::kF32,
+ type::ImageFormat::kR16Float},
+ TextureTestParams{type::TextureDimension::k1dArray, Texture::kI32,
+ type::ImageFormat::kR16Sint},
+ TextureTestParams{type::TextureDimension::k1dArray, Texture::kF32,
+ type::ImageFormat::kR8Unorm},
+ TextureTestParams{type::TextureDimension::k2d, Texture::kF32,
+ type::ImageFormat::kR16Float},
+ TextureTestParams{type::TextureDimension::k2d, Texture::kI32,
+ type::ImageFormat::kR16Sint},
+ TextureTestParams{type::TextureDimension::k2d, Texture::kF32,
+ type::ImageFormat::kR8Unorm},
+ TextureTestParams{type::TextureDimension::k2dArray, Texture::kF32,
+ type::ImageFormat::kR16Float},
+ TextureTestParams{type::TextureDimension::k2dArray, Texture::kI32,
+ type::ImageFormat::kR16Sint},
+ TextureTestParams{type::TextureDimension::k2dArray, Texture::kF32,
+ type::ImageFormat::kR8Unorm},
+ TextureTestParams{type::TextureDimension::k3d, Texture::kF32,
+ type::ImageFormat::kR16Float},
+ TextureTestParams{type::TextureDimension::k3d, Texture::kI32,
+ type::ImageFormat::kR16Sint},
+ TextureTestParams{type::TextureDimension::k3d, Texture::kF32,
+ type::ImageFormat::kR8Unorm}));
using Intrinsic_SampledTextureOperation = Intrinsic_TextureOperation;
TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) {
auto dim = GetParam().dim;
auto type = GetParam().type;
- std::unique_ptr<ast::type::Type> s = subtype(type);
+ std::unique_ptr<type::Type> s = subtype(type);
auto coords_type = get_coords_type(dim, ty.i32);
- auto texture_type = std::make_unique<ast::type::SampledTexture>(dim, s.get());
+ auto texture_type = std::make_unique<type::SampledTexture>(dim, s.get());
ast::ExpressionList call_params;
@@ -1524,34 +1476,27 @@
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- ASSERT_TRUE(expr->result_type()->Is<ast::type::Vector>());
+ ASSERT_TRUE(expr->result_type()->Is<type::Vector>());
if (type == Texture::kF32) {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
} else if (type == Texture::kI32) {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::I32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::I32>());
} else {
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::U32>());
+ EXPECT_TRUE(
+ expr->result_type()->As<type::Vector>()->type()->Is<type::U32>());
}
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 4u);
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(
TypeDeterminerTest,
Intrinsic_SampledTextureOperation,
- testing::Values(TextureTestParams{ast::type::TextureDimension::k2d},
- TextureTestParams{ast::type::TextureDimension::k2dArray},
- TextureTestParams{ast::type::TextureDimension::kCube},
- TextureTestParams{
- ast::type::TextureDimension::kCubeArray}));
+ testing::Values(TextureTestParams{type::TextureDimension::k2d},
+ TextureTestParams{type::TextureDimension::k2dArray},
+ TextureTestParams{type::TextureDimension::kCube},
+ TextureTestParams{type::TextureDimension::kCubeArray}));
TEST_F(TypeDeterminerTest, Intrinsic_Dot) {
auto* var = Var("my_var", ast::StorageClass::kNone, ty.vec3<f32>());
@@ -1564,7 +1509,7 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(expr));
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(expr->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Intrinsic_Select) {
@@ -1581,12 +1526,9 @@
EXPECT_TRUE(td()->Determine());
EXPECT_TRUE(td()->DetermineResultType(expr)) << td()->error();
ASSERT_NE(expr->result_type(), nullptr);
- EXPECT_TRUE(expr->result_type()->Is<ast::type::Vector>());
- EXPECT_EQ(expr->result_type()->As<ast::type::Vector>()->size(), 3u);
- EXPECT_TRUE(expr->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
+ EXPECT_TRUE(expr->result_type()->Is<type::Vector>());
+ EXPECT_EQ(expr->result_type()->As<type::Vector>()->size(), 3u);
+ EXPECT_TRUE(expr->result_type()->As<type::Vector>()->type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) {
@@ -1630,12 +1572,9 @@
auto* der = create<ast::UnaryOpExpression>(op, Expr("ident"));
EXPECT_TRUE(td()->DetermineResultType(der));
ASSERT_NE(der->result_type(), nullptr);
- ASSERT_TRUE(der->result_type()->Is<ast::type::Vector>());
- EXPECT_TRUE(der->result_type()
- ->As<ast::type::Vector>()
- ->type()
- ->Is<ast::type::F32>());
- EXPECT_EQ(der->result_type()->As<ast::type::Vector>()->size(), 4u);
+ ASSERT_TRUE(der->result_type()->Is<type::Vector>());
+ EXPECT_TRUE(der->result_type()->As<type::Vector>()->type()->Is<type::F32>());
+ EXPECT_EQ(der->result_type()->As<type::Vector>()->size(), 4u);
}
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
UnaryOpExpressionTest,
@@ -1804,7 +1743,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParamTest, Error_Integer) {
@@ -1886,7 +1825,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) {
@@ -1897,7 +1836,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::I32>());
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) {
@@ -1917,7 +1856,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) {
@@ -1931,7 +1870,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::U32>());
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) {
@@ -1943,7 +1882,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_Bool) {
@@ -2057,7 +1996,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_TwoParamTest, Error_Integer) {
@@ -2148,7 +2087,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::F32>());
}
TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) {
@@ -2208,7 +2147,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) {
@@ -2274,7 +2213,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParamTest, Error_Integer) {
@@ -2381,7 +2320,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) {
@@ -2392,7 +2331,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::I32>());
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) {
@@ -2405,7 +2344,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) {
@@ -2416,7 +2355,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::U32>());
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) {
@@ -2429,7 +2368,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_Bool) {
@@ -2531,7 +2470,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_Int_SingleParamTest, Error_Float) {
@@ -2582,7 +2521,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::I32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::I32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) {
@@ -2593,7 +2532,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::U32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::U32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) {
@@ -2604,7 +2543,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::F32>());
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) {
@@ -2616,7 +2555,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_signed_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) {
@@ -2628,7 +2567,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) {
@@ -2640,7 +2579,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
EXPECT_TRUE(ident->result_type()->is_float_vector());
- EXPECT_EQ(ident->result_type()->As<ast::type::Vector>()->size(), 3u);
+ EXPECT_EQ(ident->result_type()->As<type::Vector>()->size(), 3u);
}
TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_Bool) {
@@ -2722,7 +2661,7 @@
EXPECT_TRUE(td()->DetermineResultType(call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
- EXPECT_TRUE(ident->result_type()->Is<ast::type::F32>());
+ EXPECT_TRUE(ident->result_type()->Is<type::F32>());
}
using ImportData_Matrix_OneParam_Test =
@@ -3190,18 +3129,18 @@
switch (param.texture_dimension) {
default:
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
- case ast::type::TextureDimension::k1d:
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1d:
+ case type::TextureDimension::k1dArray:
EXPECT_EQ(call->result_type()->type_name(), ty.i32->type_name());
break;
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k2dArray:
EXPECT_EQ(call->result_type()->type_name(),
ty.vec2<i32>()->type_name());
break;
- case ast::type::TextureDimension::k3d:
- case ast::type::TextureDimension::kCube:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::k3d:
+ case type::TextureDimension::kCube:
+ case type::TextureDimension::kCubeArray:
EXPECT_EQ(call->result_type()->type_name(),
ty.vec3<i32>()->type_name());
break;
@@ -3220,9 +3159,8 @@
case ast::intrinsic::test::TextureKind::kMultisampled:
case ast::intrinsic::test::TextureKind::kStorage: {
auto* datatype = param.resultVectorComponentType(this);
- ASSERT_TRUE(call->result_type()->Is<ast::type::Vector>());
- EXPECT_EQ(call->result_type()->As<ast::type::Vector>()->type(),
- datatype);
+ ASSERT_TRUE(call->result_type()->Is<type::Vector>());
+ EXPECT_EQ(call->result_type()->As<type::Vector>()->type(), datatype);
break;
}
case ast::intrinsic::test::TextureKind::kDepth: {
diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc
index 35b97a2..005abe3 100644
--- a/src/validator/validator_control_block_test.cc
+++ b/src/validator/validator_control_block_test.cc
@@ -20,13 +20,13 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/alias_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
#include "src/type_determiner.h"
#include "src/validator/validator_impl.h"
#include "src/validator/validator_test_helper.h"
diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc
index 905d7b3..c5379ba 100644
--- a/src/validator/validator_function_test.cc
+++ b/src/validator/validator_function_test.cc
@@ -20,11 +20,11 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/stage_decoration.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/validator/validator_impl.h"
#include "src/validator/validator_test_helper.h"
diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc
index 15dfbbd..c673040 100644
--- a/src/validator/validator_impl.cc
+++ b/src/validator/validator_impl.cc
@@ -27,16 +27,16 @@
#include "src/ast/stage_decoration.h"
#include "src/ast/struct.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
namespace tint {
@@ -83,11 +83,11 @@
}
bool ValidatorImpl::ValidateConstructedTypes(
- const std::vector<ast::type::Type*>& constructed_types) {
+ const std::vector<type::Type*>& constructed_types) {
for (auto* const ct : constructed_types) {
- if (auto* st = ct->As<ast::type::Struct>()) {
+ if (auto* st = ct->As<type::Struct>()) {
for (auto* member : st->impl()->members()) {
- if (auto* r = member->type()->UnwrapAll()->As<ast::type::Array>()) {
+ if (auto* r = member->type()->UnwrapAll()->As<type::Array>()) {
if (r->IsRuntimeArray()) {
if (member != st->impl()->members().back()) {
add_error(member->source(), "v-0015",
@@ -167,7 +167,7 @@
return false;
}
- if (!func->return_type()->Is<ast::type::Void>()) {
+ if (!func->return_type()->Is<type::Void>()) {
add_error(func->source(), "v-0024",
"Entry point function must return void: '" +
module_.SymbolToName(func->symbol()) + "'");
@@ -209,7 +209,7 @@
}
variable_stack_.pop_scope();
- if (!current_function_->return_type()->Is<ast::type::Void>()) {
+ if (!current_function_->return_type()->Is<type::Void>()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
add_error(func->source(), "v-0002",
@@ -221,7 +221,7 @@
}
bool ValidatorImpl::ValidateParameter(const ast::Variable* param) {
- if (auto* r = param->type()->UnwrapAll()->As<ast::type::Array>()) {
+ if (auto* r = param->type()->UnwrapAll()->As<type::Array>()) {
if (r->IsRuntimeArray()) {
add_error(
param->source(), "v-0015",
@@ -235,9 +235,9 @@
bool ValidatorImpl::ValidateReturnStatement(const ast::ReturnStatement* ret) {
// TODO(sarahM0): update this when this issue resolves:
// https://github.com/gpuweb/gpuweb/issues/996
- ast::type::Type* func_type = current_function_->return_type();
+ type::Type* func_type = current_function_->return_type();
- ast::type::Void void_type;
+ type::Void void_type;
auto* ret_type =
ret->has_value() ? ret->value()->result_type()->UnwrapAll() : &void_type;
@@ -283,8 +283,7 @@
// storable.
// - types match or the RHS can be dereferenced to equal the LHS type.
variable_stack_.set(symbol, decl->variable());
- if (auto* arr =
- decl->variable()->type()->UnwrapAll()->As<ast::type::Array>()) {
+ if (auto* arr = decl->variable()->type()->UnwrapAll()->As<type::Array>()) {
if (arr->IsRuntimeArray()) {
add_error(
decl->source(), "v-0015",
@@ -358,11 +357,11 @@
}
auto v =
- static_cast<int32_t>(selector->type()->Is<ast::type::U32>()
+ static_cast<int32_t>(selector->type()->Is<type::U32>()
? selector->As<ast::UintLiteral>()->value()
: selector->As<ast::SintLiteral>()->value());
if (selector_set.count(v)) {
- auto v_str = selector->type()->Is<ast::type::U32>()
+ auto v_str = selector->type()->Is<type::U32>()
? selector->As<ast::UintLiteral>()->to_str()
: selector->As<ast::SintLiteral>()->to_str();
add_error(case_stmt->source(), "v-0027",
@@ -485,7 +484,7 @@
return false;
}
auto* lhs_result_type = lhs->result_type()->UnwrapIfNeeded();
- if (auto* lhs_reference_type = As<ast::type::Pointer>(lhs_result_type)) {
+ if (auto* lhs_reference_type = As<type::Pointer>(lhs_result_type)) {
auto* lhs_store_type = lhs_reference_type->type()->UnwrapIfNeeded();
if (lhs_store_type != rhs_result_type) {
add_error(assign->source(), "v-000x",
@@ -534,18 +533,18 @@
return true;
}
-bool ValidatorImpl::IsStorable(ast::type::Type* type) {
+bool ValidatorImpl::IsStorable(type::Type* type) {
if (type == nullptr) {
return false;
}
- if (type->is_scalar() || type->Is<ast::type::Vector>() ||
- type->Is<ast::type::Matrix>()) {
+ if (type->is_scalar() || type->Is<type::Vector>() ||
+ type->Is<type::Matrix>()) {
return true;
}
- if (ast::type::Array* array_type = type->As<ast::type::Array>()) {
+ if (type::Array* array_type = type->As<type::Array>()) {
return IsStorable(array_type->type());
}
- if (ast::type::Struct* struct_type = type->As<ast::type::Struct>()) {
+ if (type::Struct* struct_type = type->As<type::Struct>()) {
for (const auto* member : struct_type->impl()->members()) {
if (!IsStorable(member->type())) {
return false;
@@ -553,7 +552,7 @@
}
return true;
}
- if (ast::type::Alias* alias_type = type->As<ast::type::Alias>()) {
+ if (type::Alias* alias_type = type->As<type::Alias>()) {
return IsStorable(alias_type->type());
}
return false;
diff --git a/src/validator/validator_impl.h b/src/validator/validator_impl.h
index f0a1b5d..58aa2e1 100644
--- a/src/validator/validator_impl.h
+++ b/src/validator/validator_impl.h
@@ -144,15 +144,16 @@
/// @param constructed_types the types to check
/// @returns true if the valdiation was successful
bool ValidateConstructedTypes(
- const std::vector<ast::type::Type*>& constructed_types);
+ const std::vector<type::Type*>& constructed_types);
/// Returns true if the given type is storable. This uses and
/// updates `storable_` and `not_storable_`.
/// @param type the given type
/// @returns true if the given type is storable.
- bool IsStorable(ast::type::Type* type);
+ bool IsStorable(type::Type* type);
/// Testing method to inserting a given variable into the current scope.
+ /// @param var the variable to register
void RegisterVariableForTesting(ast::Variable* var) {
variable_stack_.set(var->symbol(), var);
}
diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc
index de38988..7973dc7 100644
--- a/src/validator/validator_test.cc
+++ b/src/validator/validator_test.cc
@@ -38,19 +38,19 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/validator/validator_impl.h"
#include "src/validator/validator_test_helper.h"
diff --git a/src/validator/validator_test_helper.h b/src/validator/validator_test_helper.h
index a7f4374..305f1a4 100644
--- a/src/validator/validator_test_helper.h
+++ b/src/validator/validator_test_helper.h
@@ -19,7 +19,7 @@
#include <utility>
#include "src/ast/builder.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/validator/validator_impl.h"
diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc
index 91be119..e199785 100644
--- a/src/validator/validator_type_test.cc
+++ b/src/validator/validator_type_test.cc
@@ -18,13 +18,13 @@
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
#include "src/validator/validator_impl.h"
#include "src/validator/validator_test_helper.h"
diff --git a/src/writer/append_vector.cc b/src/writer/append_vector.cc
index 6a629b2..4873723 100644
--- a/src/writer/append_vector.cc
+++ b/src/writer/append_vector.cc
@@ -17,8 +17,8 @@
#include <utility>
#include "src/ast/expression.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/vector_type.h"
namespace tint {
namespace writer {
@@ -27,7 +27,7 @@
ast::TypeConstructorExpression* AsVectorConstructor(ast::Expression* expr) {
if (auto* constructor = expr->As<ast::TypeConstructorExpression>()) {
- if (constructor->type()->Is<ast::type::Vector>()) {
+ if (constructor->type()->Is<type::Vector>()) {
return constructor;
}
}
@@ -41,8 +41,8 @@
ast::Expression* scalar,
std::function<bool(ast::TypeConstructorExpression*)> callback) {
uint32_t packed_size;
- ast::type::Type* packed_el_ty; // Currently must be f32.
- if (auto* vec = vector->result_type()->As<ast::type::Vector>()) {
+ type::Type* packed_el_ty; // Currently must be f32.
+ if (auto* vec = vector->result_type()->As<type::Vector>()) {
packed_size = vec->size() + 1;
packed_el_ty = vec->type();
} else {
@@ -58,7 +58,7 @@
ast::TypeConstructorExpression scalar_cast(Source{}, packed_el_ty, {scalar});
scalar_cast.set_result_type(packed_el_ty);
- ast::type::Vector packed_ty(packed_el_ty, packed_size);
+ type::Vector packed_ty(packed_el_ty, packed_size);
// If the coordinates are already passed in a vector constructor, extract
// the elements into the new vector instead of nesting a vector-in-vector.
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index e3e53ad..c30a220 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -39,25 +39,25 @@
#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/append_vector.h"
#include "src/writer/float_to_string.h"
@@ -97,27 +97,26 @@
return 0;
}
-const char* image_format_to_rwtexture_type(
- ast::type::ImageFormat image_format) {
+const char* image_format_to_rwtexture_type(type::ImageFormat image_format) {
switch (image_format) {
- case ast::type::ImageFormat::kRgba8Unorm:
- case ast::type::ImageFormat::kRgba8Snorm:
- case ast::type::ImageFormat::kRgba16Float:
- case ast::type::ImageFormat::kR32Float:
- case ast::type::ImageFormat::kRg32Float:
- case ast::type::ImageFormat::kRgba32Float:
+ case type::ImageFormat::kRgba8Unorm:
+ case type::ImageFormat::kRgba8Snorm:
+ case type::ImageFormat::kRgba16Float:
+ case type::ImageFormat::kR32Float:
+ case type::ImageFormat::kRg32Float:
+ case type::ImageFormat::kRgba32Float:
return "float4";
- case ast::type::ImageFormat::kRgba8Uint:
- case ast::type::ImageFormat::kRgba16Uint:
- case ast::type::ImageFormat::kR32Uint:
- case ast::type::ImageFormat::kRg32Uint:
- case ast::type::ImageFormat::kRgba32Uint:
+ case type::ImageFormat::kRgba8Uint:
+ case type::ImageFormat::kRgba16Uint:
+ case type::ImageFormat::kR32Uint:
+ case type::ImageFormat::kRg32Uint:
+ case type::ImageFormat::kRgba32Uint:
return "uint4";
- case ast::type::ImageFormat::kRgba8Sint:
- case ast::type::ImageFormat::kRgba16Sint:
- case ast::type::ImageFormat::kR32Sint:
- case ast::type::ImageFormat::kRg32Sint:
- case ast::type::ImageFormat::kRgba32Sint:
+ case type::ImageFormat::kRgba8Sint:
+ case type::ImageFormat::kRgba16Sint:
+ case type::ImageFormat::kR32Sint:
+ case type::ImageFormat::kRg32Sint:
+ case type::ImageFormat::kRgba32Sint:
return "int4";
default:
return nullptr;
@@ -226,13 +225,13 @@
}
bool GeneratorImpl::EmitConstructedType(std::ostream& out,
- const ast::type::Type* ty) {
+ const type::Type* ty) {
make_indent(out);
- if (auto* alias = ty->As<ast::type::Alias>()) {
+ if (auto* alias = ty->As<type::Alias>()) {
// HLSL typedef is for intrinsic types only. For an alias'd struct,
// generate a secondary struct with the new name.
- if (auto* str = alias->type()->As<ast::type::Struct>()) {
+ if (auto* str = alias->type()->As<type::Struct>()) {
if (!EmitStructType(out, str, module_->SymbolToName(alias->symbol()))) {
return false;
}
@@ -244,7 +243,7 @@
}
out << " " << namer_.NameFor(module_->SymbolToName(alias->symbol())) << ";"
<< std::endl;
- } else if (auto* str = ty->As<ast::type::Struct>()) {
+ } else if (auto* str = ty->As<type::Struct>()) {
if (!EmitStructType(out, str, module_->SymbolToName(str->symbol()))) {
return false;
}
@@ -385,12 +384,9 @@
// Multiplying by a matrix requires the use of `mul` in order to get the
// type of multiply we desire.
if (expr->op() == ast::BinaryOp::kMultiply &&
- ((lhs_type->Is<ast::type::Vector>() &&
- rhs_type->Is<ast::type::Matrix>()) ||
- (lhs_type->Is<ast::type::Matrix>() &&
- rhs_type->Is<ast::type::Vector>()) ||
- (lhs_type->Is<ast::type::Matrix>() &&
- rhs_type->Is<ast::type::Matrix>()))) {
+ ((lhs_type->Is<type::Vector>() && rhs_type->Is<type::Matrix>()) ||
+ (lhs_type->Is<type::Matrix>() && rhs_type->Is<type::Vector>()) ||
+ (lhs_type->Is<type::Matrix>() && rhs_type->Is<type::Matrix>()))) {
out << "mul(";
if (!EmitExpression(pre, out, expr->lhs())) {
return false;
@@ -692,8 +688,7 @@
auto const kNotUsed = ast::intrinsic::TextureSignature::Parameters::kNotUsed;
auto* texture = params[pidx.texture];
- auto* texture_type =
- texture->result_type()->UnwrapAll()->As<ast::type::Texture>();
+ auto* texture_type = texture->result_type()->UnwrapAll()->As<type::Texture>();
switch (ident->intrinsic()) {
case ast::Intrinsic::kTextureDimensions:
@@ -708,33 +703,33 @@
switch (ident->intrinsic()) {
case ast::Intrinsic::kTextureDimensions:
switch (texture_type->dim()) {
- case ast::type::TextureDimension::kNone:
+ case type::TextureDimension::kNone:
error_ = "texture dimension is kNone";
return false;
- case ast::type::TextureDimension::k1d:
+ case type::TextureDimension::k1d:
num_dimensions = 1;
break;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
num_dimensions = 2;
swizzle = ".x";
break;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
num_dimensions = 2;
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
num_dimensions = 3;
swizzle = ".xy";
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
num_dimensions = 3;
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 2;
swizzle = ".xyy"; // [width, height, height]
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
num_dimensions = 3;
@@ -747,12 +742,12 @@
default:
error_ = "texture dimension is not arrayed";
return false;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
num_dimensions = 2;
swizzle = ".y";
break;
- case ast::type::TextureDimension::k2dArray:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::k2dArray:
+ case type::TextureDimension::kCubeArray:
num_dimensions = 3;
swizzle = ".z";
break;
@@ -764,14 +759,14 @@
default:
error_ = "texture dimension does not support mips";
return false;
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::kCube:
num_dimensions = 3;
swizzle = ".z";
break;
- case ast::type::TextureDimension::k2dArray:
- case ast::type::TextureDimension::k3d:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::k2dArray:
+ case type::TextureDimension::k3d:
+ case type::TextureDimension::kCubeArray:
num_dimensions = 4;
swizzle = ".w";
break;
@@ -782,11 +777,11 @@
default:
error_ = "texture dimension does not support multisampling";
return false;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
num_dimensions = 3;
swizzle = ".z";
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
num_dimensions = 4;
swizzle = ".w";
break;
@@ -864,7 +859,7 @@
break;
case ast::Intrinsic::kTextureLoad:
out << ".Load(";
- if (!texture_type->Is<ast::type::StorageTexture>()) {
+ if (!texture_type->Is<type::StorageTexture>()) {
pack_mip_in_coords = true;
}
break;
@@ -886,7 +881,7 @@
auto* param_coords = params[pidx.coords];
auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) {
- auto* i32 = module_->create<ast::type::I32>();
+ auto* i32 = module_->create<type::I32>();
ast::SintLiteral zero_lit(Source{}, i32, 0);
ast::ScalarConstructorExpression zero(Source{}, &zero_lit);
zero.set_result_type(i32);
@@ -1063,7 +1058,7 @@
bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre,
std::ostream& out,
ast::TypeConstructorExpression* expr) {
- if (expr->type()->Is<ast::type::Array>()) {
+ if (expr->type()->Is<type::Array>()) {
out << "{";
} else {
if (!EmitType(out, expr->type(), "")) {
@@ -1092,7 +1087,7 @@
}
}
- if (expr->type()->Is<ast::type::Array>()) {
+ if (expr->type()->Is<type::Array>()) {
out << "}";
} else {
out << ")";
@@ -1379,7 +1374,7 @@
return false;
}
// Array name is output as part of the type
- if (!v->type()->Is<ast::type::Array>()) {
+ if (!v->type()->Is<type::Array>()) {
out << " " << module_->SymbolToName(v->symbol());
}
}
@@ -1447,7 +1442,7 @@
emitted_globals.insert(var->symbol());
auto* type = var->type()->UnwrapIfNeeded();
- if (auto* strct = type->As<ast::type::Struct>()) {
+ if (auto* strct = type->As<type::Struct>()) {
out << "ConstantBuffer<" << module_->SymbolToName(strct->symbol()) << "> "
<< module_->SymbolToName(var->symbol()) << " : register(b"
<< binding->value() << ");" << std::endl;
@@ -1490,7 +1485,7 @@
}
emitted_globals.insert(var->symbol());
- auto* ac = var->type()->As<ast::type::AccessControl>();
+ auto* ac = var->type()->As<type::AccessControl>();
if (ac == nullptr) {
error_ = "access control type required for storage buffer";
return false;
@@ -1712,18 +1707,18 @@
return true;
}
-bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::type::Type* type) {
- if (type->Is<ast::type::Bool>()) {
+bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) {
+ if (type->Is<type::Bool>()) {
out << "false";
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
out << "0.0f";
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
out << "0";
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
out << "0u";
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
return EmitZeroValue(out, vec->type());
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
for (uint32_t i = 0; i < (mat->rows() * mat->columns()); i++) {
if (i != 0) {
out << ", ";
@@ -1851,7 +1846,7 @@
first = false;
if (auto* mem = expr->As<ast::MemberAccessorExpression>()) {
auto* res_type = mem->structure()->result_type()->UnwrapAll();
- if (auto* str = res_type->As<ast::type::Struct>()) {
+ if (auto* str = res_type->As<type::Struct>()) {
auto* str_type = str->impl();
auto* str_member = str_type->get_member(mem->member()->symbol());
@@ -1861,7 +1856,7 @@
}
out << str_member->offset();
- } else if (res_type->Is<ast::type::Vector>()) {
+ } else if (res_type->Is<type::Vector>()) {
// TODO(dsinclair): Swizzle stuff
//
// This must be a single element swizzle if we've got a vector at this
@@ -1891,14 +1886,14 @@
auto* ary_type = ary->array()->result_type()->UnwrapAll();
out << "(";
- if (auto* arr = ary_type->As<ast::type::Array>()) {
+ if (auto* arr = ary_type->As<type::Array>()) {
out << arr->array_stride();
- } else if (ary_type->Is<ast::type::Vector>()) {
+ } else if (ary_type->Is<type::Vector>()) {
// TODO(dsinclair): This is a hack. Our vectors can only be f32, i32
// or u32 which are all 4 bytes. When we get f16 or other types we'll
// have to ask the type for the byte size.
out << "4";
- } else if (auto* mat = ary_type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = ary_type->As<type::Matrix>()) {
if (mat->columns() == 2) {
out << "8";
} else {
@@ -1939,16 +1934,16 @@
bool is_store = rhs != nullptr;
std::string access_method = is_store ? "Store" : "Load";
- if (auto* vec = result_type->As<ast::type::Vector>()) {
+ if (auto* vec = result_type->As<type::Vector>()) {
access_method += std::to_string(vec->size());
- } else if (auto* mat = result_type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = result_type->As<type::Matrix>()) {
access_method += std::to_string(mat->rows());
}
// If we aren't storing then we need to put in the outer cast.
if (!is_store) {
if (result_type->is_float_scalar_or_vector() ||
- result_type->Is<ast::type::Matrix>()) {
+ result_type->Is<type::Matrix>()) {
out << "asfloat(";
} else if (result_type->is_signed_scalar_or_vector()) {
out << "asint(";
@@ -1968,7 +1963,7 @@
return false;
}
- if (auto* mat = result_type->As<ast::type::Matrix>()) {
+ if (auto* mat = result_type->As<type::Matrix>()) {
// TODO(dsinclair): This is assuming 4 byte elements. Will need to be fixed
// if we get matrixes of f16 or f64.
uint32_t stride = mat->rows() == 2 ? 8 : 16;
@@ -2056,7 +2051,7 @@
//
// If the data is a multi-element swizzle then we will not load the swizzle
// portion through the Load command.
- if (data_type->Is<ast::type::Vector>() &&
+ if (data_type->Is<type::Vector>() &&
module_->SymbolToName(expr->member()->symbol()).size() > 1) {
return false;
}
@@ -2200,20 +2195,20 @@
}
bool GeneratorImpl::EmitType(std::ostream& out,
- ast::type::Type* type,
+ type::Type* type,
const std::string& name) {
// HLSL doesn't have the read/write only markings so just unwrap the access
// control type.
- if (auto* ac = type->As<ast::type::AccessControl>()) {
+ if (auto* ac = type->As<type::AccessControl>()) {
return EmitType(out, ac->type(), name);
}
- if (auto* alias = type->As<ast::type::Alias>()) {
+ if (auto* alias = type->As<type::Alias>()) {
out << namer_.NameFor(module_->SymbolToName(alias->symbol()));
- } else if (auto* ary = type->As<ast::type::Array>()) {
- ast::type::Type* base_type = ary;
+ } else if (auto* ary = type->As<type::Array>()) {
+ type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<ast::type::Array>()) {
+ while (auto* arr = base_type->As<type::Array>()) {
if (arr->IsRuntimeArray()) {
// TODO(dsinclair): Support runtime arrays
// https://bugs.chromium.org/p/tint/issues/detail?id=185
@@ -2233,56 +2228,56 @@
for (uint32_t size : sizes) {
out << "[" << size << "]";
}
- } else if (type->Is<ast::type::Bool>()) {
+ } else if (type->Is<type::Bool>()) {
out << "bool";
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
out << "float";
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
out << "int";
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
if (!EmitType(out, mat->type(), "")) {
return false;
}
out << mat->rows() << "x" << mat->columns();
- } else if (type->Is<ast::type::Pointer>()) {
+ } else if (type->Is<type::Pointer>()) {
// TODO(dsinclair): What do we do with pointers in HLSL?
// https://bugs.chromium.org/p/tint/issues/detail?id=183
error_ = "pointers not supported in HLSL";
return false;
- } else if (auto* sampler = type->As<ast::type::Sampler>()) {
+ } else if (auto* sampler = type->As<type::Sampler>()) {
out << "Sampler";
if (sampler->IsComparison()) {
out << "Comparison";
}
out << "State";
- } else if (auto* str = type->As<ast::type::Struct>()) {
+ } else if (auto* str = type->As<type::Struct>()) {
out << module_->SymbolToName(str->symbol());
- } else if (auto* tex = type->As<ast::type::Texture>()) {
- if (tex->Is<ast::type::StorageTexture>()) {
+ } else if (auto* tex = type->As<type::Texture>()) {
+ if (tex->Is<type::StorageTexture>()) {
out << "RW";
}
out << "Texture";
switch (tex->dim()) {
- case ast::type::TextureDimension::k1d:
+ case type::TextureDimension::k1d:
out << "1D";
break;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
out << "1DArray";
break;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
out << "2D";
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
out << "2DArray";
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
out << "3D";
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
out << "Cube";
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
out << "CubeArray";
break;
default:
@@ -2290,7 +2285,7 @@
return false;
}
- if (auto* st = tex->As<ast::type::StorageTexture>()) {
+ if (auto* st = tex->As<type::StorageTexture>()) {
auto* component = image_format_to_rwtexture_type(st->image_format());
if (component == nullptr) {
error_ = "Unsupported StorageTexture ImageFormat: " +
@@ -2299,15 +2294,15 @@
}
out << "<" << component << ">";
}
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
out << "uint";
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
auto size = vec->size();
- if (vec->type()->Is<ast::type::F32>() && size >= 1 && size <= 4) {
+ if (vec->type()->Is<type::F32>() && size >= 1 && size <= 4) {
out << "float" << size;
- } else if (vec->type()->Is<ast::type::I32>() && size >= 1 && size <= 4) {
+ } else if (vec->type()->Is<type::I32>() && size >= 1 && size <= 4) {
out << "int" << size;
- } else if (vec->type()->Is<ast::type::U32>() && size >= 1 && size <= 4) {
+ } else if (vec->type()->Is<type::U32>() && size >= 1 && size <= 4) {
out << "uint" << size;
} else {
out << "vector<";
@@ -2316,7 +2311,7 @@
}
out << ", " << size << ">";
}
- } else if (type->Is<ast::type::Void>()) {
+ } else if (type->Is<type::Void>()) {
out << "void";
} else {
error_ = "unknown type in EmitType";
@@ -2327,7 +2322,7 @@
}
bool GeneratorImpl::EmitStructType(std::ostream& out,
- const ast::type::Struct* str,
+ const type::Struct* str,
const std::string& name) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::StructDecoration::kNone) {
@@ -2344,7 +2339,7 @@
return false;
}
// Array member name will be output with the type
- if (!mem->type()->Is<ast::type::Array>()) {
+ if (!mem->type()->Is<type::Array>()) {
out << " " << namer_.NameFor(module_->SymbolToName(mem->symbol()));
}
out << ";" << std::endl;
@@ -2407,7 +2402,7 @@
if (!EmitType(out, var->type(), module_->SymbolToName(var->symbol()))) {
return false;
}
- if (!var->type()->Is<ast::type::Array>()) {
+ if (!var->type()->Is<type::Array>()) {
out << " " << module_->SymbolToName(var->symbol());
}
out << constructor_out.str() << ";" << std::endl;
@@ -2464,7 +2459,7 @@
if (!EmitType(out, var->type(), module_->SymbolToName(var->symbol()))) {
return false;
}
- if (!var->type()->Is<ast::type::Array>()) {
+ if (!var->type()->Is<type::Array>()) {
out << " " << module_->SymbolToName(var->symbol());
}
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index 0044b02..433c3a1 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -38,10 +38,10 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/struct_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/scope_stack.h"
+#include "src/type/struct_type.h"
#include "src/writer/hlsl/namer.h"
namespace tint {
@@ -85,7 +85,7 @@
/// @param out the output stream
/// @param ty the constructed type to generate
/// @returns true if the constructed type was emitted
- bool EmitConstructedType(std::ostream& out, const ast::type::Type* ty);
+ bool EmitConstructedType(std::ostream& out, const type::Type* ty);
/// Handles an array accessor expression
/// @param pre the preamble for the expression stream
/// @param out the output of the expression stream
@@ -290,16 +290,14 @@
/// @param type the type to generate
/// @param name the name of the variable, only used for array emission
/// @returns true if the type is emitted
- bool EmitType(std::ostream& out,
- ast::type::Type* type,
- const std::string& name);
+ bool EmitType(std::ostream& out, type::Type* type, const std::string& name);
/// Handles generating a structure declaration
/// @param out the output stream
/// @param ty the struct to generate
/// @param name the struct name
/// @returns true if the struct is emitted
bool EmitStructType(std::ostream& out,
- const ast::type::Struct* ty,
+ const type::Struct* ty,
const std::string& name);
/// Handles a unary op expression
/// @param pre the preamble for the expression stream
@@ -313,7 +311,7 @@
/// @param out the output stream
/// @param type the type to emit the value for
/// @returns true if the zero value was successfully emitted.
- bool EmitZeroValue(std::ostream& out, ast::type::Type* type);
+ bool EmitZeroValue(std::ostream& out, type::Type* type);
/// Handles generating a variable
/// @param out the output stream
/// @param var the variable to generate
diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc
index 544f4ea..e04d641 100644
--- a/src/writer/hlsl/generator_impl_alias_type_test.cc
+++ b/src/writer/hlsl/generator_impl_alias_type_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc
index fc71b74..cb65569 100644
--- a/src/writer/hlsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc
index 457acde..3240c10 100644
--- a/src/writer/hlsl/generator_impl_binary_test.cc
+++ b/src/writer/hlsl/generator_impl_binary_test.cc
@@ -28,16 +28,16 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc
index c47df56..a6fc904 100644
--- a/src/writer/hlsl/generator_impl_bitcast_test.cc
+++ b/src/writer/hlsl/generator_impl_bitcast_test.cc
@@ -17,9 +17,9 @@
#include "src/ast/bitcast_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc
index c9b40b4..92b1905 100644
--- a/src/writer/hlsl/generator_impl_call_test.cc
+++ b/src/writer/hlsl/generator_impl_call_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/function.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc
index 23a9a94..d6fd895 100644
--- a/src/writer/hlsl/generator_impl_case_test.cc
+++ b/src/writer/hlsl/generator_impl_case_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc
index 6625755..6a8c533 100644
--- a/src/writer/hlsl/generator_impl_cast_test.cc
+++ b/src/writer/hlsl/generator_impl_cast_test.cc
@@ -16,9 +16,9 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc
index 55512a4..0eaeb36 100644
--- a/src/writer/hlsl/generator_impl_constructor_test.cc
+++ b/src/writer/hlsl/generator_impl_constructor_test.cc
@@ -17,15 +17,15 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index 70ce1b3..ee5e40b 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -32,16 +32,16 @@
#include "src/ast/struct.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/hlsl/test_helper.h"
@@ -380,7 +380,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
@@ -426,7 +426,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ type::AccessControl ac(ast::AccessControl::kReadOnly, s);
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
@@ -473,7 +473,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
@@ -773,7 +773,7 @@
TEST_F(HlslGeneratorImplTest_Function,
Emit_FunctionDecoration_Called_By_EntryPoint_With_StorageBuffer) {
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, ty.vec4<f32>());
+ type::AccessControl ac(ast::AccessControl::kReadWrite, ty.vec4<f32>());
auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
create<ast::BindingDecoration>(0),
@@ -982,7 +982,7 @@
ast::StructDecorationList{create<ast::StructBlockDecoration>()});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc
index 04a7785..8b68fcc 100644
--- a/src/writer/hlsl/generator_impl_import_test.cc
+++ b/src/writer/hlsl/generator_impl_import_test.cc
@@ -22,11 +22,11 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/hlsl/test_helper.h"
diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc
index 2658f74..79000d5 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc
@@ -15,8 +15,8 @@
#include "src/ast/call_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/hlsl/test_helper.h"
diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
index e0ec794..30fab52 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
@@ -17,9 +17,9 @@
#include "gtest/gtest.h"
#include "src/ast/builder.h"
#include "src/ast/intrinsic_texture_helper_test.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
#include "src/type_determiner.h"
#include "src/writer/hlsl/generator_impl.h"
diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc
index 4e7f017..100e21d 100644
--- a/src/writer/hlsl/generator_impl_loop_test.cc
+++ b/src/writer/hlsl/generator_impl_loop_test.cc
@@ -21,9 +21,9 @@
#include "src/ast/loop_statement.h"
#include "src/ast/module.h"
#include "src/ast/return_statement.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/f32_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc
index ee8345a..3121135 100644
--- a/src/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -25,10 +25,10 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/hlsl/test_helper.h"
@@ -352,10 +352,10 @@
// data.a[2];
//
// -> asint(data.Load((2 * 4));
- ast::type::Array ary(ty.i32, 5,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(4),
- });
+ type::Array ary(ty.i32, 5,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
+ });
auto* str = create<ast::Struct>(
ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})},
@@ -384,10 +384,10 @@
// data.a[(2 + 4) - 3];
//
// -> asint(data.Load((4 * ((2 + 4) - 3)));
- ast::type::Array ary(ty.i32, 5,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(4),
- });
+ type::Array ary(ty.i32, 5,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
+ });
auto* str = create<ast::Struct>(
ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})},
@@ -453,10 +453,10 @@
//
// -> data.Store((2 * 4), asuint(2.3f));
- ast::type::Array ary(ty.i32, 5,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(4),
- });
+ type::Array ary(ty.i32, 5,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(4),
+ });
auto* str = create<ast::Struct>(
ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})},
@@ -608,10 +608,10 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(data, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(32),
- });
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(32),
+ });
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
@@ -657,8 +657,8 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(
- data, 4, ast::ArrayDecorationList{create<ast::StrideDecoration>(32)});
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{create<ast::StrideDecoration>(32)});
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
@@ -706,10 +706,10 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(data, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(32),
- });
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(32),
+ });
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
@@ -756,10 +756,10 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(data, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(32),
- });
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(32),
+ });
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
@@ -806,10 +806,10 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(data, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(32),
- });
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(32),
+ });
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
@@ -860,10 +860,10 @@
ast::StructDecorationList{});
auto* data = ty.struct_("Data", data_str);
- ast::type::Array ary(data, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(32),
- });
+ type::Array ary(data, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(32),
+ });
auto* pre_str = create<ast::Struct>(
ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})},
diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc
index 171942f..b8ec558 100644
--- a/src/writer/hlsl/generator_impl_module_constant_test.cc
+++ b/src/writer/hlsl/generator_impl_module_constant_test.cc
@@ -19,8 +19,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/writer/hlsl/test_helper.h"
diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc
index 9a73bce..17d8666 100644
--- a/src/writer/hlsl/generator_impl_switch_test.cc
+++ b/src/writer/hlsl/generator_impl_switch_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/module.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc
index 44be70a..27476ae 100644
--- a/src/writer/hlsl/generator_impl_test.cc
+++ b/src/writer/hlsl/generator_impl_test.cc
@@ -17,7 +17,7 @@
#include "src/ast/function.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc
index 9cf3c4f..2655b22 100644
--- a/src/writer/hlsl/generator_impl_type_test.cc
+++ b/src/writer/hlsl/generator_impl_type_test.cc
@@ -19,22 +19,22 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
@@ -126,7 +126,7 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) {
- ast::type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
+ type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(out, &p, "")) << gen.error();
EXPECT_EQ(result(), "float*");
@@ -225,21 +225,21 @@
}
TEST_F(HlslGeneratorImplTest_Type, EmitSampler) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
+ type::Sampler sampler(type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error();
EXPECT_EQ(result(), "SamplerState");
}
TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
+ type::Sampler sampler(type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error();
EXPECT_EQ(result(), "SamplerComparisonState");
}
struct HlslDepthTextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, HlslDepthTextureData data) {
@@ -250,7 +250,7 @@
TEST_P(HlslDepthtexturesTest, Emit) {
auto params = GetParam();
- ast::type::DepthTexture s(params.dim);
+ type::DepthTexture s(params.dim);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), params.result);
@@ -259,15 +259,15 @@
HlslGeneratorImplTest_Type,
HlslDepthtexturesTest,
testing::Values(
- HlslDepthTextureData{ast::type::TextureDimension::k2d, "Texture2D"},
- HlslDepthTextureData{ast::type::TextureDimension::k2dArray,
+ HlslDepthTextureData{type::TextureDimension::k2d, "Texture2D"},
+ HlslDepthTextureData{type::TextureDimension::k2dArray,
"Texture2DArray"},
- HlslDepthTextureData{ast::type::TextureDimension::kCube, "TextureCube"},
- HlslDepthTextureData{ast::type::TextureDimension::kCubeArray,
+ HlslDepthTextureData{type::TextureDimension::kCube, "TextureCube"},
+ HlslDepthTextureData{type::TextureDimension::kCubeArray,
"TextureCubeArray"}));
struct HlslTextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, HlslTextureData data) {
@@ -278,7 +278,7 @@
TEST_P(HlslSampledtexturesTest, Emit) {
auto params = GetParam();
- ast::type::SampledTexture s(params.dim, ty.f32);
+ type::SampledTexture s(params.dim, ty.f32);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), params.result);
@@ -287,27 +287,25 @@
HlslGeneratorImplTest_Type,
HlslSampledtexturesTest,
testing::Values(
- HlslTextureData{ast::type::TextureDimension::k1d, "Texture1D"},
- HlslTextureData{ast::type::TextureDimension::k1dArray,
- "Texture1DArray"},
- HlslTextureData{ast::type::TextureDimension::k2d, "Texture2D"},
- HlslTextureData{ast::type::TextureDimension::k2dArray,
- "Texture2DArray"},
- HlslTextureData{ast::type::TextureDimension::k3d, "Texture3D"},
- HlslTextureData{ast::type::TextureDimension::kCube, "TextureCube"},
- HlslTextureData{ast::type::TextureDimension::kCubeArray,
+ HlslTextureData{type::TextureDimension::k1d, "Texture1D"},
+ HlslTextureData{type::TextureDimension::k1dArray, "Texture1DArray"},
+ HlslTextureData{type::TextureDimension::k2d, "Texture2D"},
+ HlslTextureData{type::TextureDimension::k2dArray, "Texture2DArray"},
+ HlslTextureData{type::TextureDimension::k3d, "Texture3D"},
+ HlslTextureData{type::TextureDimension::kCube, "TextureCube"},
+ HlslTextureData{type::TextureDimension::kCubeArray,
"TextureCubeArray"}));
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
- ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, ty.f32);
+ type::MultisampledTexture s(type::TextureDimension::k2d, ty.f32);
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
EXPECT_EQ(result(), "Texture2D");
}
struct HlslStorageTextureData {
- ast::type::TextureDimension dim;
- ast::type::ImageFormat imgfmt;
+ type::TextureDimension dim;
+ type::ImageFormat imgfmt;
bool ro;
std::string result;
};
@@ -320,11 +318,10 @@
TEST_P(HlslStoragetexturesTest, Emit) {
auto params = GetParam();
- ast::type::StorageTexture s(params.dim,
- params.imgfmt);
- ast::type::AccessControl ac(params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- &s);
+ type::StorageTexture s(params.dim, params.imgfmt);
+ type::AccessControl ac(params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ &s);
ASSERT_TRUE(gen.EmitType(out, &ac, "")) << gen.error();
EXPECT_EQ(result(), params.result);
@@ -332,55 +329,54 @@
INSTANTIATE_TEST_SUITE_P(
HlslGeneratorImplTest_Type,
HlslStoragetexturesTest,
- testing::Values(
- HlslStorageTextureData{ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kRgba8Unorm, true,
- "RWTexture1D<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1dArray,
- ast::type::ImageFormat::kRgba8Snorm, true,
- "RWTexture1DArray<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kRgba16Float, true,
- "RWTexture2D<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2dArray,
- ast::type::ImageFormat::kR32Float, true,
- "RWTexture2DArray<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k3d,
- ast::type::ImageFormat::kRg32Float, true,
- "RWTexture3D<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kRgba32Float, false,
- "RWTexture1D<float4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1dArray,
- ast::type::ImageFormat::kRgba8Uint, false,
- "RWTexture1DArray<uint4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kRgba16Uint, false,
- "RWTexture2D<uint4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2dArray,
- ast::type::ImageFormat::kR32Uint, false,
- "RWTexture2DArray<uint4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k3d,
- ast::type::ImageFormat::kRg32Uint, false,
- "RWTexture3D<uint4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kRgba32Uint, true,
- "RWTexture1D<uint4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1dArray,
- ast::type::ImageFormat::kRgba8Sint, true,
- "RWTexture1DArray<int4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kRgba16Sint, true,
- "RWTexture2D<int4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k2dArray,
- ast::type::ImageFormat::kR32Sint, true,
- "RWTexture2DArray<int4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k3d,
- ast::type::ImageFormat::kRg32Sint, true,
- "RWTexture3D<int4>"},
- HlslStorageTextureData{ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kRgba32Sint, false,
- "RWTexture1D<int4>"}));
+ testing::Values(HlslStorageTextureData{type::TextureDimension::k1d,
+ type::ImageFormat::kRgba8Unorm, true,
+ "RWTexture1D<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k1dArray,
+ type::ImageFormat::kRgba8Snorm, true,
+ "RWTexture1DArray<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k2d,
+ type::ImageFormat::kRgba16Float,
+ true, "RWTexture2D<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k2dArray,
+ type::ImageFormat::kR32Float, true,
+ "RWTexture2DArray<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k3d,
+ type::ImageFormat::kRg32Float, true,
+ "RWTexture3D<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k1d,
+ type::ImageFormat::kRgba32Float,
+ false, "RWTexture1D<float4>"},
+ HlslStorageTextureData{type::TextureDimension::k1dArray,
+ type::ImageFormat::kRgba8Uint, false,
+ "RWTexture1DArray<uint4>"},
+ HlslStorageTextureData{type::TextureDimension::k2d,
+ type::ImageFormat::kRgba16Uint,
+ false, "RWTexture2D<uint4>"},
+ HlslStorageTextureData{type::TextureDimension::k2dArray,
+ type::ImageFormat::kR32Uint, false,
+ "RWTexture2DArray<uint4>"},
+ HlslStorageTextureData{type::TextureDimension::k3d,
+ type::ImageFormat::kRg32Uint, false,
+ "RWTexture3D<uint4>"},
+ HlslStorageTextureData{type::TextureDimension::k1d,
+ type::ImageFormat::kRgba32Uint, true,
+ "RWTexture1D<uint4>"},
+ HlslStorageTextureData{type::TextureDimension::k1dArray,
+ type::ImageFormat::kRgba8Sint, true,
+ "RWTexture1DArray<int4>"},
+ HlslStorageTextureData{type::TextureDimension::k2d,
+ type::ImageFormat::kRgba16Sint, true,
+ "RWTexture2D<int4>"},
+ HlslStorageTextureData{type::TextureDimension::k2dArray,
+ type::ImageFormat::kR32Sint, true,
+ "RWTexture2DArray<int4>"},
+ HlslStorageTextureData{type::TextureDimension::k3d,
+ type::ImageFormat::kRg32Sint, true,
+ "RWTexture3D<int4>"},
+ HlslStorageTextureData{type::TextureDimension::k1d,
+ type::ImageFormat::kRgba32Sint,
+ false, "RWTexture1D<int4>"}));
} // namespace
} // namespace hlsl
diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
index 5d5eae9..10e62fe 100644
--- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
@@ -17,12 +17,12 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/hlsl/test_helper.h"
namespace tint {
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 1de2fb9..254ca89 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -44,27 +44,27 @@
#include "src/ast/sint_literal.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/float_to_string.h"
namespace tint {
@@ -167,51 +167,50 @@
return true;
}
-uint32_t GeneratorImpl::calculate_largest_alignment(ast::type::Struct* type) {
- auto* stct = type->As<ast::type::Struct>()->impl();
+uint32_t GeneratorImpl::calculate_largest_alignment(type::Struct* type) {
+ auto* stct = type->As<type::Struct>()->impl();
uint32_t largest_alignment = 0;
for (auto* mem : stct->members()) {
auto align = calculate_alignment_size(mem->type());
if (align == 0) {
return 0;
}
- if (!mem->type()->Is<ast::type::Struct>()) {
+ if (!mem->type()->Is<type::Struct>()) {
largest_alignment = std::max(largest_alignment, align);
} else {
largest_alignment = std::max(
largest_alignment,
- calculate_largest_alignment(mem->type()->As<ast::type::Struct>()));
+ calculate_largest_alignment(mem->type()->As<type::Struct>()));
}
}
return largest_alignment;
}
-uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) {
- if (auto* alias = type->As<ast::type::Alias>()) {
+uint32_t GeneratorImpl::calculate_alignment_size(type::Type* type) {
+ if (auto* alias = type->As<type::Alias>()) {
return calculate_alignment_size(alias->type());
}
- if (auto* ary = type->As<ast::type::Array>()) {
+ if (auto* ary = type->As<type::Array>()) {
// TODO(dsinclair): Handle array stride and adjust for alignment.
uint32_t type_size = calculate_alignment_size(ary->type());
return ary->size() * type_size;
}
- if (type->Is<ast::type::Bool>()) {
+ if (type->Is<type::Bool>()) {
return 1;
}
- if (type->Is<ast::type::Pointer>()) {
+ if (type->Is<type::Pointer>()) {
return 0;
}
- if (type->Is<ast::type::F32>() || type->Is<ast::type::I32>() ||
- type->Is<ast::type::U32>()) {
+ if (type->Is<type::F32>() || type->Is<type::I32>() || type->Is<type::U32>()) {
return 4;
}
- if (auto* mat = type->As<ast::type::Matrix>()) {
+ if (auto* mat = type->As<type::Matrix>()) {
// TODO(dsinclair): Handle MatrixStride
// https://github.com/gpuweb/gpuweb/issues/773
uint32_t type_size = calculate_alignment_size(mat->type());
return mat->rows() * mat->columns() * type_size;
}
- if (auto* stct_ty = type->As<ast::type::Struct>()) {
+ if (auto* stct_ty = type->As<type::Struct>()) {
auto* stct = stct_ty->impl();
uint32_t count = 0;
uint32_t largest_alignment = 0;
@@ -226,7 +225,7 @@
if (align == 0) {
return 0;
}
- if (auto* str = mem->type()->As<ast::type::Struct>()) {
+ if (auto* str = mem->type()->As<type::Struct>()) {
largest_alignment =
std::max(largest_alignment, calculate_largest_alignment(str));
} else {
@@ -241,7 +240,7 @@
count = adjust_for_alignment(count, largest_alignment);
return count;
}
- if (auto* vec = type->As<ast::type::Vector>()) {
+ if (auto* vec = type->As<type::Vector>()) {
uint32_t type_size = calculate_alignment_size(vec->type());
if (vec->size() == 2) {
return 2 * type_size;
@@ -251,17 +250,17 @@
return 0;
}
-bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) {
+bool GeneratorImpl::EmitConstructedType(const type::Type* ty) {
make_indent();
- if (auto* alias = ty->As<ast::type::Alias>()) {
+ if (auto* alias = ty->As<type::Alias>()) {
out_ << "typedef ";
if (!EmitType(alias->type(), "")) {
return false;
}
out_ << " " << namer_.NameFor(module_->SymbolToName(alias->symbol())) << ";"
<< std::endl;
- } else if (auto* str = ty->As<ast::type::Struct>()) {
+ } else if (auto* str = ty->As<type::Struct>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -611,31 +610,29 @@
auto const kNotUsed = ast::intrinsic::TextureSignature::Parameters::kNotUsed;
assert(pidx.texture != kNotUsed);
- auto* texture_type = params[pidx.texture]
- ->result_type()
- ->UnwrapAll()
- ->As<ast::type::Texture>();
+ auto* texture_type =
+ params[pidx.texture]->result_type()->UnwrapAll()->As<type::Texture>();
switch (ident->intrinsic()) {
case ast::Intrinsic::kTextureDimensions: {
std::vector<const char*> dims;
switch (texture_type->dim()) {
- case ast::type::TextureDimension::kNone:
+ case type::TextureDimension::kNone:
error_ = "texture dimension is kNone";
return false;
- case ast::type::TextureDimension::k1d:
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1d:
+ case type::TextureDimension::k1dArray:
dims = {"width"};
break;
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k2dArray:
dims = {"width", "height"};
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
dims = {"width", "height", "depth"};
break;
- case ast::type::TextureDimension::kCube:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCube:
+ case type::TextureDimension::kCubeArray:
// width == height == depth for cubes
// See https://github.com/gpuweb/gpuweb/issues/1345
dims = {"width", "height", "height"};
@@ -768,20 +765,20 @@
auto dim = params[pidx.texture]
->result_type()
->UnwrapPtrIfNeeded()
- ->As<ast::type::Texture>()
+ ->As<type::Texture>()
->dim();
switch (dim) {
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k2dArray:
maybe_write_comma();
out_ << "gradient2d(";
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
maybe_write_comma();
out_ << "gradient3d(";
break;
- case ast::type::TextureDimension::kCube:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCube:
+ case type::TextureDimension::kCubeArray:
maybe_write_comma();
out_ << "gradientcube(";
break;
@@ -853,26 +850,26 @@
out += module_->SymbolToName(ident->symbol());
break;
case ast::Intrinsic::kAbs:
- if (ident->result_type()->Is<ast::type::F32>()) {
+ if (ident->result_type()->Is<type::F32>()) {
out += "fabs";
- } else if (ident->result_type()->Is<ast::type::U32>() ||
- ident->result_type()->Is<ast::type::I32>()) {
+ } else if (ident->result_type()->Is<type::U32>() ||
+ ident->result_type()->Is<type::I32>()) {
out += "abs";
}
break;
case ast::Intrinsic::kMax:
- if (ident->result_type()->Is<ast::type::F32>()) {
+ if (ident->result_type()->Is<type::F32>()) {
out += "fmax";
- } else if (ident->result_type()->Is<ast::type::U32>() ||
- ident->result_type()->Is<ast::type::I32>()) {
+ } else if (ident->result_type()->Is<type::U32>() ||
+ ident->result_type()->Is<type::I32>()) {
out += "max";
}
break;
case ast::Intrinsic::kMin:
- if (ident->result_type()->Is<ast::type::F32>()) {
+ if (ident->result_type()->Is<type::F32>()) {
out += "fmin";
- } else if (ident->result_type()->Is<ast::type::U32>() ||
- ident->result_type()->Is<ast::type::I32>()) {
+ } else if (ident->result_type()->Is<type::U32>() ||
+ ident->result_type()->Is<type::I32>()) {
out += "min";
}
break;
@@ -951,7 +948,7 @@
}
bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
- if (expr->type()->Is<ast::type::Array>()) {
+ if (expr->type()->Is<type::Array>()) {
out_ << "{";
} else {
if (!EmitType(expr->type(), "")) {
@@ -980,7 +977,7 @@
}
}
- if (expr->type()->Is<ast::type::Array>()) {
+ if (expr->type()->Is<type::Array>()) {
out_ << "}";
} else {
out_ << ")";
@@ -988,26 +985,26 @@
return true;
}
-bool GeneratorImpl::EmitZeroValue(ast::type::Type* type) {
- if (type->Is<ast::type::Bool>()) {
+bool GeneratorImpl::EmitZeroValue(type::Type* type) {
+ if (type->Is<type::Bool>()) {
out_ << "false";
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
out_ << "0.0f";
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
out_ << "0";
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
out_ << "0u";
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
return EmitZeroValue(vec->type());
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
return EmitZeroValue(mat->type());
- } else if (auto* arr = type->As<ast::type::Array>()) {
+ } else if (auto* arr = type->As<type::Array>()) {
out_ << "{";
if (!EmitZeroValue(arr->type())) {
return false;
}
out_ << "}";
- } else if (type->As<ast::type::Struct>()) {
+ } else if (type->As<type::Struct>()) {
out_ << "{}";
} else {
error_ = "Invalid type for zero emission: " + type->type_name();
@@ -1348,7 +1345,7 @@
}
first = false;
- auto* ac = var->type()->As<ast::type::AccessControl>();
+ auto* ac = var->type()->As<type::AccessControl>();
if (ac == nullptr) {
error_ = "invalid type for storage buffer, expected access control";
return false;
@@ -1374,7 +1371,7 @@
return false;
}
// Array name is output as part of the type
- if (!v->type()->Is<ast::type::Array>()) {
+ if (!v->type()->Is<type::Array>()) {
out_ << " " << module_->SymbolToName(v->symbol());
}
}
@@ -1512,7 +1509,7 @@
auto* binding = data.second.binding;
// auto* set = data.second.set;
- auto* ac = var->type()->As<ast::type::AccessControl>();
+ auto* ac = var->type()->As<type::AccessControl>();
if (ac == nullptr) {
error_ = "invalid type for storage buffer, expected access control";
return false;
@@ -1864,9 +1861,9 @@
return true;
}
-bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
+bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) {
std::string access_str = "";
- if (auto* ac = type->As<ast::type::AccessControl>()) {
+ if (auto* ac = type->As<type::AccessControl>()) {
if (ac->access_control() == ast::AccessControl::kReadOnly) {
access_str = "read";
} else if (ac->access_control() == ast::AccessControl::kWriteOnly) {
@@ -1879,12 +1876,12 @@
type = ac->type();
}
- if (auto* alias = type->As<ast::type::Alias>()) {
+ if (auto* alias = type->As<type::Alias>()) {
out_ << namer_.NameFor(module_->SymbolToName(alias->symbol()));
- } else if (auto* ary = type->As<ast::type::Array>()) {
- ast::type::Type* base_type = ary;
+ } else if (auto* ary = type->As<type::Array>()) {
+ type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<ast::type::Array>()) {
+ while (auto* arr = base_type->As<type::Array>()) {
if (arr->IsRuntimeArray()) {
sizes.push_back(1);
} else {
@@ -1901,79 +1898,79 @@
for (uint32_t size : sizes) {
out_ << "[" << size << "]";
}
- } else if (type->Is<ast::type::Bool>()) {
+ } else if (type->Is<type::Bool>()) {
out_ << "bool";
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
out_ << "float";
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
out_ << "int";
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
if (!EmitType(mat->type(), "")) {
return false;
}
out_ << mat->columns() << "x" << mat->rows();
- } else if (auto* ptr = type->As<ast::type::Pointer>()) {
+ } else if (auto* ptr = type->As<type::Pointer>()) {
// TODO(dsinclair): Storage class?
if (!EmitType(ptr->type(), "")) {
return false;
}
out_ << "*";
- } else if (type->Is<ast::type::Sampler>()) {
+ } else if (type->Is<type::Sampler>()) {
out_ << "sampler";
- } else if (auto* str = type->As<ast::type::Struct>()) {
+ } else if (auto* str = type->As<type::Struct>()) {
// The struct type emits as just the name. The declaration would be emitted
// as part of emitting the constructed types.
out_ << module_->SymbolToName(str->symbol());
- } else if (auto* tex = type->As<ast::type::Texture>()) {
- if (tex->Is<ast::type::DepthTexture>()) {
+ } else if (auto* tex = type->As<type::Texture>()) {
+ if (tex->Is<type::DepthTexture>()) {
out_ << "depth";
} else {
out_ << "texture";
}
switch (tex->dim()) {
- case ast::type::TextureDimension::k1d:
+ case type::TextureDimension::k1d:
out_ << "1d";
break;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
out_ << "1d_array";
break;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
out_ << "2d";
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
out_ << "2d_array";
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
out_ << "3d";
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
out_ << "cube";
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:
error_ = "Invalid texture dimensions";
return false;
}
- if (tex->Is<ast::type::MultisampledTexture>()) {
+ if (tex->Is<type::MultisampledTexture>()) {
out_ << "_ms";
}
out_ << "<";
- if (tex->Is<ast::type::DepthTexture>()) {
+ if (tex->Is<type::DepthTexture>()) {
out_ << "float, access::sample";
- } else if (auto* storage = tex->As<ast::type::StorageTexture>()) {
+ } else if (auto* storage = tex->As<type::StorageTexture>()) {
if (!EmitType(storage->type(), "")) {
return false;
}
out_ << ", access::" << access_str;
- } else if (auto* ms = tex->As<ast::type::MultisampledTexture>()) {
+ } else if (auto* ms = tex->As<type::MultisampledTexture>()) {
if (!EmitType(ms->type(), "")) {
return false;
}
out_ << ", access::sample";
- } else if (auto* sampled = tex->As<ast::type::SampledTexture>()) {
+ } else if (auto* sampled = tex->As<type::SampledTexture>()) {
if (!EmitType(sampled->type(), "")) {
return false;
}
@@ -1984,14 +1981,14 @@
}
out_ << ">";
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
out_ << "uint";
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
if (!EmitType(vec->type(), "")) {
return false;
}
out_ << vec->size();
- } else if (type->Is<ast::type::Void>()) {
+ } else if (type->Is<type::Void>()) {
out_ << "void";
} else {
error_ = "unknown type in EmitType: " + type->type_name();
@@ -2001,7 +1998,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) {
+bool GeneratorImpl::EmitStructType(const type::Struct* str) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::StructDecoration::kNone) {
// }
@@ -2040,7 +2037,7 @@
current_offset += size;
// Array member name will be output with the type
- if (!mem->type()->Is<ast::type::Array>()) {
+ if (!mem->type()->Is<type::Array>()) {
out_ << " " << namer_.NameFor(module_->SymbolToName(mem->symbol()));
}
out_ << ";" << std::endl;
@@ -2086,7 +2083,7 @@
if (!EmitType(var->type(), module_->SymbolToName(var->symbol()))) {
return false;
}
- if (!var->type()->Is<ast::type::Array>()) {
+ if (!var->type()->Is<type::Array>()) {
out_ << " " << module_->SymbolToName(var->symbol());
}
@@ -2128,7 +2125,7 @@
if (!EmitType(var->type(), module_->SymbolToName(var->symbol()))) {
return false;
}
- if (!var->type()->Is<ast::type::Array>()) {
+ if (!var->type()->Is<type::Array>()) {
out_ << " " << module_->SymbolToName(var->symbol());
}
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index 63ff186..95b6109 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -39,10 +39,10 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/struct_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/scope_stack.h"
+#include "src/type/struct_type.h"
#include "src/writer/msl/namer.h"
#include "src/writer/text_generator.h"
@@ -65,16 +65,16 @@
/// for pointers as the size is unknown.
/// @param type the type to calculate the alignment size for
/// @returns the number of bytes used to align `type` or 0 on error
- uint32_t calculate_alignment_size(ast::type::Type* type);
+ uint32_t calculate_alignment_size(type::Type* type);
/// Calculates the largest alignment seen within a struct
/// @param type the struct to calculate
/// @returns the largest alignment value
- uint32_t calculate_largest_alignment(ast::type::Struct* type);
+ uint32_t calculate_largest_alignment(type::Struct* type);
/// Handles generating a constructed
/// @param ty the constructed type to generate
/// @returns true if the constructed type was emitted
- bool EmitConstructedType(const ast::type::Type* ty);
+ bool EmitConstructedType(const type::Type* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
@@ -204,11 +204,11 @@
/// @param type the type to generate
/// @param name the name of the variable, only used for array emission
/// @returns true if the type is emitted
- bool EmitType(ast::type::Type* type, const std::string& name);
+ bool EmitType(type::Type* type, const std::string& name);
/// Handles generating a struct declaration
/// @param str the struct to generate
/// @returns true if the struct is emitted
- bool EmitStructType(const ast::type::Struct* str);
+ bool EmitStructType(const type::Struct* str);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
@@ -229,7 +229,7 @@
/// Emits the zero value for the given type
/// @param type the type to emit the value for
/// @returns true if the zero value was successfully emitted.
- bool EmitZeroValue(ast::type::Type* type);
+ bool EmitZeroValue(type::Type* type);
/// Determines if the function needs the input struct passed to it.
/// @param func the function to check
diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc
index b22aa74..0648d20 100644
--- a/src/writer/msl/generator_impl_alias_type_test.cc
+++ b/src/writer/msl/generator_impl_alias_type_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/module.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc
index 5b5c54d..9f8cda6 100644
--- a/src/writer/msl/generator_impl_array_accessor_test.cc
+++ b/src/writer/msl/generator_impl_array_accessor_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_bitcast_test.cc b/src/writer/msl/generator_impl_bitcast_test.cc
index de56fd8..372a889 100644
--- a/src/writer/msl/generator_impl_bitcast_test.cc
+++ b/src/writer/msl/generator_impl_bitcast_test.cc
@@ -18,7 +18,7 @@
#include "src/ast/bitcast_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc
index 3b7c9ed..6df0f19 100644
--- a/src/writer/msl/generator_impl_call_test.cc
+++ b/src/writer/msl/generator_impl_call_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/function.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc
index dd19fcc..a37f33e 100644
--- a/src/writer/msl/generator_impl_case_test.cc
+++ b/src/writer/msl/generator_impl_case_test.cc
@@ -21,7 +21,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc
index 3713b86..1377987 100644
--- a/src/writer/msl/generator_impl_cast_test.cc
+++ b/src/writer/msl/generator_impl_cast_test.cc
@@ -17,9 +17,9 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc
index ff82185..aa38874 100644
--- a/src/writer/msl/generator_impl_constructor_test.cc
+++ b/src/writer/msl/generator_impl_constructor_test.cc
@@ -18,15 +18,15 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
@@ -117,7 +117,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
- ast::type::Array ary(ty.vec3<f32>(), 3, ast::ArrayDecorationList{});
+ type::Array ary(ty.vec3<f32>(), 3, ast::ArrayDecorationList{});
ast::ExpressionList ary_values;
diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
index 461035b..dbe62b9 100644
--- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc
+++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
@@ -22,11 +22,11 @@
#include "src/ast/module.h"
#include "src/ast/pipeline_stage.h"
#include "src/ast/stage_decoration.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc
index 53b80ec..0ad50d3 100644
--- a/src/writer/msl/generator_impl_function_test.cc
+++ b/src/writer/msl/generator_impl_function_test.cc
@@ -35,15 +35,15 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
@@ -329,7 +329,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
mod->AddConstructedType(s);
@@ -382,7 +382,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ type::AccessControl ac(ast::AccessControl::kReadOnly, s);
mod->AddConstructedType(s);
auto* coord_var =
@@ -687,7 +687,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
mod->AddConstructedType(s);
auto* coord_var =
@@ -754,7 +754,7 @@
ast::StructDecorationList{});
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadOnly, s);
+ type::AccessControl ac(ast::AccessControl::kReadOnly, s);
mod->AddConstructedType(s);
auto* coord_var =
@@ -933,7 +933,7 @@
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* data_var =
Var("data", ast::StorageClass::kStorage, &ac, nullptr,
diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc
index b7d97d6..e123331 100644
--- a/src/writer/msl/generator_impl_import_test.cc
+++ b/src/writer/msl/generator_impl_import_test.cc
@@ -23,11 +23,11 @@
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc
index b1f0e92..41fa96e 100644
--- a/src/writer/msl/generator_impl_intrinsic_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_test.cc
@@ -16,8 +16,8 @@
#include "src/ast/call_expression.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/module.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_intrinsic_texture_test.cc b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
index 54c2a9e..4767626 100644
--- a/src/writer/msl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
@@ -17,9 +17,9 @@
#include "gtest/gtest.h"
#include "src/ast/builder.h"
#include "src/ast/intrinsic_texture_helper_test.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc
index 76e8a3e..d7f13ab 100644
--- a/src/writer/msl/generator_impl_loop_test.cc
+++ b/src/writer/msl/generator_impl_loop_test.cc
@@ -22,9 +22,9 @@
#include "src/ast/loop_statement.h"
#include "src/ast/module.h"
#include "src/ast/return_statement.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/f32_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc
index 7e272d6..d251dc6 100644
--- a/src/writer/msl/generator_impl_module_constant_test.cc
+++ b/src/writer/msl/generator_impl_module_constant_test.cc
@@ -20,8 +20,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/writer/msl/generator_impl.h"
diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc
index c67822a..8123138 100644
--- a/src/writer/msl/generator_impl_switch_test.cc
+++ b/src/writer/msl/generator_impl_switch_test.cc
@@ -21,7 +21,7 @@
#include "src/ast/module.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc
index c73e148..69de899 100644
--- a/src/writer/msl/generator_impl_test.cc
+++ b/src/writer/msl/generator_impl_test.cc
@@ -26,17 +26,17 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/msl/namer.h"
#include "src/writer/msl/test_helper.h"
@@ -137,7 +137,7 @@
}
TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) {
- ast::type::Pointer ptr(ty.bool_, ast::StorageClass::kPrivate);
+ type::Pointer ptr(ty.bool_, ast::StorageClass::kPrivate);
EXPECT_EQ(0u, gen.calculate_alignment_size(&ptr));
}
@@ -187,7 +187,7 @@
TEST_P(MslVectorSizeBoolTest, calculate) {
auto param = GetParam();
- ast::type::Vector vec(ty.bool_, param.elements);
+ type::Vector vec(ty.bool_, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -200,7 +200,7 @@
TEST_P(MslVectorSizeI32Test, calculate) {
auto param = GetParam();
- ast::type::Vector vec(ty.i32, param.elements);
+ type::Vector vec(ty.i32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -213,7 +213,7 @@
TEST_P(MslVectorSizeU32Test, calculate) {
auto param = GetParam();
- ast::type::Vector vec(ty.u32, param.elements);
+ type::Vector vec(ty.u32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
@@ -226,7 +226,7 @@
TEST_P(MslVectorSizeF32Test, calculate) {
auto param = GetParam();
- ast::type::Vector vec(ty.f32, param.elements);
+ type::Vector vec(ty.f32, param.elements);
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
}
INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc
index 90c3c88..8bc1146 100644
--- a/src/writer/msl/generator_impl_type_test.cc
+++ b/src/writer/msl/generator_impl_type_test.cc
@@ -20,22 +20,22 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
@@ -131,7 +131,7 @@
// TODO(dsinclair): How to annotate as workgroup?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) {
- ast::type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
+ type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(&p, "")) << gen.error();
EXPECT_EQ(gen.result(), "float*");
@@ -233,21 +233,21 @@
}
TEST_F(MslGeneratorImplTest, EmitType_Sampler) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
+ type::Sampler sampler(type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
}
TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
+ type::Sampler sampler(type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
}
struct MslDepthTextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslDepthTextureData data) {
@@ -258,7 +258,7 @@
TEST_P(MslDepthTexturesTest, Emit) {
auto params = GetParam();
- ast::type::DepthTexture s(params.dim);
+ type::DepthTexture s(params.dim);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), params.result);
@@ -266,18 +266,18 @@
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslDepthTexturesTest,
- testing::Values(MslDepthTextureData{ast::type::TextureDimension::k2d,
+ testing::Values(MslDepthTextureData{type::TextureDimension::k2d,
"depth2d<float, access::sample>"},
- MslDepthTextureData{ast::type::TextureDimension::k2dArray,
+ MslDepthTextureData{type::TextureDimension::k2dArray,
"depth2d_array<float, access::sample>"},
- MslDepthTextureData{ast::type::TextureDimension::kCube,
+ MslDepthTextureData{type::TextureDimension::kCube,
"depthcube<float, access::sample>"},
MslDepthTextureData{
- ast::type::TextureDimension::kCubeArray,
+ type::TextureDimension::kCubeArray,
"depthcube_array<float, access::sample>"}));
struct MslTextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
std::string result;
};
inline std::ostream& operator<<(std::ostream& out, MslTextureData data) {
@@ -288,7 +288,7 @@
TEST_P(MslSampledtexturesTest, Emit) {
auto params = GetParam();
- ast::type::SampledTexture s(params.dim, ty.f32);
+ type::SampledTexture s(params.dim, ty.f32);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), params.result);
@@ -296,31 +296,31 @@
INSTANTIATE_TEST_SUITE_P(
MslGeneratorImplTest,
MslSampledtexturesTest,
- testing::Values(MslTextureData{ast::type::TextureDimension::k1d,
+ testing::Values(MslTextureData{type::TextureDimension::k1d,
"texture1d<float, access::sample>"},
- MslTextureData{ast::type::TextureDimension::k1dArray,
+ MslTextureData{type::TextureDimension::k1dArray,
"texture1d_array<float, access::sample>"},
- MslTextureData{ast::type::TextureDimension::k2d,
+ MslTextureData{type::TextureDimension::k2d,
"texture2d<float, access::sample>"},
- MslTextureData{ast::type::TextureDimension::k2dArray,
+ MslTextureData{type::TextureDimension::k2dArray,
"texture2d_array<float, access::sample>"},
- MslTextureData{ast::type::TextureDimension::k3d,
+ MslTextureData{type::TextureDimension::k3d,
"texture3d<float, access::sample>"},
- MslTextureData{ast::type::TextureDimension::kCube,
+ MslTextureData{type::TextureDimension::kCube,
"texturecube<float, access::sample>"},
MslTextureData{
- ast::type::TextureDimension::kCubeArray,
+ type::TextureDimension::kCubeArray,
"texturecube_array<float, access::sample>"}));
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
- ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, ty.u32);
+ type::MultisampledTexture s(type::TextureDimension::k2d, ty.u32);
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
EXPECT_EQ(gen.result(), "texture2d_ms<uint, access::sample>");
}
struct MslStorageTextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
bool ro;
std::string result;
};
@@ -332,11 +332,10 @@
TEST_P(MslStorageTexturesTest, Emit) {
auto params = GetParam();
- ast::type::StorageTexture s(params.dim,
- ast::type::ImageFormat::kR16Float);
- ast::type::AccessControl ac(params.ro ? ast::AccessControl::kReadOnly
- : ast::AccessControl::kWriteOnly,
- &s);
+ type::StorageTexture s(params.dim, type::ImageFormat::kR16Float);
+ type::AccessControl ac(params.ro ? ast::AccessControl::kReadOnly
+ : ast::AccessControl::kWriteOnly,
+ &s);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
ASSERT_TRUE(gen.EmitType(&ac, "")) << gen.error();
@@ -346,25 +345,25 @@
MslGeneratorImplTest,
MslStorageTexturesTest,
testing::Values(
- MslStorageTextureData{ast::type::TextureDimension::k1d, true,
+ MslStorageTextureData{type::TextureDimension::k1d, true,
"texture1d<float, access::read>"},
- MslStorageTextureData{ast::type::TextureDimension::k1dArray, true,
+ MslStorageTextureData{type::TextureDimension::k1dArray, true,
"texture1d_array<float, access::read>"},
- MslStorageTextureData{ast::type::TextureDimension::k2d, true,
+ MslStorageTextureData{type::TextureDimension::k2d, true,
"texture2d<float, access::read>"},
- MslStorageTextureData{ast::type::TextureDimension::k2dArray, true,
+ MslStorageTextureData{type::TextureDimension::k2dArray, true,
"texture2d_array<float, access::read>"},
- MslStorageTextureData{ast::type::TextureDimension::k3d, true,
+ MslStorageTextureData{type::TextureDimension::k3d, true,
"texture3d<float, access::read>"},
- MslStorageTextureData{ast::type::TextureDimension::k1d, false,
+ MslStorageTextureData{type::TextureDimension::k1d, false,
"texture1d<float, access::write>"},
- MslStorageTextureData{ast::type::TextureDimension::k1dArray, false,
+ MslStorageTextureData{type::TextureDimension::k1dArray, false,
"texture1d_array<float, access::write>"},
- MslStorageTextureData{ast::type::TextureDimension::k2d, false,
+ MslStorageTextureData{type::TextureDimension::k2d, false,
"texture2d<float, access::write>"},
- MslStorageTextureData{ast::type::TextureDimension::k2dArray, false,
+ MslStorageTextureData{type::TextureDimension::k2dArray, false,
"texture2d_array<float, access::write>"},
- MslStorageTextureData{ast::type::TextureDimension::k3d, false,
+ MslStorageTextureData{type::TextureDimension::k3d, false,
"texture3d<float, access::write>"}));
} // namespace
diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
index 777bb32..3da40f8 100644
--- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -23,13 +23,13 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/msl/generator_impl.h"
#include "src/writer/msl/test_helper.h"
@@ -61,7 +61,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
- ast::type::Array ary(ty.f32, 5, ast::ArrayDecorationList{});
+ type::Array ary(ty.f32, 5, ast::ArrayDecorationList{});
auto* var = Var("a", ast::StorageClass::kNone, &ary);
auto* stmt = create<ast::VariableDeclStatement>(var);
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 26212e6..bfd42d7 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -52,27 +52,27 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/append_vector.h"
namespace tint {
@@ -152,15 +152,14 @@
/// one or more levels of an arrays inside of `type`.
/// @param type the given type, which must not be null
/// @returns the nested matrix type, or nullptr if none
-ast::type::Matrix* GetNestedMatrixType(ast::type::Type* type) {
- while (auto* arr = type->As<ast::type::Array>()) {
+type::Matrix* GetNestedMatrixType(type::Type* type) {
+ while (auto* arr = type->As<type::Array>()) {
type = arr->type();
}
- return type->As<ast::type::Matrix>();
+ return type->As<type::Matrix>();
}
-uint32_t intrinsic_to_glsl_method(ast::type::Type* type,
- ast::Intrinsic intrinsic) {
+uint32_t intrinsic_to_glsl_method(type::Type* type, ast::Intrinsic intrinsic) {
switch (intrinsic) {
case ast::Intrinsic::kAbs:
if (type->is_float_scalar_or_vector()) {
@@ -273,8 +272,8 @@
}
/// @return the vector element type if ty is a vector, otherwise return ty.
-ast::type::Type* ElementTypeOf(ast::type::Type* ty) {
- if (auto* v = ty->As<ast::type::Vector>()) {
+type::Type* ElementTypeOf(type::Type* ty) {
+ if (auto* v = ty->As<type::Vector>()) {
return v->type();
}
return ty;
@@ -386,7 +385,7 @@
}
uint32_t Builder::GenerateU32Literal(uint32_t val) {
- ast::type::U32 u32;
+ type::U32 u32;
ast::SintLiteral lit(Source{}, &u32, val);
return GenerateLiteralIfNeeded(nullptr, &lit);
}
@@ -651,7 +650,7 @@
auto result = result_op();
auto var_id = result.to_i();
auto sc = ast::StorageClass::kFunction;
- ast::type::Pointer pt(var->type(), sc);
+ type::Pointer pt(var->type(), sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -725,7 +724,7 @@
? ast::StorageClass::kPrivate
: var->storage_class();
- ast::type::Pointer pt(var->type(), sc);
+ type::Pointer pt(var->type(), sc);
auto type_id = GenerateTypeIfNeeded(&pt);
if (type_id == 0) {
return false;
@@ -743,8 +742,8 @@
auto* type = var->type()->UnwrapAll();
if (var->has_constructor()) {
ops.push_back(Operand::Int(init_id));
- } else if (type->Is<ast::type::Texture>()) {
- if (auto* ac = var->type()->As<ast::type::AccessControl>()) {
+ } else if (type->Is<type::Texture>()) {
+ if (auto* ac = var->type()->As<type::AccessControl>()) {
switch (ac->access_control()) {
case ast::AccessControl::kWriteOnly:
push_annot(
@@ -760,7 +759,7 @@
break;
}
}
- } else if (!type->Is<ast::type::Sampler>()) {
+ } else if (!type->Is<type::Sampler>()) {
// Certain cases require us to generate a constructor value.
//
// 1- ConstantId's must be attached to the OpConstant, if we have a
@@ -769,16 +768,16 @@
// 2- If we don't have a constructor and we're an Output or Private variable
// then WGSL requires an initializer.
if (var->HasConstantIdDecoration()) {
- if (type->Is<ast::type::F32>()) {
+ if (type->Is<type::F32>()) {
ast::FloatLiteral l(Source{}, type, 0.0f);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
ast::UintLiteral l(Source{}, type, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
ast::SintLiteral l(Source{}, type, 0);
init_id = GenerateLiteralIfNeeded(var, &l);
- } else if (type->Is<ast::type::Bool>()) {
+ } else if (type->Is<type::Bool>()) {
ast::BoolLiteral l(Source{}, type, false);
init_id = GenerateLiteralIfNeeded(var, &l);
} else {
@@ -843,9 +842,9 @@
// If the source is a pointer we access chain into it. We also access chain
// into an array of non-scalar types.
- if (info->source_type->Is<ast::type::Pointer>() ||
- (info->source_type->Is<ast::type::Array>() &&
- !info->source_type->As<ast::type::Array>()->type()->is_scalar())) {
+ if (info->source_type->Is<type::Pointer>() ||
+ (info->source_type->Is<type::Array>() &&
+ !info->source_type->As<type::Array>()->type()->is_scalar())) {
info->access_chain_indices.push_back(idx_id);
info->source_type = expr->result_type();
return true;
@@ -880,15 +879,15 @@
// If the data_type is a structure we're accessing a member, if it's a
// vector we're accessing a swizzle.
- if (data_type->Is<ast::type::Struct>()) {
- if (!info->source_type->Is<ast::type::Pointer>()) {
+ if (data_type->Is<type::Struct>()) {
+ if (!info->source_type->Is<type::Pointer>()) {
error_ =
"Attempting to access a struct member on a non-pointer. Something is "
"wrong";
return false;
}
- auto* strct = data_type->As<ast::type::Struct>()->impl();
+ auto* strct = data_type->As<type::Struct>()->impl();
auto symbol = expr->member()->symbol();
uint32_t i = 0;
@@ -908,7 +907,7 @@
return true;
}
- if (!data_type->Is<ast::type::Vector>()) {
+ if (!data_type->Is<type::Vector>()) {
error_ = "Member accessor without a struct or vector. Something is wrong";
return false;
}
@@ -923,7 +922,7 @@
return false;
}
- if (info->source_type->Is<ast::type::Pointer>()) {
+ if (info->source_type->Is<type::Pointer>()) {
auto idx_id = GenerateU32Literal(val);
if (idx_id == 0) {
return 0;
@@ -1044,10 +1043,10 @@
if (auto* array = accessors[0]->As<ast::ArrayAccessorExpression>()) {
auto* ary_res_type = array->array()->result_type();
- if (!ary_res_type->Is<ast::type::Pointer>() &&
- (ary_res_type->Is<ast::type::Array>() &&
- !ary_res_type->As<ast::type::Array>()->type()->is_scalar())) {
- ast::type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
+ if (!ary_res_type->Is<type::Pointer>() &&
+ (ary_res_type->Is<type::Array>() &&
+ !ary_res_type->As<type::Array>()->type()->is_scalar())) {
+ type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
auto result_type_id = GenerateTypeIfNeeded(&ptr);
if (result_type_id == 0) {
return 0;
@@ -1126,8 +1125,8 @@
return 0;
}
-uint32_t Builder::GenerateLoadIfNeeded(ast::type::Type* type, uint32_t id) {
- if (!type->Is<ast::type::Pointer>()) {
+uint32_t Builder::GenerateLoadIfNeeded(type::Type* type, uint32_t id) {
+ if (!type->Is<type::Pointer>()) {
return id;
}
@@ -1237,7 +1236,7 @@
}
auto* sc = e->As<ast::ScalarConstructorExpression>();
- if (result_type->Is<ast::type::Vector>() && sc == nullptr) {
+ if (result_type->Is<type::Vector>() && sc == nullptr) {
return false;
}
@@ -1246,14 +1245,14 @@
continue;
}
- ast::type::Type* subtype = result_type->UnwrapAll();
- if (auto* vec = subtype->As<ast::type::Vector>()) {
+ type::Type* subtype = result_type->UnwrapAll();
+ if (auto* vec = subtype->As<type::Vector>()) {
subtype = vec->type()->UnwrapAll();
- } else if (auto* mat = subtype->As<ast::type::Matrix>()) {
+ } else if (auto* mat = subtype->As<type::Matrix>()) {
subtype = mat->type()->UnwrapAll();
- } else if (auto* arr = subtype->As<ast::type::Array>()) {
+ } else if (auto* arr = subtype->As<type::Array>()) {
subtype = arr->type()->UnwrapAll();
- } else if (auto* str = subtype->As<ast::type::Struct>()) {
+ } else if (auto* str = subtype->As<type::Struct>()) {
subtype = str->impl()->members()[i]->type()->UnwrapAll();
}
if (subtype != sc->result_type()->UnwrapAll()) {
@@ -1285,10 +1284,10 @@
bool can_cast_or_copy = result_type->is_scalar();
- if (auto* res_vec = result_type->As<ast::type::Vector>()) {
+ if (auto* res_vec = result_type->As<type::Vector>()) {
if (res_vec->type()->is_scalar()) {
auto* value_type = values[0]->result_type()->UnwrapAll();
- if (auto* val_vec = value_type->As<ast::type::Vector>()) {
+ if (auto* val_vec = value_type->As<type::Vector>()) {
if (val_vec->type()->is_scalar()) {
can_cast_or_copy = res_vec->size() == val_vec->size();
}
@@ -1308,7 +1307,7 @@
bool result_is_constant_composite = constructor_is_const;
bool result_is_spec_composite = false;
- if (auto* vec = result_type->As<ast::type::Vector>()) {
+ if (auto* vec = result_type->As<type::Vector>()) {
result_type = vec->type();
}
@@ -1330,9 +1329,8 @@
// If the result and value types are the same we can just use the object.
// If the result is not a vector then we should have validated that the
// value type is a correctly sized vector so we can just use it directly.
- if (result_type == value_type || result_type->Is<ast::type::Matrix>() ||
- result_type->Is<ast::type::Array>() ||
- result_type->Is<ast::type::Struct>()) {
+ if (result_type == value_type || result_type->Is<type::Matrix>() ||
+ result_type->Is<type::Array>() || result_type->Is<type::Struct>()) {
out << "_" << id;
ops.push_back(Operand::Int(id));
@@ -1357,7 +1355,7 @@
//
// For cases 1 and 2, if the type is different we also may need to insert
// a type cast.
- if (auto* vec = value_type->As<ast::type::Vector>()) {
+ if (auto* vec = value_type->As<type::Vector>()) {
auto* vec_type = vec->type();
auto value_type_id = GenerateTypeIfNeeded(vec_type);
@@ -1428,7 +1426,7 @@
return result.to_i();
}
-uint32_t Builder::GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type,
+uint32_t Builder::GenerateCastOrCopyOrPassthrough(type::Type* to_type,
ast::Expression* from_expr) {
auto result = result_op();
auto result_id = result.to_i();
@@ -1447,38 +1445,29 @@
auto* from_type = from_expr->result_type()->UnwrapPtrIfNeeded();
spv::Op op = spv::Op::OpNop;
- if ((from_type->Is<ast::type::I32>() && to_type->Is<ast::type::F32>()) ||
+ if ((from_type->Is<type::I32>() && to_type->Is<type::F32>()) ||
(from_type->is_signed_integer_vector() && to_type->is_float_vector())) {
op = spv::Op::OpConvertSToF;
- } else if ((from_type->Is<ast::type::U32>() &&
- to_type->Is<ast::type::F32>()) ||
+ } else if ((from_type->Is<type::U32>() && to_type->Is<type::F32>()) ||
(from_type->is_unsigned_integer_vector() &&
to_type->is_float_vector())) {
op = spv::Op::OpConvertUToF;
- } else if ((from_type->Is<ast::type::F32>() &&
- to_type->Is<ast::type::I32>()) ||
+ } else if ((from_type->Is<type::F32>() && to_type->Is<type::I32>()) ||
(from_type->is_float_vector() &&
to_type->is_signed_integer_vector())) {
op = spv::Op::OpConvertFToS;
- } else if ((from_type->Is<ast::type::F32>() &&
- to_type->Is<ast::type::U32>()) ||
+ } else if ((from_type->Is<type::F32>() && to_type->Is<type::U32>()) ||
(from_type->is_float_vector() &&
to_type->is_unsigned_integer_vector())) {
op = spv::Op::OpConvertFToU;
- } else if ((from_type->Is<ast::type::Bool>() &&
- to_type->Is<ast::type::Bool>()) ||
- (from_type->Is<ast::type::U32>() &&
- to_type->Is<ast::type::U32>()) ||
- (from_type->Is<ast::type::I32>() &&
- to_type->Is<ast::type::I32>()) ||
- (from_type->Is<ast::type::F32>() &&
- to_type->Is<ast::type::F32>()) ||
- (from_type->Is<ast::type::Vector>() && (from_type == to_type))) {
+ } else if ((from_type->Is<type::Bool>() && to_type->Is<type::Bool>()) ||
+ (from_type->Is<type::U32>() && to_type->Is<type::U32>()) ||
+ (from_type->Is<type::I32>() && to_type->Is<type::I32>()) ||
+ (from_type->Is<type::F32>() && to_type->Is<type::F32>()) ||
+ (from_type->Is<type::Vector>() && (from_type == to_type))) {
return val_id;
- } else if ((from_type->Is<ast::type::I32>() &&
- to_type->Is<ast::type::U32>()) ||
- (from_type->Is<ast::type::U32>() &&
- to_type->Is<ast::type::I32>()) ||
+ } else if ((from_type->Is<type::I32>() && to_type->Is<type::U32>()) ||
+ (from_type->Is<type::U32>() && to_type->Is<type::I32>()) ||
(from_type->is_signed_integer_vector() &&
to_type->is_unsigned_integer_vector()) ||
(from_type->is_unsigned_integer_vector() &&
@@ -1902,14 +1891,14 @@
params.push_back(Operand::Int(struct_id));
auto* type = accessor->structure()->result_type()->UnwrapAll();
- if (!type->Is<ast::type::Struct>()) {
+ if (!type->Is<type::Struct>()) {
error_ =
"invalid type (" + type->type_name() + ") for runtime array length";
return 0;
}
// Runtime array must be the last member in the structure
params.push_back(Operand::Int(
- uint32_t(type->As<ast::type::Struct>()->impl()->members().size() - 1)));
+ uint32_t(type->As<type::Struct>()->impl()->members().size() - 1)));
if (!push_function_inst(spv::Op::OpArrayLength, params)) {
return 0;
@@ -2004,7 +1993,7 @@
auto* texture_type = call->params()[pidx.texture]
->result_type()
->UnwrapAll()
- ->As<ast::type::Texture>();
+ ->As<type::Texture>();
auto op = spv::Op::OpNop;
@@ -2051,9 +2040,9 @@
// If the texture is not a depth texture, then this function simply delegates
// to calling append_result_type_and_id_to_spirv_params().
auto append_result_type_and_id_to_spirv_params_for_read = [&]() {
- if (texture_type->Is<ast::type::DepthTexture>()) {
- auto* f32 = mod_->create<ast::type::F32>();
- auto* spirv_result_type = mod_->create<ast::type::Vector>(f32, 4);
+ if (texture_type->Is<type::DepthTexture>()) {
+ auto* f32 = mod_->create<type::F32>();
+ auto* spirv_result_type = mod_->create<type::Vector>(f32, 4);
auto spirv_result = result_op();
post_emission = [=] {
return push_function_inst(
@@ -2085,7 +2074,7 @@
auto* element_type = ElementTypeOf(call->result_type());
auto spirv_result = result_op();
auto* spirv_result_type =
- mod_->create<ast::type::Vector>(element_type, spirv_result_width);
+ mod_->create<type::Vector>(element_type, spirv_result_width);
if (swizzle.size() > 1) {
post_emission = [=] {
OperandList operands{
@@ -2165,26 +2154,26 @@
std::vector<uint32_t> swizzle;
uint32_t spirv_dims = 0;
switch (texture_type->dim()) {
- case ast::type::TextureDimension::kNone:
+ case type::TextureDimension::kNone:
error_ = "texture dimension is kNone";
return false;
- case ast::type::TextureDimension::k1d:
- case ast::type::TextureDimension::k2d:
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k1d:
+ case type::TextureDimension::k2d:
+ case type::TextureDimension::k3d:
break; // No swizzle needed
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
swizzle = {0}; // Strip array index
spirv_dims = 2; // [width, array count]
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
swizzle = {0, 1, 1}; // Duplicate height for depth
spirv_dims = 2; // [width, height]
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
swizzle = {0, 1}; // Strip array index
spirv_dims = 3; // [width, height, array_count]
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
swizzle = {0, 1, 1}; // Strip array index, duplicate height for depth
spirv_dims = 3; // [width, height, array_count]
break;
@@ -2196,14 +2185,14 @@
}
spirv_params.emplace_back(gen_param(pidx.texture));
- if (texture_type->Is<ast::type::MultisampledTexture>() ||
- texture_type->Is<ast::type::StorageTexture>()) {
+ if (texture_type->Is<type::MultisampledTexture>() ||
+ texture_type->Is<type::StorageTexture>()) {
op = spv::Op::OpImageQuerySize;
} else if (pidx.level != kNotUsed) {
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(gen_param(pidx.level));
} else {
- ast::SintLiteral i32_0(Source{}, mod_->create<ast::type::I32>(), 0);
+ ast::SintLiteral i32_0(Source{}, mod_->create<type::I32>(), 0);
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(
Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0)));
@@ -2216,11 +2205,11 @@
default:
error_ = "texture is not arrayed";
return false;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
spirv_dims = 2;
break;
- case ast::type::TextureDimension::k2dArray:
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::k2dArray:
+ case type::TextureDimension::kCubeArray:
spirv_dims = 3;
break;
}
@@ -2234,11 +2223,11 @@
spirv_params.emplace_back(gen_param(pidx.texture));
- if (texture_type->Is<ast::type::MultisampledTexture>() ||
- texture_type->Is<ast::type::StorageTexture>()) {
+ if (texture_type->Is<type::MultisampledTexture>() ||
+ texture_type->Is<type::StorageTexture>()) {
op = spv::Op::OpImageQuerySize;
} else {
- ast::SintLiteral i32_0(Source{}, mod_->create<ast::type::I32>(), 0);
+ ast::SintLiteral i32_0(Source{}, mod_->create<type::I32>(), 0);
op = spv::Op::OpImageQuerySizeLod;
spirv_params.emplace_back(
Operand::Int(GenerateLiteralIfNeeded(nullptr, &i32_0)));
@@ -2258,9 +2247,8 @@
break;
}
case ast::Intrinsic::kTextureLoad: {
- op = texture_type->Is<ast::type::StorageTexture>()
- ? spv::Op::OpImageRead
- : spv::Op::OpImageFetch;
+ op = texture_type->Is<type::StorageTexture>() ? spv::Op::OpImageRead
+ : spv::Op::OpImageFetch;
append_result_type_and_id_to_spirv_params_for_read();
spirv_params.emplace_back(gen_param(pidx.texture));
if (!append_coords_to_spirv_params()) {
@@ -2315,10 +2303,10 @@
}
assert(pidx.level != kNotUsed);
auto level = Operand::Int(0);
- if (call->params()[pidx.level]->result_type()->Is<ast::type::I32>()) {
+ if (call->params()[pidx.level]->result_type()->Is<type::I32>()) {
// Depth textures have i32 parameters for the level, but SPIR-V expects
// F32. Cast.
- auto* f32 = mod_->create<ast::type::F32>();
+ auto* f32 = mod_->create<type::F32>();
ast::TypeConstructorExpression cast(Source{}, f32,
{call->params()[pidx.level]});
level = Operand::Int(GenerateExpression(&cast));
@@ -2354,7 +2342,7 @@
assert(pidx.depth_ref != kNotUsed);
spirv_params.emplace_back(gen_param(pidx.depth_ref));
- ast::type::F32 f32;
+ type::F32 f32;
ast::FloatLiteral float_0(Source{}, &f32, 0.0);
image_operands.emplace_back(ImageOperand{
SpvImageOperandsLodMask,
@@ -2396,7 +2384,7 @@
return post_emission();
}
-uint32_t Builder::GenerateSampledImage(ast::type::Type* texture_type,
+uint32_t Builder::GenerateSampledImage(type::Type* texture_type,
Operand texture_operand,
Operand sampler_operand) {
uint32_t sampled_image_type_id = 0;
@@ -2776,18 +2764,18 @@
return GenerateFunctionVariable(stmt->variable());
}
-uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
+uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) {
if (type == nullptr) {
error_ = "attempting to generate type from null type";
return 0;
}
// The alias is a wrapper around the subtype, so emit the subtype
- if (auto* alias = type->As<ast::type::Alias>()) {
+ if (auto* alias = type->As<type::Alias>()) {
return GenerateTypeIfNeeded(alias->type());
}
- if (auto* ac = type->As<ast::type::AccessControl>()) {
- if (!ac->type()->UnwrapIfNeeded()->Is<ast::type::Struct>()) {
+ if (auto* ac = type->As<type::AccessControl>()) {
+ if (!ac->type()->UnwrapIfNeeded()->Is<type::Struct>()) {
return GenerateTypeIfNeeded(ac->type());
}
}
@@ -2799,48 +2787,48 @@
auto result = result_op();
auto id = result.to_i();
- if (auto* ac = type->As<ast::type::AccessControl>()) {
+ if (auto* ac = type->As<type::AccessControl>()) {
// The non-struct case was handled above.
auto* subtype = ac->type()->UnwrapIfNeeded();
- if (!GenerateStructType(subtype->As<ast::type::Struct>(),
- ac->access_control(), result)) {
+ if (!GenerateStructType(subtype->As<type::Struct>(), ac->access_control(),
+ result)) {
return 0;
}
- } else if (auto* arr = type->As<ast::type::Array>()) {
+ } else if (auto* arr = type->As<type::Array>()) {
if (!GenerateArrayType(arr, result)) {
return 0;
}
- } else if (type->Is<ast::type::Bool>()) {
+ } else if (type->Is<type::Bool>()) {
push_type(spv::Op::OpTypeBool, {result});
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)});
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(1)});
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
if (!GenerateMatrixType(mat, result)) {
return 0;
}
- } else if (auto* ptr = type->As<ast::type::Pointer>()) {
+ } else if (auto* ptr = type->As<type::Pointer>()) {
if (!GeneratePointerType(ptr, result)) {
return 0;
}
- } else if (auto* str = type->As<ast::type::Struct>()) {
+ } else if (auto* str = type->As<type::Struct>()) {
if (!GenerateStructType(str, ast::AccessControl::kReadWrite, result)) {
return 0;
}
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)});
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
if (!GenerateVectorType(vec, result)) {
return 0;
}
- } else if (type->Is<ast::type::Void>()) {
+ } else if (type->Is<type::Void>()) {
push_type(spv::Op::OpTypeVoid, {result});
- } else if (auto* tex = type->As<ast::type::Texture>()) {
+ } else if (auto* tex = type->As<type::Texture>()) {
if (!GenerateTextureType(tex, result)) {
return 0;
}
- } else if (type->Is<ast::type::Sampler>()) {
+ } else if (type->Is<type::Sampler>()) {
push_type(spv::Op::OpTypeSampler, {result});
// Register both of the sampler type names. In SPIR-V they're the same
@@ -2858,68 +2846,68 @@
}
// TODO(tommek): Cover multisampled textures here when they're included in AST
-bool Builder::GenerateTextureType(ast::type::Texture* texture,
+bool Builder::GenerateTextureType(type::Texture* texture,
const Operand& result) {
uint32_t array_literal = 0u;
const auto dim = texture->dim();
- if (dim == ast::type::TextureDimension::k1dArray ||
- dim == ast::type::TextureDimension::k2dArray ||
- dim == ast::type::TextureDimension::kCubeArray) {
+ if (dim == type::TextureDimension::k1dArray ||
+ dim == type::TextureDimension::k2dArray ||
+ dim == type::TextureDimension::kCubeArray) {
array_literal = 1u;
}
uint32_t dim_literal = SpvDim2D;
- if (dim == ast::type::TextureDimension::k1dArray ||
- dim == ast::type::TextureDimension::k1d) {
+ if (dim == type::TextureDimension::k1dArray ||
+ dim == type::TextureDimension::k1d) {
dim_literal = SpvDim1D;
- if (texture->Is<ast::type::SampledTexture>()) {
+ if (texture->Is<type::SampledTexture>()) {
push_capability(SpvCapabilitySampled1D);
} else {
- assert(texture->Is<ast::type::StorageTexture>());
+ assert(texture->Is<type::StorageTexture>());
push_capability(SpvCapabilityImage1D);
}
}
- if (dim == ast::type::TextureDimension::k3d) {
+ if (dim == type::TextureDimension::k3d) {
dim_literal = SpvDim3D;
}
- if (dim == ast::type::TextureDimension::kCube ||
- dim == ast::type::TextureDimension::kCubeArray) {
+ if (dim == type::TextureDimension::kCube ||
+ dim == type::TextureDimension::kCubeArray) {
dim_literal = SpvDimCube;
}
uint32_t ms_literal = 0u;
- if (texture->Is<ast::type::MultisampledTexture>()) {
+ if (texture->Is<type::MultisampledTexture>()) {
ms_literal = 1u;
}
uint32_t depth_literal = 0u;
- if (texture->Is<ast::type::DepthTexture>()) {
+ if (texture->Is<type::DepthTexture>()) {
depth_literal = 1u;
}
uint32_t sampled_literal = 2u;
- if (texture->Is<ast::type::MultisampledTexture>() ||
- texture->Is<ast::type::SampledTexture>() ||
- texture->Is<ast::type::DepthTexture>()) {
+ if (texture->Is<type::MultisampledTexture>() ||
+ texture->Is<type::SampledTexture>() ||
+ texture->Is<type::DepthTexture>()) {
sampled_literal = 1u;
}
- if (dim == ast::type::TextureDimension::kCubeArray) {
- if (texture->Is<ast::type::SampledTexture>() ||
- texture->Is<ast::type::DepthTexture>()) {
+ if (dim == type::TextureDimension::kCubeArray) {
+ if (texture->Is<type::SampledTexture>() ||
+ texture->Is<type::DepthTexture>()) {
push_capability(SpvCapabilitySampledCubeArray);
}
}
uint32_t type_id = 0u;
- if (texture->Is<ast::type::DepthTexture>()) {
- ast::type::F32 f32;
+ if (texture->Is<type::DepthTexture>()) {
+ type::F32 f32;
type_id = GenerateTypeIfNeeded(&f32);
- } else if (auto* s = texture->As<ast::type::SampledTexture>()) {
+ } else if (auto* s = texture->As<type::SampledTexture>()) {
type_id = GenerateTypeIfNeeded(s->type());
- } else if (auto* ms = texture->As<ast::type::MultisampledTexture>()) {
+ } else if (auto* ms = texture->As<type::MultisampledTexture>()) {
type_id = GenerateTypeIfNeeded(ms->type());
- } else if (auto* st = texture->As<ast::type::StorageTexture>()) {
+ } else if (auto* st = texture->As<type::StorageTexture>()) {
type_id = GenerateTypeIfNeeded(st->type());
}
if (type_id == 0u) {
@@ -2927,7 +2915,7 @@
}
uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown;
- if (auto* t = texture->As<ast::type::StorageTexture>()) {
+ if (auto* t = texture->As<type::StorageTexture>()) {
format_literal = convert_image_format_to_spv(t->image_format());
}
@@ -2940,7 +2928,7 @@
return true;
}
-bool Builder::GenerateArrayType(ast::type::Array* ary, const Operand& result) {
+bool Builder::GenerateArrayType(type::Array* ary, const Operand& result) {
auto elem_type = GenerateTypeIfNeeded(ary->type());
if (elem_type == 0) {
return false;
@@ -2967,9 +2955,8 @@
return true;
}
-bool Builder::GenerateMatrixType(ast::type::Matrix* mat,
- const Operand& result) {
- ast::type::Vector col_type(mat->type(), mat->rows());
+bool Builder::GenerateMatrixType(type::Matrix* mat, const Operand& result) {
+ type::Vector col_type(mat->type(), mat->rows());
auto col_type_id = GenerateTypeIfNeeded(&col_type);
if (has_error()) {
return false;
@@ -2980,8 +2967,7 @@
return true;
}
-bool Builder::GeneratePointerType(ast::type::Pointer* ptr,
- const Operand& result) {
+bool Builder::GeneratePointerType(type::Pointer* ptr, const Operand& result) {
auto pointee_id = GenerateTypeIfNeeded(ptr->type());
if (pointee_id == 0) {
return false;
@@ -2999,7 +2985,7 @@
return true;
}
-bool Builder::GenerateStructType(ast::type::Struct* struct_type,
+bool Builder::GenerateStructType(type::Struct* struct_type,
ast::AccessControl access_control,
const Operand& result) {
auto struct_id = result.to_i();
@@ -3074,7 +3060,7 @@
push_annot(spv::Op::OpMemberDecorate,
{Operand::Int(struct_id), Operand::Int(idx),
Operand::Int(SpvDecorationColMajor)});
- if (!matrix_type->type()->Is<ast::type::F32>()) {
+ if (!matrix_type->type()->Is<type::F32>()) {
error_ = "matrix scalar element type must be f32";
return 0;
}
@@ -3090,8 +3076,7 @@
return GenerateTypeIfNeeded(member->type());
}
-bool Builder::GenerateVectorType(ast::type::Vector* vec,
- const Operand& result) {
+bool Builder::GenerateVectorType(type::Vector* vec, const Operand& result) {
auto type_id = GenerateTypeIfNeeded(vec->type());
if (has_error()) {
return false;
@@ -3157,98 +3142,98 @@
}
SpvImageFormat Builder::convert_image_format_to_spv(
- const ast::type::ImageFormat format) {
+ const type::ImageFormat format) {
switch (format) {
- case ast::type::ImageFormat::kR8Unorm:
+ case type::ImageFormat::kR8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8;
- case ast::type::ImageFormat::kR8Snorm:
+ case type::ImageFormat::kR8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8Snorm;
- case ast::type::ImageFormat::kR8Uint:
+ case type::ImageFormat::kR8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8ui;
- case ast::type::ImageFormat::kR8Sint:
+ case type::ImageFormat::kR8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR8i;
- case ast::type::ImageFormat::kR16Uint:
+ case type::ImageFormat::kR16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16ui;
- case ast::type::ImageFormat::kR16Sint:
+ case type::ImageFormat::kR16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16i;
- case ast::type::ImageFormat::kR16Float:
+ case type::ImageFormat::kR16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR16f;
- case ast::type::ImageFormat::kRg8Unorm:
+ case type::ImageFormat::kRg8Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8;
- case ast::type::ImageFormat::kRg8Snorm:
+ case type::ImageFormat::kRg8Snorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8Snorm;
- case ast::type::ImageFormat::kRg8Uint:
+ case type::ImageFormat::kRg8Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8ui;
- case ast::type::ImageFormat::kRg8Sint:
+ case type::ImageFormat::kRg8Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg8i;
- case ast::type::ImageFormat::kR32Uint:
+ case type::ImageFormat::kR32Uint:
return SpvImageFormatR32ui;
- case ast::type::ImageFormat::kR32Sint:
+ case type::ImageFormat::kR32Sint:
return SpvImageFormatR32i;
- case ast::type::ImageFormat::kR32Float:
+ case type::ImageFormat::kR32Float:
return SpvImageFormatR32f;
- case ast::type::ImageFormat::kRg16Uint:
+ case type::ImageFormat::kRg16Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16ui;
- case ast::type::ImageFormat::kRg16Sint:
+ case type::ImageFormat::kRg16Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16i;
- case ast::type::ImageFormat::kRg16Float:
+ case type::ImageFormat::kRg16Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg16f;
- case ast::type::ImageFormat::kRgba8Unorm:
+ case type::ImageFormat::kRgba8Unorm:
return SpvImageFormatRgba8;
- case ast::type::ImageFormat::kRgba8UnormSrgb:
+ case type::ImageFormat::kRgba8UnormSrgb:
return SpvImageFormatUnknown;
- case ast::type::ImageFormat::kRgba8Snorm:
+ case type::ImageFormat::kRgba8Snorm:
return SpvImageFormatRgba8Snorm;
- case ast::type::ImageFormat::kRgba8Uint:
+ case type::ImageFormat::kRgba8Uint:
return SpvImageFormatRgba8ui;
- case ast::type::ImageFormat::kRgba8Sint:
+ case type::ImageFormat::kRgba8Sint:
return SpvImageFormatRgba8i;
- case ast::type::ImageFormat::kBgra8Unorm:
+ case type::ImageFormat::kBgra8Unorm:
return SpvImageFormatUnknown;
- case ast::type::ImageFormat::kBgra8UnormSrgb:
+ case type::ImageFormat::kBgra8UnormSrgb:
return SpvImageFormatUnknown;
- case ast::type::ImageFormat::kRgb10A2Unorm:
+ case type::ImageFormat::kRgb10A2Unorm:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRgb10A2;
- case ast::type::ImageFormat::kRg11B10Float:
+ case type::ImageFormat::kRg11B10Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatR11fG11fB10f;
- case ast::type::ImageFormat::kRg32Uint:
+ case type::ImageFormat::kRg32Uint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32ui;
- case ast::type::ImageFormat::kRg32Sint:
+ case type::ImageFormat::kRg32Sint:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32i;
- case ast::type::ImageFormat::kRg32Float:
+ case type::ImageFormat::kRg32Float:
push_capability(SpvCapabilityStorageImageExtendedFormats);
return SpvImageFormatRg32f;
- case ast::type::ImageFormat::kRgba16Uint:
+ case type::ImageFormat::kRgba16Uint:
return SpvImageFormatRgba16ui;
- case ast::type::ImageFormat::kRgba16Sint:
+ case type::ImageFormat::kRgba16Sint:
return SpvImageFormatRgba16i;
- case ast::type::ImageFormat::kRgba16Float:
+ case type::ImageFormat::kRgba16Float:
return SpvImageFormatRgba16f;
- case ast::type::ImageFormat::kRgba32Uint:
+ case type::ImageFormat::kRgba32Uint:
return SpvImageFormatRgba32ui;
- case ast::type::ImageFormat::kRgba32Sint:
+ case type::ImageFormat::kRgba32Sint:
return SpvImageFormatRgba32i;
- case ast::type::ImageFormat::kRgba32Float:
+ case type::ImageFormat::kRgba32Float:
return SpvImageFormatRgba32f;
- case ast::type::ImageFormat::kNone:
+ case type::ImageFormat::kNone:
return SpvImageFormatUnknown;
}
return SpvImageFormatUnknown;
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index 6e0c446..9a76a0d 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -41,17 +41,17 @@
#include "src/ast/return_statement.h"
#include "src/ast/struct_member.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable_decl_statement.h"
#include "src/scope_stack.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/spirv/function.h"
#include "src/writer/spirv/instruction.h"
@@ -75,7 +75,7 @@
uint32_t source_id;
/// The type of the current chain source. This type matches the deduced
/// result_type of the current source defined above.
- ast::type::Type* source_type;
+ type::Type* source_type;
/// A list of access chain indices to emit. Note, we _only_ have access
/// chain indices if the source is pointer.
std::vector<uint32_t> access_chain_indices;
@@ -269,7 +269,7 @@
/// @param type the type to generate for
/// @param struct_id the struct id
/// @param member_idx the member index
- void GenerateMemberAccessControlIfNeeded(ast::type::Type* type,
+ void GenerateMemberAccessControlIfNeeded(type::Type* type,
uint32_t struct_id,
uint32_t member_idx);
/// Generates a function variable
@@ -373,7 +373,7 @@
/// @param texture_operand the texture operand
/// @param sampler_operand the sampler operand
/// @returns the expression ID
- uint32_t GenerateSampledImage(ast::type::Type* texture_type,
+ uint32_t GenerateSampledImage(type::Type* texture_type,
Operand texture_operand,
Operand sampler_operand);
/// Generates a cast or object copy for the expression result,
@@ -382,7 +382,7 @@
/// @param to_type the type we're casting too
/// @param from_expr the expression to cast
/// @returns the expression ID on success or 0 otherwise
- uint32_t GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type,
+ uint32_t GenerateCastOrCopyOrPassthrough(type::Type* to_type,
ast::Expression* from_expr);
/// Generates a loop statement
/// @param stmt the statement to generate
@@ -414,7 +414,7 @@
/// @param type the type to load
/// @param id the variable id to load
/// @returns the ID of the loaded value or `id` if type is not a pointer
- uint32_t GenerateLoadIfNeeded(ast::type::Type* type, uint32_t id);
+ uint32_t GenerateLoadIfNeeded(type::Type* type, uint32_t id);
/// Generates an OpStore. Emits an error and returns false if we're
/// currently outside a function.
/// @param to the ID to store too
@@ -424,33 +424,33 @@
/// Generates a type if not already created
/// @param type the type to create
/// @returns the ID to use for the given type. Returns 0 on unknown type.
- uint32_t GenerateTypeIfNeeded(ast::type::Type* type);
+ uint32_t GenerateTypeIfNeeded(type::Type* type);
/// Generates a texture type declaration
/// @param texture the texture to generate
/// @param result the result operand
/// @returns true if the texture was successfully generated
- bool GenerateTextureType(ast::type::Texture* texture, const Operand& result);
+ bool GenerateTextureType(type::Texture* texture, const Operand& result);
/// Generates an array type declaration
/// @param ary the array to generate
/// @param result the result operand
/// @returns true if the array was successfully generated
- bool GenerateArrayType(ast::type::Array* ary, const Operand& result);
+ bool GenerateArrayType(type::Array* ary, const Operand& result);
/// Generates a matrix type declaration
/// @param mat the matrix to generate
/// @param result the result operand
/// @returns true if the matrix was successfully generated
- bool GenerateMatrixType(ast::type::Matrix* mat, const Operand& result);
+ bool GenerateMatrixType(type::Matrix* mat, const Operand& result);
/// Generates a pointer type declaration
/// @param ptr the pointer type to generate
/// @param result the result operand
/// @returns true if the pointer was successfully generated
- bool GeneratePointerType(ast::type::Pointer* ptr, const Operand& result);
+ bool GeneratePointerType(type::Pointer* ptr, const Operand& result);
/// Generates a vector type declaration
/// @param struct_type the vector to generate
/// @param access_control the access controls to assign to the struct
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateStructType(ast::type::Struct* struct_type,
+ bool GenerateStructType(type::Struct* struct_type,
ast::AccessControl access_control,
const Operand& result);
/// Generates a struct member
@@ -469,13 +469,12 @@
/// @param vec the vector to generate
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateVectorType(ast::type::Vector* vec, const Operand& result);
+ bool GenerateVectorType(type::Vector* vec, const Operand& result);
/// Converts AST image format to SPIR-V and pushes an appropriate capability.
/// @param format AST image format type
/// @returns SPIR-V image format type
- SpvImageFormat convert_image_format_to_spv(
- const ast::type::ImageFormat format);
+ SpvImageFormat convert_image_format_to_spv(const type::ImageFormat format);
/// Determines if the given type constructor is created from constant values
/// @param expr the expression to check
diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc
index 6fdd1c6..8159bff 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -24,15 +24,15 @@
#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
+#include "src/type/array_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
@@ -159,7 +159,7 @@
}
TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
- ast::type::Array ary4(ty.vec3<f32>(), 4, ast::ArrayDecorationList{});
+ type::Array ary4(ty.vec3<f32>(), 4, ast::ArrayDecorationList{});
// ary = array<vec3<f32>, 4>
// ary[3][2];
@@ -197,7 +197,7 @@
}
TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
- ast::type::Array ary4(ty.vec3<f32>(), 4, ast::ArrayDecorationList{});
+ type::Array ary4(ty.vec3<f32>(), 4, ast::ArrayDecorationList{});
// var a : array<vec3<f32>, 4>;
// a[2].xy;
@@ -658,12 +658,12 @@
s = create<ast::Struct>(ast::StructMemberList{Member("bar", c_type)},
ast::StructDecorationList{});
auto* b_type = ty.struct_("B", s);
- ast::type::Array b_ary_type(b_type, 3, ast::ArrayDecorationList{});
+ type::Array b_ary_type(b_type, 3, ast::ArrayDecorationList{});
s = create<ast::Struct>(ast::StructMemberList{Member("foo", &b_ary_type)},
ast::StructDecorationList{});
auto* a_type = ty.struct_("A", s);
- ast::type::Array a_ary_type(a_type, 2, ast::ArrayDecorationList{});
+ type::Array a_ary_type(a_type, 2, ast::ArrayDecorationList{});
auto* var = Var("index", ast::StorageClass::kFunction, &a_ary_type);
auto* expr = MemberAccessor(
MemberAccessor(
@@ -718,7 +718,7 @@
// vec2<f32>(0.5, -0.5));
// pos[1]
- ast::type::Array arr(ty.vec2<f32>(), 3, ast::ArrayDecorationList{});
+ type::Array arr(ty.vec2<f32>(), 3, ast::ArrayDecorationList{});
auto* var = Const("pos", ast::StorageClass::kPrivate, &arr,
Construct(&arr, vec2<f32>(0.0f, 0.5f),
diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc
index 463dbf7..040cac9 100644
--- a/src/writer/spirv/builder_assign_test.cc
+++ b/src/writer/spirv/builder_assign_test.cc
@@ -24,11 +24,11 @@
#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc
index e614b51..8f2b5a8 100644
--- a/src/writer/spirv/builder_binary_expression_test.cc
+++ b/src/writer/spirv/builder_binary_expression_test.cc
@@ -21,14 +21,14 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc
index e64aecf..2b0ba00 100644
--- a/src/writer/spirv/builder_bitcast_expression_test.cc
+++ b/src/writer/spirv/builder_bitcast_expression_test.cc
@@ -17,8 +17,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/u32_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/u32_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc
index 70a08d0..e751849 100644
--- a/src/writer/spirv/builder_block_test.cc
+++ b/src/writer/spirv/builder_block_test.cc
@@ -20,8 +20,8 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/f32_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc
index 51d9e9f..e1cf83f 100644
--- a/src/writer/spirv/builder_call_test.cc
+++ b/src/writer/spirv/builder_call_test.cc
@@ -24,9 +24,9 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc
index 0b8c9e1..a4f675a 100644
--- a/src/writer/spirv/builder_constructor_expression_test.cc
+++ b/src/writer/spirv/builder_constructor_expression_test.cc
@@ -27,16 +27,16 @@
#include "src/ast/struct.h"
#include "src/ast/struct_decoration.h"
#include "src/ast/struct_member.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_format_conversion_test.cc b/src/writer/spirv/builder_format_conversion_test.cc
index 4de15f4..0c9df47 100644
--- a/src/writer/spirv/builder_format_conversion_test.cc
+++ b/src/writer/spirv/builder_format_conversion_test.cc
@@ -23,7 +23,7 @@
namespace {
struct TestData {
- ast::type::ImageFormat ast_format;
+ type::ImageFormat ast_format;
SpvImageFormat_ spv_format;
bool extended_format = false;
};
@@ -51,46 +51,42 @@
BuilderTest,
ImageFormatConversionTest,
testing::Values(
- TestData{ast::type::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
- TestData{ast::type::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
- TestData{ast::type::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
- TestData{ast::type::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
- TestData{ast::type::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
- TestData{ast::type::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
- TestData{ast::type::ImageFormat::kR16Float, SpvImageFormatR16f, true},
- TestData{ast::type::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
- TestData{ast::type::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm,
+ TestData{type::ImageFormat::kR8Unorm, SpvImageFormatR8, true},
+ TestData{type::ImageFormat::kR8Snorm, SpvImageFormatR8Snorm, true},
+ TestData{type::ImageFormat::kR8Uint, SpvImageFormatR8ui, true},
+ TestData{type::ImageFormat::kR8Sint, SpvImageFormatR8i, true},
+ TestData{type::ImageFormat::kR16Uint, SpvImageFormatR16ui, true},
+ TestData{type::ImageFormat::kR16Sint, SpvImageFormatR16i, true},
+ TestData{type::ImageFormat::kR16Float, SpvImageFormatR16f, true},
+ TestData{type::ImageFormat::kRg8Unorm, SpvImageFormatRg8, true},
+ TestData{type::ImageFormat::kRg8Snorm, SpvImageFormatRg8Snorm, true},
+ TestData{type::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
+ TestData{type::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
+ TestData{type::ImageFormat::kR32Uint, SpvImageFormatR32ui},
+ TestData{type::ImageFormat::kR32Sint, SpvImageFormatR32i},
+ TestData{type::ImageFormat::kR32Float, SpvImageFormatR32f},
+ TestData{type::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
+ TestData{type::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
+ TestData{type::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
+ TestData{type::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
+ TestData{type::ImageFormat::kRgba8UnormSrgb, SpvImageFormatUnknown},
+ TestData{type::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
+ TestData{type::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
+ TestData{type::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
+ TestData{type::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
+ TestData{type::ImageFormat::kBgra8UnormSrgb, SpvImageFormatUnknown},
+ TestData{type::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2, true},
+ TestData{type::ImageFormat::kRg11B10Float, SpvImageFormatR11fG11fB10f,
true},
- TestData{ast::type::ImageFormat::kRg8Uint, SpvImageFormatRg8ui, true},
- TestData{ast::type::ImageFormat::kRg8Sint, SpvImageFormatRg8i, true},
- TestData{ast::type::ImageFormat::kR32Uint, SpvImageFormatR32ui},
- TestData{ast::type::ImageFormat::kR32Sint, SpvImageFormatR32i},
- TestData{ast::type::ImageFormat::kR32Float, SpvImageFormatR32f},
- TestData{ast::type::ImageFormat::kRg16Uint, SpvImageFormatRg16ui, true},
- TestData{ast::type::ImageFormat::kRg16Sint, SpvImageFormatRg16i, true},
- TestData{ast::type::ImageFormat::kRg16Float, SpvImageFormatRg16f, true},
- TestData{ast::type::ImageFormat::kRgba8Unorm, SpvImageFormatRgba8},
- TestData{ast::type::ImageFormat::kRgba8UnormSrgb,
- SpvImageFormatUnknown},
- TestData{ast::type::ImageFormat::kRgba8Snorm, SpvImageFormatRgba8Snorm},
- TestData{ast::type::ImageFormat::kRgba8Uint, SpvImageFormatRgba8ui},
- TestData{ast::type::ImageFormat::kRgba8Sint, SpvImageFormatRgba8i},
- TestData{ast::type::ImageFormat::kBgra8Unorm, SpvImageFormatUnknown},
- TestData{ast::type::ImageFormat::kBgra8UnormSrgb,
- SpvImageFormatUnknown},
- TestData{ast::type::ImageFormat::kRgb10A2Unorm, SpvImageFormatRgb10A2,
- true},
- TestData{ast::type::ImageFormat::kRg11B10Float,
- SpvImageFormatR11fG11fB10f, true},
- TestData{ast::type::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
- TestData{ast::type::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
- TestData{ast::type::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
- TestData{ast::type::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
- TestData{ast::type::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
- TestData{ast::type::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
- TestData{ast::type::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
- TestData{ast::type::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
- TestData{ast::type::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
+ TestData{type::ImageFormat::kRg32Uint, SpvImageFormatRg32ui, true},
+ TestData{type::ImageFormat::kRg32Sint, SpvImageFormatRg32i, true},
+ TestData{type::ImageFormat::kRg32Float, SpvImageFormatRg32f, true},
+ TestData{type::ImageFormat::kRgba16Uint, SpvImageFormatRgba16ui},
+ TestData{type::ImageFormat::kRgba16Sint, SpvImageFormatRgba16i},
+ TestData{type::ImageFormat::kRgba16Float, SpvImageFormatRgba16f},
+ TestData{type::ImageFormat::kRgba32Uint, SpvImageFormatRgba32ui},
+ TestData{type::ImageFormat::kRgba32Sint, SpvImageFormatRgba32i},
+ TestData{type::ImageFormat::kRgba32Float, SpvImageFormatRgba32f}));
} // namespace
} // namespace spirv
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index 3c4c00d..cc04b1c 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -26,13 +26,13 @@
#include "src/ast/struct.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/access_control_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
@@ -217,7 +217,7 @@
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc
index a113faa..21bccc5 100644
--- a/src/writer/spirv/builder_function_variable_test.cc
+++ b/src/writer/spirv/builder_function_variable_test.cc
@@ -25,10 +25,10 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/storage_class.h"
#include "src/ast/struct.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decoration.h"
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 0a1cc4d..cb0184c 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -27,16 +27,16 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/storage_class.h"
#include "src/ast/struct.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
@@ -384,7 +384,7 @@
"A", create<ast::Struct>(
ast::StructMemberList{Member("a", ty.i32), Member("b", ty.i32)},
ast::StructDecorationList{}));
- ast::type::AccessControl ac{ast::AccessControl::kReadOnly, A};
+ type::AccessControl ac{ast::AccessControl::kReadOnly, A};
auto* var = Var("b", ast::StorageClass::kStorage, &ac);
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
@@ -415,7 +415,7 @@
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
ast::StructDecorationList{}));
auto* B = ty.alias("B", A);
- ast::type::AccessControl ac{ast::AccessControl::kReadOnly, B};
+ type::AccessControl ac{ast::AccessControl::kReadOnly, B};
auto* var = Var("b", ast::StorageClass::kStorage, &ac);
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
@@ -442,7 +442,7 @@
auto* A = ty.struct_(
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
ast::StructDecorationList{}));
- ast::type::AccessControl ac{ast::AccessControl::kReadOnly, A};
+ type::AccessControl ac{ast::AccessControl::kReadOnly, A};
auto* B = ty.alias("B", &ac);
auto* var = Var("b", ast::StorageClass::kStorage, B);
EXPECT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
@@ -470,8 +470,8 @@
auto* A = ty.struct_(
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
ast::StructDecorationList{}));
- ast::type::AccessControl read{ast::AccessControl::kReadOnly, A};
- ast::type::AccessControl rw{ast::AccessControl::kReadWrite, A};
+ type::AccessControl read{ast::AccessControl::kReadOnly, A};
+ type::AccessControl rw{ast::AccessControl::kReadWrite, A};
auto* var_b = Var("b", ast::StorageClass::kStorage, &read);
auto* var_c = Var("c", ast::StorageClass::kStorage, &rw);
@@ -500,11 +500,11 @@
TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
- ast::type::StorageTexture type(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Uint);
+ type::StorageTexture type(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
- ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &type);
+ type::AccessControl ac(ast::AccessControl::kReadOnly, &type);
auto* var_a = Var("a", ast::StorageClass::kUniformConstant, &ac);
EXPECT_TRUE(b.GenerateGlobalVariable(var_a)) << b.error();
@@ -521,11 +521,11 @@
TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
// var<uniform_constant> a : [[access(write)]] texture_storage_2d<r32uint>;
- ast::type::StorageTexture type(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Uint);
+ type::StorageTexture type(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
- ast::type::AccessControl ac(ast::AccessControl::kWriteOnly, &type);
+ type::AccessControl ac(ast::AccessControl::kWriteOnly, &type);
auto* var_a = Var("a", ast::StorageClass::kUniformConstant, &ac);
EXPECT_TRUE(b.GenerateGlobalVariable(var_a)) << b.error();
@@ -545,15 +545,15 @@
// var<uniform_constant> a : [[access(read)]] texture_storage_2d<r32uint>;
// var<uniform_constant> b : [[access(write)]] texture_storage_2d<r32uint>;
- ast::type::StorageTexture st(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Uint);
+ type::StorageTexture st(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&st)) << td.error();
- ast::type::AccessControl type_a(ast::AccessControl::kReadOnly, &st);
+ type::AccessControl type_a(ast::AccessControl::kReadOnly, &st);
auto* var_a = Var("a", ast::StorageClass::kUniformConstant, &type_a);
EXPECT_TRUE(b.GenerateGlobalVariable(var_a)) << b.error();
- ast::type::AccessControl type_b(ast::AccessControl::kWriteOnly, &st);
+ type::AccessControl type_b(ast::AccessControl::kWriteOnly, &st);
auto* var_b = Var("b", ast::StorageClass::kUniformConstant, &type_b);
EXPECT_TRUE(b.GenerateGlobalVariable(var_b)) << b.error();
diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc
index 453ef6b..083abb7 100644
--- a/src/writer/spirv/builder_ident_expression_test.cc
+++ b/src/writer/spirv/builder_ident_expression_test.cc
@@ -20,11 +20,11 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/variable.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc
index 25e03b8..f826e0a 100644
--- a/src/writer/spirv/builder_if_test.cc
+++ b/src/writer/spirv/builder_if_test.cc
@@ -26,8 +26,8 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/i32_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc
index 654317b..d1d7a8d 100644
--- a/src/writer/spirv/builder_intrinsic_test.cc
+++ b/src/writer/spirv/builder_intrinsic_test.cc
@@ -25,23 +25,23 @@
#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
@@ -383,8 +383,8 @@
// This tests that we do not push OpTypeSampledImage and float_0 type twice.
TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
- ast::type::Sampler s(ast::type::SamplerKind::kComparisonSampler);
- ast::type::DepthTexture t(ast::type::TextureDimension::k2d);
+ type::Sampler s(type::SamplerKind::kComparisonSampler);
+ type::DepthTexture t(type::TextureDimension::k2d);
b.push_function(Function{});
diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc
index 9c1e251..33f2259 100644
--- a/src/writer/spirv/builder_intrinsic_texture_test.cc
+++ b/src/writer/spirv/builder_intrinsic_texture_test.cc
@@ -20,10 +20,10 @@
#include "src/ast/call_statement.h"
#include "src/ast/intrinsic_texture_helper_test.h"
#include "src/ast/stage_decoration.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/storage_texture_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/storage_texture_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/binary_writer.h"
#include "src/writer/spirv/builder.h"
diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc
index b641b92..59d0757 100644
--- a/src/writer/spirv/builder_literal_test.cc
+++ b/src/writer/spirv/builder_literal_test.cc
@@ -18,11 +18,11 @@
#include "src/ast/float_literal.h"
#include "src/ast/literal.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/u32_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/u32_type.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
#include "src/writer/spirv/test_helper.h"
diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc
index b9cfb02..fc1141a 100644
--- a/src/writer/spirv/builder_loop_test.cc
+++ b/src/writer/spirv/builder_loop_test.cc
@@ -22,7 +22,7 @@
#include "src/ast/loop_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc
index d3a55ff..017ac29 100644
--- a/src/writer/spirv/builder_return_test.cc
+++ b/src/writer/spirv/builder_return_test.cc
@@ -19,9 +19,9 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
+#include "src/type/vector_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc
index 7150529..d320474 100644
--- a/src/writer/spirv/builder_switch_test.cc
+++ b/src/writer/spirv/builder_switch_test.cc
@@ -25,8 +25,8 @@
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/i32_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index b1cf1c0..756e885 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -21,24 +21,24 @@
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/alias_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/texture_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/alias_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/texture_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
#include "src/writer/spirv/spv_dump.h"
@@ -76,7 +76,7 @@
}
TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
- ast::type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
+ type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(1u, id);
@@ -87,7 +87,7 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
- ast::type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
+ type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@@ -99,7 +99,7 @@
}
TEST_F(BuilderTest_Type, GenerateArray) {
- ast::type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
+ type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(1u, id);
@@ -112,10 +112,10 @@
}
TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
- ast::type::Array ary(ty.i32, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(16u),
- });
+ type::Array ary(ty.i32, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(16u),
+ });
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -132,7 +132,7 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
- ast::type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
+ type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@@ -225,7 +225,7 @@
}
TEST_F(BuilderTest_Type, GeneratePtr) {
- ast::type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
+ type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
auto id = b.GenerateTypeIfNeeded(&ptr);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(1u, id);
@@ -236,7 +236,7 @@
}
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
- ast::type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
+ type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u);
}
@@ -391,15 +391,15 @@
// We have to infer layout for matrix when it also has an offset.
// The decoration goes on the struct member, even if the matrix is buried
// in levels of arrays.
- ast::type::Array arr_mat2x2(
- ty.mat2x2<f32>(), 1, ast::ArrayDecorationList{}); // Singly nested array
+ type::Array arr_mat2x2(ty.mat2x2<f32>(), 1,
+ ast::ArrayDecorationList{}); // Singly nested array
- ast::type::Array arr_mat2x3(ty.mat2x3<f32>(), 1, ast::ArrayDecorationList{});
- ast::type::Array arr_arr_mat2x3(
+ type::Array arr_mat2x3(ty.mat2x3<f32>(), 1, ast::ArrayDecorationList{});
+ type::Array arr_arr_mat2x3(
ty.mat2x3<f32>(), 1, ast::ArrayDecorationList{}); // Doubly nested array
- ast::type::Array rtarr_mat4x4(ty.mat4x4<f32>(), 0,
- ast::ArrayDecorationList{}); // Runtime array
+ type::Array rtarr_mat4x4(ty.mat4x4<f32>(), 0,
+ ast::ArrayDecorationList{}); // Runtime array
auto* s = create<ast::Struct>(
ast::StructMemberList{Member("a", &arr_mat2x2, {MemberOffset(0)}),
@@ -533,7 +533,7 @@
PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction}));
TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) {
- ast::type::DepthTexture two_d(ast::type::TextureDimension::k2d);
+ type::DepthTexture two_d(type::TextureDimension::k2d);
auto id_two_d = b.GenerateTypeIfNeeded(&two_d);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -545,7 +545,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) {
- ast::type::DepthTexture two_d_array(ast::type::TextureDimension::k2dArray);
+ type::DepthTexture two_d_array(type::TextureDimension::k2dArray);
auto id_two_d_array = b.GenerateTypeIfNeeded(&two_d_array);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -557,7 +557,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) {
- ast::type::DepthTexture cube(ast::type::TextureDimension::kCube);
+ type::DepthTexture cube(type::TextureDimension::kCube);
auto id_cube = b.GenerateTypeIfNeeded(&cube);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -570,7 +570,7 @@
}
TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
- ast::type::DepthTexture cube_array(ast::type::TextureDimension::kCubeArray);
+ type::DepthTexture cube_array(type::TextureDimension::kCubeArray);
auto id_cube_array = b.GenerateTypeIfNeeded(&cube_array);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -585,7 +585,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
- ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, ty.i32);
+ type::MultisampledTexture ms(type::TextureDimension::k2d, ty.i32);
EXPECT_EQ(1u, b.GenerateTypeIfNeeded(&ms));
ASSERT_FALSE(b.has_error()) << b.error();
@@ -595,7 +595,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
- ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, ty.u32);
+ type::MultisampledTexture ms(type::TextureDimension::k2d, ty.u32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -606,7 +606,7 @@
}
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
- ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, ty.f32);
+ type::MultisampledTexture ms(type::TextureDimension::k2d, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -617,7 +617,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k1d, ty.i32);
+ type::SampledTexture s(type::TextureDimension::k1d, ty.i32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -632,7 +632,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k1d, ty.u32);
+ type::SampledTexture s(type::TextureDimension::k1d, ty.u32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -647,7 +647,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k1d, ty.f32);
+ type::SampledTexture s(type::TextureDimension::k1d, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -662,7 +662,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k1dArray, ty.f32);
+ type::SampledTexture s(type::TextureDimension::k1dArray, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -677,7 +677,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k2d, ty.f32);
+ type::SampledTexture s(type::TextureDimension::k2d, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -688,7 +688,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k2dArray, ty.f32);
+ type::SampledTexture s(type::TextureDimension::k2dArray, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -699,7 +699,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
- ast::type::SampledTexture s(ast::type::TextureDimension::k3d, ty.f32);
+ type::SampledTexture s(type::TextureDimension::k3d, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -710,7 +710,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
- ast::type::SampledTexture s(ast::type::TextureDimension::kCube, ty.f32);
+ type::SampledTexture s(type::TextureDimension::kCube, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -722,7 +722,7 @@
}
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
- ast::type::SampledTexture s(ast::type::TextureDimension::kCubeArray, ty.f32);
+ type::SampledTexture s(type::TextureDimension::kCubeArray, ty.f32);
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
@@ -736,8 +736,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R16Float) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kR16Float);
+ type::StorageTexture s(type::TextureDimension::k1d,
+ type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -753,8 +753,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8SNorm) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kR8Snorm);
+ type::StorageTexture s(type::TextureDimension::k1d,
+ type::ImageFormat::kR8Snorm);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -770,8 +770,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8UNorm) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kR8Unorm);
+ type::StorageTexture s(type::TextureDimension::k1d,
+ type::ImageFormat::kR8Unorm);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -787,8 +787,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Uint) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kR8Uint);
+ type::StorageTexture s(type::TextureDimension::k1d,
+ type::ImageFormat::kR8Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -799,8 +799,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_R8Sint) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1d,
- ast::type::ImageFormat::kR8Sint);
+ type::StorageTexture s(type::TextureDimension::k1d,
+ type::ImageFormat::kR8Sint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -811,8 +811,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_1d_array) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k1dArray,
- ast::type::ImageFormat::kR16Float);
+ type::StorageTexture s(type::TextureDimension::k1dArray,
+ type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -828,8 +828,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR16Float);
+ type::StorageTexture s(type::TextureDimension::k2d,
+ type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -840,8 +840,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k2dArray,
- ast::type::ImageFormat::kR16Float);
+ type::StorageTexture s(type::TextureDimension::k2dArray,
+ type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -852,8 +852,8 @@
}
TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k3d,
- ast::type::ImageFormat::kR16Float);
+ type::StorageTexture s(type::TextureDimension::k3d,
+ type::ImageFormat::kR16Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -865,8 +865,8 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeFloat_Format_r32float) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Float);
+ type::StorageTexture s(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Float);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -878,8 +878,8 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeSint_Format_r32sint) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Sint);
+ type::StorageTexture s(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Sint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -891,8 +891,8 @@
TEST_F(BuilderTest_Type,
StorageTexture_Generate_SampledTypeUint_Format_r32uint) {
- ast::type::StorageTexture s(ast::type::TextureDimension::k2d,
- ast::type::ImageFormat::kR32Uint);
+ type::StorageTexture s(type::TextureDimension::k2d,
+ type::ImageFormat::kR32Uint);
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error();
EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u);
@@ -903,24 +903,24 @@
}
TEST_F(BuilderTest_Type, Sampler) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
+ type::Sampler sampler(type::SamplerKind::kSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
}
TEST_F(BuilderTest_Type, ComparisonSampler) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
+ type::Sampler sampler(type::SamplerKind::kComparisonSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
}
TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) {
- ast::type::Sampler comp_sampler(ast::type::SamplerKind::kComparisonSampler);
+ type::Sampler comp_sampler(type::SamplerKind::kComparisonSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&comp_sampler), 1u);
- ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
+ type::Sampler sampler(type::SamplerKind::kSampler);
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
ASSERT_FALSE(b.has_error()) << b.error();
diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc
index 5fc830b..409994c 100644
--- a/src/writer/spirv/builder_unary_op_expression_test.cc
+++ b/src/writer/spirv/builder_unary_op_expression_test.cc
@@ -20,10 +20,10 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/vector_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/vector_type.h"
#include "src/ast/unary_op_expression.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index a0f2c6c..c395c60 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -50,28 +50,28 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/uint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/float_to_string.h"
namespace tint {
@@ -172,15 +172,15 @@
return true;
}
-bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) {
+bool GeneratorImpl::EmitConstructedType(const type::Type* ty) {
make_indent();
- if (auto* alias = ty->As<ast::type::Alias>()) {
+ if (auto* alias = ty->As<type::Alias>()) {
out_ << "type " << module_.SymbolToName(alias->symbol()) << " = ";
if (!EmitType(alias->type())) {
return false;
}
out_ << ";" << std::endl;
- } else if (auto* str = ty->As<ast::type::Struct>()) {
+ } else if (auto* str = ty->As<type::Struct>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -387,9 +387,9 @@
return EmitBlockAndNewline(func->body());
}
-bool GeneratorImpl::EmitImageFormat(const ast::type::ImageFormat fmt) {
+bool GeneratorImpl::EmitImageFormat(const type::ImageFormat fmt) {
switch (fmt) {
- case ast::type::ImageFormat::kNone:
+ case type::ImageFormat::kNone:
error_ = "unknown image format";
return false;
default:
@@ -398,9 +398,9 @@
return true;
}
-bool GeneratorImpl::EmitType(ast::type::Type* type) {
+bool GeneratorImpl::EmitType(type::Type* type) {
std::string storage_texture_access = "";
- if (auto* ac = type->As<ast::type::AccessControl>()) {
+ if (auto* ac = type->As<type::AccessControl>()) {
out_ << "[[access(";
if (ac->IsReadOnly()) {
out_ << "read";
@@ -417,9 +417,9 @@
return false;
}
return true;
- } else if (auto* alias = type->As<ast::type::Alias>()) {
+ } else if (auto* alias = type->As<type::Alias>()) {
out_ << module_.SymbolToName(alias->symbol());
- } else if (auto* ary = type->As<ast::type::Array>()) {
+ } else if (auto* ary = type->As<type::Array>()) {
for (auto* deco : ary->decorations()) {
if (auto* stride = deco->As<ast::StrideDecoration>()) {
out_ << "[[stride(" << stride->stride() << ")]] ";
@@ -435,43 +435,43 @@
out_ << ", " << ary->size();
out_ << ">";
- } else if (type->Is<ast::type::Bool>()) {
+ } else if (type->Is<type::Bool>()) {
out_ << "bool";
- } else if (type->Is<ast::type::F32>()) {
+ } else if (type->Is<type::F32>()) {
out_ << "f32";
- } else if (type->Is<ast::type::I32>()) {
+ } else if (type->Is<type::I32>()) {
out_ << "i32";
- } else if (auto* mat = type->As<ast::type::Matrix>()) {
+ } else if (auto* mat = type->As<type::Matrix>()) {
out_ << "mat" << mat->columns() << "x" << mat->rows() << "<";
if (!EmitType(mat->type())) {
return false;
}
out_ << ">";
- } else if (auto* ptr = type->As<ast::type::Pointer>()) {
+ } else if (auto* ptr = type->As<type::Pointer>()) {
out_ << "ptr<" << ptr->storage_class() << ", ";
if (!EmitType(ptr->type())) {
return false;
}
out_ << ">";
- } else if (auto* sampler = type->As<ast::type::Sampler>()) {
+ } else if (auto* sampler = type->As<type::Sampler>()) {
out_ << "sampler";
if (sampler->IsComparison()) {
out_ << "_comparison";
}
- } else if (auto* str = type->As<ast::type::Struct>()) {
+ } else if (auto* str = type->As<type::Struct>()) {
// The struct, as a type, is just the name. We should have already emitted
// the declaration through a call to |EmitStructType| earlier.
out_ << module_.SymbolToName(str->symbol());
- } else if (auto* texture = type->As<ast::type::Texture>()) {
+ } else if (auto* texture = type->As<type::Texture>()) {
out_ << "texture_";
- if (texture->Is<ast::type::DepthTexture>()) {
+ if (texture->Is<type::DepthTexture>()) {
out_ << "depth_";
- } else if (texture->Is<ast::type::SampledTexture>()) {
+ } else if (texture->Is<type::SampledTexture>()) {
/* nothing to emit */
- } else if (texture->Is<ast::type::MultisampledTexture>()) {
+ } else if (texture->Is<type::MultisampledTexture>()) {
out_ << "multisampled_";
- } else if (texture->Is<ast::type::StorageTexture>()) {
+ } else if (texture->Is<type::StorageTexture>()) {
out_ << "storage_";
} else {
error_ = "unknown texture type";
@@ -479,25 +479,25 @@
}
switch (texture->dim()) {
- case ast::type::TextureDimension::k1d:
+ case type::TextureDimension::k1d:
out_ << "1d";
break;
- case ast::type::TextureDimension::k1dArray:
+ case type::TextureDimension::k1dArray:
out_ << "1d_array";
break;
- case ast::type::TextureDimension::k2d:
+ case type::TextureDimension::k2d:
out_ << "2d";
break;
- case ast::type::TextureDimension::k2dArray:
+ case type::TextureDimension::k2dArray:
out_ << "2d_array";
break;
- case ast::type::TextureDimension::k3d:
+ case type::TextureDimension::k3d:
out_ << "3d";
break;
- case ast::type::TextureDimension::kCube:
+ case type::TextureDimension::kCube:
out_ << "cube";
break;
- case ast::type::TextureDimension::kCubeArray:
+ case type::TextureDimension::kCubeArray:
out_ << "cube_array";
break;
default:
@@ -505,19 +505,19 @@
return false;
}
- if (auto* sampled = texture->As<ast::type::SampledTexture>()) {
+ if (auto* sampled = texture->As<type::SampledTexture>()) {
out_ << "<";
if (!EmitType(sampled->type())) {
return false;
}
out_ << ">";
- } else if (auto* ms = texture->As<ast::type::MultisampledTexture>()) {
+ } else if (auto* ms = texture->As<type::MultisampledTexture>()) {
out_ << "<";
if (!EmitType(ms->type())) {
return false;
}
out_ << ">";
- } else if (auto* storage = texture->As<ast::type::StorageTexture>()) {
+ } else if (auto* storage = texture->As<type::StorageTexture>()) {
out_ << "<";
if (!EmitImageFormat(storage->image_format())) {
return false;
@@ -525,15 +525,15 @@
out_ << ">";
}
- } else if (type->Is<ast::type::U32>()) {
+ } else if (type->Is<type::U32>()) {
out_ << "u32";
- } else if (auto* vec = type->As<ast::type::Vector>()) {
+ } else if (auto* vec = type->As<type::Vector>()) {
out_ << "vec" << vec->size() << "<";
if (!EmitType(vec->type())) {
return false;
}
out_ << ">";
- } else if (type->Is<ast::type::Void>()) {
+ } else if (type->Is<type::Void>()) {
out_ << "void";
} else {
error_ = "unknown type in EmitType: " + type->type_name();
@@ -543,7 +543,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) {
+bool GeneratorImpl::EmitStructType(const type::Struct* str) {
auto* impl = str->impl();
for (auto* deco : impl->decorations()) {
out_ << "[[";
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index 9b25e82..1b3d568 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -37,12 +37,12 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/type.h"
#include "src/ast/type_constructor_expression.h"
#include "src/ast/unary_op_expression.h"
#include "src/ast/variable.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/type.h"
#include "src/writer/text_generator.h"
namespace tint {
@@ -70,7 +70,7 @@
/// Handles generating a constructed type
/// @param ty the constructed to generate
/// @returns true if the constructed was emitted
- bool EmitConstructedType(const ast::type::Type* ty);
+ bool EmitConstructedType(const type::Type* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
@@ -178,15 +178,15 @@
/// Handles generating type
/// @param type the type to generate
/// @returns true if the type is emitted
- bool EmitType(ast::type::Type* type);
+ bool EmitType(type::Type* type);
/// Handles generating a struct declaration
/// @param str the struct
/// @returns true if the struct is emitted
- bool EmitStructType(const ast::type::Struct* str);
+ bool EmitStructType(const type::Struct* str);
/// Handles emitting an image format
/// @param fmt the format to generate
/// @returns true if the format is emitted
- bool EmitImageFormat(const ast::type::ImageFormat fmt);
+ bool EmitImageFormat(const type::ImageFormat fmt);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc
index d1813ad..fc158a1 100644
--- a/src/writer/wgsl/generator_impl_alias_type_test.cc
+++ b/src/writer/wgsl/generator_impl_alias_type_test.cc
@@ -16,7 +16,7 @@
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
-#include "src/ast/type/struct_type.h"
+#include "src/type/struct_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc
index 2d8a85d..6a3e208 100644
--- a/src/writer/wgsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_bitcast_test.cc b/src/writer/wgsl/generator_impl_bitcast_test.cc
index 01c6d5e..7441780 100644
--- a/src/writer/wgsl/generator_impl_bitcast_test.cc
+++ b/src/writer/wgsl/generator_impl_bitcast_test.cc
@@ -17,7 +17,7 @@
#include "gtest/gtest.h"
#include "src/ast/bitcast_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/type/f32_type.h"
+#include "src/type/f32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc
index ff2f393..cd52219 100644
--- a/src/writer/wgsl/generator_impl_case_test.cc
+++ b/src/writer/wgsl/generator_impl_case_test.cc
@@ -19,7 +19,7 @@
#include "src/ast/case_statement.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_cast_test.cc b/src/writer/wgsl/generator_impl_cast_test.cc
index b90a7a1..ff2881b 100644
--- a/src/writer/wgsl/generator_impl_cast_test.cc
+++ b/src/writer/wgsl/generator_impl_cast_test.cc
@@ -16,8 +16,8 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/type/f32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc
index 31a577e..4705802 100644
--- a/src/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/writer/wgsl/generator_impl_constructor_test.cc
@@ -17,14 +17,14 @@
#include "src/ast/float_literal.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/sint_literal.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
#include "src/ast/uint_literal.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc
index c8f4b86..21844c6 100644
--- a/src/writer/wgsl/generator_impl_function_test.cc
+++ b/src/writer/wgsl/generator_impl_function_test.cc
@@ -22,13 +22,13 @@
#include "src/ast/stage_decoration.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/void_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/type/access_control_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/void_type.h"
#include "src/type_determiner.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
@@ -172,7 +172,7 @@
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
auto* s = ty.struct_("Data", str);
- ast::type::AccessControl ac(ast::AccessControl::kReadWrite, s);
+ type::AccessControl ac(ast::AccessControl::kReadWrite, s);
auto* data_var = Var("data", ast::StorageClass::kStorage, &ac, nullptr,
ast::VariableDecorationList{
diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc
index 602fe51..48b2b83 100644
--- a/src/writer/wgsl/generator_impl_switch_test.cc
+++ b/src/writer/wgsl/generator_impl_switch_test.cc
@@ -20,7 +20,7 @@
#include "src/ast/identifier_expression.h"
#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
-#include "src/ast/type/i32_type.h"
+#include "src/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc
index 37f080a..c3661d5 100644
--- a/src/writer/wgsl/generator_impl_test.cc
+++ b/src/writer/wgsl/generator_impl_test.cc
@@ -19,7 +19,7 @@
#include "gtest/gtest.h"
#include "src/ast/function.h"
#include "src/ast/module.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/void_type.h"
#include "src/writer/wgsl/test_helper.h"
namespace tint {
diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc
index cff995d..f67e8eb 100644
--- a/src/writer/wgsl/generator_impl_type_test.cc
+++ b/src/writer/wgsl/generator_impl_type_test.cc
@@ -21,22 +21,22 @@
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_decoration.h"
#include "src/ast/struct_member_offset_decoration.h"
-#include "src/ast/type/access_control_type.h"
-#include "src/ast/type/array_type.h"
-#include "src/ast/type/bool_type.h"
-#include "src/ast/type/depth_texture_type.h"
-#include "src/ast/type/f32_type.h"
-#include "src/ast/type/i32_type.h"
-#include "src/ast/type/matrix_type.h"
-#include "src/ast/type/multisampled_texture_type.h"
-#include "src/ast/type/pointer_type.h"
-#include "src/ast/type/sampled_texture_type.h"
-#include "src/ast/type/sampler_type.h"
-#include "src/ast/type/storage_texture_type.h"
-#include "src/ast/type/struct_type.h"
-#include "src/ast/type/u32_type.h"
-#include "src/ast/type/vector_type.h"
-#include "src/ast/type/void_type.h"
+#include "src/type/access_control_type.h"
+#include "src/type/array_type.h"
+#include "src/type/bool_type.h"
+#include "src/type/depth_texture_type.h"
+#include "src/type/f32_type.h"
+#include "src/type/i32_type.h"
+#include "src/type/matrix_type.h"
+#include "src/type/multisampled_texture_type.h"
+#include "src/type/pointer_type.h"
+#include "src/type/sampled_texture_type.h"
+#include "src/type/sampler_type.h"
+#include "src/type/storage_texture_type.h"
+#include "src/type/struct_type.h"
+#include "src/type/u32_type.h"
+#include "src/type/vector_type.h"
+#include "src/type/void_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
@@ -68,7 +68,7 @@
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)}, decos);
auto* s = ty.struct_("S", str);
- ast::type::AccessControl a(ast::AccessControl::kReadOnly, s);
+ type::AccessControl a(ast::AccessControl::kReadOnly, s);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[access(read)]]\nS");
@@ -83,35 +83,35 @@
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)}, decos);
auto* s = ty.struct_("S", str);
- ast::type::AccessControl a(ast::AccessControl::kReadWrite, s);
+ type::AccessControl a(ast::AccessControl::kReadWrite, s);
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[access(read_write)]]\nS");
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
- ast::type::Array a(ty.bool_, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(16u),
- });
+ type::Array a(ty.bool_, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(16u),
+ });
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[stride(16)]] array<bool, 4>");
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
- ast::type::Array a(ty.bool_, 4,
- ast::ArrayDecorationList{
- create<ast::StrideDecoration>(16u),
- create<ast::StrideDecoration>(32u),
- });
+ type::Array a(ty.bool_, 4,
+ ast::ArrayDecorationList{
+ create<ast::StrideDecoration>(16u),
+ create<ast::StrideDecoration>(32u),
+ });
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[stride(16)]] [[stride(32)]] array<bool, 4>");
}
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
- ast::type::Array a(ty.bool_, 0, ast::ArrayDecorationList{});
+ type::Array a(ty.bool_, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "array<bool>");
@@ -138,7 +138,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
- ast::type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
+ type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
ASSERT_TRUE(gen.EmitType(&p)) << gen.error();
EXPECT_EQ(gen.result(), "ptr<workgroup, f32>");
@@ -207,7 +207,7 @@
}
struct TextureData {
- ast::type::TextureDimension dim;
+ type::TextureDimension dim;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, TextureData data) {
@@ -219,7 +219,7 @@
TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
auto param = GetParam();
- ast::type::DepthTexture d(param.dim);
+ type::DepthTexture d(param.dim);
ASSERT_TRUE(gen.EmitType(&d)) << gen.error();
EXPECT_EQ(gen.result(), param.name);
@@ -228,18 +228,17 @@
WgslGeneratorImplTest,
WgslGenerator_DepthTextureTest,
testing::Values(
- TextureData{ast::type::TextureDimension::k2d, "texture_depth_2d"},
- TextureData{ast::type::TextureDimension::k2dArray,
- "texture_depth_2d_array"},
- TextureData{ast::type::TextureDimension::kCube, "texture_depth_cube"},
- TextureData{ast::type::TextureDimension::kCubeArray,
+ TextureData{type::TextureDimension::k2d, "texture_depth_2d"},
+ TextureData{type::TextureDimension::k2dArray, "texture_depth_2d_array"},
+ TextureData{type::TextureDimension::kCube, "texture_depth_cube"},
+ TextureData{type::TextureDimension::kCubeArray,
"texture_depth_cube_array"}));
using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
auto param = GetParam();
- ast::type::SampledTexture t(param.dim, ty.f32);
+ type::SampledTexture t(param.dim, ty.f32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<f32>");
@@ -248,7 +247,7 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
auto param = GetParam();
- ast::type::SampledTexture t(param.dim, ty.i32);
+ type::SampledTexture t(param.dim, ty.i32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<i32>");
@@ -257,7 +256,7 @@
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
auto param = GetParam();
- ast::type::SampledTexture t(param.dim, ty.u32);
+ type::SampledTexture t(param.dim, ty.u32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<u32>");
@@ -266,20 +265,19 @@
WgslGeneratorImplTest,
WgslGenerator_SampledTextureTest,
testing::Values(
- TextureData{ast::type::TextureDimension::k1d, "texture_1d"},
- TextureData{ast::type::TextureDimension::k1dArray, "texture_1d_array"},
- TextureData{ast::type::TextureDimension::k2d, "texture_2d"},
- TextureData{ast::type::TextureDimension::k2dArray, "texture_2d_array"},
- TextureData{ast::type::TextureDimension::k3d, "texture_3d"},
- TextureData{ast::type::TextureDimension::kCube, "texture_cube"},
- TextureData{ast::type::TextureDimension::kCubeArray,
- "texture_cube_array"}));
+ TextureData{type::TextureDimension::k1d, "texture_1d"},
+ TextureData{type::TextureDimension::k1dArray, "texture_1d_array"},
+ TextureData{type::TextureDimension::k2d, "texture_2d"},
+ TextureData{type::TextureDimension::k2dArray, "texture_2d_array"},
+ TextureData{type::TextureDimension::k3d, "texture_3d"},
+ TextureData{type::TextureDimension::kCube, "texture_cube"},
+ TextureData{type::TextureDimension::kCubeArray, "texture_cube_array"}));
using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
auto param = GetParam();
- ast::type::MultisampledTexture t(param.dim, ty.f32);
+ type::MultisampledTexture t(param.dim, ty.f32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<f32>");
@@ -288,7 +286,7 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
auto param = GetParam();
- ast::type::MultisampledTexture t(param.dim, ty.i32);
+ type::MultisampledTexture t(param.dim, ty.i32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<i32>");
@@ -297,7 +295,7 @@
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
auto param = GetParam();
- ast::type::MultisampledTexture t(param.dim, ty.u32);
+ type::MultisampledTexture t(param.dim, ty.u32);
ASSERT_TRUE(gen.EmitType(&t)) << gen.error();
EXPECT_EQ(gen.result(), std::string(param.name) + "<u32>");
@@ -305,12 +303,12 @@
INSTANTIATE_TEST_SUITE_P(WgslGeneratorImplTest,
WgslGenerator_MultiampledTextureTest,
testing::Values(TextureData{
- ast::type::TextureDimension::k2d,
+ type::TextureDimension::k2d,
"texture_multisampled_2d"}));
struct StorageTextureData {
- ast::type::ImageFormat fmt;
- ast::type::TextureDimension dim;
+ type::ImageFormat fmt;
+ type::TextureDimension dim;
ast::AccessControl access;
const char* name;
};
@@ -322,8 +320,8 @@
TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
auto param = GetParam();
- ast::type::StorageTexture t(param.dim, param.fmt);
- ast::type::AccessControl ac(param.access, &t);
+ type::StorageTexture t(param.dim, param.fmt);
+ type::AccessControl ac(param.access, &t);
ASSERT_TRUE(gen.EmitType(&ac)) << gen.error();
EXPECT_EQ(gen.result(), param.name);
@@ -332,53 +330,49 @@
WgslGeneratorImplTest,
WgslGenerator_StorageTextureTest,
testing::Values(
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k1d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k1d,
ast::AccessControl::kReadOnly,
"[[access(read)]]\ntexture_storage_1d<r8unorm>"},
StorageTextureData{
- ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k1dArray,
+ type::ImageFormat::kR8Unorm, type::TextureDimension::k1dArray,
ast::AccessControl::kReadOnly,
"[[access(read)]]\ntexture_storage_1d_array<r8unorm>"},
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k2d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k2d,
ast::AccessControl::kReadOnly,
"[[access(read)]]\ntexture_storage_2d<r8unorm>"},
StorageTextureData{
- ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k2dArray,
+ type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray,
ast::AccessControl::kReadOnly,
"[[access(read)]]\ntexture_storage_2d_array<r8unorm>"},
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k3d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k3d,
ast::AccessControl::kReadOnly,
"[[access(read)]]\ntexture_storage_3d<r8unorm>"},
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k1d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k1d,
ast::AccessControl::kWriteOnly,
"[[access(write)]]\ntexture_storage_1d<r8unorm>"},
StorageTextureData{
- ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k1dArray,
+ type::ImageFormat::kR8Unorm, type::TextureDimension::k1dArray,
ast::AccessControl::kWriteOnly,
"[[access(write)]]\ntexture_storage_1d_array<r8unorm>"},
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k2d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k2d,
ast::AccessControl::kWriteOnly,
"[[access(write)]]\ntexture_storage_2d<r8unorm>"},
StorageTextureData{
- ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k2dArray,
+ type::ImageFormat::kR8Unorm, type::TextureDimension::k2dArray,
ast::AccessControl::kWriteOnly,
"[[access(write)]]\ntexture_storage_2d_array<r8unorm>"},
- StorageTextureData{ast::type::ImageFormat::kR8Unorm,
- ast::type::TextureDimension::k3d,
+ StorageTextureData{type::ImageFormat::kR8Unorm,
+ type::TextureDimension::k3d,
ast::AccessControl::kWriteOnly,
"[[access(write)]]\ntexture_storage_3d<r8unorm>"}));
struct ImageFormatData {
- ast::type::ImageFormat fmt;
+ type::ImageFormat fmt;
const char* name;
};
inline std::ostream& operator<<(std::ostream& out, ImageFormatData data) {
@@ -397,53 +391,51 @@
WgslGeneratorImplTest,
WgslGenerator_ImageFormatTest,
testing::Values(
- ImageFormatData{ast::type::ImageFormat::kR8Unorm, "r8unorm"},
- ImageFormatData{ast::type::ImageFormat::kR8Snorm, "r8snorm"},
- ImageFormatData{ast::type::ImageFormat::kR8Uint, "r8uint"},
- ImageFormatData{ast::type::ImageFormat::kR8Sint, "r8sint"},
- ImageFormatData{ast::type::ImageFormat::kR16Uint, "r16uint"},
- ImageFormatData{ast::type::ImageFormat::kR16Sint, "r16sint"},
- ImageFormatData{ast::type::ImageFormat::kR16Float, "r16float"},
- ImageFormatData{ast::type::ImageFormat::kRg8Unorm, "rg8unorm"},
- ImageFormatData{ast::type::ImageFormat::kRg8Snorm, "rg8snorm"},
- ImageFormatData{ast::type::ImageFormat::kRg8Uint, "rg8uint"},
- ImageFormatData{ast::type::ImageFormat::kRg8Sint, "rg8sint"},
- ImageFormatData{ast::type::ImageFormat::kR32Uint, "r32uint"},
- ImageFormatData{ast::type::ImageFormat::kR32Sint, "r32sint"},
- ImageFormatData{ast::type::ImageFormat::kR32Float, "r32float"},
- ImageFormatData{ast::type::ImageFormat::kRg16Uint, "rg16uint"},
- ImageFormatData{ast::type::ImageFormat::kRg16Sint, "rg16sint"},
- ImageFormatData{ast::type::ImageFormat::kRg16Float, "rg16float"},
- ImageFormatData{ast::type::ImageFormat::kRgba8Unorm, "rgba8unorm"},
- ImageFormatData{ast::type::ImageFormat::kRgba8UnormSrgb,
- "rgba8unorm_srgb"},
- ImageFormatData{ast::type::ImageFormat::kRgba8Snorm, "rgba8snorm"},
- ImageFormatData{ast::type::ImageFormat::kRgba8Uint, "rgba8uint"},
- ImageFormatData{ast::type::ImageFormat::kRgba8Sint, "rgba8sint"},
- ImageFormatData{ast::type::ImageFormat::kBgra8Unorm, "bgra8unorm"},
- ImageFormatData{ast::type::ImageFormat::kBgra8UnormSrgb,
- "bgra8unorm_srgb"},
- ImageFormatData{ast::type::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
- ImageFormatData{ast::type::ImageFormat::kRg11B10Float, "rg11b10float"},
- ImageFormatData{ast::type::ImageFormat::kRg32Uint, "rg32uint"},
- ImageFormatData{ast::type::ImageFormat::kRg32Sint, "rg32sint"},
- ImageFormatData{ast::type::ImageFormat::kRg32Float, "rg32float"},
- ImageFormatData{ast::type::ImageFormat::kRgba16Uint, "rgba16uint"},
- ImageFormatData{ast::type::ImageFormat::kRgba16Sint, "rgba16sint"},
- ImageFormatData{ast::type::ImageFormat::kRgba16Float, "rgba16float"},
- ImageFormatData{ast::type::ImageFormat::kRgba32Uint, "rgba32uint"},
- ImageFormatData{ast::type::ImageFormat::kRgba32Sint, "rgba32sint"},
- ImageFormatData{ast::type::ImageFormat::kRgba32Float, "rgba32float"}));
+ ImageFormatData{type::ImageFormat::kR8Unorm, "r8unorm"},
+ ImageFormatData{type::ImageFormat::kR8Snorm, "r8snorm"},
+ ImageFormatData{type::ImageFormat::kR8Uint, "r8uint"},
+ ImageFormatData{type::ImageFormat::kR8Sint, "r8sint"},
+ ImageFormatData{type::ImageFormat::kR16Uint, "r16uint"},
+ ImageFormatData{type::ImageFormat::kR16Sint, "r16sint"},
+ ImageFormatData{type::ImageFormat::kR16Float, "r16float"},
+ ImageFormatData{type::ImageFormat::kRg8Unorm, "rg8unorm"},
+ ImageFormatData{type::ImageFormat::kRg8Snorm, "rg8snorm"},
+ ImageFormatData{type::ImageFormat::kRg8Uint, "rg8uint"},
+ ImageFormatData{type::ImageFormat::kRg8Sint, "rg8sint"},
+ ImageFormatData{type::ImageFormat::kR32Uint, "r32uint"},
+ ImageFormatData{type::ImageFormat::kR32Sint, "r32sint"},
+ ImageFormatData{type::ImageFormat::kR32Float, "r32float"},
+ ImageFormatData{type::ImageFormat::kRg16Uint, "rg16uint"},
+ ImageFormatData{type::ImageFormat::kRg16Sint, "rg16sint"},
+ ImageFormatData{type::ImageFormat::kRg16Float, "rg16float"},
+ ImageFormatData{type::ImageFormat::kRgba8Unorm, "rgba8unorm"},
+ ImageFormatData{type::ImageFormat::kRgba8UnormSrgb, "rgba8unorm_srgb"},
+ ImageFormatData{type::ImageFormat::kRgba8Snorm, "rgba8snorm"},
+ ImageFormatData{type::ImageFormat::kRgba8Uint, "rgba8uint"},
+ ImageFormatData{type::ImageFormat::kRgba8Sint, "rgba8sint"},
+ ImageFormatData{type::ImageFormat::kBgra8Unorm, "bgra8unorm"},
+ ImageFormatData{type::ImageFormat::kBgra8UnormSrgb, "bgra8unorm_srgb"},
+ ImageFormatData{type::ImageFormat::kRgb10A2Unorm, "rgb10a2unorm"},
+ ImageFormatData{type::ImageFormat::kRg11B10Float, "rg11b10float"},
+ ImageFormatData{type::ImageFormat::kRg32Uint, "rg32uint"},
+ ImageFormatData{type::ImageFormat::kRg32Sint, "rg32sint"},
+ ImageFormatData{type::ImageFormat::kRg32Float, "rg32float"},
+ ImageFormatData{type::ImageFormat::kRgba16Uint, "rgba16uint"},
+ ImageFormatData{type::ImageFormat::kRgba16Sint, "rgba16sint"},
+ ImageFormatData{type::ImageFormat::kRgba16Float, "rgba16float"},
+ ImageFormatData{type::ImageFormat::kRgba32Uint, "rgba32uint"},
+ ImageFormatData{type::ImageFormat::kRgba32Sint, "rgba32sint"},
+ ImageFormatData{type::ImageFormat::kRgba32Float, "rgba32float"}));
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kSampler);
+ type::Sampler sampler(type::SamplerKind::kSampler);
ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error();
EXPECT_EQ(gen.result(), "sampler");
}
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
- ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler);
+ type::Sampler sampler(type::SamplerKind::kComparisonSampler);
ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error();
EXPECT_EQ(gen.result(), "sampler_comparison");
diff --git a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
index 3071b8c..c1c3229 100644
--- a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc
@@ -17,9 +17,9 @@
#include "gtest/gtest.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decl_statement.h"
+#include "src/type/f32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"
diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc
index 501c880..9a8e9fc 100644
--- a/src/writer/wgsl/generator_impl_variable_test.cc
+++ b/src/writer/wgsl/generator_impl_variable_test.cc
@@ -20,9 +20,9 @@
#include "src/ast/constant_id_decoration.h"
#include "src/ast/group_decoration.h"
#include "src/ast/location_decoration.h"
-#include "src/ast/type/f32_type.h"
#include "src/ast/variable.h"
#include "src/ast/variable_decoration.h"
+#include "src/type/f32_type.h"
#include "src/writer/wgsl/generator_impl.h"
#include "src/writer/wgsl/test_helper.h"