-void VariableResolver::visit(InterfaceBlock &iface)
-{
- string key = format("%s %s", iface.interface, iface.block_name);
- auto i = stage->interface_blocks.find(key);
- if(i!=stage->interface_blocks.end())
- {
- if(i->second->source==BUILTIN_SOURCE && iface.struct_declaration && i->second->struct_declaration)
- {
- const map<string, VariableDeclaration *> &vars = iface.struct_declaration->members.variables;
- const map<string, VariableDeclaration *> &existing_vars = i->second->struct_declaration->members.variables;
-
- bool found_all = true;
- for(const auto &kvp: vars)
- {
- auto j = existing_vars.find(kvp.first);
- if(j!=existing_vars.end() && j->second->type==kvp.second->type && j->second->array==kvp.second->array)
- redeclare_builtin(*j->second, *kvp.second);
- else
- found_all = false;
- }
-
- if(found_all)
- {
- redeclared_builtins.push_back(i->second);
- nodes_to_remove.insert(&iface);
- nodes_to_remove.insert(iface.struct_declaration);
- }
- }
- }
- else
- {
- /* Block names can be reused in different interfaces. Prepend the interface
- to the name to avoid conflicts. */
- stage->interface_blocks.insert(make_pair(key, &iface));
- if(!iface.instance_name.empty())
- stage->interface_blocks.insert(make_pair(iface.instance_name, &iface));
- }
-
- TraversingVisitor::visit(iface);
-}
-