How ak47andrew/virtual-console works
Purpose and workspace shape
This is a Rust workspace for a VEA virtual-machine/cartridge ecosystem: assemble VEA source and assets into cartridges, run them in an emulator, launch workflows, and provide editor/language tooling. The top-level workspace is defined by Cargo.toml; shared VM and cartridge contracts live in src/shared/.
Executable entry points
• Compiler CLI: src/compiler/src/main.rs, with orchestration in src/compiler/src/entry.rs.
• Emulator/runtime executable: src/runtime/src/main.rs.
• Launcher executable, including a non-UI mode: src/launcher/src/main.rs, src/launcher/src/nonui.rs.
• Language-server executable: src/lsp/src/main.rs.
• Flowchart generator executable: src/flowchart-gen/src/main.rs.
These are separate crates under src/, coordinated through the workspace rather than a single server or web application.
Shared VM and cartridge contract
src/shared/ is the architectural boundary between producer-side tooling and execution-side runtime. It defines cartridge representation and loading-related primitives in src/shared/src/cartridge.rs, cartridge manifest structures in src/shared/src/manifest.rs, and VM instruction/operand/register definitions in src/shared/src/opcodes.rs, src/shared/src/operand_types.rs, and src/shared/src/registers.rs. Compiler, runtime, and tooling should depend on these definitions rather than duplicate instruction encoding or cartridge semantics.
Compilation pipeline
The compiler accepts VEA assembly plus cartridge resources, parses and validates instructions, then emits the shared cartridge format. Assembly parsing and operand validation are concentrated in src/compiler/src/vea/parsing.rs and src/compiler/src/vea/operand_checking.rs; compiler dispatch/error handling is in src/compiler/src/entry.rs and src/compiler/src/errors.rs. Asset compilation is a distinct stage for images and palettes under src/compiler/src/images/mod.rs and src/compiler/src/palette/mod.rs. Example cartridge inputs establish the expected boundary: examples/example_cartridge/source.vea, examples/example_cartridge/manifest.toml, and examples/example_cartridge/palette.pal.
Runtime execution and debugging
The runtime loads a compiled cartridge and executes its VM program. src/runtime/src/emulator.rs owns instruction execution/control flow, while src/runtime/src/memory.rs represents VM memory behavior and src/runtime/src/debugger.rs supplies debugging integration. Its primary dependency boundary is the shared cartridge, opcode, register, and memory constants model in src/shared/src/.
Developer tooling and documentation
The LSP packages opcode documentation from src/lsp/opcodes/ during its build (src/lsp/build.rs) and serves language functionality from src/lsp/src/main.rs; it should remain aligned with shared opcode definitions. src/flowchart-gen/src/graph.rs provides a separate analysis/visualization path over program control flow. The mdBook documentation under docs/src/ describes the language and VM model, especially docs/src/assembler.md, docs/src/memory.md, and docs/src/opcodes.md.
Main entry points: entry.rs Compile orchestration · main.rs Compiler CLI · opcodes.rs VM ISA contracts · emulator.rs VM emulator
Components 21
Cartridge Inputs
- VEA assembly
examples/example_cartridge/source.vea - Cartridge manifest
examples/example_cartridge/manifest.toml - Palette asset
examples/example_cartridge/palette.pal
Compiler
- Compiler CLI
src/compiler/src/main.rs - Compile orchestration · Coordinates compilation and diagnostics.
src/compiler/src/entry.rs - Assembly parser
src/compiler/src/vea/parsing.rs - Operand validation
src/compiler/src/vea/operand_checking.rs - Image & palette compilation
src/compiler/src/images/mod.rs
Shared Contract
- Cartridge format · Defines cartridge representation and loading primitives.
src/shared/src/cartridge.rs - Manifest contract
src/shared/src/manifest.rs - VM ISA contracts · Opcodes, operands, and registers shared by tools and runtime.
src/shared/src/opcodes.rs
Execution
- Runtime executable
src/runtime/src/main.rs - VM emulator · Executes program instructions and control flow.
src/runtime/src/emulator.rs - VM memory
src/runtime/src/memory.rs - Debugger
src/runtime/src/debugger.rs - Launcher · Supports UI and non-UI launch workflows.
src/launcher/src/main.rs
Tooling & Docs
- Language server
src/lsp/src/main.rs - Opcode documentation package · Packaged into the language server at build time.
- Flowchart generator · Analyzes program control flow.
src/flowchart-gen/src/main.rs - Control-flow analysis
src/flowchart-gen/src/graph.rs - VM & assembler docs
Connections 23
- VEA assembly → Compiler CLI: compile
- Cartridge manifest → Compiler CLI: package metadata
- Palette asset → Compiler CLI: asset
- Compiler CLI → Compile orchestration: invokes
- Compile orchestration → Assembly parser: parses
- Assembly parser → Operand validation: validates operands
- Compile orchestration → Image & palette compilation: compiles assets
- Compile orchestration → Cartridge format: emits
- Compile orchestration → Manifest contract: uses
- Operand validation → VM ISA contracts: checks against
- Cartridge format → Runtime executable: compiled cartridge
- Runtime executable → VM emulator: runs
- VM emulator → VM memory: reads and writes
- VM emulator → Debugger: debug hooks
- VM emulator → VM ISA contracts: executes
- Launcher → Compiler CLI: launches workflow
- Launcher → Runtime executable: launches workflow
- Language server → Opcode documentation package: packages at build
- Language server → VM ISA contracts: aligns with
- Flowchart generator → Control-flow analysis: generates
- Control-flow analysis → VM ISA contracts: interprets control flow
- VM & assembler docs → VM ISA contracts: documents
- VM & assembler docs → Cartridge format: documents