diff options
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 6 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index dd38ef97..6d82e94b 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -276,8 +276,10 @@ void CompilerUtils::memoryCopy() m_context << u256(0) << u256(identityContractAddress); // compute gas costs m_context << u256(32) << eth::Instruction::DUP5 << u256(31) << eth::Instruction::ADD; - m_context << eth::Instruction::DIV << u256(eth::c_identityWordGas) << eth::Instruction::MUL; - m_context << u256(eth::c_identityGas) << eth::Instruction::ADD; + static unsigned c_identityGas = 3; + static unsigned c_identityWordGas = 15; + m_context << eth::Instruction::DIV << u256(c_identityWordGas) << eth::Instruction::MUL; + m_context << u256(c_identityGas) << eth::Instruction::ADD; m_context << eth::Instruction::CALL; m_context << eth::Instruction::POP; // ignore return value } diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 3906a897..0f952f9c 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -637,6 +637,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: |