| 12345678910111213141516171819202122 |
- // Multi-argument and optional-argument world reads. What this pins in the lowered output:
- // arguments are packed positionally, and an absent trailing optional yields a SHORTER
- // array — not a `undefined` hole — because `inputHash({op, args})` is the journal key and
- // `["TODO"]` must not hash the same as `["TODO", undefined]`.
- const hits = await __host.worldRead("world-read#1", "grep", ["TODO"]);
- const narrowed = await __host.worldRead("world-read#2", "grep", ["TODO", "*.ts"]);
- const changed = await __host.worldRead("world-read#3", "git-changed-files", []);
- const againstMain = await __host.worldRead("world-read#4", "git-changed-files", ["main"]);
- const wholeDiff = await __host.worldRead("world-read#5", "git-diff", []);
- const onePath = await __host.worldRead("world-read#6", "git-diff", ["main", "src/a.ts"]);
- const state = await __host.worldRead("world-read#7", "git-status", []);
- const recent = await __host.worldRead("world-read#8", "git-log", []);
- const fiveCommits = await __host.worldRead("world-read#9", "git-log", [5]);
- // The collision case, in lowered form: a top-level log call becomes __host.log, while the
- // git container's log member becomes __host.worldRead with the "git-log" op.
- __host.log(`${hits.length} / ${narrowed.length}`);
- return {
- changed: changed.length + againstMain.length,
- commits: recent.length + fiveCommits.length,
- diffBytes: wholeDiff.length + onePath.length,
- branch: state.branch ?? "detached",
- };
|