aboutsummaryrefslogtreecommitdiffstats
path: root/Types.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-03-06 01:22:17 +0800
committerchriseth <c@ethdev.com>2015-03-06 20:17:52 +0800
commitd8b156ecbbb4d470ba3432975694585dd5a019e2 (patch)
treea5ffc773101dcba3b274acc5329c20f6a73aed6b /Types.h
parent34e8de749aeecbca5f5dae817aa67f42907e9bf7 (diff)
downloaddexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.tar.gz
dexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.tar.zst
dexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.zip
Copying between calldata and storage.
Diffstat (limited to 'Types.h')
-rw-r--r--Types.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/Types.h b/Types.h
index afecf3c8..0915e0da 100644
--- a/Types.h
+++ b/Types.h
@@ -120,8 +120,10 @@ public:
/// @returns number of bytes used by this type when encoded for CALL, or 0 if the encoding
/// is not a simple big-endian encoding or the type cannot be stored in calldata.
- /// Note that irrespective of this size, each calldata element is padded to a multiple of 32 bytes.
- virtual unsigned getCalldataEncodedSize() const { return 0; }
+ /// If @a _padded then it is assumed that each element is padded to a multiple of 32 bytes.
+ virtual unsigned getCalldataEncodedSize(bool _padded) const { (void)_padded; return 0; }
+ /// Convenience eversion of @see getCalldataEncodedSize(bool)
+ unsigned getCalldataEncodedSize() const { return getCalldataEncodedSize(true); }
/// @returns true if the type is dynamically encoded in calldata
virtual bool isDynamicallySized() const { return false; }
/// @returns number of bytes required to hold this value in storage.
@@ -176,7 +178,7 @@ public:
virtual bool operator==(Type const& _other) const override;
- virtual unsigned getCalldataEncodedSize() const override { return m_bits / 8; }
+ virtual unsigned getCalldataEncodedSize(bool _padded = true) const override { return _padded ? 32 : m_bits / 8; }
virtual bool isValueType() const override { return true; }
virtual MemberList const& getMembers() const { return isAddress() ? AddressMemberList : EmptyMemberList; }
@@ -247,7 +249,7 @@ public:
virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override;
virtual bool operator==(Type const& _other) const override;
- virtual unsigned getCalldataEncodedSize() const override { return m_bytes; }
+ virtual unsigned getCalldataEncodedSize(bool _padded) const override { return _padded && m_bytes > 0 ? 32 : m_bytes; }
virtual bool isValueType() const override { return true; }
virtual std::string toString() const override { return "string" + dev::toString(m_bytes); }
@@ -271,7 +273,7 @@ public:
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual TypePointer binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const override;
- virtual unsigned getCalldataEncodedSize() const { return 1; }
+ virtual unsigned getCalldataEncodedSize(bool _padded) const { return _padded ? 32 : 1; }
virtual bool isValueType() const override { return true; }
virtual std::string toString() const override { return "bool"; }
@@ -302,7 +304,7 @@ public:
virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override;
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual bool operator==(const Type& _other) const override;
- virtual unsigned getCalldataEncodedSize() const override;
+ virtual unsigned getCalldataEncodedSize(bool _padded) const override;
virtual bool isDynamicallySized() const { return m_hasDynamicLength; }
virtual u256 getStorageSize() const override;
virtual unsigned getSizeOnStack() const override;