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,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)
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user