Skip to main content

Crate gors

Crate gors 

Source
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 banner::version_banner;
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 version banner string.
cli
Command-line parsing for the go binary.
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 import paths to Go source, parse each imported package, and merge everything into one compile unit.
returns
The return-statement rules go enforces at build time: a function with results must end in a terminating statement (“missing return”), and each return must 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 go binary so go-rs is self-contained (no $GOROOT needed at run time). Packages are vendored here once verified to run on go-rs; until then crate::pkg falls back to $GOROOT/src.
tiers
Which fusevm execution tier a program’s bytecode actually reaches.

Functions§

compile
Parse and lower Go src to a runnable fusevm chunk. Imported (non-native) packages are resolved to source, linked in, and compiled together (see pkg) — the standard library is executed, not reimplemented.
disassemble
Compile src and return a human-readable disassembly of the fusevm chunk (for go --disasm).
env_report
go env: the Go environment as go-rs reports it. A curated, deterministic subset (no go toolchain paths — go-rs has no module system).
parse
Parse Go src to an AST. Inline rust { ... } FFI blocks are desugared to __rust_compile(...) statements first (see rust_ffi), so every parse path — run, --dump-ast, --disasm, --dap — sees the same rewritten source. No-op when the source has no rust block.
run_file
Read and run a .go file.
run_str
Compile and run a Go source string; return the last VM value.
vet
go vet: parse and compile src, returning Ok(()) if it is well-formed (no lex/parse/compile error) without running it.