Skip to main content

sim_lib_lang_ruby/
profile.rs

1use sim_kernel::{Cx, Result, Symbol};
2use sim_lib_standard_core::{
3    LanguageProfile, OrganUse, ProfileRegistry, fidelity_badge, install_language_profile,
4};
5
6use crate::{
7    ruby_blocks_fidelity_symbol, ruby_conformance_test_symbol, ruby_control_fidelity_symbol,
8    ruby_dispatch_fidelity_symbol, ruby_lowering_symbol, ruby_profile_symbol, ruby_reader_symbol,
9};
10
11/// Builds the [`LanguageProfile`] describing the Ruby DSL surface profile.
12///
13/// Reuses the shared algol reader, wires Ruby lowering and eval policy, draws on
14/// the control and dispatch organs, marks the full object model as unsupported,
15/// and publishes honest fidelity badges (control and dispatch supported, full
16/// blocks limited).
17pub fn ruby_dsl_profile() -> LanguageProfile {
18    let profile = ruby_profile_symbol();
19    let test = ruby_conformance_test_symbol();
20    LanguageProfile::new(profile.clone())
21        .with_reader(ruby_reader_symbol())
22        .with_lowering(ruby_lowering_symbol())
23        .with_eval_policy(Symbol::qualified("eval", "ruby-dsl"))
24        .with_organ(OrganUse::new(sim_lib_control::control_organ_symbol()))
25        .with_organ(OrganUse::new(sim_lib_dispatch::dispatch_organ_symbol()))
26        .with_unsupported_form(Symbol::qualified("ruby", "full-object-model"))
27        .with_conformance_test(test.clone())
28        .with_fidelity_badge(fidelity_badge(
29            &profile,
30            ruby_control_fidelity_symbol(),
31            1,
32            &test,
33        ))
34        .with_fidelity_badge(fidelity_badge(
35            &profile,
36            ruby_dispatch_fidelity_symbol(),
37            1,
38            &test,
39        ))
40        .with_fidelity_badge(fidelity_badge(
41            &profile,
42            ruby_blocks_fidelity_symbol(),
43            0,
44            &test,
45        ))
46}
47
48/// Installs the Ruby DSL profile and its organ claims into a registry.
49///
50/// First-reach entry point: registers [`ruby_dsl_profile`] through the standard
51/// profile installer, publishing the control- and dispatch-organ claims so the
52/// surface becomes loadable.
53///
54/// # Examples
55///
56/// ```
57/// use std::sync::Arc;
58/// use sim_kernel::{Cx, DefaultFactory, NoopEvalPolicy, Symbol};
59/// use sim_lib_standard_core::ProfileRegistry;
60/// use sim_lib_lang_ruby::install_ruby_dsl_profile;
61///
62/// let mut cx = Cx::new(Arc::new(NoopEvalPolicy), Arc::new(DefaultFactory));
63/// let mut registry = ProfileRegistry::new();
64/// let profile = install_ruby_dsl_profile(&mut cx, &mut registry).unwrap();
65/// assert_eq!(profile.reader, Symbol::qualified("codec", "algol"));
66/// ```
67pub fn install_ruby_dsl_profile(
68    cx: &mut Cx,
69    registry: &mut ProfileRegistry,
70) -> Result<LanguageProfile> {
71    install_language_profile(
72        cx,
73        registry,
74        ruby_dsl_profile(),
75        &[
76            sim_lib_control::publish_control_organ_claims_for_lib,
77            sim_lib_dispatch::publish_dispatch_organ_claims_for_lib,
78        ],
79    )
80}