diff options
-rw-r--r-- | AST.cpp | 6 | ||||
-rwxr-xr-x | AST.h | 16 | ||||
-rw-r--r-- | Token.h | 12 | ||||
-rw-r--r-- | Types.cpp | 18 |
4 files changed, 28 insertions, 24 deletions
@@ -599,10 +599,10 @@ Literal::Literal(Location const& _location, Token::Value _token, Token::Value _sub): PrimaryExpression(_location), m_token(_token), m_value(_value) { - if(Token::isEtherSubdenomination(_sub)) - m_subDenomination = static_cast<Literal::ethSubDenomination>(_sub); + if (Token::isEtherSubdenomination(_sub)) + m_subDenomination = static_cast<Literal::SubDenomination>(_sub); else - m_subDenomination = Literal::ethSubDenomination::NONE; + m_subDenomination = Literal::SubDenomination::NONE; } void Literal::checkTypeRequirements() @@ -1117,12 +1117,14 @@ private: class Literal: public PrimaryExpression { public: - enum class ethSubDenomination { + enum class SubDenomination + { NONE = Token::ILLEGAL, - WEI = Token::ETH_SUB_WEI, - SZABO = Token::ETH_SUB_SZABO, - FINNEY = Token::ETH_SUB_FINNEY, - ETHER = Token::ETH_SUB_ETHER}; + WEI = Token::SubWei, + SZABO = Token::SubSzabo, + FINNEY = Token::SubFinney, + ETHER = Token::SubEther + }; Literal(Location const& _location, Token::Value _token, ASTPointer<ASTString> const& _value, Token::Value _sub = Token::ILLEGAL); @@ -1134,12 +1136,12 @@ public: /// @returns the non-parsed value of the literal ASTString const& getValue() const { return *m_value; } - ethSubDenomination getSubDenomination() const { return m_subDenomination; } + SubDenomination getSubDenomination() const { return m_subDenomination; } private: Token::Value m_token; ASTPointer<ASTString> m_value; - ethSubDenomination m_subDenomination; + SubDenomination m_subDenomination; }; /// @} @@ -174,11 +174,11 @@ namespace solidity K(WHILE, "while", 0) \ \ \ - /* Ether subdenominations */ \ - K(ETH_SUB_WEI, "wei", 0) \ - K(ETH_SUB_SZABO, "szabo", 0) \ - K(ETH_SUB_FINNEY, "finney", 0) \ - K(ETH_SUB_ETHER, "ether", 0) \ + /* Ether subdenominations */ \ + K(SubWei, "wei", 0) \ + K(SubSzabo, "szabo", 0) \ + K(SubFinney, "finney", 0) \ + K(SubEther, "ether", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here * TODO more to be added */ \ @@ -383,7 +383,7 @@ public: static bool isCountOp(Value op) { return op == INC || op == DEC; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return op == PUBLIC || op == PRIVATE || op == PROTECTED; } - static bool isEtherSubdenomination(Value op) { return op == ETH_SUB_WEI || op == ETH_SUB_SZABO || op == ETH_SUB_FINNEY || op == Token::ETH_SUB_ETHER; } + static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't @@ -338,19 +338,21 @@ u256 IntegerConstantType::literalValue(Literal const* _literal) const else value = s2u(s256(m_value)); - if (_literal) { - Literal::ethSubDenomination sub =_literal->getSubDenomination(); - switch(sub) { - case Literal::ethSubDenomination::WEI: - case Literal::ethSubDenomination::NONE: + if (_literal) + { + Literal::SubDenomination sub =_literal->getSubDenomination(); + switch(sub) + { + case Literal::SubDenomination::WEI: + case Literal::SubDenomination::NONE: break; - case Literal::ethSubDenomination::SZABO: + case Literal::SubDenomination::SZABO: value *= u256(1000000000000); break; - case Literal::ethSubDenomination::FINNEY: + case Literal::SubDenomination::FINNEY: value *= u256(1000000000000000); break; - case Literal::ethSubDenomination::ETHER: + case Literal::SubDenomination::ETHER: value *= u256(1000000000000000000); break; } |