aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-09 07:58:32 +0800
committerChristian <c@ethdev.com>2015-01-10 01:20:51 +0800
commitfe16922087ef41f157ef8661a9295aa1539796a5 (patch)
treee11a1111c08a862c72f9de92b2d47f6d81ea3bcd /Compiler.cpp
parent396f638ce19206144ce32dcf3926fc13fa9a89b7 (diff)
downloaddexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.gz
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.bz2
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.lz
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.xz
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.zst
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.zip
Padding for ABI types.
Diffstat (limited to 'Compiler.cpp')
-rw-r--r--Compiler.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index 4e5b7f55..c7d063ea 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -95,7 +95,7 @@ void Compiler::appendConstructorCall(FunctionDefinition const& _constructor)
// copy constructor arguments from code to memory and then to stack, they are supplied after the actual program
unsigned argumentSize = 0;
for (ASTPointer<VariableDeclaration> const& var: _constructor.getParameters())
- argumentSize += var->getType()->getCalldataEncodedSize();
+ argumentSize += CompilerUtils::getPaddedSize(var->getType()->getCalldataEncodedSize());
if (argumentSize > 0)
{
m_context << u256(argumentSize);
@@ -159,9 +159,9 @@ unsigned Compiler::appendCalldataUnpacker(FunctionDefinition const& _function, b
BOOST_THROW_EXCEPTION(CompilerError()
<< errinfo_sourceLocation(var->getLocation())
<< errinfo_comment("Type " + var->getType()->toString() + " not yet supported."));
- bool leftAligned = var->getType()->getCategory() == Type::Category::STRING;
- CompilerUtils(m_context).loadFromMemory(dataOffset, numBytes, leftAligned, !_fromMemory);
- dataOffset += numBytes;
+ bool const leftAligned = var->getType()->getCategory() == Type::Category::STRING;
+ bool const padToWords = true;
+ dataOffset += CompilerUtils(m_context).loadFromMemory(dataOffset, numBytes, leftAligned, !_fromMemory, padToWords);
}
return dataOffset;
}
@@ -181,10 +181,11 @@ 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);
+ ExpressionCompiler::appendTypeConversion(m_context, paramType, paramType, true);
bool const leftAligned = paramType.getCategory() == Type::Category::STRING;
- CompilerUtils(m_context).storeInMemory(dataOffset, numBytes, leftAligned);
+ bool const padToWords = true;
+ dataOffset += CompilerUtils(m_context).storeInMemory(dataOffset, numBytes, leftAligned, padToWords);
stackDepth -= paramType.getSizeOnStack();
- dataOffset += numBytes;
}
// note that the stack is not cleaned up here
m_context << u256(dataOffset) << u256(0) << eth::Instruction::RETURN;