diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2015-02-08 19:23:17 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2015-02-10 23:39:13 +0800 |
commit | d307b0914c4425ffbdf312b270a5528868915667 (patch) | |
tree | acd96e9f0412bc57efa78dfeb194ac5edfb68d3c /Types.cpp | |
parent | cf4144b70246b53589b3238213f688244485f9b0 (diff) | |
download | dexon-solidity-d307b0914c4425ffbdf312b270a5528868915667.tar.gz dexon-solidity-d307b0914c4425ffbdf312b270a5528868915667.tar.zst dexon-solidity-d307b0914c4425ffbdf312b270a5528868915667.zip |
add exponent operator
https://www.pivotaltracker.com/n/projects/1189488/stories/83746404
Diffstat (limited to 'Types.cpp')
-rw-r--r-- | Types.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -320,6 +320,16 @@ TypePointer IntegerConstantType::binaryOperatorResult(Token::Value _operator, Ty return TypePointer(); value = m_value % other.m_value; break; + case Token::Exp: + if (other.m_value < 0) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("exponent can't be negative")); + else + { + value = boost::multiprecision::powm(m_value, other.m_value, bigint(2) << 256); + if (value >= (bigint(1) << 256)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("exp result overflowed")); + } + break; default: return TypePointer(); } |