Files
sx/examples/comptime/0636-comptime-extern-libc.sx
agra 66bdc70bf1 test: group examples into per-category folders
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.
2026-06-21 14:41:34 +03:00

18 lines
664 B
Plaintext

// Comptime host-FFI: a `#run` that calls real libc functions (`toupper`/`tolower`)
// at compile time. The comptime VM resolves the symbol via dlsym and dispatches
// through the host_ffi trampolines (Phase 4D) — a scalar arg in, a scalar return
// out — folding the result into a constant. (The legacy interpreter does the same
// via its own dlsym path; both agree.)
#import "modules/std.sx";
toupper :: (c: i32) -> i32 extern libc;
tolower :: (c: i32) -> i32 extern libc;
UP :: #run toupper(97); // 'a' -> 'A' = 65
LO :: #run tolower(90); // 'Z' -> 'z' = 122
main :: () -> i32 {
print("toupper(97)={} tolower(90)={}\n", UP, LO);
return 0;
}