aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-16 20:43:57 +0800
committerGitHub <noreply@github.com>2018-05-16 20:43:57 +0800
commite67f0147998a9e3835ed3ce8bf6a0a0c634216c5 (patch)
treeb9c0b7d41cd9f78ae3404704a888da30e767edbe /libsolidity/codegen/ExpressionCompiler.cpp
parent124ca40dc525a987a88176c6e5170978e82fa290 (diff)
parent1e45d3ab2e0ca688c2ae48ab657f11496ccebc12 (diff)
downloaddexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.gz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.bz2
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.lz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.xz
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.tar.zst
dexon-solidity-e67f0147998a9e3835ed3ce8bf6a0a0c634216c5.zip
Merge pull request #4148 from ethereum/develop
Merge develop into release for 0.4.24
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 3cf46a9d..4bcc1fa9 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -548,7 +548,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
if (m_context.runtimeContext())
// We have a runtime context, so we need the creation part.
- utils().rightShiftNumberOnStack(32, false);
+ utils().rightShiftNumberOnStack(32);
else
// Extract the runtime part.
m_context << ((u256(1) << 32) - 1) << Instruction::AND;
@@ -933,7 +933,11 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
// condition was not met, flag an error
m_context.appendInvalid();
else if (arguments.size() > 1)
+ {
utils().revertWithStringData(*arguments.at(1)->annotation().type);
+ // Here, the argument is consumed, but in the other branch, it is still there.
+ m_context.adjustStackOffset(arguments.at(1)->annotation().type->sizeOnStack());
+ }
else
m_context.appendRevert();
// the success branch
@@ -1706,13 +1710,23 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator, Type co
m_context.appendConditionalInvalid();
}
+ m_context << Instruction::SWAP1;
+ // stack: value_to_shift shift_amount
+
switch (_operator)
{
case Token::SHL:
- m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::MUL;
+ if (m_context.evmVersion().hasBitwiseShifting())
+ m_context << Instruction::SHL;
+ else
+ m_context << u256(2) << Instruction::EXP << Instruction::MUL;
break;
case Token::SAR:
- m_context << Instruction::SWAP1 << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV);
+ // NOTE: SAR rounds differently than SDIV
+ if (m_context.evmVersion().hasBitwiseShifting() && !c_valueSigned)
+ m_context << Instruction::SHR;
+ else
+ m_context << u256(2) << Instruction::EXP << Instruction::SWAP1 << (c_valueSigned ? Instruction::SDIV : Instruction::DIV);
break;
case Token::SHR:
default: