aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-24 23:25:36 +0800
committerchriseth <c@ethdev.com>2015-06-25 01:34:43 +0800
commite5ae5955b97009233fc46ac04070073750240698 (patch)
tree9781a740e3dc3f63110dece7127adcbdd3019380 /Types.cpp
parent1add48a652ea695032d8c664fad3ea84afbfb9ea (diff)
downloaddexon-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.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/Types.cpp b/Types.cpp
index ab93839d..01876b5a 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -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());