git-mv the 10 foreign-named example families to extern/runtime-class names + update every #import/#include/#source ref, stale comment ref, and the 1172 stderr snapshot (path + 'extern symbol' message). Renames: 0729…-foreign→…-extern, 1172-diagnostics- foreign-symbol-conflict→…-extern-symbol-conflict, 1205/1207 ffi-foreign-global→ ffi-extern-global, 1216/1217 ffi-…-foreign-(in-method|result-chain)→…-extern-…, 1219-ffi-foreign→1219-ffi-extern, 1306 objc-foreign-class-chained→objc-runtime-class- chained, 1318 objc-property-foreign→objc-property-extern-class. DEDUP: deleted 1218-ffi-foreign-cvariadic (identical to 1229-ffi-extern-cvariadic; updated 1229's twin ref) + the orphaned 1620 dir. Also purged editors/vscode tmLanguage (#foreign dropped from the directive highlighter) + 1220.h/issues-0030.sx comment refs. Suite green (644 corpus / 443 unit, 0 failed).
33 lines
1.3 KiB
Plaintext
33 lines
1.3 KiB
Plaintext
// Extern data globals via `<name> : <type> extern;`. Lets sx code
|
|
// reference libSystem / framework symbols (NSConcreteStackBlock,
|
|
// __stdinp, etc.) for FFI bridges. Mirrors the long-standing
|
|
// `<fn> :: (...) -> ... extern;` form on the function side.
|
|
//
|
|
// Cross-file dimension (PLAN-FFI step 0.10): the helper companion
|
|
// `1205-ffi-extern-global-helper.sx` ALSO declares `__stdinp : *void extern;`.
|
|
// Both files referencing the same extern symbol must link cleanly —
|
|
// LLVM dedupes the named global, the C linker resolves both refs to
|
|
// the one libSystem symbol.
|
|
//
|
|
// We *don't* check that the helper computes the same address — see
|
|
// issue-0037 (helper-function-scoped `@extern_global` lowers to
|
|
// undef today). When that fixes, fold the helper's address back into
|
|
// the equality check here.
|
|
|
|
#import "modules/std.sx";
|
|
#import "1205-ffi-extern-global-helper.sx";
|
|
|
|
__stdinp : *void extern;
|
|
|
|
main :: () -> i32 {
|
|
addr_bits : u64 = xx @__stdinp;
|
|
print("stdin extern global non-null: {}\n", addr_bits != 0);
|
|
// Force the helper symbol to participate in linking (otherwise the
|
|
// imported file's #extern decl might get dropped by the
|
|
// dead-code stripper). The actual return value is busted today
|
|
// — see issue-0037.
|
|
_ := stdinp_addr_present();
|
|
print("helper file linked: true\n");
|
|
0
|
|
}
|