diff options
Diffstat (limited to 'libsolidity/ast/Types.cpp')
-rw-r--r-- | libsolidity/ast/Types.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index e4b7e4fd..bf5745a6 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -170,6 +170,26 @@ string parenthesizeUserIdentifier(string const& _internal) } +string Type::escapeIdentifier(string const& _identifier) +{ + string ret = _identifier; + boost::algorithm::replace_all(ret, "$", "_$$$_"); + boost::algorithm::replace_all(ret, ",", "_$_"); + boost::algorithm::replace_all(ret, "(", "$_"); + boost::algorithm::replace_all(ret, ")", "_$"); + return ret; +} + +string Type::unescapeIdentifier(string const& _identifier) +{ + string ret = _identifier; + boost::algorithm::replace_all(ret, "_$_", ","); + boost::algorithm::replace_all(ret, "_$$$_", "$"); + boost::algorithm::replace_all(ret, "$_", "("); + boost::algorithm::replace_all(ret, "_$", ")"); + return ret; +} + TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type) { solAssert(Token::isElementaryTypeName(_type.token()), |