refactor(ffi-linkage): Phase 9.2d — rename foreign_path → runtime_path (coupled .sx↔.zig↔hook)
The JNI/runtime-class path (Decision 5, Runtime* family). Coordinated across the hook boundary so the BuildOptions accessor + its registered hook string stay in sync: - src/: RuntimeClassDecl.foreign_path→runtime_path, splitForeignPath→splitRuntimePath, foreignPathToJavaName→runtimePathToJavaName, jni_main_foreign_paths→ jni_main_runtime_paths, hookJniMainForeignPathAt→hookJniMainRuntimePathAt, and the hook string 'BuildOptions.jni_main_foreign_path_at'→'…runtime_path_at'. - library/: build.sx accessor jni_main_foreign_path_at→jni_main_runtime_path_at + bundle.sx call sites + the local var → runtime_path + a comment. - specs.md: the accessor name + <foreign_path_with_dots> doc refs. - Regenerated 37 .ir snapshots: every program importing build declares the renamed @BuildOptions.jni_main_runtime_path_at hook stub — symbol-name change only (verified the .ir diff is ONLY this rename; reverted orthogonal empty-file normalization). Suite green (646 corpus / 444 unit, 0 failed).
This commit is contained in:
@@ -4149,7 +4149,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -4695,7 +4695,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
@@ -5247,7 +5247,7 @@ declare ptr @BuildOptions.keystore_path.293(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.294(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.295(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.295(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.296(i64, i64) #0
|
||||
|
||||
@@ -4069,7 +4069,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -4615,7 +4615,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
@@ -5167,7 +5167,7 @@ declare ptr @BuildOptions.keystore_path.293(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.294(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.295(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.295(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.296(i64, i64) #0
|
||||
|
||||
@@ -4016,7 +4016,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -3991,7 +3991,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -3992,7 +3992,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4296,7 +4296,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -3997,7 +3997,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4105,7 +4105,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4202,7 +4202,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4218,7 +4218,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4308,7 +4308,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -4854,7 +4854,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
@@ -5406,7 +5406,7 @@ declare ptr @BuildOptions.keystore_path.293(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.294(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.295(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.295(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.296(i64, i64) #0
|
||||
|
||||
@@ -4061,7 +4061,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4004,7 +4004,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -3998,7 +3998,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4154,7 +4154,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4186,7 +4186,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4037,7 +4037,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4001,7 +4001,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4008,7 +4008,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -4003,7 +4003,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -660,7 +660,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1152,7 +1152,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -1632,7 +1632,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -1168,7 +1168,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -1648,7 +1648,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -4152,7 +4152,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -4632,7 +4632,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -1624,7 +1624,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -4080,7 +4080,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -4560,7 +4560,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -1170,7 +1170,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -1650,7 +1650,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -1146,7 +1146,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -1144,7 +1144,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
|
||||
@@ -667,7 +667,7 @@ declare ptr @BuildOptions.keystore_path(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at(i64, i64) #0
|
||||
@@ -1147,7 +1147,7 @@ declare ptr @BuildOptions.keystore_path.109(i64) #0
|
||||
declare i64 @BuildOptions.jni_main_count.110(i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_foreign_path_at.111(i64, i64) #0
|
||||
declare ptr @BuildOptions.jni_main_runtime_path_at.111(i64, i64) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @BuildOptions.jni_main_java_source_at.112(i64, i64) #0
|
||||
|
||||
@@ -84,10 +84,10 @@ BuildOptions :: struct #compiler {
|
||||
// `#jni_main #jni_class("path") { ... }` decls collected during
|
||||
// lowering. The Android bundler walks `0..jni_main_count()` and
|
||||
// for each entry writes a `.java` file at
|
||||
// `<stage>/java/<foreign_path>.java`, compiles via javac + d8, and
|
||||
// `<stage>/java/<runtime_path>.java`, compiles via javac + d8, and
|
||||
// bundles the resulting classes.dex into the APK.
|
||||
jni_main_count :: (self: BuildOptions) -> i64;
|
||||
jni_main_foreign_path_at :: (self: BuildOptions, i: i64) -> string;
|
||||
jni_main_runtime_path_at :: (self: BuildOptions, i: i64) -> string;
|
||||
jni_main_java_source_at :: (self: BuildOptions, i: i64) -> string;
|
||||
}
|
||||
|
||||
|
||||
@@ -871,11 +871,11 @@ build_android_manifest :: (opts: BuildOptions, package: string, lib_name: string
|
||||
pkg_esc := xml.escape(package);
|
||||
lib_esc := xml.escape(lib_name);
|
||||
if opts.jni_main_count() > 0 {
|
||||
// First `#jni_main` decl drives the Activity. The foreign_path
|
||||
// First `#jni_main` decl drives the Activity. The runtime_path
|
||||
// uses `/` separators; Java fully-qualified class names use
|
||||
// `.` so we rewrite.
|
||||
foreign := opts.jni_main_foreign_path_at(0);
|
||||
cls := slash_to_dot(foreign);
|
||||
runtime_path := opts.jni_main_runtime_path_at(0);
|
||||
cls := slash_to_dot(runtime_path);
|
||||
cls_esc := xml.escape(cls);
|
||||
return format(#string MANIFEST
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -938,7 +938,7 @@ slash_to_dot :: (path: string) -> string {
|
||||
}
|
||||
|
||||
// Last `/`-separated component of a forward-slash path (used to split
|
||||
// JNI foreign paths into pkg + class). `co/swipelab/Foo` → `Foo`.
|
||||
// JNI runtime-class paths into pkg + class). `co/swipelab/Foo` → `Foo`.
|
||||
// `Foo` → `Foo`. `dir_part` returns the part before the last slash
|
||||
// (or "" if none).
|
||||
last_slash_component :: (path: string) -> string {
|
||||
@@ -990,10 +990,10 @@ compile_jni_main_sources :: (opts: BuildOptions, stage: string, android_jar: str
|
||||
count := opts.jni_main_count();
|
||||
i : i64 = 0;
|
||||
while i < count {
|
||||
foreign := opts.jni_main_foreign_path_at(i);
|
||||
runtime_path := opts.jni_main_runtime_path_at(i);
|
||||
java_source := opts.jni_main_java_source_at(i);
|
||||
pkg := dir_part(foreign);
|
||||
cls := last_slash_component(foreign);
|
||||
pkg := dir_part(runtime_path);
|
||||
cls := last_slash_component(runtime_path);
|
||||
|
||||
pkg_dir := if pkg.len > 0 then path_join(java_root, pkg) else java_root;
|
||||
if !create_dir_all(str_to_cstr(pkg_dir)) {
|
||||
@@ -1003,7 +1003,7 @@ compile_jni_main_sources :: (opts: BuildOptions, stage: string, android_jar: str
|
||||
java_path := path_join(pkg_dir, concat(cls, ".java"));
|
||||
if !write_file(str_to_cstr(java_path), java_source) {
|
||||
out("error: apk: cannot write .java for ");
|
||||
out(foreign);
|
||||
out(runtime_path);
|
||||
out("\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
4
specs.md
4
specs.md
@@ -2972,7 +2972,7 @@ back inside the post-link callback.
|
||||
| `is_macos() / is_ios() / is_ios_device() / is_ios_simulator() / is_android()` | read | per-target predicates |
|
||||
| `framework_count() / framework_at(i)` | read | linker `-framework` names (for `Frameworks/` embed) |
|
||||
| `framework_path_count() / framework_path_at(i)` | read | linker `-F` search paths |
|
||||
| `jni_main_count() / jni_main_foreign_path_at(i) / jni_main_java_source_at(i)` | read | `#jni_main` emissions for the APK bundler |
|
||||
| `jni_main_count() / jni_main_runtime_path_at(i) / jni_main_java_source_at(i)` | read | `#jni_main` emissions for the APK bundler |
|
||||
| `asset_dir_count() / asset_dir_src_at(i) / asset_dir_dest_at(i)` | read | iterate registered asset trees |
|
||||
|
||||
Returned strings are `""` when unset; integer counts are `0`. Accessors
|
||||
@@ -3046,7 +3046,7 @@ The Android branch:
|
||||
3. **Stage `<apk>.stage/lib/arm64-v8a/<libfoo.so>`** — `copy_file` from the linked output.
|
||||
4. **Manifest** — user-supplied via `set_manifest_path()`, or synthesized:
|
||||
- `NativeActivity` shape when no `#jni_main` is declared.
|
||||
- `#jni_main` Activity shape with `android:name="<foreign_path_with_dots>"` + `android:hasCode="true"` otherwise.
|
||||
- `#jni_main` Activity shape with `android:name="<runtime_path_with_dots>"` + `android:hasCode="true"` otherwise.
|
||||
5. **Compile `#jni_main` Java sources** — write each entry's `java_source` to `<stage>/java/<pkg>/<Cls>.java`, run `javac --release 11 -classpath <android.jar>` to `<stage>/classes/`, run `d8 --release --lib <android.jar> --output <stage>` to produce `<stage>/classes.dex`. `javac` discovered via `$JAVA_HOME/bin/javac` then `command -v javac`.
|
||||
6. **`aapt2 link -I <android.jar> --manifest <m> -o <unaligned>`**.
|
||||
7. **Append archives** — `zip -q -r <unaligned> lib/`, then `zip -q <unaligned> classes.dex` (if dex was produced), then `zip` each registered asset dir at its `dest` path.
|
||||
|
||||
@@ -885,7 +885,7 @@ pub const RuntimeClassMember = union(enum) {
|
||||
|
||||
pub const RuntimeClassDecl = struct {
|
||||
name: []const u8, // sx-side alias (left of `::`)
|
||||
foreign_path: []const u8, // directive arg: "java/path/Foo" / "NSString" / "Foundation.URL"
|
||||
runtime_path: []const u8, // directive arg: "java/path/Foo" / "NSString" / "Foundation.URL"
|
||||
runtime: RuntimeKind,
|
||||
members: []const RuntimeClassMember = &.{},
|
||||
is_extern: bool = false, // `#objc_class(…) extern` — class is provided by the runtime; we only reference it (vs `export`, which defines + registers a new sx class)
|
||||
|
||||
12
src/core.zig
12
src/core.zig
@@ -362,10 +362,10 @@ pub const Compilation = struct {
|
||||
/// Walk `lowering.program_index.runtime_class_map` and render Java sources for every
|
||||
/// `#jni_main #jni_class("...")` declaration. Renders happen here so the
|
||||
/// AST + class-registry snapshot stay confined to the lowering pass; the
|
||||
/// downstream APK pipeline only needs `{foreign_path, java_source}` pairs.
|
||||
/// downstream APK pipeline only needs `{runtime_path, java_source}` pairs.
|
||||
fn collectJniMainEmissions(self: *Compilation, lowering: *ir.Lowering) !void {
|
||||
// `runtime_class_map` registers each decl under bare + qualified names —
|
||||
// dedupe by foreign_path so a single decl emits one .java.
|
||||
// dedupe by runtime_path so a single decl emits one .java.
|
||||
var seen = std.StringHashMap(void).init(self.allocator);
|
||||
defer seen.deinit();
|
||||
|
||||
@@ -375,7 +375,7 @@ pub const Compilation = struct {
|
||||
defer registry.deinit();
|
||||
var it_reg = lowering.program_index.runtime_class_map.iterator();
|
||||
while (it_reg.next()) |entry| {
|
||||
try registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path);
|
||||
try registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path);
|
||||
}
|
||||
|
||||
// Derive the `System.loadLibrary` argument from the `-o` basename
|
||||
@@ -390,15 +390,15 @@ pub const Compilation = struct {
|
||||
if (!fcd.is_main) continue;
|
||||
if (fcd.is_extern) continue;
|
||||
if (fcd.runtime != .jni_class) continue;
|
||||
if (seen.contains(fcd.foreign_path)) continue;
|
||||
try seen.put(fcd.foreign_path, {});
|
||||
if (seen.contains(fcd.runtime_path)) continue;
|
||||
try seen.put(fcd.runtime_path, {});
|
||||
|
||||
const java_source = try ir.jni_java_emit.emitJavaSource(self.allocator, fcd, .{
|
||||
.classes = ®istry,
|
||||
.lib_name = lib_name,
|
||||
});
|
||||
try self.lowering_jni_main_decls.append(self.allocator, .{
|
||||
.foreign_path = try self.allocator.dupe(u8, fcd.foreign_path),
|
||||
.runtime_path = try self.allocator.dupe(u8, fcd.runtime_path),
|
||||
.java_source = java_source,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ test "plan: foreign-class instance vs static dispatch" {
|
||||
.{ .method = .{ .name = "length", .params = &.{}, .param_names = &.{}, .return_type = typeExpr(alloc, "i64"), .is_static = false } },
|
||||
.{ .method = .{ .name = "stringWithUTF8String", .params = &.{}, .param_names = &.{}, .return_type = typeExpr(alloc, "i64"), .is_static = true } },
|
||||
};
|
||||
var fcd = ast.RuntimeClassDecl{ .name = "NSString", .foreign_path = "NSString", .runtime = .objc_class, .members = &members };
|
||||
var fcd = ast.RuntimeClassDecl{ .name = "NSString", .runtime_path = "NSString", .runtime = .objc_class, .members = &members };
|
||||
l.program_index.runtime_class_map.put("NSString", &fcd) catch unreachable;
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = module.types.internString("NSString"), .fields = &.{} } });
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ pub const BuildConfig = struct {
|
||||
/// and bundles the resulting `classes.dex` into the APK. Slices
|
||||
/// reference compiler-owned memory that outlives the post-link
|
||||
/// callback.
|
||||
jni_main_foreign_paths: []const []const u8 = &.{},
|
||||
jni_main_runtime_paths: []const []const u8 = &.{},
|
||||
jni_main_java_sources: []const []const u8 = &.{},
|
||||
|
||||
pub fn deinit(self: *BuildConfig, alloc: Allocator) void {
|
||||
@@ -160,7 +160,7 @@ pub const Registry = struct {
|
||||
self.hooks.put("BuildOptions.keystore_path", &hookGetKeystorePath) catch {};
|
||||
// #jni_main class emissions, exposed by index so bundle.sx can iterate.
|
||||
self.hooks.put("BuildOptions.jni_main_count", &hookJniMainCount) catch {};
|
||||
self.hooks.put("BuildOptions.jni_main_foreign_path_at", &hookJniMainForeignPathAt) catch {};
|
||||
self.hooks.put("BuildOptions.jni_main_runtime_path_at", &hookJniMainRuntimePathAt) catch {};
|
||||
self.hooks.put("BuildOptions.jni_main_java_source_at", &hookJniMainJavaSourceAt) catch {};
|
||||
// Framework list accessors (for `.app/Frameworks/` embedding)
|
||||
self.hooks.put("BuildOptions.framework_count", &hookFrameworkCount) catch {};
|
||||
@@ -470,19 +470,19 @@ fn hookGetKeystorePath(_: *const Interpreter, _: []const Value, bc: *BuildConfig
|
||||
|
||||
// ── #jni_main emission accessors ──────────────────────────────────────
|
||||
// The Android bundler walks these as `0..jni_main_count()` and reads
|
||||
// each entry's `(foreign_path, java_source)` pair so it can write a
|
||||
// each entry's `(runtime_path, java_source)` pair so it can write a
|
||||
// `.java` file per decl, compile via javac, and produce classes.dex
|
||||
// via d8 before zipping into the APK.
|
||||
|
||||
fn hookJniMainCount(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .int = @intCast(bc.jni_main_foreign_paths.len) };
|
||||
return Value{ .int = @intCast(bc.jni_main_runtime_paths.len) };
|
||||
}
|
||||
|
||||
fn hookJniMainForeignPathAt(_: *const Interpreter, args: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
fn hookJniMainRuntimePathAt(_: *const Interpreter, args: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
if (args.len < 2) return Value{ .string = "" };
|
||||
const idx = args[1].asInt() orelse return error.TypeError;
|
||||
if (idx < 0 or @as(usize, @intCast(idx)) >= bc.jni_main_foreign_paths.len) return Value{ .string = "" };
|
||||
return Value{ .string = bc.jni_main_foreign_paths[@intCast(idx)] };
|
||||
if (idx < 0 or @as(usize, @intCast(idx)) >= bc.jni_main_runtime_paths.len) return Value{ .string = "" };
|
||||
return Value{ .string = bc.jni_main_runtime_paths[@intCast(idx)] };
|
||||
}
|
||||
|
||||
fn hookJniMainJavaSourceAt(_: *const Interpreter, args: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
|
||||
@@ -169,14 +169,14 @@ pub fn isJniReturnTypeSupported(table: *const types.TypeTable, ret_ty: TypeId) b
|
||||
};
|
||||
}
|
||||
|
||||
/// Encode a (foreign_path, method_name) pair as the JNI-resolved symbol
|
||||
/// Encode a (runtime_path, method_name) pair as the JNI-resolved symbol
|
||||
/// `Java_<pkg-mangled>_<Class>_sx_1<method-mangled>`. JNI mangling:
|
||||
/// `/` → `_`, `_` → `_1`. The `sx_` prefix matches the Java-side
|
||||
/// `private native sx_<name>(...)` delegate.
|
||||
pub fn jniMangleNativeName(allocator: std.mem.Allocator, foreign_path: []const u8, method_name: []const u8) ![]u8 {
|
||||
pub fn jniMangleNativeName(allocator: std.mem.Allocator, runtime_path: []const u8, method_name: []const u8) ![]u8 {
|
||||
var buf = std.ArrayList(u8).empty;
|
||||
try buf.appendSlice(allocator, "Java_");
|
||||
for (foreign_path) |ch| {
|
||||
for (runtime_path) |ch| {
|
||||
if (ch == '/') {
|
||||
try buf.append(allocator, '_');
|
||||
} else if (ch == '_') {
|
||||
|
||||
@@ -42,7 +42,7 @@ test "rejects non-main decl" {
|
||||
const a = std.testing.allocator;
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Foo",
|
||||
.foreign_path = "co/example/Foo",
|
||||
.runtime_path = "co/example/Foo",
|
||||
.runtime = .jni_class,
|
||||
.is_main = false, // ← not main
|
||||
};
|
||||
@@ -73,7 +73,7 @@ test "void onCreate(Bundle) with default Activity superclass" {
|
||||
} };
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/swipelab/sx_runtime/SxNativeActivity",
|
||||
.runtime_path = "co/swipelab/sx_runtime/SxNativeActivity",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{member},
|
||||
@@ -116,7 +116,7 @@ test "primitive params" {
|
||||
} };
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/sample/Sx",
|
||||
.runtime_path = "co/sample/Sx",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{member},
|
||||
@@ -157,7 +157,7 @@ test "declaration-only methods are skipped" {
|
||||
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/example/Sx",
|
||||
.runtime_path = "co/example/Sx",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{ bodied, decl_only },
|
||||
@@ -194,7 +194,7 @@ test "#extends Alias resolves through class registry" {
|
||||
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "co/example/Sx",
|
||||
.runtime_path = "co/example/Sx",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{ extends_member, method_member },
|
||||
@@ -204,7 +204,7 @@ test "#extends Alias resolves through class registry" {
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "extends co.example.MyParentActivity") != null);
|
||||
}
|
||||
|
||||
test "default-package class (no slash in foreign_path)" {
|
||||
test "default-package class (no slash in runtime_path)" {
|
||||
const a = std.testing.allocator;
|
||||
var arena = std.heap.ArenaAllocator.init(a);
|
||||
defer arena.deinit();
|
||||
@@ -222,7 +222,7 @@ test "default-package class (no slash in foreign_path)" {
|
||||
} };
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "Sx",
|
||||
.foreign_path = "SxNoPackage",
|
||||
.runtime_path = "SxNoPackage",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{member},
|
||||
@@ -253,7 +253,7 @@ test "lib_name renders System.loadLibrary static init block" {
|
||||
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{method},
|
||||
@@ -296,7 +296,7 @@ test "field declarations render as private Java fields" {
|
||||
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{ view_field, w_field, method },
|
||||
@@ -334,7 +334,7 @@ test "#implements clauses on the class header" {
|
||||
|
||||
const fcd: ast.RuntimeClassDecl = .{
|
||||
.name = "SxApp",
|
||||
.foreign_path = "co/example/SxApp",
|
||||
.runtime_path = "co/example/SxApp",
|
||||
.runtime = .jni_class,
|
||||
.is_main = true,
|
||||
.members = &.{ impl_a, impl_b, method },
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// Given a `RuntimeClassDecl` whose `is_main` flag is set, emit a `.java`
|
||||
// source file that:
|
||||
//
|
||||
// - declares a `public class` at the foreign_path's package + simple
|
||||
// - declares a `public class` at the runtime_path's package + simple
|
||||
// name (e.g. `co/swipelab/Test/SxTestActivity` →
|
||||
// `package co.swipelab.Test; public class SxTestActivity`);
|
||||
// - extends the parent specified by `#extends Alias` (or
|
||||
@@ -91,7 +91,7 @@ pub fn emitJavaSource(
|
||||
var buf: std.ArrayList(u8) = .empty;
|
||||
errdefer buf.deinit(allocator);
|
||||
|
||||
const parts = splitForeignPath(fcd.foreign_path);
|
||||
const parts = splitRuntimePath(fcd.runtime_path);
|
||||
if (parts.pkg.len > 0) {
|
||||
try buf.appendSlice(allocator, "package ");
|
||||
try appendDotted(allocator, &buf, parts.pkg);
|
||||
@@ -104,7 +104,7 @@ pub fn emitJavaSource(
|
||||
.extends => |alias| {
|
||||
if (opts.classes) |reg| {
|
||||
if (reg.get(alias)) |path| {
|
||||
parent = try foreignPathToJavaName(allocator, path);
|
||||
parent = try runtimePathToJavaName(allocator, path);
|
||||
parent_owned = true;
|
||||
break;
|
||||
}
|
||||
@@ -189,13 +189,13 @@ pub fn emitJavaSource(
|
||||
|
||||
const PathParts = struct { pkg: []const u8, cls: []const u8 };
|
||||
|
||||
fn splitForeignPath(foreign_path: []const u8) PathParts {
|
||||
const last_slash = std.mem.lastIndexOfScalar(u8, foreign_path, '/') orelse {
|
||||
return .{ .pkg = "", .cls = foreign_path };
|
||||
fn splitRuntimePath(runtime_path: []const u8) PathParts {
|
||||
const last_slash = std.mem.lastIndexOfScalar(u8, runtime_path, '/') orelse {
|
||||
return .{ .pkg = "", .cls = runtime_path };
|
||||
};
|
||||
return .{
|
||||
.pkg = foreign_path[0..last_slash],
|
||||
.cls = foreign_path[last_slash + 1 ..],
|
||||
.pkg = runtime_path[0..last_slash],
|
||||
.cls = runtime_path[last_slash + 1 ..],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ fn appendDotted(
|
||||
}
|
||||
}
|
||||
|
||||
fn foreignPathToJavaName(allocator: Allocator, slash_path: []const u8) EmitError![]u8 {
|
||||
fn runtimePathToJavaName(allocator: Allocator, slash_path: []const u8) EmitError![]u8 {
|
||||
var buf: std.ArrayList(u8) = .empty;
|
||||
try appendDotted(allocator, &buf, slash_path);
|
||||
return buf.toOwnedSlice(allocator);
|
||||
|
||||
@@ -386,7 +386,7 @@ test "lower: objcDefinedStateStructType collects user-declared fields" {
|
||||
};
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxFoo",
|
||||
.foreign_path = "SxFoo",
|
||||
.runtime_path = "SxFoo",
|
||||
.runtime = .objc_class,
|
||||
.members = &members,
|
||||
.is_extern = false,
|
||||
@@ -418,7 +418,7 @@ test "lower: objcDefinedStateStructType handles empty field set" {
|
||||
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxEmpty",
|
||||
.foreign_path = "SxEmpty",
|
||||
.runtime_path = "SxEmpty",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = false,
|
||||
@@ -450,7 +450,7 @@ test "lower: objcDefinedStateStructType skips non-field members" {
|
||||
};
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "SxMixed",
|
||||
.foreign_path = "SxMixed",
|
||||
.runtime_path = "SxMixed",
|
||||
.runtime = .objc_class,
|
||||
.members = &members,
|
||||
.is_extern = false,
|
||||
@@ -478,7 +478,7 @@ test "lower: objcTypeEncodingFromSignature emits @ for Obj-C class pointers" {
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
@@ -511,7 +511,7 @@ test "lower: objcTypeEncodingFromSignature unwraps optional to wire type" {
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
@@ -680,7 +680,7 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
const ns_ptr = module.types.ptrTo(ns_struct);
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
@@ -696,7 +696,7 @@ test "lower: isObjcClassPointer recognises pointer-to-foreign-Obj-C-class" {
|
||||
const proto_ptr = module.types.ptrTo(proto_struct);
|
||||
var proto_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSCopying",
|
||||
.foreign_path = "NSCopying",
|
||||
.runtime_path = "NSCopying",
|
||||
.runtime = .objc_protocol,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
@@ -728,7 +728,7 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = ns_name, .fields = &.{} } });
|
||||
var ns_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
@@ -753,7 +753,7 @@ test "lower: objcPropertyKind defaults + explicit ARC modifiers" {
|
||||
_ = module.types.intern(.{ .@"struct" = .{ .name = proto_name, .fields = &.{} } });
|
||||
var proto_fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSCoding",
|
||||
.foreign_path = "NSCoding",
|
||||
.runtime_path = "NSCoding",
|
||||
.runtime = .objc_protocol,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
|
||||
@@ -297,11 +297,11 @@ pub fn lowerRuntimeMethodCall(
|
||||
defer registry.deinit();
|
||||
var it = self.program_index.runtime_class_map.iterator();
|
||||
while (it.next()) |entry| {
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
|
||||
}
|
||||
|
||||
const desc_str = jni_descriptor.deriveMethod(self.alloc, .{
|
||||
.enclosing_path = fcd.foreign_path,
|
||||
.enclosing_path = fcd.runtime_path,
|
||||
.classes = ®istry,
|
||||
}, method) catch |err| {
|
||||
if (self.diagnostics) |d| {
|
||||
@@ -496,7 +496,7 @@ pub fn lowerObjcStaticCall(
|
||||
// Load the class object from its module-scoped cached slot.
|
||||
// `objc_getClass(<name>)` runs once at module-init via the
|
||||
// constructor emit_llvm synthesizes (see `emitObjcClassInit`).
|
||||
const class_slot_gid = self.internObjcClassObject(fcd.foreign_path);
|
||||
const class_slot_gid = self.internObjcClassObject(fcd.runtime_path);
|
||||
const class_slot_ptr = self.builder.emit(.{ .global_addr = class_slot_gid }, self.module.types.ptrTo(vptr_ty));
|
||||
const class_obj = self.builder.emit(.{ .load = .{ .operand = class_slot_ptr } }, vptr_ty);
|
||||
|
||||
@@ -602,7 +602,7 @@ pub fn lowerRuntimeStaticCall(
|
||||
defer registry.deinit();
|
||||
var it = self.program_index.runtime_class_map.iterator();
|
||||
while (it.next()) |entry| {
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
|
||||
}
|
||||
|
||||
// For `new`, the JNI descriptor's return position is `V` (the
|
||||
@@ -620,7 +620,7 @@ pub fn lowerRuntimeStaticCall(
|
||||
};
|
||||
|
||||
const descriptor = jni_descriptor.deriveMethod(self.alloc, .{
|
||||
.enclosing_path = fcd.foreign_path,
|
||||
.enclosing_path = fcd.runtime_path,
|
||||
.classes = ®istry,
|
||||
}, m_for_desc) catch |err| {
|
||||
if (self.diagnostics) |d| d.addFmt(.err, span, "JNI descriptor derivation failed for '{s}.new': {s}", .{ fcd.name, @errorName(err) });
|
||||
@@ -655,7 +655,7 @@ pub fn lowerRuntimeStaticCall(
|
||||
.args = args_owned,
|
||||
.is_static = false,
|
||||
.is_constructor = true,
|
||||
.parent_class_path = self.alloc.dupe(u8, fcd.foreign_path) catch fcd.foreign_path,
|
||||
.parent_class_path = self.alloc.dupe(u8, fcd.runtime_path) catch fcd.runtime_path,
|
||||
.cache_key = null,
|
||||
} }, ret_ty);
|
||||
}
|
||||
@@ -684,13 +684,13 @@ pub fn lowerSuperCall(
|
||||
return Ref.none;
|
||||
};
|
||||
|
||||
// Resolve parent foreign_path from the fcd's `#extends`. Default to
|
||||
// Resolve parent runtime_path from the fcd's `#extends`. Default to
|
||||
// android.app.Activity to match the jni_java_emit default.
|
||||
var parent_path: []const u8 = "android/app/Activity";
|
||||
for (fcd.members) |m| switch (m) {
|
||||
.extends => |alias| {
|
||||
if (self.program_index.runtime_class_map.get(alias)) |parent_fcd| {
|
||||
parent_path = parent_fcd.foreign_path;
|
||||
parent_path = parent_fcd.runtime_path;
|
||||
} else {
|
||||
parent_path = alias;
|
||||
}
|
||||
@@ -735,7 +735,7 @@ pub fn lowerSuperCall(
|
||||
defer registry.deinit();
|
||||
var it = self.program_index.runtime_class_map.iterator();
|
||||
while (it.next()) |entry| {
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.foreign_path) catch {};
|
||||
registry.put(entry.key_ptr.*, entry.value_ptr.*.runtime_path) catch {};
|
||||
}
|
||||
descriptor = jni_descriptor.deriveMethod(self.alloc, .{
|
||||
.enclosing_path = parent_path,
|
||||
@@ -822,14 +822,14 @@ pub fn registerRuntimeClassDecl(self: *Lowering, fcd: *const ast.RuntimeClassDec
|
||||
/// `#objc_class` to the actual Obj-C runtime class name. Falls
|
||||
/// back to "NSObject" when no `#extends` is declared.
|
||||
/// Aliases that resolve to foreign Obj-C classes use the
|
||||
/// foreign_path; aliases for OTHER sx-defined classes use the
|
||||
/// runtime_path; aliases for OTHER sx-defined classes use the
|
||||
/// alias name directly (which equals the Obj-C class name for
|
||||
/// sx-defined classes).
|
||||
pub fn resolveObjcParentName(self: *Lowering, fcd: *const ast.RuntimeClassDecl) []const u8 {
|
||||
for (fcd.members) |m| switch (m) {
|
||||
.extends => |alias| {
|
||||
if (self.program_index.runtime_class_map.get(alias)) |parent_fcd| {
|
||||
if (parent_fcd.is_extern) return parent_fcd.foreign_path;
|
||||
if (parent_fcd.is_extern) return parent_fcd.runtime_path;
|
||||
// Sx-defined parent — its alias IS its Obj-C name.
|
||||
return parent_fcd.name;
|
||||
}
|
||||
@@ -1039,8 +1039,8 @@ pub fn synthesizeJniMainStubs(self: *Lowering) void {
|
||||
if (!fcd.is_main) continue;
|
||||
if (fcd.is_extern) continue;
|
||||
if (fcd.runtime != .jni_class) continue;
|
||||
if (seen.contains(fcd.foreign_path)) continue;
|
||||
seen.put(fcd.foreign_path, {}) catch continue;
|
||||
if (seen.contains(fcd.runtime_path)) continue;
|
||||
seen.put(fcd.runtime_path, {}) catch continue;
|
||||
|
||||
for (fcd.members) |m| switch (m) {
|
||||
.method => |md| {
|
||||
@@ -1054,7 +1054,7 @@ pub fn synthesizeJniMainStubs(self: *Lowering) void {
|
||||
}
|
||||
|
||||
pub fn synthesizeJniMainStub(self: *Lowering, fcd: *const ast.RuntimeClassDecl, md: ast.RuntimeMethodDecl) void {
|
||||
const mangled = jni_descriptor.jniMangleNativeName(self.alloc, fcd.foreign_path, md.name) catch return;
|
||||
const mangled = jni_descriptor.jniMangleNativeName(self.alloc, fcd.runtime_path, md.name) catch return;
|
||||
const name_id = self.module.types.internString(mangled);
|
||||
|
||||
const ptr_void = self.module.types.ptrTo(.void);
|
||||
|
||||
@@ -70,7 +70,7 @@ test "ProgramIndex declaration maps round-trip (A1.1b)" {
|
||||
// runtime_class_map: sx alias → RuntimeClassDecl.
|
||||
const fcd = ast.RuntimeClassDecl{
|
||||
.name = "NSString",
|
||||
.foreign_path = "NSString",
|
||||
.runtime_path = "NSString",
|
||||
.runtime = .objc_class,
|
||||
.members = &.{},
|
||||
.is_extern = true,
|
||||
|
||||
@@ -704,7 +704,7 @@ fn compileWithTimer(allocator: std.mem.Allocator, io: std.Io, input_path: []cons
|
||||
if (e.build_config.manifest_path == null) e.build_config.manifest_path = merged_config.manifest_path;
|
||||
if (e.build_config.keystore_path == null) e.build_config.keystore_path = merged_config.keystore_path;
|
||||
// `#jni_main` decls flow from the compiler's lowering pass —
|
||||
// pre-rendered Java sources + the foreign_path for each. Build
|
||||
// pre-rendered Java sources + the runtime_path for each. Build
|
||||
// two parallel slices since BuildConfig hooks return strings.
|
||||
const jni_decls = comp.getJniMainEmissions();
|
||||
if (jni_decls.len > 0) {
|
||||
@@ -722,13 +722,13 @@ fn compileWithTimer(allocator: std.mem.Allocator, io: std.Io, input_path: []cons
|
||||
const fps = try allocator.alloc([]const u8, jni_decls.len);
|
||||
const srcs = try allocator.alloc([]const u8, jni_decls.len);
|
||||
for (jni_decls, 0..) |em, idx| {
|
||||
fps[idx] = em.foreign_path;
|
||||
fps[idx] = em.runtime_path;
|
||||
srcs[idx] = if (lib_name) |ln|
|
||||
try sx.ir.jni_java_emit.injectLoadLibrary(allocator, em.java_source, ln)
|
||||
else
|
||||
em.java_source;
|
||||
}
|
||||
e.build_config.jni_main_foreign_paths = fps;
|
||||
e.build_config.jni_main_runtime_paths = fps;
|
||||
e.build_config.jni_main_java_sources = srcs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1371,7 +1371,7 @@ pub const Parser = struct {
|
||||
return self.fail("expected string literal foreign-type path after directive");
|
||||
}
|
||||
const raw = self.tokenSlice(self.current);
|
||||
const foreign_path = raw[1 .. raw.len - 1];
|
||||
const runtime_path = raw[1 .. raw.len - 1];
|
||||
self.advance();
|
||||
try self.expect(.r_paren);
|
||||
|
||||
@@ -1621,7 +1621,7 @@ pub const Parser = struct {
|
||||
|
||||
return try self.createNode(start_pos, .{ .runtime_class_decl = .{
|
||||
.name = name,
|
||||
.foreign_path = foreign_path,
|
||||
.runtime_path = runtime_path,
|
||||
.runtime = runtime,
|
||||
.members = try members.toOwnedSlice(self.allocator),
|
||||
.is_extern = is_extern_eff,
|
||||
|
||||
@@ -9,9 +9,9 @@ const c = llvm.c;
|
||||
/// compiles via `javac`, dexes via `d8`, and bundles the resulting
|
||||
/// `classes.dex` into the APK.
|
||||
pub const JniMainEmission = struct {
|
||||
/// foreign_path of the source decl (e.g. "co/swipelab/sxmain/SxApp").
|
||||
/// runtime_path of the source decl (e.g. "co/swipelab/sxmain/SxApp").
|
||||
/// Splits into package + class name for `<stage>/java/<pkg>/<Class>.java`.
|
||||
foreign_path: []const u8,
|
||||
runtime_path: []const u8,
|
||||
/// Pre-rendered Java source bytes (from `jni_java_emit.emitJavaSource`).
|
||||
java_source: []const u8,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user