diff --git a/libsolidity/Token.h b/libsolidity/Token.h index ac8c618fa..5167c1a77 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -176,8 +176,7 @@ namespace solidity K(SubFinney, "finney", 0) \ K(SubEther, "ether", 0) \ /* type keywords, keep them in this order, keep int as first keyword - * the implementation in Types.cpp has to be synced to this here - * TODO more to be added */ \ + * the implementation in Types.cpp has to be synced to this here */\ K(Int, "int", 0) \ K(Int8, "int8", 0) \ K(Int16, "int16", 0) \ @@ -279,7 +278,8 @@ namespace solidity K(Hash256, "hash256", 0) \ K(Address, "address", 0) \ K(Bool, "bool", 0) \ - K(StringType, "string", 0) \ + K(Bytes, "bytes", 0) \ + K(StringType, "string", 0) \ K(String0, "string0", 0) \ K(String1, "string1", 0) \ K(String2, "string2", 0) \ diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 5f573a6da..069493e62 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -57,6 +57,8 @@ shared_ptr Type::fromElementaryTypeName(Token::Value _typeToken) return make_shared(); else if (Token::String0 <= _typeToken && _typeToken <= Token::String32) return make_shared(int(_typeToken) - int(Token::String0)); + else if (_typeToken == Token::Bytes) + return make_shared(ByteArrayType::Location::Storage, 0, 0, true); else BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unable to convert elementary typename " + std::string(Token::toString(_typeToken)) + " to type.")); @@ -506,6 +508,15 @@ TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const return _operator == Token::Delete ? make_shared() : TypePointer(); } +bool ByteArrayType::operator==(Type const& _other) const +{ + if (_other.getCategory() != getCategory()) + return false; + ByteArrayType const& other = dynamic_cast(_other); + return other.m_location == m_location && other.m_dynamicLength == m_dynamicLength + && other.m_length == m_length && other.m_offset == m_offset; +} + bool ContractType::operator==(Type const& _other) const { if (_other.getCategory() != getCategory()) diff --git a/libsolidity/Types.h b/libsolidity/Types.h index 05090c7a2..927ca2902 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -76,9 +76,10 @@ class Type: private boost::noncopyable, public std::enable_shared_from_this