diff options
author | chriseth <c@ethdev.com> | 2015-07-16 07:06:19 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-07-16 07:10:09 +0800 |
commit | a2796c3d15593d9744433dbfb35d166c07e3dec6 (patch) | |
tree | e51e8932396b808915468fc09f6889174a8b7e96 /Types.cpp | |
parent | d747f34466ed6b3f3be0ea0c0d5278a7670e4d57 (diff) | |
download | dexon-solidity-a2796c3d15593d9744433dbfb35d166c07e3dec6.tar.gz dexon-solidity-a2796c3d15593d9744433dbfb35d166c07e3dec6.tar.zst dexon-solidity-a2796c3d15593d9744433dbfb35d166c07e3dec6.zip |
Allow structs containing mappings in memory.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -1040,14 +1040,6 @@ u256 StructType::getStorageSize() const return max<u256>(1, getMembers().getStorageSize()); } -bool StructType::canLiveOutsideStorage() const -{ - for (auto const& member: getMembers()) - if (!member.type->canLiveOutsideStorage()) - return false; - return true; -} - string StructType::toString(bool _short) const { string ret = "struct " + m_struct.getName(); @@ -1064,9 +1056,13 @@ MemberList const& StructType::getMembers() const MemberList::MemberMap members; for (ASTPointer<VariableDeclaration> const& variable: m_struct.getMembers()) { + TypePointer type = variable->getType(); + // Skip all mapping members if we are not in storage. + if (location() != DataLocation::Storage && !type->canLiveOutsideStorage()) + continue; members.push_back(MemberList::Member( variable->getName(), - copyForLocationIfReference(variable->getType()), + copyForLocationIfReference(type), variable.get()) ); } @@ -1077,8 +1073,7 @@ MemberList const& StructType::getMembers() const TypePointer StructType::copyForLocation(DataLocation _location, bool _isPointer) const { - auto copy = make_shared<StructType>(m_struct); - copy->m_location = _location; + auto copy = make_shared<StructType>(m_struct, _location); copy->m_isPointer = _isPointer; return copy; } @@ -1122,6 +1117,15 @@ u256 StructType::memoryOffsetOfMember(string const& _name) const return 0; } +set<string> StructType::membersMissingInMemory() const +{ + set<string> missing; + for (ASTPointer<VariableDeclaration> const& variable: m_struct.getMembers()) + if (!variable->getType()->canLiveOutsideStorage()) + missing.insert(variable->getName()); + return missing; +} + TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const { return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer(); |