- const map<string, InterfaceBlock *> &blocks = stage->interface_blocks;
- map<string, InterfaceBlock *>::const_iterator i = blocks.find("_"+var.name);
- if(i!=blocks.end())
- {
- /* The name refers to an interface block with an instance name rather
- than a variable. Prepare a new syntax tree node accordingly. */
- InterfaceBlockReference *iface_ref = new InterfaceBlockReference;
- iface_ref->source = var.source;
- iface_ref->line = var.line;
- iface_ref->name = var.name;
- iface_ref->declaration = i->second;
- r_replacement_expr = iface_ref;
- }
- else
- {
- // Look for the variable in anonymous interface blocks.
- for(i=blocks.begin(); (!declaration && i!=blocks.end()); ++i)
- if(i->second->instance_name.empty() && i->second->struct_declaration)
- {
- const map<string, VariableDeclaration *> &iface_vars = i->second->struct_declaration->members.variables;
- map<string, VariableDeclaration *>::const_iterator j = iface_vars.find(var.name);
- if(j!=iface_vars.end())
- declaration = j->second;
- }
- }
+ for(const auto &kvp: stage->interface_blocks)
+ if(kvp.second->name.find(' ')!=string::npos && kvp.second->block_declaration->members.variables.count(var.name))
+ {
+ /* The name refers a member of an anonymous interface block. Prepare
+ new syntax tree nodes accordingly. */
+ VariableReference *iface_ref = new VariableReference;
+ iface_ref->name = kvp.first;
+ iface_ref->source = var.source;
+ iface_ref->line = var.line;
+ iface_ref->declaration = kvp.second;
+
+ MemberAccess *memacc = new MemberAccess;
+ memacc->source = var.source;
+ memacc->line = var.line;
+ memacc->left = iface_ref;
+ memacc->member = var.name;
+
+ r_replacement_expr = memacc;
+ break;
+ }