/src/solidity/libsolidity/experimental/analysis/SyntaxRestrictor.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | This file is part of solidity. |
3 | | |
4 | | solidity is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation, either version 3 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | solidity is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU General Public License |
15 | | along with solidity. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | // SPDX-License-Identifier: GPL-3.0 |
18 | | #pragma once |
19 | | |
20 | | #include <libsolidity/ast/ASTVisitor.h> |
21 | | |
22 | | #include <liblangutil/ErrorReporter.h> |
23 | | #include <liblangutil/Exceptions.h> |
24 | | |
25 | | namespace solidity::frontend::experimental |
26 | | { |
27 | | class Analysis; |
28 | | |
29 | | class SyntaxRestrictor: public ASTConstVisitor |
30 | | { |
31 | | public: |
32 | | SyntaxRestrictor(Analysis& _analysis); |
33 | | |
34 | | bool analyze(ASTNode const& _astRoot); |
35 | | |
36 | | private: |
37 | | /// Default visit will reject all AST nodes that are not explicitly allowed. |
38 | | bool visitNode(ASTNode const& _node) override; |
39 | | |
40 | 139 | bool visit(SourceUnit const&) override { return true; } |
41 | 331 | bool visit(PragmaDirective const&) override { return true; } |
42 | 11 | bool visit(ImportDirective const&) override { return true; } |
43 | | bool visit(ContractDefinition const& _contractDefinition) override; |
44 | | bool visit(FunctionDefinition const& _functionDefinition) override; |
45 | 52 | bool visit(ExpressionStatement const&) override { return true; } |
46 | 69 | bool visit(FunctionCall const&) override { return true; } |
47 | 6 | bool visit(Assignment const&) override { return true; } |
48 | 76 | bool visit(Block const&) override { return true; } |
49 | 0 | bool visit(InlineAssembly const&) override { return true; } |
50 | 241 | bool visit(Identifier const&) override { return true; } |
51 | 0 | bool visit(IdentifierPath const&) override { return true; } |
52 | 0 | bool visit(IfStatement const&) override { return true; } |
53 | | bool visit(VariableDeclarationStatement const&) override; |
54 | | bool visit(VariableDeclaration const&) override; |
55 | 0 | bool visit(ElementaryTypeName const&) override { return true; } |
56 | 82 | bool visit(ParameterList const&) override { return true; } |
57 | 0 | bool visit(Return const&) override { return true; } |
58 | 0 | bool visit(MemberAccess const&) override { return true; } |
59 | 9 | bool visit(BinaryOperation const&) override { return true; } |
60 | 0 | bool visit(ElementaryTypeNameExpression const&) override { return true; } |
61 | 14 | bool visit(TupleExpression const&) override { return true; } |
62 | 18 | bool visit(Literal const&) override { return true; } |
63 | | |
64 | | langutil::ErrorReporter& m_errorReporter; |
65 | | }; |
66 | | |
67 | | } |