P5.2: emit_object() -> string query primitive

The compiler emits the sx object eagerly (the Zig driver, before the post-link
callback), so emit_object is a QUERY (not an action): it returns the path from
a new BuildConfig.object_path field main.zig forwards — no driver vtable. This
completes the build-pipeline QUERY primitives (emit_object / c_object_paths /
link_libraries); only link (the genuine action) remains for the vtable step.

Extended examples/1662 to also assert emit_object().len > 0. 703/0 both gates.
This commit is contained in:
agra
2026-06-19 07:58:59 +03:00
parent 44dfdcddf9
commit 83de0fa04d
8 changed files with 57 additions and 19 deletions

View File

@@ -69,14 +69,15 @@ pub const bound_fns = [_]BoundFn{
// recognizes the names as compiler-API functions.
.{ .sx_name = "c_object_paths", .handler = handleBuildPipelineQuery },
.{ .sx_name = "link_libraries", .handler = handleBuildPipelineQuery },
.{ .sx_name = "emit_object", .handler = handleBuildPipelineQuery },
};
/// Legacy-path stub for the Phase 5 build-pipeline metadata queries — see the
/// `bound_fns` comment. These return a `List(string)` the legacy `Value` model
/// can't faithfully build (issue 0141), and the only caller (the post-link
/// callback) runs on the VM, so bail loudly here instead of guessing.
/// Legacy-path stub for the Phase 5 build-pipeline primitives — see the
/// `bound_fns` comment. The only caller (the post-link build driver) runs on the
/// VM (`core.invokeByFuncId`), so these legacy handlers are never reached; they
/// bail loudly instead of fabricating a silent result.
fn handleBuildPipelineQuery(_: *Interpreter, _: []const Value) InterpError!Value {
Interpreter.last_bail_detail = "build-pipeline query (c_object_paths/link_libraries) is VM-only (post-link); not available on the legacy interpreter";
Interpreter.last_bail_detail = "build-pipeline primitive (emit_object/c_object_paths/link_libraries) is VM-only (post-link); not available on the legacy interpreter";
return error.CannotEvalComptime;
}