use sim_kernel::{Cx, Result, Symbol};
use sim_lib_standard_core::{
LanguageProfile, OrganUse, ProfileBackingLib, ProfileRegistry, fidelity_badge,
install_language_profile,
};
use crate::{
lua_conformance_test_symbol, lua_control_fidelity_symbol, lua_eval_policy_symbol,
lua_full_runtime_fidelity_symbol, lua_lowering_symbol, lua_mutation_fidelity_symbol,
lua_profile_symbol, lua_reader_symbol,
};
pub fn lua_core_profile() -> LanguageProfile {
let profile = lua_profile_symbol();
let test = lua_conformance_test_symbol();
LanguageProfile::new(profile.clone())
.with_reader(lua_reader_symbol())
.with_lowering(lua_lowering_symbol())
.with_eval_policy(lua_eval_policy_symbol())
.with_organ(OrganUse::new(sim_lib_binding::binding_organ_symbol()))
.with_organ(OrganUse::new(sim_lib_control::control_organ_symbol()))
.with_organ(OrganUse::new(sim_lib_mutation::mutation_organ_symbol()))
.with_organ(OrganUse::new(sim_lib_sequence::sequence_organ_symbol()))
.with_organ(OrganUse::new(sim_lib_dispatch::dispatch_organ_symbol()))
.requiring(sim_lib_mutation::standard_mutate_capability())
.with_unsupported_form(Symbol::qualified("lua", "c-api"))
.with_unsupported_form(Symbol::qualified("lua", "debug-hooks"))
.with_unsupported_form(Symbol::qualified("lua", "string-dump-bytecode"))
.with_conformance_test(test.clone())
.with_fidelity_badge(fidelity_badge(
&profile,
lua_control_fidelity_symbol(),
1,
&test,
))
.with_fidelity_badge(fidelity_badge(
&profile,
lua_mutation_fidelity_symbol(),
1,
&test,
))
.with_fidelity_badge(fidelity_badge(
&profile,
lua_full_runtime_fidelity_symbol(),
1,
&test,
))
}
pub fn install_lua_core_profile(
cx: &mut Cx,
registry: &mut ProfileRegistry,
) -> Result<LanguageProfile> {
install_language_profile(
cx,
registry,
lua_core_profile(),
&[
ProfileBackingLib::loadable(
sim_lib_binding::binding_organ_symbol(),
sim_lib_binding::manifest_name(),
sim_lib_binding::install_binding_lib,
Some(sim_lib_binding::publish_binding_organ_claims_for_lib),
),
ProfileBackingLib::loadable(
sim_lib_control::control_organ_symbol(),
sim_lib_control::manifest_name(),
sim_lib_control::install_control_lib,
None,
),
ProfileBackingLib::unresolved(
sim_lib_mutation::mutation_organ_symbol(),
Symbol::qualified("sim", "mutation"),
),
ProfileBackingLib::loadable(
sim_lib_sequence::sequence_organ_symbol(),
sim_lib_sequence::manifest_name(),
sim_lib_sequence::install_sequence_lib,
Some(sim_lib_sequence::publish_sequence_organ_claims_for_lib),
),
ProfileBackingLib::unresolved(
sim_lib_dispatch::dispatch_organ_symbol(),
Symbol::qualified("sim", "dispatch"),
),
],
&[],
)
}