diff options
author | Christian <c@ethdev.com> | 2014-12-13 00:22:19 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-13 00:22:45 +0800 |
commit | 6893d4d4557e9968feaa162c8fc5ea3859aa0565 (patch) | |
tree | 034b8915c6f66baa2d5e2e7d41c998b85aa589ea /Compiler.cpp | |
parent | e2547526ab82ce00511da0c69f7e7de5944d6530 (diff) | |
parent | 3860814fa0a50ea496926069c4144209fdccdc3a (diff) | |
download | dexon-solidity-6893d4d4557e9968feaa162c8fc5ea3859aa0565.tar.gz dexon-solidity-6893d4d4557e9968feaa162c8fc5ea3859aa0565.tar.zst dexon-solidity-6893d4d4557e9968feaa162c8fc5ea3859aa0565.zip |
Merge remote-tracking branch 'ethereum/develop' into sol_swapConstants
Conflicts:
test/solidityOptimizerTest.cpp
Diffstat (limited to 'Compiler.cpp')
-rw-r--r-- | Compiler.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Compiler.cpp b/Compiler.cpp index 97431341..25833691 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -130,21 +130,17 @@ unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, b { // We do not check the calldata size, everything is zero-padded. unsigned dataOffset = 1; - eth::Instruction load = _fromMemory ? eth::Instruction::MLOAD : eth::Instruction::CALLDATALOAD; //@todo this can be done more efficiently, saving some CALLDATALOAD calls for (ASTPointer<VariableDeclaration> const& var: _function.getParameters()) { unsigned const numBytes = var->getType()->getCalldataEncodedSize(); - if (numBytes == 0 || numBytes > 32) + if (numBytes > 32) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(var->getLocation()) << errinfo_comment("Type " + var->getType()->toString() + " not yet supported.")); - if (numBytes == 32) - m_context << u256(dataOffset) << load; - else - m_context << (u256(1) << ((32 - numBytes) * 8)) << u256(dataOffset) - << load << eth::Instruction::DIV; + bool leftAligned = var->getType()->getCategory() == Type::Category::STRING; + CompilerUtils(m_context).loadFromMemory(dataOffset, numBytes, leftAligned, !_fromMemory); dataOffset += numBytes; } return dataOffset; @@ -160,14 +156,13 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function) { Type const& paramType = *parameters[i]->getType(); unsigned numBytes = paramType.getCalldataEncodedSize(); - if (numBytes == 0 || numBytes > 32) + if (numBytes > 32) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_sourceLocation(parameters[i]->getLocation()) << errinfo_comment("Type " + paramType.toString() + " not yet supported.")); CompilerUtils(m_context).copyToStackTop(stackDepth, paramType); - if (numBytes != 32) - m_context << (u256(1) << ((32 - numBytes) * 8)) << eth::Instruction::MUL; - m_context << u256(dataOffset) << eth::Instruction::MSTORE; + bool const leftAligned = paramType.getCategory() == Type::Category::STRING; + CompilerUtils(m_context).storeInMemory(dataOffset, numBytes, leftAligned); stackDepth -= paramType.getSizeOnStack(); dataOffset += numBytes; } |