cli: bootstrap verified std bytes and math with source imports

This commit is contained in:
dev committed 2026-10-06 14:51:10 +03:00
1 parent 268926ca0f
commit 10a370471b
52 files changed
+1000 -22

No files matched your search

+2 -1
View File
@@ -12,7 +12,8 @@
- Every construct has one canonical spelling (spec 15 §1).
*)
module = "module" path { item } ;
module = "module" path { std_import } { item } ;
std_import = "import" path ";" ; (* contextual word, spec 15 §13 *)
item = type_decl | fn_decl ;
path = ident { "." ident } ;
+38
View File
@@ -0,0 +1,38 @@
# Standard library API
Normative contracts: spec 16. Import rules: spec 15 §13. These modules are bundled with the compiler, with no external dependencies or grants.
All functions below declare `effects []`, allocate no heap memory and retain no borrows. Pass arrays/slices using explicit `ref` or `mut`. Names are fully qualified; no alias or short-name import exists.
| Module | Function signature | Result/failure |
|---|---|---|
| `std.math` | `min_u64(a: u64, b: u64) -> u64` | smaller operand |
| `std.math` | `max_u64(a: u64, b: u64) -> u64` | larger operand |
| `std.math` | `clamp_u64(value: u64, lower: u64, upper: u64) -> u64` | inclusive clamp; `T0002` if `lower > upper` |
| `std.bytes` | `equal(a: slice<u8>, b: slice<u8>) -> bool` | byte equality |
| `std.bytes` | `compare(a: slice<u8>, b: slice<u8>) -> i8` | unsigned lexicographic order: exactly -1/0/1 |
| `std.bytes` | `find(data: slice<u8>, byte: u8) -> usize` | first index; `data.len` if absent |
| `std.bytes` | `starts_with(data: slice<u8>, prefix: slice<u8>) -> bool` | empty prefix matches |
| `std.bytes` | `ends_with(data: slice<u8>, suffix: slice<u8>) -> bool` | empty suffix matches |
| `std.bytes` | `fill(dst: slice_mut<u8>, byte: u8) -> void` | fills caller-provided storage |
```aji
module demo.standard
import std.bytes;
import std.math;
fn main() -> u64
effects []
{
var data: [u8; 4] = zero;
std.bytes.fill(mut data, 65);
assert(std.bytes.equal(ref data, b"AAAA"));
let index = std.bytes.find(ref data, 65);
if index < data.len { assert(data[index] == 65); }
return std.math.clamp_u64(42, 0, 100);
}
```
Unknown module/member or absent import: `E7002`; duplicate import: `E7006`; malformed import or type arguments: `E7001`; wrong argument type/arity: `E7005`; conflicting borrows: `E2101`. No new diagnostic code.
The example is `tests/conformance/source/quickref/std.aji`; library boundary and algorithm tests live under `tests/conformance/source/std/`.