aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <g@ethdev.com>2015-04-28 18:39:03 +0800
committerGav Wood <g@ethdev.com>2015-04-28 18:39:03 +0800
commita508d29489af7c75bedafe83df0c36c6b5e611b6 (patch)
treebee8f61e03fd73679c06c39718f9ed041a467ce4
parenteddf443fd2ab60cc0ab0159f9b8f5359159be2a0 (diff)
parentc1983d1bef0df65767485acd18232642917666e0 (diff)
downloaddexon-solidity-a508d29489af7c75bedafe83df0c36c6b5e611b6.tar.gz
dexon-solidity-a508d29489af7c75bedafe83df0c36c6b5e611b6.tar.zst
dexon-solidity-a508d29489af7c75bedafe83df0c36c6b5e611b6.zip
Merge pull request #1761 from chriseth/sol_fix_deleteBytes
Fix for deleting byte array elements.
-rw-r--r--LValue.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/LValue.cpp b/LValue.cpp
index bb68a663..38efb2a7 100644
--- a/LValue.cpp
+++ b/LValue.cpp
@@ -311,8 +311,6 @@ void StorageByteArrayElement::retrieveValue(SourceLocation const&, bool _remove)
void StorageByteArrayElement::storeValue(Type const&, SourceLocation const&, bool _move) const
{
- //@todo optimize this
-
// stack: value ref byte_number
m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP;
// stack: value ref (1<<(8*(31-byte_number)))
@@ -335,19 +333,16 @@ void StorageByteArrayElement::setToZero(SourceLocation const&, bool _removeRefer
{
// stack: ref byte_number
if (!_removeReference)
- m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2;
+ m_context << eth::Instruction::DUP2 << eth::Instruction::DUP2;
m_context << u256(31) << eth::Instruction::SUB << u256(0x100) << eth::Instruction::EXP;
// stack: ref (1<<(8*(31-byte_number)))
m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD;
// stack: ref (1<<(8*(31-byte_number))) old_full_value
// clear byte in old value
- m_context << eth::Instruction::SWAP1 << u256(0xff) << eth::Instruction::MUL << eth::Instruction::AND;
+ m_context << eth::Instruction::SWAP1 << u256(0xff) << eth::Instruction::MUL;
+ m_context << eth::Instruction::NOT << eth::Instruction::AND;
// stack: ref old_full_value_with_cleared_byte
m_context << eth::Instruction::SWAP1 << eth::Instruction::SSTORE;
- if (!_removeReference)
- m_context << eth::Instruction::SWAP1;
- else
- m_context << eth::Instruction::POP;
}
StorageArrayLength::StorageArrayLength(CompilerContext& _compilerContext, const ArrayType& _arrayType):