diff --git a/libsolidity/ASTJsonConverter.cpp b/libsolidity/ASTJsonConverter.cpp index be89de924..122b1c0d1 100644 --- a/libsolidity/ASTJsonConverter.cpp +++ b/libsolidity/ASTJsonConverter.cpp @@ -151,12 +151,6 @@ bool ASTJsonConverter::visit(Mapping const&) return true; } -bool ASTJsonConverter::visit(Statement const&) -{ - addJsonNode("Statement", {}, true); - return true; -} - bool ASTJsonConverter::visit(Block const&) { addJsonNode("Block", {}, true); @@ -169,11 +163,6 @@ bool ASTJsonConverter::visit(IfStatement const&) return true; } -bool ASTJsonConverter::visit(BreakableStatement const&) -{ - return true; -} - bool ASTJsonConverter::visit(WhileStatement const&) { addJsonNode("WhileStatement", {}, true); @@ -216,17 +205,6 @@ bool ASTJsonConverter::visit(ExpressionStatement const&) return true; } -bool ASTJsonConverter::visit(Expression const& _node) -{ - addJsonNode( - "Expression", - { make_pair("type", getType(_node)), - make_pair("lvalue", boost::lexical_cast(_node.isLValue())) }, - true - ); - return true; -} - bool ASTJsonConverter::visit(Assignment const& _node) { addJsonNode("Assignment", @@ -285,11 +263,6 @@ bool ASTJsonConverter::visit(IndexAccess const& _node) return true; } -bool ASTJsonConverter::visit(PrimaryExpression const&) -{ - return true; -} - bool ASTJsonConverter::visit(Identifier const& _node) { addJsonNode("Identifier", @@ -358,11 +331,6 @@ void ASTJsonConverter::endVisit(Mapping const&) { } -void ASTJsonConverter::endVisit(Statement const&) -{ - goUp(); -} - void ASTJsonConverter::endVisit(Block const&) { goUp(); @@ -373,10 +341,6 @@ void ASTJsonConverter::endVisit(IfStatement const&) goUp(); } -void ASTJsonConverter::endVisit(BreakableStatement const&) -{ -} - void ASTJsonConverter::endVisit(WhileStatement const&) { goUp(); @@ -410,11 +374,6 @@ void ASTJsonConverter::endVisit(ExpressionStatement const&) goUp(); } -void ASTJsonConverter::endVisit(Expression const&) -{ - goUp(); -} - void ASTJsonConverter::endVisit(Assignment const&) { goUp(); @@ -450,10 +409,6 @@ void ASTJsonConverter::endVisit(IndexAccess const&) goUp(); } -void ASTJsonConverter::endVisit(PrimaryExpression const&) -{ -} - void ASTJsonConverter::endVisit(Identifier const&) { } diff --git a/libsolidity/ASTJsonConverter.h b/libsolidity/ASTJsonConverter.h index 56502ab3c..aaa54f7fd 100644 --- a/libsolidity/ASTJsonConverter.h +++ b/libsolidity/ASTJsonConverter.h @@ -56,10 +56,8 @@ public: bool visit(ElementaryTypeName const& _node) override; bool visit(UserDefinedTypeName const& _node) override; bool visit(Mapping const& _node) override; - bool visit(Statement const& _node) override; bool visit(Block const& _node) override; bool visit(IfStatement const& _node) override; - bool visit(BreakableStatement const& _node) override; bool visit(WhileStatement const& _node) override; bool visit(ForStatement const& _node) override; bool visit(Continue const& _node) override; @@ -67,7 +65,6 @@ public: bool visit(Return const& _node) override; bool visit(VariableDeclarationStatement const& _node) override; bool visit(ExpressionStatement const& _node) override; - bool visit(Expression const& _node) override; bool visit(Assignment const& _node) override; bool visit(UnaryOperation const& _node) override; bool visit(BinaryOperation const& _node) override; @@ -75,7 +72,6 @@ public: bool visit(NewExpression const& _node) override; bool visit(MemberAccess const& _node) override; bool visit(IndexAccess const& _node) override; - bool visit(PrimaryExpression const& _node) override; bool visit(Identifier const& _node) override; bool visit(ElementaryTypeNameExpression const& _node) override; bool visit(Literal const& _node) override; @@ -90,10 +86,8 @@ public: void endVisit(ElementaryTypeName const&) override; void endVisit(UserDefinedTypeName const&) override; void endVisit(Mapping const&) override; - void endVisit(Statement const&) override; void endVisit(Block const&) override; void endVisit(IfStatement const&) override; - void endVisit(BreakableStatement const&) override; void endVisit(WhileStatement const&) override; void endVisit(ForStatement const&) override; void endVisit(Continue const&) override; @@ -101,7 +95,6 @@ public: void endVisit(Return const&) override; void endVisit(VariableDeclarationStatement const&) override; void endVisit(ExpressionStatement const&) override; - void endVisit(Expression const&) override; void endVisit(Assignment const&) override; void endVisit(UnaryOperation const&) override; void endVisit(BinaryOperation const&) override; @@ -109,7 +102,6 @@ public: void endVisit(NewExpression const&) override; void endVisit(MemberAccess const&) override; void endVisit(IndexAccess const&) override; - void endVisit(PrimaryExpression const&) override; void endVisit(Identifier const&) override; void endVisit(ElementaryTypeNameExpression const&) override; void endVisit(Literal const&) override; diff --git a/libsolidity/ASTPrinter.cpp b/libsolidity/ASTPrinter.cpp index d0b27b317..713059d38 100644 --- a/libsolidity/ASTPrinter.cpp +++ b/libsolidity/ASTPrinter.cpp @@ -162,13 +162,6 @@ bool ASTPrinter::visit(ArrayTypeName const& _node) return goDeeper(); } -bool ASTPrinter::visit(Statement const& _node) -{ - writeLine("Statement"); - printSourcePart(_node); - return goDeeper(); -} - bool ASTPrinter::visit(Block const& _node) { writeLine("Block"); @@ -190,13 +183,6 @@ bool ASTPrinter::visit(IfStatement const& _node) return goDeeper(); } -bool ASTPrinter::visit(BreakableStatement const& _node) -{ - writeLine("BreakableStatement"); - printSourcePart(_node); - return goDeeper(); -} - bool ASTPrinter::visit(WhileStatement const& _node) { writeLine("WhileStatement"); @@ -246,14 +232,6 @@ bool ASTPrinter::visit(ExpressionStatement const& _node) return goDeeper(); } -bool ASTPrinter::visit(Expression const& _node) -{ - writeLine("Expression"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - bool ASTPrinter::visit(Assignment const& _node) { writeLine(string("Assignment using operator ") + Token::toString(_node.getAssignmentOperator())); @@ -311,14 +289,6 @@ bool ASTPrinter::visit(IndexAccess const& _node) return goDeeper(); } -bool ASTPrinter::visit(PrimaryExpression const& _node) -{ - writeLine("PrimaryExpression"); - printType(_node); - printSourcePart(_node); - return goDeeper(); -} - bool ASTPrinter::visit(Identifier const& _node) { writeLine(string("Identifier ") + _node.getName()); @@ -431,11 +401,6 @@ void ASTPrinter::endVisit(ArrayTypeName const&) m_indentation--; } -void ASTPrinter::endVisit(Statement const&) -{ - m_indentation--; -} - void ASTPrinter::endVisit(Block const&) { m_indentation--; @@ -451,11 +416,6 @@ void ASTPrinter::endVisit(IfStatement const&) m_indentation--; } -void ASTPrinter::endVisit(BreakableStatement const&) -{ - m_indentation--; -} - void ASTPrinter::endVisit(WhileStatement const&) { m_indentation--; @@ -491,11 +451,6 @@ void ASTPrinter::endVisit(ExpressionStatement const&) m_indentation--; } -void ASTPrinter::endVisit(Expression const&) -{ - m_indentation--; -} - void ASTPrinter::endVisit(Assignment const&) { m_indentation--; @@ -531,11 +486,6 @@ void ASTPrinter::endVisit(IndexAccess const&) m_indentation--; } -void ASTPrinter::endVisit(PrimaryExpression const&) -{ - m_indentation--; -} - void ASTPrinter::endVisit(Identifier const&) { m_indentation--; diff --git a/libsolidity/ASTPrinter.h b/libsolidity/ASTPrinter.h index a1797383c..9494bf8cb 100644 --- a/libsolidity/ASTPrinter.h +++ b/libsolidity/ASTPrinter.h @@ -59,11 +59,9 @@ public: bool visit(UserDefinedTypeName const& _node) override; bool visit(Mapping const& _node) override; bool visit(ArrayTypeName const& _node) override; - bool visit(Statement const& _node) override; bool visit(Block const& _node) override; bool visit(PlaceholderStatement const& _node) override; bool visit(IfStatement const& _node) override; - bool visit(BreakableStatement const& _node) override; bool visit(WhileStatement const& _node) override; bool visit(ForStatement const& _node) override; bool visit(Continue const& _node) override; @@ -71,7 +69,6 @@ public: bool visit(Return const& _node) override; bool visit(VariableDeclarationStatement const& _node) override; bool visit(ExpressionStatement const& _node) override; - bool visit(Expression const& _node) override; bool visit(Assignment const& _node) override; bool visit(UnaryOperation const& _node) override; bool visit(BinaryOperation const& _node) override; @@ -79,7 +76,6 @@ public: bool visit(NewExpression const& _node) override; bool visit(MemberAccess const& _node) override; bool visit(IndexAccess const& _node) override; - bool visit(PrimaryExpression const& _node) override; bool visit(Identifier const& _node) override; bool visit(ElementaryTypeNameExpression const& _node) override; bool visit(Literal const& _node) override; @@ -101,11 +97,9 @@ public: void endVisit(UserDefinedTypeName const&) override; void endVisit(Mapping const&) override; void endVisit(ArrayTypeName const&) override; - void endVisit(Statement const&) override; void endVisit(Block const&) override; void endVisit(PlaceholderStatement const&) override; void endVisit(IfStatement const&) override; - void endVisit(BreakableStatement const&) override; void endVisit(WhileStatement const&) override; void endVisit(ForStatement const&) override; void endVisit(Continue const&) override; @@ -113,7 +107,6 @@ public: void endVisit(Return const&) override; void endVisit(VariableDeclarationStatement const&) override; void endVisit(ExpressionStatement const&) override; - void endVisit(Expression const&) override; void endVisit(Assignment const&) override; void endVisit(UnaryOperation const&) override; void endVisit(BinaryOperation const&) override; @@ -121,7 +114,6 @@ public: void endVisit(NewExpression const&) override; void endVisit(MemberAccess const&) override; void endVisit(IndexAccess const&) override; - void endVisit(PrimaryExpression const&) override; void endVisit(Identifier const&) override; void endVisit(ElementaryTypeNameExpression const&) override; void endVisit(Literal const&) override; diff --git a/libsolidity/ASTVisitor.h b/libsolidity/ASTVisitor.h index 3eeb9c456..ec22bd443 100644 --- a/libsolidity/ASTVisitor.h +++ b/libsolidity/ASTVisitor.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include namespace dev { @@ -41,185 +41,181 @@ namespace solidity class ASTVisitor { public: - virtual bool visit(ASTNode&) { return true; } - virtual bool visit(SourceUnit&) { return true; } - virtual bool visit(ImportDirective&) { return true; } - virtual bool visit(ContractDefinition&) { return true; } - virtual bool visit(InheritanceSpecifier&) { return true; } - virtual bool visit(StructDefinition&) { return true; } - virtual bool visit(EnumDefinition&) { return true; } - virtual bool visit(EnumValue&) { return true; } - virtual bool visit(ParameterList&) { return true; } - virtual bool visit(FunctionDefinition&) { return true; } - virtual bool visit(VariableDeclaration&) { return true; } - virtual bool visit(ModifierDefinition&) { return true; } - virtual bool visit(ModifierInvocation&) { return true; } - virtual bool visit(EventDefinition&) { return true; } - virtual bool visit(TypeName&) { return true; } - virtual bool visit(ElementaryTypeName&) { return true; } - virtual bool visit(UserDefinedTypeName&) { return true; } - virtual bool visit(Mapping&) { return true; } - virtual bool visit(ArrayTypeName&) { return true; } - virtual bool visit(Statement&) { return true; } - virtual bool visit(Block&) { return true; } - virtual bool visit(PlaceholderStatement&) { return true; } - virtual bool visit(IfStatement&) { return true; } - virtual bool visit(BreakableStatement&) { return true; } - virtual bool visit(WhileStatement&) { return true; } - virtual bool visit(ForStatement&) { return true; } - virtual bool visit(Continue&) { return true; } - virtual bool visit(Break&) { return true; } - virtual bool visit(Return&) { return true; } - virtual bool visit(VariableDeclarationStatement&) { return true; } - virtual bool visit(ExpressionStatement&) { return true; } - virtual bool visit(Expression&) { return true; } - virtual bool visit(Assignment&) { return true; } - virtual bool visit(UnaryOperation&) { return true; } - virtual bool visit(BinaryOperation&) { return true; } - virtual bool visit(FunctionCall&) { return true; } - virtual bool visit(NewExpression&) { return true; } - virtual bool visit(MemberAccess&) { return true; } - virtual bool visit(IndexAccess&) { return true; } - virtual bool visit(PrimaryExpression&) { return true; } - virtual bool visit(Identifier&) { return true; } - virtual bool visit(ElementaryTypeNameExpression&) { return true; } - virtual bool visit(Literal&) { return true; } + virtual bool visit(SourceUnit& _node) { return visitNode(_node); } + virtual bool visit(ImportDirective& _node) { return visitNode(_node); } + virtual bool visit(ContractDefinition& _node) { return visitNode(_node); } + virtual bool visit(InheritanceSpecifier& _node) { return visitNode(_node); } + virtual bool visit(StructDefinition& _node) { return visitNode(_node); } + virtual bool visit(EnumDefinition& _node) { return visitNode(_node); } + virtual bool visit(EnumValue& _node) { return visitNode(_node); } + virtual bool visit(ParameterList& _node) { return visitNode(_node); } + virtual bool visit(FunctionDefinition& _node) { return visitNode(_node); } + virtual bool visit(VariableDeclaration& _node) { return visitNode(_node); } + virtual bool visit(ModifierDefinition& _node) { return visitNode(_node); } + virtual bool visit(ModifierInvocation& _node) { return visitNode(_node); } + virtual bool visit(EventDefinition& _node) { return visitNode(_node); } + virtual bool visit(TypeName& _node) { return visitNode(_node); } + virtual bool visit(ElementaryTypeName& _node) { return visitNode(_node); } + virtual bool visit(UserDefinedTypeName& _node) { return visitNode(_node); } + virtual bool visit(Mapping& _node) { return visitNode(_node); } + virtual bool visit(ArrayTypeName& _node) { return visitNode(_node); } + virtual bool visit(Block& _node) { return visitNode(_node); } + virtual bool visit(PlaceholderStatement& _node) { return visitNode(_node); } + virtual bool visit(IfStatement& _node) { return visitNode(_node); } + virtual bool visit(WhileStatement& _node) { return visitNode(_node); } + virtual bool visit(ForStatement& _node) { return visitNode(_node); } + virtual bool visit(Continue& _node) { return visitNode(_node); } + virtual bool visit(Break& _node) { return visitNode(_node); } + virtual bool visit(Return& _node) { return visitNode(_node); } + virtual bool visit(VariableDeclarationStatement& _node) { return visitNode(_node); } + virtual bool visit(ExpressionStatement& _node) { return visitNode(_node); } + virtual bool visit(Assignment& _node) { return visitNode(_node); } + virtual bool visit(UnaryOperation& _node) { return visitNode(_node); } + virtual bool visit(BinaryOperation& _node) { return visitNode(_node); } + virtual bool visit(FunctionCall& _node) { return visitNode(_node); } + virtual bool visit(NewExpression& _node) { return visitNode(_node); } + virtual bool visit(MemberAccess& _node) { return visitNode(_node); } + virtual bool visit(IndexAccess& _node) { return visitNode(_node); } + virtual bool visit(Identifier& _node) { return visitNode(_node); } + virtual bool visit(ElementaryTypeNameExpression& _node) { return visitNode(_node); } + virtual bool visit(Literal& _node) { return visitNode(_node); } - virtual void endVisit(ASTNode&) { } - virtual void endVisit(SourceUnit&) { } - virtual void endVisit(ImportDirective&) { } - virtual void endVisit(ContractDefinition&) { } - virtual void endVisit(InheritanceSpecifier&) { } - virtual void endVisit(StructDefinition&) { } - virtual void endVisit(EnumDefinition&) { } - virtual void endVisit(EnumValue&) { } - virtual void endVisit(ParameterList&) { } - virtual void endVisit(FunctionDefinition&) { } - virtual void endVisit(VariableDeclaration&) { } - virtual void endVisit(ModifierDefinition&) { } - virtual void endVisit(ModifierInvocation&) { } - virtual void endVisit(EventDefinition&) { } - virtual void endVisit(TypeName&) { } - virtual void endVisit(ElementaryTypeName&) { } - virtual void endVisit(UserDefinedTypeName&) { } - virtual void endVisit(Mapping&) { } - virtual void endVisit(ArrayTypeName&) { } - virtual void endVisit(Statement&) { } - virtual void endVisit(Block&) { } - virtual void endVisit(PlaceholderStatement&) { } - virtual void endVisit(IfStatement&) { } - virtual void endVisit(BreakableStatement&) { } - virtual void endVisit(WhileStatement&) { } - virtual void endVisit(ForStatement&) { } - virtual void endVisit(Continue&) { } - virtual void endVisit(Break&) { } - virtual void endVisit(Return&) { } - virtual void endVisit(VariableDeclarationStatement&) { } - virtual void endVisit(ExpressionStatement&) { } - virtual void endVisit(Expression&) { } - virtual void endVisit(Assignment&) { } - virtual void endVisit(UnaryOperation&) { } - virtual void endVisit(BinaryOperation&) { } - virtual void endVisit(FunctionCall&) { } - virtual void endVisit(NewExpression&) { } - virtual void endVisit(MemberAccess&) { } - virtual void endVisit(IndexAccess&) { } - virtual void endVisit(PrimaryExpression&) { } - virtual void endVisit(Identifier&) { } - virtual void endVisit(ElementaryTypeNameExpression&) { } - virtual void endVisit(Literal&) { } + virtual void endVisit(SourceUnit& _node) { endVisitNode(_node); } + virtual void endVisit(ImportDirective& _node) { endVisitNode(_node); } + virtual void endVisit(ContractDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(InheritanceSpecifier& _node) { endVisitNode(_node); } + virtual void endVisit(StructDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(EnumDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(EnumValue& _node) { endVisitNode(_node); } + virtual void endVisit(ParameterList& _node) { endVisitNode(_node); } + virtual void endVisit(FunctionDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(VariableDeclaration& _node) { endVisitNode(_node); } + virtual void endVisit(ModifierDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(ModifierInvocation& _node) { endVisitNode(_node); } + virtual void endVisit(EventDefinition& _node) { endVisitNode(_node); } + virtual void endVisit(TypeName& _node) { endVisitNode(_node); } + virtual void endVisit(ElementaryTypeName& _node) { endVisitNode(_node); } + virtual void endVisit(UserDefinedTypeName& _node) { endVisitNode(_node); } + virtual void endVisit(Mapping& _node) { endVisitNode(_node); } + virtual void endVisit(ArrayTypeName& _node) { endVisitNode(_node); } + virtual void endVisit(Block& _node) { endVisitNode(_node); } + virtual void endVisit(PlaceholderStatement& _node) { endVisitNode(_node); } + virtual void endVisit(IfStatement& _node) { endVisitNode(_node); } + virtual void endVisit(WhileStatement& _node) { endVisitNode(_node); } + virtual void endVisit(ForStatement& _node) { endVisitNode(_node); } + virtual void endVisit(Continue& _node) { endVisitNode(_node); } + virtual void endVisit(Break& _node) { endVisitNode(_node); } + virtual void endVisit(Return& _node) { endVisitNode(_node); } + virtual void endVisit(VariableDeclarationStatement& _node) { endVisitNode(_node); } + virtual void endVisit(ExpressionStatement& _node) { endVisitNode(_node); } + virtual void endVisit(Assignment& _node) { endVisitNode(_node); } + virtual void endVisit(UnaryOperation& _node) { endVisitNode(_node); } + virtual void endVisit(BinaryOperation& _node) { endVisitNode(_node); } + virtual void endVisit(FunctionCall& _node) { endVisitNode(_node); } + virtual void endVisit(NewExpression& _node) { endVisitNode(_node); } + virtual void endVisit(MemberAccess& _node) { endVisitNode(_node); } + virtual void endVisit(IndexAccess& _node) { endVisitNode(_node); } + virtual void endVisit(Identifier& _node) { endVisitNode(_node); } + virtual void endVisit(ElementaryTypeNameExpression& _node) { endVisitNode(_node); } + virtual void endVisit(Literal& _node) { endVisitNode(_node); } + +protected: + /// Generic function called by default for each node, to be overridden by derived classes + /// if behaviour unspecific to a node type is desired. + virtual bool visitNode(ASTNode&) { return true; } + /// Generic function called by default for each node, to be overridden by derived classes + /// if behaviour unspecific to a node type is desired. + virtual void endVisitNode(ASTNode&) { } }; class ASTConstVisitor { public: - virtual bool visit(ASTNode const&) { return true; } - virtual bool visit(SourceUnit const&) { return true; } - virtual bool visit(ImportDirective const&) { return true; } - virtual bool visit(ContractDefinition const&) { return true; } - virtual bool visit(InheritanceSpecifier const&) { return true; } - virtual bool visit(StructDefinition const&) { return true; } - virtual bool visit(EnumDefinition const&) { return true; } - virtual bool visit(EnumValue const&) { return true; } - virtual bool visit(ParameterList const&) { return true; } - virtual bool visit(FunctionDefinition const&) { return true; } - virtual bool visit(VariableDeclaration const&) { return true; } - virtual bool visit(ModifierDefinition const&) { return true; } - virtual bool visit(ModifierInvocation const&) { return true; } - virtual bool visit(EventDefinition const&) { return true; } - virtual bool visit(TypeName const&) { return true; } - virtual bool visit(ElementaryTypeName const&) { return true; } - virtual bool visit(UserDefinedTypeName const&) { return true; } - virtual bool visit(Mapping const&) { return true; } - virtual bool visit(ArrayTypeName const&) { return true; } - virtual bool visit(Statement const&) { return true; } - virtual bool visit(Block const&) { return true; } - virtual bool visit(PlaceholderStatement const&) { return true; } - virtual bool visit(IfStatement const&) { return true; } - virtual bool visit(BreakableStatement const&) { return true; } - virtual bool visit(WhileStatement const&) { return true; } - virtual bool visit(ForStatement const&) { return true; } - virtual bool visit(Continue const&) { return true; } - virtual bool visit(Break const&) { return true; } - virtual bool visit(Return const&) { return true; } - virtual bool visit(VariableDeclarationStatement const&) { return true; } - virtual bool visit(ExpressionStatement const&) { return true; } - virtual bool visit(Expression const&) { return true; } - virtual bool visit(Assignment const&) { return true; } - virtual bool visit(UnaryOperation const&) { return true; } - virtual bool visit(BinaryOperation const&) { return true; } - virtual bool visit(FunctionCall const&) { return true; } - virtual bool visit(NewExpression const&) { return true; } - virtual bool visit(MemberAccess const&) { return true; } - virtual bool visit(IndexAccess const&) { return true; } - virtual bool visit(PrimaryExpression const&) { return true; } - virtual bool visit(Identifier const&) { return true; } - virtual bool visit(ElementaryTypeNameExpression const&) { return true; } - virtual bool visit(Literal const&) { return true; } + virtual bool visit(SourceUnit const& _node) { return visitNode(_node); } + virtual bool visit(ImportDirective const& _node) { return visitNode(_node); } + virtual bool visit(ContractDefinition const& _node) { return visitNode(_node); } + virtual bool visit(InheritanceSpecifier const& _node) { return visitNode(_node); } + virtual bool visit(StructDefinition const& _node) { return visitNode(_node); } + virtual bool visit(EnumDefinition const& _node) { return visitNode(_node); } + virtual bool visit(EnumValue const& _node) { return visitNode(_node); } + virtual bool visit(ParameterList const& _node) { return visitNode(_node); } + virtual bool visit(FunctionDefinition const& _node) { return visitNode(_node); } + virtual bool visit(VariableDeclaration const& _node) { return visitNode(_node); } + virtual bool visit(ModifierDefinition const& _node) { return visitNode(_node); } + virtual bool visit(ModifierInvocation const& _node) { return visitNode(_node); } + virtual bool visit(EventDefinition const& _node) { return visitNode(_node); } + virtual bool visit(TypeName const& _node) { return visitNode(_node); } + virtual bool visit(ElementaryTypeName const& _node) { return visitNode(_node); } + virtual bool visit(UserDefinedTypeName const& _node) { return visitNode(_node); } + virtual bool visit(Mapping const& _node) { return visitNode(_node); } + virtual bool visit(ArrayTypeName const& _node) { return visitNode(_node); } + virtual bool visit(Block const& _node) { return visitNode(_node); } + virtual bool visit(PlaceholderStatement const& _node) { return visitNode(_node); } + virtual bool visit(IfStatement const& _node) { return visitNode(_node); } + virtual bool visit(WhileStatement const& _node) { return visitNode(_node); } + virtual bool visit(ForStatement const& _node) { return visitNode(_node); } + virtual bool visit(Continue const& _node) { return visitNode(_node); } + virtual bool visit(Break const& _node) { return visitNode(_node); } + virtual bool visit(Return const& _node) { return visitNode(_node); } + virtual bool visit(VariableDeclarationStatement const& _node) { return visitNode(_node); } + virtual bool visit(ExpressionStatement const& _node) { return visitNode(_node); } + virtual bool visit(Assignment const& _node) { return visitNode(_node); } + virtual bool visit(UnaryOperation const& _node) { return visitNode(_node); } + virtual bool visit(BinaryOperation const& _node) { return visitNode(_node); } + virtual bool visit(FunctionCall const& _node) { return visitNode(_node); } + virtual bool visit(NewExpression const& _node) { return visitNode(_node); } + virtual bool visit(MemberAccess const& _node) { return visitNode(_node); } + virtual bool visit(IndexAccess const& _node) { return visitNode(_node); } + virtual bool visit(Identifier const& _node) { return visitNode(_node); } + virtual bool visit(ElementaryTypeNameExpression const& _node) { return visitNode(_node); } + virtual bool visit(Literal const& _node) { return visitNode(_node); } + + virtual void endVisit(SourceUnit const& _node) { endVisitNode(_node); } + virtual void endVisit(ImportDirective const& _node) { endVisitNode(_node); } + virtual void endVisit(ContractDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(InheritanceSpecifier const& _node) { endVisitNode(_node); } + virtual void endVisit(StructDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(EnumDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(EnumValue const& _node) { endVisitNode(_node); } + virtual void endVisit(ParameterList const& _node) { endVisitNode(_node); } + virtual void endVisit(FunctionDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(VariableDeclaration const& _node) { endVisitNode(_node); } + virtual void endVisit(ModifierDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(ModifierInvocation const& _node) { endVisitNode(_node); } + virtual void endVisit(EventDefinition const& _node) { endVisitNode(_node); } + virtual void endVisit(TypeName const& _node) { endVisitNode(_node); } + virtual void endVisit(ElementaryTypeName const& _node) { endVisitNode(_node); } + virtual void endVisit(UserDefinedTypeName const& _node) { endVisitNode(_node); } + virtual void endVisit(Mapping const& _node) { endVisitNode(_node); } + virtual void endVisit(ArrayTypeName const& _node) { endVisitNode(_node); } + virtual void endVisit(Block const& _node) { endVisitNode(_node); } + virtual void endVisit(PlaceholderStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(IfStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(WhileStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(ForStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(Continue const& _node) { endVisitNode(_node); } + virtual void endVisit(Break const& _node) { endVisitNode(_node); } + virtual void endVisit(Return const& _node) { endVisitNode(_node); } + virtual void endVisit(VariableDeclarationStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(ExpressionStatement const& _node) { endVisitNode(_node); } + virtual void endVisit(Assignment const& _node) { endVisitNode(_node); } + virtual void endVisit(UnaryOperation const& _node) { endVisitNode(_node); } + virtual void endVisit(BinaryOperation const& _node) { endVisitNode(_node); } + virtual void endVisit(FunctionCall const& _node) { endVisitNode(_node); } + virtual void endVisit(NewExpression const& _node) { endVisitNode(_node); } + virtual void endVisit(MemberAccess const& _node) { endVisitNode(_node); } + virtual void endVisit(IndexAccess const& _node) { endVisitNode(_node); } + virtual void endVisit(Identifier const& _node) { endVisitNode(_node); } + virtual void endVisit(ElementaryTypeNameExpression const& _node) { endVisitNode(_node); } + virtual void endVisit(Literal const& _node) { endVisitNode(_node); } - virtual void endVisit(ASTNode const&) { } - virtual void endVisit(SourceUnit const&) { } - virtual void endVisit(ImportDirective const&) { } - virtual void endVisit(ContractDefinition const&) { } - virtual void endVisit(InheritanceSpecifier const&) { } - virtual void endVisit(StructDefinition const&) { } - virtual void endVisit(EnumDefinition const&) { } - virtual void endVisit(EnumValue const&) { } - virtual void endVisit(ParameterList const&) { } - virtual void endVisit(FunctionDefinition const&) { } - virtual void endVisit(VariableDeclaration const&) { } - virtual void endVisit(ModifierDefinition const&) { } - virtual void endVisit(ModifierInvocation const&) { } - virtual void endVisit(EventDefinition const&) { } - virtual void endVisit(TypeName const&) { } - virtual void endVisit(ElementaryTypeName const&) { } - virtual void endVisit(UserDefinedTypeName const&) { } - virtual void endVisit(Mapping const&) { } - virtual void endVisit(ArrayTypeName const&) { } - virtual void endVisit(Statement const&) { } - virtual void endVisit(Block const&) { } - virtual void endVisit(PlaceholderStatement const&) { } - virtual void endVisit(IfStatement const&) { } - virtual void endVisit(BreakableStatement const&) { } - virtual void endVisit(WhileStatement const&) { } - virtual void endVisit(ForStatement const&) { } - virtual void endVisit(Continue const&) { } - virtual void endVisit(Break const&) { } - virtual void endVisit(Return const&) { } - virtual void endVisit(VariableDeclarationStatement const&) { } - virtual void endVisit(ExpressionStatement const&) { } - virtual void endVisit(Expression const&) { } - virtual void endVisit(Assignment const&) { } - virtual void endVisit(UnaryOperation const&) { } - virtual void endVisit(BinaryOperation const&) { } - virtual void endVisit(FunctionCall const&) { } - virtual void endVisit(NewExpression const&) { } - virtual void endVisit(MemberAccess const&) { } - virtual void endVisit(IndexAccess const&) { } - virtual void endVisit(PrimaryExpression const&) { } - virtual void endVisit(Identifier const&) { } - virtual void endVisit(ElementaryTypeNameExpression const&) { } - virtual void endVisit(Literal const&) { } +protected: + /// Generic function called by default for each node, to be overridden by derived classes + /// if behaviour unspecific to a node type is desired. + virtual bool visitNode(ASTNode const&) { return true; } + /// Generic function called by default for each node, to be overridden by derived classes + /// if behaviour unspecific to a node type is desired. + virtual void endVisitNode(ASTNode const&) { } }; } diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index b2436cfa7..ee631197e 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -50,14 +50,12 @@ public: FirstExpressionExtractor(ASTNode& _node): m_expression(nullptr) { _node.accept(*this); } Expression* getExpression() const { return m_expression; } private: - virtual bool visit(Expression& _expression) override { return checkExpression(_expression); } virtual bool visit(Assignment& _expression) override { return checkExpression(_expression); } virtual bool visit(UnaryOperation& _expression) override { return checkExpression(_expression); } virtual bool visit(BinaryOperation& _expression) override { return checkExpression(_expression); } virtual bool visit(FunctionCall& _expression) override { return checkExpression(_expression); } virtual bool visit(MemberAccess& _expression) override { return checkExpression(_expression); } virtual bool visit(IndexAccess& _expression) override { return checkExpression(_expression); } - virtual bool visit(PrimaryExpression& _expression) override { return checkExpression(_expression); } virtual bool visit(Identifier& _expression) override { return checkExpression(_expression); } virtual bool visit(ElementaryTypeNameExpression& _expression) override { return checkExpression(_expression); } virtual bool visit(Literal& _expression) override { return checkExpression(_expression); }