aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Compiler.cpp')
-rw-r--r--Compiler.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index b094af19..940a5e70 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -130,7 +130,6 @@ 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())
@@ -140,11 +139,8 @@ unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, b
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;
@@ -165,9 +161,8 @@ void Compiler::appendReturnValuePacker(FunctionDefinition const& _function)
<< 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;
}