From 7a62eb7f7550df161656616f2ece5a094b754392 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 18 Mar 2021 11:49:59 +0200 Subject: [PATCH] Rename DeclarationValidator to IdentifierValidator This name more accurately describes what it does. --- source/glsl/compiler.cpp | 2 +- source/glsl/validate.cpp | 20 ++++++++++---------- source/glsl/validate.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/glsl/compiler.cpp b/source/glsl/compiler.cpp index 8a18fdf4..40dfede3 100644 --- a/source/glsl/compiler.cpp +++ b/source/glsl/compiler.cpp @@ -301,7 +301,7 @@ void Compiler::resolve(Stage &stage, unsigned flags) bool Compiler::validate(Stage &stage) { TypeValidator().apply(stage); - DeclarationValidator().apply(stage); + IdentifierValidator().apply(stage); ReferenceValidator().apply(stage); ExpressionValidator().apply(stage); diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 99e2dfe8..e025a61b 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -89,17 +89,17 @@ void TypeValidator::visit(VariableDeclaration &var) } -DeclarationValidator::DeclarationValidator(): +IdentifierValidator::IdentifierValidator(): anonymous_block(false) { } -void DeclarationValidator::multiple_definition(const string &name, Statement &statement, Statement &previous) +void IdentifierValidator::multiple_definition(const string &name, Statement &statement, Statement &previous) { error(statement, format("Multiple definition of %s", name)); add_info(previous, "Previous definition is here"); } -Statement *DeclarationValidator::find_definition(const string &name) +Statement *IdentifierValidator::find_definition(const string &name) { BlockDeclarationMap *decls = &declarations[current_block]; BlockDeclarationMap::const_iterator i = decls->find(name); @@ -111,7 +111,7 @@ Statement *DeclarationValidator::find_definition(const string &name) return (i!=decls->end() ? i->second : 0); } -void DeclarationValidator::check_definition(const string &name, Statement &statement) +void IdentifierValidator::check_definition(const string &name, Statement &statement) { if(Statement *previous = find_definition(name)) multiple_definition(format("'%s'", name), statement, *previous); @@ -119,31 +119,31 @@ void DeclarationValidator::check_definition(const string &name, Statement &state record_definition(name, statement); } -void DeclarationValidator::record_definition(const string &name, Statement &statement) +void IdentifierValidator::record_definition(const string &name, Statement &statement) { declarations[current_block].insert(make_pair(name, &statement)); if(anonymous_block) declarations[current_block->parent].insert(make_pair(name, &statement)); } -void DeclarationValidator::visit(TypeDeclaration &type) +void IdentifierValidator::visit(TypeDeclaration &type) { check_definition(type.name, type); } -void DeclarationValidator::visit(StructDeclaration &strct) +void IdentifierValidator::visit(StructDeclaration &strct) { check_definition(strct.name, strct); TraversingVisitor::visit(strct); } -void DeclarationValidator::visit(VariableDeclaration &var) +void IdentifierValidator::visit(VariableDeclaration &var) { check_definition(var.name, var); TraversingVisitor::visit(var); } -void DeclarationValidator::visit(InterfaceBlock &iface) +void IdentifierValidator::visit(InterfaceBlock &iface) { string key = iface.interface+iface.block_name; map::const_iterator i = interface_blocks.find(key); @@ -172,7 +172,7 @@ void DeclarationValidator::visit(InterfaceBlock &iface) } } -void DeclarationValidator::visit(FunctionDeclaration &func) +void IdentifierValidator::visit(FunctionDeclaration &func) { string key = func.name+func.signature; map::const_iterator i = overloaded_functions.find(key); diff --git a/source/glsl/validate.h b/source/glsl/validate.h index bafa550b..6cd5675a 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -41,7 +41,7 @@ private: virtual void visit(VariableDeclaration &); }; -class DeclarationValidator: private Validator +class IdentifierValidator: private Validator { private: typedef std::map BlockDeclarationMap; @@ -52,7 +52,7 @@ private: bool anonymous_block; public: - DeclarationValidator(); + IdentifierValidator(); void apply(Stage &s) { stage = &s; s.content.visit(*this); } -- 2.45.2