Skip to main content

Crate rubylang

Crate rubylang 

Source
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 require bundling — the AOT whole-app merge.
cache
rkyv-backed bytecode cache for compiled Ruby scripts (mirrors zshrs/elisprs/vimlrs). Versioned from day one so a .rb that compiled once never breaks on a later run.
cli
Command-line interface for the ruby binary.
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 — in Encoding.list order.
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 the Buffer that assembles the Ruby source ERB#src answers and ERB#result evaluates.
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 ruby the 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’s prettyprint.rb (the Oppen-style line breaker) and the pretty_print methods pp.rb defines 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.c and missing/mt19937.c (ruby 4.0).
repl
Interactive REPL for ruby — utop-style line editor backed by reedline, 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 Rust String so the overwhelmingly common case borrows as &str for free.
rtime
Ruby Time: the value model and the formatting core, ported from MRI’s time.c and strftime.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.rb from 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, -I load-path prepends, -r requires, and the $0 script 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/-v switch.
RUBY_COMPAT_VERSION
The MRI language level rubylang targets — the value reported as RUBY_VERSION and in ruby --version. Gems test this against required_ruby_version.
RUBY_ENGINE
RUBY_ENGINE — rubylang is its own engine (like jruby/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 .rb file. Seeds $LOAD_PATH/$LOADED_FEATURES and the require file-dir stack with the script’s own directory (MRI seeds the running script’s dir), so require/require_relative resolve against it.
eval_file_cfg
eval_file with command-line configuration (-I/-r/ARGV/$0).
eval_file_debug
Read and run a .rb file 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_FEATURES and the require file-dir stack are seeded with the current directory so a require/require_relative from a -e one-liner resolves against it.
eval_str_captured
Run Ruby source on a fresh host with globals bound and the program’s output captured in-process, returning the program’s outcome alongside everything it wrote.
eval_str_cfg
eval_str with command-line configuration: seeds -I includes, ARGV/$0, runs -r requires, then the one-liner. $0/__FILE__ default to -e.
eval_to_string
Evaluate src and return the inspect form 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 every require/load.
ruby_platform
The RUBY_PLATFORM string, 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 / -v banner. Starts with ruby <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.