diff options
author | chriseth <c@ethdev.com> | 2015-06-27 01:14:26 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-27 03:28:02 +0800 |
commit | 03edf74e62f8dde537c8d3f956c6cc0a5e823e6b (patch) | |
tree | 49045f17093e1d836c34bb3196148658421a9ee8 /Types.cpp | |
parent | ca497f5d10b49e5faa348a9285d8d87784072477 (diff) | |
download | dexon-solidity-03edf74e62f8dde537c8d3f956c6cc0a5e823e6b.tar.gz dexon-solidity-03edf74e62f8dde537c8d3f956c6cc0a5e823e6b.tar.zst dexon-solidity-03edf74e62f8dde537c8d3f956c6cc0a5e823e6b.zip |
No delete on storage pointers.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -671,6 +671,23 @@ TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer(); } +TypePointer ReferenceType::unaryOperatorResult(Token::Value _operator) const +{ + if (_operator != Token::Delete) + return TypePointer(); + // delete can be used on everything except calldata references or storage pointers + // (storage references are ok) + switch (location()) + { + case DataLocation::CallData: + return TypePointer(); + case DataLocation::Memory: + return make_shared<VoidType>(); + case DataLocation::Storage: + return m_isPointer ? TypePointer() : make_shared<VoidType>(); + } +} + TypePointer ReferenceType::copyForLocationIfReference(DataLocation _location, TypePointer const& _type) { if (auto type = dynamic_cast<ReferenceType const*>(_type.get())) @@ -738,13 +755,6 @@ bool ArrayType::isImplicitlyConvertibleTo(const Type& _convertTo) const } } -TypePointer ArrayType::unaryOperatorResult(Token::Value _operator) const -{ - if (_operator == Token::Delete) - return make_shared<VoidType>(); - return TypePointer(); -} - bool ArrayType::operator==(Type const& _other) const { if (_other.getCategory() != getCategory()) @@ -962,11 +972,6 @@ bool StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const return this->m_struct == convertTo.m_struct; } -TypePointer StructType::unaryOperatorResult(Token::Value _operator) const -{ - return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer(); -} - bool StructType::operator==(Type const& _other) const { if (_other.getCategory() != getCategory()) |