aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp37
-rw-r--r--libsolidity/codegen/LValue.cpp16
2 files changed, 45 insertions, 8 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index b5b10c30..05d9ea1c 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -588,11 +588,24 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
{
++numIndexed;
arguments[arg - 1]->accept(*this);
- utils().convertType(
- *arguments[arg - 1]->annotation().type,
- *function.parameterTypes()[arg - 1],
- true
- );
+ if (auto const& arrayType = dynamic_pointer_cast<ArrayType const>(function.parameterTypes()[arg - 1]))
+ {
+ utils().fetchFreeMemoryPointer();
+ utils().encodeToMemory(
+ {arguments[arg - 1]->annotation().type},
+ {arrayType},
+ false,
+ true
+ );
+ utils().toSizeAfterFreeMemoryPointer();
+ m_context << eth::Instruction::SHA3;
+ }
+ else
+ utils().convertType(
+ *arguments[arg - 1]->annotation().type,
+ *function.parameterTypes()[arg - 1],
+ true
+ );
}
if (!event.isAnonymous())
{
@@ -625,6 +638,20 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
m_context << eth::Instruction::BLOCKHASH;
break;
}
+ case Location::AddMod:
+ case Location::MulMod:
+ {
+ for (unsigned i = 0; i < 3; i ++)
+ {
+ arguments[2 - i]->accept(*this);
+ utils().convertType(*arguments[2 - i]->annotation().type, IntegerType(256));
+ }
+ if (function.location() == Location::AddMod)
+ m_context << eth::Instruction::ADDMOD;
+ else
+ m_context << eth::Instruction::MULMOD;
+ break;
+ }
case Location::ECRecover:
case Location::SHA256:
case Location::RIPEMD160:
diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp
index 574d42f8..864f28d0 100644
--- a/libsolidity/codegen/LValue.cpp
+++ b/libsolidity/codegen/LValue.cpp
@@ -103,10 +103,20 @@ void MemoryItem::storeValue(Type const& _sourceType, SourceLocation const&, bool
if (!_move)
{
utils.moveToStackTop(m_dataType->sizeOnStack());
- utils.copyToStackTop(2, m_dataType->sizeOnStack());
+ utils.copyToStackTop(1 + m_dataType->sizeOnStack(), m_dataType->sizeOnStack());
+ }
+ if (!m_padded)
+ {
+ solAssert(m_dataType->calldataEncodedSize(false) == 1, "Invalid non-padded type.");
+ if (m_dataType->category() == Type::Category::FixedBytes)
+ m_context << u256(0) << eth::Instruction::BYTE;
+ m_context << eth::Instruction::SWAP1 << eth::Instruction::MSTORE8;
+ }
+ else
+ {
+ utils.storeInMemoryDynamic(*m_dataType, m_padded);
+ m_context << eth::Instruction::POP;
}
- utils.storeInMemoryDynamic(*m_dataType, m_padded);
- m_context << eth::Instruction::POP;
}
else
{