✓
Passing This code compiles and runs correctly.
Code
// Test: Custom Compiler Coordinator Override
//
// Validates that users can override the abstract coordinate event
// with their own pipeline implementation using ~impl.
//
// The custom coordinator prints a marker, then delegates to standard pipeline.
~import "$std/compiler"
const std = @import("std");
const ast = @import("ast");
const Program = ast.Program;
// Custom coordinator that wraps the default pipeline
// All compiler events must be module-qualified
~impl std.compiler:coordinate =
custom_marker()
| done |> std.compiler:context_create(program_ast: program_ast, allocator: allocator)
| created c0 |> std.compiler:frontend(ctx: c0.ctx)
| ctx c1 |> std.compiler:transform_taps(ctx: c1)
| ctx c2 |> std.compiler:analysis(ctx: c2)
| ctx c3 |> std.compiler:test_generation(ctx: c3)
| ctx c4 |> std.compiler:optimize(ctx: c4)
| ctx c5 |> std.compiler:emission(ctx: c5)
| ctx c6 |> coordinated {
ast: c6.ctx.ast,
code: c6.code,
metrics: "Custom coordinator ran!"
}
| failed f |> error { message: f.message }
// Helper event to print marker (must be comptime since it's called from coordinate handler)
~[comptime] event custom_marker {}
| done {}
~proc custom_marker {
std.debug.print("CUSTOM COORDINATOR: Pipeline override active!\n", .{});
return .{ .done = .{} };
}
// Simple test event
~pub event hello {}
| done {}
~proc hello {
std.debug.print("Hello from custom-compiled code!\n", .{});
return .{ .done = .{} };
}
~hello()
| done |> _