Move examples/*.sx and their expected/ snapshots into per-category subfolders (examples/<category>/...). Folder = leading filename token, with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus runner and LSP sweep now discover each category's expected/ dir, while issues/ stays flat. Example 1058's repo-root-relative companion import is made file-relative. Path strings embedded in 164 snapshots were regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
24 lines
819 B
Plaintext
24 lines
819 B
Plaintext
// Comptime compiler API — welded compiler FUNCTIONS over the host-call bridge.
|
|
//
|
|
// `intern` / `text_of` are bound to the `compiler` library via
|
|
// `abi(.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";
|
|
|
|
|
|
StringId :: u32;
|
|
intern :: (s: string) -> StringId abi(.compiler);
|
|
text_of :: (id: StringId) -> string abi(.compiler);
|
|
|
|
greeting :: #run text_of(intern("hello, compiler"));
|
|
|
|
main :: () {
|
|
print("{}\n", greeting);
|
|
}
|