aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ArrayUtils.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-09-25 23:13:29 +0800
committerchriseth <c@ethdev.com>2015-10-02 19:12:23 +0800
commitda408640ca44b0d0cd8140fe2882bd344b4e24b9 (patch)
tree214b57e1bd300e1df40263d1b0e52283fb342ef9 /libsolidity/ArrayUtils.h
parentcae8db989a28838dc25c262f60b34162e6e3f83d (diff)
downloaddexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar.gz
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar.bz2
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar.lz
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar.xz
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.tar.zst
dexon-solidity-da408640ca44b0d0cd8140fe2882bd344b4e24b9.zip
Store small byte arrays and strings in storage in one slot with their
length.
Diffstat (limited to 'libsolidity/ArrayUtils.h')
-rw-r--r--libsolidity/ArrayUtils.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/libsolidity/ArrayUtils.h b/libsolidity/ArrayUtils.h
index 80ffc008..53d36c14 100644
--- a/libsolidity/ArrayUtils.h
+++ b/libsolidity/ArrayUtils.h
@@ -75,9 +75,14 @@ public:
void convertLengthToSize(ArrayType const& _arrayType, bool _pad = false) const;
/// Retrieves the length (number of elements) of the array ref on the stack. This also
/// works for statically-sized arrays.
+ /// @param _stackDepth number of stack elements between top of stack and top (!) of reference
/// Stack pre: reference (excludes byte offset for dynamic storage arrays)
/// Stack post: reference length
- void retrieveLength(ArrayType const& _arrayType) const;
+ void retrieveLength(ArrayType const& _arrayType, unsigned _stackDepth = 0) const;
+ /// Stores the length of an array of type @a _arrayType in storage. The length itself is stored
+ /// on the stack at position @a _stackDepthLength and the storage reference at @a _stackDepthRef.
+ /// If @a _arrayType is a byte array, takes tight coding into account.
+ void storeLength(ArrayType const& _arrayType, unsigned _stackDepthLength = 0, unsigned _stackDepthRef = 1) const;
/// Performs bounds checking and returns a reference on the stack.
/// Stack pre: reference [length] index
/// Stack post (storage): storage_slot byte_offset