diff options
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 4bcc1fa9..ac7610fc 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -866,6 +866,20 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) StorageByteArrayElement(m_context).storeValue(*type, _functionCall.location(), true); break; } + case FunctionType::Kind::ByteArrayPop: + 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); @@ -1348,10 +1362,21 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) else if (member == "push") { solAssert( - type.isDynamicallySized() && type.location() == DataLocation::Storage, + type.isDynamicallySized() && + type.location() == DataLocation::Storage && + type.category() == Type::Category::Array, "Tried to use .push() on a non-dynamically sized array" ); } + else if (member == "pop") + { + solAssert( + type.isDynamicallySized() && + type.location() == DataLocation::Storage && + type.category() == Type::Category::Array, + "Tried to use .pop() on a non-dynamically sized array" + ); + } else solAssert(false, "Illegal array member."); break; |