aboutsummaryrefslogtreecommitdiffstats
path: root/LValue.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-04-28 17:31:40 +0800
committerchriseth <c@ethdev.com>2015-04-28 17:31:40 +0800
commitc1983d1bef0df65767485acd18232642917666e0 (patch)
tree087f50e6fc435087385e19279a21432499327320 /LValue.cpp
parent1087d34a665ad2d3595d8a5259d69e8f3d52eebe (diff)
downloaddexon-solidity-c1983d1bef0df65767485acd18232642917666e0.tar.gz
dexon-solidity-c1983d1bef0df65767485acd18232642917666e0.tar.zst
dexon-solidity-c1983d1bef0df65767485acd18232642917666e0.zip
Fix for deleting byte array elements.
Fixes #1759.
Diffstat (limited to 'LValue.cpp')
-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):