aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRJ <catalanor0220@gmail.com>2016-05-17 23:04:10 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-10-20 07:03:09 +0800
commit48f20289115183ce48bc2df8116069f7460fe9e8 (patch)
tree8fb40c6ad1c648c787047184a3e1cd23d3f25e14
parent2bb37f8203d5b64f603d4c7c802407a5500429b5 (diff)
downloaddexon-solidity-48f20289115183ce48bc2df8116069f7460fe9e8.tar.gz
dexon-solidity-48f20289115183ce48bc2df8116069f7460fe9e8.tar.zst
dexon-solidity-48f20289115183ce48bc2df8116069f7460fe9e8.zip
Support shifting constants
-rw-r--r--libsolidity/ast/Types.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 068cc138..a6c73953 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -705,6 +705,28 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
value = rational(denominator, numerator);
break;
}
+ case Token::SHL:
+ {
+ using boost::multiprecision::pow;
+ if (fractional)
+ return TypePointer();
+ else if (abs(other.m_value) > numeric_limits<uint32_t>::max())
+ return TypePointer();
+ uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>();
+ value = m_value.numerator() * pow(bigint(2), exponent);
+ break;
+ }
+ case Token::SHR:
+ {
+ using boost::multiprecision::pow;
+ if (fractional)
+ return TypePointer();
+ else if (abs(other.m_value) > numeric_limits<uint32_t>::max())
+ return TypePointer();
+ uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>();
+ value = rational(m_value.numerator() / pow(bigint(2), exponent), 1);
+ break;
+ }
default:
return TypePointer();
}