TypeDeclaration *TypeResolver::get_or_create_array_type(TypeDeclaration &type)
{
- auto i = array_types.find(&type);
+ bool extended_alignment = iface_block;
+ auto key = make_pair(&type, extended_alignment);
+ auto i = array_types.find(key);
if(i!=array_types.end())
return i->second;
array->source = INTERNAL_SOURCE;
array->name = type.name+"[]";
array->kind = BasicTypeDeclaration::ARRAY;
+ array->extended_alignment = extended_alignment;
array->base = type.name;
array->base_type = &type;
stage->content.body.insert(type_insert_point, array);
- array_types[&type] = array;
+ array_types[key] = array;
return array;
}
if(type.kind==BasicTypeDeclaration::ALIAS && type.base_type)
alias_map[&type] = type.base_type;
else if(type.kind==BasicTypeDeclaration::ARRAY && type.base_type)
- array_types[type.base_type] = &type;
+ array_types[make_pair(type.base_type, type.extended_alignment)] = &type;
stage->types.insert(make_pair(type.name, &type));
}
void TypeResolver::visit(StructDeclaration &strct)
{
stage->types.insert(make_pair(strct.name, &strct));
+ SetForScope<InterfaceBlock *> set_iface(iface_block, strct.interface_block);
TraversingVisitor::visit(strct);
}
void TypeResolver::visit(VariableDeclaration &var)
{
resolve_type(var.type_declaration, var.type, var.array);
- if(iface_block && var.interface==iface_block->interface)
- var.interface.clear();
+ if(iface_block)
+ {
+ if(var.interface==iface_block->interface)
+ var.interface.clear();
+ if(StructDeclaration *strct = dynamic_cast<StructDeclaration *>(var.type_declaration))
+ strct->extended_alignment = true;
+ }
}
void TypeResolver::visit(InterfaceBlock &iface)
strct->source = INTERNAL_SOURCE;
strct->name = format("_%s_%s", iface.interface, iface.block_name);
strct->members.body.splice(strct->members.body.begin(), iface.members->body);
+ strct->extended_alignment = true;
stage->content.body.insert(type_insert_point, strct);
stage->types.insert(make_pair(strct->name, strct));