Expand description
go-rs — Go as a fusevm frontend.
Pipeline: lexer (with Go automatic semicolon insertion) → parser builds a
Go 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 Go’s + string-concatenation overload and string
ordering. There is no bespoke VM and no Go runtime here — execution and
codegen live in fusevm, the same engine behind zshrs, strykelang, awkrs,
vimlrs, elisprs, rubylang, javars, kotlinrs, and scalars.
Re-exports§
pub use embed::run_program;
Modules§
- aot_
native - Native AOT for go-rs via
fusevm::aot(go build). - ast
- The Go abstract syntax tree go-rs parses into and lowers from.
- banner
- The
go versionbanner string. - cli
- Command-line parsing for the
gobinary. - compiler
- Lower the Go AST to a
fusevm::Chunk. - dap
- Debug Adapter Protocol over stdio (
go --dap). - embed
- Run a Go program from Rust with a given stdin and get its stdout back.
- escape
- A small escape analysis over the Go AST.
- host
- Host builtins and the strict numeric hook for go-rs.
- lexer
- A hand-written Go lexer with automatic semicolon insertion (ASI).
- lsp
- Language Server Protocol over stdio (
go --lsp). - parser
- A recursive-descent parser for the slice-1 Go grammar.
- pkg
- Multi-package linking: resolve
importpaths to Go source, parse each imported package, and merge everything into one compile unit. - returns
- The return-statement rules
goenforces at build time: a function with results must end in a terminating statement (“missing return”), and eachreturnmust supply as many values as the function has results. - rust_
ffi - Go wiring for inline Rust FFI (
rust { ... }blocks). - scope
- Block scoping for local variables.
- stdlib_
vendor - Vendored Go standard-library source, embedded in the
gobinary so go-rs is self-contained (no$GOROOTneeded at run time). Packages are vendored here once verified to run on go-rs; until thencrate::pkgfalls back to$GOROOT/src. - tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
Functions§
- compile
- Parse and lower Go
srcto a runnable fusevm chunk. Imported (non-native) packages are resolved to source, linked in, and compiled together (seepkg) — the standard library is executed, not reimplemented. - disassemble
- Compile
srcand return a human-readable disassembly of the fusevm chunk (forgo --disasm). - env_
report go env: the Go environment as go-rs reports it. A curated, deterministic subset (nogotoolchain paths — go-rs has no module system).- parse
- Parse Go
srcto an AST. Inlinerust { ... }FFI blocks are desugared to__rust_compile(...)statements first (seerust_ffi), so every parse path — run,--dump-ast,--disasm,--dap— sees the same rewritten source. No-op when the source has norustblock. - run_
file - Read and run a
.gofile. - run_str
- Compile and run a Go source string; return the last VM value.
- vet
go vet: parse and compilesrc, returningOk(())if it is well-formed (no lex/parse/compile error) without running it.