diff options
author | chriseth <c@ethdev.com> | 2015-06-24 23:25:36 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-25 01:34:43 +0800 |
commit | e5ae5955b97009233fc46ac04070073750240698 (patch) | |
tree | 9781a740e3dc3f63110dece7127adcbdd3019380 /Types.cpp | |
parent | 1add48a652ea695032d8c664fad3ea84afbfb9ea (diff) | |
download | dexon-solidity-e5ae5955b97009233fc46ac04070073750240698.tar.gz dexon-solidity-e5ae5955b97009233fc46ac04070073750240698.tar.zst dexon-solidity-e5ae5955b97009233fc46ac04070073750240698.zip |
Initialisation of memory types.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -826,16 +826,16 @@ string ArrayType::toString(bool _short) const TypePointer ArrayType::externalType() const { if (m_arrayKind != ArrayKind::Ordinary) - return this->copyForLocation(DataLocation::CallData, true); + return this->copyForLocation(DataLocation::Memory, true); if (!m_baseType->externalType()) return TypePointer(); if (m_baseType->getCategory() == Category::Array && m_baseType->isDynamicallySized()) return TypePointer(); if (isDynamicallySized()) - return std::make_shared<ArrayType>(DataLocation::CallData, m_baseType->externalType()); + return std::make_shared<ArrayType>(DataLocation::Memory, m_baseType->externalType()); else - return std::make_shared<ArrayType>(DataLocation::CallData, m_baseType->externalType(), m_length); + return std::make_shared<ArrayType>(DataLocation::Memory, m_baseType->externalType(), m_length); } TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer) const @@ -974,6 +974,22 @@ bool StructType::operator==(Type const& _other) const return ReferenceType::operator==(other) && other.m_struct == m_struct; } +unsigned StructType::getCalldataEncodedSize(bool _padded) const +{ + unsigned size = 0; + for (auto const& member: getMembers()) + if (!member.type->canLiveOutsideStorage()) + return 0; + else + { + unsigned memberSize = member.type->getCalldataEncodedSize(_padded); + if (memberSize == 0) + return 0; + size += memberSize; + } + return size; +} + u256 StructType::getStorageSize() const { return max<u256>(1, getMembers().getStorageSize()); |