Rename 'constructed types' to 'type declarartions'
Change-Id: I0c79be17a10a542df602447e555c1344621d2dce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53803
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/ast/module.cc b/src/ast/module.cc
index fcb7216..e85c033 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -37,7 +37,7 @@
}
if (auto* ty = decl->As<ast::TypeDecl>()) {
- constructed_types_.push_back(ty);
+ type_decls_.push_back(ty);
} else if (auto* func = decl->As<Function>()) {
functions_.push_back(func);
} else if (auto* var = decl->As<Variable>()) {
@@ -52,7 +52,7 @@
Module::~Module() = default;
const ast::TypeDecl* Module::LookupType(Symbol name) const {
- for (auto* ty : ConstructedTypes()) {
+ for (auto* ty : TypeDecls()) {
if (ty->name() == name) {
return ty;
}
@@ -67,9 +67,9 @@
global_declarations_.push_back(var);
}
-void Module::AddConstructedType(ast::TypeDecl* type) {
+void Module::AddTypeDecl(ast::TypeDecl* type) {
TINT_ASSERT(type);
- constructed_types_.push_back(type);
+ type_decls_.push_back(type);
global_declarations_.push_back(type);
}
@@ -93,7 +93,7 @@
continue;
}
if (auto* ty = decl->As<ast::TypeDecl>()) {
- AddConstructedType(ty);
+ AddTypeDecl(ty);
} else if (auto* func = decl->As<Function>()) {
AddFunction(func);
} else if (auto* var = decl->As<Variable>()) {
@@ -110,7 +110,7 @@
make_indent(out, indent);
out << "Module{" << std::endl;
indent += 2;
- for (auto* ty : constructed_types_) {
+ for (auto* ty : type_decls_) {
make_indent(out, indent);
if (auto* alias = ty->As<ast::Alias>()) {
out << alias->symbol().to_str() << " -> " << alias->type()->type_name()
diff --git a/src/ast/module.h b/src/ast/module.h
index af502cf..8ce8e7e 100644
--- a/src/ast/module.h
+++ b/src/ast/module.h
@@ -74,17 +74,15 @@
VariableList& GlobalVariables() { return global_variables_; }
/// Adds a type declaration to the Builder.
- /// @param decl the constructed type declaration to add
- void AddConstructedType(ast::TypeDecl* decl);
+ /// @param decl the type declaration to add
+ void AddTypeDecl(ast::TypeDecl* decl);
- /// @returns the TypeDecl registered as a ConstructedType()
+ /// @returns the TypeDecl registered as a TypeDecl()
/// @param name the name of the type to search for
const ast::TypeDecl* LookupType(Symbol name) const;
- /// @returns the constructed types in the translation unit
- const std::vector<ast::TypeDecl*>& ConstructedTypes() const {
- return constructed_types_;
- }
+ /// @returns the declared types in the translation unit
+ const std::vector<ast::TypeDecl*>& TypeDecls() const { return type_decls_; }
/// Add a function to the Builder
/// @param func the function to add
@@ -118,7 +116,7 @@
private:
std::vector<ast::Node*> global_declarations_;
- std::vector<ast::TypeDecl*> constructed_types_;
+ std::vector<ast::TypeDecl*> type_decls_;
FunctionList functions_;
VariableList global_variables_;
};
diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc
index 7007b4b..28bf548 100644
--- a/src/ast/module_test.cc
+++ b/src/ast/module_test.cc
@@ -55,11 +55,11 @@
"internal compiler error");
}
-TEST_F(ModuleTest, Assert_Null_ConstructedType) {
+TEST_F(ModuleTest, Assert_Null_TypeDecl) {
EXPECT_FATAL_FAILURE(
{
ProgramBuilder builder;
- builder.AST().AddConstructedType(nullptr);
+ builder.AST().AddTypeDecl(nullptr);
},
"internal compiler error");
}
diff --git a/src/program_builder.h b/src/program_builder.h
index 62c4ee8..5769545 100644
--- a/src/program_builder.h
+++ b/src/program_builder.h
@@ -1598,7 +1598,7 @@
return create<ast::ReturnStatement>(Expr(std::forward<EXPR>(val)));
}
- /// Creates a ast::Alias registering it with the AST().ConstructedTypes().
+ /// Creates a ast::Alias registering it with the AST().TypeDecls().
/// @param source the source information
/// @param name the alias name
/// @param type the alias target type
@@ -1606,22 +1606,22 @@
template <typename NAME>
ast::Alias* Alias(const Source& source, NAME&& name, ast::Type* type) {
auto* out = ty.alias(source, std::forward<NAME>(name), type);
- AST().AddConstructedType(out);
+ AST().AddTypeDecl(out);
return out;
}
- /// Creates a ast::Alias registering it with the AST().ConstructedTypes().
+ /// Creates a ast::Alias registering it with the AST().TypeDecls().
/// @param name the alias name
/// @param type the alias target type
/// @returns the alias type
template <typename NAME>
ast::Alias* Alias(NAME&& name, ast::Type* type) {
auto* out = ty.alias(std::forward<NAME>(name), type);
- AST().AddConstructedType(out);
+ AST().AddTypeDecl(out);
return out;
}
- /// Creates a ast::Struct registering it with the AST().ConstructedTypes().
+ /// Creates a ast::Struct registering it with the AST().TypeDecls().
/// @param source the source information
/// @param name the struct name
/// @param members the struct members
@@ -1635,11 +1635,11 @@
auto sym = Sym(std::forward<NAME>(name));
auto* type = create<ast::Struct>(source, sym, std::move(members),
std::move(decorations));
- AST().AddConstructedType(type);
+ AST().AddTypeDecl(type);
return type;
}
- /// Creates a ast::Struct registering it with the AST().ConstructedTypes().
+ /// Creates a ast::Struct registering it with the AST().TypeDecls().
/// @param name the struct name
/// @param members the struct members
/// @param decorations the optional struct decorations
@@ -1651,7 +1651,7 @@
auto sym = Sym(std::forward<NAME>(name));
auto* type =
create<ast::Struct>(sym, std::move(members), std::move(decorations));
- AST().AddConstructedType(type);
+ AST().AddTypeDecl(type);
return type;
}
diff --git a/src/program_test.cc b/src/program_test.cc
index 9b3e38e..acd6355 100644
--- a/src/program_test.cc
+++ b/src/program_test.cc
@@ -68,11 +68,11 @@
"internal compiler error");
}
-TEST_F(ProgramTest, Assert_NullConstructedType) {
+TEST_F(ProgramTest, Assert_NullTypeDecl) {
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.AST().AddConstructedType(nullptr);
+ b.AST().AddTypeDecl(nullptr);
},
"internal compiler error");
}
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 132f91f..e5a97f0 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -1044,7 +1044,7 @@
// Create and register the result type.
auto* str = create<ast::Struct>(Source{}, return_struct_sym, return_members,
ast::DecorationList{});
- parser_impl_.AddConstructedType(return_struct_sym, str);
+ parser_impl_.AddTypeDecl(return_struct_sym, str);
return_type = builder_.ty.Of(str);
// Add the return-value statement.
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index f262de9..7551a7a5 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -1033,14 +1033,14 @@
if (num_non_writable_members == members.size()) {
read_only_struct_types_.insert(ast_struct->name());
}
- AddConstructedType(sym, ast_struct);
+ AddTypeDecl(sym, ast_struct);
return ty_.Struct(sym, std::move(ast_member_types));
}
-void ParserImpl::AddConstructedType(Symbol name, ast::TypeDecl* decl) {
- auto iter = constructed_types_.insert(name);
+void ParserImpl::AddTypeDecl(Symbol name, ast::TypeDecl* decl) {
+ auto iter = declared_types_.insert(name);
if (iter.second) {
- builder_.AST().AddConstructedType(decl);
+ builder_.AST().AddTypeDecl(decl);
}
}
@@ -1220,7 +1220,7 @@
builder_.ty.alias(sym, ast_underlying_type->Build(builder_));
// Record this new alias as the AST type for this SPIR-V ID.
- AddConstructedType(sym, ast_alias_type);
+ AddTypeDecl(sym, ast_alias_type);
return ty_.Alias(sym, ast_underlying_type);
}
diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h
index d6d2ccf..062cb58 100644
--- a/src/reader/spirv/parser_impl.h
+++ b/src/reader/spirv/parser_impl.h
@@ -190,10 +190,10 @@
const spvtools::opt::analysis::Type* type,
const Type* ast_type);
- /// Adds `type` as a constructed type if it hasn't been added yet.
+ /// Adds `decl` as a declared type if it hasn't been added yet.
/// @param name the type's unique name
/// @param decl the type declaration to add
- void AddConstructedType(Symbol name, ast::TypeDecl* decl);
+ void AddTypeDecl(Symbol name, ast::TypeDecl* decl);
/// @returns the fail stream object
FailStream& fail_stream() { return fail_stream_; }
@@ -760,9 +760,9 @@
std::unordered_map<const spvtools::opt::Instruction*, const Pointer*>
handle_type_;
- // Set of symbols of constructed types that have been added, used to avoid
+ // Set of symbols of declared type that have been added, used to avoid
// adding duplicates.
- std::unordered_set<Symbol> constructed_types_;
+ std::unordered_set<Symbol> declared_types_;
/// Maps the SPIR-V ID of a module-scope builtin variable that should be
/// ignored or type-converted, to its builtin kind.
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index aa52558..a84e15c 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -312,16 +312,16 @@
return last_token_;
}
-void ParserImpl::register_constructed(const std::string& name,
- const ast::TypeDecl* type_decl) {
- registered_constructs_[name] = type_decl;
+void ParserImpl::register_type(const std::string& name,
+ const ast::TypeDecl* type_decl) {
+ registered_types_[name] = type_decl;
}
-const ast::TypeDecl* ParserImpl::get_constructed(const std::string& name) {
- if (registered_constructs_.find(name) == registered_constructs_.end()) {
+const ast::TypeDecl* ParserImpl::get_type(const std::string& name) {
+ if (registered_types_.find(name) == registered_types_.end()) {
return nullptr;
}
- return registered_constructs_[name];
+ return registered_types_[name];
}
bool ParserImpl::Parse() {
@@ -397,7 +397,7 @@
if (!expect("type alias", Token::Type::kSemicolon))
return Failure::kErrored;
- builder_.AST().AddConstructedType(const_cast<ast::Alias*>(ta.value));
+ builder_.AST().AddTypeDecl(const_cast<ast::Alias*>(ta.value));
return true;
}
@@ -409,9 +409,8 @@
if (!expect("struct declaration", Token::Type::kSemicolon))
return Failure::kErrored;
- register_constructed(builder_.Symbols().NameFor(str.value->name()),
- str.value);
- builder_.AST().AddConstructedType(str.value);
+ register_type(builder_.Symbols().NameFor(str.value->name()), str.value);
+ builder_.AST().AddTypeDecl(str.value);
return true;
}
@@ -1032,7 +1031,7 @@
auto* alias = builder_.ty.alias(make_source_range_from(t.source()),
name.value, type.value);
- register_constructed(name.value, alias);
+ register_type(name.value, alias);
return alias;
}
@@ -1082,9 +1081,9 @@
Source source;
if (match(Token::Type::kIdentifier, &source)) {
// TODO(crbug.com/tint/697): Remove
- auto* ty = get_constructed(t.to_str());
+ auto* ty = get_type(t.to_str());
if (ty == nullptr)
- return add_error(t, "unknown constructed type '" + t.to_str() + "'");
+ return add_error(t, "unknown type '" + t.to_str() + "'");
return builder_.create<ast::TypeName>(
source, builder_.Symbols().Register(t.to_str()));
@@ -2242,7 +2241,7 @@
return create<ast::BitcastExpression>(source, type.value, params.value);
}
- if (t.IsIdentifier() && !get_constructed(t.to_str())) {
+ if (t.IsIdentifier() && !get_type(t.to_str())) {
next();
auto* ident = create<ast::IdentifierExpression>(
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index dce6662..8e6fb0c 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -378,17 +378,16 @@
/// @param source the source to associate the error with
/// @param msg the warning message
void deprecated(const Source& source, const std::string& msg);
- /// Registers a constructed type into the parser
+ /// Registers a declared type into the parser
/// TODO(crbug.com/tint/724): Remove
- /// @param name the constructed name
- /// @param type_decl the constructed type declaration
- void register_constructed(const std::string& name,
- const ast::TypeDecl* type_decl);
- /// Retrieves a constructed type
+ /// @param name the type name
+ /// @param type_decl the type declaration
+ void register_type(const std::string& name, const ast::TypeDecl* type_decl);
+ /// Retrieves a declared type
/// TODO(crbug.com/tint/724): Remove
/// @param name The name to lookup
- /// @returns the constructed type for `name` or `nullptr` if not found
- const ast::TypeDecl* get_constructed(const std::string& name);
+ /// @returns the declared type for `name` or `nullptr` if not found
+ const ast::TypeDecl* get_type(const std::string& name);
/// Parses the `translation_unit` grammar element
void translation_unit();
@@ -882,7 +881,7 @@
uint32_t sync_depth_ = 0;
std::vector<Token::Type> sync_tokens_;
int silence_errors_ = 0;
- std::unordered_map<std::string, const ast::TypeDecl*> registered_constructs_;
+ std::unordered_map<std::string, const ast::TypeDecl*> registered_types_;
ProgramBuilder builder_;
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 6fc59bd..5a43c48 100644
--- a/src/reader/wgsl/parser_impl_const_expr_test.cc
+++ b/src/reader/wgsl/parser_impl_const_expr_test.cc
@@ -134,7 +134,7 @@
ASSERT_TRUE(p->has_error());
ASSERT_TRUE(e.errored);
ASSERT_EQ(e.value, nullptr);
- EXPECT_EQ(p->error(), "1:1: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:1: unknown type 'invalid'");
}
TEST_F(ParserImplTest, ConstExpr_Recursion) {
diff --git a/src/reader/wgsl/parser_impl_error_msg_test.cc b/src/reader/wgsl/parser_impl_error_msg_test.cc
index 0de7480..e1e8a97 100644
--- a/src/reader/wgsl/parser_impl_error_msg_test.cc
+++ b/src/reader/wgsl/parser_impl_error_msg_test.cc
@@ -420,7 +420,7 @@
var a : f32 = bar[0];
return;
})",
- "test.wgsl:2:17 error: unknown constructed type 'bar'\n"
+ "test.wgsl:2:17 error: unknown type 'bar'\n"
" var a : f32 = bar[0];\n"
" ^^^\n"
"\n"
@@ -733,7 +733,7 @@
TEST_F(ParserImplErrorTest, GlobalDeclTypeInvalid) {
EXPECT("var x : fish;",
- "test.wgsl:1:9 error: unknown constructed type 'fish'\n"
+ "test.wgsl:1:9 error: unknown type 'fish'\n"
"var x : fish;\n"
" ^^^^\n");
}
diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc
index 193950c..0cef4aa 100644
--- a/src/reader/wgsl/parser_impl_function_header_test.cc
+++ b/src/reader/wgsl/parser_impl_function_header_test.cc
@@ -112,7 +112,7 @@
EXPECT_FALSE(f.matched);
EXPECT_TRUE(f.errored);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:14: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:14: unknown type 'invalid'");
}
TEST_F(ParserImplTest, FunctionHeader_MissingReturnType) {
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 8892df7..bf48641 100644
--- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc
@@ -85,7 +85,7 @@
EXPECT_TRUE(e.errored);
EXPECT_FALSE(e.matched);
EXPECT_EQ(e.value, nullptr);
- EXPECT_EQ(p->error(), "1:9: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:9: unknown type 'invalid'");
}
TEST_F(ParserImplTest, GlobalConstantDecl_InvalidExpression) {
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index d9421db..ef7caff 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -48,7 +48,7 @@
auto p = parser("var<private> a : vec2<invalid>;");
p->expect_global_decl();
ASSERT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:23: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:23: unknown type 'invalid'");
}
TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_MissingSemicolon) {
@@ -90,12 +90,11 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
- ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
- ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<ast::Alias>());
- EXPECT_EQ(
- program.Symbols().NameFor(
- program.AST().ConstructedTypes()[0]->As<ast::Alias>()->symbol()),
- "A");
+ ASSERT_EQ(program.AST().TypeDecls().size(), 1u);
+ ASSERT_TRUE(program.AST().TypeDecls()[0]->Is<ast::Alias>());
+ EXPECT_EQ(program.Symbols().NameFor(
+ program.AST().TypeDecls()[0]->As<ast::Alias>()->symbol()),
+ "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
@@ -108,13 +107,13 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
- ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u);
- ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<ast::Struct>());
- auto* str = program.AST().ConstructedTypes()[0]->As<ast::Struct>();
+ ASSERT_EQ(program.AST().TypeDecls().size(), 2u);
+ ASSERT_TRUE(program.AST().TypeDecls()[0]->Is<ast::Struct>());
+ auto* str = program.AST().TypeDecls()[0]->As<ast::Struct>();
EXPECT_EQ(str->name(), program.Symbols().Get("A"));
- ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<ast::Alias>());
- auto* alias = program.AST().ConstructedTypes()[1]->As<ast::Alias>();
+ ASSERT_TRUE(program.AST().TypeDecls()[1]->Is<ast::Alias>());
+ auto* alias = program.AST().TypeDecls()[1]->As<ast::Alias>();
EXPECT_EQ(alias->symbol(), program.Symbols().Get("B"));
auto* tn = alias->type()->As<ast::TypeName>();
EXPECT_NE(tn, nullptr);
@@ -125,7 +124,7 @@
auto p = parser("type A = invalid;");
p->expect_global_decl();
ASSERT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:10: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:10: unknown type 'invalid'");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) {
@@ -170,9 +169,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
- ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
+ ASSERT_EQ(program.AST().TypeDecls().size(), 1u);
- auto* t = program.AST().ConstructedTypes()[0];
+ auto* t = program.AST().TypeDecls()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::Struct>());
@@ -188,9 +187,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
- ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
+ ASSERT_EQ(program.AST().TypeDecls().size(), 1u);
- auto* t = program.AST().ConstructedTypes()[0];
+ auto* t = program.AST().TypeDecls()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::Struct>());
@@ -215,9 +214,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto program = p->program();
- ASSERT_EQ(program.AST().ConstructedTypes().size(), 1u);
+ ASSERT_EQ(program.AST().TypeDecls().size(), 1u);
- auto* t = program.AST().ConstructedTypes()[0];
+ auto* t = program.AST().TypeDecls()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<ast::Struct>());
diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc
index 2c10397..28241a6 100644
--- a/src/reader/wgsl/parser_impl_primary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc
@@ -300,7 +300,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
ASSERT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:9: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:9: unknown type 'invalid'");
}
TEST_F(ParserImplTest, PrimaryExpression_Bitcast_MissingLeftParen) {
diff --git a/src/reader/wgsl/parser_impl_struct_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decl_test.cc
index d98fb5c..1d5b783 100644
--- a/src/reader/wgsl/parser_impl_struct_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_decl_test.cc
@@ -152,7 +152,7 @@
EXPECT_EQ(s.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:16: unknown constructed type 'B'");
+ EXPECT_EQ(p->error(), "1:16: unknown type 'B'");
}
TEST_F(ParserImplTest, StructDecl_InvalidDecorationDecl) {
diff --git a/src/reader/wgsl/parser_impl_struct_member_test.cc b/src/reader/wgsl/parser_impl_struct_member_test.cc
index eb81ae3..cfa3555 100644
--- a/src/reader/wgsl/parser_impl_struct_member_test.cc
+++ b/src/reader/wgsl/parser_impl_struct_member_test.cc
@@ -202,7 +202,7 @@
ASSERT_TRUE(p->has_error());
ASSERT_TRUE(m.errored);
ASSERT_EQ(m.value, nullptr);
- EXPECT_EQ(p->error(), "1:17: unknown constructed type 'B'");
+ EXPECT_EQ(p->error(), "1:17: unknown type 'B'");
}
TEST_F(ParserImplTest, StructMember_MissingSemicolon) {
diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc
index 632d013..42ee6cd 100644
--- a/src/reader/wgsl/parser_impl_test.cc
+++ b/src/reader/wgsl/parser_impl_test.cc
@@ -54,15 +54,15 @@
TEST_F(ParserImplTest, GetRegisteredType) {
auto p = parser("");
auto* alias = create<ast::Alias>(Sym("my_alias"), ty.i32());
- p->register_constructed("my_alias", alias);
+ p->register_type("my_alias", alias);
- auto* got = p->get_constructed("my_alias");
+ auto* got = p->get_type("my_alias");
EXPECT_EQ(got, alias);
}
TEST_F(ParserImplTest, GetUnregisteredType) {
auto p = parser("");
- auto* alias = p->get_constructed("my_alias");
+ auto* alias = p->get_type("my_alias");
ASSERT_EQ(alias, nullptr);
}
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 b36169a..fce5b3c 100644
--- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
+++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc
@@ -126,7 +126,7 @@
EXPECT_EQ(t.value, nullptr);
EXPECT_FALSE(t.matched);
EXPECT_TRUE(t.errored);
- EXPECT_EQ(p->error(), "1:12: unknown constructed type 'abc'");
+ EXPECT_EQ(p->error(), "1:12: unknown type 'abc'");
}
TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_MissingType) {
@@ -185,7 +185,7 @@
EXPECT_EQ(t.value, nullptr);
EXPECT_FALSE(t.matched);
EXPECT_TRUE(t.errored);
- EXPECT_EQ(p->error(), "1:25: unknown constructed type 'abc'");
+ EXPECT_EQ(p->error(), "1:25: unknown type 'abc'");
}
TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_MissingType) {
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index fb2f2d3..274d8a9 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -38,7 +38,7 @@
auto p = parser("type a = B");
auto* str = p->builder().Structure(p->builder().Symbols().Register("B"), {});
- p->register_constructed("B", str);
+ p->register_type("B", str);
auto t = p->type_alias();
EXPECT_FALSE(p->has_error());
@@ -89,7 +89,7 @@
EXPECT_FALSE(t.matched);
EXPECT_TRUE(p->has_error());
EXPECT_EQ(t.value, nullptr);
- EXPECT_EQ(p->error(), "1:10: unknown constructed type 'B'");
+ EXPECT_EQ(p->error(), "1:10: unknown type 'B'");
}
} // namespace
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index fa44edf..3a2c2fc 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -38,7 +38,7 @@
auto& builder = p->builder();
auto* alias_type = builder.ty.alias("A", builder.ty.i32());
- p->register_constructed("A", alias_type);
+ p->register_type("A", alias_type);
auto t = p->type_decl();
EXPECT_TRUE(t.matched);
@@ -58,7 +58,7 @@
EXPECT_FALSE(t.matched);
ASSERT_EQ(t.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:1: unknown constructed type 'B'");
+ EXPECT_EQ(p->error(), "1:1: unknown type 'B'");
}
TEST_F(ParserImplTest, TypeDecl_Bool) {
@@ -182,7 +182,7 @@
EXPECT_FALSE(t.matched);
ASSERT_EQ(t.value, nullptr);
ASSERT_TRUE(p->has_error());
- ASSERT_EQ(p->error(), "1:6: unknown constructed type 'unknown'");
+ ASSERT_EQ(p->error(), "1:6: unknown type 'unknown'");
}
INSTANTIATE_TEST_SUITE_P(ParserImplTest,
VecBadType,
@@ -365,7 +365,7 @@
EXPECT_FALSE(t.matched);
ASSERT_EQ(t.value, nullptr);
ASSERT_TRUE(p->has_error());
- ASSERT_EQ(p->error(), "1:15: unknown constructed type 'unknown'");
+ ASSERT_EQ(p->error(), "1:15: unknown type 'unknown'");
}
TEST_F(ParserImplTest, TypeDecl_Ptr_BadAccess) {
@@ -599,7 +599,7 @@
EXPECT_FALSE(t.matched);
ASSERT_EQ(t.value, nullptr);
ASSERT_TRUE(p->has_error());
- ASSERT_EQ(p->error(), "1:7: unknown constructed type 'unknown'");
+ ASSERT_EQ(p->error(), "1:7: unknown type 'unknown'");
}
TEST_F(ParserImplTest, TypeDecl_Array_ZeroSize) {
@@ -761,7 +761,7 @@
EXPECT_FALSE(t.matched);
ASSERT_EQ(t.value, nullptr);
ASSERT_TRUE(p->has_error());
- ASSERT_EQ(p->error(), "1:8: unknown constructed type 'unknown'");
+ ASSERT_EQ(p->error(), "1:8: unknown type 'unknown'");
}
INSTANTIATE_TEST_SUITE_P(
ParserImplTest,
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 541df21..af959b4 100644
--- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
@@ -81,7 +81,7 @@
auto decl = p->expect_variable_ident_decl("test");
ASSERT_TRUE(p->has_error());
ASSERT_TRUE(decl.errored);
- ASSERT_EQ(p->error(), "1:10: unknown constructed type 'invalid'");
+ ASSERT_EQ(p->error(), "1:10: unknown type 'invalid'");
}
// TODO(crbug.com/tint/846): Remove
@@ -134,7 +134,7 @@
auto* s = Structure(Sym("S"), members, decos);
- p->register_constructed("S", s);
+ p->register_type("S", s);
auto res = p->expect_global_decl();
ASSERT_FALSE(res.errored) << p->error();
@@ -166,7 +166,7 @@
auto* s = Structure(Sym("S"), members, decos);
- p->register_constructed("S", s);
+ p->register_type("S", s);
auto res = p->expect_global_decl();
ASSERT_FALSE(res.errored) << p->error();
@@ -197,7 +197,7 @@
auto* s = Structure(Sym("S"), members, decos);
- p->register_constructed("S", s);
+ p->register_type("S", s);
auto decl = p->expect_variable_ident_decl("test");
ASSERT_TRUE(p->has_error());
@@ -220,7 +220,7 @@
auto* s = Structure(Sym("S"), members, decos);
- p->register_constructed("S", s);
+ p->register_type("S", s);
auto decl = p->expect_variable_ident_decl("test");
ASSERT_TRUE(p->has_error());
@@ -259,7 +259,7 @@
auto* s = Structure(Sym("S"), members, decos);
- p->register_constructed("S", s);
+ p->register_type("S", s);
auto decl = p->expect_variable_ident_decl("test");
ASSERT_TRUE(p->has_error());
diff --git a/src/reader/wgsl/parser_impl_variable_stmt_test.cc b/src/reader/wgsl/parser_impl_variable_stmt_test.cc
index 624b78f..ee6536c 100644
--- a/src/reader/wgsl/parser_impl_variable_stmt_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_stmt_test.cc
@@ -65,7 +65,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:9: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:9: unknown type 'invalid'");
}
TEST_F(ParserImplTest, VariableStmt_VariableDecl_ConstructorInvalid) {
@@ -160,7 +160,7 @@
EXPECT_TRUE(e.errored);
EXPECT_EQ(e.value, nullptr);
EXPECT_TRUE(p->has_error());
- EXPECT_EQ(p->error(), "1:9: unknown constructed type 'invalid'");
+ EXPECT_EQ(p->error(), "1:9: unknown type 'invalid'");
}
TEST_F(ParserImplTest, VariableStmt_Let_MissingEqual) {
diff --git a/src/resolver/resolver_test_helper.h b/src/resolver/resolver_test_helper.h
index 37692fb..20fc229 100644
--- a/src/resolver/resolver_test_helper.h
+++ b/src/resolver/resolver_test_helper.h
@@ -351,7 +351,7 @@
auto name = b.Symbols().Register("alias_" + std::to_string(ID));
if (!b.AST().LookupType(name)) {
auto* type = DataType<T>::AST(b);
- b.AST().AddConstructedType(b.ty.alias(name, type));
+ b.AST().AddTypeDecl(b.ty.alias(name, type));
}
return b.create<ast::TypeName>(name);
}
diff --git a/src/transform/canonicalize_entry_point_io.cc b/src/transform/canonicalize_entry_point_io.cc
index d0ac744..156c44e9 100644
--- a/src/transform/canonicalize_entry_point_io.cc
+++ b/src/transform/canonicalize_entry_point_io.cc
@@ -75,7 +75,7 @@
// Strip entry point IO decorations from struct declarations.
// TODO(jrprice): This code is duplicated with the SPIR-V transform.
- for (auto* ty : ctx.src->AST().ConstructedTypes()) {
+ for (auto* ty : ctx.src->AST().TypeDecls()) {
if (auto* struct_ty = ty->As<ast::Struct>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc
index 9de497c..b42b303 100644
--- a/src/transform/decompose_storage_access.cc
+++ b/src/transform/decompose_storage_access.cc
@@ -331,8 +331,8 @@
}
}
-/// @returns the unwrapped, user-declared constructed type of ty.
-const ast::TypeDecl* ConstructedTypeOf(const sem::Type* ty) {
+/// @returns the unwrapped, user-declared type of ty.
+const ast::TypeDecl* TypeDeclOf(const sem::Type* ty) {
while (true) {
if (auto* ref = ty->As<sem::Reference>()) {
ty = ref->StoreType();
@@ -341,7 +341,7 @@
if (auto* str = ty->As<sem::Struct>()) {
return str->Declaration();
}
- // Not a constructed type
+ // Not a declared type
return nullptr;
}
}
@@ -762,7 +762,7 @@
auto* offset = access.offset->Build(ctx);
auto* buf_ty = access.var->Type()->UnwrapRef();
auto* el_ty = access.type->UnwrapRef();
- auto* insert_after = ConstructedTypeOf(access.var->Type());
+ auto* insert_after = TypeDeclOf(access.var->Type());
Symbol func = state.LoadFunc(ctx, insert_after, buf_ty, el_ty,
access.var->As<sem::VariableUser>());
@@ -778,7 +778,7 @@
auto* buf_ty = store.target.var->Type()->UnwrapRef();
auto* el_ty = store.target.type->UnwrapRef();
auto* value = store.assignment->rhs();
- auto* insert_after = ConstructedTypeOf(store.target.var->Type());
+ auto* insert_after = TypeDeclOf(store.target.var->Type());
Symbol func = state.StoreFunc(ctx, insert_after, buf_ty, el_ty,
store.target.var->As<sem::VariableUser>());
diff --git a/src/transform/single_entry_point.cc b/src/transform/single_entry_point.cc
index 26f12ec..a926d11 100644
--- a/src/transform/single_entry_point.cc
+++ b/src/transform/single_entry_point.cc
@@ -71,7 +71,7 @@
for (auto* decl : in->AST().GlobalDeclarations()) {
if (auto* ty = decl->As<ast::TypeDecl>()) {
// TODO(jrprice): Strip unused types.
- out.AST().AddConstructedType(ctx.Clone(ty));
+ out.AST().AddTypeDecl(ctx.Clone(ty));
} else if (auto* var = decl->As<ast::Variable>()) {
if (var->is_const() || referenced_vars.count(var)) {
out.AST().AddGlobalVariable(ctx.Clone(var));
diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc
index e16a0f0..616eec6 100644
--- a/src/transform/spirv.cc
+++ b/src/transform/spirv.cc
@@ -127,7 +127,7 @@
// ```
// Strip entry point IO decorations from struct declarations.
- for (auto* ty : ctx.src->AST().ConstructedTypes()) {
+ for (auto* ty : ctx.src->AST().TypeDecls()) {
if (auto* struct_ty = ty->As<ast::Struct>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index db44cb5..29b77ba 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -120,15 +120,15 @@
register_global(global);
}
- for (auto* const ty : builder_.AST().ConstructedTypes()) {
+ for (auto* const ty : builder_.AST().TypeDecls()) {
if (ty->Is<ast::Alias>()) {
continue;
}
- if (!EmitConstructedType(out, TypeOf(ty))) {
+ if (!EmitTypeDecl(out, TypeOf(ty))) {
return false;
}
}
- if (!builder_.AST().ConstructedTypes().empty()) {
+ if (!builder_.AST().TypeDecls().empty()) {
out << std::endl;
}
@@ -204,8 +204,7 @@
return name;
}
-bool GeneratorImpl::EmitConstructedType(std::ostream& out,
- const sem::Type* ty) {
+bool GeneratorImpl::EmitTypeDecl(std::ostream& out, const sem::Type* ty) {
make_indent(out);
if (auto* str = ty->As<sem::Struct>()) {
@@ -214,8 +213,7 @@
return false;
}
} else {
- TINT_UNREACHABLE(diagnostics_)
- << "constructed type: " << ty->TypeInfo().name;
+ TINT_UNREACHABLE(diagnostics_) << "declared type: " << ty->TypeInfo().name;
return false;
}
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index 57de7a3..3c527c7 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -57,11 +57,11 @@
/// @returns true on successful generation; false otherwise
bool Generate(std::ostream& out);
- /// Handles generating a constructed type
+ /// Handles generating a declared type
/// @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 sem::Type* ty);
+ /// @param ty the declared type to generate
+ /// @returns true if the declared type was emitted
+ bool EmitTypeDecl(std::ostream& out, const sem::Type* ty);
/// Handles an array accessor expression
/// @param pre the preamble for the expression stream
/// @param out the output of the expression stream
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 9ebb145..adbcddd 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -87,9 +87,9 @@
global_variables_.set(global->symbol(), sem);
}
- for (auto* const type_decl : program_->AST().ConstructedTypes()) {
+ for (auto* const type_decl : program_->AST().TypeDecls()) {
if (!type_decl->Is<ast::Alias>()) {
- if (!EmitConstructedType(TypeOf(type_decl))) {
+ if (!EmitTypeDecl(TypeOf(type_decl))) {
return false;
}
}
@@ -105,7 +105,7 @@
}
}
- if (!program_->AST().ConstructedTypes().empty() || array_wrappers_.size()) {
+ if (!program_->AST().TypeDecls().empty() || array_wrappers_.size()) {
out_ << std::endl;
}
@@ -160,7 +160,7 @@
return true;
}
-bool GeneratorImpl::EmitConstructedType(const sem::Type* ty) {
+bool GeneratorImpl::EmitTypeDecl(const sem::Type* ty) {
make_indent();
if (auto* str = ty->As<sem::Struct>()) {
@@ -2011,7 +2011,7 @@
out_ << "sampler";
} else if (auto* str = type->As<sem::Struct>()) {
// The struct type emits as just the name. The declaration would be emitted
- // as part of emitting the constructed types.
+ // as part of emitting the declared types.
out_ << program_->Symbols().NameFor(str->Declaration()->name());
} else if (auto* tex = type->As<sem::Texture>()) {
if (tex->Is<sem::DepthTexture>()) {
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index 72e3739..9a417ee 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -61,10 +61,10 @@
/// @returns true on successful generation; false otherwise
bool Generate();
- /// Handles generating a constructed
- /// @param ty the constructed type to generate
- /// @returns true if the constructed type was emitted
- bool EmitConstructedType(const sem::Type* ty);
+ /// Handles generating a declared type
+ /// @param ty the declared type to generate
+ /// @returns true if the declared type was emitted
+ bool EmitTypeDecl(const sem::Type* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index 006b799..8dc1c01 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -67,7 +67,7 @@
// Generate global declarations in the order they appear in the module.
for (auto* decl : program_->AST().GlobalDeclarations()) {
if (auto* td = decl->As<ast::TypeDecl>()) {
- if (!EmitConstructedType(td)) {
+ if (!EmitTypeDecl(td)) {
return false;
}
} else if (auto* func = decl->As<ast::Function>()) {
@@ -91,7 +91,7 @@
return true;
}
-bool GeneratorImpl::EmitConstructedType(const ast::TypeDecl* ty) {
+bool GeneratorImpl::EmitTypeDecl(const ast::TypeDecl* ty) {
make_indent();
if (auto* alias = ty->As<ast::Alias>()) {
@@ -105,7 +105,7 @@
return false;
}
} else {
- diagnostics_.add_error("unknown constructed type: " +
+ diagnostics_.add_error("unknown declared type: " +
std::string(ty->TypeInfo().name));
return false;
}
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index 4d48d76..ad9f535 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -54,10 +54,10 @@
/// @returns true on successful generation; false otherwise
bool Generate();
- /// Handles generating a constructed type
- /// @param ty the constructed to generate
- /// @returns true if the constructed was emitted
- bool EmitConstructedType(const ast::TypeDecl* ty);
+ /// Handles generating a declared type
+ /// @param ty the declared type to generate
+ /// @returns true if the declared type was emitted
+ bool EmitTypeDecl(const ast::TypeDecl* ty);
/// Handles an array accessor expression
/// @param expr the expression to emit
/// @returns true if the array accessor was emitted
diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc
index 43c5270..754849d 100644
--- a/src/writer/wgsl/generator_impl_alias_type_test.cc
+++ b/src/writer/wgsl/generator_impl_alias_type_test.cc
@@ -26,12 +26,12 @@
GeneratorImpl& gen = Build();
- ASSERT_TRUE(gen.EmitConstructedType(alias)) << gen.error();
+ ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(type a = f32;
)");
}
-TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
+TEST_F(WgslGeneratorImplTest, EmitTypeDecl_Struct) {
auto* s = Structure("A", {
Member("a", ty.f32()),
Member("b", ty.i32()),
@@ -41,8 +41,8 @@
GeneratorImpl& gen = Build();
- ASSERT_TRUE(gen.EmitConstructedType(s)) << gen.error();
- ASSERT_TRUE(gen.EmitConstructedType(alias)) << gen.error();
+ ASSERT_TRUE(gen.EmitTypeDecl(s)) << gen.error();
+ ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(struct A {
a : f32;
b : i32;
@@ -61,7 +61,7 @@
GeneratorImpl& gen = Build();
- ASSERT_TRUE(gen.EmitConstructedType(alias)) << gen.error();
+ ASSERT_TRUE(gen.EmitTypeDecl(alias)) << gen.error();
EXPECT_EQ(gen.result(), R"(type B = A;
)");
}