From 79c415b104a69c24ae2e5e5a99c496856e7be504 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 7 Dec 2017 15:43:09 +0100 Subject: Use hoisting. --- libjulia/optimiser/NameCollector.cpp | 1 - libjulia/optimiser/NameCollector.h | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'libjulia') diff --git a/libjulia/optimiser/NameCollector.cpp b/libjulia/optimiser/NameCollector.cpp index 510ee289..c0d0b707 100644 --- a/libjulia/optimiser/NameCollector.cpp +++ b/libjulia/optimiser/NameCollector.cpp @@ -35,7 +35,6 @@ void NameCollector::operator()(VariableDeclaration const& _varDecl) void NameCollector::operator ()(FunctionDefinition const& _funDef) { m_names.insert(_funDef.name); - m_functions[_funDef.name] = &_funDef; for (auto const arg: _funDef.parameters) m_names.insert(arg.name); for (auto const ret: _funDef.returnVariables) diff --git a/libjulia/optimiser/NameCollector.h b/libjulia/optimiser/NameCollector.h index 2d4a1d4b..29856172 100644 --- a/libjulia/optimiser/NameCollector.h +++ b/libjulia/optimiser/NameCollector.h @@ -37,15 +37,18 @@ namespace julia class NameCollector: public ASTWalker { public: + explicit NameCollector(Block const& _block) + { + (*this)(_block); + } + using ASTWalker::operator (); virtual void operator()(VariableDeclaration const& _varDecl) override; virtual void operator()(FunctionDefinition const& _funDef) override; - std::set const& names() const { return m_names; } - std::map const& functions() const { return m_functions; } + std::set names() const { return m_names; } private: std::set m_names; - std::map m_functions; }; /** -- cgit