NameCollecter can now only collect VariableDeclarations

This is done to help with the optimizer step FunctionSpecializer
This commit is contained in:
hrkrshnn 2020-11-26 18:50:18 +01:00
parent 4080748b1d
commit b42fc2015c
2 changed files with 19 additions and 2 deletions

View File

@ -36,7 +36,8 @@ void NameCollector::operator()(VariableDeclaration const& _varDecl)
void NameCollector::operator ()(FunctionDefinition const& _funDef)
{
m_names.emplace(_funDef.name);
if (m_collectWhat == VariablesAndFunctions)
m_names.emplace(_funDef.name);
for (auto const& arg: _funDef.parameters)
m_names.emplace(arg.name);
for (auto const& ret: _funDef.returnVariables)

View File

@ -35,11 +35,26 @@ namespace solidity::yul
class NameCollector: public ASTWalker
{
public:
explicit NameCollector(Block const& _block)
enum CollectWhat { VariablesAndFunctions, OnlyVariables };
explicit NameCollector(
Block const& _block,
CollectWhat _collectWhat = VariablesAndFunctions
):
m_collectWhat(_collectWhat)
{
(*this)(_block);
}
explicit NameCollector(
FunctionDefinition const& _functionDefinition,
CollectWhat _collectWhat = VariablesAndFunctions
):
m_collectWhat(_collectWhat)
{
(*this)(_functionDefinition);
}
using ASTWalker::operator ();
void operator()(VariableDeclaration const& _varDecl) override;
void operator()(FunctionDefinition const& _funDef) override;
@ -47,6 +62,7 @@ public:
std::set<YulString> names() const { return m_names; }
private:
std::set<YulString> m_names;
CollectWhat m_collectWhat = VariablesAndFunctions;
};
/**