diff options
Diffstat (limited to 'src/source_manifest.zig')
| -rw-r--r-- | src/source_manifest.zig | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/source_manifest.zig b/src/source_manifest.zig deleted file mode 100644 index c3bfde88..00000000 --- a/src/source_manifest.zig +++ /dev/null @@ -1,50 +0,0 @@ -//! The virtual filesystem: pardes's own source, embedded, as an ALLOWLIST. -//! -//! This is the default filesystem — what a host that implements no file method -//! reads and writes, and the only one the browser has ever had. It replaced a -//! build-time generator that embedded every tracked `.zig` file: 64 files and -//! 2.4 MB of generated Zig, rediscovered on every consumer build because the -//! tracked set can change without any known input changing. -//! -//! An allowlist instead, for the reason the generator's own comment gave away: -//! nothing needs all of them. What earns a place here is a file that explains -//! how pardes works to someone reading it inside pardes — the core, the host -//! seam, the keymap, the build. `src/pardes.zig` alone is 722 KB of the total, -//! and it is the one file worth that: it IS the program. -//! -//! Paths are as a user would type them, repo-root-relative, which is what -//! `look` resolves a click against. - -const limits = @import("limits.zig"); - -pub const Source = struct { path: []const u8, contents: []const u8 }; - -/// A slice, not an array: the P4 table is empty (see `limits.embedded_sources` -/// for why) and every consumer only ever iterates or takes `.len`. -pub const all: []const Source = if (limits.embedded_sources) &allowlist else &.{}; - -const allowlist = [_]Source{ - .{ .path = "build.zig", .contents = @embedFile("root-build.zig") }, - .{ .path = "build.zig.zon", .contents = @embedFile("root-build.zig.zon") }, - .{ .path = "src/pardes.zig", .contents = @embedFile("pardes.zig") }, - .{ .path = "src/host.zig", .contents = @embedFile("host.zig") }, - .{ .path = "src/config.zig", .contents = @embedFile("config.zig") }, - .{ .path = "src/main.zig", .contents = @embedFile("main.zig") }, - .{ .path = "src/builtins.zig", .contents = @embedFile("builtins.zig") }, - .{ .path = "src/grammar_manifest.zig", .contents = @embedFile("grammar_manifest.zig") }, - .{ .path = "src/source_manifest.zig", .contents = @embedFile("source_manifest.zig") }, - .{ .path = "src/CHANGELOG.md", .contents = @embedFile("CHANGELOG.md") }, -}; - -/// The written-file override wins, then the allowlist. Callers own no memory -/// here: every byte is static or lives in the Fallback that answered. -pub fn find(path: []const u8) ?[]const u8 { - for (all) |s| if (eql(s.path, path)) return s.contents; - return null; -} - -fn eql(a: []const u8, b: []const u8) bool { - if (a.len != b.len) return false; - for (a, b) |x, y| if (x != y) return false; - return true; -} |
