How wren-lang/wren works
Wren is an embeddable, class-based scripting language with a single-pass compiler, bytecode VM, core library, and lightweight fibers. Its principal workflow is a host embedding the C API, supplying or compiling Wren modules, and executing them in the VM. The graph also preserves value/heap management, core primitives, debugging, and optional meta/random modules. Some internal connections are based on the source index or README rather than complete source excerpts; those limits are reflected by omitting uncertain links.
Main entry points: wren_vm.c VM Interpreter · wren.h C Embedding API · wren_compiler.c Single-Pass Compiler · wren_core.c Core Classes
Components 13
Embedding
- C Embedding API
src/include/wren.h - Module Callbacks
src/include/wren.h
Language Runtime
- Single-Pass Compiler
src/vm/wren_compiler.c - Bytecode Opcodes
src/vm/wren_opcodes.h - VM Interpreter
src/vm/wren_vm.c - Values and Objects
src/vm/wren_value.c
Built-in Library
- Core Classes
src/vm/wren_core.c - Primitive Methods
src/vm/wren_primitive.c - Meta Module
src/optional/wren_opt_meta.c - Random Module
src/optional/wren_opt_random.c
Runtime Support
- Errors and Debugging
src/vm/wren_debug.c - Allocation Utilities
src/vm/wren_utils.c
Other components
- Host Application
Connections 14
- Host Application → C Embedding API: embeds through
README.md - Host Application → Module Callbacks: provides callbacks
src/include/wren.h - C Embedding API → VM Interpreter: configures and invokes
src/vm/wren_vm.c - VM Interpreter → Single-Pass Compiler: compiles modules
src/vm/wren_vm.c - Single-Pass Compiler → Bytecode Opcodes: emits instructions
src/vm/wren_compiler.c - VM Interpreter → Bytecode Opcodes: dispatches instructions
src/vm/wren_vm.c - VM Interpreter → Values and Objects: manages runtime values
src/vm/wren_vm.c - Core Classes → Primitive Methods: binds primitives
src/vm/wren_core.c - VM Interpreter → Core Classes: initializes core
- VM Interpreter → Module Callbacks: loads modules
src/vm/wren_vm.c - VM Interpreter → Meta Module: loads optional module
src/vm/wren_vm.c - VM Interpreter → Random Module: loads optional module
src/vm/wren_vm.c - VM Interpreter → Errors and Debugging: reports runtime errors
- VM Interpreter → Allocation Utilities: allocates runtime memory