// Comptime compiler API — welded compiler FUNCTIONS over the host-call bridge. // // `intern` / `text_of` are bound to the `compiler` library via // `abi(.zig) extern compiler`. They have no real symbol — under the comptime // interpreter the call dispatches to the compiler's registered Zig handler // (the string pool), never dlsym. Comptime-only: here they run inside `#run`, // folding to a plain string constant the runtime `main` prints. // // Round-trip: `text_of(intern(s)) == s` — interning a string yields a handle, // and resolving the handle gives the text back. #import "modules/std.sx"; compiler :: #library "compiler"; StringId :: u32; intern :: (s: string) -> StringId abi(.zig) extern compiler; text_of :: (id: StringId) -> string abi(.zig) extern compiler; greeting :: #run text_of(intern("hello, compiler")); main :: () { print("{}\n", greeting); }