NodeRemover::NodeRemover():
stage(0),
to_remove(0),
- anonymous(false),
recursive_remove(false)
{ }
void NodeRemover::visit(Block &block)
{
- blocks.push_back(&block);
+ SetForScope<Block *> set_block(current_block, &block);
for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); )
{
(*i)->visit(*this);
else
++i;
}
- blocks.pop_back();
}
void NodeRemover::visit(StructDeclaration &strct)
{
if(to_remove->count(&strct))
- blocks.back()->types.erase(strct.name);
+ current_block->types.erase(strct.name);
}
void NodeRemover::visit(VariableDeclaration &var)
{
if(recursive_remove || to_remove->count(&var))
{
- remove_variable(blocks.back()->variables, var);
- if(anonymous && blocks.size()>1)
- remove_variable(blocks[blocks.size()-2]->variables, 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);
stage->locations.erase(var.name);
void NodeRemover::visit(InterfaceBlock &iface)
{
- SetFlag set_anon(anonymous);
SetFlag set_recursive(recursive_remove, recursive_remove || to_remove->count(&iface));
TraversingVisitor::visit(iface);
}