/src/solidity/libsolidity/ast/ASTForward.h
Line | Count | Source |
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 | | /** |
19 | | * @author Christian <c@ethdev.com> |
20 | | * @date 2014 |
21 | | * Forward-declarations of AST classes. |
22 | | */ |
23 | | |
24 | | #pragma once |
25 | | |
26 | | #include <memory> |
27 | | #include <string> |
28 | | #include <vector> |
29 | | |
30 | | // Forward-declare all AST node types and related enums. |
31 | | |
32 | | namespace solidity::langutil |
33 | | { |
34 | | enum class Token : unsigned int; |
35 | | } |
36 | | |
37 | | namespace solidity::frontend |
38 | | { |
39 | | |
40 | | class ASTNode; |
41 | | class ScopeOpener; |
42 | | class SourceUnit; |
43 | | class PragmaDirective; |
44 | | class ImportDirective; |
45 | | class Declaration; |
46 | | class CallableDeclaration; |
47 | | class OverrideSpecifier; |
48 | | class ContractDefinition; |
49 | | class InheritanceSpecifier; |
50 | | class UsingForDirective; |
51 | | class StructDefinition; |
52 | | class EnumDefinition; |
53 | | class EnumValue; |
54 | | class UserDefinedValueTypeDefinition; |
55 | | class ParameterList; |
56 | | class FunctionDefinition; |
57 | | class VariableDeclaration; |
58 | | class ModifierDefinition; |
59 | | class ModifierInvocation; |
60 | | class EventDefinition; |
61 | | class ErrorDefinition; |
62 | | class MagicVariableDeclaration; |
63 | | class TypeName; |
64 | | class ElementaryTypeName; |
65 | | class UserDefinedTypeName; |
66 | | class FunctionTypeName; |
67 | | class Mapping; |
68 | | class ArrayTypeName; |
69 | | class InlineAssembly; |
70 | | class Statement; |
71 | | class Block; |
72 | | class PlaceholderStatement; |
73 | | class IfStatement; |
74 | | class TryCatchClause; |
75 | | class TryStatement; |
76 | | class BreakableStatement; |
77 | | class WhileStatement; |
78 | | class ForStatement; |
79 | | class Continue; |
80 | | class Break; |
81 | | class Return; |
82 | | class Throw; |
83 | | class EmitStatement; |
84 | | class VariableDeclarationStatement; |
85 | | class ExpressionStatement; |
86 | | class Expression; |
87 | | class Conditional; |
88 | | class Assignment; |
89 | | class TupleExpression; |
90 | | class UnaryOperation; |
91 | | class BinaryOperation; |
92 | | class FunctionCall; |
93 | | class NewExpression; |
94 | | class MemberAccess; |
95 | | class IndexAccess; |
96 | | class PrimaryExpression; |
97 | | class Identifier; |
98 | | class ElementaryTypeNameExpression; |
99 | | class Literal; |
100 | | class StructuredDocumentation; |
101 | | class StorageLayoutSpecifier; |
102 | | |
103 | | /// Experimental Solidity nodes |
104 | | /// @{ |
105 | | class TypeClassDefinition; |
106 | | class TypeClassInstantiation; |
107 | | class TypeClassName; |
108 | | class TypeDefinition; |
109 | | class Builtin; |
110 | | class ForAllQuantifier; |
111 | | /// @} |
112 | | |
113 | | class VariableScope; |
114 | | |
115 | | template <class T> |
116 | | struct ASTCompareByID |
117 | | { |
118 | | using is_transparent = void; |
119 | | |
120 | | bool operator()(T const* _lhs, T const* _rhs) const |
121 | 213k | { |
122 | 213k | return _lhs->id() < _rhs->id(); |
123 | 213k | } solidity::frontend::ASTCompareByID<solidity::frontend::ContractDefinition>::operator()(solidity::frontend::ContractDefinition const*, solidity::frontend::ContractDefinition const*) const Line | Count | Source | 121 | 23.2k | { | 122 | 23.2k | return _lhs->id() < _rhs->id(); | 123 | 23.2k | } |
solidity::frontend::ASTCompareByID<solidity::frontend::ASTNode>::operator()(solidity::frontend::ASTNode const*, solidity::frontend::ASTNode const*) const Line | Count | Source | 121 | 186k | { | 122 | 186k | return _lhs->id() < _rhs->id(); | 123 | 186k | } |
solidity::frontend::ASTCompareByID<solidity::frontend::FunctionCall>::operator()(solidity::frontend::FunctionCall const*, solidity::frontend::FunctionCall const*) const Line | Count | Source | 121 | 3.14k | { | 122 | 3.14k | return _lhs->id() < _rhs->id(); | 123 | 3.14k | } |
solidity::frontend::ASTCompareByID<solidity::frontend::FunctionDefinition>::operator()(solidity::frontend::FunctionDefinition const*, solidity::frontend::FunctionDefinition const*) const Line | Count | Source | 121 | 228 | { | 122 | 228 | return _lhs->id() < _rhs->id(); | 123 | 228 | } |
Unexecuted instantiation: solidity::frontend::ASTCompareByID<solidity::frontend::TypeClassInstantiation>::operator()(solidity::frontend::TypeClassInstantiation const*, solidity::frontend::TypeClassInstantiation const*) const |
124 | | bool operator()(T const* _lhs, int64_t _rhs) const |
125 | | { |
126 | | return _lhs->id() < _rhs; |
127 | | } |
128 | | bool operator()(int64_t _lhs, T const* _rhs) const |
129 | | { |
130 | | return _lhs < _rhs->id(); |
131 | | } |
132 | | }; |
133 | | |
134 | | // Used as pointers to AST nodes, to be replaced by more clever pointers, e.g. pointers which do |
135 | | // not do reference counting but point to a special memory area that is completely released |
136 | | // explicitly. |
137 | | template <class T> |
138 | | using ASTPointer = std::shared_ptr<T>; |
139 | | |
140 | | using ASTString = std::string; |
141 | | |
142 | | } |