Expand description
rubylang — Ruby as a fusevm frontend.
Pipeline: lexer → parser builds a Ruby AST → compiler lowers it to a
fusevm::Chunk (plus a table of method/block sub-chunks) → fusevm executes
it, calling back into the host (through registered builtins and the strict
numeric hook) for every Ruby-specific operation. There is no bespoke VM or
JIT here — execution and codegen live in fusevm.
Re-exports§
pub use embed::run_program;
Modules§
- aot
- Ahead-of-time compilation (
ruby --build). - arity_
table - MRI’s declared built-in method shapes — the arity, defining module and parameter list of every method the reference interpreter defines on the core classes.
- ast
- Ruby abstract syntax tree.
- banner
- The REPL banner (shown only for the interactive
ruby --repl, never for script execution). - builtins
- Registered fusevm builtins + the Ruby method/kernel dispatch.
- bundle
- Build-time
requirebundling — the AOT whole-app merge. - cache
- rkyv-backed bytecode cache for compiled Ruby scripts (mirrors
zshrs/elisprs/vimlrs). Versioned from day one so a
.rbthat compiled once never breaks on a later run. - cli
- Command-line interface for the
rubybinary. - compiler
- Lower the Ruby AST to
fusevm::Chunk. - dap
- Debug Adapter Protocol over stdio (
ruby --dap). - embed
- Embedding entry point: run a Ruby program from a host and capture its output.
- encoding_
table - Every encoding MRI defines — name, aliases, dummy / ASCII-compatible
flags, boot-loaded state and
Encoding::constant names — inEncoding.listorder. - erb
- Port of MRI’s
ERB::Compiler(erb 6.0.7,lib/erb/compiler.rb): the scanner family, every trim mode (nil/0,1/">",2/"<>","-", and the"%"line prefix), the magic-comment probe and theBufferthat assembles the Ruby sourceERB#srcanswers andERB#resultevaluates. - host
- The Ruby object heap and runtime, reached from fusevm through registered
builtins (
register_builtin) and the strict numeric hook. - intercepts
- Method-call intercepts (aspect-oriented advice) — a glob-matched registry of before/after/around hooks keyed by method-name pattern.
- lexer
- Ruby lexer.
- lsp
- Language Server Protocol over stdio (
ruby --lsp). - oracle
- Locating the ORACLE — the reference MRI
rubythe differential harnesses compare rubylang against. - parser
- Recursive-descent / precedence-climbing parser for the Ruby subset rubylang
lowers. Produces
Vec<Stmt>. Binary operators use a binding-power table (bp);**and assignment are right-associative. Command (paren-less) calls are recognized when a bare identifier is immediately followed by a token that unambiguously starts an argument. - pp
Kernel#pp/#pretty_inspect: a port of MRI’sprettyprint.rb(the Oppen-style line breaker) and thepretty_printmethodspp.rbdefines for the core classes.- private_
builtins - Which of MRI’s built-in methods are PRIVATE.
- random
- MRI’s pseudo-random number generator, ported from
random.candmissing/mt19937.c(ruby 4.0). - repl
- Interactive REPL for
ruby— utop-style line editor backed byreedline, ported from the strykelang REPL onto the Ruby host. - rstr
- The content of a Ruby String: its bytes and the encoding that reads them —
MRI’s
RString, with the one shortcut that valid UTF-8 is kept as a RustStringso the overwhelmingly common case borrows as&strfor free. - rtime
- Ruby
Time: the value model and the formatting core, ported from MRI’stime.candstrftime.c. - rust_
ffi - Ruby wiring for inline Rust FFI (
rust { ... }blocks). - tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
- unicode_
tables - Unicode character classes, generated by
tools/gen_unicode_tables.rbfrom ruby 4.0.8 (Unicode 17.0.0). Do not edit by hand: regenerate.
Structs§
- RunConfig
- Program-invocation configuration threaded in from the command line:
ARGV,-Iload-path prepends,-rrequires, and the$0script name.
Enums§
- Value
- Core value type — what lives on the stack and in variables.
Constants§
- DEFAULT_
WARN_ LEVEL - The warning level of an interpreter started with no
-w/-W/-vswitch. - RUBY_
COMPAT_ VERSION - The MRI language level rubylang targets — the value reported as
RUBY_VERSIONand inruby --version. Gems test this againstrequired_ruby_version. - RUBY_
ENGINE RUBY_ENGINE— rubylang is its own engine (likejruby/truffleruby), so engine-sniffing code can tell it apart from MRI.- RUBY_
ENGINE_ VERSION RUBY_ENGINE_VERSION— this crate’s own version.
Functions§
- compile
- Compile a source string to a runnable program.
- compile_
debug - Compile with per-statement DAP line markers enabled (
ruby --dap). - eval_
file - Read and run a
.rbfile. Seeds$LOAD_PATH/$LOADED_FEATURESand therequirefile-dir stack with the script’s own directory (MRI seeds the running script’s dir), sorequire/require_relativeresolve against it. - eval_
file_ cfg eval_filewith command-line configuration (-I/-r/ARGV/$0).- eval_
file_ debug - Read and run a
.rbfile under the DAP debugger: compile with per-statement line markers and run with the debug hook installed (ruby --dap). - eval_
str - Parse, compile, load, and run a Ruby source string on a fresh host; return
the value of the last top-level expression.
$LOAD_PATH/$LOADED_FEATURESand therequirefile-dir stack are seeded with the current directory so arequire/require_relativefrom a-eone-liner resolves against it. - eval_
str_ captured - Run Ruby source on a fresh host with
globalsbound and the program’s output captured in-process, returning the program’s outcome alongside everything it wrote. - eval_
str_ cfg eval_strwith command-line configuration: seeds-Iincludes,ARGV/$0, runs-rrequires, then the one-liner.$0/__FILE__default to-e.- eval_
to_ string - Evaluate
srcand return theinspectform of the last expression’s value. The convenience entry point for tests and--eval-style checks. - load_
merged - Merge an already-compiled program onto the current host: rebase its
proc/begin ids above what is already loaded (so ids never collide — see
compiler::rebase_program), install its methods/classes/begins/procs, and return the (rebased) main chunk for the caller to run. Shared by the initial script run, each REPL line, and everyrequire/load. - ruby_
platform - The
RUBY_PLATFORMstring, built from the host arch/OS. - run_
compiled - Run an already-compiled program on the current host (rebasing + merging it first, then running its main chunk at the top level).
- version_
banner - The
ruby --version/-vbanner. Starts withruby <X.Y.Z>so tools that parse the version line (rbenv/chruby/bundler) read the compat level, then names the real engine so nothing is misrepresented as MRI.