Gaia Types
The foundational type system and binary utility library for the Gaia project, providing core abstractions for intermediate representation (IR), architecture definitions, and endian-aware binary I/O.
🏛️ Architecture
graph TB
subgraph "Gaia Type System"
A[Gaia Types] --> B[Core Models]
A --> C[Binary Utilities]
A --> D[Error Management]
subgraph "Core Models"
E[Architecture/ABI/API]
F[Compilation Target]
G[Diagnostic System]
end
subgraph "Binary Utilities"
H[Binary Reader/Writer]
I[LEB128 Encoding]
J[Endian Management]
end
B --> E
B --> F
B --> G
C --> H
C --> I
C --> J
end
🚀 Features
Core Capabilities
- Architecture Abstraction: Unified definitions for CPU architectures (X86, ARM, RISC-V), ABIs (SystemV, Win64), and platform APIs (Vulkan, Metal, Win32).
- Endian-Aware I/O: High-performance
BinaryReaderandBinaryWritersupporting both Little-Endian and Big-Endian data processing. - Structured Error Model: A comprehensive
GaiaErrortype with support for source location tracking, diagnostic levels, and specialized error categories (IO, Parse, Backend).
Advanced Features
- Variable-Length Encoding: Optimized implementation of LEB128 (Little Endian Base 128) for compact integer storage in binary formats like DWARF and WebAssembly.
- Diagnostic Framework: Rich diagnostic reporting with
DiagnosticandSourceLocationtypes, compatible with IDE-style error highlighting. - Zero-Copy Primitives: (🚧) Support for memory-mapped binary parsing and zero-copy data structures to maximize throughput.
💻 Usage
Endian-Aware Binary Writing
The following example demonstrates how to use BinaryWriter to encode structured data with specific endianness.
use ;
use Cursor;
Using Architecture Definitions
use ;
🛠️ Support Status
| Category | Feature | Status |
|---|---|---|
| Binary I/O | Little/Big Endian | ✅ Full |
| Binary I/O | LEB128 (Signed/Unsigned) | ✅ Full |
| Models | Architecture Definitions | ✅ Full |
| Models | ABI / API Compatibility | ✅ Full |
| Diagnostics | Source Tracking | ✅ Full |
| Performance | Zero-copy Parsing | 🚧 In Progress |
Legend: ✅ Supported, 🚧 In Progress, ❌ Not Supported
🔗 Relations
- gaia-assembler: Provides the type definitions for the assembler's IR and backend configuration.
- gaia-jit: Supplies the diagnostic and error handling infrastructure for the runtime compiler.
- All Examples: Every assembler example (e.g.,
pe-assembler,wasi-assembler) depends ongaia-typesfor its binary encoding and architectural modeling needs.