-void VariableResolver::visit(InterfaceBlock &iface)
-{
- /* Block names can be reused in different interfaces. Prefix the name with
- the first character of the interface to avoid conflicts. */
- stage->interface_blocks.insert(make_pair(format("%s %s", iface.interface, iface.block_name), &iface));
- if(!iface.instance_name.empty())
- stage->interface_blocks.insert(make_pair(iface.instance_name, &iface));
+ 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(existing);
+ nodes_to_remove.insert(&var);
+ // The block struct will be removed during unused type removal
+ //nodes_to_remove.insert(var.block_declaration);
+ }
+ }
+ else if(!var.block_declaration && !existing->block_declaration && var.type==existing->type)
+ {
+ redeclare_builtin(*existing, var);
+
+ if(block)
+ {
+ /* Cause the block and its members to be marked as not builtin
+ so it will be emitted in output */
+ redeclared_builtins.push_back(block);
+ for(const auto &kvp: block->block_declaration->members.variables)
+ redeclared_builtins.push_back(kvp.second);
+ }