pub fn install(
sources: &mut SourceMap,
modules: &mut BTreeMap<String, Module>,
) -> Result<(), Vec<Diagnostic>>Expand description
Adds the standard library’s sources to sources and answers the modules
to put in a package.
This must add to the caller’s SourceMap rather than one of its own:
a Span is an offset into whichever SourceMap it was
built against, and a diagnostic built from a span into a different map
than the one rendering it would point at the wrong file entirely. Calling
this is therefore always attach(&mut sources) where sources is the
same map the rest of the package’s units are already in.
Adds the standard library to a package a host is composing.
This is the one call an embedder makes. cove_sema::package::load makes
it for a package read off disk; a host that composes its own — because
its sources are embedded, or generated, or come from somewhere that is
not a directory — makes it itself, and this is the whole of that step:
cove_sema::stdlib::install(sources, modules)?;It is not done inside crate::Compiler::compile, and that is a
decision rather than an omission: what compile is given should be a
package that is already whole, dependencies and all, so that what checks
is what the host assembled. compile refuses a package missing a module
cove_schema::builtins::STANDARD_LIBRARY names — see the diagnostic
cove::compile::missing_stdlib, which says to call this.