}
-void BlockResolver::visit(Block &block)
+void BlockResolver::enter(Block &block)
{
block.parent = current_block;
- TraversingVisitor::visit(block);
}
void BlockResolver::visit(InterfaceBlock &iface)
return block.parent ? block.parent : &block!=builtins ? builtins : 0;
}
-void VariableResolver::visit(Block &block)
+void VariableResolver::enter(Block &block)
{
- if(current_block!=&block)
- block.variables.clear();
-
- TraversingVisitor::visit(block);
+ block.variables.clear();
}
void VariableResolver::visit(VariableReference &var)
TraversingVisitor::visit(iface);
}
-void VariableResolver::visit(FunctionDeclaration &func)
-{
- SetForScope<Block *> set_block(current_block, &func.body);
- func.body.variables.clear();
- TraversingVisitor::visit(func);
-}
-
-void VariableResolver::visit(Iteration &iter)
-{
- SetForScope<Block *> set_block(current_block, &iter.body);
- iter.body.variables.clear();
- TraversingVisitor::visit(iter);
-}
-
void FunctionResolver::visit(FunctionCall &call)
{
void apply(Stage &s) { s.content.visit(*this); }
private:
- virtual void visit(Block &);
+ virtual void enter(Block &);
virtual void visit(InterfaceBlock &);
};
private:
Block *next_block(Block &);
- virtual void visit(Block &);
+ virtual void enter(Block &);
virtual void visit(VariableReference &);
virtual void visit(MemberAccess &);
virtual void visit(BinaryExpression &);
virtual void visit(StructDeclaration &);
virtual void visit(VariableDeclaration &);
virtual void visit(InterfaceBlock &);
- virtual void visit(FunctionDeclaration &);
- virtual void visit(Iteration &);
};
class FunctionResolver: private TraversingVisitor
void TraversingVisitor::visit(Block &block)
{
+ if(&block!=current_block)
+ enter(block);
SetForScope<Block *> set_block(current_block, &block);
for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
(*i)->visit(*this);
void TraversingVisitor::visit(FunctionDeclaration &func)
{
+ enter(func.body);
+ SetForScope<Block *> set_block(current_block, &func.body);
for(NodeArray<VariableDeclaration>::iterator i=func.parameters.begin(); i!=func.parameters.end(); ++i)
(*i)->visit(*this);
func.body.visit(*this);
void TraversingVisitor::visit(Iteration &iter)
{
+ enter(iter.body);
+ SetForScope<Block *> set_block(current_block, &iter.body);
if(iter.init_statement)
iter.init_statement->visit(*this);
if(iter.condition)
TraversingVisitor(): current_block(0) { }
public:
+ virtual void enter(Block &) { }
virtual void visit(Block &);
virtual void visit(ParenthesizedExpression &);
virtual void visit(MemberAccess &);