How codenirccc/rsharp works
R# is an AOT systems-language compiler: users compile .rsx source into an executable, with a Rust front end producing editable s-expression IR and a native-code back end emitting PE32+ or Mach-O images. The graph also preserves the documented package manager (cdc) and editor integrations as distinct capabilities. The supplied tree omits the documented OCaml backend, driver, and most editor files, so those runtime links are documented rather than attributed to unseen implementations; the visible RHIR crate is a separate IR/code-generation subsystem.
Main entry points: lib.rs RHIR build API · manifest.rs Manifest handling · main.rs Rust front end · mem2reg.rs Memory promotion
Components 34
R# compiler
- Rust front end
frontend/src/main.rs - Lexer
frontend/src/lexer.rs - Parser and checks
frontend/src/parser.rs - Language AST
frontend/src/ast.rs - IR serializer
frontend/src/sexpr.rs - S-expression IR
- OCaml back end
- Native executable
RHIR compiler
- RHIR build API
rhir/src/lib.rs - IR text parser
rhir/src/text.rs - RHIR representation
rhir/src/ir.rs - IR optimization
rhir/src/opt.rs - Memory promotion
rhir/src/mem2reg.rs - Control-flow analysis
rhir/src/cfg.rs - Dominators
rhir/src/dom.rs - Machine IR
rhir/src/mir.rs - Instruction selection
rhir/src/isel.rs - Register allocation
rhir/src/regalloc.rs - Code emission
rhir/src/emit.rs - PE image writer
rhir/src/pe.rs
Package management
- cdc command
cdc/src/main.rs - Project and build
cdc/src/project.rs - Manifest handling
cdc/src/manifest.rs - Dependency resolution
cdc/src/resolve.rs - Package registry
cdc/src/registry.rs - Lockfile
cdc/src/lock.rs - Version ranges
cdc/src/semver.rs - JSON codec
cdc/src/json.rs - Filesystem utilities
cdc/src/fsutil.rs - SHA-256
cdc/src/sha256.rs
Editor integrations
- VS Code integration
editors/vscode/package.json - Editor diagnostics check
editors/check.js
Other components
- Language user
- Package developer
Connections 40
- Language user → Rust front end: compiles source
- Rust front end → Lexer: tokenizes
frontend/src/main.rs - Rust front end → Parser and checks: parses
frontend/src/main.rs - Parser and checks → Lexer: reads tokens
frontend/src/parser.rs - Parser and checks → Language AST: builds AST
frontend/src/parser.rs - Rust front end → IR serializer: serializes IR
frontend/src/main.rs - IR serializer → Language AST: encodes
frontend/src/sexpr.rs - IR serializer → S-expression IR: writes
- S-expression IR → OCaml back end: feeds IR
- OCaml back end → Native executable: emits image
- RHIR build API → IR text parser: parses text
rhir/src/lib.rs - IR text parser → RHIR representation: builds IR
rhir/src/text.rs - RHIR build API → RHIR representation: builds module
rhir/src/lib.rs - RHIR build API → IR optimization: optimizes functions
rhir/src/lib.rs - IR optimization → Memory promotion: promotes memory
rhir/src/opt.rs - Memory promotion → Control-flow analysis: uses CFG
rhir/src/mem2reg.rs - Memory promotion → Dominators: uses dominators
rhir/src/mem2reg.rs - Memory promotion → RHIR representation: rewrites IR
rhir/src/mem2reg.rs - RHIR build API → Instruction selection: selects instructions
rhir/src/lib.rs - Instruction selection → Machine IR: builds machine IR
rhir/src/isel.rs - RHIR build API → Code emission: emits code
rhir/src/lib.rs - Code emission → Register allocation: uses allocation
rhir/src/emit.rs - Code emission → Machine IR: consumes machine IR
rhir/src/emit.rs - RHIR build API → PE image writer: writes PE image
rhir/src/lib.rs - Package developer → cdc command: manages packages
- cdc command → Project and build: runs project actions
cdc/src/main.rs - Project and build → Manifest handling: loads manifest
cdc/src/project.rs - Project and build → Dependency resolution: resolves dependencies
cdc/src/project.rs - Project and build → Lockfile: uses lockfile
cdc/src/project.rs - Dependency resolution → Package registry: queries packages
cdc/src/resolve.rs - Dependency resolution → Manifest handling: reads requirements
cdc/src/resolve.rs - Package registry → Manifest handling: loads package metadata
cdc/src/registry.rs - Lockfile → JSON codec: encodes data
cdc/src/lock.rs - Manifest handling → JSON codec: parses and writes
cdc/src/manifest.rs - Manifest handling → Version ranges: validates ranges
cdc/src/manifest.rs - Lockfile → Version ranges: stores versions
cdc/src/lock.rs - Package registry → Filesystem utilities: copies packages
cdc/src/registry.rs - Filesystem utilities → SHA-256: hashes files
cdc/src/fsutil.rs - VS Code integration → Editor diagnostics check: configures checks
- Editor diagnostics check → Language user: reports diagnostics