}
-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);
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);
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<string, InterfaceBlock *>::const_iterator i = interface_blocks.find(key);
}
}
-void DeclarationValidator::visit(FunctionDeclaration &func)
+void IdentifierValidator::visit(FunctionDeclaration &func)
{
string key = func.name+func.signature;
map<string, FunctionDeclaration *>::const_iterator i = overloaded_functions.find(key);