How solaeus/dust works
Main Components
a) Frontend (Source Processing):
• Lexer (dust-lang/src/lexer.rs)
• Compiler (dust-lang/src/compiler.rs)
• Type System (dust-lang/src/type.rs)
b) Intermediate Representation:
• Chunk (dust-lang/src/chunk.rs)
• Instructions (dust-lang/src/instruction/)
• Constants and Locals
c) Backend (Execution):
• Virtual Machine (dust-lang/src/vm.rs)
• Value System (dust-lang/src/value/)
• Native Functions (dust-lang/src/native_function/)
Component Relationships
Source Code → Lexer → Tokens → Compiler → Chunk → VM → Program Output
With additional relationships:
• Compiler ↔ Type System (for type checking)
• Compiler → Optimizer (for instruction optimization)
• VM ↔ Native Functions
• VM ↔ Value System
Detailed Component Descriptions
a) Lexer Section:
• Zero-copy token generation
• Source code reference preservation
b) Compiler Section:
• Pratt parser component
• Type checking flow
• Optimization phase
• Chunk generation with:
• Bytecode instructions
• Constants list
• Locals list
c) Virtual Machine Section:
• Register stack
• Instruction execution loop
• Value/pointer handling
• Native function integration
[0-8: OpCode][9-10: Flags][11-13: Local Flags][17-32: Arg1][33-48: Arg2][49-63: Arg3]
Implementation Details to Highlight
• Register-based VM architecture
• Static type checking during compilation
• Zero-copy optimization strategies
• Function compilation into separate chunks
Notes Section
A small notes section mentioning:
• Maximum register count (2^16)
• Constant/local limitations
• Type system constraints
• Performance characteristics
Remember to emphasize the three main processing stages (lexing/parsing, compilation, and execution) while showing how the supporting systems (type checking, optimization, native functions) integrate with these primary components.