diff options
author | Christian <c@ethdev.com> | 2015-02-12 18:40:14 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-02-12 18:50:47 +0800 |
commit | 5673f994fc5b035f7583bcc857ac93ecf86b4f65 (patch) | |
tree | eefc033a028f82988c69308367a7217168414a2b | |
parent | 9b8cf4af1db58f3b38ca3172faf53dc5deab84ce (diff) | |
download | dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar.gz dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar.bz2 dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar.lz dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar.xz dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.tar.zst dexon-solidity-5673f994fc5b035f7583bcc857ac93ecf86b4f65.zip |
Added some comments.
-rw-r--r-- | CompilerUtils.h | 17 | ||||
-rw-r--r-- | ExpressionCompiler.cpp | 4 |
2 files changed, 13 insertions, 8 deletions
diff --git a/CompilerUtils.h b/CompilerUtils.h index 7ac3cc29..fe28cead 100644 --- a/CompilerUtils.h +++ b/CompilerUtils.h @@ -54,6 +54,8 @@ public: unsigned storeInMemory(unsigned _offset, Type const& _type = IntegerType(256), bool _padToWordBoundaries = false); /// Dynamic version of @see storeInMemory, expects the memory offset below the value on the stack /// and also updates that. + /// Stack pre: memory_offset value... + /// Stack post: (memory_offset+length) void storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries = true); /// @returns _size rounded up to the next multiple of 32 (the number of bytes occupied in the /// padded calldata) @@ -75,11 +77,13 @@ public: /// @note Only works for types of fixed size. void computeHashStatic(Type const& _type = IntegerType(256), bool _padToWordBoundaries = false); - /// Copies a byte array to a byte array in storage, where the target is assumed to be on the - /// to top of the stay. Leaves a reference to the target on the stack. + /// Copies a byte array to a byte array in storage. + /// Stack pre: [source_reference] target_reference + /// Stack post: target_reference void copyByteArrayToStorage(ByteArrayType const& _targetType, ByteArrayType const& _sourceType) const; /// Clears the length and data elements of the byte array referenced on the stack. - /// Removes the reference from the stack. + /// Stack pre: reference + /// Stack post: void clearByteArray(ByteArrayType const& _type) const; /// Bytes we need to the start of call data. @@ -87,10 +91,11 @@ public: static const unsigned int dataStartOffset; private: + /// Prepares the given type for storing in memory by shifting it if necessary. unsigned prepareMemoryStore(Type const& _type, bool _padToWordBoundaries) const; - /// Appends a loop that clears all storage between the storage reference at the stack top - /// and the one below it (excluding). - /// Will leave the single value of the end pointer on the stack. + /// Appends a loop that clears a sequence of storage slots (excluding end). + /// Stack pre: end_ref start_ref + /// Stack post: end_ref void clearStorageLoop() const; CompilerContext& m_context; diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index b373bfbc..63132a12 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -1032,7 +1032,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, Type break; } case LValueType::Storage: - // stack layout: value value ... value ref + // stack layout: value value ... value target_ref if (_expression.getType()->isValueType()) { if (!_move) // copy values @@ -1050,7 +1050,7 @@ void ExpressionCompiler::LValue::storeValue(Expression const& _expression, Type if (i + 1 >= m_size) *m_context << eth::Instruction::SSTORE; else - // v v ... v v r+x + // stack here: value value ... value value (target_ref+offset) *m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2 << eth::Instruction::SSTORE << u256(1) << eth::Instruction::SWAP1 << eth::Instruction::SUB; |