aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorChristian Parpart <christian@ethereum.org>2018-10-22 22:48:21 +0800
committerChristian Parpart <christian@ethereum.org>2018-10-22 23:00:51 +0800
commitf112377dd44e8281bff092639bb546ec8a6a39ac (patch)
tree4b6b8b3816a0a1620e73a30de687ff3557a10098 /libsolidity/analysis
parentc13b5280c1b44f18a2a1fb61ef5556e91c5678e7 (diff)
downloaddexon-solidity-f112377dd44e8281bff092639bb546ec8a6a39ac.tar.gz
dexon-solidity-f112377dd44e8281bff092639bb546ec8a6a39ac.tar.zst
dexon-solidity-f112377dd44e8281bff092639bb546ec8a6a39ac.zip
Refactor `solidity::Token` into an `enum class` with `TokenTraits` helper namespace
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/ConstantEvaluator.cpp4
-rw-r--r--libsolidity/analysis/SemVerHandler.cpp4
-rw-r--r--libsolidity/analysis/SemVerHandler.h8
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp14
5 files changed, 16 insertions, 16 deletions
diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp
index 8659bbfd..f9b00927 100644
--- a/libsolidity/analysis/ConstantEvaluator.cpp
+++ b/libsolidity/analysis/ConstantEvaluator.cpp
@@ -46,7 +46,7 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation)
m_errorReporter.fatalTypeError(
_operation.location(),
"Operator " +
- string(Token::toString(_operation.getOperator())) +
+ string(TokenTraits::toString(_operation.getOperator())) +
" not compatible with types " +
left->toString() +
" and " +
@@ -54,7 +54,7 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation)
);
setType(
_operation,
- Token::isCompareOp(_operation.getOperator()) ?
+ TokenTraits::isCompareOp(_operation.getOperator()) ?
make_shared<BoolType>() :
commonType
);
diff --git a/libsolidity/analysis/SemVerHandler.cpp b/libsolidity/analysis/SemVerHandler.cpp
index 29f6d5de..64fa17b3 100644
--- a/libsolidity/analysis/SemVerHandler.cpp
+++ b/libsolidity/analysis/SemVerHandler.cpp
@@ -199,7 +199,7 @@ void SemVerMatchExpressionParser::parseMatchExpression()
SemVerMatchExpression::MatchComponent SemVerMatchExpressionParser::parseMatchComponent()
{
SemVerMatchExpression::MatchComponent component;
- Token::Value token = currentToken();
+ Token token = currentToken();
switch (token)
{
@@ -280,7 +280,7 @@ char SemVerMatchExpressionParser::nextChar()
return currentChar();
}
-Token::Value SemVerMatchExpressionParser::currentToken() const
+Token SemVerMatchExpressionParser::currentToken() const
{
if (m_pos < m_tokens.size())
return m_tokens[m_pos];
diff --git a/libsolidity/analysis/SemVerHandler.h b/libsolidity/analysis/SemVerHandler.h
index 76b70c5b..03a557c5 100644
--- a/libsolidity/analysis/SemVerHandler.h
+++ b/libsolidity/analysis/SemVerHandler.h
@@ -61,7 +61,7 @@ struct SemVerMatchExpression
struct MatchComponent
{
/// Prefix from < > <= >= ~ ^
- Token::Value prefix = Token::Illegal;
+ Token prefix = Token::Illegal;
/// Version, where unsigned(-1) in major, minor or patch denotes '*', 'x' or 'X'
SemVerVersion version;
/// Whether we have 1, 1.2 or 1.2.4
@@ -81,7 +81,7 @@ struct SemVerMatchExpression
class SemVerMatchExpressionParser
{
public:
- SemVerMatchExpressionParser(std::vector<Token::Value> const& _tokens, std::vector<std::string> const& _literals):
+ SemVerMatchExpressionParser(std::vector<Token> const& _tokens, std::vector<std::string> const& _literals):
m_tokens(_tokens), m_literals(_literals)
{}
SemVerMatchExpression parse();
@@ -95,10 +95,10 @@ private:
char currentChar() const;
char nextChar();
- Token::Value currentToken() const;
+ Token currentToken() const;
void nextToken();
- std::vector<Token::Value> m_tokens;
+ std::vector<Token> m_tokens;
std::vector<std::string> m_literals;
unsigned m_pos = 0;
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index ab544388..3f9f8373 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -106,7 +106,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
}
else if (_pragma.literals()[0] == "solidity")
{
- vector<Token::Value> tokens(_pragma.tokens().begin() + 1, _pragma.tokens().end());
+ vector<Token> tokens(_pragma.tokens().begin() + 1, _pragma.tokens().end());
vector<string> literals(_pragma.literals().begin() + 1, _pragma.literals().end());
SemVerMatchExpressionParser parser(tokens, literals);
auto matchExpression = parser.parse();
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 3830935f..3774cf86 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1499,14 +1499,14 @@ bool TypeChecker::visit(Assignment const& _assignment)
// compound assignment
_assignment.rightHandSide().accept(*this);
TypePointer resultType = t->binaryOperatorResult(
- Token::AssignmentToBinaryOp(_assignment.assignmentOperator()),
+ TokenTraits::AssignmentToBinaryOp(_assignment.assignmentOperator()),
type(_assignment.rightHandSide())
);
if (!resultType || *resultType != *t)
m_errorReporter.typeError(
_assignment.location(),
"Operator " +
- string(Token::toString(_assignment.assignmentOperator())) +
+ string(TokenTraits::toString(_assignment.assignmentOperator())) +
" not compatible with types " +
t->toString() +
" and " +
@@ -1607,8 +1607,8 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
bool TypeChecker::visit(UnaryOperation const& _operation)
{
// Inc, Dec, Add, Sub, Not, BitNot, Delete
- Token::Value op = _operation.getOperator();
- bool const modifying = (op == Token::Value::Inc || op == Token::Value::Dec || op == Token::Value::Delete);
+ Token op = _operation.getOperator();
+ bool const modifying = (op == Token::Inc || op == Token::Dec || op == Token::Delete);
if (modifying)
requireLValue(_operation.subExpression());
else
@@ -1620,7 +1620,7 @@ bool TypeChecker::visit(UnaryOperation const& _operation)
m_errorReporter.typeError(
_operation.location(),
"Unary operator " +
- string(Token::toString(op)) +
+ string(TokenTraits::toString(op)) +
" cannot be applied to type " +
subExprType->toString()
);
@@ -1641,7 +1641,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
m_errorReporter.typeError(
_operation.location(),
"Operator " +
- string(Token::toString(_operation.getOperator())) +
+ string(TokenTraits::toString(_operation.getOperator())) +
" not compatible with types " +
leftType->toString() +
" and " +
@@ -1651,7 +1651,7 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
}
_operation.annotation().commonType = commonType;
_operation.annotation().type =
- Token::isCompareOp(_operation.getOperator()) ?
+ TokenTraits::isCompareOp(_operation.getOperator()) ?
make_shared<BoolType>() :
commonType;
_operation.annotation().isPure =