X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvisitor.cpp;h=d8b1813959f17e4535ea1ea8c60001c22a36d76f;hb=3f899b1fc2e04f4fe74c99ad3e8ebb900c257214;hp=0577b5ab213f5e67296f87e0285323cc0e361433;hpb=33dcf183c6394b403b340095f0cf6ac58bd8090d;p=libs%2Fgl.git diff --git a/source/glsl/visitor.cpp b/source/glsl/visitor.cpp index 0577b5ab..d8b18139 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,18 +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); - if(current_block->anonymous && current_block->parent) - remove_variable(current_block->parent->variables, var); - remove_variable(stage->in_variables, var); - remove_variable(stage->out_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; @@ -179,10 +176,23 @@ void NodeRemover::visit(VariableDeclaration &var) void NodeRemover::visit(InterfaceBlock &iface) { + if(to_remove->count(&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); } +void NodeRemover::visit(FunctionDeclaration &func) +{ + if(to_remove->count(&func)) + remove_from_map(stage->functions, func.name+func.signature, func); + TraversingVisitor::visit(func); +} + void NodeRemover::visit(Iteration &iter) { if(to_remove->count(iter.init_statement.get()))