- objc.sx, objc_block.sx (from std/) + sdl3/opengl/raylib/stb/stb_truetype/ wasm vendor bindings (from modules/ root) -> modules/ffi/ - std/uikit.sx deleted: platform/uikit.sx already declares UIApplicationMain and imports objc; '#framework "UIKit"' cannot live in a file imported on macOS targets (unconditional link directive, UIKit is iOS-only), so the three iOS-only examples carry the 3-line glue inline. 1607/1608/1616 also un-rotted (dead ns_string -> 'xx "..."' Into conversions, callconv(.c) msgSend fn-ptrs) — all three build for ios-sim/ios again. - math/math.sx -> math/scalar.sx; one spelling '#import "modules/math"' everywhere (4 pinned IR snapshots regenerated: dir import adds Vec2/Mat4 to the type tables). - compiler.sx -> build.sx (imports, CLAUDE.md bundling table, specs.md). - testpkg/ + test_c.sx -> tests/fixtures/ (resolve CWD-relative from repo root, same as vendors/). - library-internal imports use full modules/... paths (std.sx tail, platform/bundle.sx, fixtures).
84 lines
1.8 KiB
Plaintext
84 lines
1.8 KiB
Plaintext
#import "modules/std.sx";
|
|
#import "modules/math";
|
|
#import "modules/build.sx";
|
|
#import "modules/std/test.sx";
|
|
pkg :: #import "tests/fixtures/testpkg";
|
|
|
|
add :: (a: s32, b: s32) -> s32 { a + b }
|
|
|
|
mul :: (a: s32, b: s32) -> s32 { a * b }
|
|
|
|
// #run compile-time constants
|
|
CT_VAL :: #run add(10, 15);
|
|
|
|
CT_MUL :: #run mul(6, 7);
|
|
|
|
CT_CHAIN :: #run add(CT_VAL, 5);
|
|
|
|
// #run compile-time optional tests
|
|
|
|
// #run compile-time optional tests
|
|
ct_opt_coalesce :: () -> s32 {
|
|
x: ?s32 = 42;
|
|
y: ?s32 = null;
|
|
return (x ?? 0) + (y ?? 99);
|
|
}
|
|
|
|
ct_opt_unwrap :: () -> s32 {
|
|
x: ?s32 = 77;
|
|
return x!;
|
|
}
|
|
|
|
ct_opt_guard :: () -> s32 {
|
|
x: ?s32 = 10;
|
|
if x == null { return -1; }
|
|
return x;
|
|
}
|
|
|
|
CT_OPT_COALESCE :: #run ct_opt_coalesce();
|
|
|
|
CT_OPT_UNWRAP :: #run ct_opt_unwrap();
|
|
|
|
CT_OPT_GUARD :: #run ct_opt_guard();
|
|
|
|
// #insert helpers
|
|
|
|
// #insert helpers
|
|
gen_code :: () -> string {
|
|
return "print(\"insert-ok\\n\");";
|
|
}
|
|
|
|
gen_val :: () -> string {
|
|
return "print(\"insert-gen: {}\\n\", 42);";
|
|
}
|
|
|
|
// --- Error handling (failable functions: sets, raise/try/catch/or/onfail) ---
|
|
|
|
main :: () {
|
|
|
|
// ========================================================
|
|
// 8. COMPILE-TIME
|
|
// ========================================================
|
|
print("=== 8. Comptime ===\n");
|
|
|
|
// #run constant
|
|
print("run-const: {}\n", CT_VAL);
|
|
|
|
// #run with expression
|
|
print("run-expr: {}\n", CT_MUL);
|
|
|
|
// #run chained dependency
|
|
print("run-chain: {}\n", CT_CHAIN);
|
|
|
|
// #run comptime optionals
|
|
print("ct-opt-coalesce: {}\n", CT_OPT_COALESCE); // ct-opt-coalesce: 141
|
|
print("ct-opt-unwrap: {}\n", CT_OPT_UNWRAP); // ct-opt-unwrap: 77
|
|
print("ct-opt-guard: {}\n", CT_OPT_GUARD); // ct-opt-guard: 10
|
|
|
|
// #insert with function
|
|
#insert gen_code();
|
|
|
|
// #insert additional
|
|
#insert gen_val();
|
|
}
|