diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-03 21:02:58 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-06 16:38:04 +0800 |
commit | 8c1d928c944b70cf7318d8277cdfbf2ef0421857 (patch) | |
tree | 6033cb8918ae2049b6b339e716067a7f3db82198 /ExpressionCompiler.cpp | |
parent | 59a390937637111ebdadf2d3af57122a10bdd012 (diff) | |
download | dexon-solidity-8c1d928c944b70cf7318d8277cdfbf2ef0421857.tar.gz dexon-solidity-8c1d928c944b70cf7318d8277cdfbf2ef0421857.tar.zst dexon-solidity-8c1d928c944b70cf7318d8277cdfbf2ef0421857.zip |
Solidity SHA3 can now take multiple arguments
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 875e00bc..8672611a 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -206,7 +206,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) TypePointers const& parameterTypes = function.getParameterTypes(); vector<ASTPointer<Expression const>> const& callArguments = _functionCall.getArguments(); vector<ASTPointer<ASTString>> const& callArgumentNames = _functionCall.getNames(); - solAssert(callArguments.size() == parameterTypes.size(), ""); + if (function.getLocation() != Location::SHA3) + solAssert(callArguments.size() == parameterTypes.size(), ""); vector<ASTPointer<Expression const>> arguments; if (callArgumentNames.empty()) @@ -325,9 +326,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) m_context << eth::Instruction::SUICIDE; break; case Location::SHA3: - appendExpressionCopyToMemory(*function.getParameterTypes().front(), *arguments.front()); - m_context << u256(32) << u256(0) << eth::Instruction::SHA3; + { + unsigned length = appendSameTypeArgumentsCopyToMemory(function.getParameterTypes().front(), arguments, 0); + m_context << u256(length) << u256(0) << eth::Instruction::SHA3; break; + } case Location::LOG0: case Location::LOG1: case Location::LOG2: @@ -843,8 +846,18 @@ unsigned ExpressionCompiler::appendArgumentCopyToMemory(TypePointers const& _typ return length; } -unsigned ExpressionCompiler::appendTypeConversionAndMoveToMemory(Type const& _expectedType, Type const& _type, - Location const& _location, unsigned _memoryOffset) +unsigned ExpressionCompiler::appendSameTypeArgumentsCopyToMemory(TypePointer const& _type, + vector<ASTPointer<Expression const>> const& _arguments, + unsigned _memoryOffset) +{ + unsigned length = 0; + for (unsigned i = 0; i < _arguments.size(); ++i) + length += appendExpressionCopyToMemory(*_type, *_arguments[i], _memoryOffset + length); + return length; +} + +unsigned ExpressionCompiler::appendExpressionCopyToMemory(Type const& _expectedType, + Expression const& _expression, unsigned _memoryOffset) { appendTypeConversion(_type, _expectedType, true); unsigned const c_numBytes = CompilerUtils::getPaddedSize(_expectedType.getCalldataEncodedSize()); |