diff options
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -999,6 +999,15 @@ unsigned StructType::getCalldataEncodedSize(bool _padded) const return size; } +u256 StructType::memorySize() const +{ + u256 size; + for (auto const& member: getMembers()) + if (member.type->canLiveOutsideStorage()) + size += member.type->memoryHeadSize(); + return size; +} + u256 StructType::getStorageSize() const { return max<u256>(1, getMembers().getStorageSize()); @@ -1012,6 +1021,17 @@ bool StructType::canLiveOutsideStorage() const return true; } +unsigned StructType::getSizeOnStack() const +{ + switch (location()) + { + case DataLocation::Storage: + return 2; // slot and offset + default: + return 1; + } +} + string StructType::toString(bool _short) const { string ret = "struct " + m_struct.getName(); @@ -1054,6 +1074,18 @@ pair<u256, unsigned> const& StructType::getStorageOffsetsOfMember(string const& return *offsets; } +u256 StructType::memoryOffsetOfMember(string const& _name) const +{ + u256 offset; + for (auto const& member: getMembers()) + if (member.name == _name) + return offset; + else + offset += member.type->memoryHeadSize(); + solAssert(false, "Member not found in struct."); + return 0; +} + TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const { return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer(); |