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
stateMutabilityToString(StateMutability const & _stateMutability)44 inline std::string stateMutabilityToString(StateMutability const& _stateMutability)
45 {
46 switch (_stateMutability)
47 {
48 case StateMutability::Pure:
49 return "pure";
50 case StateMutability::View:
51 return "view";
52 case StateMutability::NonPayable:
53 return "nonpayable";
54 case StateMutability::Payable:
55 return "payable";
56 default:
57 solAssert(false, "Unknown state mutability.");
58 }
59 }
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
numArgumentsFuncCallArguments71 size_t numArguments() const { return types.size(); }
numNamesFuncCallArguments72 size_t numNames() const { return names.size(); }
hasNamedArgumentsFuncCallArguments73 bool hasNamedArguments() const { return !names.empty(); }
74 };
75
76 enum class ContractKind { Interface, Contract, Library };
77
78 }
79