diff options
author | chriseth <c@ethdev.com> | 2015-03-06 01:22:17 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-06 20:17:52 +0800 |
commit | d8b156ecbbb4d470ba3432975694585dd5a019e2 (patch) | |
tree | a5ffc773101dcba3b274acc5329c20f6a73aed6b /ExpressionCompiler.cpp | |
parent | 34e8de749aeecbca5f5dae817aa67f42907e9bf7 (diff) | |
download | dexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.tar.gz dexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.tar.zst dexon-solidity-d8b156ecbbb4d470ba3432975694585dd5a019e2.zip |
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 793bd55e..b967f9ed 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; @@ -779,8 +779,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; @@ -798,8 +799,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); @@ -1018,7 +1019,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) @@ -1048,8 +1049,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. @@ -1080,7 +1081,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); } |