for(std::map<string, InterfaceBlock *>::const_iterator i=stage.interface_blocks.begin(); i!=stage.interface_blocks.end(); ++i)
if(seen_interfaces.insert(i->second).second)
{
- string text = format("Interface block: %%%d %s %s", get_label(*i->second), i->second->interface, i->second->name);
+ string text = format("Interface block: %%%d %s %s", get_label(*i->second), i->second->interface, i->second->block_name);
if(!i->second->instance_name.empty())
text += format(" %s", i->second->instance_name);
append(text);
string head;
if(!iface.instance_name.empty())
head += format("%%%d ", get_label(iface));
- head += format("%s %s", iface.interface, iface.name);
+ head += format("%s %s", iface.interface, iface.block_name);
if(!iface.instance_name.empty())
head += format(" %s", iface.instance_name);
if(iface.array)
StructDeclaration *strct = new StructDeclaration;
strct->source = INTERNAL_SOURCE;
- strct->name = format("_%s_%s", iface.interface, iface.name);
+ strct->name = format("_%s_%s", iface.interface, iface.block_name);
strct->members.body.splice(strct->members.body.begin(), iface.members->body);
stage->content.body.insert(type_insert_point, strct);
stage->types.insert(make_pair(strct->name, strct));
{
/* 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(iface.interface+iface.name, &iface));
+ stage->interface_blocks.insert(make_pair(iface.interface+iface.block_name, &iface));
if(!iface.instance_name.empty())
stage->interface_blocks.insert(make_pair("_"+iface.instance_name, &iface));
InterfaceBlock *InterfaceGenerator::generate_interface(InterfaceBlock &out_block)
{
- if(stage->interface_blocks.count("in"+out_block.name))
+ if(stage->interface_blocks.count("in"+out_block.block_name))
return 0;
InterfaceBlock *in_block = new InterfaceBlock;
in_block->interface = "in";
- in_block->name = out_block.name;
+ in_block->block_name = out_block.block_name;
in_block->members = new Block;
in_block->instance_name = out_block.instance_name;
if(stage->type==Stage::GEOMETRY)
}
iface_target_block->body.insert(iface_insert_point, in_block);
- stage->interface_blocks.insert(make_pair("in"+in_block->name, in_block));
+ stage->interface_blocks.insert(make_pair("in"+in_block->block_name, in_block));
if(!in_block->instance_name.empty())
stage->interface_blocks.insert(make_pair("_"+in_block->instance_name, in_block));
if(!iface.linked_block && stage->previous)
{
const map<string, InterfaceBlock *> &prev_blocks = stage->previous->interface_blocks;
- map<string, InterfaceBlock *>::const_iterator i = prev_blocks.find("out"+iface.name);
+ map<string, InterfaceBlock *>::const_iterator i = prev_blocks.find("out"+iface.block_name);
if(i!=prev_blocks.end())
{
iface.linked_block = i->second;
/* Mark variables as output if they're used by the next stage or the
graphics API. */
if(interface_block)
- var_info.output = (interface_block->interface=="out" && (interface_block->linked_block || !interface_block->name.compare(0, 3, "gl_")));
+ var_info.output = (interface_block->interface=="out" && (interface_block->linked_block || !interface_block->block_name.compare(0, 3, "gl_")));
else
var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_")));
else
{
VariableInfo &var_info = variables[&iface];
- var_info.output = (iface.interface=="out" && (iface.linked_block || !iface.name.compare(0, 3, "gl_")));
+ var_info.output = (iface.interface=="out" && (iface.linked_block || !iface.block_name.compare(0, 3, "gl_")));
}
}
void Formatter::visit(InterfaceBlock &iface)
{
- append(format("%s %s\n", iface.interface, iface.name));
+ append(format("%s %s\n", iface.interface, iface.block_name));
if(iface.struct_declaration)
iface.struct_declaration->members.visit(*this);
if(!iface.instance_name.empty())
if(!is_interface_qualifier(iface->interface))
throw parse_error(tokenizer.get_location(), iface->interface, "an interface qualifier");
- iface->name = expect_identifier();
+ iface->block_name = expect_identifier();
iface->members = new Block;
parse_block(*iface->members, true, &Parser::parse_variable_declaration_with_layout);
if(!check(";"))
InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
Statement(other),
interface(other.interface),
- name(other.name),
+ block_name(other.block_name),
members(other.members),
instance_name(other.instance_name),
array(other.array),
struct InterfaceBlock: Statement
{
std::string interface;
- std::string name;
+ std::string block_name;
NodePtr<Block> members;
std::string instance_name;
bool array;
void DeclarationValidator::visit(InterfaceBlock &iface)
{
- string key = iface.interface+iface.name;
+ string key = iface.interface+iface.block_name;
map<string, InterfaceBlock *>::const_iterator i = interface_blocks.find(key);
if(i!=interface_blocks.end())
- multiple_definition(format("interface block '%s %s'", iface.interface, iface.name), iface, *i->second);
+ multiple_definition(format("interface block '%s %s'", iface.interface, iface.block_name), iface, *i->second);
else
interface_blocks.insert(make_pair(key, &iface));
- if(Statement *previous = find_definition(iface.name))
+ if(Statement *previous = find_definition(iface.block_name))
{
if(!dynamic_cast<InterfaceBlock *>(previous))
- multiple_definition(format("'%s'", iface.name), iface, *previous);
+ multiple_definition(format("'%s'", iface.block_name), iface, *previous);
}
else
- record_definition(iface.name, iface);
+ record_definition(iface.block_name, iface);
if(!iface.instance_name.empty())
check_definition(iface.instance_name, iface);
void ReferenceValidator::visit(InterfaceBlock &iface)
{
if(!iface.struct_declaration)
- error(iface, format("Interface block '%s %s' lacks a struct declaration", iface.interface, iface.name));
+ error(iface, format("Interface block '%s %s' lacks a struct declaration", iface.interface, iface.block_name));
TraversingVisitor::visit(iface);
}
{
if(to_remove->count(&iface))
{
- remove_from_map(stage->interface_blocks, iface.interface+iface.name, iface);
+ remove_from_map(stage->interface_blocks, iface.interface+iface.block_name, iface);
if(!iface.instance_name.empty())
remove_from_map(stage->interface_blocks, "_"+iface.instance_name, iface);
}