/src/solidity/liblangutil/DebugData.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 | | #pragma once |
20 | | |
21 | | #include <liblangutil/SourceLocation.h> |
22 | | #include <optional> |
23 | | #include <memory> |
24 | | |
25 | | namespace solidity::langutil |
26 | | { |
27 | | |
28 | | struct DebugData |
29 | | { |
30 | | typedef typename std::shared_ptr<DebugData const> ConstPtr; |
31 | | |
32 | | explicit DebugData( |
33 | | langutil::SourceLocation _nativeLocation = {}, |
34 | | langutil::SourceLocation _originLocation = {}, |
35 | | std::optional<int64_t> _astID = {} |
36 | | ): |
37 | | nativeLocation(std::move(_nativeLocation)), |
38 | | originLocation(std::move(_originLocation)), |
39 | | astID(_astID) |
40 | 51.7M | {} |
41 | | |
42 | | static DebugData::ConstPtr create( |
43 | | langutil::SourceLocation _nativeLocation, |
44 | | langutil::SourceLocation _originLocation = {}, |
45 | | std::optional<int64_t> _astID = {} |
46 | | ) |
47 | 51.7M | { |
48 | 51.7M | return std::make_shared<DebugData>( |
49 | 51.7M | std::move(_nativeLocation), |
50 | 51.7M | std::move(_originLocation), |
51 | 51.7M | _astID |
52 | 51.7M | ); |
53 | 51.7M | } |
54 | | |
55 | | static DebugData::ConstPtr create() |
56 | 380M | { |
57 | 380M | static DebugData::ConstPtr emptyDebugData = create({}); |
58 | 380M | return emptyDebugData; |
59 | 380M | } |
60 | | |
61 | | /// Location in the Yul code. |
62 | | langutil::SourceLocation nativeLocation; |
63 | | /// Location in the original source that the Yul code was produced from. |
64 | | /// Optional. Only present if the Yul source contains location annotations. |
65 | | langutil::SourceLocation originLocation; |
66 | | /// ID in the (Solidity) source AST. |
67 | | std::optional<int64_t> astID; |
68 | | }; |
69 | | |
70 | | } // namespace solidity::langutil |