mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
NameCollecter can now only collect VariableDeclarations
This is done to help with the optimizer step FunctionSpecializer
This commit is contained in:
parent
4080748b1d
commit
b42fc2015c
@ -36,6 +36,7 @@ void NameCollector::operator()(VariableDeclaration const& _varDecl)
|
|||||||
|
|
||||||
void NameCollector::operator ()(FunctionDefinition const& _funDef)
|
void NameCollector::operator ()(FunctionDefinition const& _funDef)
|
||||||
{
|
{
|
||||||
|
if (m_collectWhat == VariablesAndFunctions)
|
||||||
m_names.emplace(_funDef.name);
|
m_names.emplace(_funDef.name);
|
||||||
for (auto const& arg: _funDef.parameters)
|
for (auto const& arg: _funDef.parameters)
|
||||||
m_names.emplace(arg.name);
|
m_names.emplace(arg.name);
|
||||||
|
@ -35,11 +35,26 @@ namespace solidity::yul
|
|||||||
class NameCollector: public ASTWalker
|
class NameCollector: public ASTWalker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit NameCollector(Block const& _block)
|
enum CollectWhat { VariablesAndFunctions, OnlyVariables };
|
||||||
|
|
||||||
|
explicit NameCollector(
|
||||||
|
Block const& _block,
|
||||||
|
CollectWhat _collectWhat = VariablesAndFunctions
|
||||||
|
):
|
||||||
|
m_collectWhat(_collectWhat)
|
||||||
{
|
{
|
||||||
(*this)(_block);
|
(*this)(_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit NameCollector(
|
||||||
|
FunctionDefinition const& _functionDefinition,
|
||||||
|
CollectWhat _collectWhat = VariablesAndFunctions
|
||||||
|
):
|
||||||
|
m_collectWhat(_collectWhat)
|
||||||
|
{
|
||||||
|
(*this)(_functionDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
using ASTWalker::operator ();
|
using ASTWalker::operator ();
|
||||||
void operator()(VariableDeclaration const& _varDecl) override;
|
void operator()(VariableDeclaration const& _varDecl) override;
|
||||||
void operator()(FunctionDefinition const& _funDef) override;
|
void operator()(FunctionDefinition const& _funDef) override;
|
||||||
@ -47,6 +62,7 @@ public:
|
|||||||
std::set<YulString> names() const { return m_names; }
|
std::set<YulString> names() const { return m_names; }
|
||||||
private:
|
private:
|
||||||
std::set<YulString> m_names;
|
std::set<YulString> m_names;
|
||||||
|
CollectWhat m_collectWhat = VariablesAndFunctions;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user