aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-05 20:48:02 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-05 22:41:13 +0800
commiteaadc71b4c88603a7264211401d249ca1ead22e3 (patch)
tree1d90d9d43d59472be6092e372d4d9d05ad1654d8 /Types.cpp
parent426f9a286071714de61accd04a13ce9d2446ba30 (diff)
downloaddexon-solidity-eaadc71b4c88603a7264211401d249ca1ead22e3.tar.gz
dexon-solidity-eaadc71b4c88603a7264211401d249ca1ead22e3.tar.zst
dexon-solidity-eaadc71b4c88603a7264211401d249ca1ead22e3.zip
Tests and fixes for ether subdenominations
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/Types.cpp b/Types.cpp
index 98c64802..c554f355 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -328,31 +328,32 @@ string IntegerConstantType::toString() const
u256 IntegerConstantType::literalValue(Literal const* _literal) const
{
- Literal::ethSubDenomination sub =_literal->getSubDenomination();
u256 value;
// we ignore the literal and hope that the type was correctly determined
solAssert(m_value <= u256(-1), "Integer constant too large.");
solAssert(m_value >= -(bigint(1) << 255), "Integer constant too small.");
-
if (m_value >= 0)
value = u256(m_value);
else
value = s2u(s256(m_value));
- switch(sub) {
- case Literal::ethSubDenomination::WEI:
- case Literal::ethSubDenomination::NONE:
- break;
- case Literal::ethSubDenomination::SZABO:
- value *= u256(1000000000000);
- break;
- case Literal::ethSubDenomination::FINNEY:
- value *= u256(1000000000000000);
- break;
- case Literal::ethSubDenomination::ETHER:
- value *= u256(1000000000000000000);
- break;
+ if (_literal) {
+ Literal::ethSubDenomination sub =_literal->getSubDenomination();
+ switch(sub) {
+ case Literal::ethSubDenomination::WEI:
+ case Literal::ethSubDenomination::NONE:
+ break;
+ case Literal::ethSubDenomination::SZABO:
+ value *= u256(1000000000000);
+ break;
+ case Literal::ethSubDenomination::FINNEY:
+ value *= u256(1000000000000000);
+ break;
+ case Literal::ethSubDenomination::ETHER:
+ value *= u256(1000000000000000000);
+ break;
+ }
}
return value;