|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Common Development Commands |
| 6 | + |
| 7 | +### Building Io |
| 8 | + |
| 9 | +```bash |
| 10 | +# Create build directory (one-time setup) |
| 11 | +mkdir build && cd build |
| 12 | + |
| 13 | +# Configure for development (debug mode) |
| 14 | +cmake .. |
| 15 | + |
| 16 | +# Configure for production (with optimizations) |
| 17 | +cmake -DCMAKE_BUILD_TYPE=release .. |
| 18 | + |
| 19 | +# Build the project |
| 20 | +make |
| 21 | + |
| 22 | +# Install (requires sudo on Unix systems) |
| 23 | +sudo make install |
| 24 | +``` |
| 25 | + |
| 26 | +### Running Tests |
| 27 | + |
| 28 | +```bash |
| 29 | +# Run the main test suite (from build directory) |
| 30 | +io ../libs/iovm/tests/correctness/run.io |
| 31 | + |
| 32 | +# Run a specific test file |
| 33 | +io ../libs/iovm/tests/correctness/<TestName>Test.io |
| 34 | +``` |
| 35 | + |
| 36 | +### Development Workflow |
| 37 | + |
| 38 | +```bash |
| 39 | +# Clean rebuild |
| 40 | +cd build && make clean && make |
| 41 | + |
| 42 | +# Run the Io REPL |
| 43 | +io |
| 44 | + |
| 45 | +# Execute an Io script |
| 46 | +io script.io |
| 47 | +``` |
| 48 | + |
| 49 | +## Architecture Overview |
| 50 | + |
| 51 | +### Core Structure |
| 52 | + |
| 53 | +The Io language is a dynamic, prototype-based programming language implemented in C. The architecture consists of: |
| 54 | + |
| 55 | +1. **Virtual Machine Core** (`libs/iovm/`): The interpreter and runtime system |
| 56 | + - Objects clone from prototypes (no classes) |
| 57 | + - Everything is an object that responds to messages |
| 58 | + - Message passing is the fundamental operation |
| 59 | + - Coroutines provide lightweight concurrency |
| 60 | + |
| 61 | +2. **Foundation Libraries** (`libs/`): |
| 62 | + - `basekit`: Cross-platform C utilities and data structures |
| 63 | + - `coroutine`: Architecture-specific context switching (x86, x86_64, ARM64, PowerPC) |
| 64 | + - `garbagecollector`: Mark-and-sweep garbage collection |
| 65 | + |
| 66 | +3. **Standard Library**: Split between C (`libs/iovm/source/`) and Io (`libs/iovm/io/`) implementations |
| 67 | + - Core objects like IoObject, IoMessage, IoState in C |
| 68 | + - Higher-level functionality in Io for flexibility |
| 69 | + |
| 70 | +### Key Design Patterns |
| 71 | + |
| 72 | +- **Prototype-based OOP**: Objects clone from prototypes rather than instantiating classes |
| 73 | +- **Message Passing**: All operations are messages sent to objects |
| 74 | +- **C Naming Convention**: `IoObjectName_methodName` for C functions |
| 75 | +- **Minimal Core**: Keep VM small, implement features in Io when possible |
| 76 | + |
| 77 | +### Testing Approach |
| 78 | + |
| 79 | +Tests are written in Io using the built-in UnitTest framework. The test runner (`libs/iovm/tests/correctness/run.io`) discovers and executes all test files ending with `Test.io`. |
| 80 | + |
| 81 | +### Build System |
| 82 | + |
| 83 | +CMake-based build system with hierarchical CMakeLists.txt files. Each library manages its own build configuration and dependencies. |
0 commit comments