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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (C) 2019-2025 Provable Inc.
// This file is part of the Leo library.
// The Leo library 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.
// The Leo library 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 the Leo library. If not, see <https://www.gnu.org/licenses/>.
//! A transform pass that resolves and reconstructs AST paths by prefixing them with the current module path.
//!
//! The main goal is to fully qualify all paths by prepending the current module's path segments
//! before semantic analysis is performed. Since semantic information (e.g., symbol resolution)
//! is not yet available at this stage, this pass conservatively prefixes all paths to ensure
//! that references to items (functions, types, constants, structs) are correctly scoped.
//!
//! # Key behaviors:
//! - Composite types have their `resolved_path` set to the concatenation of the current module path and the type's path.
//! - Function call expressions have their function path fully qualified similarly.
//! - Struct initializers have their paths prefixed, and their member expressions recursively reconstructed.
//! - Standalone paths are prefixed as well, accounting for possible global constants.
//!
//! # Note:
//! This pass does not perform full semantic resolution; it prepares the AST paths for later
//! stages by making all paths absolute or fully qualified relative to the current module context.
//!
//! # Example
//!
//! Input (in module `foo`):
//! ```leo
//! struct Bar { x: u32 }
//! const Y: u32 = 1;
//! transition t() { let z = Bar { x: Y }; }
//! ```
//!
//! After `PathResolution`, all relevant paths are qualified with `foo::`:
//! ```leo
//! struct Bar { x: u32 }
//! const Y: u32 = 1;
//! transition t() { let z = foo::Bar { x: foo::Y }; }
//! ```
use cratePass;
use ProgramReconstructor as _;
use Result;
use *;
;