diff options
author | chriseth <chris@ethereum.org> | 2018-05-31 00:32:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-31 00:32:08 +0800 |
commit | 5a73044fa77c0572a3a5375b0c557313e8c600a7 (patch) | |
tree | b73bfd0559cc70eea3aa022a375bfe273e68445d /libsolidity/codegen/ExpressionCompiler.cpp | |
parent | a77531d245d24d82e11858fb99ebfc9ec53b5d38 (diff) | |
parent | fea0d116f7d95e9a39f0c80c5156cb3656b03ce0 (diff) | |
download | dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar.gz dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar.bz2 dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar.lz dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar.xz dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.tar.zst dexon-solidity-5a73044fa77c0572a3a5375b0c557313e8c600a7.zip |
Merge pull request #3743 from ethereum/popStorageArray
pop() for storage arrays
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 4bcc1fa9..93d440c8 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -866,6 +866,19 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) StorageByteArrayElement(m_context).storeValue(*type, _functionCall.location(), true); break; } + case FunctionType::Kind::ArrayPop: + { + _functionCall.expression().accept(*this); + solAssert(function.parameterTypes().empty(), ""); + + ArrayType const& arrayType = dynamic_cast<ArrayType const&>( + *dynamic_cast<MemberAccess const&>(_functionCall.expression()).expression().annotation().type + ); + solAssert(arrayType.dataStoredIn(DataLocation::Storage), ""); + + ArrayUtils(m_context).popStorageArrayElement(arrayType); + break; + } case FunctionType::Kind::ObjectCreation: { ArrayType const& arrayType = dynamic_cast<ArrayType const&>(*_functionCall.annotation().type); @@ -1345,11 +1358,13 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) break; } } - else if (member == "push") + else if (member == "push" || member == "pop") { solAssert( - type.isDynamicallySized() && type.location() == DataLocation::Storage, - "Tried to use .push() on a non-dynamically sized array" + type.isDynamicallySized() && + type.location() == DataLocation::Storage && + type.category() == Type::Category::Array, + "Tried to use ." + member + "() on a non-dynamically sized array" ); } else |