Expand description
scalars — Scala as a fusevm frontend.
Pipeline: lexer → parser builds a Scala AST → compiler lowers it to a
fusevm::Chunk → fusevm executes it on the shared three-tier Cranelift JIT,
calling back into host (the strict numeric hook) for Scala’s String +
overload. There is no bespoke VM or JVM here — execution and codegen live in
fusevm, the same engine behind zshrs, stryke, awkrs, elisp, and ruby.
Re-exports§
pub use embed::run_program;
Modules§
- ast
- The Scala AST scalars parses and lowers to fusevm bytecode.
- banner
- The
scala --versionbanner string. - bigdec
scala.math.BigDecimal—java.math.BigDecimalunderMathContext.DECIMAL128.- cli
- Command-line parsing for the
scalabinary. - compiler
- Lower the Scala AST to a
fusevm::Chunk. - corpus
- The language-reference corpus: the
(name, chapter, doc, signature+example)table behind editor completion, editor hover (src/lsp.rs) and the generateddocs/reference.html(src/bin/gen_docs.rs). - dap
- Debug Adapter Protocol over stdio (
scala --dap). - embed
- Embedding entry point: run a Scala program from Rust with a given stdin and get its stdout back as a string.
- fdlibm
java.lang.StrictMath: fdlibm 5.3, as the JDK transliterates it injava.lang.FdLibm(JDK 21).- host
- The scalars host: builtin registration, Scala value formatting, and the strict numeric hook.
- jlocale
java.util.Locale’s identity, text forms and English display names, ported from JDK 21:java.util.Locale, andsun.util.locale’sBaseLocale,LanguageTag,InternalLocaleBuilder,LocaleExtensionsandUnicodeLocaleExtension.- jrandom
java.util.Random— the 48-bit linear congruential generator behind bothjava.util.Randomandscala.util.Random(which delegates to it). A seeded generator reproduces the JVM’s sequence exactly; the derived draws (nextInt(bound),nextDouble,nextGaussian) are ports of the JDK algorithms, andbetween/nextLong(n)/shuffleare ports ofscala.util.Randomin the 2.13 library, which Scala 3 runs on.- lexer
- A hand-written Scala lexer with newline inference.
- locale_
names - The English display names
java.util.Localeanswers through the JDK’s locale data — whatgetDisplayLanguage/getDisplayScript/getDisplayCountry/getDisplayVariantand the Unicode extension names ingetDisplayNameproduce in an English display locale. - lsp
- Language Server Protocol over stdio (
scala --lsp). - parser
- A recursive-descent parser with precedence-climbing for expressions.
- rbtree
scala.collection.immutable.RedBlackTree, ported from the Scala 3.10 library (scala/collection/immutable/RedBlackTree.scala) — the storage of an immutableTreeSet/TreeMap.- resolve
- Lexical scoping: unique renaming of
defs and shadowed bindings, plus lambda lifting. - rust_
ffi - Scala wiring for inline Rust FFI (
rust { ... }blocks). - tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
- timsort
- The two stable sorts a Scala program’s comparisons run through, ported so
the comparator is asked exactly what the JVM asks it — in the same order,
the same number of times. An
Ordering.by(f)runsfonce per operand of every comparison and asortWithpredicate is a user closure, so both the count and the sequence are observable.
Functions§
- compile
- Parse and lower Scala
srcto a runnable fusevm chunk. - compile_
debug - Parse and lower Scala
srcwith per-statementDBG_LINEmarkers (forscala --dap). - disassemble
- Compile
srcand return a human-readable disassembly of the fusevm chunk (forscala --disasm). - eval_
file_ debug - Read and run a
.scalafile under the debug marker path (forscala --dap). - parse
- Parse Scala
srcto an AST. - run_
file - Read and run a
.scalafile. - run_str
- Compile and run a Scala source string; return the last VM value.
- run_
str_ with_ args - Run a Scala source string with the program arguments a
def main’sargsparameter and a@mainmethod’s parameters read from.