Expand description
kotlinrs — Kotlin as a fusevm frontend.
The library lexes and parses a Kotlin subset (lexer, parser), lowers
it to a fusevm::Chunk (compiler), and runs it on the shared bytecode VM
with a small Kotlin extension handler (host). There is no VM or JIT here:
arithmetic, comparison, control flow, locals, and calls are native fusevm
ops, so the engine’s three-tier Cranelift JIT can trace hot loops.
let out = kotlinrs::run("fun main() { println(6 * 7) }");
assert!(out.is_ok());Re-exports§
pub use embed::run_program;
Modules§
- ast
- Abstract syntax tree for the supported Kotlin subset.
- cli
- Command-line parsing for the
kotlinbinary. - compiler
- Lower the Kotlin AST to a
fusevm::Chunk. - dap
- Debug Adapter Protocol over stdio (
kotlin --dap). - embed
- Embedding entry point: run a Kotlin program from Rust with a given stdin and get its stdout back as a string.
- fdlibm
- Ports of the fdlibm routines
java.lang.StrictMathspecifies — and, on the reference JVM,java.lang.Mathanswers bit-for-bit — for thekotlin.mathfunctions that delegate to them. Each is a line-for-line transliteration of the C original (Sun fdlibm 5.3), so every intermediate rounding matches. - host
- Kotlin-specific runtime hooks reached through fusevm’s extension-op dispatch.
- lexer
- Hand-written Kotlin lexer.
- lsp
- Language Server Protocol over stdio (
kotlin --lsp). - parser
- Recursive-descent parser for the Kotlin subset.
- regex
kotlin.text.Regex— the matching engine behind the heap’sRegexvalue.- runtime
- Drive a Kotlin source string through the pipeline: parse → lower to a
fusevm::Chunk→ run on a fresh VM with the Kotlin extension handler installed. - rust_
ffi - Kotlin wiring for inline Rust FFI (
rust { ... }blocks). - tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
- token
- Token stream for the Kotlin frontend.
- unicode_
jdk - Character-class tables measured from the reference JVM.
- variance
- Declaration-site and use-site variance, checked the way
kotlincchecks them, over the written types the parser keeps beside the coarse ones (seeTypeExpr).
Constants§
- VERSION
- Crate version, from
Cargo.toml.
Functions§
- has_
main - True when the source already declares
fun main— otherwise a snippet is wrapped as amainbody (script mode, used for-eone-liners). - prepare_
source - Wrap a bare statement snippet in
fun main { … }when it has nomain, so-e 'println(1)'runs like a script. - run
- Compile and run a full Kotlin source string (must contain
fun main). - run_
snippet - Compile and run a snippet, wrapping it in
mainif needed (-emode). - version_
banner - One-line version banner (
--version).