TraversingVisitor::visit(block);
}
-void DeclarationCombiner::visit(FunctionDeclaration &func)
-{
- vector<FunctionDeclaration *> &decls = functions[func.name];
- if(func.definition)
- {
- for(vector<FunctionDeclaration *>::iterator i=decls.begin(); i!=decls.end(); ++i)
- {
- (*i)->definition = func.definition;
- (*i)->body.body.clear();
- }
- }
- decls.push_back(&func);
-}
-
void DeclarationCombiner::visit(VariableDeclaration &var)
{
VariableDeclaration *&ptr = variables[var.name];
void FunctionResolver::visit(FunctionDeclaration &func)
{
vector<FunctionDeclaration *> &decls = functions[func.name];
- if(func.definition)
+ if(func.definition==&func)
{
for(vector<FunctionDeclaration *>::iterator i=decls.begin(); i!=decls.end(); ++i)
+ {
(*i)->definition = func.definition;
- decls.clear();
- decls.push_back(&func);
+ (*i)->body.body.clear();
+ }
}
else if(!decls.empty() && decls.back()->definition)
func.definition = decls.back()->definition;
- else
- decls.push_back(&func);
+ decls.push_back(&func);
TraversingVisitor::visit(func);
}
private:
virtual void visit(Block &);
- virtual void visit(FunctionDeclaration &);
virtual void visit(VariableDeclaration &);
+ virtual void visit(FunctionDeclaration &) { }
};
/** Manipulates specialization constants. If values are specified, turns