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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! `@require:`/`@import:` name resolution.
//!
//! Transcribed from v0.0.6's `src/frontend/main.ml` (lines ~95-140): a header
//! name is turned into a list of candidate file paths, tried in order; the
//! first candidate that exists on disk wins. We do NOT implement the
//! mode-specific `.satyh-<mode>` extension SATySFi also tries — out of scope
//! here, matching the task's transcription instructions.
use RustyfiVersion;
use ;
/// Extensions tried, in preference order, when a header name has none of its
/// own. `.satyh` (the "normal" library extension) beats `.satyg` (the
/// "governed"/restricted-grammar library extension) — same order as
/// `main.ml`'s candidate list.
pub const CANDIDATE_EXTS: = ;
/// All paths `base/name` could resolve to, without checking existence.
/// Resolve `@import: name` relative to `dir`, the directory of the file that
/// contains the header (NOT the entry document's directory — see main.ml,
/// where imports are resolved relative to the current file being processed,
/// which matters once library files import each other from different
/// subdirectories).
///
/// Returns the first candidate that exists, or `Err` with the full list of
/// paths tried (for `UnresolvedImport::searched`).
pub
/// Resolve `@require: name` against the package/library root.
///
/// v0.0.6's `Config.resolve_package` searches a configurable list of library
/// directories; we approximate that with five fixed candidates under
/// `lib_root`, in order:
/// 1. `<lib_root>/dist/packages/<name>` (the standard SATySFi package
/// layout used by `rustyfi-dist`/opam installs, and this port's own
/// no-manifest flat-copy fallback).
/// 2. `<lib_root>/<name>` (a plain fallback, for a `lib_root` that already
/// points directly at a package tree, e.g. in tests).
/// 3. `<lib_root>/dist/packages/<name>/<name>` (the *nested* per-library
/// layout real Satyrographos produces and this port's manifest-driven
/// installer materialises).
/// 4. `<lib_root>/dist-v01/packages/<name>` (the 0.1
/// corpus, mirroring candidate 1). This is what lets a `V0_0`-rooted
/// load's `@require:` reach a 0.1 package under
/// `lib-rustyfi/dist-v01/packages/` from the SAME `lib_root` a 0.0.6
/// document also `@require:`s the 0.0.6 corpus from. Ordered LAST for a
/// 0.0.6 load, so it only ever adds resolutions and never changes which
/// candidate wins for a name candidates 1-3 already resolve.
/// 5. `<lib_root>/dist-v01/packages/<name>/<name>` — candidate 3's analogue
/// for the 0.1 corpus. `install --lang 0.1` of a package whose manifest
/// declares `(packageDir ...)`, which is what real Satyrographos packages
/// declare, materialises exactly this nested layout; without this
/// candidate such a package installs successfully and is then
/// unreachable from any `@require:`.
///
/// If `lib_root` is `None`, there is nowhere to search: returns `Err(vec![])`
/// immediately (surfaced by `UnresolvedRequire` as "no candidates").
pub