aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-06 23:27:41 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-06 23:27:41 +0800
commit293344b4733e2de8f9159f3b73bbdd6e4a475195 (patch)
treea3a8047d9add8aff65e0c3f9eabdb1e67cb937a0 /ExpressionCompiler.cpp
parent2c9ff4747d81a34125e976a65d6eca8cb5349c9d (diff)
downloaddexon-solidity-293344b4733e2de8f9159f3b73bbdd6e4a475195.tar.gz
dexon-solidity-293344b4733e2de8f9159f3b73bbdd6e4a475195.tar.zst
dexon-solidity-293344b4733e2de8f9159f3b73bbdd6e4a475195.zip
SHA3 of string literals now should work
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 39593a6e..4f091db4 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -851,22 +851,23 @@ unsigned ExpressionCompiler::appendArgumentsCopyToMemory(vector<ASTPointer<Expre
// without type conversion
for (unsigned i = 0; i < _arguments.size(); ++i)
{
+ bool wantPadding = (_arguments[i]->getType()->getCategory() == Type::Category::STRING) ? false : true;
_arguments[i]->accept(*this);
- length += moveTypeToMemory(*_arguments[i]->getType()->getRealType(), _arguments[i]->getLocation(), _memoryOffset + length);
+ length += moveTypeToMemory(*_arguments[i]->getType()->getRealType(), _arguments[i]->getLocation(), _memoryOffset + length, wantPadding);
}
return length;
}
-unsigned ExpressionCompiler::moveTypeToMemory(Type const& _type, Location const& _location, unsigned _memoryOffset)
+unsigned ExpressionCompiler::moveTypeToMemory(Type const& _type, Location const& _location, unsigned _memoryOffset, bool _padToWordBoundaries)
{
- unsigned const c_numBytes = CompilerUtils::getPaddedSize(_type.getCalldataEncodedSize());
+ unsigned const encodedSize = _type.getCalldataEncodedSize();
+ unsigned const c_numBytes = _padToWordBoundaries ? CompilerUtils::getPaddedSize(encodedSize) : encodedSize;
if (c_numBytes == 0 || c_numBytes > 32)
BOOST_THROW_EXCEPTION(CompilerError()
<< errinfo_sourceLocation(_location)
<< errinfo_comment("Type " + _type.toString() + " not yet supported."));
bool const c_leftAligned = _type.getCategory() == Type::Category::STRING;
- bool const c_padToWords = true;
- return CompilerUtils(m_context).storeInMemory(_memoryOffset, c_numBytes, c_leftAligned, c_padToWords);
+ return CompilerUtils(m_context).storeInMemory(_memoryOffset, c_numBytes, c_leftAligned, _padToWordBoundaries);
}
unsigned ExpressionCompiler::appendTypeConversionAndMoveToMemory(Type const& _expectedType, Type const& _type,