comptime VM arc: abi(.compiler) ABI, out as sx fn, VM-native diagnostics, BuildConfig threaded

Lands the full VM/compiler-API arc on branch reify (701/0 both gates):
- abi(.compiler) ABI replaces abi(.zig) extern compiler + the fake
  #library "compiler"; bodiless decl = compiler-API surface, bodied =
  user compiler-domain fn (lowered for VM eval, emit-skipped).
- out is a plain sx fn (libc write) — the out builtin deleted; the VM
  handles it via host-FFI. trace_resolve + interp_print_frames ported.
- 4B VM-native diagnostics: 1179/1180 render proper comptime type
  construction failed: under strict.
- S5a: build_options/set_post_link_callback on abi(.compiler) with
  BuildConfig threaded into the VM (green intermediate).
- 0522 fixed (describe(args: []Type)); regression 0638.

Strict deletion-gate down to 4 compiler_call bails (1609/1614/1615/1616)
+ 1654 (legitimate unresolvable-symbol diagnostic).
This commit is contained in:
agra
2026-06-19 07:04:10 +03:00
parent fdc4ee2331
commit 2060373c16
80 changed files with 12684 additions and 11922 deletions

View File

@@ -80,20 +80,18 @@ test "parser: comptime type-metaprogramming surface parses" {
}
// Lock: the `compiler`-library binding surface PARSES — `name :: #library "x";`
// (already supported) plus the new postfix `abi(.zig)` annotation (in the slot
// before `extern`) followed by the library handle, on a function declaration. The
// AST must carry the binding: `abi == .zig`, `extern_export == .extern_`, and the
// library handle in `extern_lib`. No semantics yet — this is the first testable
// sub-step of Phase 1 (parse only).
test "parser: abi(.zig) extern <lib> binding parses on a fn decl" {
// (already supported) plus the postfix `abi(.compiler)` annotation, marking a
// compiler-domain / compiler-API function — no `extern`, no fake `#library`. The
// AST must carry `abi == .compiler`, `extern_export == .none`, `extern_lib ==
// null`, and a synthesized empty-block (bodiless) body.
test "parser: abi(.compiler) binding parses on a bodiless fn decl" {
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
const src =
\\compiler :: #library "compiler";
\\text_of :: (id: StringId) -> string abi(.zig) extern compiler;
\\intern :: (s: string) -> StringId abi(.zig) extern compiler;
\\text_of :: (id: StringId) -> string abi(.compiler);
\\intern :: (s: string) -> StringId abi(.compiler);
\\
;
var parser = Parser.init(alloc, src);
@@ -101,14 +99,10 @@ test "parser: abi(.zig) extern <lib> binding parses on a fn decl" {
try std.testing.expect(root.data == .root);
const decls = root.data.root.decls;
try std.testing.expectEqual(@as(usize, 3), decls.len);
try std.testing.expectEqual(@as(usize, 2), decls.len);
// The `#library` decl still parses to a `library_decl` node carrying the name.
try std.testing.expect(decls[0].data == .library_decl);
try std.testing.expectEqualStrings("compiler", decls[0].data.library_decl.name);
try std.testing.expectEqualStrings("compiler", decls[0].data.library_decl.lib_name);
// The two `abi(.zig) extern compiler` fns: `.fn_decl` with the binding fields set.
// The two `abi(.compiler)` fns: `.fn_decl` with the compiler-domain ABI set,
// NO extern linkage, NO bound library.
for ([_][]const u8{ "text_of", "intern" }) |bn| {
var found: ?*const Node = null;
for (decls) |d| {
@@ -119,11 +113,10 @@ test "parser: abi(.zig) extern <lib> binding parses on a fn decl" {
const d = found orelse return error.MissingDecl;
try std.testing.expect(d.data == .fn_decl);
const fd = d.data.fn_decl;
try std.testing.expectEqual(ast.ABI.zig, fd.abi);
try std.testing.expectEqual(ast.ExternExportModifier.extern_, fd.extern_export);
try std.testing.expect(fd.extern_lib != null);
try std.testing.expectEqualStrings("compiler", fd.extern_lib.?);
// Bodyless extern import: synthesized empty block, no `#builtin`/`#compiler`.
try std.testing.expectEqual(ast.ABI.compiler, fd.abi);
try std.testing.expectEqual(ast.ExternExportModifier.none, fd.extern_export);
try std.testing.expect(fd.extern_lib == null);
// Bodyless compiler-domain decl: synthesized empty block, no `#builtin`/`#compiler`.
try std.testing.expect(fd.body.data == .block);
}
}
@@ -173,18 +166,19 @@ test "parser: abi(.c) and abi(.pure) parse standalone" {
try std.testing.expectEqual(ast.ABI.pure, decls[1].data.fn_decl.abi);
}
// Lock: the `compiler`-library binding PARSES on a STRUCT decl — `Name :: struct
// abi(.zig) extern <lib> { … }`. The AST struct_decl must carry `abi == .zig` and
// the library handle in `extern_lib`, with the field list intact. No semantics
// yet (parse-only) — this is the second testable sub-step of Phase 1.
test "parser: abi(.zig) extern <lib> binding parses on a struct decl" {
// Lock: the postfix `abi(...)` slot PARSES on a STRUCT decl — `Name :: struct
// abi(.compiler) extern <lib> { … }`. The AST struct_decl carries the abi + the
// library handle in `extern_lib`, with the field list intact. Parse-only — the
// struct-weld semantics were stripped (compiler-API types are VM-native now); this
// just locks that the annotation slot still parses without perturbing fields.
test "parser: abi(...) extern <lib> annotation parses on a struct decl" {
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
const src =
\\compiler :: #library "compiler";
\\Field :: struct abi(.zig) extern compiler { name: StringId; ty: Type; }
\\Field :: struct abi(.compiler) extern compiler { name: StringId; ty: Type; }
\\
;
var parser = Parser.init(alloc, src);
@@ -194,7 +188,7 @@ test "parser: abi(.zig) extern <lib> binding parses on a struct decl" {
try std.testing.expect(decls[1].data == .struct_decl);
const sd = decls[1].data.struct_decl;
try std.testing.expectEqual(ast.ABI.zig, sd.abi);
try std.testing.expectEqual(ast.ABI.compiler, sd.abi);
try std.testing.expect(sd.extern_lib != null);
try std.testing.expectEqualStrings("compiler", sd.extern_lib.?);
// Field list survives the binding annotation.