mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Changed occurences of isByteArray() to isByteArrayOrString(). The idea
is to, in a future commit, replace such occurences of isByteArrayOrString() which are required to return True only for Bytes type with a new isByteArray() function.
This commit is contained in:
+13
-13
@@ -1206,7 +1206,7 @@ BoolResult StringLiteralType::isImplicitlyConvertibleTo(Type const& _convertTo)
|
||||
);
|
||||
return
|
||||
arrayType->location() != DataLocation::CallData &&
|
||||
arrayType->isByteArray() &&
|
||||
arrayType->isByteArrayOrString() &&
|
||||
!(arrayType->dataStoredIn(DataLocation::Storage) && arrayType->isPointer());
|
||||
}
|
||||
else
|
||||
@@ -1530,7 +1530,7 @@ BoolResult ArrayType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
if (_convertTo.category() != category())
|
||||
return false;
|
||||
auto& convertTo = dynamic_cast<ArrayType const&>(_convertTo);
|
||||
if (convertTo.isByteArray() != isByteArray() || convertTo.isString() != isString())
|
||||
if (convertTo.isByteArrayOrString() != isByteArrayOrString() || convertTo.isString() != isString())
|
||||
return false;
|
||||
// memory/calldata to storage can be converted, but only to a direct storage reference
|
||||
if (convertTo.location() == DataLocation::Storage && location() != DataLocation::Storage && convertTo.isPointer())
|
||||
@@ -1571,11 +1571,11 @@ BoolResult ArrayType::isExplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
return true;
|
||||
// allow conversion bytes <-> string and bytes -> bytesNN
|
||||
if (_convertTo.category() != category())
|
||||
return isByteArray() && !isString() && _convertTo.category() == Type::Category::FixedBytes;
|
||||
return isByteArrayOrString() && !isString() && _convertTo.category() == Type::Category::FixedBytes;
|
||||
auto& convertTo = dynamic_cast<ArrayType const&>(_convertTo);
|
||||
if (convertTo.location() != location())
|
||||
return false;
|
||||
if (!isByteArray() || !convertTo.isByteArray())
|
||||
if (!isByteArrayOrString() || !convertTo.isByteArrayOrString())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -1585,7 +1585,7 @@ string ArrayType::richIdentifier() const
|
||||
string id;
|
||||
if (isString())
|
||||
id = "t_string";
|
||||
else if (isByteArray())
|
||||
else if (isByteArrayOrString())
|
||||
id = "t_bytes";
|
||||
else
|
||||
{
|
||||
@@ -1608,7 +1608,7 @@ bool ArrayType::operator==(Type const& _other) const
|
||||
ArrayType const& other = dynamic_cast<ArrayType const&>(_other);
|
||||
if (
|
||||
!ReferenceType::operator==(other) ||
|
||||
other.isByteArray() != isByteArray() ||
|
||||
other.isByteArrayOrString() != isByteArrayOrString() ||
|
||||
other.isString() != isString() ||
|
||||
other.isDynamicallySized() != isDynamicallySized()
|
||||
)
|
||||
@@ -1751,7 +1751,7 @@ string ArrayType::toString(bool _short) const
|
||||
string ret;
|
||||
if (isString())
|
||||
ret = "string";
|
||||
else if (isByteArray())
|
||||
else if (isByteArrayOrString())
|
||||
ret = "bytes";
|
||||
else
|
||||
{
|
||||
@@ -1770,7 +1770,7 @@ string ArrayType::canonicalName() const
|
||||
string ret;
|
||||
if (isString())
|
||||
ret = "string";
|
||||
else if (isByteArray())
|
||||
else if (isByteArrayOrString())
|
||||
ret = "bytes";
|
||||
else
|
||||
{
|
||||
@@ -1784,7 +1784,7 @@ string ArrayType::canonicalName() const
|
||||
|
||||
string ArrayType::signatureInExternalFunction(bool _structsByName) const
|
||||
{
|
||||
if (isByteArray())
|
||||
if (isByteArrayOrString())
|
||||
return canonicalName();
|
||||
else
|
||||
{
|
||||
@@ -1899,7 +1899,7 @@ u256 ArrayType::memoryDataSize() const
|
||||
{
|
||||
solAssert(!isDynamicallySized(), "");
|
||||
solAssert(m_location == DataLocation::Memory, "");
|
||||
solAssert(!isByteArray(), "");
|
||||
solAssert(!isByteArrayOrString(), "");
|
||||
bigint size = bigint(m_length) * m_baseType->memoryHeadSize();
|
||||
solAssert(size <= numeric_limits<u256>::max(), "Array size does not fit u256.");
|
||||
return u256(size);
|
||||
@@ -2701,7 +2701,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
||||
}
|
||||
else if (auto arrayType = dynamic_cast<ArrayType const*>(returnType))
|
||||
{
|
||||
if (arrayType->isByteArray())
|
||||
if (arrayType->isByteArrayOrString())
|
||||
// Return byte arrays as whole.
|
||||
break;
|
||||
returnType = arrayType->baseType();
|
||||
@@ -2720,7 +2720,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
||||
if (member.type->category() != Category::Mapping)
|
||||
{
|
||||
if (auto arrayType = dynamic_cast<ArrayType const*>(member.type))
|
||||
if (!arrayType->isByteArray())
|
||||
if (!arrayType->isByteArrayOrString())
|
||||
continue;
|
||||
m_returnParameterTypes.push_back(TypeProvider::withLocationIfReference(
|
||||
DataLocation::Memory,
|
||||
@@ -3813,7 +3813,7 @@ MemberList::MemberMap TypeType::nativeMembers(ASTNode const* _currentScope) cons
|
||||
}
|
||||
else if (
|
||||
auto const* arrayType = dynamic_cast<ArrayType const*>(m_actualType);
|
||||
arrayType && arrayType->isByteArray()
|
||||
arrayType && arrayType->isByteArrayOrString()
|
||||
)
|
||||
members.emplace_back("concat", TypeProvider::function(
|
||||
TypePointers{},
|
||||
|
||||
Reference in New Issue
Block a user