sim_lib_lang_lua/
profile.rs1use sim_kernel::{Cx, Result, Symbol};
2use sim_lib_standard_core::{
3 LanguageProfile, OrganUse, ProfileBackingLib, ProfileRegistry, fidelity_badge,
4 install_language_profile,
5};
6
7use crate::{
8 lua_conformance_test_symbol, lua_control_fidelity_symbol, lua_eval_policy_symbol,
9 lua_full_runtime_fidelity_symbol, lua_lowering_symbol, lua_mutation_fidelity_symbol,
10 lua_profile_symbol, lua_reader_symbol,
11};
12
13pub fn lua_core_profile() -> LanguageProfile {
20 let profile = lua_profile_symbol();
21 let test = lua_conformance_test_symbol();
22 LanguageProfile::new(profile.clone())
23 .with_reader(lua_reader_symbol())
24 .with_lowering(lua_lowering_symbol())
25 .with_eval_policy(lua_eval_policy_symbol())
26 .with_organ(OrganUse::new(sim_lib_binding::binding_organ_symbol()))
27 .with_organ(OrganUse::new(sim_lib_control::control_organ_symbol()))
28 .with_organ(OrganUse::new(sim_lib_mutation::mutation_organ_symbol()))
29 .with_organ(OrganUse::new(sim_lib_sequence::sequence_organ_symbol()))
30 .with_organ(OrganUse::new(sim_lib_dispatch::dispatch_organ_symbol()))
31 .requiring(sim_lib_mutation::standard_mutate_capability())
32 .with_unsupported_form(Symbol::qualified("lua", "c-api"))
33 .with_unsupported_form(Symbol::qualified("lua", "debug-hooks"))
34 .with_unsupported_form(Symbol::qualified("lua", "string-dump-bytecode"))
35 .with_conformance_test(test.clone())
36 .with_fidelity_badge(fidelity_badge(
37 &profile,
38 lua_control_fidelity_symbol(),
39 1,
40 &test,
41 ))
42 .with_fidelity_badge(fidelity_badge(
43 &profile,
44 lua_mutation_fidelity_symbol(),
45 1,
46 &test,
47 ))
48 .with_fidelity_badge(fidelity_badge(
49 &profile,
50 lua_full_runtime_fidelity_symbol(),
51 1,
52 &test,
53 ))
54}
55
56pub fn install_lua_core_profile(
76 cx: &mut Cx,
77 registry: &mut ProfileRegistry,
78) -> Result<LanguageProfile> {
79 install_language_profile(
80 cx,
81 registry,
82 lua_core_profile(),
83 &[
84 ProfileBackingLib::loadable(
85 sim_lib_binding::binding_organ_symbol(),
86 sim_lib_binding::manifest_name(),
87 sim_lib_binding::install_binding_lib,
88 Some(sim_lib_binding::publish_binding_organ_claims_for_lib),
89 ),
90 ProfileBackingLib::loadable(
91 sim_lib_control::control_organ_symbol(),
92 sim_lib_control::manifest_name(),
93 sim_lib_control::install_control_lib,
94 None,
95 ),
96 ProfileBackingLib::unresolved(
97 sim_lib_mutation::mutation_organ_symbol(),
98 Symbol::qualified("sim", "mutation"),
99 ),
100 ProfileBackingLib::loadable(
101 sim_lib_sequence::sequence_organ_symbol(),
102 sim_lib_sequence::manifest_name(),
103 sim_lib_sequence::install_sequence_lib,
104 Some(sim_lib_sequence::publish_sequence_organ_claims_for_lib),
105 ),
106 ProfileBackingLib::unresolved(
107 sim_lib_dispatch::dispatch_organ_symbol(),
108 Symbol::qualified("sim", "dispatch"),
109 ),
110 ],
111 &[],
112 )
113}
114
115#[cfg(test)]
116mod evidence_tests {
117 use super::*;
118
119 #[test]
120 fn lua_profile_is_complete_guest_evidence() {
121 let evidence = lua_core_profile().checked_guest_evidence().unwrap();
122 assert_eq!(evidence.reader, lua_reader_symbol());
123 assert_eq!(evidence.lowering, lua_lowering_symbol());
124 assert_eq!(evidence.eval_policy, lua_eval_policy_symbol());
125 assert_eq!(evidence.organs.len(), 5);
126 assert_eq!(evidence.capabilities.len(), 1);
127 assert_eq!(evidence.gaps.len(), 3);
128 }
129}