mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
NameDispenser: Added three public functions.
The private function `illegalName` was converted into a public function. A new public getter function `usedNames()` returns a reference to `m_usedNames`. A public function reset that would change all `m_usedNames` to *only* the names that are used in the AST. Also resets the counter. This will be used before the final NameSimplifier step in the optimization phase. The first two functions were added so that `NameSimplifier` could use it instead of traversing the AST using `NameCollector` to find used names.
This commit is contained in:
@@ -35,8 +35,9 @@ using namespace solidity::yul;
|
||||
using namespace solidity::util;
|
||||
|
||||
NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast, set<YulString> _reservedNames):
|
||||
NameDispenser(_dialect, NameCollector(_ast).names() + std::move(_reservedNames))
|
||||
NameDispenser(_dialect, NameCollector(_ast).names() + _reservedNames)
|
||||
{
|
||||
m_reservedNames = move(_reservedNames);
|
||||
}
|
||||
|
||||
NameDispenser::NameDispenser(Dialect const& _dialect, set<YulString> _usedNames):
|
||||
@@ -61,3 +62,9 @@ bool NameDispenser::illegalName(YulString _name)
|
||||
{
|
||||
return isRestrictedIdentifier(m_dialect, _name) || m_usedNames.count(_name);
|
||||
}
|
||||
|
||||
void NameDispenser::reset(Block const& _ast)
|
||||
{
|
||||
m_usedNames = NameCollector(_ast).names() + m_reservedNames;
|
||||
m_counter = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user