cli: bootstrap verified std bytes and math with source imports
This commit is contained in:
52 files changed
+1000
-22
No files matched your search
@@ -58,6 +58,7 @@ effects [io.read, io.write]
|
||||
```
|
||||
|
||||
- A file holds one module: `module <dotted.path>`, then type and function declarations in any order.
|
||||
- Between the module header and declarations, `import <dotted.path>;` imports a built-in standard module (§13). `import` is contextual at this position; it remains an ordinary identifier elsewhere.
|
||||
- `//` starts a line comment.
|
||||
- Function `f` lowers to `@f`; type `T` to `@T`.
|
||||
- **Signature.** `fn name(params) -> type`, then optionally `from p` for a borrow return (spec 08 §11.3), then the line `effects [...]`, then the body block.
|
||||
@@ -466,3 +467,17 @@ Other rules:
|
||||
|
||||
- `*c` and any other ordinary read of a cell is `E4202`.
|
||||
- Effects are declared by the programmer (spec 05 §13).
|
||||
|
||||
## 13. Built-in standard modules
|
||||
|
||||
The compiler MUST provide the standard modules listed in spec 16 §2, pinned to its own version. An import MUST resolve only against that closed registry: no file-system search, environment variable, network fetch, package manifest, or build extension participates. Unknown modules are `E7002`; duplicate imports are `E7006`. Imports MUST precede declarations; a misplaced import or missing semicolon is `E7001`.
|
||||
|
||||
An imported function is called by its full path, for example `std.bytes.equal(ref a, ref b)`. An unknown member or a call without the corresponding import is `E7002`. Importing a module MUST NOT introduce unqualified names or aliases. Qualified standard calls MUST NOT resolve through a local binding named `std`. User functions with the same short name remain independent. Standard functions are ordinary function calls: their argument types, borrows, moves, effects and failure contracts follow the existing rules. Type arguments on these monomorphic functions are outside the grammar (`E7001`).
|
||||
|
||||
Lowering MUST append the complete function declarations of the imported modules after the program's declarations, in lexicographic module order and source declaration order within each module. For function `f` in module `m`, the AIR name starts as `__aji_` plus `m` with dots replaced by underscores, then `_f`. If that name collides with a program type/function or a previously linked standard function, the compiler MUST append the smallest positive decimal suffix `_1`, `_2`, … that is unused. Qualified source calls MUST use the resulting AIR name. This is name mangling, not an extension to the format-0 identifier grammar. The imported source is parsed and lowered as ordinary safe `.aji` and the combined AIR MUST pass the same verifier. No runtime dispatch or new AIR instruction is introduced. The feature header is the dependency closure of the combined module, including unused imported functions.
|
||||
|
||||
Imports grant no authority, perform no runtime initialization and allocate no program heap memory. Merely importing a module does not add effects to the caller's contract; calling an effectful function would require its declared effects under the usual call rule.
|
||||
|
||||
Canonical AIR MUST be independent of import order, working directory and execution profile for a fixed compiler and program. Source diagnostics and traps inside a standard function MUST identify its stable repository-relative source path (`std/math.aji` or `std/bytes.aji`) and its original line/column, rather than the program's path. `aji lower --annotate` MUST include that path on annotations for imported instructions. AIR locations remain available as in §10.
|
||||
|
||||
This increment exposes functions with built-in parameter/result types only. General user modules, dependency resolution, aliases, imported type names and generics require separate specifications.
|
||||
Reference in new issue
Block a user