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