1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! elisp wiring for inline Rust FFI (`rust { ... }` blocks).
//!
//! A `rust { ... }` block is not valid s-expression syntax, so it is rewritten
//! at the raw source level — BEFORE the reader runs — into an ordinary elisp
//! call `(__rust-compile "<b64>" LINE)`. The reader, compiler, and VM only ever
//! see that call; it dispatches to [`fusevm::ffi`] (compile the block to a
//! cdylib, `dlopen` it, register every `pub extern "C"` export). Each exported
//! function is then callable by bareword — `(add 21 21)` — resolved in
//! [`crate::host::call_function`]'s `void-function` fallback (a user `defun`
//! still shadows it).
//!
//! The heavy lifting (scan/rewrite, compile, marshal) lives in fusevm; this
//! module only supplies the elisp-flavored [`fusevm::RustSugar`] config and the
//! [`desugar`] entry the execution path calls.
use RustSugar;
/// Emit the elisp form a `rust { ... }` block desugars to: a call to the
/// `__rust-compile` builtin carrying the base64-encoded block body and its
/// source line. `__rust-compile` is a valid elisp symbol (hyphens allowed in
/// symbol names), and the emitted form is valid top-level elisp.
/// elisp desugar config. Comments start with `;`; elisp has no block comment.
/// `newline_boundary` is `true` so a top-level `rust {` on its own line is
/// recognized: `;` line comments are skipped first, `(`/`)` set a non-boundary
/// (fine — a real FFI block sits at top level on its own lines), and the reader
/// would otherwise choke on `{` (elisp has no brace syntax), so a match only
/// ever fires on an intended FFI block.
pub const SUGAR: RustSugar = RustSugar ;
/// Rewrite every top-level `rust { ... }` block in elisp source into a
/// `(__rust-compile ...)` call, before reading. No-op (single substring scan on
/// the fast path) when the source contains no `rust` token.