mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests and fixes for ether subdenominations
This commit is contained in:
parent
426f9a2860
commit
eaadc71b4c
@ -694,10 +694,10 @@ ASTPointer<Expression> Parser::parsePrimaryExpression()
|
|||||||
case Token::NUMBER:
|
case Token::NUMBER:
|
||||||
nextToken = m_scanner->peekNextToken();
|
nextToken = m_scanner->peekNextToken();
|
||||||
case Token::STRING_LITERAL:
|
case Token::STRING_LITERAL:
|
||||||
if (Token::isEtherSubdenomination(nextToken))
|
|
||||||
m_scanner->next();
|
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expression = nodeFactory.createNode<Literal>(token, getLiteralAndAdvance(), nextToken);
|
expression = nodeFactory.createNode<Literal>(token, getLiteralAndAdvance(), nextToken);
|
||||||
|
if (Token::isEtherSubdenomination(nextToken))
|
||||||
|
m_scanner->next();
|
||||||
break;
|
break;
|
||||||
case Token::IDENTIFIER:
|
case Token::IDENTIFIER:
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
|
@ -328,18 +328,18 @@ string IntegerConstantType::toString() const
|
|||||||
|
|
||||||
u256 IntegerConstantType::literalValue(Literal const* _literal) const
|
u256 IntegerConstantType::literalValue(Literal const* _literal) const
|
||||||
{
|
{
|
||||||
Literal::ethSubDenomination sub =_literal->getSubDenomination();
|
|
||||||
u256 value;
|
u256 value;
|
||||||
// we ignore the literal and hope that the type was correctly determined
|
// we ignore the literal and hope that the type was correctly determined
|
||||||
solAssert(m_value <= u256(-1), "Integer constant too large.");
|
solAssert(m_value <= u256(-1), "Integer constant too large.");
|
||||||
solAssert(m_value >= -(bigint(1) << 255), "Integer constant too small.");
|
solAssert(m_value >= -(bigint(1) << 255), "Integer constant too small.");
|
||||||
|
|
||||||
|
|
||||||
if (m_value >= 0)
|
if (m_value >= 0)
|
||||||
value = u256(m_value);
|
value = u256(m_value);
|
||||||
else
|
else
|
||||||
value = s2u(s256(m_value));
|
value = s2u(s256(m_value));
|
||||||
|
|
||||||
|
if (_literal) {
|
||||||
|
Literal::ethSubDenomination sub =_literal->getSubDenomination();
|
||||||
switch(sub) {
|
switch(sub) {
|
||||||
case Literal::ethSubDenomination::WEI:
|
case Literal::ethSubDenomination::WEI:
|
||||||
case Literal::ethSubDenomination::NONE:
|
case Literal::ethSubDenomination::NONE:
|
||||||
@ -354,6 +354,7 @@ u256 IntegerConstantType::literalValue(Literal const* _literal) const
|
|||||||
value *= u256(1000000000000000000);
|
value *= u256(1000000000000000000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user