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
//! Go wiring for inline Rust FFI (`rust { ... }` blocks).
//!
//! The heavy lifting lives in fusevm: [`fusevm::RustSugar`] scans and rewrites
//! the block at the source level, and `fusevm::ffi` compiles / loads / marshals
//! it. This module only supplies the Go-flavored [`fusevm::RustSugar`] config
//! and the desugar entry [`crate::parse`] calls before lexing. The emitted
//! `__rust_compile(...)` call and every exported bareword are resolved in
//! [`crate::compiler`] (the `GFFI_COMPILE` / `GFFI_CALL` builtins) and executed
//! by [`crate::host`].
//!
//! A `rust { ... }` block appears as a statement inside a function body; the
//! desugar replaces it in place with a `__rust_compile("<base64>", <line>);`
//! statement. The explicit trailing `;` is a valid Go empty-safe terminator (Go
//! usually omits it via automatic semicolon insertion, but tolerates it), so the
//! parser sees an ordinary expression statement.
use RustSugar;
/// Emit the Go statement a `rust { ... }` block desugars to: a call to the
/// `__rust_compile` builtin carrying the base64-encoded block body and its line,
/// terminated by `;`. base64's alphabet (`A-Za-z0-9+/=`) has no `"` or `\`, so
/// it needs no escaping inside the double-quoted Go string literal.
/// Go desugar config. Line comments are `//`, block comments `/* */`.
/// `newline_boundary` is `true` so a `rust { ... }` block starting a statement
/// line is recognized; `{`/`}`/`;` are boundaries too.
pub const SUGAR: RustSugar = RustSugar ;
/// Rewrite every `rust { ... }` block in Go source into a `__rust_compile(...)`
/// statement, before lexing. No-op when the source has no `rust` token.