mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Refined cleanup.
This commit is contained in:
parent
c812d928fd
commit
fc0e571a07
@ -81,24 +81,29 @@ void NameSimplifier::findSimplification(YulString const& _name)
|
|||||||
string name = _name.str();
|
string name = _name.str();
|
||||||
|
|
||||||
static auto replacements = vector<pair<regex, string>>{
|
static auto replacements = vector<pair<regex, string>>{
|
||||||
{regex("_\\$\\d+"), ""}, // removes AST IDs
|
{regex("_\\$|\\$_"), "_"}, // remove type mangling delimiters
|
||||||
|
{regex("_[0-9]+([^0-9a-fA-Fx])"), "$1"}, // removes AST IDs that are not hex.
|
||||||
|
{regex("_[0-9]+$"), ""}, // removes AST IDs that are not hex.
|
||||||
|
{regex("_t_"), "_"}, // remove type prefixes
|
||||||
|
{regex("__"), "_"},
|
||||||
{regex("(abi_..code.*)_to_.*"), "$1"}, // removes _to... for abi functions
|
{regex("(abi_..code.*)_to_.*"), "$1"}, // removes _to... for abi functions
|
||||||
{regex("(stringliteral_[0-9a-f][0-9a-f][0-9a-f][0-9a-f])[0-9a-f]*"), "$1"}, // shorten string literal
|
{regex("(stringliteral_?[0-9a-f][0-9a-f][0-9a-f][0-9a-f])[0-9a-f]*"), "$1"}, // shorten string literal
|
||||||
{regex("tuple_t_"), ""},
|
{regex("tuple_"), ""},
|
||||||
{regex("_memory_ptr"), ""},
|
{regex("_memory_ptr"), ""},
|
||||||
{regex("_calldata_ptr"), "_calldata"},
|
{regex("_calldata_ptr"), "_calldata"},
|
||||||
{regex("_fromStack"), ""},
|
{regex("_fromStack"), ""},
|
||||||
{regex("_storage_storage"), "_storage"},
|
{regex("_storage_storage"), "_storage"},
|
||||||
|
{regex("(storage.*)_?storage"), "$1"},
|
||||||
{regex("_memory_memory"), "_memory"},
|
{regex("_memory_memory"), "_memory"},
|
||||||
{regex("t_contract\\$_([^_]*)_"), "$1_"},
|
{regex("_contract\\$_([^_]*)_?"), "$1_"},
|
||||||
{regex("index_access_t_array"), "index_access"},
|
{regex("index_access_(t_)?array"), "index_access"},
|
||||||
{regex("[0-9]*_$"), ""}
|
{regex("[0-9]*_$"), ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto const& [pattern, substitute]: replacements)
|
for (auto const& [pattern, substitute]: replacements)
|
||||||
{
|
{
|
||||||
string candidate = regex_replace(name, pattern, substitute);
|
string candidate = regex_replace(name, pattern, substitute);
|
||||||
if (!m_context.dispenser.illegalName(YulString(candidate)))
|
if (!candidate.empty() && !m_context.dispenser.illegalName(YulString(candidate)))
|
||||||
name = candidate;
|
name = candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user