From 3287cd464fc6b73ba5da2a94030ab202370f647a Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 12 Oct 2015 10:11:58 +0200 Subject: WIP - Expression compiler for array push --- libsolidity/ExpressionCompiler.cpp | 46 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index f6eed0de..c25202b6 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -784,26 +784,42 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) } case Type::Category::Array: { - solAssert(member == "length", "Illegal array member."); auto const& type = dynamic_cast(*_memberAccess.expression().annotation().type); - if (!type.isDynamicallySized()) + if (member == "length") { - utils().popStackElement(type); - m_context << type.length(); + if (!type.isDynamicallySized()) + { + utils().popStackElement(type); + m_context << type.length(); + } + else + switch (type.location()) + { + case DataLocation::CallData: + m_context << eth::Instruction::SWAP1 << eth::Instruction::POP; + break; + case DataLocation::Storage: + setLValue(_memberAccess, type); + break; + case DataLocation::Memory: + m_context << eth::Instruction::MLOAD; + break; + } } - else - switch (type.location()) + else if (member == "push" && type.isDynamicallySized() && type.location() == DataLocation::Storage) + { + if (type.isByteArray()) { - case DataLocation::CallData: - m_context << eth::Instruction::SWAP1 << eth::Instruction::POP; - break; - case DataLocation::Storage: - setLValue(_memberAccess, type); - break; - case DataLocation::Memory: - m_context << eth::Instruction::MLOAD; - break; + solAssert(!type.isString(), "Index access to string is not allowed."); + setLValue(_indexAccess); } + else + setLValueToStorageItem(_indexAccess); + setLValue(_memberAccess, type); + } + else + solAssert(false, "Illegal array member."); + break; } default: -- cgit v1.2.3