Skip to main content

sim_lib_lang_islisp/
profile.rs

1use sim_kernel::{Cx, Ref, Result, Symbol};
2use sim_lib_standard_core::{
3    FidelityBadge, LanguageProfile, OrganUse, ProfileBackingLib, ProfileRegistry,
4    install_language_profile,
5};
6
7use crate::{
8    islisp_conformance_test_symbol, islisp_dispatch_fidelity_symbol, islisp_lowering_symbol,
9    islisp_profile_symbol, islisp_reader_symbol,
10};
11
12/// Builds the [`LanguageProfile`] describing the ISLISP surface profile.
13///
14/// Wires the ISLISP reader, lowering, eval policy, numeric tower, dispatch
15/// organ, and conformance fidelity badge as data; it describes the profile but
16/// installs nothing on its own.
17pub fn islisp_profile() -> LanguageProfile {
18    let profile = islisp_profile_symbol();
19    let test = islisp_conformance_test_symbol();
20    LanguageProfile::new(profile.clone())
21        .with_reader(islisp_reader_symbol())
22        .with_lowering(islisp_lowering_symbol())
23        .with_eval_policy(Symbol::qualified("eval", "islisp-core"))
24        .with_organ(OrganUse::new(sim_lib_dispatch::dispatch_organ_symbol()))
25        .with_numeric_tower(Symbol::qualified("numbers", "islisp-core"))
26        .with_conformance_test(test.clone())
27        .with_fidelity_badge(FidelityBadge::new(
28            Ref::Symbol(profile),
29            islisp_dispatch_fidelity_symbol(),
30            1,
31            Ref::Symbol(test),
32        ))
33}
34
35/// Installs the ISLISP profile and its dispatch-organ claims into a registry.
36///
37/// First-reach entry point: registers [`islisp_profile`] through the standard
38/// profile installer so the surface becomes loadable.
39///
40/// # Examples
41///
42/// ```
43/// use std::sync::Arc;
44/// use sim_kernel::{Cx, DefaultFactory, NoopEvalPolicy};
45/// use sim_lib_standard_core::ProfileRegistry;
46/// use sim_lib_lang_islisp::install_islisp_profile;
47/// use sim_kernel::Symbol;
48///
49/// let mut cx = Cx::new(Arc::new(NoopEvalPolicy), Arc::new(DefaultFactory));
50/// let mut registry = ProfileRegistry::new();
51/// let profile = install_islisp_profile(&mut cx, &mut registry).unwrap();
52/// assert!(profile.backing_requirements.contains(&Symbol::qualified("sim", "dispatch")));
53/// ```
54pub fn install_islisp_profile(
55    cx: &mut Cx,
56    registry: &mut ProfileRegistry,
57) -> Result<LanguageProfile> {
58    install_language_profile(
59        cx,
60        registry,
61        islisp_profile(),
62        &[ProfileBackingLib::unresolved(
63            sim_lib_dispatch::dispatch_organ_symbol(),
64            Symbol::qualified("sim", "dispatch"),
65        )],
66        &[],
67    )
68}