How matz/spinel works
Spinel turns Ruby source into a standalone native executable: it parses the program, builds an in-memory AST model, infers types, generates C, then compiles and links that C with the runtime. The spin project tool adds project scaffolding, dependency management, and build/run/test workflows around the compiler. The README documents the main pipeline; source excerpts and the index support the compiler entry point and runtime/package boundaries. Some implementation details are unsampled, so uncertain internal calls are omitted.
Main entry points: main.c spinel Compiler · spin.rb spin CLI · runtime.h Spinel Runtime · node_table.h Node Table
Components 19
Compiler
- spinel Compiler
src/main.c - Prism Parser
- Node Table
src/node_table.h - Type Analysis
src/analyze_infer.c - RBS Extraction
tools/spinel_rbs_extract.c - C Generation
src/codegen_expr.c
Project Tool
- spin CLI
tools/spin.rb - Project Build Output
Runtime
- Spinel Runtime
lib/spinel/runtime.h - Runtime Helpers
lib/sp_cold.c - Regexp Engine
lib/regexp/re_compile.c
Packages
- Package Sources
packages - JSON Package
packages/json/sp_json.c - OpenSSL Package
packages/openssl/sp_openssl.c
Other components
- Ruby Developer
- Ruby Source
- Generated C
- System C Compiler
- Native Executable
Connections 20
- Ruby Developer → spin CLI: uses
- Ruby Developer → spinel Compiler: invokes
- Ruby Source → spinel Compiler: compiles
- spin CLI → spinel Compiler: drives
- spinel Compiler → Prism Parser: parses with
- Prism Parser → Node Table: produces AST
- spinel Compiler → Node Table: loads AST
src/main.c - Node Table → Type Analysis: analyzes
- RBS Extraction → Type Analysis: seeds types
- Type Analysis → C Generation: shares inferred types
- C Generation → Generated C: emits C
- spinel Compiler → System C Compiler: invokes
- System C Compiler → Native Executable: compiles and links
- System C Compiler → Spinel Runtime: links
- Package Sources → Native Executable: compiled into
- JSON Package → Spinel Runtime: uses ABI
packages/json/sp_json.c - OpenSSL Package → Spinel Runtime: uses ABI
packages/openssl/sp_openssl.c - Runtime Helpers → Spinel Runtime: implements helpers
- spin CLI → Project Build Output: builds projects
- spin CLI → Package Sources: resolves dependencies