mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Anything outside storage is always a pointer.
This commit is contained in:
committed by
chriseth
parent
148b87c977
commit
fe659ceb41
@@ -1487,11 +1487,19 @@ TypeResult ReferenceType::unaryOperatorResult(Token _operator) const
|
||||
case DataLocation::Memory:
|
||||
return TypeProvider::emptyTuple();
|
||||
case DataLocation::Storage:
|
||||
return m_isPointer ? nullptr : TypeProvider::emptyTuple();
|
||||
return isPointer() ? nullptr : TypeProvider::emptyTuple();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ReferenceType::isPointer() const
|
||||
{
|
||||
if (m_location == DataLocation::Storage)
|
||||
return m_isPointer;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
TypePointer ReferenceType::copyForLocationIfReference(Type const* _type) const
|
||||
{
|
||||
return TypeProvider::withLocationIfReference(m_location, _type);
|
||||
@@ -1502,7 +1510,7 @@ string ReferenceType::stringForReferencePart() const
|
||||
switch (m_location)
|
||||
{
|
||||
case DataLocation::Storage:
|
||||
return string("storage ") + (m_isPointer ? "pointer" : "ref");
|
||||
return string("storage ") + (isPointer() ? "pointer" : "ref");
|
||||
case DataLocation::CallData:
|
||||
return "calldata";
|
||||
case DataLocation::Memory:
|
||||
@@ -1868,7 +1876,8 @@ u256 ArrayType::memoryDataSize() const
|
||||
std::unique_ptr<ReferenceType> ArrayType::copyForLocation(DataLocation _location, bool _isPointer) const
|
||||
{
|
||||
auto copy = make_unique<ArrayType>(_location);
|
||||
copy->m_isPointer = _isPointer;
|
||||
if (_location == DataLocation::Storage)
|
||||
copy->m_isPointer = _isPointer;
|
||||
copy->m_arrayKind = m_arrayKind;
|
||||
copy->m_baseType = copy->copyForLocationIfReference(m_baseType);
|
||||
copy->m_hasDynamicLength = m_hasDynamicLength;
|
||||
@@ -2247,7 +2256,8 @@ TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
std::unique_ptr<ReferenceType> StructType::copyForLocation(DataLocation _location, bool _isPointer) const
|
||||
{
|
||||
auto copy = make_unique<StructType>(m_struct, _location);
|
||||
copy->m_isPointer = _isPointer;
|
||||
if (_location == DataLocation::Storage)
|
||||
copy->m_isPointer = _isPointer;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
@@ -701,7 +701,9 @@ public:
|
||||
/// pointer type, state variables are bound references. Assignments to pointers or deleting
|
||||
/// them will not modify storage (that will only change the pointer). Assignment from
|
||||
/// non-storage objects to a variable of storage pointer type is not possible.
|
||||
bool isPointer() const { return m_isPointer; }
|
||||
/// For anything other than storage, this always returns true because assignments
|
||||
/// never change the contents of the original value.
|
||||
bool isPointer() const;
|
||||
|
||||
bool operator==(ReferenceType const& _other) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user