/src/solidity/libsolidity/ast/ASTEnums.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 | | /** |
19 | | * @date 2017 |
20 | | * Enums for AST classes. |
21 | | */ |
22 | | |
23 | | #pragma once |
24 | | |
25 | | #include <liblangutil/Exceptions.h> |
26 | | #include <libsolidity/ast/ASTForward.h> |
27 | | |
28 | | #include <string> |
29 | | |
30 | | namespace solidity::frontend |
31 | | { |
32 | | |
33 | | /// Possible lookups for function resolving |
34 | | enum class VirtualLookup { Static, Virtual, Super }; |
35 | | |
36 | | // How a function can mutate the EVM state. |
37 | | enum class StateMutability { Pure, View, NonPayable, Payable }; |
38 | | |
39 | | /// Visibility ordered from restricted to unrestricted. |
40 | | enum class Visibility { Default, Private, Internal, Public, External }; |
41 | | |
42 | | enum class Arithmetic { Checked, Wrapping }; |
43 | | |
44 | | inline std::string stateMutabilityToString(StateMutability const& _stateMutability) |
45 | 36.2k | { |
46 | 36.2k | switch (_stateMutability) |
47 | 36.2k | { |
48 | 11.7k | case StateMutability::Pure: |
49 | 11.7k | return "pure"; |
50 | 6.91k | case StateMutability::View: |
51 | 6.91k | return "view"; |
52 | 16.7k | case StateMutability::NonPayable: |
53 | 16.7k | return "nonpayable"; |
54 | 788 | case StateMutability::Payable: |
55 | 788 | return "payable"; |
56 | 0 | default: |
57 | 0 | solAssert(false, "Unknown state mutability."); |
58 | 36.2k | } |
59 | 36.2k | } |
60 | | |
61 | | class Type; |
62 | | |
63 | | /// Container for function call parameter types & names |
64 | | struct FuncCallArguments |
65 | | { |
66 | | /// Types of arguments |
67 | | std::vector<Type const*> types; |
68 | | /// Names of the arguments if given, otherwise unset |
69 | | std::vector<ASTPointer<ASTString>> names; |
70 | | |
71 | 10.1k | size_t numArguments() const { return types.size(); } |
72 | 407 | size_t numNames() const { return names.size(); } |
73 | 3.51k | bool hasNamedArguments() const { return !names.empty(); } |
74 | | }; |
75 | | |
76 | | enum class ContractKind { Interface, Contract, Library }; |
77 | | |
78 | | } |