sim_lib_lang_islisp/forms.rs
1use sim_kernel::Symbol;
2
3/// Runtime role a documented ISLISP surface form lowers to.
4///
5/// The kernel owns the codec and dispatch contracts; this enum only labels
6/// which organ surface a given ISLISP defining form targets.
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum IslispFormRole {
9 /// Form that declares an ISLISP class or object recipe.
10 Object,
11 /// Form that declares or extends a generic function.
12 Generic,
13}
14
15/// Documentation record for one ISLISP defining form.
16///
17/// Describes how a surface symbol in the ISLISP profile maps onto the shared
18/// dispatch organ; it carries metadata only, not the lowering behavior itself.
19#[derive(Clone, Debug, PartialEq, Eq)]
20pub struct IslispFormSpec {
21 /// Qualified surface symbol of the form (for example `islisp/defclass`).
22 pub symbol: Symbol,
23 /// Runtime role the form lowers to.
24 pub role: IslispFormRole,
25 /// Organ symbol that supplies the form's behavior.
26 pub organ: Symbol,
27 /// One-line human-readable description of the form.
28 pub doc: &'static str,
29}
30
31/// Returns the documented ISLISP defining forms supported by this profile.
32///
33/// Each entry maps a surface symbol onto the shared dispatch organ; see the
34/// crate README language-profiles section.
35pub fn islisp_form_specs() -> Vec<IslispFormSpec> {
36 vec![
37 IslispFormSpec {
38 symbol: Symbol::qualified("islisp", "defclass"),
39 role: IslispFormRole::Object,
40 organ: sim_lib_dispatch::dispatch_organ_symbol(),
41 doc: "Declare an ISLISP class recipe consumed by generic method shapes.",
42 },
43 IslispFormSpec {
44 symbol: Symbol::qualified("islisp", "defgeneric"),
45 role: IslispFormRole::Generic,
46 organ: sim_lib_dispatch::dispatch_organ_symbol(),
47 doc: "Declare a generic function backed by the shared dispatch organ.",
48 },
49 IslispFormSpec {
50 symbol: Symbol::qualified("islisp", "defmethod"),
51 role: IslispFormRole::Generic,
52 organ: sim_lib_dispatch::dispatch_organ_symbol(),
53 doc: "Attach a primary method to an ISLISP generic through dispatch.",
54 },
55 ]
56}