forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASTUtils.h
64 lines (49 loc) · 2.82 KB
/
ASTUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
This file is part of solidity.
solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
solidity is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-3.0
#pragma once
#include <libsolutil/Numeric.h>
namespace solidity::frontend
{
class ASTNode;
class Declaration;
class Expression;
class SourceUnit;
class VariableDeclaration;
class ContractDefinition;
/// Find the topmost referenced constant variable declaration when the given variable
/// declaration value is an identifier. Works only for constant variable declarations.
/// Returns nullptr if an identifier in the chain is not referencing a constant variable declaration.
VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration const& _varDecl);
/// Returns true if the constant variable declaration is recursive.
bool isConstantVariableRecursive(VariableDeclaration const& _varDecl);
/// Returns the innermost AST node that covers the given location or nullptr if not found.
ASTNode const* locateInnermostASTNode(int _offsetInFile, SourceUnit const& _sourceUnit);
/// @returns @a _expr itself, in case it is not a unary tuple expression. Otherwise it descends recursively
/// into unary tuples and returns the contained expression.
Expression const* resolveOuterUnaryTuples(Expression const* _expr);
/// @returns the type of an expression and asserts that it is present.
Type const* type(Expression const& _expression);
/// @returns the type of the given variable and throws if the type is not present
/// (this can happen for variables with non-explicit types before their types are resolved)
Type const* type(VariableDeclaration const& _variable);
/// @returns The number of slots occupied by all state variables in contract's inheritance hierarchy,
/// located in @a _location (either storage or transient storage).
bigint contractStorageSizeUpperBound(ContractDefinition const& _contract, VariableDeclaration::Location _location);
/// @returns The base slot of the inheritance hierarchy rooted at the specified contract.
/// The value comes from the inheritance specifier of the contract and defaults to zero.
/// The value is zero also when the contract is an interface or a library (and cannot have storage).
/// Assumes analysis was successful.
u256 layoutBaseForInheritanceHierarchy(ContractDefinition const& _topLevelContract, DataLocation _location);
}