diff options
author | chriseth <c@ethdev.com> | 2015-03-06 22:42:49 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-06 22:42:49 +0800 |
commit | 6fea41abd8db5b60c8c42d98db234c038e577a49 (patch) | |
tree | 0ec924ae185a546dfd8f799927a3fa9c2fbfc54d /ExpressionCompiler.cpp | |
parent | 28e88903dc7e503e6bf5981f08a56136b860927b (diff) | |
parent | 8de5ff5c25c812512fe46ecb7bbe8a219f4a6b2a (diff) | |
download | dexon-solidity-6fea41abd8db5b60c8c42d98db234c038e577a49.tar.gz dexon-solidity-6fea41abd8db5b60c8c42d98db234c038e577a49.tar.zst dexon-solidity-6fea41abd8db5b60c8c42d98db234c038e577a49.zip |
Merge pull request #1222 from chriseth/sol_copyFromCalldata
Copying between calldata and storage.
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r-- | ExpressionCompiler.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index adaaff23..6b797887 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -74,7 +74,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& { // move offset to memory CompilerUtils(m_context).storeInMemory(length); - unsigned argLen = CompilerUtils::getPaddedSize(paramType->getCalldataEncodedSize()); + unsigned argLen = paramType->getCalldataEncodedSize(); length -= argLen; m_context << u256(argLen + 32) << u256(length) << eth::Instruction::SHA3; @@ -782,8 +782,9 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) else { u256 elementSize = - location == ArrayType::Location::Storage ? arrayType.getBaseType()->getStorageSize() : - CompilerUtils::getPaddedSize(arrayType.getBaseType()->getCalldataEncodedSize()); + location == ArrayType::Location::Storage ? + arrayType.getBaseType()->getStorageSize() : + arrayType.getBaseType()->getCalldataEncodedSize(); solAssert(elementSize != 0, "Invalid element size."); if (elementSize > 1) m_context << elementSize << eth::Instruction::MUL; @@ -801,8 +802,8 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) switch (location) { case ArrayType::Location::CallData: - // no lvalue - CompilerUtils(m_context).loadFromMemoryDynamic(*arrayType.getBaseType(), true, true, false); + if (arrayType.getBaseType()->isValueType()) + CompilerUtils(m_context).loadFromMemoryDynamic(*arrayType.getBaseType(), true, true, false); break; case ArrayType::Location::Storage: setLValueToStorageItem(_indexAccess); @@ -1021,7 +1022,7 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio //@todo only return the first return value for now Type const* firstType = _functionType.getReturnParameterTypes().empty() ? nullptr : _functionType.getReturnParameterTypes().front().get(); - unsigned retSize = firstType ? CompilerUtils::getPaddedSize(firstType->getCalldataEncodedSize()) : 0; + unsigned retSize = firstType ? firstType->getCalldataEncodedSize() : 0; m_context << u256(retSize) << u256(0); if (bare) @@ -1051,8 +1052,8 @@ void ExpressionCompiler::appendExternalFunctionCall(FunctionType const& _functio if (_functionType.gasSet()) m_context << eth::dupInstruction(m_context.baseToCurrentStackOffset(gasStackPos)); else - // send all gas except for the 21 needed to execute "SUB" and "CALL" - m_context << u256(_functionType.valueSet() ? 6741 : 41) << eth::Instruction::GAS << eth::Instruction::SUB; + // send all gas except for the 41 / 6741 needed to execute "SUB" and "CALL" + m_context << u256(41 + (_functionType.valueSet() ? 6700 : 0)) << eth::Instruction::GAS << eth::Instruction::SUB; m_context << eth::Instruction::CALL; auto tag = m_context.appendConditionalJump(); m_context << eth::Instruction::STOP << tag; // STOP if CALL leaves 0. @@ -1083,7 +1084,7 @@ void ExpressionCompiler::appendArgumentsCopyToMemory( appendTypeConversion(*_arguments[i]->getType(), *expectedType, true); bool pad = _padToWordBoundaries; // Do not pad if the first argument has exactly four bytes - if (i == 0 && pad && _padExceptionIfFourBytes && expectedType->getCalldataEncodedSize() == 4) + if (i == 0 && pad && _padExceptionIfFourBytes && expectedType->getCalldataEncodedSize(false) == 4) pad = false; appendTypeMoveToMemory(*expectedType, pad); } |