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>
This commit is contained in:
Ben Clayton
2021-06-09 14:32:14 +00:00
parent 8758f10a20
commit 950809f534
36 changed files with 141 additions and 148 deletions

View File

@@ -37,7 +37,7 @@ Module::Module(ProgramID program_id,
}
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(ProgramID program_id,
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 @@ void Module::AddGlobalVariable(ast::Variable* var) {
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 @@ void Module::Copy(CloneContext* ctx, const Module* src) {
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 @@ void Module::to_str(const sem::Info& sem,
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()

View File

@@ -74,17 +74,15 @@ class Module : public Castable<Module, Node> {
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 @@ class Module : public Castable<Module, Node> {
private:
std::vector<ast::Node*> global_declarations_;
std::vector<ast::TypeDecl*> constructed_types_;
std::vector<ast::TypeDecl*> type_decls_;
FunctionList functions_;
VariableList global_variables_;
};

View File

@@ -55,11 +55,11 @@ TEST_F(ModuleTest, Assert_Null_GlobalVariable) {
"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");
}