X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvisitor.cpp;h=fd25bf342a7ea588525be88079166453474c4e8e;hb=7f29c6d2a4eee36538d7ccf24980e749592e2444;hp=c27de11892607ec627e1a6bf7022e2aa267e0023;hpb=f08bd843fbe63a0bf5bcbc21308f2751d08f00c1;p=libs%2Fgl.git diff --git a/source/glsl/visitor.cpp b/source/glsl/visitor.cpp index c27de118..fd25bf34 100644 --- a/source/glsl/visitor.cpp +++ b/source/glsl/visitor.cpp @@ -134,10 +134,11 @@ void NodeRemover::apply(Stage &s, const set &tr) s.content.visit(*this); } -void NodeRemover::remove_variable(map &vars, VariableDeclaration &decl) +template +void NodeRemover::remove_from_map(map &vars, const string &key, T &node) { - map::iterator i = vars.find(decl.name); - if(i!=vars.end() && i->second==&decl) + typename map::iterator i = vars.find(key); + if(i!=vars.end() && i->second==&node) vars.erase(i); } @@ -157,14 +158,14 @@ void NodeRemover::visit(Block &block) void NodeRemover::visit(StructDeclaration &strct) { if(to_remove->count(&strct)) - current_block->types.erase(strct.name); + remove_from_map(stage->types, strct.name, strct); } void NodeRemover::visit(VariableDeclaration &var) { if(recursive_remove || to_remove->count(&var)) { - remove_variable(current_block->variables, var); + remove_from_map(current_block->variables, var.name, var); stage->locations.erase(var.name); if(var.linked_declaration) var.linked_declaration->linked_declaration = 0; @@ -176,7 +177,11 @@ void NodeRemover::visit(VariableDeclaration &var) void NodeRemover::visit(InterfaceBlock &iface) { if(to_remove->count(&iface)) - current_block->interfaces.erase(&iface); + { + remove_from_map(stage->interface_blocks, iface.name, iface); + if(!iface.instance_name.empty()) + remove_from_map(stage->interface_blocks, iface.instance_name, iface); + } SetFlag set_recursive(recursive_remove, recursive_remove || to_remove->count(&iface)); TraversingVisitor::visit(iface); }