LayerScript is an experimental, bare-metal systems programming language designed for hyper-aggressive optimization. Rather than translating sequential code directly into instructions, LayerScript models your program as a Partially Ordered Multiset (POMSET) of traces subject to logical constraints. If a value or operation does not affect the program's Observability Boundary, the compiler is free to compile it away, dissolve it into registers, or fold it entirely at compile-time.
Explore the technical details of the LayerScript Language:
- Complete Gameplan ⭐ UPDATED — now split into per-phase files
- Glossary
- Syntax and Grammar
- Base and Compound Types
- Variables and Hooks
- Control Flow and Statements
- Functions and Procedures
- First-Class Types and Generics
- Layer System
- Modules and Namespaces ⭐ NEW
- Traits and Operator Overloading ⭐ NEW
- Pattern Matching ⭐ NEW
- Compiler Implementation
- Codebase Navigation
- Codebase Reference ⭐ NEW — file-by-file, code-grounded
- Parser and Lexer
- Elaboration and Constraints
- Observability and Trace Folding
- Type Checking and Inference
// 1. Bit-Precise and Refined Types
var age: u32 = 25; // Unsigned 32-bit scalar
var mut delta: i8 = -1; // Signed 8-bit mutable scalar
var flags: b16 = 0xFFFF; // Raw 16-bit vector
// Refined parameters: Index must be mathematically proven < length N
function safe_read<T, N: usize>(arr: T*, idx: usize where idx < N) -> T {
return arr[idx]; // Compiles with zero bounds-checking!
}
// 2. Types as First-Class Values
function IntOrFloat(is_float: bool) -> type {
match is_float {
true => return f32,
false => return i32,
}
}
var value: IntOrFloat(true) = 1.5;
// 3. Variable Hooks
var health: f64 = 100.0 {
on_change: function(new, old) -> f64 {
if new < 0 { return 0; }
return new;
}
}
// 4. Hardware Mapping
packed struct RegisterState {
rax: b64,
rbx: b64,
}
graph TD
A[LayerScript Language] --> B[Language Spec]
A --> C[Type System]
A --> D[Compiler]
A --> E[Execution]
A --> F[Bare Metal]
A --> G[API/Stdlib]
A --> H[Glossary]
B --> B1[Syntax]
B --> B2[Types]
B --> B3[Variables + Hooks]
B --> B4[Control Flow]
B --> B5[Functions]
B --> B6[Layer System]
B --> B7[Modules + Namespaces]
B --> B8[Traits + Overloading]
B --> B9[Pattern Matching]
C --> C1[Coercions]
C --> C2[Refined Types]
C --> C3[Type Storage + Inheritance]
D --> D1[Parser/Lexer]
D --> D2[Constraints/Z3]
D --> D3[Observability]
D --> D4[Type Checking]
E --> E1[POMSET]
E --> E2[layertrace]
E --> E3[Hooks Runtime]
F --> F1[Havoc]
F --> F2[Interrupt]
F --> F3[Memory Layout]
F --> F4[FFI]
G --> G1[Core Library]
G --> G2[Runtime API]
G --> G3[Built-in Types]
G --> G4[CLI Reference]