P5.3: on_build(cb) build-callback registrar; callback takes BuildOptions
Per user design: on_build(build) is the build-callback registrar (a free fn), generalizing set_post_link_callback — the callback is (opt: BuildOptions) -> bool and the compiler invokes it post-codegen WITH the BuildOptions handle. - VM: callCompilerFn 'on_build' arm + legacy handleOnBuild, both set post_link_callback_fn + a new BuildConfig.post_link_takes_options flag. - comptime_vm: runEntry refactored to runEntryArgs(extra) (implicit ctx + explicit args); new public runBuildCallback(..., pass_options) passes the opaque BuildOptions handle (one word) after the ctx. The fat-config marshaling fear is moot — the handle is a single null-sentinel word. - core.invokeByFuncId/invokeByName take pass_options (was an unused args slice); main.zig passes comp.getPostLinkTakesOptions(). - build.sx: on_build decl (set_post_link_callback kept for now). Smoke test examples/1664-platform-on-build-callback (AOT): #run on_build(build) with build :: (opt: BuildOptions) -> bool; the callback is invoked with the handle arg (runEntryArgs param-count match) and runs the primitives. Benign .ir churn (37 snapshots: type table +1 for the on_build fn type + global renumber; behavior identical). 705/0 both gates.
This commit is contained in:
@@ -94,3 +94,11 @@ build_options :: () -> BuildOptions abi(.compiler);
|
||||
// onto the comptime compiler-API (`abi(.compiler)`); called as
|
||||
// `opts.set_post_link_callback(cb)` via UFCS, from inside a `#run { … }` block.
|
||||
set_post_link_callback :: ufcs (self: BuildOptions, cb: () -> bool) abi(.compiler);
|
||||
|
||||
// The build callback registrar (Phase 5). Registers the sx function that drives
|
||||
// the build — the compiler invokes it after codegen with the `BuildOptions`
|
||||
// handle. Generalizes `set_post_link_callback` (a free fn, and the callback
|
||||
// receives `opt`); `#run on_build(build);` is the override form, where
|
||||
// `build :: (opt: BuildOptions) -> bool abi(.compiler) { … }`. The stdlib default
|
||||
// implementation lives below (the default `build` script).
|
||||
on_build :: (cb: (opt: BuildOptions) -> bool abi(.compiler)) abi(.compiler);
|
||||
|
||||
Reference in New Issue
Block a user