diff options
author | Christian <c@ethdev.com> | 2015-02-23 02:15:41 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-24 01:25:49 +0800 |
commit | 754c804d191ad8f05d886566e599a82efbd38d8e (patch) | |
tree | 3872af65523e734487f9ef2eb605ae0329d0caa2 /Types.cpp | |
parent | 3abbb8d625bd3a904c54dfda7558a77d5543ac70 (diff) | |
download | dexon-solidity-754c804d191ad8f05d886566e599a82efbd38d8e.tar.gz dexon-solidity-754c804d191ad8f05d886566e599a82efbd38d8e.tar.zst dexon-solidity-754c804d191ad8f05d886566e599a82efbd38d8e.zip |
Implementation of index access.
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -555,6 +555,19 @@ bool ArrayType::operator==(Type const& _other) const return other.m_location == m_location; } +u256 ArrayType::getStorageSize() const +{ + if (isDynamicallySized()) + return 1; + else + { + bigint size = bigint(getLength()) * getBaseType()->getStorageSize(); + if (size >= bigint(1) << 256) + BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Array too large for storage.")); + return max<u256>(1, u256(size)); + } +} + unsigned ArrayType::getSizeOnStack() const { if (m_location == Location::CallData) @@ -665,10 +678,12 @@ bool StructType::operator==(Type const& _other) const u256 StructType::getStorageSize() const { - u256 size = 0; + bigint size = 0; for (pair<string, TypePointer> const& member: getMembers()) size += member.second->getStorageSize(); - return max<u256>(1, size); + if (size >= bigint(1) << 256) + BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Struct too large for storage.")); + return max<u256>(1, u256(size)); } bool StructType::canLiveOutsideStorage() const |