MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / get_stdlib_modules_for_mode

Function get_stdlib_modules_for_mode

crates/hll-to-ir/src/stdlib.rs:14–35  ·  view source on GitHub ↗

Return the stdlib as a list of (`module_name`, source) tuples for the given mode. This makes it possible to compile each HLL file independently so that `.ir`, `.s` and `.o` artifacts exist per original source file instead of concatenating everything into one big bundle.

(mode: TargetMode)

Source from the content-addressed store, hash-verified

12 let manifest = fs_utils::build_manifest::parse(STDLIB_BUILD).expect("parse stdlib.build");
13 let key = match mode {
14 TargetMode::Hosted => "hosted",
15 TargetMode::Freestanding => "freestanding",
16 TargetMode::Kernel => "kernel",
17 };
18 let entries = manifest
19 .list(key)
20 .expect("parse stdlib module list")
21 .unwrap_or_else(|| panic!("stdlib.build missing `{key}` list"));
22
23 entries
24 .into_iter()
25 .map(|entry| {
26 let (name, source_key) = parse_module_entry(&entry);
27 let source = os_runtime::module_source(source_key)
28 .unwrap_or_else(|| panic!("stdlib.build references unknown module `{source_key}`"));
29 (leak(name), source)
30 })
31 .collect()
32}
33
34/// Repo-relative source path of stdlib module `name` in `mode`, for the
35/// pc-to-source line table. `None` when the module or its path is unknown.
36pub fn stdlib_module_source_path(mode: TargetMode, name: &str) -> Option<&'static str> {
37 let manifest = fs_utils::build_manifest::parse(STDLIB_BUILD).ok()?;
38 let key = match mode {

Calls 5

parse_module_entryFunction · 0.85
leakFunction · 0.85
listMethod · 0.80
collectMethod · 0.80
parseFunction · 0.50