aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLu Guanqun <guanqun.lu@gmail.com>2015-02-08 19:23:17 +0800
committerLu Guanqun <guanqun.lu@gmail.com>2015-02-10 23:39:13 +0800
commitd307b0914c4425ffbdf312b270a5528868915667 (patch)
treeacd96e9f0412bc57efa78dfeb194ac5edfb68d3c /Types.cpp
parentcf4144b70246b53589b3238213f688244485f9b0 (diff)
downloaddexon-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.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Types.cpp b/Types.cpp
index 6fd9e8b4..dcc0738d 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -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();
}