diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-24 08:13:34 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-27 02:09:43 +0800 |
commit | b471983e3cacf4d92ecd987eac85620bd8030aff (patch) | |
tree | 4037c1c11edab178304e5c6202a741c01cb2781e | |
parent | 2e7067fbe421872e0e7d0a4a4373199e56a9b7d0 (diff) | |
download | dexon-solidity-b471983e3cacf4d92ecd987eac85620bd8030aff.tar.gz dexon-solidity-b471983e3cacf4d92ecd987eac85620bd8030aff.tar.zst dexon-solidity-b471983e3cacf4d92ecd987eac85620bd8030aff.zip |
Use new escaping helpers for type identifiers
-rw-r--r-- | libsolidity/ast/Types.cpp | 27 | ||||
-rw-r--r-- | libsolidity/ast/Types.h | 2 |
2 files changed, 9 insertions, 20 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 97e7a922..fadaf621 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -131,28 +131,28 @@ namespace string parenthesizeIdentifier(string const& _internal) { - return "$_" + _internal + "_$"; + return "(" + _internal + ")"; } template <class Range> string identifierList(Range const&& _list) { - return parenthesizeIdentifier(boost::algorithm::join(_list, "_$_")); + return parenthesizeIdentifier(boost::algorithm::join(_list, ",")); } -string identifier(TypePointer const& _type) +string richIdentifier(TypePointer const& _type) { - return _type ? _type->identifier() : ""; + return _type ? _type->richIdentifier() : ""; } string identifierList(vector<TypePointer> const& _list) { - return identifierList(_list | boost::adaptors::transformed(identifier)); + return identifierList(_list | boost::adaptors::transformed(richIdentifier)); } string identifierList(TypePointer const& _type) { - return parenthesizeIdentifier(identifier(_type)); + return parenthesizeIdentifier(richIdentifier(_type)); } string identifierList(TypePointer const& _type1, TypePointer const& _type2) @@ -165,7 +165,7 @@ string identifierList(TypePointer const& _type1, TypePointer const& _type2) string parenthesizeUserIdentifier(string const& _internal) { - return parenthesizeIdentifier(boost::algorithm::replace_all_copy(_internal, "$", "$$$")); + return parenthesizeIdentifier(_internal); } } @@ -173,23 +173,14 @@ string parenthesizeUserIdentifier(string const& _internal) string Type::escapeIdentifier(string const& _identifier) { string ret = _identifier; - boost::algorithm::replace_all(ret, "$", "_$$$_"); + // FIXME: should be _$$$_ + 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()), diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index a12b7063..7985521e 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -176,8 +176,6 @@ public: /// appears as part of a user-supplied identifier is escaped as _$$$_. /// @returns an escaped identifier (will not contain any parenthesis or commas) static std::string escapeIdentifier(std::string const& _identifier); - /// @returns an unescaped identifier - static std::string unescapeIdentifier(std::string const& _identifier); virtual bool isImplicitlyConvertibleTo(Type const& _other) const { return *this == _other; } virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const |