bundling: fs/process stdlib + post-link callback + Apple .app in sx
Campaign Weeks 3-6 of /Users/agra/.claude/plans/lets-plan-to-move-splendid-pumpkin.md
land in one push: the bundling pipeline that used to live in
src/target.zig (createBundle, embedFramework, extractEntitlements,
buildInfoPlist, codesign) now lives in
library/modules/platform/bundle.sx and runs in the IR interpreter
after target.link() returns.
New language-side surface:
- library/modules/fs.sx — POSIX libc bindings (open/read/write/close,
mkdir/unlink/rmdir, chmod, rename, access, basename/dirname). Variadic
open() lowers to C's varargs via the new args: ..T form. Direct libc
calls bypass *File method dispatch so they work from the post-link
IR interpreter.
- library/modules/process.sx — popen-based run(cmd) returning
ProcessResult{ exit_code, stdout }, plus env() and find_executable().
- library/modules/std.sx — xml_escape(s) and variadic path_join(parts).
- library/modules/compiler.sx — BuildOptions grows
set_post_link_callback / set_post_link_module / binary_path
accessors; bundle_path/bundle_id/codesign_identity/provisioning_profile
setters + accessors; per-target predicates is_macos/is_ios/
is_ios_device/is_ios_simulator + target_triple; framework_count /
framework_at(i) / framework_path_count / framework_path_at(i);
add_asset_dir(src, dest) + asset_dir_count / src_at / dest_at.
Compiler-side wiring:
- src/ir/compiler_hooks.zig — BuildConfig now carries post_link_callback_fn,
post_link_module, binary_path, bundle_*, target_triple,
target_frameworks, target_framework_paths, asset_dirs. Hook registry
exposes every accessor; getters return "" / 0 for unset fields so
bundle.sx can treat absent values uniformly.
- src/ir/host_ffi.zig (new) — dlsym(RTLD_DEFAULT) + arity-switched cdecl
trampolines so #foreign("c") declarations resolve through the host
libc during #run / post-link interpretation.
- src/ir/interp.zig — callForeign dispatch; build_config pointer
injection so accessor hooks see live state during re-entry.
- src/core.zig — keeps the IR module alive past generateCode; exposes
invokeByName / invokeByFuncId so main.zig can re-enter the
interpreter after linking.
- src/main.zig — wires bundle/codesign/provisioning CLI flags +
target_triple + framework lists into BuildConfig; invokes the
post-link callback (by FuncId or by <module>.bundle_main lookup) once
target.link() returns. When --bundle is set but no callback is
registered, auto-falls-back to post_link_module = "platform.bundle"
so the legacy --bundle CLI keeps working for any program that imports
modules/platform/bundle.sx.
Apple .app bundler (library/modules/platform/bundle.sx):
- Single bundle_main entry covers macOS, iOS simulator, iOS device.
Per-target Info.plist switch keys off is_ios()/is_ios_simulator() —
iOS emits UIDeviceFamily / LSRequiresIPhoneOS /
UIApplicationSceneManifest / DTPlatformName (iPhoneOS or
iPhoneSimulator); macOS emits the minimal CFBundle* set.
- iOS-only steps:
- Provisioning embed: fs.read_file + fs.write_file to
<bundle>/embedded.mobileprovision.
- Framework embed: recursive cp -R per -F search path into
<bundle>/Frameworks/<Name>.framework/ (until fs.sx grows list_dir).
- Entitlements extraction: four process.run calls (security cms -D,
plutil -extract Entitlements xml1, plutil -extract
ApplicationIdentifierPrefix.0, plutil -replace application-identifier)
resolving the wildcard <TEAM>.* -> <TEAM>.<bundle_id>.
- Real codesign with --entitlements when present.
- Asset dirs (add_asset_dir): recursive cp -R src/. into <bundle>/dest/.
Missing src is treated as "nothing to do" so projects can register
add_asset_dir("assets", "assets") unconditionally.
Parser:
- parseStmt() now accepts #import \"path\"; and #framework \"Name\"; as
statement-position tokens. Needed for top-level
inline if OS == .android { #import \"modules/platform/android.sx\"; }
blocks (issue-0042 flatten pass surfaces them); chess's
inline-if-with-#import was rejected at parse time before this fix.
Removals from src/target.zig:
- createBundle, embedFramework, extractEntitlements, buildInfoPlist,
codesign (~210 lines). main.zig no longer calls createBundle after
link(); the sx callback is the single entry point.
Tests / regression markers (all run under sx run host JIT):
- examples/115-post-link-callback.sx — callback registration round-trip.
- examples/116-fs-roundtrip.sx — fs.write_file -> fs.read_file -> exists.
- examples/117-process-roundtrip.sx — process.run + env + find_executable.
- examples/118-macos-bundle.sx — macOS .app via bundle_main callback.
- examples/119-interp-cast-ptr-cmp.sx — cast(T) val under interpreter.
- examples/120-interp-variadic-any.sx — variadic ..Any indexing in IR
interpreter.
- examples/121-ios-sim-bundle.sx — iOS-sim cross-compile + .app with
iOS-shaped Info.plist (added to tests/cross_compile.sh as the
ios-sim tuple).
- examples/122-ios-device-bundle.sx — iOS device cross-compile +
full codesign pipeline (provisioning embed + entitlements
extraction + --entitlements codesign). Manually verified end-to-end:
installed via xcrun devicectl device install app + launched
successfully on iPhone 17 Pro.
- examples/123-inline-if-import-in-body.sx — locks in the parser fix.
zig build && zig build test && bash tests/run_examples.sh => 141 passed,
0 failed; bash tests/cross_compile.sh => 7 passed, 0 failed.
This commit is contained in:
@@ -3,19 +3,71 @@ const Allocator = std.mem.Allocator;
|
||||
const interp_mod = @import("interp.zig");
|
||||
const Value = interp_mod.Value;
|
||||
const Interpreter = interp_mod.Interpreter;
|
||||
const inst = @import("inst.zig");
|
||||
const FuncId = inst.FuncId;
|
||||
|
||||
// ── BuildConfig ─────────────────────────────────────────────────────────
|
||||
// Mutable build configuration accumulated by #run blocks via #compiler methods.
|
||||
|
||||
/// `(src_dir, dest_in_bundle)` pair recorded by
|
||||
/// `BuildOptions.add_asset_dir(src, dest)`. The sx bundler walks the
|
||||
/// list and recursively copies each `src` directory into the bundle
|
||||
/// at the relative `dest` path (e.g. `("assets", "assets")` copies
|
||||
/// `./assets/` to `<bundle>/assets/`). Android's Week-7 APK path will
|
||||
/// zip the same pairs into the unaligned APK.
|
||||
pub const AssetDir = struct {
|
||||
src: []const u8,
|
||||
dest: []const u8,
|
||||
};
|
||||
|
||||
pub const BuildConfig = struct {
|
||||
link_flags: std.ArrayList([]const u8) = .empty,
|
||||
frameworks: std.ArrayList([]const u8) = .empty,
|
||||
asset_dirs: std.ArrayList(AssetDir) = .empty,
|
||||
output_path: ?[]const u8 = null,
|
||||
wasm_shell_path: ?[]const u8 = null,
|
||||
|
||||
/// Post-link callback registered via
|
||||
/// `BuildOptions.set_post_link_callback(fn)`. When set, the
|
||||
/// compiler re-enters the IR interpreter after `target.link()`
|
||||
/// and invokes this function with no args. A `false` return is
|
||||
/// treated as a build failure.
|
||||
post_link_callback_fn: ?FuncId = null,
|
||||
/// Alternative to `post_link_callback_fn`: the qualified name of
|
||||
/// a module whose `bundle_main` function should be called
|
||||
/// post-link.
|
||||
post_link_module: ?[]const u8 = null,
|
||||
|
||||
/// Path of the freshly-linked binary, populated by `main.zig`
|
||||
/// right before the post-link callback runs. The sx-side bundler
|
||||
/// reads this via `binary_path()` to know what file to wrap.
|
||||
binary_path: ?[]const u8 = null,
|
||||
|
||||
// Apple `.app` / Android `.apk` bundling parameters. Set either
|
||||
// by the sx-side `BuildOptions.set_bundle_*` methods (preferred)
|
||||
// or by main.zig from CLI flags (transitional fallback). The sx
|
||||
// bundler reads them via the matching accessor methods.
|
||||
bundle_path: ?[]const u8 = null,
|
||||
bundle_id: ?[]const u8 = null,
|
||||
codesign_identity: ?[]const u8 = null,
|
||||
provisioning_profile: ?[]const u8 = null,
|
||||
|
||||
/// Target triple as supplied to `--target` (canonicalized).
|
||||
/// Populated by main.zig before the post-link callback runs so the
|
||||
/// sx bundler can switch on iOS vs. macOS vs. simulator.
|
||||
target_triple: ?[]const u8 = null,
|
||||
|
||||
/// Frameworks the binary links against (`-framework` names) and
|
||||
/// the search paths to look them up in (`-F` directories), forwarded
|
||||
/// from the link step so the sx bundler can embed them into
|
||||
/// `<bundle>/Frameworks/`.
|
||||
target_frameworks: []const []const u8 = &.{},
|
||||
target_framework_paths: []const []const u8 = &.{},
|
||||
|
||||
pub fn deinit(self: *BuildConfig, alloc: Allocator) void {
|
||||
self.link_flags.deinit(alloc);
|
||||
self.frameworks.deinit(alloc);
|
||||
self.asset_dirs.deinit(alloc);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,8 +107,36 @@ pub const Registry = struct {
|
||||
self.hooks.put("build_options", &hookBuildOptions) catch {};
|
||||
self.hooks.put("BuildOptions.add_link_flag", &hookAddLinkFlag) catch {};
|
||||
self.hooks.put("BuildOptions.add_framework", &hookAddFramework) catch {};
|
||||
self.hooks.put("BuildOptions.add_asset_dir", &hookAddAssetDir) catch {};
|
||||
self.hooks.put("BuildOptions.asset_dir_count", &hookAssetDirCount) catch {};
|
||||
self.hooks.put("BuildOptions.asset_dir_src_at", &hookAssetDirSrcAt) catch {};
|
||||
self.hooks.put("BuildOptions.asset_dir_dest_at", &hookAssetDirDestAt) catch {};
|
||||
self.hooks.put("BuildOptions.set_output_path", &hookSetOutputPath) catch {};
|
||||
self.hooks.put("BuildOptions.set_wasm_shell", &hookSetWasmShell) catch {};
|
||||
self.hooks.put("BuildOptions.set_post_link_callback", &hookSetPostLinkCallback) catch {};
|
||||
self.hooks.put("BuildOptions.set_post_link_module", &hookSetPostLinkModule) catch {};
|
||||
self.hooks.put("BuildOptions.binary_path", &hookGetBinaryPath) catch {};
|
||||
// Bundling setters
|
||||
self.hooks.put("BuildOptions.set_bundle_path", &hookSetBundlePath) catch {};
|
||||
self.hooks.put("BuildOptions.set_bundle_id", &hookSetBundleId) catch {};
|
||||
self.hooks.put("BuildOptions.set_codesign_identity", &hookSetCodesignIdentity) catch {};
|
||||
self.hooks.put("BuildOptions.set_provisioning_profile", &hookSetProvisioningProfile) catch {};
|
||||
// Bundling accessors
|
||||
self.hooks.put("BuildOptions.bundle_path", &hookGetBundlePath) catch {};
|
||||
self.hooks.put("BuildOptions.bundle_id", &hookGetBundleId) catch {};
|
||||
self.hooks.put("BuildOptions.codesign_identity", &hookGetCodesignIdentity) catch {};
|
||||
self.hooks.put("BuildOptions.provisioning_profile", &hookGetProvisioningProfile) catch {};
|
||||
// Target accessors — mirror TargetConfig.is{MacOS,IOS,IOSDevice,IOSSimulator}()
|
||||
self.hooks.put("BuildOptions.target_triple", &hookGetTargetTriple) catch {};
|
||||
self.hooks.put("BuildOptions.is_macos", &hookIsMacOS) catch {};
|
||||
self.hooks.put("BuildOptions.is_ios", &hookIsIOS) catch {};
|
||||
self.hooks.put("BuildOptions.is_ios_device", &hookIsIOSDevice) catch {};
|
||||
self.hooks.put("BuildOptions.is_ios_simulator", &hookIsIOSSimulator) catch {};
|
||||
// Framework list accessors (for `.app/Frameworks/` embedding)
|
||||
self.hooks.put("BuildOptions.framework_count", &hookFrameworkCount) catch {};
|
||||
self.hooks.put("BuildOptions.framework_at", &hookFrameworkAt) catch {};
|
||||
self.hooks.put("BuildOptions.framework_path_count", &hookFrameworkPathCount) catch {};
|
||||
self.hooks.put("BuildOptions.framework_path_at", &hookFrameworkPathAt) catch {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -105,6 +185,40 @@ fn hookAddFramework(
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookAddAssetDir(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
// args: [self (BuildOptions value), src_path, dest_path_in_bundle]
|
||||
if (args.len < 3) return .void_val;
|
||||
const src = args[1].asString(interp) orelse return error.TypeError;
|
||||
const dest = args[2].asString(interp) orelse return error.TypeError;
|
||||
const src_dup = alloc.dupe(u8, src) catch return error.CannotEvalComptime;
|
||||
const dest_dup = alloc.dupe(u8, dest) catch return error.CannotEvalComptime;
|
||||
bc.asset_dirs.append(alloc, .{ .src = src_dup, .dest = dest_dup }) catch return error.CannotEvalComptime;
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookAssetDirCount(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .int = @intCast(bc.asset_dirs.items.len) };
|
||||
}
|
||||
|
||||
fn hookAssetDirSrcAt(_: *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.asset_dirs.items.len) return Value{ .string = "" };
|
||||
return Value{ .string = bc.asset_dirs.items[@intCast(idx)].src };
|
||||
}
|
||||
|
||||
fn hookAssetDirDestAt(_: *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.asset_dirs.items.len) return Value{ .string = "" };
|
||||
return Value{ .string = bc.asset_dirs.items[@intCast(idx)].dest };
|
||||
}
|
||||
|
||||
fn hookSetOutputPath(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
@@ -134,3 +248,199 @@ fn hookSetWasmShell(
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookSetPostLinkCallback(
|
||||
_: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
_: Allocator,
|
||||
) HookError!Value {
|
||||
// args: [self (BuildOptions value), fn_value]. We accept a function
|
||||
// value (.func_ref) and stash the FuncId so `main.zig` can re-enter
|
||||
// the interpreter after linking.
|
||||
if (args.len < 2) return .void_val;
|
||||
switch (args[1]) {
|
||||
.func_ref => |id| bc.post_link_callback_fn = id,
|
||||
else => return error.TypeError,
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookSetPostLinkModule(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
if (args.len < 2) return .void_val;
|
||||
if (args[1].asString(interp)) |s| {
|
||||
bc.post_link_module = alloc.dupe(u8, s) catch return error.CannotEvalComptime;
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
/// Read the linked-binary path that main.zig populated right before
|
||||
/// invoking the post-link callback. Returns the fat-string aggregate
|
||||
/// the interpreter normally hands out for sx `string` values.
|
||||
fn hookGetBinaryPath(
|
||||
interp: *const Interpreter,
|
||||
_: []const Value,
|
||||
bc: *BuildConfig,
|
||||
_: Allocator,
|
||||
) HookError!Value {
|
||||
_ = interp;
|
||||
const path = bc.binary_path orelse "";
|
||||
return Value{ .string = path };
|
||||
}
|
||||
|
||||
// ── Bundling setters & accessors ─────────────────────────────────────
|
||||
// Same pattern as set_output_path: take a string arg, dupe into the
|
||||
// long-lived allocator, store on BuildConfig. The companion accessor
|
||||
// reads back the same field; empty string when unset.
|
||||
|
||||
fn hookSetBundlePath(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
if (args.len < 2) return .void_val;
|
||||
if (args[1].asString(interp)) |s| {
|
||||
bc.bundle_path = alloc.dupe(u8, s) catch return error.CannotEvalComptime;
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookSetBundleId(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
if (args.len < 2) return .void_val;
|
||||
if (args[1].asString(interp)) |s| {
|
||||
bc.bundle_id = alloc.dupe(u8, s) catch return error.CannotEvalComptime;
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookSetCodesignIdentity(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
if (args.len < 2) return .void_val;
|
||||
if (args[1].asString(interp)) |s| {
|
||||
bc.codesign_identity = alloc.dupe(u8, s) catch return error.CannotEvalComptime;
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookSetProvisioningProfile(
|
||||
interp: *const Interpreter,
|
||||
args: []const Value,
|
||||
bc: *BuildConfig,
|
||||
alloc: Allocator,
|
||||
) HookError!Value {
|
||||
if (args.len < 2) return .void_val;
|
||||
if (args[1].asString(interp)) |s| {
|
||||
bc.provisioning_profile = alloc.dupe(u8, s) catch return error.CannotEvalComptime;
|
||||
}
|
||||
return .void_val;
|
||||
}
|
||||
|
||||
fn hookGetBundlePath(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .string = bc.bundle_path orelse "" };
|
||||
}
|
||||
|
||||
fn hookGetBundleId(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .string = bc.bundle_id orelse "" };
|
||||
}
|
||||
|
||||
fn hookGetCodesignIdentity(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .string = bc.codesign_identity orelse "" };
|
||||
}
|
||||
|
||||
fn hookGetProvisioningProfile(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .string = bc.provisioning_profile orelse "" };
|
||||
}
|
||||
|
||||
// ── Target accessors ──────────────────────────────────────────────────
|
||||
// These look at the target_triple that main.zig populates and answer
|
||||
// the same questions TargetConfig's helpers do for Zig callers.
|
||||
|
||||
fn tripleContains(triple: ?[]const u8, needle: []const u8) bool {
|
||||
const t = triple orelse return false;
|
||||
return std.mem.indexOf(u8, t, needle) != null;
|
||||
}
|
||||
|
||||
fn isIOSTriple(triple: ?[]const u8) bool {
|
||||
return tripleContains(triple, "apple-ios");
|
||||
}
|
||||
|
||||
fn hookGetTargetTriple(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .string = bc.target_triple orelse "" };
|
||||
}
|
||||
|
||||
fn hookIsMacOS(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
if (isIOSTriple(bc.target_triple)) return Value{ .boolean = false };
|
||||
const t = bc.target_triple orelse "";
|
||||
const is_mac = std.mem.indexOf(u8, t, "apple-macosx") != null or
|
||||
std.mem.indexOf(u8, t, "apple-macos") != null or
|
||||
std.mem.indexOf(u8, t, "apple-darwin") != null;
|
||||
return Value{ .boolean = is_mac };
|
||||
}
|
||||
|
||||
fn hookIsIOS(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return Value{ .boolean = isIOSTriple(bc.target_triple) };
|
||||
}
|
||||
|
||||
fn hookIsIOSDevice(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
const ios = isIOSTriple(bc.target_triple);
|
||||
const sim = tripleContains(bc.target_triple, "simulator");
|
||||
return Value{ .boolean = ios and !sim };
|
||||
}
|
||||
|
||||
fn hookIsIOSSimulator(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
const ios = isIOSTriple(bc.target_triple);
|
||||
const sim = tripleContains(bc.target_triple, "simulator");
|
||||
return Value{ .boolean = ios and sim };
|
||||
}
|
||||
|
||||
// ── Framework list accessors ──────────────────────────────────────────
|
||||
// The Apple .app bundler in `library/modules/platform/bundle.sx` walks
|
||||
// the framework list to recursively copy each `<Name>.framework`
|
||||
// directory from the user's -F search paths into `<bundle>/Frameworks/`.
|
||||
// Slice-of-string returns aren't natively expressible as a Value, so we
|
||||
// expose count + indexed lookups instead.
|
||||
|
||||
fn intValue(n: i64) Value {
|
||||
return Value{ .int = n };
|
||||
}
|
||||
|
||||
fn hookFrameworkCount(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return intValue(@intCast(bc.target_frameworks.len));
|
||||
}
|
||||
|
||||
fn hookFrameworkAt(_: *const Interpreter, args: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
if (args.len < 2) return Value{ .string = "" };
|
||||
const idx_i64 = args[1].asInt() orelse return error.TypeError;
|
||||
if (idx_i64 < 0 or @as(usize, @intCast(idx_i64)) >= bc.target_frameworks.len) {
|
||||
return Value{ .string = "" };
|
||||
}
|
||||
return Value{ .string = bc.target_frameworks[@intCast(idx_i64)] };
|
||||
}
|
||||
|
||||
fn hookFrameworkPathCount(_: *const Interpreter, _: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
return intValue(@intCast(bc.target_framework_paths.len));
|
||||
}
|
||||
|
||||
fn hookFrameworkPathAt(_: *const Interpreter, args: []const Value, bc: *BuildConfig, _: Allocator) HookError!Value {
|
||||
if (args.len < 2) return Value{ .string = "" };
|
||||
const idx_i64 = args[1].asInt() orelse return error.TypeError;
|
||||
if (idx_i64 < 0 or @as(usize, @intCast(idx_i64)) >= bc.target_framework_paths.len) {
|
||||
return Value{ .string = "" };
|
||||
}
|
||||
return Value{ .string = bc.target_framework_paths[@intCast(idx_i64)] };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user