mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow `memory` suffix for internal elementary type parsing.
This commit is contained in:
committed by
Alex Beregszaszi
parent
95b0589f77
commit
5b1c0506fa
@@ -233,11 +233,22 @@ TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type)
|
||||
|
||||
TypePointer Type::fromElementaryTypeName(string const& _name)
|
||||
{
|
||||
string name = _name;
|
||||
DataLocation location = DataLocation::Storage;
|
||||
if (boost::algorithm::ends_with(name, " memory"))
|
||||
{
|
||||
name = name.substr(0, name.length() - 7);
|
||||
location = DataLocation::Memory;
|
||||
}
|
||||
unsigned short firstNum;
|
||||
unsigned short secondNum;
|
||||
Token::Value token;
|
||||
tie(token, firstNum, secondNum) = Token::fromIdentifierOrKeyword(_name);
|
||||
return fromElementaryTypeName(ElementaryTypeNameToken(token, firstNum, secondNum));
|
||||
tie(token, firstNum, secondNum) = Token::fromIdentifierOrKeyword(name);
|
||||
auto t = fromElementaryTypeName(ElementaryTypeNameToken(token, firstNum, secondNum));
|
||||
if (auto* ref = dynamic_cast<ReferenceType const*>(t.get()))
|
||||
return ref->copyForLocation(location, true);
|
||||
else
|
||||
return t;
|
||||
}
|
||||
|
||||
TypePointer Type::forLiteral(Literal const& _literal)
|
||||
|
||||
@@ -150,6 +150,7 @@ public:
|
||||
/// @name Factory functions
|
||||
/// Factory functions that convert an AST @ref TypeName to a Type.
|
||||
static TypePointer fromElementaryTypeName(ElementaryTypeNameToken const& _type);
|
||||
/// Converts a given elementary type name with optional suffix " memory" to a type pointer.
|
||||
static TypePointer fromElementaryTypeName(std::string const& _name);
|
||||
/// @}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user