Skip to main content

Crate kotlinrs

Crate kotlinrs 

Source
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 kotlin binary.
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.StrictMath specifies — and, on the reference JVM, java.lang.Math answers bit-for-bit — for the kotlin.math functions 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’s Regex value.
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 kotlinc checks them, over the written types the parser keeps beside the coarse ones (see TypeExpr).

Constants§

VERSION
Crate version, from Cargo.toml.

Functions§

has_main
True when the source already declares fun main — otherwise a snippet is wrapped as a main body (script mode, used for -e one-liners).
prepare_source
Wrap a bare statement snippet in fun main { … } when it has no main, 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 main if needed (-e mode).
version_banner
One-line version banner (--version).