diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-10-15 19:54:59 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-10-15 19:54:59 +0800 |
commit | 9224c1f7128f92f47ddf3feaf83b57d6d98e0a04 (patch) | |
tree | c6d94f12a23b771a388994b01f034a04f338eb01 /libsolidity | |
parent | a521843f6b0bf019a19d9a377f4bbbc473083151 (diff) | |
download | dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar.gz dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar.bz2 dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar.lz dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar.xz dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.tar.zst dexon-solidity-9224c1f7128f92f47ddf3feaf83b57d6d98e0a04.zip |
Working implementation of arraypush
ByteArrayPush() gets a test but is ignored for now, since there are
still some issues with its implementation
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ExpressionCompiler.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 5ff1363f..2d3126c8 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -623,27 +623,29 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) appendExternalFunctionCall(function, arguments); break; } + case Location::ByteArrayPush: + solAssert(false, "Not properly implemented yet"); case Location::ArrayPush: { - cout << "Beginning " << m_context.stackHeight() << endl; + _functionCall.expression().accept(*this); solAssert(function.parameterTypes().size() == 1, ""); solAssert(!!function.parameterTypes()[0], ""); TypePointer const& paramType = function.parameterTypes()[0]; - ArrayType arrayType(DataLocation::Storage, paramType); + shared_ptr<ArrayType> arrayType = + function.location() == Location::ArrayPush ? + make_shared<ArrayType>(DataLocation::Storage, paramType) : + make_shared<ArrayType>(DataLocation::Storage); // get the current length - ArrayUtils(m_context).retrieveLength(arrayType); + ArrayUtils(m_context).retrieveLength(*arrayType); m_context << eth::Instruction::DUP1; - cout << "After DUP1 " << m_context.stackHeight() << endl; // stack: ArrayReference currentLength currentLength m_context << u256(1) << eth::Instruction::ADD; // stack: ArrayReference currentLength newLength m_context << eth::Instruction::DUP3 << eth::Instruction::DUP2; - ArrayUtils(m_context).resizeDynamicArray(arrayType); - cout << "After Resize Dynamic Array " << m_context.stackHeight() << endl; + ArrayUtils(m_context).resizeDynamicArray(*arrayType); m_context << eth::Instruction::SWAP2 << eth::Instruction::SWAP1; // stack: newLength ArrayReference oldLength - ArrayUtils(m_context).accessIndex(arrayType, false); - cout << "After Access Index " << m_context.stackHeight() << endl; + ArrayUtils(m_context).accessIndex(*arrayType, false); // stack: newLength storageSlot slotOffset arguments[0]->accept(*this); @@ -657,9 +659,6 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) StorageItem(m_context, *paramType).storeValue(*type, _functionCall.location(), true); break; } - case Location::ByteArrayPush: - // TODO - break; default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid function type.")); } @@ -852,7 +851,6 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) } else solAssert(false, "Illegal array member."); - break; } default: |