aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-04 23:37:54 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-05 00:52:28 +0800
commitdca5f7b57bb5b535930d437c806f48a25cf6b569 (patch)
tree04ee06c48c7ca6c4f012c6778bb9ea01248582d9 /Types.cpp
parentdb263bd9d751f69f9d8d9484ff916d38b86c68c4 (diff)
downloaddexon-solidity-dca5f7b57bb5b535930d437c806f48a25cf6b569.tar.gz
dexon-solidity-dca5f7b57bb5b535930d437c806f48a25cf6b569.tar.zst
dexon-solidity-dca5f7b57bb5b535930d437c806f48a25cf6b569.zip
Adding ether subdenominations after constan literals
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/Types.cpp b/Types.cpp
index 54e701c1..98c64802 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -326,15 +326,36 @@ string IntegerConstantType::toString() const
return "int_const " + m_value.str();
}
-u256 IntegerConstantType::literalValue(Literal const*) 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)
- return u256(m_value);
+ value = u256(m_value);
else
- return s2u(s256(m_value));
+ 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;
+ }
+
+ return value;
}
shared_ptr<IntegerType const> IntegerConstantType::getIntegerType() const