diff --git a/docs/proposals/PACKAGE_MANAGER_LOGIC_PROPOSAL.md b/docs/proposals/PACKAGE_MANAGER_LOGIC_PROPOSAL.md index 9bf967930..10c180ef0 100644 --- a/docs/proposals/PACKAGE_MANAGER_LOGIC_PROPOSAL.md +++ b/docs/proposals/PACKAGE_MANAGER_LOGIC_PROPOSAL.md @@ -116,6 +116,168 @@ this resolver is not redundant with apt: it reasons about a boundary apt is built to ignore. (Historical echo: Puppy's abandoned `Pkg` project and PPM's dependency heuristics were circling exactly this in bash.) +### 2e. Graduated freeze semantics: holds have REASONS (P0.5 direction) + +Follow-on insight (from the TrixiePup discussion): a hold is a boolean, but +freezing is not — and the reason determines upgrade safety. TrixiePup's +practical problem is arguably that it freezes too much precisely because apt +cannot represent WHY anything is frozen. Model it: `base(Pkg-Ver, Reason)`, + +| Reason | meaning | safe to upgrade? | +|---|---|---| +| `layer_shadow` | files live in read-only SFS; save-layer upgrade duplicates/shadows | yes, at a computable cost (shadow bytes) | +| `abi_anchor` | other base packages built against this version | only as a **coordinated set** | +| `puppy_modified` | Woof-CE patched/trimmed/replaced it | not without re-applying modifications | +| `footprint` | held only for savefile size | yes, if cost accepted | +| `blanket` | held with no specific constraint | probably — the over-freezing category | + +New queries from the same clauses: `safe_upgrade(Pkg, NewVer, Cost)` and +`upgrade_set(Pkg, NewVer, Set)` — the minimal reverse-dependency closure that +must move together (apt's `full-upgrade` computed minimally + explainably). +"Why is this frozen?" becomes a query instead of forum lore. + +Crucially, most reasons are **derivable, not hand-annotated**: `abi_anchor` +from reverse-dep degree + constraint tightness over the catalog; `layer_shadow` +from the SFS manifest; only `puppy_modified` needs Woof-CE build metadata +(`DISTRO_PKGS_SPECS`, trim lists). A blanket hold is then detectable as "held +with no derivable reason" — the over-freezing diagnosis, computed. + +Related bounded task — **done**: the dormant `Pkg` project was mined as a +requirements source; see `PKG_MINING_NOTES.md` (485 lines, code-cited: 8 +adopt / 3 adapt / 3 already-covered / 1 out-of-scope, top-10 ranked list). +Headline finds: Pkg's own orphan-cleanup was DEAD CODE because its flat +install record never distinguished requested-vs-dependency (validating our +`requested/1`/`installed/1` split); its blacklist accidentally blocked +REMOVAL of blacklisted-but-installed packages (why `excluded/1` must stay +decoupled from removal safety); DEVX-layer detection via a `which gcc` proxy +(validating mount-table-driven `in_layer/2`, §2f); repo federation is a +priority-ordered per-repo fallback chain, not a flat bag. + +### 2f. Two dependency graphs: declared vs linked (check_deps/ListDD lineage) + +Further Puppy research (check_deps.sh, ListDD, ldd, resolvedeps.sh) shows the +ecosystem always ran on TWO graphs, and P0 models only the first: + +1. **Declared** — package-level metadata (`depends/4`): human-curated, often + incomplete or wrong; what apt reasons over. +2. **Linked** — what binaries actually require: ELF `DT_NEEDED` sonames, + mechanically extractable (`readelf -d`), ground truth for dynamic linkage; + what Puppy's checkers worked from when metadata failed. + +Model additions (P0.5/P2 direction): +- `needs_soname(Pkg-Ver, Soname)` / `provides_soname(Pkg-Ver, Soname)` — + derivable at scan/build time; natural rows for the GP-LMDB catalog store. +- `soname_provider(Soname, Candidates)` — the "libXfixes.so.3 → which + package?" lookup Puppy users did by forum search, as a join. +- `verify_closure(Layer, Report)` — cross-check a declared-deps + `layer_closure` at soname level: declared-but-unlinked (trimmable bloat) + and linked-but-undeclared (the metadata bugs check_deps existed to catch). + The graphs audit each other; neither alone suffices. +- **Named layers, not one base**: resolvedeps.sh's filter chain + (`no_dupes_no_builtins_no_devx_no_blacklisted`) shows the exclusion set is + layered — base SFS, devx SFS, blacklist. Generalize `base/1` to + `in_layer(PkgOrSoname, LayerName)` with closures computed relative to the + loaded-layer set. +- **Honest limits, modeled**: ELF analysis misses dlopen, plugins + (GStreamer/GTK/Python), data files, exec'd helpers, and symbol-version ABI + breaks. Soname facts are labeled *detected dynamic linkage* — never claimed + as the complete runtime closure. + +(check_deps.sh source lives in the Woof-CE rootfs skeleton +`/usr/local/petget/check_deps.sh`, not the Pkg repo — a separate targeted +recon if we want its exact aggregation/exclusion rules.) + +### 2g. Time-indexed catalogs: version selection UNDER the ceiling + +The manual workflow that motivated this (user report): see the missing `.so`, +search Debian's **Contents index** for the exact package containing it, then +install a version *behind* the current snapshot that still fits the frozen +base — two things apt structurally cannot do: + +1. **Soname → package reverse lookup**: apt doesn't do it (separate + `apt-file` tooling; PPM users did it in a browser). For us it's + `soname_provider/2`, and Debian's `Contents-.gz` (path → package, + huge, queried by bound key) is its ingestion source — exactly the shape of + the D43 seek-indexed fact store. Ingest once; the browser session becomes + an O(log n) seek. +2. **Cross-snapshot resolution**: apt reasons over ONE Packages snapshot. + Debian keeps every version (snapshot.debian.org). Give catalog facts a + snapshot dimension — `package(Name, Ver, Snap)`, `depends(..., Snap)` — + and "newest version of P satisfying C whose closure fits under `base/1`" + ranges over history. The §2d ceiling explanation gains its natural + follow-up: *blocked at today's version — but snapshot 2024-06's fits.* + +The full manual flow compiles to one query chain: +`missing_sonames` → `soname_provider` (multi-snapshot Contents facts) → +`resolve_layered` (candidate pinned) → `layer_closure`. + +### 2h. The symbol level, and the fact sources nobody's solver reads + +Snapshots answered: the archives EXIST — snapshot.debian.org (whole archive, +several captures daily, since ~2005; apt can install FROM one dated snapshot +but cannot search ACROSS them), snapshot.ubuntu.com, Launchpad's every-built- +.deb, archive.debian.org. §2g's time-indexed catalog is published data +awaiting its first relational consumer. + +Below the soname graph sits a third: **symbols**. A soname can match while a +versioned symbol doesn't (`version 'GLIBC_2.34' not found`). Facts: +`needs_symbol(Bin, Sym, SymVer)` / `exports_symbol(Lib-Ver, Sym, SymVer)` — +and Debian already publishes the database: per-library **`.symbols` files** +(symbol → minimal introducing version; what dpkg-shlibdeps consumes). This +transforms §2e's `upgrade_set`: a base-lib upgrade is safe for a dependent iff +the new version exports a SUPERSET of the symbols that dependent actually +uses — usually a stable subset, so the true coordinated set is far smaller +than declared reverse-deps (the pessimism that makes TrixiePup over-freeze). +When blocked, the explanation is exact: *installed X links foo_frob@LIBFOO_2.35, +absent from the proposed version.* Set containment over facts — native Prolog. + +Further published sources for the spec's fact schema: libabigail/abidiff ABI +diffs (`abi_breaks/4`, stricter than symbols); the Debian security tracker's +CVE JSON (§2g's advisory annotation); file conflicts derived from the Contents +index already ingested; Provides/virtual packages; Essential/priority flags. +Lineage note, honestly: Debian's EDOS/Mancoosi work and `dose-debcheck` +formalized installability long ago — our contribution is unifying ALL layers +(declared / soname / symbol / ABI / time / advisories) in ONE queryable, +explaining, transpilable spec rather than one standalone checker per layer. + +### 2i. Maintainer scripts and platform seams: classify the imperative residue + +Two places the declarative model meets imperative reality (user-raised): +pre/post-install scripts, and platform-assumption seams (graphics, audio, +IPC/dbus, init — Xorg/Wayland, systemd-vs-not). + +**Maintainer scripts.** Stripping them when upgrading frozen packages is +sometimes right and sometimes breaks things — because "the script" bundles +distinct EFFECTS. Most content is debhelper-generated boilerplate from a small +template vocabulary, so it classifies: `maintscript(Pkg-Ver, Phase, Class)`, +Class ∈ ldconfig | alternatives(N) | sysusers(U) | systemd_enable(Unit) | +cache(Kind) | conffile_move | custom(Hash). The strip/keep decision becomes a +relation `script_action(Class, Platform, Action)`: +- **bake_at_build** — file-producing effects run once in a chroot against the + target base while BUILDING the layer; outputs baked into the SFS. Scripts + belong to layer-build time, not live-install time, in the layered model. +- **noop_on_platform** — e.g. systemd_enable with no systemd; but the class + lets us check whether the package's FUNCTION needs the unit → conflict, not + silent no-op. +- **run_on_target** — genuinely environmental (user creation). +- **needs_review(custom)** — unrecognized code surfaces for review/sandbox, + never silently stripped NOR silently trusted. The irreducible residue, + explicit. + +**Platform seams.** `platform_provides(Platform, Capability)` facts (Puppy: +no systemd; init flavor; display/audio stacks) vs derived package +assumptions — from deps (systemd-sysv → hard), Contents artifacts (.service +units, udev rules, dbus activation — weak alone), and maintscript classes. +`platform_conflicts(Pkg, Platform, Assumptions)` grades each assumption WITH +ITS EVIDENCE: `assumes(P, systemd, evidence(depends(systemd_sysv)))` strong; +`evidence(ships_unit_file)` weak (inert without systemd). Evidence-graded +facts let decisions demand strong evidence while surfacing weak signals — +heuristics that admit they are heuristics. + +Feedback into §2e: much base over-freezing is platform divergence, not ABI — +freezing was the blunt instrument for "this package's assumptions don't hold +here." With 2i's facts, that reason becomes explicit and per-package. + ## 3. Why Prolog is the right spec language here (concretely) | resolver need | Prolog form | diff --git a/docs/proposals/PKG_MINING_NOTES.md b/docs/proposals/PKG_MINING_NOTES.md new file mode 100644 index 000000000..82aa39a3b --- /dev/null +++ b/docs/proposals/PKG_MINING_NOTES.md @@ -0,0 +1,485 @@ + + + +# Mining notes: `Pkg` (Puppy Linux) as a requirements source for `uw-resolve` + +Bounded recon task referenced from `PACKAGE_MANAGER_LOGIC_PROPOSAL.md` §2d/§2e. +Goal: read Pkg's actual bash and map every real mechanism it encodes onto the +`uw-resolve` P0 predicate set defined in `GROK_PKG_RESOLVER_PROMPT.md`: +`package/2`, `depends/4`, `conflicts/3`, `base/1`, `installed/1`, +`requested/1`, and the four queries `resolve/2`, `resolve_layered/2`, +`layer_closure/2`, `removal_orphans/2` (plus `explain_blocked/2`). No code was +changed; this file is the only deliverable. + +**Honesty note:** every claim below either cites `file:line`/function name in +the cloned tree, or is explicitly marked `(inference)`. Nothing is from +memory of Puppy/Pkg outside what was read this session. + +## 1. Provenance + +- **Source cloned:** `https://github.com/puppylinux-woof-CE/Pkg` (option 1 in + the task, reachable on first try; options 2/3 were not needed). +- **Clone:** `git clone --depth 50`, into + `/tmp/.../scratchpad/pkgmine/woof-ce` (outside the UnifyWeaver tree, not + vendored). +- **HEAD of clone:** commit `d64aff6657ea67a0d2ba5e13f70ee8cd8a33d094`, + authored `2021-10-04`. Most recent commit touching the main script: + `df5e828c8627da5782f9fa96489411c3a6454082`, `2020-12-17` — consistent with + "dormant since ~2021" in the task brief. +- **Shallow-clone caveat:** `--depth 50` means `git log` for the main script + only reaches back to `2018-12-31` in this clone; it is *not* the true + project start. The script's own header and inline date-tagged comments + supply the real origin: `usr/sbin/pkg:1-25` — `Copyright (c) 2013 Puppy + Linux Community`, author "Scott Jarvis (sc0ttman)", `APPVER="1.9.23"`, + license GPL. Inline comments carry DDMMYY change-tags going back further + still, e.g. `#130511` (13 May 2011, `usr/sbin/pkg:177`), `#110913`, + `#260713`, `#080917` — i.e. the dependency/blacklist/layer logic mined below + was accreted over roughly a decade of real user bug reports, not designed + up front. +- **Script size:** `usr/sbin/pkg` is 7,950 lines (`wc -l`), by far the + largest file in the repo; supporting tools are `pkgdialog` (830), + `gpkgdialog` (1,264, GTK frontend), `ppa2pup`/`ppa2pup_gawk` (409+364, + PPA→Puppy repo conversion), `slack2pup` (271, Slackware→Puppy repo + conversion), `splitpkg`/`strippkg`/`buildpet` (124/128/195, PET + build/split tooling), `makepkg-fast` (386). Total repo: 26,101 lines across + the files `find` walked. +- **Docs read:** `README.md` (370 lines, the full command reference and + feature list quoted below), `CHANGELOG` (351 lines, used to date specific + features), `pet.specs` (a real PET metadata sample), `root/.pkg/sources-all` + and `etc/pkg/sources-all` (repo-index format samples). +- **Areas not read in depth** (out of the bounded-task budget, flagged rather + than silently skipped): `usr/sbin/gpkgdialog` (GTK UI, 1,264 lines — no new + resolution logic expected, it's a frontend over the same `pkg` functions); + `usr/sbin/ppa2pup*` / `usr/sbin/slack2pup` (repo-conversion scripts — noted + by name only in §4); the `usr/share/buildpet/*.bp` build-recipe files + (build-from-source specs, orthogonal to dependency *resolution*). + +## 2. Command-vocabulary table + +Transcribed from `README.md:183-298` (the `pkg help-all` usage text), grouped +by lifecycle. This is the candidate `pkg`-style CLI schema uw-resolve's plan +executor / CLI would express through the `cli_args` schema machinery. + +| Lifecycle group | Commands (long\|short alias) | uw-resolve query coverage | +|---|---|---| +| **Global options** | `--ask\|-a`, `--quiet\|-q`, `--force\|-f`, `--no-colour\|-nc` | plan-executor flags, not resolver — see §7 | +| **Search / info** | `search\|s`, `search-all\|sa`, `names\|n`, `names-all\|na`, `names-exact\|ne`, `names-exact-all\|nea`, `all-pkgs`, `status\|ps\|PS`, `contents\|c`, `entry\|pe`, `installed\|pi`, `manpage\|man` | catalog lookup by name/bound field — `package/2` fact lookup, not a resolution query | +| **Install / remove** | `add\|a`, `get\|g` (alias of add), `get-only\|go`, `download\|d`, `install\|i`, `install-all\|ia`, `update\|pu`, `remove\|rm`, `uninstall\|u`, `uninstall-all\|ua`, `delete\|l`, `delete-all\|la` | `resolve/2` + plan-apply; `remove`/`uninstall` → `removal_orphans/2` | +| **Deps** | `deps\|e`, `deps-download\|ed`, `deps-all\|ea`, `deps-check\|ldd`, `list-deps\|le\|LE`, `what-needs\|wn` | `deps\|e` ≈ `resolve_layered` restricted to one pkg's closure; `list-deps` ≈ printing `depends/4` closure; `what-needs` ≈ reverse-dep query (no current uw-resolve predicate — see §3.6); `deps-check\|ldd` is **runtime linkage verification**, out of scope (§3.7) | +| **Blacklist / config** | `blacklist`, `whitelist`, `repo-pkg-scope`, `repo-dep-scope`, `bleeding-edge`, `rdep-check`, `autoclean`, `clean`, `show-config`, `workdir` | `blacklist`/`whitelist` ≈ an `excluded/1` fact set, orthogonal to `base/1` (§3.3); the rest are resolver *policy knobs* uw-resolve doesn't yet model (§3.8) | +| **Listing / status** | `list-downloaded\|ld`, `list-installed\|li\|LI`, `list-builtins\|lb`, `build-list\|pbl` | `installed/1` and `base/1` fact dumps | +| **Build from source** | `build-list\|pbl`, `build\|pb`, `pkg-combine\|pc`, `sfs-combine\|sc`, `repack\|pr`, `merge` | `pkg-combine`/`sfs-combine` ARE `layer_closure/2` materialized to a file — the central finding, §5 | +| **Repo management** | `repo\|r`, `repo-info\|ri`, `repo-update\|ru`, `repo-list\|rl`, `repo-file-list\|rfl`, `repo-convert\|rc`, `add-repo`, `rm-repo`, `dir2repo`, `add-source`, `update-sources` | catalog ingestion / federation — `repo-update` explicitly delegates to PPM, the resolver/plumbing boundary (§6) | +| **Format conversion** | `dir2pet`, `dir2sfs`, `dir2tgz`, `deb2pet`, `pet2sfs`, `pet2tgz`, `pet2txz`, `sfs2pet`, `tgz2pet`, `txz2pet`, `extract\|unpack`, `split` | out of scope — file-format plumbing, not resolution | +| **Misc / UX** | `welcome`, `show-config`, `version\|v`, `help\|h`, `help-all\|H`, `usage`, `examples\|ex`, `func-list` | CLI ergonomics, §8 | + +Two commands imply capabilities uw-resolve's four queries don't currently +name: **`what-needs\|wn`** (reverse-dependency query over *installed* +packages — `list_dependents()`, `usr/sbin/pkg:6796`) and **`deps-check\|ldd`** +(runtime `ldd`-based missing-`.so` check, `pkg_ldd()`, `usr/sbin/pkg:6667`). +See §3.6–3.7. + +## 3. Dependency heuristics — findings mapped to the design + +### 3.1 The base/installed/user three-way split IS `base/1` — already-covered, with a wrinkle + +`is_builtin_pkg()` (`usr/sbin/pkg:971-1002`), `is_usr_pkg()` +(`usr/sbin/pkg:1039-1070`), and the record files they read — +`${REPO_DIR}/woof-installed-packages` and `${REPO_DIR}/user-installed-packages` +— are exactly the `base/1` vs. non-base partition the proposal's §2d +describes, implemented in bash a decade before the Prolog framing. A third +file, `devx-only-installed-packages`, tracks the separately-loadable DEVX +(dev-tools) SFS the same way. + +**Mapping:** `base(Pkg-Ver)` ← `woof-installed-packages` row; +`installed(Pkg-Ver)` ← union of all three files, computed at +`list_all_installed_pkgs()` (`usr/sbin/pkg:6167-6190`). + +**Wrinkle our design should adopt (P0.5):** the "base" set is not static — it +is a function of *which SFS layers are currently mounted*. At startup +(`usr/sbin/pkg:176-184`) Pkg builds `layers-installed-packages` as +`woof-installed-packages` **plus** `devx-only-installed-packages` **only if** +DEVX looks loaded, and it tests that with `which gcc` (`usr/sbin/pkg:178`) — +i.e. "is gcc on PATH" is used as a proxy for "is the dev-tools SFS layer +mounted right now." This is real evidence for §2e's `layer_shadow` reason: +Pkg already treats "which packages are frozen" as **session-dependent on +mounted layers**, not a fixed manifest baked at build time. **Adopt:** +`base(Pkg-Ver, layer_shadow)` should be derived from *which layers are +currently mounted*, sourced from a layer-manifest predicate +(`layer_mounted/1`), not hardcoded once. Pkg's own heuristic for detecting +mount state (`which gcc`) is fragile and worth explicitly NOT copying — ours +should read the actual SFS mount table (or Woof-CE's own record of it), which +is a cleaner source than Pkg had available in pure bash. + +### 3.2 Dependency closure walk — adopt the bound-depth iterative BFS pattern, note the wrinkle + +`list_deps()` (`usr/sbin/pkg:6199-6361`) computes the transitive dependency +closure of a package with an explicit **iterative BFS bounded at 16 levels** +(`for i in 0 1 2 ... 15`, `usr/sbin/pkg:6268`), each level: strip already-done +packages (`DEP_DONE`, a visited-set file) and already-installed packages, then +expand the next level's deps. This is structurally identical to what +`layer_closure/2` needs to compute, but with two real-world compromises our +declarative closure removes: + +- **Adopt (recognize, don't copy):** the depth bound exists because bash has + no efficient recursion/fixpoint primitive; Prolog's `resolve_layered`/ + `layer_closure` should compute a true fixpoint (no artificial depth cap). + Flag this explicitly as something Pkg got *wrong* under constraint — not a + requirement to reproduce. Note for the P0 contract corpus: add a + deep-dependency-chain test case (>16 levels) specifically because Pkg's own + bound would silently truncate it — a scenario apt-based tooling wouldn't + even think to test, but Puppy users with long chains (e.g. a desktop + environment → toolkit → font stack → locale data) plausibly hit. +- **Adapt — already-covered with a wrinkle:** the visited-set (`DEP_DONE`) + pattern is exactly the closure/memoization `layer_closure/2` needs + internally; no new predicate required, just confirms the standard approach + is right. + +### 3.3 Blacklist/exclude is a THIRD partition, orthogonal to `base/1` — adopt + +`is_blacklisted_pkg()` (`usr/sbin/pkg:919-930`) and the exclusion applied +inside every closure step (`grep -vE "'$PKG_BLACKLIST_REGEX'"`, +`usr/sbin/pkg:6253,6277,6342`) implement a **third category** the current +`GROK_PKG_RESOLVER_PROMPT.md` fact set doesn't name: packages the user (or +the distro, via `PKG_NAME_IGNORE` sourced from Woof-CE's own +`/root/.packages/PKGS_MANAGEMENT`, per `CHANGELOG:90`) has declared "never +auto-pull as a dependency," independent of whether it's base or installed. +Blacklisting is checked at *every* dependency-expansion step (never appears +in a closure) and also blocks fresh installs (`pkg_install()`, +`usr/sbin/pkg:4818`) — but, found while reading `pkg_uninstall()` +(`usr/sbin/pkg:5825-5828`), it **also blocks removal** of an +already-installed package that's since been blacklisted. That looks like an +unintended interaction (a user who blacklists a package they already have +installed can no longer `pkg uninstall` it without `--force`) — worth citing +as a **wrinkle to avoid**, not adopt: our design should make "excluded from +new installs" and "protected from removal" independently controllable facts. + +**Adopt for P0.5:** an `excluded/1` fact, distinct from `base/1`, consulted +in `resolve`/`resolve_layered` candidate generation (never select an excluded +package to satisfy a dependency) but explicitly NOT consulted by +`removal_orphans` (removal safety should depend only on live reverse-deps, +never on exclusion state) — the opposite of what Pkg accidentally does. + +### 3.4 Removal safety net — already-covered, but Pkg's provenance tracking for "installed as a dependency" is effectively dead code + +`pkg_uninstall()` computes `list_dependents()` (`usr/sbin/pkg:6796-6852`) — +a real reverse-dependency scan across all repo files (`Packages-*`) restricted +to packages that are *actually installed* (`comm -12` against +`user-installed-packages`, `usr/sbin/pkg:6845-6846`) — and **refuses to +uninstall** if anything still depends on the target, unless `--force` +(`usr/sbin/pkg:5896-5909`). This is exactly `removal_orphans/2`'s safety +invariant ("no other installed package or request needs them") and confirms +the design is right: already-covered by §2d point 4. + +**Honesty-flagged finding — a real gap in Pkg, worth noting as a +contradiction with an assumption a naive reading of Pkg might suggest:** +`pkg_remove()` (`usr/sbin/pkg:6009-6058`) *tries* to clean up "leftover +dependencies" by reading a per-package file matching `*_dep_list` +(`usr/sbin/pkg:6038`, `find $TMPDIR -iname "${1}*_dep_list"`) — but **no code +anywhere in the 7,950-line script ever writes a file matching that glob** +(confirmed via `grep -rn "_dep_list"` across the whole repo — the only hit is +the read site). The only similarly-named file, `${PKGNAME}_bgdep_list` +(`usr/sbin/pkg:5626,6546-6547`), is a session-scoped background-prefetch +cache written by `pkg_get()`, not a persistent per-package dependency +manifest. **Conclusion: Pkg has no persistent record of "which currently +installed packages were pulled in as a dependency of which request."** +`user-installed-packages` is a flat, undifferentiated list — direct user +requests and auto-pulled dependencies are indistinguishable once written. +`pkg remove`'s "leftover deps" cleanup pass is therefore vestigial/inert in +this version of the script; the *actual* safety net users get is the +reverse-dependency check in `pkg_uninstall` (§ above), which prevents bad +removals but never proactively offers orphan cleanup after a `remove`. + +This is the single clearest point where **uw-resolve's design is already +ahead of Pkg**, not behind it: `requested/1` vs. `installed/1` as separate +facts (per `GROK_PKG_RESOLVER_PROMPT.md`) is precisely the distinction Pkg's +data model lacks, and `removal_orphans/2` computing "no request and no +surviving reverse-dep needs it" over that distinction is a real improvement, +not a re-derivation of something Pkg already had. **Adopt:** keep +`requested/1` as a first-class fact distinct from `installed/1` — cite this +finding as the reason it matters, not merely as good hygiene. + +### 3.5 Repack/combine excludes exactly base ∪ (devx unless forced) ∪ blacklist — this IS `layer_closure` minus base, confirmed in code + +`pkg_combine()`/`sfs-combine` (`usr/sbin/pkg:3730-3920`, dispatch table at +`usr/sbin/pkg:7821,7824`) builds a single artifact containing a package plus +its **non-base** dependency closure: builtins are skipped unless +`HIDE_BUILTINS=false` (`usr/sbin/pkg:3838`), DEVX packages are skipped unless +`--force` (`usr/sbin/pkg:3841`), blacklisted packages are always skipped +(`usr/sbin/pkg:3835`). This is §2d point 3 ("closure-minus-base IS the layer +manifest") independently arrived at in bash — **already-covered**, and the +exact filter conditions (base, devx-unless-forced, blacklist) are a +ready-made test-oracle for the P0 contract corpus's `layer_closure` cases. +See §5 for the SFS-specific packaging requirements this implies. + +### 3.6 `what-needs` (reverse-dependency-of query) — adopt as a named predicate + +`list_dependents()` (`usr/sbin/pkg:6796-6852`, exposed as `wn`) answers +"what installed packages need X" as a standalone, user-facing query — not +just an internal removal-safety check. `resolve_layered`/`removal_orphans` +compute reverse-deps internally but `GROK_PKG_RESOLVER_PROMPT.md` names no +predicate for exposing it directly. **Adopt:** add `dependents(Pkg, +Dependents)` (or similar) to the P0 predicate set — cheap (it's a subset of +what `removal_orphans` already computes) and it's explicitly one of the +"four questions Puppy users actually ask" per README's own quick-start flow +(`README.md:254`, listed as a top-level command, not buried). + +### 3.7 `deps-check`/`ldd` — out of scope, name why precisely + +`pkg_ldd()` (`usr/sbin/pkg:6667-6744`) runs the real `ldd(1)` against every +binary a package's file-manifest lists (`usr/sbin/pkg:6709-6722`) to find +missing shared libraries **that the declared dependency metadata didn't +catch** — a runtime/filesystem check, not a fact-base query. **Out of +scope** for a declarative resolver spec: it requires executing `ldd` against +real installed binaries on disk, which is executor-side verification, not +resolution. Worth a one-line mention in the phased plan as a *possible* +post-install executor step (verify the plan actually satisfied real linkage) +but explicitly not a `uw-resolve` predicate. + +### 3.8 Policy knobs Pkg exposes that uw-resolve's plan/query layer doesn't yet name — adapt + +`repo-pkg-scope one|all`, `repo-dep-scope one|all`, `bleeding-edge no|yes`, +`rdep-check no|yes` (README.md:271-274, backed by `set_pkg_scope()`, +`set_dep_scope()`, `set_bleeding_edge()`, `set_recursive_deps()` — +`usr/sbin/pkg:1216-1324`) are real user-facing resolution-policy switches: +whether to search only the current repo or federate across all repos when +resolving names/deps, and whether to prefer the newest version from *any* +repo vs. staying within one repo's version line. These map onto candidate +generation order in `resolve`/`resolve_layered` (§3 of +`GROK_PKG_RESOLVER_PROMPT.md` already specifies "prefer base-satisfied, then +highest version" as the determinism policy) — **adapt:** the policy needs a +knob for "highest version within the current/preferred repo" vs. "highest +version across all federated repos," because Puppy users apparently wanted +both and toggle it (`bleeding-edge`). Not a new predicate, but the candidate +ordering should be explicitly parameterized rather than a single fixed rule. + +## 4. Record / repo-format notes — candidate fact-ingestion specs + +### 4.1 The 12-field pipe-delimited package record (repo indexes AND installed-package DBs) + +Confirmed by two independent sites: the `DB_ENTRY` constructed at +`usr/sbin/pkg:5195` and the shipped sample `pet.specs:1`: + +``` +Name|NameOnly|Version|Build|Category|SizeK|Dir|Filename|+Dep1,+Dep2,...|Description|DistroCompat|DistroCompatVersion +``` + +This single format is reused, unchanged, for: `Packages-*` repo-index files +(one per repo, e.g. `Packages-puppy-noarch-official`), `woof-installed-packages` +(base), `devx-installed-packages`/`devx-only-installed-packages`, and +`user-installed-packages`. All the `is_*_pkg()` lookup functions +(`usr/sbin/pkg:933-1136`) `cut -f1,2,8 -d'|'` or similar against these same +files. **Candidate ingestion spec:** a single fact-loader +`load_puppy_pkgdb(File) → package/2, depends/4` (deps field needs the +`+dep1,+dep2` → `depends(Name,_,Dep,any)` unpack seen in `list_deps()`, +`usr/sbin/pkg:6234-6239`, including the `:any`/`&ge`/`<` constraint-suffix +stripping at `usr/sbin/pkg:6160-6162` — note Pkg **discards** version +constraints on deps entirely rather than parsing them into `gte`/`range`; +our ingestion should do better and actually parse `&ge1.2.0` etc. into +`depends/4`'s `Constraint` argument instead of dropping it). + +### 4.2 Repo-source federation list with per-repo fallback chains + +`root/.pkg/sources-all` / `etc/pkg/sources-all` format: + +``` +name|ext|repo_file|mirror1|mirror2|mirror3|mirror4|fallback_repo_names... +``` + +e.g. `slacko|pet|Packages-puppy-slacko-official||||slacko14 noarch` +(`root/.pkg/sources-all:8`). The trailing field is a **space-separated, +priority-ordered fallback list of other repo names** to search if a package +isn't found in this one. **Candidate for the catalog design:** the GP-LMDB +catalog store (proposal §2c) should model repos as a small DAG/priority chain +(`repo_fallback(Repo, FallbackRepo, Priority)`), not a flat "all repos" +bag — this is a real federation topology Puppy repos actually use (e.g. +`slackware14.1` → `slackware14.1-patches` → `slackware14.1-salix` → +`slacko14.1` → `slacko14` → `noarch` → `common32`, `root/.pkg/sources-all:20`) +and it directly affects candidate ordering under `bleeding-edge`/`repo-scope` +(§3.8). + +### 4.3 Name-alias table — adopt as a small `alias/2` fact set + +`usr/sbin/pkg:227-236` hardcodes a name-normalization table, e.g. +`rxvt-unicode,urxvt,urxvt-unicode`, `gtk+,gtk+2*`, `dbus*,libdbus*,libdbus-glib*`, +`mesa,mesa_*,libgl1-mesa*,mesa-common*`. Real packages get renamed/split +across distro versions and repos disagree on canonical names; without this +table, dependency-name matching silently fails. **Adopt for P2 (catalog +ingestion):** an `alias(CanonicalName, MatchPattern)` fact set consulted +during candidate-name resolution before falling back to "not found" — +directly informed by this table, not invented from scratch. + +### 4.4 Plugin hook points — adopt (lightweight) for the executor, not the resolver + +`run_plugins()` (`usr/sbin/pkg:262-...`) defines hook names +`init|pre_install|post_install|pre_uninstall|post_uninstall|pre_build|post_build|exit` +(`usr/sbin/pkg:266`). This belongs on the **plan-executor** side (proposal +§4 constraint 4: "executors are dumb, apply-only"), not the resolver — but a +plan schema that names these same boundary points (so an executor can run +distro-specific hacks around each install/uninstall step, the way +`postinstall_hacks()` at `usr/sbin/pkg:5251` does for Puppy-specific fixups) +would make executors pluggable without touching the resolver spec. + +## 5. SFS-workflow requirements for `layer_closure` output + +Read from `pkg_combine()` (`usr/sbin/pkg:3730-3920+`) and the SFS build call +site (`usr/sbin/pkg:7109`, `mksquashfs "$SFS_DIR" "$SFS_NAME" -noappend`): + +1. **Materialization is "download/unpack every closure member into one + directory tree, then `mksquashfs` the tree."** `layer_closure/2`'s output + (an ordered manifest) is consumed by, for each member: locate or download + its package file, extract it into a shared build directory + (`usr/sbin/pkg:3813-3871`), then squash the whole tree in one pass. The + manifest itself doesn't need to carry file lists — just package identities + — because extraction does that work. +2. **No file-conflict detection between closure members observed.** Each + package's files get copied into the same build directory; a later + package's file silently overwrites an earlier one with the same path (no + check found at `usr/sbin/pkg:3861-3870` or nearby). **Out of scope for + the resolver** (this is a packaging-time concern, not a selection + concern) but worth flagging explicitly as a requirement the *executor* + should add and Pkg doesn't have: `layer_closure`'s manifest should be + sufficient for an executor to detect path collisions before squashing, + even though Pkg itself never did. +3. **Ordering: the request itself is materialized before its dependencies** + (`usr/sbin/pkg:3817-3823` copies the main package first, deps in the loop + after, `usr/sbin/pkg:3830-3871`) — but since materialization here is "copy + files into a merged tree, then squash once," order doesn't matter for + *this* consumer. **This does not confirm or refute** whether + `layer_closure`'s "dependencies before dependents" ordering requirement + (`GROK_PKG_RESOLVER_PROMPT.md` line ~42) matters for some *other* SFS + consumer (e.g. sequential `pkg_install` calls, where a package's + post-install script might expect a dependency already present) — + `pkg_install()` itself is called once per package with no + observed ordering guarantee across a dependency set (inference: the + `get_deps()` loop at `usr/sbin/pkg:6582-6652` installs in whatever order + `DEPS_MISSING` iterates, not a topological order). **Adopt:** keep + `layer_closure`'s dependency-before-dependent ordering guarantee anyway — + it's strictly safer for executors that install sequentially, even though + Pkg's own code doesn't enforce or need it for the squashfs path. +4. **The two SFS "flavors" (`pkg-combine` → `.pet`, `sfs-combine` → `.sfs`) + share one code path**, gated only by `$COMBINE2SFS` + (`usr/sbin/pkg:3788,7821,7824`) — i.e. `layer_closure`'s output format + should be packaging-format-agnostic; the choice of `.pet` vs `.sfs` is a + pure executor/output-format decision, not something the resolver needs to + know about. + +## 6. PPM interop boundary — already-covered (matches proposal §5 scope discipline) + +`update_repo()` (`usr/sbin/pkg:2058-2100`) is the concrete boundary line: `pkg +repo-update` does **not** reimplement repo-index fetching. It shells out +directly to `/usr/local/petget/0setup` — PPM's own repo-sync tool — and +parses PPM's output text to report which repos updated +(`usr/sbin/pkg:2078-2094`). The comment at `usr/sbin/pkg:2069-2071` is +explicit about *why*: "petget wont accept $1 and only do that repo... but +petget code is way faster than mine... we're limited to updating only the +repos that petget supports." **This is exactly the resolver-vs-plumbing line +the proposal already draws** (§5 "a planner over existing package managers," +constraint 5 "not a new package format, store, or Nix competitor"): +network repo-index syncing is explicitly PPM's job in Pkg's own design, never +reimplemented even though the author clearly wanted to (`README.md:26`: +"Puppy Package Manager (for `pkg repo-update` only)" is listed as Pkg's +*only* hard runtime dependency beyond bash/coreutils). **No new finding +needed here** — cite this as confirmation the proposal's scope line matches +what a decade of real Puppy tooling converged on independently. + +## 7. CLI ergonomics worth stealing + +- **`--ask` as a universal prefix flag**, not a per-command option: any + destructive/mutating command becomes "confirm each item" by prepending + `--ask` (`README.md:189`, e.g. `pkg -a e PKGNAME`, `pkg --ask add + "firefox mplayer"`). Implemented as one global `$ASK` variable checked at + every confirmation point (`read -n 1 CONFIRM`, e.g. + `usr/sbin/pkg:5913,4890`). **Adopt:** a plan-executor-level `--ask`/`-y` + toggle rather than per-command confirm flags — cheap and it's the single + most-repeated pattern in the README's own example section + (`README.md:322-370`, 6 of 17 examples use `-a`/`--ask`). +- **Pipe-friendly, one-item-per-line output everywhere**, explicitly designed + for chaining (`README.md:355-359`: `pkg li vim | pkg status -`, `pkg li | + pkg -a u -` — `-` as "read the package name from stdin"). **Adopt:** the + CLI's list-producing commands (search, list-installed, list-deps, etc.) + and its mutating commands (status, uninstall) should compose via stdin the + same way; this is the single ergonomic idea repeated most across the + README's examples. +- **`get-only`/`go`: resolve+download without installing** — the closest + thing Pkg has to a dry-run for the install path (`README.md:207-208, + 343`). Not a true dry-run (files ARE downloaded) but confirms user demand + for "show me what would happen without committing" — `uw-resolve`'s plan + being inspectable data *before* any executor runs (proposal §2a: "print + it, diff it, dry-run it") is a strict improvement over this, worth calling + out as validated by real demand rather than invented. +- **`func-list`** (`README.md:297`) — the script can enumerate its own + functions; a small but real precedent for a resolver/CLI that can + introspect its own command surface, relevant if `cli_args` schema + generation wants a "list everything this build understands" command. + +## 8. Top 10 things `uw-resolve` should take from `Pkg` + +1. Model "frozen base" as **layer-membership over currently-mounted SFS + layers**, not a static manifest — Pkg already ties `devx` freeze status to + runtime mount state (`usr/sbin/pkg:176-184`); `base/1`/`layer_shadow` + should be derived the same way, just from a cleaner mount-table source. +2. Add `dependents(Pkg, List)` as a first-class query (`what-needs`, + `usr/sbin/pkg:6796-6852`) — Puppy users ask this directly, not just as a + removal-safety side effect. +3. Keep `requested/1` strictly separate from `installed/1` — Pkg's flat + `user-installed-packages` list conflates them, which is precisely why its + own `pkg remove` orphan-cleanup code is dead (§3.4); this is the clearest + place `uw-resolve`'s design is already better, and it's worth stating why. +4. Add an `excluded/1` (blacklist) fact set, orthogonal to `base/1`, consulted + only in candidate generation — never in removal safety (Pkg accidentally + couples the two, `usr/sbin/pkg:5825-5828`; don't repeat that). +5. Parse dependency version constraints into `depends/4`'s `Constraint` + argument instead of discarding them the way `list_deps()` does + (`usr/sbin/pkg:6160-6162` strips `&ge`/`<` rather than keeping them) — + a straightforward improvement the ingestion spec should make explicitly. +6. Model repo federation as a **priority-ordered fallback chain per repo** + (`root/.pkg/sources-all`'s trailing fallback-list field), not a flat "all + repos" bag, for `bleeding-edge`/`repo-scope` candidate ordering. +7. Adopt a small `alias/2` name-normalization fact set + (`usr/sbin/pkg:227-236`) — cross-repo/cross-distro name drift is real and + already has a working, if ad hoc, table to start from. +8. `layer_closure`'s output should stay packaging-format-agnostic (Pkg's + `.pet` vs `.sfs` combine paths share one closure computation, gated only + at materialization time, `usr/sbin/pkg:3788`) and should keep its + dependency-before-dependent ordering guarantee even though Pkg's own + squashfs consumer doesn't strictly need it — safer for sequential + executors that Pkg itself doesn't have but a future one might. +9. Give the plan executor a universal `--ask` confirm-everything flag and + design mutating/listing commands to compose over stdin (`pkg li vim | pkg + status -`) — the most-repeated ergonomic pattern in Pkg's own usage + examples. +10. Treat `pkg_ldd`'s runtime linkage check as a validated *executor-side + post-install verification* idea (confirm the plan's effect matches + reality) without adding it to the resolver spec — real users wanted this + (it's a top-level command, not hidden), but it needs a filesystem, not a + fact base. + +## Summary: adopt/adapt/already-covered/out-of-scope counts + +- **Adopt** (new fact/query shape proposed): §3.3 `excluded/1`, §3.6 + `dependents/2`, §4.1 constraint parsing, §4.2 repo-fallback chains, §4.3 + `alias/2`, §4.4 executor hook points, §5 point 2 (collision-check + requirement) and point 3 (ordering guarantee) — **8 items**. +- **Adapt** (covered, but a wrinkle ours misses): §3.1 layer-mount-dependent + `base/1`, §3.2 fixpoint-vs-depth-bound (test-corpus implication), §3.8 + repo-scope/bleeding-edge candidate ordering — **3 items**. +- **Already-covered** (cite proposal section): §3.4 removal safety (§2d + point 4), §3.5 layer_closure-minus-base (§2d point 3), §6 PPM boundary + (§5 scope discipline) — **3 items**. +- **Out-of-scope** (say why): §3.7 `deps-check`/`ldd` runtime linkage check + (needs real binaries on disk, not facts) — **1 item**. + +## Contradictions with the current proposal design + +None found that require changing `PACKAGE_MANAGER_LOGIC_PROPOSAL.md`'s +architecture. The closest things to a contradiction are both **findings that +uw-resolve is already ahead of Pkg**, not evidence against the design: + +- §3.4: Pkg's own orphan-cleanup-on-remove code path is dead (no writer for + the file it reads) — the `requested/1` vs `installed/1` split the proposal + already calls for is precisely the fix, not a redundant idea. +- §3.3: Pkg's blacklist accidentally blocks removal of already-installed + blacklisted packages — a reason to keep `excluded/1` and removal-safety + logic explicitly decoupled, which the current design already does by not + conflating them (no predicate currently ties exclusion to removal). diff --git a/examples/pkg_resolver/README.md b/examples/pkg_resolver/README.md index bb89ceea3..670eb2f08 100644 --- a/examples/pkg_resolver/README.md +++ b/examples/pkg_resolver/README.md @@ -1,47 +1,113 @@ -# uw-resolve P0 — a frozen-base package resolver +# uw-resolve P0.5 — holds get reasons; mining adoptions land Layered / frugal distros (Puppy, Woof-CE) run an **immutable curated base** under a writable layer. Stock apt cannot reason about that boundary: it will happily "upgrade" a held package that lives in a read-only SFS. This program -is a Prolog spec of a resolver that *can*. One set of relations, four queries; -SWI-Prolog is the oracle; the same spec is compiled through `wam_javascript` +is a Prolog spec of a resolver that *can*. One set of relations; SWI-Prolog +is the oracle; the same spec is compiled through `wam_javascript` (`emit_mode(mixed)`) and gated by the contract corpus plus a seeded differential. Debian epoch/tilde version semantics, `Provides:`/virtual packages, a GP-LMDB -catalog backend, and a `pkg`-style CLI (via `examples/cli_args`) are deferred. +catalog backend, and a `pkg`-style CLI (via `examples/cli_args`) remain +deferred. ## The model -The catalog is **data**, not the Prolog database. Every query takes +The catalog is **data**, not the Prolog database. Every query takes a +`catalog/6` (P0) or `catalog/9` (P0.5 extras) term as its first argument. +There is no `assert`/`retract`. Bare `catalog/6` is still accepted: missing +layers / excluded / aliases are `[]`, and a bare `Name-Ver` hold is +`blanket`. Every P0 scenario is unchanged. ``` catalog(Packages, Depends, Conflicts, Base, Installed, Requested) +catalog(Packages, Depends, Conflicts, Base, Installed, Requested, + Layers, Excluded, Aliases) ``` -as its first argument. There is no `assert`/`retract`. - | Field | Shape | | --- | --- | | `Packages` | `[package(Name, v(M,I,P)), …]` | | `Depends` | `[depends(Name, Ver, DepName, Constraint), …]` | | `Conflicts` | `[conflicts(Name, Ver, OtherName), …]` (checked in both directions) | -| `Base` / `Installed` | `[Name-Ver, …]` | +| `Base` | `[Hold, …]` — see **Freeze reasons** | +| `Installed` | `[Name-Ver, …]` | | `Requested` | `[Name, …]` — manual/root installs, used only by `removal_orphans` | +| `Layers` | `[layer(Name, [Hold, …]), …]` — named loaded layers (§2f, minimal) | +| `Excluded` | `[Name, …]` — candidate-generation blacklist only | +| `Aliases` | `[alias(Alias, Canonical), …]` — request edge only | **Versions** are `v(Major, Minor, Patch)`, compared lexicographically. **Constraints:** `any` · `eq(V)` · `gte(V)` · `lt(V)` · `range(Lo, Hi)` -(Lo inclusive, Hi exclusive). No Debian epoch/tilde in P0. +(Lo inclusive, Hi exclusive). No Debian epoch/tilde in P0.5. **Requests** are an atom `Name` (constraint `any`) or `req(Name, Constraint)`. +Alias rewriting happens here only; catalog names stay canonical. + +## Freeze reasons (§2e) + +A base hold is either the P0 pair `Name-Ver` (read as `blanket`) or +`base(Name-Ver, Reason)` with + +``` +Reason ∈ { layer_shadow, abi_anchor, modified, footprint, blanket } +``` + +| Reason | `safe_upgrade` verdict | +| --- | --- | +| `footprint` / `blanket` / `layer_shadow` | `safe(cost(Reason))` | +| `abi_anchor` | `coordinated(Set)` — minimal reverse-dep closure that must move with `Pkg` | +| `modified` | `unsafe(modified)` — never without re-applying modifications | +| (no such `NewVer`, or `Pkg` is not a base hold) | `no_candidate` | + +`upgrade_set(Catalog, Pkg, NewVer, Set)` is that coordinated set: reverse +dependencies **among BASE packages** whose *current* version's constraint on a +moving package breaks at the new version. Each broken member is repaired with +the highest catalog version that satisfies the moving pins. A base dependent +whose constraint still holds at `NewVer` stays **out**. When a member has no +satisfying version the query fails; `upgrade_set_result/4` binds the same +`blocked(Name, needs(C), base_has(V))` shape as layered resolve. + +`freeze_audit(Catalog, Audit)` walks **base-layer** holds only (other named +layers are not freeze-audited): + +- non-blanket → `audit(Name, held(Reason))` +- blanket + a tight (`\== any`) reverse-dep from another base package → + `audit(Name, suggest(abi_anchor))` +- blanket + no such reverse-dep → `audit(Name, over_frozen)` — the + "TrixiePup freezes too much" diagnosis as a query + +## Named layers (§2f, minimal slice) -## The four queries +`layer(Name, [Hold, …])` entries live in the 7th catalog argument (and are +also accepted inside `Base`). The layer named `base` is the frozen base; +every layer present in the catalog is treated as **loaded**. A dependency +already satisfied by any loaded layer is used in place (`from_base`) and is +not re-selected — the same rule P0 applied to `Base` alone. No per-file +modeling; membership is package-name + version per named layer. -All four are exported from `resolver.pl`. `Cat` is the catalog term. +## Excluded vs removal (Pkg bug we refuse to copy) + +`excluded/1` names filter **candidate generation only**. An excluded package +is never selected by `resolve` / `resolve_layered`. Exclusion is **not** +consulted by `removal_orphans`: blacklisting an installed package must not +protect it from being orphaned. (Stock Pkg conflated the two.) + +## Aliases + +`alias(Alias, Canonical)` is applied at the **request edge** +(`resolve*`, `explain_blocked`, `layer_closure`, `removal_orphans`, +`safe_upgrade`, `upgrade_set`, `dependents*`). Catalog package names stay +canonical: requesting `urxvt` selects `rxvt`. + +## Queries + +All are exported from `resolver.pl`. `Cat` is the catalog term. ### 1. `resolve(+Cat, +Requests, -Selection)` @@ -57,10 +123,10 @@ Sel = [app-v(1,0,0), lib-v(2,0,0)]. % lib 1.0 is in the base; classic picks 2. ### 2. `resolve_layered(+Cat, +Requests, -Selection)` -The same closure, **without touching the base**. A dependency already -satisfied by `base(Name-Ver)` is used in place (never re-selected, never -upgraded). Only non-base packages appear in `Selection`. When a held package -is a version ceiling, the query **fails**. +The same closure, **without touching loaded layers**. A dependency already +satisfied by a loaded-layer hold is used in place (never re-selected, never +upgraded). Only packages not held in a loaded layer appear in `Selection`. +When a held package is a version ceiling, the query **fails**. ```prolog ?- scenario_catalog(upgradeable_base, Cat), resolve_layered(Cat, [app], Sel). @@ -78,9 +144,9 @@ blocked(lib, needs(gte(v(2,0,0))), base_has(v(1,0,0))) ### 3. `layer_closure(+Cat, +Request, -Layer)` -The request plus its full **non-base** dependency closure as an ordered -manifest (dependencies before dependents): the self-contained SFS-style -layer that installs without evolving the base. +The request plus its full **non-loaded-layer** dependency closure as an +ordered manifest (dependencies before dependents): the self-contained +SFS-style layer that installs without evolving the base / loaded layers. ```prolog ?- scenario_catalog(layer_tree, Cat), layer_closure(Cat, a, Layer). @@ -89,21 +155,40 @@ Layer = [c-v(1,0,0), b-v(1,0,0), d-v(1,0,0), a-v(1,0,0)]. ### 4. `removal_orphans(+Cat, +Pkg, -Orphans)` -Given `installed/1` and `requested/1` facts, the packages that were pulled -in as dependencies and would be orphaned by removing `Pkg` (no remaining -requested root needs them). **Base packages are never orphans.** The -PPM-style lifecycle trim, relationally. +Given `installed` and `requested` fields, the packages that were pulled in +as dependencies and would be orphaned by removing `Pkg` (no remaining +requested root needs them). **Base / loaded-layer packages are never +orphans.** Exclusion does not apply. The PPM-style lifecycle trim, +relationally. + +### 5. `safe_upgrade(+Cat, +Pkg, +NewVer, -Verdict)` / `upgrade_set/4` + +See **Freeze reasons**. `upgrade_set_result/4` is the always-binding form +used by the JS-WAM shim (`ok(Set)` | `blocked(...)` | `no_candidate`). + +### 6. `freeze_audit(+Cat, -Audit)` + +Per base-layer hold: held reason, or a derived `suggest(abi_anchor)` / +`over_frozen` diagnosis for blankets. + +### 7. `dependents(+Cat, +Pkg, -Dependents)` / `dependents_installed/3` + +`what-needs`: catalog packages (any version) that depend **directly** on +`Pkg`. `dependents_installed/3` keeps only those currently installed at +that version or held in a loaded layer at that version. ## Determinism policy - `resolve/3` and `resolve_layered/3` commit to the **first** search solution (`!` at the API edge only). Candidate order: layered prefers a - **base-satisfied** version; otherwise **highest version**. + **loaded-layer-satisfied** version; otherwise **highest version**. - Selections and layer manifests are sorted (by `Name-Ver` for `resolve*`; topological with sorted sibling names for `layer_closure`) so corpus/differential comparison is stable. - `explain_blocked/3` enumerates; callers `findall`+`sort`. -- `removal_orphans/3` returns one sorted list. +- `removal_orphans/3`, `safe_upgrade/4`, `upgrade_set/4`, `freeze_audit/2`, + `dependents/3`, `dependents_installed/3` each return one sorted / + ground answer. ## Files @@ -111,12 +196,12 @@ PPM-style lifecycle trim, relationally. | --- | --- | | `resolver.pl` | the spec (pure relations) | | `test_resolver.pl` | contract corpus (plunit + `corpus_case/4`) | -| `dump_corpus.pl` | SWI → JSONL for the node runner | +| `dump_corpus.pl` | SWI → JSONL for the wamjs runner | | `wamjs/` | P1 build, argparser-playbook style | | `wamjs/build.sh` | `swipl` → `wam_javascript`, `emit_mode(mixed)` | | `wamjs/resolver.mjs` | term ↔ JSON **only** — no resolver logic | | `wamjs/run_corpus_wamjs.sh` | the same corpus through node vs SWI | -| `gen_catalogs.mjs` | mulberry32, 2200 catalogs | +| `gen_catalogs.mjs` | mulberry32, 2400 catalogs (seed `0xa5b6c7d8`) | | `run_differential.sh` | SWI vs wamjs, 0-divergence gate | ## Build / run @@ -131,14 +216,15 @@ swipl -q -g test_resolver -t halt examples/pkg_resolver/test_resolver.pl bash examples/pkg_resolver/wamjs/build.sh bash examples/pkg_resolver/wamjs/run_corpus_wamjs.sh -# ≥2000 seeded catalogs, four queries, 0 divergences +# ≥2200 seeded catalogs, all queries, 0 divergences bash examples/pkg_resolver/run_differential.sh ``` -## Deferred (not P0) +## Deferred (not P0.5) - Debian epoch / tilde / letter version semantics - `Provides:` / virtual packages / alternatives - GP-LMDB catalog backend (P2 — the `indexed` / `lmdb` fact-source path) - `pkg`-style CLI on top of `examples/cli_args` - write paths (install / remove / commit a layer) +- per-file / per-SFS modeling inside a named layer diff --git a/examples/pkg_resolver/diff_runner.pl b/examples/pkg_resolver/diff_runner.pl index 4a6e37716..2e22186da 100644 --- a/examples/pkg_resolver/diff_runner.pl +++ b/examples/pkg_resolver/diff_runner.pl @@ -66,14 +66,44 @@ removal_orphans(Cat, Pkg, Orphans), sel_json(Orphans, Js), Exp = _{ok: Js}. +run_query(safe_upgrade, Cat, Args, Exp) :- + json_to_pkg_ver(Args, Pkg, Ver), + safe_upgrade(Cat, Pkg, Ver, Verdict), + verdict_json(Verdict, Js), + Exp = _{ok: Js}. +run_query(upgrade_set, Cat, Args, Exp) :- + json_to_pkg_ver(Args, Pkg, Ver), + upgrade_set_result(Cat, Pkg, Ver, R), + upgrade_json(R, Exp). +run_query(freeze_audit, Cat, _, Exp) :- + freeze_audit(Cat, Audit), + maplist(audit_json, Audit, Js), + Exp = _{ok: Js}. +run_query(dependents, Cat, Args, Exp) :- + json_to_pkg(Args, Pkg), + dependents(Cat, Pkg, Deps), + sel_json(Deps, Js), + Exp = _{ok: Js}. +run_query(dependents_installed, Cat, Args, Exp) :- + json_to_pkg(Args, Pkg), + dependents_installed(Cat, Pkg, Deps), + sel_json(Deps, Js), + Exp = _{ok: Js}. -json_to_catalog(D, catalog(Ps, Ds, Cs, Bs, Is, Rs)) :- +json_to_catalog(D, Cat) :- maplist(json_pkg, D.packages, Ps), maplist(json_dep, D.depends, Ds), maplist(json_conf, D.conflicts, Cs), - maplist(json_pair, D.base, Bs), + maplist(json_hold, D.base, Bs), maplist(json_pair, D.installed, Is), - maplist(json_atom, D.requested, Rs). + maplist(json_atom, D.requested, Rs), + ( get_dict(layers, D, L0) -> maplist(json_layer, L0, Ls) ; Ls = [] ), + ( get_dict(excluded, D, E0) -> maplist(json_atom, E0, Es) ; Es = [] ), + ( get_dict(aliases, D, A0) -> maplist(json_alias, A0, As) ; As = [] ), + ( Ls == [], Es == [], As == [] + -> Cat = catalog(Ps, Ds, Cs, Bs, Is, Rs) + ; Cat = catalog(Ps, Ds, Cs, Bs, Is, Rs, Ls, Es, As) + ). json_pkg([N, V], package(Name, Ver)) :- json_atom(N, Name), json_ver(V, Ver). @@ -84,6 +114,19 @@ json_atom(N, Name), json_ver(V, Ver), json_atom(O, Other). json_pair([N, V], Name-Ver) :- json_atom(N, Name), json_ver(V, Ver). +json_hold([N, V], Name-Ver) :- + json_atom(N, Name), json_ver(V, Ver). +json_hold([N, V, R], base(Name-Ver, Reason)) :- + json_atom(N, Name), json_ver(V, Ver), json_atom(R, Reason). +json_layer(D, layer(Name, Pkgs)) :- + is_dict(D), + json_atom(D.name, Name), + maplist(json_hold, D.packages, Pkgs). +json_alias([A, C], alias(Alias, Canon)) :- + json_atom(A, Alias), json_atom(C, Canon). + +json_to_pkg_ver([P, V], Pkg, Ver) :- + json_atom(P, Pkg), json_ver(V, Ver). json_ver([A, B, C], v(A, B, C)). @@ -131,6 +174,26 @@ ver_json(V, VJ), blocked_list_json(Rest, Js). +verdict_json(safe(cost(R)), _{cost: RS, verdict: "safe"}) :- + atom_string(R, RS). +verdict_json(coordinated(Set), _{set: SJ, verdict: "coordinated"}) :- + sel_json(Set, SJ). +verdict_json(unsafe(modified), _{reason: "modified", verdict: "unsafe"}). +verdict_json(no_candidate, _{verdict: "no_candidate"}). + +upgrade_json(ok(Set), _{ok: Js}) :- + sel_json(Set, Js). +upgrade_json(no_candidate, _{fail: true}). +upgrade_json(blocked(N, needs(C), base_has(V)), _{ok: _{blocked: BJ}}) :- + blocked_list_json([blocked(N, needs(C), base_has(V))], [BJ]). + +audit_json(audit(N, over_frozen), _{kind: "over_frozen", name: NS}) :- + atom_string(N, NS). +audit_json(audit(N, suggest(R)), _{kind: "suggest", name: NS, reason: RS}) :- + atom_string(N, NS), atom_string(R, RS). +audit_json(audit(N, held(R)), _{kind: "held", name: NS, reason: RS}) :- + atom_string(N, NS), atom_string(R, RS). + constraint_json(any, any). constraint_json(eq(V), _{op: "eq", v: J}) :- ver_json(V, J). constraint_json(gte(V), _{op: "gte", v: J}) :- ver_json(V, J). diff --git a/examples/pkg_resolver/dump_corpus.pl b/examples/pkg_resolver/dump_corpus.pl index ef42d713f..5506221b5 100644 --- a/examples/pkg_resolver/dump_corpus.pl +++ b/examples/pkg_resolver/dump_corpus.pl @@ -52,12 +52,38 @@ removal_orphans(Cat, Args, Orphans), sel_json(Orphans, Js), Exp = _{ok: Js}. +run_query(safe_upgrade, Cat, [Pkg, Ver], Exp) :- + safe_upgrade(Cat, Pkg, Ver, Verdict), + verdict_json(Verdict, Js), + Exp = _{ok: Js}. +run_query(upgrade_set, Cat, [Pkg, Ver], Exp) :- + upgrade_set_result(Cat, Pkg, Ver, R), + upgrade_json(R, Exp). +run_query(freeze_audit, Cat, _, Exp) :- + freeze_audit(Cat, Audit), + maplist(audit_json, Audit, Js), + Exp = _{ok: Js}. +run_query(dependents, Cat, Args, Exp) :- + dependents(Cat, Args, Deps), + sel_json(Deps, Js), + Exp = _{ok: Js}. +run_query(dependents_installed, Cat, Args, Exp) :- + dependents_installed(Cat, Args, Deps), + sel_json(Deps, Js), + Exp = _{ok: Js}. args_json(resolve, Reqs, Js) :- reqs_json(Reqs, Js). args_json(resolve_layered, Reqs, Js) :- reqs_json(Reqs, Js). args_json(explain_blocked, Req, Js) :- req_json(Req, Js). args_json(layer_closure, Req, Js) :- req_json(Req, Js). args_json(removal_orphans, Pkg, Js) :- atom_string(Pkg, Js). +args_json(safe_upgrade, [Pkg, Ver], [NS, VJ]) :- + atom_string(Pkg, NS), ver_json(Ver, VJ). +args_json(upgrade_set, [Pkg, Ver], [NS, VJ]) :- + atom_string(Pkg, NS), ver_json(Ver, VJ). +args_json(freeze_audit, _, []). +args_json(dependents, Pkg, Js) :- atom_string(Pkg, Js). +args_json(dependents_installed, Pkg, Js) :- atom_string(Pkg, Js). reqs_json([], []). reqs_json([R|Rs], [J|Js]) :- @@ -77,9 +103,22 @@ maplist(pkg_json, Ps, PJ), maplist(dep_json, Ds, DJ), maplist(conf_json, Cs, CJ), - maplist(pair_json, Bs, BJ), + maplist(hold_json, Bs, BJ), maplist(pair_json, Is, IJ), maplist(atom_string, Rs, RJ). +catalog_json(catalog(Ps, Ds, Cs, Bs, Is, Rs, Ls, Es, As), + _{packages: PJ, depends: DJ, conflicts: CJ, + base: BJ, installed: IJ, requested: RJ, + layers: LJ, excluded: EJ, aliases: AJ}) :- + maplist(pkg_json, Ps, PJ), + maplist(dep_json, Ds, DJ), + maplist(conf_json, Cs, CJ), + maplist(hold_json, Bs, BJ), + maplist(pair_json, Is, IJ), + maplist(atom_string, Rs, RJ), + maplist(layer_json, Ls, LJ), + maplist(atom_string, Es, EJ), + maplist(alias_json, As, AJ). pkg_json(package(N, V), [NS, VJ]) :- atom_string(N, NS), ver_json(V, VJ). @@ -90,6 +129,15 @@ atom_string(N, NS), ver_json(V, VJ), atom_string(O, OS). pair_json(N-V, [NS, VJ]) :- atom_string(N, NS), ver_json(V, VJ). +hold_json(N-V, [NS, VJ]) :- + atom_string(N, NS), ver_json(V, VJ). +hold_json(base(N-V, R), [NS, VJ, RS]) :- + atom_string(N, NS), ver_json(V, VJ), atom_string(R, RS). +layer_json(layer(N, Pkgs), _{name: NS, packages: PJ}) :- + atom_string(N, NS), + maplist(hold_json, Pkgs, PJ). +alias_json(alias(A, C), [AS, CS]) :- + atom_string(A, AS), atom_string(C, CS). ver_json(v(A, B, C), [A, B, C]). @@ -112,3 +160,23 @@ constraint_json(C, CJ), ver_json(V, VJ), blocked_list_json(Rest, Js). + +verdict_json(safe(cost(R)), _{cost: RS, verdict: "safe"}) :- + atom_string(R, RS). +verdict_json(coordinated(Set), _{set: SJ, verdict: "coordinated"}) :- + sel_json(Set, SJ). +verdict_json(unsafe(modified), _{reason: "modified", verdict: "unsafe"}). +verdict_json(no_candidate, _{verdict: "no_candidate"}). + +upgrade_json(ok(Set), _{ok: Js}) :- + sel_json(Set, Js). +upgrade_json(no_candidate, _{fail: true}). +upgrade_json(blocked(N, needs(C), base_has(V)), _{ok: _{blocked: BJ}}) :- + blocked_list_json([blocked(N, needs(C), base_has(V))], [BJ]). + +audit_json(audit(N, over_frozen), _{kind: "over_frozen", name: NS}) :- + atom_string(N, NS). +audit_json(audit(N, suggest(R)), _{kind: "suggest", name: NS, reason: RS}) :- + atom_string(N, NS), atom_string(R, RS). +audit_json(audit(N, held(R)), _{kind: "held", name: NS, reason: RS}) :- + atom_string(N, NS), atom_string(R, RS). diff --git a/examples/pkg_resolver/gen_catalogs.mjs b/examples/pkg_resolver/gen_catalogs.mjs index 8c0b83cbd..4eebf31eb 100644 --- a/examples/pkg_resolver/gen_catalogs.mjs +++ b/examples/pkg_resolver/gen_catalogs.mjs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright (c) 2026 John William Creighton (@s243a) // -// gen_catalogs.mjs -- seeded random catalogs for the uw-resolve P0 +// gen_catalogs.mjs -- seeded random catalogs for the uw-resolve P0.5 // differential. mulberry32, same construction as examples/cli_args/gen_cases.mjs. // // Each line is one JSON object: @@ -10,8 +10,8 @@ // // node examples/pkg_resolver/gen_catalogs.mjs > cases.jsonl -const SEED = 0x91a2b3c4; -const CASES = 2200; +const SEED = 0xa5b6c7d8; +const CASES = 2400; function mulberry32(a) { return function () { @@ -101,26 +101,43 @@ function genCatalog(rng) { conflicts.push([names[a], va, names[b]]); } + const REASONS = ["layer_shadow", "abi_anchor", "modified", "footprint", "blanket"]; const base = []; const installed = []; const requested = []; + const layerPkgs = []; + const excluded = []; + const aliases = []; for (let i = 0; i < nPkgs; i += 1) { const name = names[i]; const ver = versions[name][0]; - if (rng() < 0.2) base.push([name, ver]); + if (rng() < 0.2) { + if (rng() < 0.55) base.push([name, ver, pickOne(rng, REASONS)]); + else base.push([name, ver]); + } else if (rng() < 0.08) { + layerPkgs.push([name, ver]); + } if (rng() < 0.35) { installed.push([name, ver]); if (rng() < 0.5) requested.push(name); } + if (rng() < 0.04) excluded.push(name); + if (rng() < 0.05) aliases.push(["alias_" + name, name]); } + const layers = []; + if (layerPkgs.length > 0) layers.push({ name: "devx", packages: layerPkgs }); + return { packages, depends, conflicts, base, installed, - requested + requested, + layers, + excluded, + aliases }; } @@ -157,15 +174,51 @@ function removalPkg(rng, cat) { return "ghost"; } -const QUERIES = ["resolve", "resolve_layered", "explain_blocked", "layer_closure", "removal_orphans"]; +function safeUpgradeArgs(rng, cat) { + if (cat.base.length > 0) { + const b = pickOne(rng, cat.base); + const name = b[0]; + const vers = cat.packages.filter((p) => p[0] === name).map((p) => p[1]); + const ver = vers.length > 0 ? pickOne(rng, vers) : b[1]; + return [name, ver]; + } + if (cat.packages.length > 0) { + const p = pickOne(rng, cat.packages); + return [p[0], p[1]]; + } + return ["ghost", [1, 0, 0]]; +} + +function dependentsPkg(rng, cat) { + if (cat.packages.length > 0) return pickOne(rng, cat.packages)[0]; + return "ghost"; +} + +function aliasOrName(rng, cat, name) { + const hits = (cat.aliases || []).filter((a) => a[1] === name); + if (hits.length > 0 && rng() < 0.5) return hits[0][0]; + return name; +} + +const QUERIES = [ + "resolve", "resolve_layered", "explain_blocked", "layer_closure", "removal_orphans", + "safe_upgrade", "upgrade_set", "freeze_audit", "dependents", "dependents_installed" +]; const rng = mulberry32(SEED); for (let i = 0; i < CASES; i += 1) { const catalog = genCatalog(rng); const query = QUERIES[i % QUERIES.length]; let args; - if (query === "resolve" || query === "resolve_layered") args = requestsFor(rng, catalog); - else if (query === "removal_orphans") args = removalPkg(rng, catalog); + if (query === "resolve" || query === "resolve_layered") { + args = requestsFor(rng, catalog).map((r) => { + if (typeof r === "string") return aliasOrName(rng, catalog, r); + return { ...r, req: aliasOrName(rng, catalog, r.req) }; + }); + } else if (query === "removal_orphans") args = removalPkg(rng, catalog); + else if (query === "safe_upgrade" || query === "upgrade_set") args = safeUpgradeArgs(rng, catalog); + else if (query === "freeze_audit") args = []; + else if (query === "dependents" || query === "dependents_installed") args = dependentsPkg(rng, catalog); else args = requestFor(rng, catalog); process.stdout.write(JSON.stringify({ id: "g" + i, catalog, query, args }) + "\n"); } diff --git a/examples/pkg_resolver/resolver.pl b/examples/pkg_resolver/resolver.pl index 0580afb0c..827f4ed84 100644 --- a/examples/pkg_resolver/resolver.pl +++ b/examples/pkg_resolver/resolver.pl @@ -2,31 +2,26 @@ % SPDX-License-Identifier: MIT OR Apache-2.0 % Copyright (c) 2026 John William Creighton (@s243a) % -% resolver.pl -- uw-resolve P0. Pure relations over a frozen catalog term. +% resolver.pl -- uw-resolve P0.5. Pure relations over a frozen catalog term. % -% Catalog: +% Catalog (P0, still accepted): % catalog(Packages, Depends, Conflicts, Base, Installed, Requested) -% Packages = [package(Name, v(M,I,P)), ...] -% Depends = [depends(Name, Ver, DepName, Constraint), ...] -% Conflicts = [conflicts(Name, Ver, OtherName), ...] -% Base/Installed = [Name-Ver, ...] -% Requested = [Name, ...] % manual/root installs (removal_orphans) % -% Constraints: any | eq(V) | gte(V) | lt(V) | range(Lo, Hi) -% Lo inclusive, Hi exclusive. Versions compared lexicographically. -% Debian epoch/tilde semantics are deferred. +% Catalog (P0.5 extras; Layers / Excluded / Aliases): +% catalog(Packages, Depends, Conflicts, Base, Installed, Requested, +% Layers, Excluded, Aliases) % -% Queries (Catalog is data; no assert/retract): -% resolve(+Cat, +Requests, -Selection) -% resolve_layered(+Cat, +Requests, -Selection) -% explain_blocked(+Cat, +Request, -Blocked) % nondet -% layer_closure(+Cat, +Request, -Layer) -% removal_orphans(+Cat, +Pkg, -Orphans) +% Base entries (back-compat): +% Name-Ver % Reason = blanket +% base(Name-Ver, Reason) % Reason ∈ layer_shadow | abi_anchor +% % | modified | footprint | blanket +% layer(LayerName, [Entry...]) % also accepted in Base; base = layer `base` +% Layers: [layer(Name, [Entry...]), ...] +% Excluded: [Name, ...] % candidate-generation blacklist only +% Aliases: [alias(Alias, Canonical), ...] % request edge only % -% Determinism: resolve* commit to the FIRST search solution (prefer a -% base-satisfied dependency, else highest version). Selections are sorted -% by Name-Ver. explain_blocked enumerates; callers findall+sort at the -% API edge. removal_orphans returns a sorted list. +% Constraints: any | eq(V) | gte(V) | lt(V) | range(Lo, Hi) +% Debian epoch/tilde, Provides/virtual, GP-LMDB catalog, CLI: deferred. % % swipl -q -g test_resolver -t halt examples/pkg_resolver/test_resolver.pl @@ -37,20 +32,38 @@ explain_blocked_list/3, layer_closure/3, removal_orphans/3, + safe_upgrade/4, + upgrade_set/4, + upgrade_set_result/4, + freeze_audit/2, + dependents/3, + dependents_installed/3, satisfies/2, version_lt/2 ]). % --------------------------------------------------------------------------- -% Catalog accessors +% Catalog accessors — catalog/6 (P0) and catalog/9 (P0.5) % --------------------------------------------------------------------------- packages(catalog(Ps, _, _, _, _, _), Ps). +packages(catalog(Ps, _, _, _, _, _, _, _, _), Ps). depends_list(catalog(_, Ds, _, _, _, _), Ds). +depends_list(catalog(_, Ds, _, _, _, _, _, _, _), Ds). conflicts_list(catalog(_, _, Cs, _, _, _), Cs). +conflicts_list(catalog(_, _, Cs, _, _, _, _, _, _), Cs). base_list(catalog(_, _, _, Bs, _, _), Bs). +base_list(catalog(_, _, _, Bs, _, _, _, _, _), Bs). installed_list(catalog(_, _, _, _, Is, _), Is). +installed_list(catalog(_, _, _, _, Is, _, _, _, _), Is). requested_list(catalog(_, _, _, _, _, Rs), Rs). +requested_list(catalog(_, _, _, _, _, Rs, _, _, _), Rs). +layers_list(catalog(_, _, _, _, _, _), []). +layers_list(catalog(_, _, _, _, _, _, Ls, _, _), Ls). +excluded_list(catalog(_, _, _, _, _, _), []). +excluded_list(catalog(_, _, _, _, _, _, _, Es, _), Es). +alias_list(catalog(_, _, _, _, _, _), []). +alias_list(catalog(_, _, _, _, _, _, _, _, As), As). package_in(Cat, Name, Ver) :- packages(Cat, Ps), @@ -64,9 +77,13 @@ conflicts_list(Cat, Cs), member(conflicts(Name, Ver, Other), Cs). +% A package in ANY loaded layer (base list + named layers), first match. +% Bare Name-Ver is the P0 shape; base/2 and nested layer/2 are P0.5. base_ver(Cat, Name, Ver) :- base_list(Cat, Bs), - member(Name-Ver, Bs). + layers_list(Cat, Ls), + append(Bs, Ls, All), + lookup_held(All, Name, Ver). base_name(Cat, Name) :- base_ver(Cat, Name, _). @@ -75,6 +92,23 @@ installed_list(Cat, Is), member(Name-Ver, Is). +excluded_name(Cat, Name) :- + excluded_list(Cat, Es), + member(Name, Es). + +lookup_held([H|T], Name, Ver) :- + ( item_ver(H, Name, V0) + -> Ver = V0 + ; lookup_held(T, Name, Ver) + ). + +item_ver(N-V, Name, V) :- + N == Name. +item_ver(base(N-V, _R), Name, V) :- + N == Name. +item_ver(layer(_L, Pkgs), Name, V) :- + lookup_held(Pkgs, Name, V). + % --------------------------------------------------------------------------- % Versions and constraints % --------------------------------------------------------------------------- @@ -95,10 +129,13 @@ \+ version_lt(Ver, Lo), version_lt(Ver, Hi). -% Highest version first (standard order on v/3 is lexicographic). -% Collected without findall so the JS WAM interpreter does not have to -% run a lowered helper inside BeginAggregate (that path drops answers). +tight_constraint(C) :- + C \== any. + +% Highest version first. Excluded names produce no candidates (blacklist +% filters generation only — never removal). candidates_high_first(Cat, Name, C, Ver) :- + \+ excluded_name(Cat, Name), packages(Cat, Ps), matching_versions(Ps, Name, C, Vs), sort(Vs, Asc), @@ -115,20 +152,31 @@ matching_versions(Rest, Name, C, Vs). % --------------------------------------------------------------------------- -% Requests +% Requests (aliases applied here only; catalog names stay canonical) % --------------------------------------------------------------------------- -request_to_req(R, req(Name, C)) :- - ( R = req(Name, C) - -> true - ; Name = R, +canonicalize_name(Cat, In, Out) :- + alias_list(Cat, As), + alias_lookup(As, In, Out). + +alias_lookup([], N, N). +alias_lookup([alias(A, Canon)|Rest], In, Out) :- + ( In == A + -> Out = Canon + ; alias_lookup(Rest, In, Out) + ). + +request_to_req(Cat, R, req(Name, C)) :- + ( R = req(Raw, C) + -> canonicalize_name(Cat, Raw, Name) + ; canonicalize_name(Cat, R, Name), C = any ). -map_requests([], []). -map_requests([R|Rs], [Q|Qs]) :- - request_to_req(R, Q), - map_requests(Rs, Qs). +map_requests(_Cat, [], []). +map_requests(Cat, [R|Rs], [Q|Qs]) :- + request_to_req(Cat, R, Q), + map_requests(Cat, Rs, Qs). selected_ver([H|Rest], Name, Ver) :- ( H = Name-Ver @@ -140,7 +188,7 @@ member(Name-Ver, Acc). % --------------------------------------------------------------------------- -% Conflicts: either direction, against a selected OtherName (any version). +% Conflicts % --------------------------------------------------------------------------- acc_conflicts(Cat, Name, Ver, Acc) :- @@ -149,8 +197,6 @@ ; conflicts_in(Cat, Other, OtherVer, Name) ). -% Deterministic scan — no leftover CPs, so a later failure can still -% retry candidate versions. Used by resolve_pending instead of \+/1. no_acc_conflicts(_Cat, _Name, _Ver, []). no_acc_conflicts(Cat, Name, Ver, [Other-OtherVer|Rest]) :- \+ conflicts_in(Cat, Name, Ver, Other), @@ -158,21 +204,17 @@ no_acc_conflicts(Cat, Name, Ver, Rest). % --------------------------------------------------------------------------- -% Classic resolve — first solution, highest version, may "upgrade" a base pkg. +% Classic / layered resolve % --------------------------------------------------------------------------- resolve(Cat, Requests, Selection) :- - map_requests(Requests, Pending), + map_requests(Cat, Requests, Pending), resolve_pending(classic, Cat, Pending, [], Acc), !, sort(Acc, Selection). -% --------------------------------------------------------------------------- -% Layered resolve — never re-select or upgrade a base package. -% --------------------------------------------------------------------------- - resolve_layered(Cat, Requests, Selection) :- - map_requests(Requests, Pending), + map_requests(Cat, Requests, Pending), resolve_pending(layered, Cat, Pending, [], Acc), !, sort(Acc, Selection). @@ -205,13 +247,12 @@ ), matching_deps(Rest, Name, Ver, Rs). -% Classic: catalog versions, highest first. Backtracks. pick(classic, Cat, Name, C, _Acc, Ver, from_catalog) :- candidates_high_first(Cat, Name, C, Ver). -% Layered: a base package that satisfies is used in-place (not selected). -% A base package that does not satisfy is a hard fail (no upgrade). -% Names not in the base are chosen from the catalog, highest first. +% Layered: a loaded-layer package that satisfies is used in-place +% (never re-selected). A loaded-layer package that does not satisfy is +% a hard fail. Names not in any loaded layer come from the catalog. pick(layered, Cat, Name, C, _Acc, Ver, Origin) :- ( base_ver(Cat, Name, BV) -> satisfies(BV, C), @@ -222,15 +263,15 @@ ). % --------------------------------------------------------------------------- -% explain_blocked — same layered pick, failure branch yields blocked/3. +% explain_blocked % --------------------------------------------------------------------------- explain_blocked(Cat, Request, Blocked) :- - request_to_req(Request, Req), + request_to_req(Cat, Request, Req), blocked_from(Cat, Req, [], Blocked). explain_blocked_list(Cat, Request, List) :- - request_to_req(Request, Req), + request_to_req(Cat, Request, Req), blocked_acc(Cat, Req, [], [], Acc), sort(Acc, List), !. @@ -247,7 +288,6 @@ member(Dep, DepReqs), blocked_from(Cat, Dep, [Name|Seen], Blocked). -% Deterministic walk used by explain_blocked_list/3 (no findall). blocked_acc(_Cat, req(Name, _C), Seen, Acc, Acc) :- seen_name(Seen, Name), !. blocked_acc(Cat, req(Name, C), Seen, Acc0, Acc) :- @@ -273,8 +313,6 @@ ; seen_name(Rest, Name) ). -% The version layered resolution would use, if any (no conflict check — -% version-ceiling explanations are independent of sibling conflicts). layered_walk_ver(Cat, Name, C, Ver) :- ( base_ver(Cat, Name, BV) -> satisfies(BV, C), @@ -284,7 +322,7 @@ !. % --------------------------------------------------------------------------- -% layer_closure — non-base closure, dependencies before dependents. +% layer_closure % --------------------------------------------------------------------------- layer_closure(Cat, Request, Layer) :- @@ -323,10 +361,11 @@ ). % --------------------------------------------------------------------------- -% removal_orphans — PPM-style trim. Base packages are never orphans. +% removal_orphans — exclusion is NOT consulted (Pkg bug we refuse to copy) % --------------------------------------------------------------------------- -removal_orphans(Cat, Pkg, Orphans) :- +removal_orphans(Cat, Pkg0, Orphans) :- + canonicalize_name(Cat, Pkg0, Pkg), installed_list(Cat, Inst), ( installed_ver(Cat, Pkg, Ver) -> true @@ -382,3 +421,194 @@ roots_to_pairs(Ns, Inst, Ps). roots_to_pairs([_|Ns], Inst, Ps) :- roots_to_pairs(Ns, Inst, Ps). + +% --------------------------------------------------------------------------- +% Base holds with reasons (P0 Name-Ver ⇒ blanket). Named layers other +% than `base` are not freeze-audited. +% --------------------------------------------------------------------------- + +base_holds(Cat, Holds) :- + base_list(Cat, Bs), + scan_base_holds(Bs, [], Acc), + sort(Acc, Holds). + +scan_base_holds([], Acc, Acc). +scan_base_holds([H|T], Acc0, Acc) :- + ( H = layer(base, Pkgs) + -> scan_base_holds(Pkgs, Acc0, Acc1) + ; H = layer(_, _) + -> Acc1 = Acc0 + ; H = base(N-V, R) + -> Acc1 = [hold(N, V, R)|Acc0] + ; H = N-V + -> Acc1 = [hold(N, V, blanket)|Acc0] + ; Acc1 = Acc0 + ), + scan_base_holds(T, Acc1, Acc). + +base_reason(Cat, Name, Reason) :- + base_holds(Cat, Holds), + hold_reason(Holds, Name, Reason). + +hold_reason([hold(N, _V, R)|T], Name, Reason) :- + ( N == Name + -> Reason = R + ; hold_reason(T, Name, Reason) + ). + +% --------------------------------------------------------------------------- +% safe_upgrade / upgrade_set +% --------------------------------------------------------------------------- + +safe_upgrade(Cat, Pkg0, NewVer, Verdict) :- + canonicalize_name(Cat, Pkg0, Pkg), + ( \+ package_in(Cat, Pkg, NewVer) + -> Verdict = no_candidate + ; \+ base_reason(Cat, Pkg, _) + -> Verdict = no_candidate + ; base_reason(Cat, Pkg, Reason), + safe_upgrade_reason(Cat, Pkg, NewVer, Reason, Verdict) + ), + !. + +safe_upgrade_reason(_Cat, _Pkg, _NewVer, modified, unsafe(modified)). +safe_upgrade_reason(_Cat, _Pkg, _NewVer, footprint, safe(cost(footprint))). +safe_upgrade_reason(_Cat, _Pkg, _NewVer, blanket, safe(cost(blanket))). +safe_upgrade_reason(_Cat, _Pkg, _NewVer, layer_shadow, safe(cost(layer_shadow))). +safe_upgrade_reason(Cat, Pkg, NewVer, abi_anchor, coordinated(Set)) :- + upgrade_set_result(Cat, Pkg, NewVer, ok(Set)). + +upgrade_set(Cat, Pkg, NewVer, Set) :- + upgrade_set_result(Cat, Pkg, NewVer, ok(Set)), + !. + +upgrade_set_result(Cat, Pkg0, NewVer, Result) :- + canonicalize_name(Cat, Pkg0, Pkg), + ( package_in(Cat, Pkg, NewVer) + -> close_moving(Cat, [Pkg-NewVer], Result) + ; Result = no_candidate + ), + !. + +close_moving(Cat, Acc, Result) :- + base_holds(Cat, Holds), + first_broken(Holds, Cat, Acc, Broken), + ( Broken = none + -> sort(Acc, Sorted), + Result = ok(Sorted) + ; Broken = broken(N, V, C), + ( pick_repair(Cat, N, Acc, NewV) + -> close_moving(Cat, [N-NewV|Acc], Result) + ; Result = blocked(N, needs(C), base_has(V)) + ) + ). + +first_broken([], _Cat, _Acc, none). +first_broken([hold(N, V, _R)|Rest], Cat, Acc, Broken) :- + ( selected_ver(Acc, N, _) + -> first_broken(Rest, Cat, Acc, Broken) + ; dep_breaks_moving(Cat, N, V, Acc, C) + -> Broken = broken(N, V, C) + ; first_broken(Rest, Cat, Acc, Broken) + ). + +dep_breaks_moving(Cat, N, V, Acc, C) :- + depends_list(Cat, Ds), + dep_breaks(Ds, N, V, Acc, C). + +dep_breaks([depends(HN, HV, D, C)|Rest], N, V, Acc, COut) :- + ( HN == N, + HV == V, + selected_ver(Acc, D, MV), + \+ satisfies(MV, C) + -> COut = C + ; dep_breaks(Rest, N, V, Acc, COut) + ). + +pick_repair(Cat, Name, Acc, NewV) :- + candidates_high_first(Cat, Name, any, NewV), + repairs_moving(Cat, Name, NewV, Acc). + +repairs_moving(Cat, Name, NewV, Acc) :- + collect_deps(Cat, Name, NewV, Reqs), + reqs_ok_moving(Reqs, Acc). + +reqs_ok_moving([], _). +reqs_ok_moving([req(D, C)|Rest], Acc) :- + ( selected_ver(Acc, D, MV) + -> satisfies(MV, C) + ; true + ), + reqs_ok_moving(Rest, Acc). + +% --------------------------------------------------------------------------- +% freeze_audit +% --------------------------------------------------------------------------- + +freeze_audit(Cat, Audit) :- + base_holds(Cat, Holds), + audit_holds(Holds, Cat, [], Acc), + sort(Acc, Audit), + !. + +audit_holds([], _Cat, Acc, Acc). +audit_holds([hold(N, _V, R)|Rest], Cat, Acc0, Acc) :- + ( R == blanket + -> ( tight_base_revdep(Cat, N) + -> Item = audit(N, suggest(abi_anchor)) + ; Item = audit(N, over_frozen) + ) + ; Item = audit(N, held(R)) + ), + audit_holds(Rest, Cat, [Item|Acc0], Acc). + +tight_base_revdep(Cat, Pkg) :- + base_holds(Cat, Holds), + tight_rev_in(Holds, Cat, Pkg). + +tight_rev_in([hold(N, V, _R)|Rest], Cat, Pkg) :- + ( N \== Pkg, + depends_in(Cat, N, V, Pkg, C), + tight_constraint(C) + -> true + ; tight_rev_in(Rest, Cat, Pkg) + ). + +% --------------------------------------------------------------------------- +% dependents / dependents_installed (what-needs) +% --------------------------------------------------------------------------- + +dependents(Cat, Pkg0, Deps) :- + canonicalize_name(Cat, Pkg0, Pkg), + depends_list(Cat, Ds), + direct_on(Ds, Pkg, [], Acc), + sort(Acc, Deps), + !. + +dependents_installed(Cat, Pkg0, Deps) :- + dependents(Cat, Pkg0, All), + keep_installed_or_base(All, Cat, [], Acc), + sort(Acc, Deps), + !. + +direct_on([], _Pkg, Acc, Acc). +direct_on([depends(N, V, D, _C)|Rest], Pkg, Acc0, Acc) :- + ( D == Pkg + -> Acc1 = [N-V|Acc0] + ; Acc1 = Acc0 + ), + direct_on(Rest, Pkg, Acc1, Acc). + +keep_installed_or_base([], _Cat, Acc, Acc). +keep_installed_or_base([N-V|Rest], Cat, Acc0, Acc) :- + ( installed_or_base(Cat, N, V) + -> Acc1 = [N-V|Acc0] + ; Acc1 = Acc0 + ), + keep_installed_or_base(Rest, Cat, Acc1, Acc). + +installed_or_base(Cat, N, V) :- + installed_ver(Cat, N, V). +installed_or_base(Cat, N, V) :- + base_ver(Cat, N, BV), + V == BV. diff --git a/examples/pkg_resolver/run_differential.sh b/examples/pkg_resolver/run_differential.sh index 204ed9bfa..b40d06883 100755 --- a/examples/pkg_resolver/run_differential.sh +++ b/examples/pkg_resolver/run_differential.sh @@ -2,8 +2,8 @@ # SPDX-License-Identifier: MIT OR Apache-2.0 # Copyright (c) 2026 John William Creighton (@s243a) # -# run_differential.sh -- ≥2000 seeded catalogs through SWI and the wamjs -# build; exit non-zero on any divergence of the four queries. +# run_differential.sh -- ≥2200 seeded catalogs through SWI and the wamjs +# build; exit non-zero on any divergence of any query (P0 four + P0.5). # # bash examples/pkg_resolver/run_differential.sh diff --git a/examples/pkg_resolver/test_resolver.pl b/examples/pkg_resolver/test_resolver.pl index d28fc8dda..3e5792d10 100644 --- a/examples/pkg_resolver/test_resolver.pl +++ b/examples/pkg_resolver/test_resolver.pl @@ -2,7 +2,7 @@ % SPDX-License-Identifier: MIT OR Apache-2.0 % Copyright (c) 2026 John William Creighton (@s243a) % -% test_resolver.pl -- uw-resolve P0 contract corpus. +% test_resolver.pl -- uw-resolve P0 + P0.5 contract corpus. % % swipl -q -g test_resolver -t halt examples/pkg_resolver/test_resolver.pl @@ -163,6 +163,116 @@ [lib-V1, old-V1], [], []). +% --- P0.5 catalogs (P0 catalogs above are unchanged) --- + +scenario_catalog(reasons_safe, Cat) :- + v1(V1), v2(V2), + Cat = catalog( + [package(foot, V1), package(foot, V2), + package(blank, V1), package(blank, V2), + package(shadow, V1), package(shadow, V2)], + [], [], + [base(foot-V1, footprint), base(blank-V1, blanket), + base(shadow-V1, layer_shadow)], + [], []). + +scenario_catalog(reasons_modified, Cat) :- + v1(V1), v2(V2), + Cat = catalog( + [package(patched, V1), package(patched, V2)], + [], [], + [base(patched-V1, modified)], + [], []). + +scenario_catalog(abi_coord, Cat) :- + v1(V1), v2(V2), + Cat = catalog( + [package(lib, V1), package(lib, V2), + package(app, V1), package(app, V2), + package(tool, V1)], + [depends(app, V1, lib, lt(V2)), + depends(app, V2, lib, gte(V2)), + depends(tool, V1, lib, any)], + [], + [base(lib-V1, abi_anchor), app-V1, tool-V1], + [], []). + +scenario_catalog(abi_blocked, Cat) :- + v1(V1), v2(V2), + Cat = catalog( + [package(lib, V1), package(lib, V2), + package(app, V1)], + [depends(app, V1, lib, eq(V1))], + [], + [base(lib-V1, abi_anchor), app-V1], + [], []). + +scenario_catalog(audit_mix, Cat) :- + v1(V1), v2(V2), + Cat = catalog( + [package(solo, V1), package(lib, V1), package(lib, V2), + package(app, V1), package(patched, V1)], + [depends(app, V1, lib, eq(V1))], + [], + [solo-V1, lib-V1, base(app-V1, footprint), base(patched-V1, modified)], + [], []). + +scenario_catalog(named_devx, Cat) :- + v1(V), + Cat = catalog( + [package(app, V), package(lib, V), package(gcc, V)], + [depends(app, V, lib, any), depends(lib, V, gcc, any)], + [], + [lib-V], + [], [], + [layer(devx, [gcc-V])], + [], []). + +scenario_catalog(excluded_select, Cat) :- + v1(V), + Cat = catalog( + [package(app, V), package(bad, V)], + [depends(app, V, bad, any)], + [], [], [], [], + [], + [bad], + []). + +scenario_catalog(excluded_removal, Cat) :- + v1(V), + Cat = catalog( + [package(app, V), package(lib, V)], + [depends(app, V, lib, any)], + [], + [], + [app-V, lib-V], + [app], + [], + [lib], + []). + +scenario_catalog(what_needs, Cat) :- + v1(V), v2(V2), + Cat = catalog( + [package(lib, V), package(app, V), package(app, V2), + package(other, V), package(ghost, V)], + [depends(app, V, lib, any), depends(app, V2, lib, gte(V)), + depends(other, V, lib, any), depends(ghost, V, nosuch, any)], + [], + [lib-V], + [app-V, lib-V], + [app]). + +scenario_catalog(alias_rxvt, Cat) :- + v1(V), + Cat = catalog( + [package(rxvt, V), package(app, V)], + [depends(app, V, rxvt, any)], + [], [], [], [], + [], + [], + [alias(urxvt, rxvt)]). + % corpus_case(Id, CatalogName, Query, Args) % Query = resolve | resolve_layered | explain_blocked | layer_closure | removal_orphans % Args = requests list, a single request, or a package name. @@ -189,6 +299,23 @@ corpus_case(layered_request_already_base, base_request, resolve_layered, [lib]). corpus_case(layered_request_already_base_layer, base_request, layer_closure, lib). corpus_case(removal_missing_pkg, empty, removal_orphans, ghost). +% P0.5 +corpus_case(safe_upgrade_footprint, reasons_safe, safe_upgrade, [foot, v(2, 0, 0)]). +corpus_case(safe_upgrade_blanket, reasons_safe, safe_upgrade, [blank, v(2, 0, 0)]). +corpus_case(safe_upgrade_shadow, reasons_safe, safe_upgrade, [shadow, v(2, 0, 0)]). +corpus_case(safe_upgrade_modified, reasons_modified, safe_upgrade, [patched, v(2, 0, 0)]). +corpus_case(safe_upgrade_no_candidate, reasons_safe, safe_upgrade, [foot, v(9, 0, 0)]). +corpus_case(safe_upgrade_coordinated, abi_coord, safe_upgrade, [lib, v(2, 0, 0)]). +corpus_case(upgrade_set_minimal, abi_coord, upgrade_set, [lib, v(2, 0, 0)]). +corpus_case(upgrade_set_blocked, abi_blocked, upgrade_set, [lib, v(2, 0, 0)]). +corpus_case(freeze_audit_mix, audit_mix, freeze_audit, []). +corpus_case(named_layer_satisfies, named_devx, resolve_layered, [app]). +corpus_case(named_layer_closure, named_devx, layer_closure, app). +corpus_case(excluded_never_selected, excluded_select, resolve, [app]). +corpus_case(excluded_does_not_block_removal, excluded_removal, removal_orphans, app). +corpus_case(dependents_lib, what_needs, dependents, lib). +corpus_case(dependents_installed_lib, what_needs, dependents_installed, lib). +corpus_case(alias_request_edge, alias_rxvt, resolve, [urxvt]). :- begin_tests(pkg_resolver). @@ -341,4 +468,97 @@ removal_orphans(Cat, ghost, Orphans), assertion(Orphans == []). +% ---- P0.5 --------------------------------------------------------------- + +test(safe_upgrade_footprint) :- + scenario_catalog(reasons_safe, Cat), v2(V2), + safe_upgrade(Cat, foot, V2, Verdict), + assertion(Verdict == safe(cost(footprint))). + +test(safe_upgrade_blanket) :- + scenario_catalog(reasons_safe, Cat), v2(V2), + safe_upgrade(Cat, blank, V2, Verdict), + assertion(Verdict == safe(cost(blanket))). + +test(safe_upgrade_layer_shadow) :- + scenario_catalog(reasons_safe, Cat), v2(V2), + safe_upgrade(Cat, shadow, V2, Verdict), + assertion(Verdict == safe(cost(layer_shadow))). + +test(safe_upgrade_modified) :- + scenario_catalog(reasons_modified, Cat), v2(V2), + safe_upgrade(Cat, patched, V2, Verdict), + assertion(Verdict == unsafe(modified)). + +test(safe_upgrade_no_candidate) :- + scenario_catalog(reasons_safe, Cat), + safe_upgrade(Cat, foot, v(9, 0, 0), Verdict), + assertion(Verdict == no_candidate). + +test(safe_upgrade_coordinated) :- + scenario_catalog(abi_coord, Cat), v2(V2), + safe_upgrade(Cat, lib, V2, Verdict), + assertion(Verdict == coordinated([app-V2, lib-V2])). + +test(upgrade_set_minimality) :- + scenario_catalog(abi_coord, Cat), v1(V1), v2(V2), + upgrade_set(Cat, lib, V2, Set), + assertion(Set == [app-V2, lib-V2]), + assertion(\+ member(tool-_, Set)), + assertion(\+ member(app-V1, Set)). + +test(upgrade_set_blocked_explanation) :- + scenario_catalog(abi_blocked, Cat), v1(V1), v2(V2), + \+ upgrade_set(Cat, lib, V2, _), + upgrade_set_result(Cat, lib, V2, R), + assertion(R == blocked(app, needs(eq(V1)), base_has(V1))). + +test(freeze_audit_over_frozen_and_suggest) :- + scenario_catalog(audit_mix, Cat), + freeze_audit(Cat, Audit), + assertion(member(audit(solo, over_frozen), Audit)), + assertion(member(audit(lib, suggest(abi_anchor)), Audit)), + assertion(member(audit(app, held(footprint)), Audit)), + assertion(member(audit(patched, held(modified)), Audit)). + +test(named_layer_satisfies_dep) :- + scenario_catalog(named_devx, Cat), v1(V), + resolve_layered(Cat, [app], Sel), + assertion(Sel == [app-V]), + assertion(\+ member(gcc-_, Sel)), + assertion(\+ member(lib-_, Sel)). + +test(named_layer_closure_omits_loaded) :- + scenario_catalog(named_devx, Cat), v1(V), + layer_closure(Cat, app, Layer), + assertion(Layer == [app-V]). + +test(excluded_never_selected) :- + scenario_catalog(excluded_select, Cat), + \+ resolve(Cat, [app], _), + \+ resolve(Cat, [bad], _). + +test(excluded_does_not_block_removal) :- + scenario_catalog(excluded_removal, Cat), v1(V), + removal_orphans(Cat, app, Orphans), + assertion(Orphans == [lib-V]). + +test(dependents_direct) :- + scenario_catalog(what_needs, Cat), v1(V), v2(V2), + dependents(Cat, lib, Ds), + assertion(Ds == [app-V, app-V2, other-V]). + +test(dependents_installed_restricted) :- + scenario_catalog(what_needs, Cat), v1(V), + dependents_installed(Cat, lib, Ds), + assertion(Ds == [app-V]), + assertion(\+ member(other-_, Ds)), + assertion(\+ member(app-v(2, 0, 0), Ds)). + +test(alias_at_request_edge) :- + scenario_catalog(alias_rxvt, Cat), v1(V), + resolve(Cat, [urxvt], Sel), + assertion(Sel == [rxvt-V]), + assertion(\+ member(urxvt-_, Sel)). + :- end_tests(pkg_resolver). diff --git a/examples/pkg_resolver/wamjs/js/generated_program.js b/examples/pkg_resolver/wamjs/js/generated_program.js index 2a6ed4aa5..64a1aa46e 100644 --- a/examples/pkg_resolver/wamjs/js/generated_program.js +++ b/examples/pkg_resolver/wamjs/js/generated_program.js @@ -20,20 +20,40 @@ const intern_seed = [ "", "[|]", "catalog", - "-", + "alias", + "hold", + "blanket", + "audit", + "suggest", + "abi_anchor", + "over_frozen", + "held", "req", "blocked", "needs", "base_has", + "none", + "ok", + "broken", + "-", "conflicts", "depends", + "base", + "layer", "package", "classic", "layered", "from_catalog", "from_base", - "none", "any", + "no_candidate", + "modified", + "unsafe", + "footprint", + "safe", + "cost", + "layer_shadow", + "coordinated", "eq", "gte", "lt", @@ -70,6 +90,142 @@ const shared_instructions = [ I.Call("conflicts_in", 4), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_alias_list_2_2_body"}]), + I.TryMeElse("L_alias_list_2_2"), + I.GetStructure(6, 1, 6), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.GetConstant(V.Atom(2), 2), + I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(109, 2), + I.Proceed(), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_alias_lookup_3_2_body", 1), + I.TryMeElse("L_alias_lookup_3_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetValue(101, 3), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(106), + I.GetStructure(7, 106, 2), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.UnifyVariable(203), + I.GetVariable(204, 2), + I.GetVariable(205, 3), + I.GetLevel(206), + I.TryMeElse("L_ite_else_4"), + I.PutValue(204, 1), + I.PutValue(201, 2), + I.BuiltinCall("==/2", 2), + I.Cut(206), + I.PutValue(205, 1), + I.PutValue(202, 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_4"), + I.TrustMe(), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.PutValue(205, 3), + I.Call("alias_lookup", 3), + I.Deallocate(), + I.Proceed(), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_audit_holds_4_2_body", 1), + I.TryMeElse("L_audit_holds_4_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetVariable(102, 3), + I.GetValue(102, 4), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(108), + I.GetStructure(8, 108, 3), + I.UnifyVariable(201), + I.UnifyVariable(109), + I.UnifyVariable(202), + I.UnifyVariable(203), + I.GetVariable(204, 2), + I.GetVariable(206, 3), + I.GetVariable(207, 4), + I.GetLevel(208), + I.TryMeElse("L_ite_else_6"), + I.PutValue(202, 1), + I.PutConstant(V.Atom(9), 2), + I.BuiltinCall("==/2", 2), + I.Cut(208), + I.GetLevel(209), + I.TryMeElse("L_ite_else_7"), + I.PutValue(204, 1), + I.PutValue(201, 2), + I.Call("tight_base_revdep", 2), + I.Cut(209), + I.PutVariable(205, 1), + I.PutStructure(10, 2, 2), + I.SetValue(201), + I.SetVariable(111), + I.PutStructure(11, 111, 1), + I.SetConstant(V.Atom(12)), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_7"), + I.TrustMe(), + I.PutVariable(205, 1), + I.PutStructure(10, 2, 2), + I.SetValue(201), + I.SetConstant(V.Atom(13)), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_6"), + I.TrustMe(), + I.PutVariable(205, 1), + I.PutStructure(10, 2, 2), + I.SetValue(201), + I.SetVariable(111), + I.PutStructure(14, 111, 1), + I.SetValue(202), + I.BuiltinCall("=/2", 2), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.PutStructure(5, 3, 2), + I.SetValue(205), + I.SetValue(206), + I.PutValue(207, 4), + I.Deallocate(), + I.Execute("audit_holds", 4), + I.Allocate(), + I.GetVariable(104, 1), + I.GetVariable(203, 2), + I.PutValue(104, 1), + I.PutVariable(201, 2), + I.Call("base_list", 2), + I.PutValue(201, 1), + I.PutConstant(V.Atom(2), 2), + I.PutVariable(202, 3), + I.Call("scan_base_holds", 3), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.BuiltinCall("sort/2", 2), + I.Deallocate(), + I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_base_list_2_2_body"}]), + I.TryMeElse("L_base_list_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -79,6 +235,19 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(104, 2), I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(104, 2), + I.Proceed(), I.Allocate(), I.GetVariable(101, 1), I.GetVariable(102, 2), @@ -89,23 +258,40 @@ const shared_instructions = [ I.Execute("base_ver", 3), I.Allocate(), I.GetVariable(104, 1), - I.GetVariable(201, 2), - I.GetVariable(202, 3), + I.GetVariable(202, 2), + I.GetVariable(203, 3), I.PutValue(104, 1), - I.PutVariable(203, 2), + I.PutVariable(201, 2), + I.Call("base_holds", 2), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.Deallocate(), + I.Execute("hold_reason", 3), + I.Allocate(), + I.GetVariable(201, 1), + I.GetVariable(205, 2), + I.GetVariable(206, 3), + I.PutValue(201, 1), + I.PutVariable(202, 2), I.Call("base_list", 2), - I.PutStructure(7, 1, 2), - I.SetValue(201), - I.SetValue(202), + I.PutValue(201, 1), + I.PutVariable(203, 2), + I.Call("layers_list", 2), + I.PutValue(202, 1), I.PutValue(203, 2), - I.BuiltinCall("member/2", 2), + I.PutVariable(204, 3), + I.BuiltinCall("append/3", 3), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.PutValue(206, 3), I.Deallocate(), - I.Proceed(), - I.SwitchOnStructureA2([{fid: 8, arity: 2, label: "default"}, {fid: 8, arity: 2, label: "L_blocked_acc_5_2"}]), + I.Execute("lookup_held", 3), + I.SwitchOnStructureA2([{fid: 15, arity: 2, label: "default"}, {fid: 15, arity: 2, label: "L_blocked_acc_5_2"}]), I.TryMeElse("L_blocked_acc_5_2"), I.Allocate(), I.GetVariable(101, 1), - I.GetStructure(8, 2, 2), + I.GetStructure(15, 2, 2), I.UnifyVariable(102), I.UnifyVariable(103), I.GetVariable(104, 3), @@ -120,26 +306,26 @@ const shared_instructions = [ I.TrustMe(), I.Allocate(), I.GetVariable(205, 1), - I.GetStructure(8, 2, 2), + I.GetStructure(15, 2, 2), I.UnifyVariable(207), I.UnifyVariable(203), I.GetVariable(208, 3), I.GetVariable(202, 4), I.GetVariable(209, 5), I.GetLevel(211), - I.TryMeElse("L_ite_else_4"), + I.TryMeElse("L_ite_else_12"), I.PutValue(205, 1), I.PutValue(207, 2), I.PutVariable(201, 3), I.Call("base_ver", 3), I.GetLevel(212), - I.TryMeElse("L_ite_else_5"), + I.TryMeElse("L_ite_else_13"), I.PutValue(201, 1), I.PutValue(203, 2), I.Call("satisfies", 2), I.Cut(212), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_5"), + I.Jump("L_ite_cont_13"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.Cut(211), @@ -147,22 +333,22 @@ const shared_instructions = [ I.PutStructure(5, 2, 2), I.SetVariable(112), I.SetValue(202), - I.PutStructure(9, 112, 3), + I.PutStructure(16, 112, 3), I.SetValue(207), I.SetVariable(113), I.SetVariable(114), - I.PutStructure(10, 113, 1), + I.PutStructure(17, 113, 1), I.SetValue(203), - I.PutStructure(11, 114, 1), + I.PutStructure(18, 114, 1), I.SetValue(201), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_4"), + I.Jump("L_ite_cont_12"), I.TrustMe(), I.PutVariable(210, 1), I.PutValue(202, 2), I.BuiltinCall("=/2", 2), I.GetLevel(213), - I.TryMeElse("L_ite_else_6"), + I.TryMeElse("L_ite_else_14"), I.PutValue(205, 1), I.PutValue(207, 2), I.PutValue(203, 3), @@ -182,7 +368,7 @@ const shared_instructions = [ I.PutValue(210, 4), I.PutValue(209, 5), I.Call("blocked_acc_list", 5), - I.Jump("L_ite_cont_6"), + I.Jump("L_ite_cont_14"), I.TrustMe(), I.PutValue(209, 1), I.PutValue(210, 2), @@ -219,23 +405,23 @@ const shared_instructions = [ I.PutValue(205, 5), I.Deallocate(), I.Execute("blocked_acc_list", 5), - I.SwitchOnStructureA2([{fid: 8, arity: 2, label: "default"}, {fid: 8, arity: 2, label: "L_blocked_from_4_2"}]), + I.SwitchOnStructureA2([{fid: 15, arity: 2, label: "default"}, {fid: 15, arity: 2, label: "L_blocked_from_4_2"}]), I.TryMeElse("L_blocked_from_4_2"), I.Allocate(), I.GetVariable(201, 1), - I.GetStructure(8, 2, 2), + I.GetStructure(15, 2, 2), I.UnifyVariable(203), I.UnifyVariable(204), I.GetVariable(106, 3), I.GetVariable(202, 4), I.GetLevel(206), - I.TryMeElse("L_ite_else_13"), + I.TryMeElse("L_ite_else_21"), I.PutValue(106, 1), I.PutValue(203, 2), I.Call("seen_name", 2), I.Cut(206), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_13"), + I.Jump("L_ite_cont_21"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.PutValue(201, 1), @@ -243,23 +429,23 @@ const shared_instructions = [ I.PutVariable(205, 3), I.Call("base_ver", 3), I.GetLevel(207), - I.TryMeElse("L_ite_else_14"), + I.TryMeElse("L_ite_else_22"), I.PutValue(205, 1), I.PutValue(204, 2), I.Call("satisfies", 2), I.Cut(207), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_14"), + I.Jump("L_ite_cont_22"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.PutValue(202, 1), - I.PutStructure(9, 2, 3), + I.PutStructure(16, 2, 3), I.SetValue(203), I.SetVariable(108), I.SetVariable(109), - I.PutStructure(10, 108, 1), + I.PutStructure(17, 108, 1), I.SetValue(204), - I.PutStructure(11, 109, 1), + I.PutStructure(18, 109, 1), I.SetValue(205), I.BuiltinCall("=/2", 2), I.Deallocate(), @@ -267,19 +453,19 @@ const shared_instructions = [ I.TrustMe(), I.Allocate(), I.GetVariable(204, 1), - I.GetStructure(8, 2, 2), + I.GetStructure(15, 2, 2), I.UnifyVariable(206), I.UnifyVariable(201), I.GetVariable(207, 3), I.GetVariable(208, 4), I.GetLevel(209), - I.TryMeElse("L_ite_else_15"), + I.TryMeElse("L_ite_else_23"), I.PutValue(207, 1), I.PutValue(206, 2), I.Call("seen_name", 2), I.Cut(209), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_15"), + I.Jump("L_ite_cont_23"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.PutValue(204, 1), @@ -304,27 +490,113 @@ const shared_instructions = [ I.Deallocate(), I.Execute("blocked_from", 4), I.Allocate(), - I.GetVariable(108, 1), + I.GetVariable(201, 1), + I.GetVariable(203, 2), + I.GetVariable(204, 3), + I.GetVariable(207, 4), + I.GetLevel(209), + I.TryMeElse("L_ite_else_30"), + I.PutValue(201, 1), + I.PutValue(203, 2), + I.Call("excluded_name", 2), + I.Cut(209), + I.BuiltinCall("fail/0", 0), + I.Jump("L_ite_cont_30"), + I.TrustMe(), + I.BuiltinCall("true/0", 0), + I.PutValue(201, 1), + I.PutVariable(202, 2), + I.Call("packages", 2), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.PutValue(204, 3), + I.PutVariable(205, 4), + I.Call("matching_versions", 4), + I.PutValue(205, 1), + I.PutVariable(206, 2), + I.BuiltinCall("sort/2", 2), + I.PutValue(206, 1), + I.PutVariable(208, 2), + I.BuiltinCall("reverse/2", 2), + I.PutValue(207, 1), + I.PutValue(208, 2), + I.BuiltinCall("member/2", 2), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(104, 1), I.GetVariable(202, 2), I.GetVariable(203, 3), - I.GetVariable(206, 4), - I.PutValue(108, 1), + I.PutValue(104, 1), I.PutVariable(201, 2), - I.Call("packages", 2), + I.Call("alias_list", 2), I.PutValue(201, 1), I.PutValue(202, 2), I.PutValue(203, 3), - I.PutVariable(204, 4), - I.Call("matching_versions", 4), + I.Deallocate(), + I.Execute("alias_lookup", 3), + I.Allocate(), + I.GetVariable(204, 1), + I.GetVariable(206, 2), + I.GetVariable(208, 3), I.PutValue(204, 1), - I.PutVariable(205, 2), - I.BuiltinCall("sort/2", 2), - I.PutValue(205, 1), - I.PutVariable(207, 2), - I.BuiltinCall("reverse/2", 2), + I.PutVariable(201, 2), + I.Call("base_holds", 2), + I.PutValue(201, 1), + I.PutValue(204, 2), + I.PutValue(206, 3), + I.PutVariable(203, 4), + I.Call("first_broken", 4), + I.GetLevel(211), + I.TryMeElse("L_ite_else_33"), + I.PutValue(203, 1), + I.PutConstant(V.Atom(19), 2), + I.BuiltinCall("=/2", 2), + I.Cut(211), I.PutValue(206, 1), - I.PutValue(207, 2), - I.BuiltinCall("member/2", 2), + I.PutVariable(202, 2), + I.BuiltinCall("sort/2", 2), + I.PutValue(208, 1), + I.PutStructure(20, 2, 1), + I.SetValue(202), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_33"), + I.TrustMe(), + I.PutValue(203, 1), + I.PutStructure(21, 2, 3), + I.SetVariable(205), + I.SetVariable(210), + I.SetVariable(209), + I.BuiltinCall("=/2", 2), + I.GetLevel(212), + I.TryMeElse("L_ite_else_34"), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.PutValue(206, 3), + I.PutVariable(207, 4), + I.Call("pick_repair", 4), + I.Cut(212), + I.PutValue(204, 1), + I.PutStructure(5, 2, 2), + I.SetVariable(113), + I.SetValue(206), + I.PutStructure(22, 113, 2), + I.SetValue(205), + I.SetValue(207), + I.PutValue(208, 3), + I.Call("close_moving", 3), + I.Jump("L_ite_cont_34"), + I.TrustMe(), + I.PutValue(208, 1), + I.PutStructure(16, 2, 3), + I.SetValue(205), + I.SetVariable(113), + I.SetVariable(114), + I.PutStructure(17, 113, 1), + I.SetValue(209), + I.PutStructure(18, 114, 1), + I.SetValue(210), + I.BuiltinCall("=/2", 2), I.Deallocate(), I.Proceed(), I.Allocate(), @@ -349,7 +621,7 @@ const shared_instructions = [ I.PutValue(105, 1), I.PutVariable(204, 2), I.Call("conflicts_list", 2), - I.PutStructure(12, 1, 3), + I.PutStructure(23, 1, 3), I.SetValue(201), I.SetValue(202), I.SetValue(203), @@ -357,6 +629,8 @@ const shared_instructions = [ I.BuiltinCall("member/2", 2), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_conflicts_list_2_2_body"}]), + I.TryMeElse("L_conflicts_list_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -366,16 +640,135 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(103, 2), I.Proceed(), - I.Allocate(), - I.GetVariable(106, 1), - I.GetVariable(201, 2), - I.GetVariable(202, 3), - I.GetVariable(203, 4), - I.GetVariable(204, 5), - I.PutValue(106, 1), - I.PutVariable(205, 2), - I.Call("depends_list", 2), - I.PutStructure(13, 1, 4), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(103, 2), + I.Proceed(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(111), + I.GetStructure(24, 111, 4), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.UnifyVariable(203), + I.UnifyVariable(205), + I.UnifyVariable(206), + I.GetVariable(207, 2), + I.GetVariable(208, 3), + I.GetVariable(209, 4), + I.GetVariable(210, 5), + I.GetLevel(211), + I.TryMeElse("L_ite_else_39"), + I.PutValue(201, 1), + I.PutValue(207, 2), + I.BuiltinCall("==/2", 2), + I.PutValue(202, 1), + I.PutValue(208, 2), + I.BuiltinCall("==/2", 2), + I.PutValue(209, 1), + I.PutValue(203, 2), + I.PutVariable(204, 3), + I.Call("selected_ver", 3), + I.GetLevel(212), + I.TryMeElse("L_ite_else_40"), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.Call("satisfies", 2), + I.Cut(212), + I.BuiltinCall("fail/0", 0), + I.Jump("L_ite_cont_40"), + I.TrustMe(), + I.BuiltinCall("true/0", 0), + I.Cut(211), + I.PutValue(210, 1), + I.PutValue(205, 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_39"), + I.TrustMe(), + I.PutValue(206, 1), + I.PutValue(207, 2), + I.PutValue(208, 3), + I.PutValue(209, 4), + I.PutValue(210, 5), + I.Call("dep_breaks", 5), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(106, 1), + I.GetVariable(202, 2), + I.GetVariable(203, 3), + I.GetVariable(204, 4), + I.GetVariable(205, 5), + I.PutValue(106, 1), + I.PutVariable(201, 2), + I.Call("depends_list", 2), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.PutValue(204, 4), + I.PutValue(205, 5), + I.Deallocate(), + I.Execute("dep_breaks", 5), + I.Allocate(), + I.GetVariable(201, 1), + I.GetVariable(106, 2), + I.GetVariable(205, 3), + I.PutValue(201, 1), + I.PutValue(106, 2), + I.PutVariable(203, 3), + I.Call("canonicalize_name", 3), + I.PutValue(201, 1), + I.PutVariable(202, 2), + I.Call("depends_list", 2), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.PutConstant(V.Atom(2), 3), + I.PutVariable(204, 4), + I.Call("direct_on", 4), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.BuiltinCall("sort/2", 2), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(202, 1), + I.GetVariable(105, 2), + I.GetVariable(204, 3), + I.PutValue(202, 1), + I.PutValue(105, 2), + I.PutVariable(201, 3), + I.Call("dependents", 3), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutConstant(V.Atom(2), 3), + I.PutVariable(203, 4), + I.Call("keep_installed_or_base", 4), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.BuiltinCall("sort/2", 2), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(106, 1), + I.GetVariable(201, 2), + I.GetVariable(202, 3), + I.GetVariable(203, 4), + I.GetVariable(204, 5), + I.PutValue(106, 1), + I.PutVariable(205, 2), + I.Call("depends_list", 2), + I.PutStructure(24, 1, 4), I.SetValue(201), I.SetValue(202), I.SetValue(203), @@ -384,6 +777,8 @@ const shared_instructions = [ I.BuiltinCall("member/2", 2), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_depends_list_2_2_body"}]), + I.TryMeElse("L_depends_list_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -393,6 +788,64 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(102, 2), I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(102, 2), + I.Proceed(), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_direct_on_4_2_body", 1), + I.TryMeElse("L_direct_on_4_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetVariable(102, 3), + I.GetValue(102, 4), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(109), + I.GetStructure(24, 109, 4), + I.UnifyVariable(202), + I.UnifyVariable(203), + I.UnifyVariable(201), + I.UnifyVariable(110), + I.UnifyVariable(205), + I.GetVariable(206, 2), + I.GetVariable(204, 3), + I.GetVariable(208, 4), + I.GetLevel(209), + I.TryMeElse("L_ite_else_43"), + I.PutValue(201, 1), + I.PutValue(206, 2), + I.BuiltinCall("==/2", 2), + I.Cut(209), + I.PutVariable(207, 1), + I.PutStructure(5, 2, 2), + I.SetVariable(112), + I.SetValue(204), + I.PutStructure(22, 112, 2), + I.SetValue(202), + I.SetValue(203), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_43"), + I.TrustMe(), + I.PutVariable(207, 1), + I.PutValue(204, 2), + I.BuiltinCall("=/2", 2), + I.PutValue(205, 1), + I.PutValue(206, 2), + I.PutValue(207, 3), + I.PutValue(208, 4), + I.Deallocate(), + I.Execute("direct_on", 4), I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_exclude_name_3_2", 2), I.TryMeElse("L_exclude_name_3_2"), I.GetVariable(101, 1), @@ -426,13 +879,49 @@ const shared_instructions = [ I.PutValue(104, 3), I.Deallocate(), I.Execute("exclude_name", 3), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_excluded_list_2_2_body"}]), + I.TryMeElse("L_excluded_list_2_2"), + I.GetStructure(6, 1, 6), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.GetConstant(V.Atom(2), 2), + I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(108, 2), + I.Proceed(), + I.Allocate(), + I.GetVariable(103, 1), + I.GetVariable(201, 2), + I.PutValue(103, 1), + I.PutVariable(202, 2), + I.Call("excluded_list", 2), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.BuiltinCall("member/2", 2), + I.Deallocate(), + I.Proceed(), I.Allocate(), I.GetVariable(201, 1), I.GetVariable(104, 2), I.GetVariable(203, 3), - I.PutValue(104, 1), - I.PutVariable(202, 2), - I.Call("request_to_req", 2), + I.PutValue(201, 1), + I.PutValue(104, 2), + I.PutVariable(202, 3), + I.Call("request_to_req", 3), I.PutValue(201, 1), I.PutValue(202, 2), I.PutConstant(V.Atom(2), 3), @@ -443,9 +932,10 @@ const shared_instructions = [ I.GetVariable(201, 1), I.GetVariable(105, 2), I.GetVariable(204, 3), - I.PutValue(105, 1), - I.PutVariable(202, 2), - I.Call("request_to_req", 2), + I.PutValue(201, 1), + I.PutValue(105, 2), + I.PutVariable(202, 3), + I.Call("request_to_req", 3), I.PutValue(201, 1), I.PutValue(202, 2), I.PutConstant(V.Atom(2), 3), @@ -458,78 +948,179 @@ const shared_instructions = [ I.BuiltinCall("!/0", 0), I.Deallocate(), I.Proceed(), - I.Allocate(), - I.GetVariable(101, 1), - I.GetVariable(102, 2), - I.GetVariable(103, 3), - I.GetVariable(104, 4), - I.GetVariable(105, 5), - I.PutList(1, 5), - I.SetVariable(107), - I.SetConstant(V.Atom(2)), - I.PutStructure(7, 107, 2), - I.SetValue(103), - I.SetValue(104), - I.PutValue(101, 2), - I.PutValue(102, 3), - I.PutConstant(V.Atom(2), 4), - I.PutConstant(V.Atom(2), 5), - I.PutValue(105, 6), - I.Deallocate(), - I.Execute("inst_walk", 6), - I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_inst_walk_6_2_body", 1), - I.TryMeElse("L_inst_walk_6_2"), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_first_broken_4_2_body", 1), + I.TryMeElse("L_first_broken_4_2"), I.GetConstant(V.Atom(2), 1), I.GetVariable(101, 2), I.GetVariable(102, 3), - I.GetVariable(103, 4), - I.GetVariable(104, 5), - I.GetValue(104, 6), + I.GetConstant(V.Atom(19), 4), I.Proceed(), I.TrustMe(), I.Allocate(), I.GetList(1, 5), - I.UnifyVariable(114), - I.GetStructure(7, 114, 2), - I.UnifyVariable(210), + I.UnifyVariable(109), + I.GetStructure(8, 109, 3), I.UnifyVariable(203), - I.UnifyVariable(206), - I.GetVariable(208, 2), - I.GetVariable(209, 3), - I.GetVariable(211, 4), - I.GetVariable(212, 5), - I.GetVariable(213, 6), - I.GetLevel(214), - I.TryMeElse("L_ite_else_22"), - I.PutValue(210, 1), - I.PutValue(211, 2), - I.BuiltinCall("member/2", 2), - I.Cut(214), - I.PutValue(206, 1), - I.PutValue(208, 2), - I.PutValue(209, 3), - I.PutValue(211, 4), - I.PutValue(212, 5), - I.PutValue(213, 6), - I.Call("inst_walk", 6), - I.Jump("L_ite_cont_22"), - I.TrustMe(), - I.PutVariable(205, 205), - I.PutVariable(201, 201), - I.PutVariable(202, 202), - I.BeginAggregate("collect", 1, 205, []), + I.UnifyVariable(204), + I.UnifyVariable(110), + I.UnifyVariable(208), + I.GetVariable(202, 2), + I.GetVariable(205, 3), + I.GetVariable(207, 4), + I.GetLevel(209), + I.TryMeElse("L_ite_else_45"), + I.PutValue(205, 1), + I.PutValue(203, 2), + I.PutVariable(201, 3), + I.Call("selected_ver", 3), + I.Cut(209), + I.PutValue(208, 1), + I.PutValue(202, 2), + I.PutValue(205, 3), + I.PutValue(207, 4), + I.Call("first_broken", 4), + I.Jump("L_ite_cont_45"), + I.TrustMe(), + I.GetLevel(210), + I.TryMeElse("L_ite_else_46"), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.PutValue(204, 3), + I.PutValue(205, 4), + I.PutVariable(206, 5), + I.Call("dep_breaks_moving", 5), + I.Cut(210), + I.PutValue(207, 1), + I.PutStructure(21, 2, 3), + I.SetValue(203), + I.SetValue(204), + I.SetValue(206), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_46"), + I.TrustMe(), + I.PutValue(208, 1), + I.PutValue(202, 2), + I.PutValue(205, 3), + I.PutValue(207, 4), + I.Call("first_broken", 4), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(202, 1), + I.GetVariable(204, 2), + I.PutValue(202, 1), + I.PutVariable(201, 2), + I.Call("base_holds", 2), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutConstant(V.Atom(2), 3), + I.PutVariable(203, 4), + I.Call("audit_holds", 4), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.BuiltinCall("sort/2", 2), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(106), + I.GetStructure(8, 106, 3), + I.UnifyVariable(201), + I.UnifyVariable(107), + I.UnifyVariable(202), + I.UnifyVariable(203), + I.GetVariable(204, 2), + I.GetVariable(205, 3), + I.GetLevel(206), + I.TryMeElse("L_ite_else_49"), + I.PutValue(201, 1), + I.PutValue(204, 2), + I.BuiltinCall("==/2", 2), + I.Cut(206), + I.PutValue(205, 1), + I.PutValue(202, 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_49"), + I.TrustMe(), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.PutValue(205, 3), + I.Call("hold_reason", 3), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetVariable(104, 4), + I.GetVariable(105, 5), + I.PutList(1, 5), + I.SetVariable(107), + I.SetConstant(V.Atom(2)), + I.PutStructure(22, 107, 2), + I.SetValue(103), + I.SetValue(104), + I.PutValue(101, 2), + I.PutValue(102, 3), + I.PutConstant(V.Atom(2), 4), + I.PutConstant(V.Atom(2), 5), + I.PutValue(105, 6), + I.Deallocate(), + I.Execute("inst_walk", 6), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_inst_walk_6_2_body", 1), + I.TryMeElse("L_inst_walk_6_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetVariable(102, 3), + I.GetVariable(103, 4), + I.GetVariable(104, 5), + I.GetValue(104, 6), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(114), + I.GetStructure(22, 114, 2), + I.UnifyVariable(210), + I.UnifyVariable(203), + I.UnifyVariable(206), + I.GetVariable(208, 2), + I.GetVariable(209, 3), + I.GetVariable(211, 4), + I.GetVariable(212, 5), + I.GetVariable(213, 6), + I.GetLevel(214), + I.TryMeElse("L_ite_else_51"), + I.PutValue(210, 1), + I.PutValue(211, 2), + I.BuiltinCall("member/2", 2), + I.Cut(214), + I.PutValue(206, 1), + I.PutValue(208, 2), + I.PutValue(209, 3), + I.PutValue(211, 4), + I.PutValue(212, 5), + I.PutValue(213, 6), + I.Call("inst_walk", 6), + I.Jump("L_ite_cont_51"), + I.TrustMe(), + I.PutVariable(205, 205), + I.PutVariable(201, 201), + I.PutVariable(202, 202), + I.BeginAggregate("collect", 1, 205, []), I.PutValue(208, 1), I.PutValue(210, 2), I.PutValue(203, 3), I.PutValue(201, 4), I.PutVariable(204, 5), I.Call("depends_in", 5), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(201), I.SetValue(202), I.PutValue(209, 2), I.BuiltinCall("member/2", 2), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(201), I.SetValue(202), I.EndAggregate(1), @@ -550,6 +1141,8 @@ const shared_instructions = [ I.Call("inst_walk", 6), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_installed_list_2_2_body"}]), + I.TryMeElse("L_installed_list_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -559,6 +1152,43 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(105, 2), I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(105, 2), + I.Proceed(), + I.TryMeElse("L_installed_or_base_3_2"), + I.Allocate(), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.PutValue(101, 1), + I.PutValue(102, 2), + I.PutValue(103, 3), + I.Deallocate(), + I.Execute("installed_ver", 3), + I.TrustMe(), + I.Allocate(), + I.GetVariable(103, 1), + I.GetVariable(104, 2), + I.GetVariable(201, 3), + I.PutValue(103, 1), + I.PutValue(104, 2), + I.PutVariable(202, 3), + I.Call("base_ver", 3), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.BuiltinCall("==/2", 2), + I.Deallocate(), + I.Proceed(), I.Allocate(), I.GetVariable(104, 1), I.GetVariable(201, 2), @@ -566,13 +1196,97 @@ const shared_instructions = [ I.PutValue(104, 1), I.PutVariable(203, 2), I.Call("installed_list", 2), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(201), I.SetValue(202), I.PutValue(203, 2), I.BuiltinCall("member/2", 2), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 22, arity: 2, label: "default"}, {fid: 25, arity: 2, label: "L_item_ver_3_2_body"}, {fid: 26, arity: 2, label: "L_item_ver_3_3_body"}]), + I.TryMeElse("L_item_ver_3_2"), + I.Allocate(), + I.GetStructure(22, 1, 2), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.GetVariable(103, 2), + I.GetValue(102, 3), + I.PutValue(101, 1), + I.PutValue(103, 2), + I.BuiltinCall("==/2", 2), + I.Deallocate(), + I.Proceed(), + I.RetryMeElse("L_item_ver_3_3"), + I.Allocate(), + I.GetStructure(25, 1, 2), + I.UnifyVariable(101), + I.GetStructure(22, 101, 2), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.GetVariable(105, 2), + I.GetValue(103, 3), + I.PutValue(102, 1), + I.PutValue(105, 2), + I.BuiltinCall("==/2", 2), + I.Deallocate(), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetStructure(26, 1, 2), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.GetVariable(103, 2), + I.GetVariable(104, 3), + I.PutValue(102, 1), + I.PutValue(103, 2), + I.PutValue(104, 3), + I.Deallocate(), + I.Execute("lookup_held", 3), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_keep_installed_or_base_4_2_body", 1), + I.TryMeElse("L_keep_installed_or_base_4_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetVariable(102, 3), + I.GetValue(102, 4), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(108), + I.GetStructure(22, 108, 2), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.UnifyVariable(204), + I.GetVariable(205, 2), + I.GetVariable(203, 3), + I.GetVariable(207, 4), + I.GetLevel(208), + I.TryMeElse("L_ite_else_54"), + I.PutValue(205, 1), + I.PutValue(201, 2), + I.PutValue(202, 3), + I.Call("installed_or_base", 3), + I.Cut(208), + I.PutVariable(206, 1), + I.PutStructure(5, 2, 2), + I.SetVariable(110), + I.SetValue(203), + I.PutStructure(22, 110, 2), + I.SetValue(201), + I.SetValue(202), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_54"), + I.TrustMe(), + I.PutVariable(206, 1), + I.PutValue(203, 2), + I.BuiltinCall("=/2", 2), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.PutValue(206, 3), + I.PutValue(207, 4), + I.Deallocate(), + I.Execute("keep_installed_or_base", 4), I.Allocate(), I.GetVariable(201, 1), I.GetVariable(104, 2), @@ -596,7 +1310,7 @@ const shared_instructions = [ I.GetVariable(204, 3), I.GetVariable(205, 4), I.GetLevel(206), - I.TryMeElse("L_ite_else_25"), + I.TryMeElse("L_ite_else_57"), I.PutValue(202, 1), I.PutValue(203, 2), I.PutVariable(201, 3), @@ -608,7 +1322,7 @@ const shared_instructions = [ I.PutValue(205, 1), I.PutValue(201, 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_25"), + I.Jump("L_ite_cont_57"), I.TrustMe(), I.PutValue(202, 1), I.PutValue(203, 2), @@ -618,38 +1332,90 @@ const shared_instructions = [ I.BuiltinCall("!/0", 0), I.Deallocate(), I.Proceed(), - I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_map_requests_2_2_body", 1), - I.TryMeElse("L_map_requests_2_2"), - I.GetConstant(V.Atom(2), 1), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_layers_list_2_2_body"}]), + I.TryMeElse("L_layers_list_2_2"), + I.GetStructure(6, 1, 6), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), I.GetConstant(V.Atom(2), 2), I.Proceed(), I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(107, 2), + I.Proceed(), I.Allocate(), I.GetList(1, 5), - I.UnifyVariable(103), I.UnifyVariable(201), - I.GetList(2, 5), - I.UnifyVariable(104), - I.UnifyVariable(202), - I.PutValue(103, 1), - I.PutValue(104, 2), - I.Call("request_to_req", 2), + I.UnifyVariable(203), + I.GetVariable(204, 2), + I.GetVariable(205, 3), + I.GetLevel(206), + I.TryMeElse("L_ite_else_60"), I.PutValue(201, 1), + I.PutValue(204, 2), + I.PutVariable(202, 3), + I.Call("item_ver", 3), + I.Cut(206), + I.PutValue(205, 1), I.PutValue(202, 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_60"), + I.TrustMe(), + I.PutValue(203, 1), + I.PutValue(204, 2), + I.PutValue(205, 3), + I.Call("lookup_held", 3), I.Deallocate(), - I.Execute("map_requests", 2), - I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_matching_deps_4_2_body", 1), - I.TryMeElse("L_matching_deps_4_2"), - I.GetConstant(V.Atom(2), 1), - I.GetVariable(101, 2), - I.GetVariable(102, 3), - I.GetConstant(V.Atom(2), 4), + I.Proceed(), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_map_requests_3_2", 2), + I.TryMeElse("L_map_requests_3_2"), + I.GetVariable(101, 1), + I.GetConstant(V.Atom(2), 2), + I.GetConstant(V.Atom(2), 3), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetVariable(201, 1), + I.GetList(2, 5), + I.UnifyVariable(104), + I.UnifyVariable(202), + I.GetList(3, 5), + I.UnifyVariable(105), + I.UnifyVariable(203), + I.PutValue(201, 1), + I.PutValue(104, 2), + I.PutValue(105, 3), + I.Call("request_to_req", 3), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.Deallocate(), + I.Execute("map_requests", 3), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_matching_deps_4_2_body", 1), + I.TryMeElse("L_matching_deps_4_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetVariable(102, 3), + I.GetConstant(V.Atom(2), 4), I.Proceed(), I.TrustMe(), I.Allocate(), I.GetList(1, 5), I.UnifyVariable(110), - I.GetStructure(13, 110, 4), + I.GetStructure(24, 110, 4), I.UnifyVariable(201), I.UnifyVariable(202), I.UnifyVariable(203), @@ -659,7 +1425,7 @@ const shared_instructions = [ I.GetVariable(208, 3), I.GetVariable(205, 4), I.GetLevel(210), - I.TryMeElse("L_ite_else_28"), + I.TryMeElse("L_ite_else_62"), I.PutValue(201, 1), I.PutValue(207, 2), I.BuiltinCall("==/2", 2), @@ -671,11 +1437,11 @@ const shared_instructions = [ I.PutStructure(5, 2, 2), I.SetVariable(112), I.SetVariable(209), - I.PutStructure(8, 112, 2), + I.PutStructure(15, 112, 2), I.SetValue(203), I.SetValue(204), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_28"), + I.Jump("L_ite_cont_62"), I.TrustMe(), I.PutValue(205, 1), I.PutVariable(209, 2), @@ -697,7 +1463,7 @@ const shared_instructions = [ I.Allocate(), I.GetList(1, 5), I.UnifyVariable(108), - I.GetStructure(14, 108, 2), + I.GetStructure(27, 108, 2), I.UnifyVariable(201), I.UnifyVariable(202), I.UnifyVariable(204), @@ -705,7 +1471,7 @@ const shared_instructions = [ I.GetVariable(206, 3), I.GetVariable(203, 4), I.GetLevel(208), - I.TryMeElse("L_ite_else_30"), + I.TryMeElse("L_ite_else_64"), I.PutValue(201, 1), I.PutValue(205, 2), I.BuiltinCall("==/2", 2), @@ -718,7 +1484,7 @@ const shared_instructions = [ I.SetValue(202), I.SetVariable(207), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_30"), + I.Jump("L_ite_cont_64"), I.TrustMe(), I.PutValue(203, 1), I.PutVariable(207, 2), @@ -732,7 +1498,7 @@ const shared_instructions = [ I.GetVariable(101, 1), I.GetVariable(102, 2), I.GetVariable(103, 3), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(102), I.SetValue(103), I.PutValue(101, 2), @@ -747,7 +1513,7 @@ const shared_instructions = [ I.Allocate(), I.GetList(1, 5), I.UnifyVariable(101), - I.GetStructure(7, 101, 2), + I.GetStructure(22, 101, 2), I.UnifyVariable(102), I.UnifyVariable(103), I.UnifyVariable(104), @@ -795,12 +1561,12 @@ const shared_instructions = [ I.GetVariable(205, 3), I.GetList(4, 5), I.UnifyVariable(107), - I.GetStructure(7, 107, 2), + I.GetStructure(22, 107, 2), I.UnifyVariable(201), I.UnifyVariable(202), I.UnifyVariable(206), I.GetLevel(207), - I.TryMeElse("L_ite_else_32"), + I.TryMeElse("L_ite_else_66"), I.PutValue(203, 1), I.PutValue(204, 2), I.PutValue(205, 3), @@ -808,11 +1574,11 @@ const shared_instructions = [ I.Call("conflicts_in", 4), I.Cut(207), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_32"), + I.Jump("L_ite_cont_66"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.GetLevel(208), - I.TryMeElse("L_ite_else_33"), + I.TryMeElse("L_ite_else_67"), I.PutValue(203, 1), I.PutValue(201, 2), I.PutValue(202, 3), @@ -820,7 +1586,7 @@ const shared_instructions = [ I.Call("conflicts_in", 4), I.Cut(208), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_33"), + I.Jump("L_ite_cont_67"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.PutValue(203, 1), @@ -836,13 +1602,15 @@ const shared_instructions = [ I.PutValue(104, 1), I.PutVariable(203, 2), I.Call("packages", 2), - I.PutStructure(14, 1, 2), + I.PutStructure(27, 1, 2), I.SetValue(201), I.SetValue(202), I.PutValue(203, 2), I.BuiltinCall("member/2", 2), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_packages_2_2_body"}]), + I.TryMeElse("L_packages_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -852,16 +1620,29 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(101, 2), I.Proceed(), - I.SwitchOnConstant([{value: V.Atom(15), label: "default"}, {value: V.Atom(16), label: "L_pick_7_2_body"}], false), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(101, 2), + I.Proceed(), + I.SwitchOnConstant([{value: V.Atom(28), label: "default"}, {value: V.Atom(29), label: "L_pick_7_2_body"}], false), I.TryMeElse("L_pick_7_2"), I.Allocate(), - I.GetConstant(V.Atom(15), 1), + I.GetConstant(V.Atom(28), 1), I.GetVariable(101, 2), I.GetVariable(102, 3), I.GetVariable(103, 4), I.GetVariable(104, 5), I.GetVariable(105, 6), - I.GetConstant(V.Atom(17), 7), + I.GetConstant(V.Atom(30), 7), I.PutValue(101, 1), I.PutValue(102, 2), I.PutValue(103, 3), @@ -870,7 +1651,7 @@ const shared_instructions = [ I.Execute("candidates_high_first", 4), I.TrustMe(), I.Allocate(), - I.GetConstant(V.Atom(16), 1), + I.GetConstant(V.Atom(29), 1), I.GetVariable(202, 2), I.GetVariable(203, 3), I.GetVariable(204, 4), @@ -878,7 +1659,7 @@ const shared_instructions = [ I.GetVariable(205, 6), I.GetVariable(206, 7), I.GetLevel(207), - I.TryMeElse("L_ite_else_38"), + I.TryMeElse("L_ite_else_72"), I.PutValue(202, 1), I.PutValue(203, 2), I.PutVariable(201, 3), @@ -891,9 +1672,9 @@ const shared_instructions = [ I.PutValue(201, 2), I.BuiltinCall("=/2", 2), I.PutValue(206, 1), - I.PutConstant(V.Atom(18), 2), + I.PutConstant(V.Atom(31), 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_38"), + I.Jump("L_ite_cont_72"), I.TrustMe(), I.PutValue(202, 1), I.PutValue(203, 2), @@ -901,32 +1682,52 @@ const shared_instructions = [ I.PutValue(205, 4), I.Call("candidates_high_first", 4), I.PutValue(206, 1), - I.PutConstant(V.Atom(17), 2), + I.PutConstant(V.Atom(30), 2), I.BuiltinCall("=/2", 2), I.Deallocate(), I.Proceed(), I.Allocate(), + I.GetVariable(201, 1), + I.GetVariable(202, 2), + I.GetVariable(204, 3), + I.GetVariable(203, 4), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutConstant(V.Atom(32), 3), + I.PutValue(203, 4), + I.Call("candidates_high_first", 4), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.PutValue(204, 4), + I.Deallocate(), + I.Execute("repairs_moving", 4), + I.Allocate(), I.GetVariable(210, 1), - I.GetVariable(207, 2), + I.GetVariable(113, 2), I.GetVariable(212, 3), I.PutValue(210, 1), + I.PutValue(113, 2), + I.PutVariable(207, 3), + I.Call("canonicalize_name", 3), + I.PutValue(210, 1), I.PutVariable(206, 2), I.Call("installed_list", 2), I.GetLevel(213), - I.TryMeElse("L_ite_else_41"), + I.TryMeElse("L_ite_else_75"), I.PutValue(210, 1), I.PutValue(207, 2), I.PutVariable(201, 3), I.Call("installed_ver", 3), I.Cut(213), I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_41"), + I.Jump("L_ite_cont_75"), I.TrustMe(), I.PutVariable(201, 1), I.PutConstant(V.Atom(19), 2), I.BuiltinCall("=/2", 2), I.GetLevel(214), - I.TryMeElse("L_ite_else_42"), + I.TryMeElse("L_ite_else_76"), I.PutValue(201, 1), I.PutConstant(V.Atom(19), 2), I.BuiltinCall("==/2", 2), @@ -934,7 +1735,7 @@ const shared_instructions = [ I.PutValue(212, 1), I.PutConstant(V.Atom(2), 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_42"), + I.Jump("L_ite_cont_76"), I.TrustMe(), I.PutValue(210, 1), I.PutValue(206, 2), @@ -958,7 +1759,7 @@ const shared_instructions = [ I.PutVariable(204, 204), I.PutVariable(205, 205), I.BeginAggregate("collect", 1, 211, []), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(204), I.SetValue(205), I.PutValue(206, 2), @@ -970,26 +1771,26 @@ const shared_instructions = [ I.PutValue(208, 2), I.BuiltinCall("member/2", 2), I.GetLevel(215), - I.TryMeElse("L_ite_else_43"), + I.TryMeElse("L_ite_else_77"), I.PutValue(204, 1), I.PutValue(209, 2), I.BuiltinCall("member/2", 2), I.Cut(215), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_43"), + I.Jump("L_ite_cont_77"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.GetLevel(216), - I.TryMeElse("L_ite_else_44"), + I.TryMeElse("L_ite_else_78"), I.PutValue(210, 1), I.PutValue(204, 2), I.Call("base_name", 2), I.Cut(216), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_44"), + I.Jump("L_ite_cont_78"), I.TrustMe(), I.BuiltinCall("true/0", 0), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(204), I.SetValue(205), I.EndAggregate(1), @@ -1000,29 +1801,81 @@ const shared_instructions = [ I.Deallocate(), I.Proceed(), I.Allocate(), - I.GetVariable(202, 1), - I.GetStructure(8, 2, 2), + I.GetVariable(103, 1), + I.GetVariable(104, 2), + I.GetVariable(105, 3), + I.GetVariable(202, 4), + I.PutValue(103, 1), + I.PutValue(104, 2), + I.PutValue(105, 3), + I.PutVariable(201, 4), + I.Call("collect_deps", 4), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.Deallocate(), + I.Execute("reqs_ok_moving", 2), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_reqs_ok_moving_2_2_body", 1), + I.TryMeElse("L_reqs_ok_moving_2_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(106), + I.GetStructure(15, 106, 2), I.UnifyVariable(201), I.UnifyVariable(203), - I.GetLevel(204), - I.TryMeElse("L_ite_else_53"), + I.UnifyVariable(204), + I.GetVariable(205, 2), + I.GetLevel(206), + I.TryMeElse("L_ite_else_87"), + I.PutValue(205, 1), + I.PutValue(201, 2), + I.PutVariable(202, 3), + I.Call("selected_ver", 3), + I.Cut(206), I.PutValue(202, 1), - I.PutStructure(8, 2, 2), - I.SetValue(201), - I.SetValue(203), - I.BuiltinCall("=/2", 2), - I.Cut(204), - I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_53"), + I.PutValue(203, 2), + I.Call("satisfies", 2), + I.Jump("L_ite_cont_87"), I.TrustMe(), - I.PutValue(201, 1), - I.PutValue(202, 2), - I.BuiltinCall("=/2", 2), + I.BuiltinCall("true/0", 0), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.Deallocate(), + I.Execute("reqs_ok_moving", 2), + I.Allocate(), + I.GetVariable(202, 1), + I.GetVariable(203, 2), + I.GetStructure(15, 3, 2), + I.UnifyVariable(204), + I.UnifyVariable(205), + I.GetLevel(206), + I.TryMeElse("L_ite_else_89"), I.PutValue(203, 1), - I.PutConstant(V.Atom(20), 2), + I.PutStructure(15, 2, 2), + I.SetVariable(201), + I.SetValue(205), + I.BuiltinCall("=/2", 2), + I.Cut(206), + I.PutValue(202, 1), + I.PutValue(201, 2), + I.PutValue(204, 3), + I.Call("canonicalize_name", 3), + I.Jump("L_ite_cont_89"), + I.TrustMe(), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.PutValue(204, 3), + I.Call("canonicalize_name", 3), + I.PutValue(205, 1), + I.PutConstant(V.Atom(32), 2), I.BuiltinCall("=/2", 2), I.Deallocate(), I.Proceed(), + I.SwitchOnStructure([{fid: 6, arity: 6, label: "default"}, {fid: 6, arity: 9, label: "L_requested_list_2_2_body"}]), + I.TryMeElse("L_requested_list_2_2"), I.GetStructure(6, 1, 6), I.UnifyVariable(101), I.UnifyVariable(102), @@ -1032,14 +1885,28 @@ const shared_instructions = [ I.UnifyVariable(106), I.GetValue(106, 2), I.Proceed(), + I.TrustMe(), + I.GetStructure(6, 1, 9), + I.UnifyVariable(101), + I.UnifyVariable(102), + I.UnifyVariable(103), + I.UnifyVariable(104), + I.UnifyVariable(105), + I.UnifyVariable(106), + I.UnifyVariable(107), + I.UnifyVariable(108), + I.UnifyVariable(109), + I.GetValue(106, 2), + I.Proceed(), I.Allocate(), I.GetVariable(201, 1), I.GetVariable(105, 2), I.GetVariable(204, 3), - I.PutValue(105, 1), - I.PutVariable(202, 2), - I.Call("map_requests", 2), - I.PutConstant(V.Atom(15), 1), + I.PutValue(201, 1), + I.PutValue(105, 2), + I.PutVariable(202, 3), + I.Call("map_requests", 3), + I.PutConstant(V.Atom(28), 1), I.PutValue(201, 2), I.PutValue(202, 3), I.PutConstant(V.Atom(2), 4), @@ -1055,10 +1922,11 @@ const shared_instructions = [ I.GetVariable(201, 1), I.GetVariable(105, 2), I.GetVariable(204, 3), - I.PutValue(105, 1), - I.PutVariable(202, 2), - I.Call("map_requests", 2), - I.PutConstant(V.Atom(16), 1), + I.PutValue(201, 1), + I.PutValue(105, 2), + I.PutVariable(202, 3), + I.Call("map_requests", 3), + I.PutConstant(V.Atom(29), 1), I.PutValue(201, 2), I.PutValue(202, 3), I.PutConstant(V.Atom(2), 4), @@ -1083,14 +1951,14 @@ const shared_instructions = [ I.GetVariable(206, 2), I.GetList(3, 5), I.UnifyVariable(112), - I.GetStructure(8, 112, 2), + I.GetStructure(15, 112, 2), I.UnifyVariable(210), I.UnifyVariable(201), I.UnifyVariable(203), I.GetVariable(208, 4), I.GetVariable(209, 5), I.GetLevel(212), - I.TryMeElse("L_ite_else_55"), + I.TryMeElse("L_ite_else_91"), I.PutValue(208, 1), I.PutValue(210, 2), I.PutVariable(211, 3), @@ -1105,7 +1973,7 @@ const shared_instructions = [ I.PutValue(208, 4), I.PutValue(209, 5), I.Call("resolve_pending", 5), - I.Jump("L_ite_cont_55"), + I.Jump("L_ite_cont_91"), I.TrustMe(), I.PutValue(205, 1), I.PutValue(206, 2), @@ -1125,9 +1993,9 @@ const shared_instructions = [ I.PutVariable(207, 3), I.BuiltinCall("append/3", 3), I.GetLevel(213), - I.TryMeElse("L_ite_else_56"), + I.TryMeElse("L_ite_else_92"), I.PutValue(204, 1), - I.PutConstant(V.Atom(18), 2), + I.PutConstant(V.Atom(31), 2), I.BuiltinCall("=/2", 2), I.Cut(213), I.PutValue(205, 1), @@ -1136,7 +2004,7 @@ const shared_instructions = [ I.PutValue(208, 4), I.PutValue(209, 5), I.Call("resolve_pending", 5), - I.Jump("L_ite_cont_56"), + I.Jump("L_ite_cont_92"), I.TrustMe(), I.PutValue(206, 1), I.PutValue(210, 2), @@ -1149,7 +2017,7 @@ const shared_instructions = [ I.PutStructure(5, 4, 2), I.SetVariable(114), I.SetValue(208), - I.PutStructure(7, 114, 2), + I.PutStructure(22, 114, 2), I.SetValue(210), I.SetValue(211), I.PutValue(209, 5), @@ -1170,11 +2038,11 @@ const shared_instructions = [ I.GetVariable(202, 2), I.GetList(3, 5), I.UnifyVariable(105), - I.GetStructure(7, 105, 2), + I.GetStructure(22, 105, 2), I.UnifyValue(104), I.UnifyVariable(106), I.UnifyVariable(203), - I.PutStructure(7, 1, 2), + I.PutStructure(22, 1, 2), I.SetValue(104), I.SetValue(106), I.PutValue(202, 2), @@ -1199,14 +2067,127 @@ const shared_instructions = [ I.Execute("roots_to_pairs", 3), I.Try("L_roots_to_pairs_3_2_body"), I.Trust("L_roots_to_pairs_3_3_body"), - I.SwitchOnTerm([{value: V.Atom(20), label: "default"}], [{fid: 21, arity: 1, label: "L_satisfies_2_2"}, {fid: 22, arity: 1, label: "L_satisfies_2_3"}, {fid: 23, arity: 1, label: "L_satisfies_2_4"}, {fid: 24, arity: 2, label: "L_satisfies_2_5"}], "none", 2), + I.Allocate(), + I.GetVariable(201, 1), + I.GetVariable(107, 2), + I.GetVariable(206, 3), + I.GetVariable(204, 4), + I.PutValue(201, 1), + I.PutValue(107, 2), + I.PutVariable(202, 3), + I.Call("canonicalize_name", 3), + I.GetLevel(207), + I.TryMeElse("L_ite_else_97"), + I.GetLevel(208), + I.TryMeElse("L_ite_else_98"), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(206, 3), + I.Call("package_in", 3), + I.Cut(208), + I.BuiltinCall("fail/0", 0), + I.Jump("L_ite_cont_98"), + I.TrustMe(), + I.BuiltinCall("true/0", 0), + I.Cut(207), + I.PutValue(204, 1), + I.PutConstant(V.Atom(33), 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_97"), + I.TrustMe(), + I.GetLevel(208), + I.TryMeElse("L_ite_else_99"), + I.GetLevel(209), + I.TryMeElse("L_ite_else_100"), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutVariable(203, 3), + I.Call("base_reason", 3), + I.Cut(209), + I.BuiltinCall("fail/0", 0), + I.Jump("L_ite_cont_100"), + I.TrustMe(), + I.BuiltinCall("true/0", 0), + I.Cut(208), + I.PutValue(204, 1), + I.PutConstant(V.Atom(33), 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_99"), + I.TrustMe(), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutVariable(205, 3), + I.Call("base_reason", 3), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(206, 3), + I.PutValue(205, 4), + I.PutValue(204, 5), + I.Call("safe_upgrade_reason", 5), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.TryMeElse("L_safe_upgrade_reason_5_2"), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetConstant(V.Atom(34), 4), + I.GetStructure(35, 5, 1), + I.UnifyConstant(V.Atom(34)), + I.Proceed(), + I.RetryMeElse("L_safe_upgrade_reason_5_3"), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetConstant(V.Atom(36), 4), + I.GetStructure(37, 5, 1), + I.UnifyVariable(104), + I.GetStructure(38, 104, 1), + I.UnifyConstant(V.Atom(36)), + I.Proceed(), + I.RetryMeElse("L_safe_upgrade_reason_5_4"), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetConstant(V.Atom(9), 4), + I.GetStructure(37, 5, 1), + I.UnifyVariable(104), + I.GetStructure(38, 104, 1), + I.UnifyConstant(V.Atom(9)), + I.Proceed(), + I.RetryMeElse("L_safe_upgrade_reason_5_5"), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetConstant(V.Atom(39), 4), + I.GetStructure(37, 5, 1), + I.UnifyVariable(104), + I.GetStructure(38, 104, 1), + I.UnifyConstant(V.Atom(39)), + I.Proceed(), + I.TrustMe(), + I.Allocate(), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetConstant(V.Atom(12), 4), + I.GetStructure(40, 5, 1), + I.UnifyVariable(104), + I.PutValue(101, 1), + I.PutValue(102, 2), + I.PutValue(103, 3), + I.PutStructure(20, 4, 1), + I.SetValue(104), + I.Deallocate(), + I.Execute("upgrade_set_result", 4), + I.SwitchOnTerm([{value: V.Atom(32), label: "default"}], [{fid: 41, arity: 1, label: "L_satisfies_2_2"}, {fid: 42, arity: 1, label: "L_satisfies_2_3"}, {fid: 43, arity: 1, label: "L_satisfies_2_4"}, {fid: 44, arity: 2, label: "L_satisfies_2_5"}], "none", 2), I.TryMeElse("L_satisfies_2_2"), I.GetVariable(101, 1), - I.GetConstant(V.Atom(20), 2), + I.GetConstant(V.Atom(32), 2), I.Proceed(), I.RetryMeElse("L_satisfies_2_3"), I.GetVariable(101, 1), - I.GetStructure(21, 2, 1), + I.GetStructure(41, 2, 1), I.UnifyVariable(102), I.PutValue(101, 1), I.PutValue(102, 2), @@ -1214,23 +2195,23 @@ const shared_instructions = [ I.Proceed(), I.RetryMeElse("L_satisfies_2_4"), I.GetVariable(101, 1), - I.GetStructure(22, 2, 1), + I.GetStructure(42, 2, 1), I.UnifyVariable(102), I.GetLevel(201), - I.TryMeElse("L_ite_else_61"), + I.TryMeElse("L_ite_else_109"), I.PutValue(101, 1), I.PutValue(102, 2), I.Call("version_lt", 2), I.Cut(201), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_61"), + I.Jump("L_ite_cont_109"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.Proceed(), I.RetryMeElse("L_satisfies_2_5"), I.Allocate(), I.GetVariable(101, 1), - I.GetStructure(23, 2, 1), + I.GetStructure(43, 2, 1), I.UnifyVariable(102), I.PutValue(101, 1), I.PutValue(102, 2), @@ -1239,65 +2220,203 @@ const shared_instructions = [ I.TrustMe(), I.Allocate(), I.GetVariable(201, 1), - I.GetStructure(24, 2, 2), + I.GetStructure(44, 2, 2), I.UnifyVariable(103), I.UnifyVariable(202), I.GetLevel(203), - I.TryMeElse("L_ite_else_62"), + I.TryMeElse("L_ite_else_110"), I.PutValue(201, 1), I.PutValue(103, 2), I.Call("version_lt", 2), I.Cut(203), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_62"), + I.Jump("L_ite_cont_110"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.PutValue(201, 1), I.PutValue(202, 2), I.Deallocate(), I.Execute("version_lt", 2), + I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_scan_base_holds_3_2_body", 1), + I.TryMeElse("L_scan_base_holds_3_2"), + I.GetConstant(V.Atom(2), 1), + I.GetVariable(101, 2), + I.GetValue(101, 3), + I.Proceed(), + I.TrustMe(), I.Allocate(), I.GetList(1, 5), - I.UnifyVariable(201), I.UnifyVariable(202), - I.GetVariable(203, 2), - I.GetLevel(204), - I.TryMeElse("L_ite_else_65"), + I.UnifyVariable(209), + I.GetVariable(205, 2), + I.GetVariable(211, 3), + I.GetLevel(212), + I.TryMeElse("L_ite_else_113"), + I.PutValue(202, 1), + I.PutStructure(26, 2, 2), + I.SetConstant(V.Atom(25)), + I.SetVariable(201), + I.BuiltinCall("=/2", 2), + I.Cut(212), I.PutValue(201, 1), - I.PutValue(203, 2), - I.BuiltinCall("==/2", 2), - I.Cut(204), - I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_65"), + I.PutValue(205, 2), + I.PutVariable(210, 3), + I.Call("scan_base_holds", 3), + I.Jump("L_ite_cont_113"), I.TrustMe(), + I.GetLevel(213), + I.TryMeElse("L_ite_else_114"), I.PutValue(202, 1), - I.PutValue(203, 2), - I.Call("seen_name", 2), - I.Deallocate(), - I.Proceed(), - I.Allocate(), - I.GetList(1, 5), - I.UnifyVariable(201), - I.UnifyVariable(202), - I.GetVariable(203, 2), - I.GetVariable(204, 3), - I.GetLevel(205), - I.TryMeElse("L_ite_else_67"), - I.PutValue(201, 1), - I.PutStructure(7, 2, 2), - I.SetValue(203), - I.SetValue(204), + I.PutStructure(26, 2, 2), + I.SetVariable(203), + I.SetVariable(204), I.BuiltinCall("=/2", 2), - I.Cut(205), - I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_67"), + I.Cut(213), + I.PutVariable(210, 1), + I.PutValue(205, 2), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_114"), I.TrustMe(), + I.GetLevel(214), + I.TryMeElse("L_ite_else_115"), I.PutValue(202, 1), - I.PutValue(203, 2), + I.PutStructure(25, 2, 2), + I.SetVariable(113), + I.SetVariable(208), + I.PutStructure(22, 113, 2), + I.SetVariable(206), + I.SetVariable(207), + I.BuiltinCall("=/2", 2), + I.Cut(214), + I.PutVariable(210, 1), + I.PutStructure(5, 2, 2), + I.SetVariable(115), + I.SetValue(205), + I.PutStructure(8, 115, 3), + I.SetValue(206), + I.SetValue(207), + I.SetValue(208), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_115"), + I.TrustMe(), + I.GetLevel(215), + I.TryMeElse("L_ite_else_116"), + I.PutValue(202, 1), + I.PutStructure(22, 2, 2), + I.SetVariable(206), + I.SetVariable(207), + I.BuiltinCall("=/2", 2), + I.Cut(215), + I.PutVariable(210, 1), + I.PutStructure(5, 2, 2), + I.SetVariable(114), + I.SetValue(205), + I.PutStructure(8, 114, 3), + I.SetValue(206), + I.SetValue(207), + I.SetConstant(V.Atom(9)), + I.BuiltinCall("=/2", 2), + I.Jump("L_ite_cont_116"), + I.TrustMe(), + I.PutVariable(210, 1), + I.PutValue(205, 2), + I.BuiltinCall("=/2", 2), + I.PutValue(209, 1), + I.PutValue(210, 2), + I.PutValue(211, 3), + I.Deallocate(), + I.Execute("scan_base_holds", 3), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.GetVariable(203, 2), + I.GetLevel(204), + I.TryMeElse("L_ite_else_121"), + I.PutValue(201, 1), + I.PutValue(203, 2), + I.BuiltinCall("==/2", 2), + I.Cut(204), + I.BuiltinCall("true/0", 0), + I.Jump("L_ite_cont_121"), + I.TrustMe(), + I.PutValue(202, 1), + I.PutValue(203, 2), + I.Call("seen_name", 2), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.GetVariable(203, 2), + I.GetVariable(204, 3), + I.GetLevel(205), + I.TryMeElse("L_ite_else_123"), + I.PutValue(201, 1), + I.PutStructure(22, 2, 2), + I.SetValue(203), + I.SetValue(204), + I.BuiltinCall("=/2", 2), + I.Cut(205), + I.BuiltinCall("true/0", 0), + I.Jump("L_ite_cont_123"), + I.TrustMe(), + I.PutValue(202, 1), + I.PutValue(203, 2), I.PutValue(204, 3), I.Call("selected_ver", 3), I.Deallocate(), I.Proceed(), + I.Allocate(), + I.GetVariable(202, 1), + I.GetVariable(203, 2), + I.PutValue(202, 1), + I.PutVariable(201, 2), + I.Call("base_holds", 2), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.Deallocate(), + I.Execute("tight_rev_in", 3), + I.Allocate(), + I.PutConstant(V.Atom(32), 2), + I.BuiltinCall("\\==/2", 2), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetList(1, 5), + I.UnifyVariable(107), + I.GetStructure(8, 107, 3), + I.UnifyVariable(201), + I.UnifyVariable(202), + I.UnifyVariable(108), + I.UnifyVariable(204), + I.GetVariable(205, 2), + I.GetVariable(206, 3), + I.GetLevel(207), + I.TryMeElse("L_ite_else_125"), + I.PutValue(201, 1), + I.PutValue(206, 2), + I.BuiltinCall("\\==/2", 2), + I.PutValue(205, 1), + I.PutValue(201, 2), + I.PutValue(202, 3), + I.PutValue(206, 4), + I.PutVariable(203, 5), + I.Call("depends_in", 5), + I.PutValue(203, 1), + I.Call("tight_constraint", 1), + I.Cut(207), + I.BuiltinCall("true/0", 0), + I.Jump("L_ite_cont_125"), + I.TrustMe(), + I.PutValue(204, 1), + I.PutValue(205, 2), + I.PutValue(206, 3), + I.Call("tight_rev_in", 3), + I.Deallocate(), + I.Proceed(), I.SwitchOnTerm([{value: V.Atom(2), label: "default"}], [], "L_topo_all_7_2", 2), I.TryMeElse("L_topo_all_7_2"), I.GetVariable(101, 1), @@ -1361,8 +2480,8 @@ const shared_instructions = [ I.GetVariable(214, 6), I.GetVariable(213, 7), I.GetLevel(215), - I.TryMeElse("L_ite_else_69"), - I.PutStructure(7, 1, 2), + I.TryMeElse("L_ite_else_128"), + I.PutStructure(22, 1, 2), I.SetValue(211), I.SetVariable(207), I.PutValue(206, 2), @@ -1395,14 +2514,14 @@ const shared_instructions = [ I.PutStructure(5, 2, 2), I.SetVariable(118), I.SetValue(208), - I.PutStructure(7, 118, 2), + I.PutStructure(22, 118, 2), I.SetValue(211), I.SetValue(207), I.BuiltinCall("=/2", 2), I.PutValue(210, 1), I.PutValue(209, 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_69"), + I.Jump("L_ite_cont_128"), I.TrustMe(), I.PutValue(210, 1), I.PutStructure(5, 2, 2), @@ -1448,25 +2567,72 @@ const shared_instructions = [ I.Deallocate(), I.Proceed(), I.Allocate(), - I.GetStructure(25, 1, 3), + I.GetVariable(101, 1), + I.GetVariable(102, 2), + I.GetVariable(103, 3), + I.GetVariable(104, 4), + I.PutValue(101, 1), + I.PutValue(102, 2), + I.PutValue(103, 3), + I.PutStructure(20, 4, 1), + I.SetValue(104), + I.Call("upgrade_set_result", 4), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetVariable(201, 1), + I.GetVariable(105, 2), + I.GetVariable(203, 3), + I.GetVariable(204, 4), + I.PutValue(201, 1), + I.PutValue(105, 2), + I.PutVariable(202, 3), + I.Call("canonicalize_name", 3), + I.GetLevel(205), + I.TryMeElse("L_ite_else_131"), + I.PutValue(201, 1), + I.PutValue(202, 2), + I.PutValue(203, 3), + I.Call("package_in", 3), + I.Cut(205), + I.PutValue(201, 1), + I.PutList(2, 5), + I.SetVariable(107), + I.SetConstant(V.Atom(2)), + I.PutStructure(22, 107, 2), + I.SetValue(202), + I.SetValue(203), + I.PutValue(204, 3), + I.Call("close_moving", 3), + I.Jump("L_ite_cont_131"), + I.TrustMe(), + I.PutValue(204, 1), + I.PutConstant(V.Atom(33), 2), + I.BuiltinCall("=/2", 2), + I.BuiltinCall("!/0", 0), + I.Deallocate(), + I.Proceed(), + I.Allocate(), + I.GetStructure(45, 1, 3), I.UnifyVariable(201), I.UnifyVariable(203), I.UnifyVariable(205), - I.GetStructure(25, 2, 3), + I.GetStructure(45, 2, 3), I.UnifyVariable(202), I.UnifyVariable(204), I.UnifyVariable(206), I.GetLevel(207), - I.TryMeElse("L_ite_else_72"), + I.TryMeElse("L_ite_else_134"), I.PutValue(201, 1), I.PutValue(202, 2), I.BuiltinCall(" _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { - Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 21, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; return true; return false; })()) return true; @@ -1943,22 +3412,33 @@ function lowered_satisfies_2(program, state) { state.read_args = _t4_rargs; state.read_cursor = _t4_rcur; if ((function () { - Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 22, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_get_level(state, 201) !== true) return false; + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 209) !== true) return false; + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 211, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 212) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); - if (typeof lowered_version_lt_2 === "function") { - if (lowered_version_lt_2(program, state) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 26, 2, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(25)) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_scan_base_holds_3 === "function") { + if (lowered_scan_base_holds_3(program, state) !== true) return false; } else { const saved_cp = state.cp; const saved_pc = state.pc; - const target = program.labels["version_lt/2"]; + const target = program.labels["scan_base_holds/3"]; let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); @@ -1967,7 +3447,7 @@ function lowered_satisfies_2(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("version_lt", 2)) !== true) { + } else if (Runtime.step(program, state, I.Call("scan_base_holds", 3)) !== true) { _ok = false; } state.cp = saved_cp; @@ -1975,13 +3455,192 @@ function lowered_satisfies_2(program, state) { state.halt = false; if (!_ok) return false; } - return true; - })(); - if (_ite_cond) { - if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); + if (Runtime.op_get_level(state, 213) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 26, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + if (Runtime.op_get_level(state, 214) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 25, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 113) !== true) return false; + if (Runtime.op_unify_variable(state, 208) !== true) return false; + if (Runtime.op_put_structure(program, state, 22, 113, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 115) !== true) return false; + if (Runtime.op_unify_value(program, state, 205) !== true) return false; + if (Runtime.op_put_structure(program, state, 8, 115, 3) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_unify_value(program, state, 207) !== true) return false; + if (Runtime.op_unify_value(program, state, 208) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + if (Runtime.op_get_level(state, 215) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 22, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 114) !== true) return false; + if (Runtime.op_unify_value(program, state, 205) !== true) return false; + if (Runtime.op_put_structure(program, state, 8, 114, 3) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_unify_value(program, state, 207) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(9)) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + } + } + } + } + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 211)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_scan_base_holds_3 === "function") return lowered_scan_base_holds_3(program, state) === true; + { + const target = program.labels["scan_base_holds/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "scan_base_holds", 3) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["scan_base_holds/3"] = function (program, state) { return lowered_scan_base_holds_3(program, state); }; +// Lowered: satisfies/2 (T4 all-clauses inline) +function lowered_satisfies_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("satisfies/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_constant(program, state, 2, V.Atom(32)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_structure(program, state, 41, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_structure(program, state, 42, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_get_level(state, 201) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); + if (typeof lowered_version_lt_2 === "function") { + if (lowered_version_lt_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["version_lt/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("version_lt", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } } @@ -2001,7 +3660,7 @@ function lowered_satisfies_2(program, state) { if ((function () { if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 23, 2, 1) !== true) return false; + if (Runtime.op_get_structure(program, state, 43, 2, 1) !== true) return false; if (Runtime.op_unify_variable(state, 102) !== true) return false; Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); @@ -2029,7 +3688,7 @@ function lowered_satisfies_2(program, state) { if ((function () { if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 24, 2, 2) !== true) return false; + if (Runtime.op_get_structure(program, state, 44, 2, 2) !== true) return false; if (Runtime.op_unify_variable(state, 103) !== true) return false; if (Runtime.op_unify_variable(state, 202) !== true) return false; if (Runtime.op_get_level(state, 203) !== true) return false; @@ -2088,117 +3747,15 @@ function lowered_satisfies_2(program, state) { } lowered_dispatch["satisfies/2"] = function (program, state) { return lowered_satisfies_2(program, state); }; +// wamjs lower fallback: safe_upgrade_reason/5 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: safe_upgrade/4 fallback(naked member/2 (or callee) needs interpreter choice points) // wamjs lower fallback: roots_to_pairs/3 fallback(naked member/2 (or callee) needs interpreter choice points) // wamjs lower fallback: resolve_pending/5 fallback(naked member/2 (or callee) needs interpreter choice points) // wamjs lower fallback: resolve_layered/3 fallback(naked member/2 (or callee) needs interpreter choice points) // wamjs lower fallback: resolve/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: requested_list/2 (deterministic) +// Lowered: requested_list/2 (T4 all-clauses inline) function lowered_requested_list_2(program, state) { if (Runtime._prof) Runtime.prof_lowered_call("requested_list/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 106, 2) !== true) return false; - return true; - return true; -} - -lowered_dispatch["requested_list/2"] = function (program, state) { return lowered_requested_list_2(program, state); }; -// Lowered: request_to_req/2 (if-then-else / negation / once) -function lowered_request_to_req_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("request_to_req/2"); - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 8, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - if (Runtime.op_get_level(state, 204) !== true) return false; - { - const _ite_lite = Runtime.snapshot_lite(state); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - if (Runtime.op_put_structure(program, state, 8, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 201) !== true) return false; - if (Runtime.op_unify_value(program, state, 203) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; - } else { - Runtime.restore_lite(state, _ite_lite); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - Runtime.put_reg(state, 2, V.Atom(20)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["request_to_req/2"] = function (program, state) { return lowered_request_to_req_2(program, state); }; -// wamjs lower fallback: removal_orphans/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: pick/7 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: packages/2 (deterministic) -function lowered_packages_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("packages/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 101, 2) !== true) return false; - return true; - return true; -} - -lowered_dispatch["packages/2"] = function (program, state) { return lowered_packages_2(program, state); }; -// wamjs lower fallback: package_in/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: no_acc_conflicts/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: needed_names/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: names_of/2 (T4 nil/cons dispatch; no snapshot on bound A1) -function lowered_names_of_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("names_of/2"); - const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); - if (Runtime.term_is_nil(program, _a1)) { - if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; - return true; - return true; - } - if (Runtime.term_is_cons(program, _a1)) { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_get_structure(program, state, 7, 101, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_names_of_2 === "function") return lowered_names_of_2(program, state) === true; - { - const target = program.labels["names_of/2"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "names_of", 2) === true; - } - return true; - } const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -2210,8 +3767,14 @@ function lowered_names_of_2(program, state) { const _t4_rargs = state.read_args; const _t4_rcur = state.read_cursor; if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; - if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 106, 2) !== true) return false; return true; return false; })()) return true; @@ -2226,84 +3789,152 @@ function lowered_names_of_2(program, state) { state.read_args = _t4_rargs; state.read_cursor = _t4_rcur; if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_get_structure(program, state, 7, 101, 2) !== true) return false; if (Runtime.op_unify_variable(state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 103) !== true) return false; if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 105) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_names_of_2 === "function") return lowered_names_of_2(program, state) === true; - { - const target = program.labels["names_of/2"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "names_of", 2) === true; - } + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 106, 2) !== true) return false; + return true; return false; })()) return true; return false; } -lowered_dispatch["names_of/2"] = function (program, state) { return lowered_names_of_2(program, state); }; -// wamjs lower fallback: member_selected/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: matching_versions/4 (T4 nil/cons dispatch; no snapshot on bound A1) -function lowered_matching_versions_4(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("matching_versions/4"); - const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); - if (Runtime.term_is_nil(program, _a1)) { - Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); - if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; - return true; - return true; - } - if (Runtime.term_is_cons(program, _a1)) { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 108) !== true) return false; - if (Runtime.op_get_structure(program, state, 14, 108, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 204) !== true) return false; - Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 203, Runtime.get_reg(state, 4)); - if (Runtime.op_get_level(state, 208) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); - if (typeof lowered_satisfies_2 === "function") { - if (lowered_satisfies_2(program, state) !== true) return false; - } else { - const saved_cp = state.cp; - const saved_pc = state.pc; - const target = program.labels["satisfies/2"]; - let _ok = true; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("satisfies", 2)) !== true) { - _ok = false; - } - state.cp = saved_cp; +lowered_dispatch["requested_list/2"] = function (program, state) { return lowered_requested_list_2(program, state); }; +// Lowered: request_to_req/3 (if-then-else / negation / once) +function lowered_request_to_req_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("request_to_req/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); + if (Runtime.op_get_structure(program, state, 15, 3, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (Runtime.op_put_structure(program, state, 15, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_value(program, state, 205) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + if (typeof lowered_canonicalize_name_3 === "function") { + if (lowered_canonicalize_name_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["canonicalize_name/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("canonicalize_name", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + if (typeof lowered_canonicalize_name_3 === "function") { + if (lowered_canonicalize_name_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["canonicalize_name/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("canonicalize_name", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, V.Atom(32)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["request_to_req/3"] = function (program, state) { return lowered_request_to_req_3(program, state); }; +// Lowered: reqs_ok_moving/2 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_reqs_ok_moving_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("reqs_ok_moving/2"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 15, 106, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_selected_ver_3 === "function") { + if (lowered_selected_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["selected_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("selected_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; state.pc = saved_pc; state.halt = false; if (!_ok) return false; @@ -2311,31 +3942,46 @@ function lowered_matching_versions_4(program, state) { return true; })(); if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 207) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + if (typeof lowered_satisfies_2 === "function") { + if (lowered_satisfies_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["satisfies/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("satisfies", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } } else { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } } Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_matching_versions_4 === "function") return lowered_matching_versions_4(program, state) === true; + if (typeof lowered_reqs_ok_moving_2 === "function") return lowered_reqs_ok_moving_2(program, state) === true; { - const target = program.labels["matching_versions/4"]; + const target = program.labels["reqs_ok_moving/2"]; if (target !== undefined && target !== null) { return Runtime.execute_user_isolated(program, state, target) === true; } - return Runtime.op_builtin(program, state, "matching_versions", 4) === true; + return Runtime.op_builtin(program, state, "reqs_ok_moving", 2) === true; } return true; } @@ -2352,8 +3998,6 @@ function lowered_matching_versions_4(program, state) { if ((function () { if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); - if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; return true; return false; })()) return true; @@ -2370,24 +4014,47 @@ function lowered_matching_versions_4(program, state) { if ((function () { if (Runtime.op_allocate(state) !== true) return false; if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 108) !== true) return false; - if (Runtime.op_get_structure(program, state, 14, 108, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 15, 106, 2) !== true) return false; if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; if (Runtime.op_unify_variable(state, 204) !== true) return false; Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 203, Runtime.get_reg(state, 4)); - if (Runtime.op_get_level(state, 208) !== true) return false; + if (Runtime.op_get_level(state, 206) !== true) return false; { const _ite_snap = Runtime.snapshot_machine(state); const _ite_cps = state.cps.length; const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_selected_ver_3 === "function") { + if (lowered_selected_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["selected_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("selected_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); if (typeof lowered_satisfies_2 === "function") { if (lowered_satisfies_2(program, state) !== true) return false; } else { @@ -2410,110 +4077,87 @@ function lowered_matching_versions_4(program, state) { state.halt = false; if (!_ok) return false; } - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 207) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } } Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_matching_versions_4 === "function") return lowered_matching_versions_4(program, state) === true; + if (typeof lowered_reqs_ok_moving_2 === "function") return lowered_reqs_ok_moving_2(program, state) === true; { - const target = program.labels["matching_versions/4"]; + const target = program.labels["reqs_ok_moving/2"]; if (target !== undefined && target !== null) { return Runtime.execute_user_isolated(program, state, target) === true; } - return Runtime.op_builtin(program, state, "matching_versions", 4) === true; + return Runtime.op_builtin(program, state, "reqs_ok_moving", 2) === true; } return false; })()) return true; return false; } -lowered_dispatch["matching_versions/4"] = function (program, state) { return lowered_matching_versions_4(program, state); }; -// Lowered: matching_deps/4 (T4 nil/cons dispatch; no snapshot on bound A1) -function lowered_matching_deps_4(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("matching_deps/4"); - const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); - if (Runtime.term_is_nil(program, _a1)) { - Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); - if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; - return true; - return true; - } - if (Runtime.term_is_cons(program, _a1)) { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 110) !== true) return false; - if (Runtime.op_get_structure(program, state, 13, 110, 4) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - if (Runtime.op_unify_variable(state, 204) !== true) return false; - if (Runtime.op_unify_variable(state, 206) !== true) return false; - Runtime.put_reg(state, 207, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 205, Runtime.get_reg(state, 4)); - if (Runtime.op_get_level(state, 210) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 208)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 112) !== true) return false; - if (Runtime.op_unify_variable(state, 209) !== true) return false; - if (Runtime.op_put_structure(program, state, 8, 112, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 203) !== true) return false; - if (Runtime.op_unify_value(program, state, 204) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } +lowered_dispatch["reqs_ok_moving/2"] = function (program, state) { return lowered_reqs_ok_moving_2(program, state); }; +// Lowered: repairs_moving/4 (deterministic) +function lowered_repairs_moving_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("repairs_moving/4"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 103, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 104, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 105, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 104)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 105)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_collect_deps_4 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_collect_deps_4); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["collect_deps/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("collect_deps", 4)) !== true) { + _ok = false; } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 208)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 209)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; - { - const target = program.labels["matching_deps/4"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "matching_deps", 4) === true; + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_reqs_ok_moving_2 === "function") return lowered_reqs_ok_moving_2(program, state) === true; + { + const target = program.labels["reqs_ok_moving/2"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; } - return true; + return Runtime.op_builtin(program, state, "reqs_ok_moving", 2) === true; } + return true; +} + +lowered_dispatch["repairs_moving/4"] = function (program, state) { return lowered_repairs_moving_4(program, state); }; +// wamjs lower fallback: removal_orphans/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: pick_repair/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: pick/7 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: packages/2 (T4 all-clauses inline) +function lowered_packages_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("packages/2"); const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -2525,10 +4169,14 @@ function lowered_matching_deps_4(program, state) { const _t4_rargs = state.read_args; const _t4_rcur = state.read_cursor; if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; - Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); - if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 101, 2) !== true) return false; return true; return false; })()) return true; @@ -2543,70 +4191,30 @@ function lowered_matching_deps_4(program, state) { state.read_args = _t4_rargs; state.read_cursor = _t4_rcur; if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 110) !== true) return false; - if (Runtime.op_get_structure(program, state, 13, 110, 4) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - if (Runtime.op_unify_variable(state, 204) !== true) return false; - if (Runtime.op_unify_variable(state, 206) !== true) return false; - Runtime.put_reg(state, 207, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 205, Runtime.get_reg(state, 4)); - if (Runtime.op_get_level(state, 210) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 208)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 112) !== true) return false; - if (Runtime.op_unify_variable(state, 209) !== true) return false; - if (Runtime.op_put_structure(program, state, 8, 112, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 203) !== true) return false; - if (Runtime.op_unify_value(program, state, 204) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 208)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 209)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; - { - const target = program.labels["matching_deps/4"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "matching_deps", 4) === true; - } + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 101, 2) !== true) return false; + return true; return false; })()) return true; return false; } -lowered_dispatch["matching_deps/4"] = function (program, state) { return lowered_matching_deps_4(program, state); }; -// Lowered: map_requests/2 (T4 nil/cons dispatch; no snapshot on bound A1) -function lowered_map_requests_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("map_requests/2"); +lowered_dispatch["packages/2"] = function (program, state) { return lowered_packages_2(program, state); }; +// wamjs lower fallback: package_in/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: no_acc_conflicts/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: needed_names/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: names_of/2 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_names_of_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("names_of/2"); const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); if (Runtime.term_is_nil(program, _a1)) { if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; @@ -2616,45 +4224,24 @@ function lowered_map_requests_2(program, state) { if (Runtime.term_is_cons(program, _a1)) { if (Runtime.op_allocate(state) !== true) return false; if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_get_structure(program, state, 22, 101, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 104)); - if (typeof lowered_request_to_req_2 === "function") { - if (lowered_request_to_req_2(program, state) !== true) return false; - } else { - const saved_cp = state.cp; - const saved_pc = state.pc; - const target = program.labels["request_to_req/2"]; - let _ok = true; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("request_to_req", 2)) !== true) { - _ok = false; - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_map_requests_2 === "function") return lowered_map_requests_2(program, state) === true; + if (typeof lowered_names_of_2 === "function") return lowered_names_of_2(program, state) === true; { - const target = program.labels["map_requests/2"]; + const target = program.labels["names_of/2"]; if (target !== undefined && target !== null) { return Runtime.execute_user_isolated(program, state, target) === true; } - return Runtime.op_builtin(program, state, "map_requests", 2) === true; + return Runtime.op_builtin(program, state, "names_of", 2) === true; } return true; } @@ -2687,126 +4274,2144 @@ function lowered_map_requests_2(program, state) { if ((function () { if (Runtime.op_allocate(state) !== true) return false; if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_get_structure(program, state, 22, 101, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 104)); - if (typeof lowered_request_to_req_2 === "function") { - if (lowered_request_to_req_2(program, state) !== true) return false; - } else { - const saved_cp = state.cp; - const saved_pc = state.pc; - const target = program.labels["request_to_req/2"]; - let _ok = true; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("request_to_req", 2)) !== true) { - _ok = false; - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_map_requests_2 === "function") return lowered_map_requests_2(program, state) === true; + if (typeof lowered_names_of_2 === "function") return lowered_names_of_2(program, state) === true; { - const target = program.labels["map_requests/2"]; + const target = program.labels["names_of/2"]; if (target !== undefined && target !== null) { return Runtime.execute_user_isolated(program, state, target) === true; } - return Runtime.op_builtin(program, state, "map_requests", 2) === true; + return Runtime.op_builtin(program, state, "names_of", 2) === true; } return false; })()) return true; return false; } -lowered_dispatch["map_requests/2"] = function (program, state) { return lowered_map_requests_2(program, state); }; -// wamjs lower fallback: layered_walk_ver/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: layer_closure/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: installed_ver/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: installed_list/2 (deterministic) -function lowered_installed_list_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("installed_list/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 105, 2) !== true) return false; - return true; - return true; -} - -lowered_dispatch["installed_list/2"] = function (program, state) { return lowered_installed_list_2(program, state); }; -// wamjs lower fallback: inst_walk/6 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: inst_closure_names/5 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: explain_blocked_list/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: explain_blocked/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: exclude_name/3 (T4 all-clauses inline) -function lowered_exclude_name_3(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("exclude_name/3"); - const _t4_trail = state.trail.length; - const _t4_regs = Runtime.copy_table(state.regs); - const _t4_vc = state.var_counter; - const _t4_stack = state.stack.slice(); - const _t4_ysave = (state.y_save || []).slice(); - const _t4_mode = state.mode; - const _t4_build = state.build_stack.slice(); - const _t4_rstack = (state.read_stack || []).slice(); - const _t4_rargs = state.read_args; - const _t4_rcur = state.read_cursor; - if ((function () { - Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); - if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; - if (Runtime.op_get_constant(program, state, 3, V.Atom(2)) !== true) return false; +lowered_dispatch["names_of/2"] = function (program, state) { return lowered_names_of_2(program, state); }; +// wamjs lower fallback: member_selected/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: matching_versions/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_matching_versions_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("matching_versions/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { + return true; + } + if (Runtime.term_is_cons(program, _a1)) { if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_get_structure(program, state, 27, 108, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; if (Runtime.op_unify_variable(state, 202) !== true) return false; - Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); - if (Runtime.op_builtin(program, state, "!/0", 0) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_exclude_name_3 === "function") return lowered_exclude_name_3(program, state) === true; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 208) !== true) return false; { - const target = program.labels["exclude_name/3"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "exclude_name", 3) === true; - } - return false; + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + if (typeof lowered_satisfies_2 === "function") { + if (lowered_satisfies_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["satisfies/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("satisfies", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_matching_versions_4 === "function") return lowered_matching_versions_4(program, state) === true; + { + const target = program.labels["matching_versions/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "matching_versions", 4) === true; + } + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_get_structure(program, state, 27, 108, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 208) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + if (typeof lowered_satisfies_2 === "function") { + if (lowered_satisfies_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["satisfies/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("satisfies", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_matching_versions_4 === "function") return lowered_matching_versions_4(program, state) === true; + { + const target = program.labels["matching_versions/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "matching_versions", 4) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["matching_versions/4"] = function (program, state) { return lowered_matching_versions_4(program, state); }; +// Lowered: matching_deps/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_matching_deps_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("matching_deps/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_get_structure(program, state, 24, 110, 4) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + Runtime.put_reg(state, 207, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 210) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 208)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 112) !== true) return false; + if (Runtime.op_unify_variable(state, 209) !== true) return false; + if (Runtime.op_put_structure(program, state, 15, 112, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 209)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; + { + const target = program.labels["matching_deps/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "matching_deps", 4) === true; + } + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_get_structure(program, state, 24, 110, 4) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + Runtime.put_reg(state, 207, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 210) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 208)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 112) !== true) return false; + if (Runtime.op_unify_variable(state, 209) !== true) return false; + if (Runtime.op_put_structure(program, state, 15, 112, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 209)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; + { + const target = program.labels["matching_deps/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "matching_deps", 4) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["matching_deps/4"] = function (program, state) { return lowered_matching_deps_4(program, state); }; +// Lowered: map_requests/3 (T4 all-clauses inline) +function lowered_map_requests_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("map_requests/3"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + if (Runtime.op_get_constant(program, state, 3, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_get_list(program, state, 3, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 104)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 105)); + if (typeof lowered_request_to_req_3 === "function") { + if (lowered_request_to_req_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["request_to_req/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("request_to_req", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_map_requests_3 === "function") return lowered_map_requests_3(program, state) === true; + { + const target = program.labels["map_requests/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "map_requests", 3) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["map_requests/3"] = function (program, state) { return lowered_map_requests_3(program, state); }; +// Lowered: lookup_held/3 (if-then-else / negation / once) +function lowered_lookup_held_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("lookup_held/3"); + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_item_ver_3 === "function") { + if (lowered_item_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["item_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("item_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (typeof lowered_lookup_held_3 === "function") { + if (lowered_lookup_held_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["lookup_held/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lookup_held", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["lookup_held/3"] = function (program, state) { return lowered_lookup_held_3(program, state); }; +// Lowered: layers_list/2 (T4 all-clauses inline) +function lowered_layers_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("layers_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 107, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["layers_list/2"] = function (program, state) { return lowered_layers_list_2(program, state); }; +// wamjs lower fallback: layered_walk_ver/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: layer_closure/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: keep_installed_or_base/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: item_ver/3 (T4 all-clauses inline) +function lowered_item_ver_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("item_ver/3"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_structure(program, state, 22, 1, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + Runtime.put_reg(state, 103, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 102, 3) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 103)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_structure(program, state, 25, 1, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_get_structure(program, state, 22, 101, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + Runtime.put_reg(state, 105, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 103, 3) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 102)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_structure(program, state, 26, 1, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + Runtime.put_reg(state, 103, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 104, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 102)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 103)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 104)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_lookup_held_3 === "function") return lowered_lookup_held_3(program, state) === true; + { + const target = program.labels["lookup_held/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "lookup_held", 3) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["item_ver/3"] = function (program, state) { return lowered_item_ver_3(program, state); }; +// wamjs lower fallback: installed_ver/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: installed_or_base/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: installed_list/2 (T4 all-clauses inline) +function lowered_installed_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("installed_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 105, 2) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 105, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["installed_list/2"] = function (program, state) { return lowered_installed_list_2(program, state); }; +// wamjs lower fallback: inst_walk/6 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: inst_closure_names/5 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: hold_reason/3 (if-then-else / negation / once) +function lowered_hold_reason_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("hold_reason/3"); + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 8, 106, 3) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (typeof lowered_hold_reason_3 === "function") { + if (lowered_hold_reason_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["hold_reason/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("hold_reason", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["hold_reason/3"] = function (program, state) { return lowered_hold_reason_3(program, state); }; +// wamjs lower fallback: freeze_audit/2 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: first_broken/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_first_broken_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("first_broken/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(19)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_structure(program, state, 8, 109, 3) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_variable(state, 208) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 207, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 209) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_selected_ver_3 === "function") { + if (lowered_selected_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["selected_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("selected_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (typeof lowered_first_broken_4 === "function") { + if (lowered_first_broken_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_broken/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_broken", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_get_level(state, 210) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 206, v); Runtime.put_reg(state, 5, v); } + if (typeof lowered_dep_breaks_moving_5 === "function") { + if (lowered_dep_breaks_moving_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["dep_breaks_moving/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("dep_breaks_moving", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 21, 2, 3) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (typeof lowered_first_broken_4 === "function") { + if (lowered_first_broken_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_broken/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_broken", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Atom(19)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_structure(program, state, 8, 109, 3) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_variable(state, 208) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 207, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 209) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_selected_ver_3 === "function") { + if (lowered_selected_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["selected_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("selected_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (typeof lowered_first_broken_4 === "function") { + if (lowered_first_broken_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_broken/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_broken", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_get_level(state, 210) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 206, v); Runtime.put_reg(state, 5, v); } + if (typeof lowered_dep_breaks_moving_5 === "function") { + if (lowered_dep_breaks_moving_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["dep_breaks_moving/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("dep_breaks_moving", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 21, 2, 3) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (typeof lowered_first_broken_4 === "function") { + if (lowered_first_broken_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_broken/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_broken", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["first_broken/4"] = function (program, state) { return lowered_first_broken_4(program, state); }; +// wamjs lower fallback: explain_blocked_list/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: explain_blocked/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: excluded_name/2 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: excluded_list/2 (T4 all-clauses inline) +function lowered_excluded_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("excluded_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 108, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["excluded_list/2"] = function (program, state) { return lowered_excluded_list_2(program, state); }; +// Lowered: exclude_name/3 (T4 all-clauses inline) +function lowered_exclude_name_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("exclude_name/3"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + if (Runtime.op_get_constant(program, state, 3, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + if (Runtime.op_builtin(program, state, "!/0", 0) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_exclude_name_3 === "function") return lowered_exclude_name_3(program, state) === true; + { + const target = program.labels["exclude_name/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "exclude_name", 3) === true; + } + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_get_list(program, state, 3, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 103)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 104)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_exclude_name_3 === "function") return lowered_exclude_name_3(program, state) === true; + { + const target = program.labels["exclude_name/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "exclude_name", 3) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["exclude_name/3"] = function (program, state) { return lowered_exclude_name_3(program, state); }; +// Lowered: direct_on/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_direct_on_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("direct_on/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_value(program, state, 102, 4) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_structure(program, state, 24, 109, 4) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 209) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 112) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_put_structure(program, state, 22, 112, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 208)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_direct_on_4 === "function") return lowered_direct_on_4(program, state) === true; + { + const target = program.labels["direct_on/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "direct_on", 4) === true; + } + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_value(program, state, 102, 4) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_structure(program, state, 24, 109, 4) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 209) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 112) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_put_structure(program, state, 22, 112, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 208)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_direct_on_4 === "function") return lowered_direct_on_4(program, state) === true; + { + const target = program.labels["direct_on/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "direct_on", 4) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["direct_on/4"] = function (program, state) { return lowered_direct_on_4(program, state); }; +// Lowered: depends_list/2 (T4 all-clauses inline) +function lowered_depends_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("depends_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 102, 2) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 102, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["depends_list/2"] = function (program, state) { return lowered_depends_list_2(program, state); }; +// wamjs lower fallback: depends_in/5 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: dependents_installed/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: dependents/3 (deterministic) +function lowered_dependents_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("dependents/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 106, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 106)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_canonicalize_name_3 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_canonicalize_name_3); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["canonicalize_name/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("canonicalize_name", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_depends_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_depends_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["depends_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("depends_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, V.Atom(2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_direct_on_4 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_direct_on_4); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["direct_on/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("direct_on", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "sort/2", 2) !== true) return false; + if (Runtime.op_builtin(program, state, "!/0", 0) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["dependents/3"] = function (program, state) { return lowered_dependents_3(program, state); }; +// Lowered: dep_breaks_moving/5 (deterministic) +function lowered_dep_breaks_moving_5(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("dep_breaks_moving/5"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 106, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 5)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 106)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_depends_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_depends_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["depends_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("depends_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_dep_breaks_5 === "function") return lowered_dep_breaks_5(program, state) === true; + { + const target = program.labels["dep_breaks/5"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "dep_breaks", 5) === true; + } + return true; +} + +lowered_dispatch["dep_breaks_moving/5"] = function (program, state) { return lowered_dep_breaks_moving_5(program, state); }; +// Lowered: dep_breaks/5 (if-then-else / negation / once) +function lowered_dep_breaks_5(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("dep_breaks/5"); + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 111) !== true) return false; + if (Runtime.op_get_structure(program, state, 24, 111, 4) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + Runtime.put_reg(state, 207, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 209, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 210, Runtime.get_reg(state, 5)); + if (Runtime.op_get_level(state, 211) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 208)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_selected_ver_3 === "function") { + if (lowered_selected_ver_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["selected_ver/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("selected_ver", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 212) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (typeof lowered_satisfies_2 === "function") { + if (lowered_satisfies_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["satisfies/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("satisfies", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + } + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 210)); + if (typeof lowered_dep_breaks_5 === "function") { + if (lowered_dep_breaks_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["dep_breaks/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("dep_breaks", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["dep_breaks/5"] = function (program, state) { return lowered_dep_breaks_5(program, state); }; +// Lowered: conflicts_list/2 (T4 all-clauses inline) +function lowered_conflicts_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("conflicts_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 103, 2) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 103, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["conflicts_list/2"] = function (program, state) { return lowered_conflicts_list_2(program, state); }; +// wamjs lower fallback: conflicts_in/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: collect_deps/4 (deterministic) +function lowered_collect_deps_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("collect_deps/4"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 105, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 105)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_depends_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_depends_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["depends_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("depends_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 204)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; + { + const target = program.labels["matching_deps/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "matching_deps", 4) === true; + } + return true; +} + +lowered_dispatch["collect_deps/4"] = function (program, state) { return lowered_collect_deps_4(program, state); }; +// wamjs lower fallback: close_moving/3 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: canonicalize_name/3 (deterministic) +function lowered_canonicalize_name_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("canonicalize_name/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 104, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_alias_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_alias_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["alias_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("alias_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_alias_lookup_3 === "function") return lowered_alias_lookup_3(program, state) === true; + { + const target = program.labels["alias_lookup/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "alias_lookup", 3) === true; + } + return true; +} + +lowered_dispatch["canonicalize_name/3"] = function (program, state) { return lowered_canonicalize_name_3(program, state); }; +// wamjs lower fallback: candidates_high_first/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: blocked_from/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: blocked_acc_list/5 fallback(naked member/2 (or callee) needs interpreter choice points) +// wamjs lower fallback: blocked_acc/5 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: base_ver/3 (deterministic) +function lowered_base_ver_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("base_ver/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_base_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_base_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["base_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("base_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_layers_list_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_layers_list_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["layers_list/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("layers_list", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 3, v); } + if (Runtime.op_builtin(program, state, "append/3", 3) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_lookup_held_3 === "function") return lowered_lookup_held_3(program, state) === true; + { + const target = program.labels["lookup_held/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "lookup_held", 3) === true; + } + return true; +} + +lowered_dispatch["base_ver/3"] = function (program, state) { return lowered_base_ver_3(program, state); }; +// Lowered: base_reason/3 (deterministic) +function lowered_base_reason_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("base_reason/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 104, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_base_holds_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_base_holds_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["base_holds/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("base_holds", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_hold_reason_3 === "function") return lowered_hold_reason_3(program, state) === true; + { + const target = program.labels["hold_reason/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "hold_reason", 3) === true; + } + return true; +} + +lowered_dispatch["base_reason/3"] = function (program, state) { return lowered_base_reason_3(program, state); }; +// Lowered: base_name/2 (deterministic) +function lowered_base_name_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("base_name/2"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 103, v); Runtime.put_reg(state, 3, v); } + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_base_ver_3 === "function") return lowered_base_ver_3(program, state) === true; + { + const target = program.labels["base_ver/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "base_ver", 3) === true; + } + return true; +} + +lowered_dispatch["base_name/2"] = function (program, state) { return lowered_base_name_2(program, state); }; +// Lowered: base_list/2 (T4 all-clauses inline) +function lowered_base_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("base_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_value(program, state, 104, 2) !== true) return false; + return true; + return false; })()) return true; while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } state.regs = Runtime.copy_table(_t4_regs); @@ -2819,85 +6424,41 @@ function lowered_exclude_name_3(program, state) { state.read_args = _t4_rargs; state.read_cursor = _t4_rcur; if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); - if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; if (Runtime.op_unify_variable(state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_get_list(program, state, 3, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 104) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 103)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 104)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_exclude_name_3 === "function") return lowered_exclude_name_3(program, state) === true; - { - const target = program.labels["exclude_name/3"]; - if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; - } - return Runtime.op_builtin(program, state, "exclude_name", 3) === true; - } + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 104, 2) !== true) return false; + return true; return false; })()) return true; return false; } -lowered_dispatch["exclude_name/3"] = function (program, state) { return lowered_exclude_name_3(program, state); }; -// Lowered: depends_list/2 (deterministic) -function lowered_depends_list_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("depends_list/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 102, 2) !== true) return false; - return true; - return true; -} - -lowered_dispatch["depends_list/2"] = function (program, state) { return lowered_depends_list_2(program, state); }; -// wamjs lower fallback: depends_in/5 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: conflicts_list/2 (deterministic) -function lowered_conflicts_list_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("conflicts_list/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 103, 2) !== true) return false; - return true; - return true; -} - -lowered_dispatch["conflicts_list/2"] = function (program, state) { return lowered_conflicts_list_2(program, state); }; -// wamjs lower fallback: conflicts_in/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: collect_deps/4 (deterministic) -function lowered_collect_deps_4(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("collect_deps/4"); +lowered_dispatch["base_list/2"] = function (program, state) { return lowered_base_list_2(program, state); }; +// Lowered: base_holds/2 (deterministic) +function lowered_base_holds_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("base_holds/2"); if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 105, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 204, Runtime.get_reg(state, 4)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 105)); + Runtime.put_reg(state, 104, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 104)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } - if (typeof lowered_depends_list_2 === "function") { + if (typeof lowered_base_list_2 === "function") { Runtime.push_y_save(state); - const _ok = Runtime.run_lowered_body(program, state, lowered_depends_list_2); + const _ok = Runtime.run_lowered_body(program, state, lowered_base_list_2); Runtime.pop_y_save(state); if (_ok !== true) return false; } else { const saved_cp = state.cp; const saved_pc = state.pc; - const target = program.labels["depends_list/2"]; + const target = program.labels["base_list/2"]; let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); @@ -2906,7 +6467,7 @@ function lowered_collect_deps_4(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("depends_list", 2)) !== true) { + } else if (Runtime.step(program, state, I.Call("base_list", 2)) !== true) { _ok = false; } state.cp = saved_cp; @@ -2915,44 +6476,254 @@ function lowered_collect_deps_4(program, state) { if (!_ok) return false; } Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 204)); - if (Runtime.op_deallocate(state) !== true) return false; - if (typeof lowered_matching_deps_4 === "function") return lowered_matching_deps_4(program, state) === true; - { - const target = program.labels["matching_deps/4"]; + Runtime.put_reg(state, 2, V.Atom(2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_scan_base_holds_3 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_scan_base_holds_3); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["scan_base_holds/3"]; + let _ok = true; if (target !== undefined && target !== null) { - return Runtime.execute_user_isolated(program, state, target) === true; + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_base_holds", 3)) !== true) { + _ok = false; } - return Runtime.op_builtin(program, state, "matching_deps", 4) === true; + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + if (Runtime.op_builtin(program, state, "sort/2", 2) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; return true; } -lowered_dispatch["collect_deps/4"] = function (program, state) { return lowered_collect_deps_4(program, state); }; -// wamjs lower fallback: candidates_high_first/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: blocked_from/4 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: blocked_acc_list/5 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: blocked_acc/5 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: base_ver/3 fallback(naked member/2 (or callee) needs interpreter choice points) -// wamjs lower fallback: base_name/2 fallback(naked member/2 (or callee) needs interpreter choice points) -// Lowered: base_list/2 (deterministic) -function lowered_base_list_2(program, state) { - if (Runtime._prof) Runtime.prof_lowered_call("base_list/2"); - if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; - if (Runtime.op_unify_variable(state, 101) !== true) return false; - if (Runtime.op_unify_variable(state, 102) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_value(program, state, 104, 2) !== true) return false; - return true; - return true; +lowered_dispatch["base_holds/2"] = function (program, state) { return lowered_base_holds_2(program, state); }; +// wamjs lower fallback: audit_holds/4 fallback(naked member/2 (or callee) needs interpreter choice points) +// Lowered: alias_lookup/3 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_alias_lookup_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("alias_lookup/3"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 7, 106, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (typeof lowered_alias_lookup_3 === "function") { + if (lowered_alias_lookup_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["alias_lookup/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("alias_lookup", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 7, 106, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (typeof lowered_alias_lookup_3 === "function") { + if (lowered_alias_lookup_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["alias_lookup/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("alias_lookup", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; } -lowered_dispatch["base_list/2"] = function (program, state) { return lowered_base_list_2(program, state); }; +lowered_dispatch["alias_lookup/3"] = function (program, state) { return lowered_alias_lookup_3(program, state); }; +// Lowered: alias_list/2 (T4 all-clauses inline) +function lowered_alias_list_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("alias_list/2"); + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 6) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_get_structure(program, state, 6, 1, 9) !== true) return false; + if (Runtime.op_unify_variable(state, 101) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_unify_variable(state, 109) !== true) return false; + if (Runtime.op_get_value(program, state, 109, 2) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["alias_list/2"] = function (program, state) { return lowered_alias_list_2(program, state); }; // wamjs lower fallback: acc_conflicts/4 fallback(naked member/2 (or callee) needs interpreter choice points) shared_program.lowered_dispatch = lowered_dispatch; @@ -2968,21 +6739,53 @@ function version_lt(a1, a2) { } M.version_lt = version_lt; +function upgrade_set_result(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 2515, [a1, a2, a3, a4]); +} +M.upgrade_set_result = upgrade_set_result; + +function upgrade_set(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 2501, [a1, a2, a3, a4]); +} +M.upgrade_set = upgrade_set; + function topo_sort_sel(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 1369, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 2468, [a1, a2, a3]); } M.topo_sort_sel = topo_sort_sel; function topo_one(a1, a2, a3, a4, a5, a6, a7) { - return Runtime.run_predicate(shared_program, 1291, [a1, a2, a3, a4, a5, a6, a7]); + return Runtime.run_predicate(shared_program, 2390, [a1, a2, a3, a4, a5, a6, a7]); } M.topo_one = topo_one; function topo_all(a1, a2, a3, a4, a5, a6, a7) { - return Runtime.run_predicate(shared_program, 1253, [a1, a2, a3, a4, a5, a6, a7]); + return Runtime.run_predicate(shared_program, 2352, [a1, a2, a3, a4, a5, a6, a7]); } M.topo_all = topo_all; +function tight_rev_in(a1, a2, a3) { + return Runtime.run_predicate(shared_program, 2319, [a1, a2, a3]); +} +M.tight_rev_in = tight_rev_in; + +function tight_constraint(a1) { + const state = Runtime.new_state(); + const args = [a1]; + for (let i = 0; i < 1; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_tight_constraint_1(shared_program, state) === true; +} +M.tight_constraint = tight_constraint; + +function tight_base_revdep(a1, a2) { + return Runtime.run_predicate(shared_program, 2303, [a1, a2]); +} +M.tight_base_revdep = tight_base_revdep; + function selected_ver(a1, a2, a3) { const state = Runtime.new_state(); const args = [a1, a2, a3]; @@ -3007,6 +6810,18 @@ function seen_name(a1, a2) { } M.seen_name = seen_name; +function scan_base_holds(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_scan_base_holds_3(shared_program, state) === true; +} +M.scan_base_holds = scan_base_holds; + function satisfies(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; @@ -3019,23 +6834,33 @@ function satisfies(a1, a2) { } M.satisfies = satisfies; +function safe_upgrade_reason(a1, a2, a3, a4, a5) { + return Runtime.run_predicate(shared_program, 2062, [a1, a2, a3, a4, a5]); +} +M.safe_upgrade_reason = safe_upgrade_reason; + +function safe_upgrade(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 2002, [a1, a2, a3, a4]); +} +M.safe_upgrade = safe_upgrade; + function roots_to_pairs(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 1111, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1959, [a1, a2, a3]); } M.roots_to_pairs = roots_to_pairs; function resolve_pending(a1, a2, a3, a4, a5) { - return Runtime.run_predicate(shared_program, 1025, [a1, a2, a3, a4, a5]); + return Runtime.run_predicate(shared_program, 1873, [a1, a2, a3, a4, a5]); } M.resolve_pending = resolve_pending; function resolve_layered(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 1006, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1853, [a1, a2, a3]); } M.resolve_layered = resolve_layered; function resolve(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 987, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1833, [a1, a2, a3]); } M.resolve = resolve; @@ -3051,7 +6876,19 @@ function requested_list(a1, a2) { } M.requested_list = requested_list; -function request_to_req(a1, a2) { +function request_to_req(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_request_to_req_3(shared_program, state) === true; +} +M.request_to_req = request_to_req; + +function reqs_ok_moving(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; for (let i = 0; i < 2; i++) { @@ -3059,17 +6896,34 @@ function request_to_req(a1, a2) { } state.cp = 0; state.program = shared_program; - return lowered_request_to_req_2(shared_program, state) === true; + return lowered_reqs_ok_moving_2(shared_program, state) === true; } -M.request_to_req = request_to_req; +M.reqs_ok_moving = reqs_ok_moving; + +function repairs_moving(a1, a2, a3, a4) { + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4]; + for (let i = 0; i < 4; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_repairs_moving_4(shared_program, state) === true; +} +M.repairs_moving = repairs_moving; function removal_orphans(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 860, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1637, [a1, a2, a3]); } M.removal_orphans = removal_orphans; +function pick_repair(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 1621, [a1, a2, a3, a4]); +} +M.pick_repair = pick_repair; + function pick(a1, a2, a3, a4, a5, a6, a7) { - return Runtime.run_predicate(shared_program, 807, [a1, a2, a3, a4, a5, a6, a7]); + return Runtime.run_predicate(shared_program, 1568, [a1, a2, a3, a4, a5, a6, a7]); } M.pick = pick; @@ -3086,17 +6940,17 @@ function packages(a1, a2) { M.packages = packages; function package_in(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 784, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1530, [a1, a2, a3]); } M.package_in = package_in; function no_acc_conflicts(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 737, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 1483, [a1, a2, a3, a4]); } M.no_acc_conflicts = no_acc_conflicts; function needed_names(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 713, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 1459, [a1, a2, a3, a4]); } M.needed_names = needed_names; @@ -3113,7 +6967,7 @@ function names_of(a1, a2) { M.names_of = names_of; function member_selected(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 684, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1430, [a1, a2, a3]); } M.member_selected = member_selected; @@ -3141,7 +6995,31 @@ function matching_deps(a1, a2, a3, a4) { } M.matching_deps = matching_deps; -function map_requests(a1, a2) { +function map_requests(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_map_requests_3(shared_program, state) === true; +} +M.map_requests = map_requests; + +function lookup_held(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_lookup_held_3(shared_program, state) === true; +} +M.lookup_held = lookup_held; + +function layers_list(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; for (let i = 0; i < 2; i++) { @@ -3149,25 +7027,47 @@ function map_requests(a1, a2) { } state.cp = 0; state.program = shared_program; - return lowered_map_requests_2(shared_program, state) === true; + return lowered_layers_list_2(shared_program, state) === true; } -M.map_requests = map_requests; +M.layers_list = layers_list; function layered_walk_ver(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 545, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 1239, [a1, a2, a3, a4]); } M.layered_walk_ver = layered_walk_ver; function layer_closure(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 528, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1222, [a1, a2, a3]); } M.layer_closure = layer_closure; +function keep_installed_or_base(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 1178, [a1, a2, a3, a4]); +} +M.keep_installed_or_base = keep_installed_or_base; + +function item_ver(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_item_ver_3(shared_program, state) === true; +} +M.item_ver = item_ver; + function installed_ver(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 514, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 1124, [a1, a2, a3]); } M.installed_ver = installed_ver; +function installed_or_base(a1, a2, a3) { + return Runtime.run_predicate(shared_program, 1100, [a1, a2, a3]); +} +M.installed_or_base = installed_or_base; + function installed_list(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; @@ -3181,25 +7081,71 @@ function installed_list(a1, a2) { M.installed_list = installed_list; function inst_walk(a1, a2, a3, a4, a5, a6) { - return Runtime.run_predicate(shared_program, 432, [a1, a2, a3, a4, a5, a6]); + return Runtime.run_predicate(shared_program, 1003, [a1, a2, a3, a4, a5, a6]); } M.inst_walk = inst_walk; function inst_closure_names(a1, a2, a3, a4, a5) { - return Runtime.run_predicate(shared_program, 413, [a1, a2, a3, a4, a5]); + return Runtime.run_predicate(shared_program, 984, [a1, a2, a3, a4, a5]); } M.inst_closure_names = inst_closure_names; +function hold_reason(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_hold_reason_3(shared_program, state) === true; +} +M.hold_reason = hold_reason; + +function freeze_audit(a1, a2) { + return Runtime.run_predicate(shared_program, 940, [a1, a2]); +} +M.freeze_audit = freeze_audit; + +function first_broken(a1, a2, a3, a4) { + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4]; + for (let i = 0; i < 4; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_first_broken_4(shared_program, state) === true; +} +M.first_broken = first_broken; + function explain_blocked_list(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 394, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 863, [a1, a2, a3]); } M.explain_blocked_list = explain_blocked_list; function explain_blocked(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 381, [a1, a2, a3]); + return Runtime.run_predicate(shared_program, 849, [a1, a2, a3]); } M.explain_blocked = explain_blocked; +function excluded_name(a1, a2) { + return Runtime.run_predicate(shared_program, 838, [a1, a2]); +} +M.excluded_name = excluded_name; + +function excluded_list(a1, a2) { + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_excluded_list_2(shared_program, state) === true; +} +M.excluded_list = excluded_list; + function exclude_name(a1, a2, a3) { const state = Runtime.new_state(); const args = [a1, a2, a3]; @@ -3212,6 +7158,18 @@ function exclude_name(a1, a2, a3) { } M.exclude_name = exclude_name; +function direct_on(a1, a2, a3, a4) { + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4]; + for (let i = 0; i < 4; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_direct_on_4(shared_program, state) === true; +} +M.direct_on = direct_on; + function depends_list(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; @@ -3225,10 +7183,51 @@ function depends_list(a1, a2) { M.depends_list = depends_list; function depends_in(a1, a2, a3, a4, a5) { - return Runtime.run_predicate(shared_program, 321, [a1, a2, a3, a4, a5]); + return Runtime.run_predicate(shared_program, 694, [a1, a2, a3, a4, a5]); } M.depends_in = depends_in; +function dependents_installed(a1, a2, a3) { + return Runtime.run_predicate(shared_program, 675, [a1, a2, a3]); +} +M.dependents_installed = dependents_installed; + +function dependents(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_dependents_3(shared_program, state) === true; +} +M.dependents = dependents; + +function dep_breaks_moving(a1, a2, a3, a4, a5) { + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4, a5]; + for (let i = 0; i < 5; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_dep_breaks_moving_5(shared_program, state) === true; +} +M.dep_breaks_moving = dep_breaks_moving; + +function dep_breaks(a1, a2, a3, a4, a5) { + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4, a5]; + for (let i = 0; i < 5; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_dep_breaks_5(shared_program, state) === true; +} +M.dep_breaks = dep_breaks; + function conflicts_list(a1, a2) { const state = Runtime.new_state(); const args = [a1, a2]; @@ -3242,7 +7241,7 @@ function conflicts_list(a1, a2) { M.conflicts_list = conflicts_list; function conflicts_in(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 296, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 548, [a1, a2, a3, a4]); } M.conflicts_in = conflicts_in; @@ -3258,33 +7257,76 @@ function collect_deps(a1, a2, a3, a4) { } M.collect_deps = collect_deps; +function close_moving(a1, a2, a3) { + return Runtime.run_predicate(shared_program, 470, [a1, a2, a3]); +} +M.close_moving = close_moving; + +function canonicalize_name(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_canonicalize_name_3(shared_program, state) === true; +} +M.canonicalize_name = canonicalize_name; + function candidates_high_first(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 258, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 424, [a1, a2, a3, a4]); } M.candidates_high_first = candidates_high_first; function blocked_from(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 174, [a1, a2, a3, a4]); + return Runtime.run_predicate(shared_program, 340, [a1, a2, a3, a4]); } M.blocked_from = blocked_from; function blocked_acc_list(a1, a2, a3, a4, a5) { - return Runtime.run_predicate(shared_program, 144, [a1, a2, a3, a4, a5]); + return Runtime.run_predicate(shared_program, 310, [a1, a2, a3, a4, a5]); } M.blocked_acc_list = blocked_acc_list; function blocked_acc(a1, a2, a3, a4, a5) { - return Runtime.run_predicate(shared_program, 56, [a1, a2, a3, a4, a5]); + return Runtime.run_predicate(shared_program, 222, [a1, a2, a3, a4, a5]); } M.blocked_acc = blocked_acc; function base_ver(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 42, [a1, a2, a3]); + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_base_ver_3(shared_program, state) === true; } M.base_ver = base_ver; +function base_reason(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_base_reason_3(shared_program, state) === true; +} +M.base_reason = base_reason; + function base_name(a1, a2) { - return Runtime.run_predicate(shared_program, 34, [a1, a2]); + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_base_name_2(shared_program, state) === true; } M.base_name = base_name; @@ -3300,6 +7342,47 @@ function base_list(a1, a2) { } M.base_list = base_list; +function base_holds(a1, a2) { + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_base_holds_2(shared_program, state) === true; +} +M.base_holds = base_holds; + +function audit_holds(a1, a2, a3, a4) { + return Runtime.run_predicate(shared_program, 82, [a1, a2, a3, a4]); +} +M.audit_holds = audit_holds; + +function alias_lookup(a1, a2, a3) { + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_alias_lookup_3(shared_program, state) === true; +} +M.alias_lookup = alias_lookup; + +function alias_list(a1, a2) { + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_alias_list_2(shared_program, state) === true; +} +M.alias_list = alias_list; + function acc_conflicts(a1, a2, a3, a4) { return Runtime.run_predicate(shared_program, 1, [a1, a2, a3, a4]); } diff --git a/examples/pkg_resolver/wamjs/resolver.mjs b/examples/pkg_resolver/wamjs/resolver.mjs index 9eb32ef95..fe568972c 100644 --- a/examples/pkg_resolver/wamjs/resolver.mjs +++ b/examples/pkg_resolver/wamjs/resolver.mjs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright (c) 2026 John William Creighton (@s243a) // -// resolver.mjs -- EDGE of the JS-WAM compiled uw-resolve P0. +// resolver.mjs -- EDGE of the JS-WAM compiled uw-resolve P0.5. // // WHAT IS IN HERE, exhaustively: conversion between JSON catalogs/requests // and WAM terms, plus driving Runtime.run / lowered_dispatch. There is NO @@ -68,6 +68,24 @@ function pairTerm(name, ver) { return V.Struct(functorId("-"), [internAtom(name), vTerm(ver)]); } +function holdTerm(row) { + if (!row) return internAtom("[]"); + if (row.length >= 3) { + return V.Struct(functorId("base"), [pairTerm(row[0], row[1]), internAtom(row[2])]); + } + return pairTerm(row[0], row[1]); +} + +function layerTerm(row) { + const name = (row && row.name) || row[0]; + const pkgs = (row && row.packages) || row[1] || []; + return V.Struct(functorId("layer"), [internAtom(name), jsListToTerm(pkgs, holdTerm)]); +} + +function aliasTerm(row) { + return V.Struct(functorId("alias"), [internAtom(row[0]), internAtom(row[1])]); +} + function pkgTerm(row) { return V.Struct(functorId("package"), [internAtom(row[0]), vTerm(row[1])]); } @@ -93,13 +111,28 @@ function requestTerm(req) { export function catalogToTerm(cat) { const c = cat || {}; - return V.Struct(functorId("catalog"), [ + const base = jsListToTerm(c.base || [], holdTerm); + const installed = jsListToTerm(c.installed || [], (p) => pairTerm(p[0], p[1])); + const requested = jsListToTerm(c.requested || [], internAtom); + const core = [ jsListToTerm(c.packages || [], pkgTerm), jsListToTerm(c.depends || [], depTerm), jsListToTerm(c.conflicts || [], confTerm), - jsListToTerm(c.base || [], (p) => pairTerm(p[0], p[1])), - jsListToTerm(c.installed || [], (p) => pairTerm(p[0], p[1])), - jsListToTerm(c.requested || [], internAtom) + base, + installed, + requested + ]; + const layers = c.layers || []; + const excluded = c.excluded || []; + const aliases = c.aliases || []; + if (layers.length === 0 && excluded.length === 0 && aliases.length === 0) { + return V.Struct(functorId("catalog"), core); + } + return V.Struct(functorId("catalog"), [ + ...core, + jsListToTerm(layers, layerTerm), + jsListToTerm(excluded, internAtom), + jsListToTerm(aliases, aliasTerm) ]); } @@ -135,12 +168,26 @@ function termToJs(state, term0) { if (n === "v" && args.length === 3) return args; if (n === "-" && args.length === 2) return [args[0], args[1]]; if (n === "blocked" && args.length === 3) { - // blocked(Name, needs(C), base_has(V)) const needs = args[1] && args[1][0] === "needs" ? args[1][1] : args[1]; const bh = args[2] && args[2][0] === "base_has" ? args[2][1] : args[2]; return { name: args[0], needs: needs, base_has: bh }; } - if (n === "needs" || n === "base_has" || n === "eq" || n === "gte" || n === "lt") { + if (n === "safe" && args.length === 1) { + const cost = Array.isArray(args[0]) && args[0][0] === "cost" ? args[0][1] : args[0]; + return { cost: cost, verdict: "safe" }; + } + if (n === "coordinated" && args.length === 1) { + return { set: args[0], verdict: "coordinated" }; + } + if (n === "unsafe" && args.length === 1) { + return { reason: args[0], verdict: "unsafe" }; + } + if (n === "audit" && args.length === 2) { + return normalizeAuditTerm(args[0], args[1]); + } + if (n === "ok" && args.length === 1) return { __ok_set: args[0] }; + if (n === "needs" || n === "base_has" || n === "eq" || n === "gte" || n === "lt" + || n === "cost" || n === "held" || n === "suggest") { return [n, args[0]]; } if (n === "range") return { op: "range", lo: args[0], hi: args[1] }; @@ -159,6 +206,34 @@ function normalizeConstraint(c) { return c; } +function normalizeAuditTerm(name, payload) { + if (payload === "over_frozen") return { kind: "over_frozen", name: name }; + if (Array.isArray(payload) && payload[0] === "suggest") { + return { kind: "suggest", name: name, reason: payload[1] }; + } + if (Array.isArray(payload) && payload[0] === "held") { + return { kind: "held", name: name, reason: payload[1] }; + } + if (payload && typeof payload === "object" && payload.kind) return payload; + return { kind: "held", name: name, reason: payload }; +} + +function normalizeVerdict(v) { + if (v === "no_candidate") return { verdict: "no_candidate" }; + if (v && typeof v === "object" && v.verdict) return v; + return v; +} + +function normalizeUpgrade(r) { + if (r === "no_candidate") return { fail: true }; + if (r && typeof r === "object" && r.__ok_set) return { ok: r.__ok_set }; + if (Array.isArray(r)) return { ok: r }; + if (r && typeof r === "object" && r.name && r.base_has !== undefined) { + return { ok: { blocked: normalizeBlocked(r) } }; + } + return r; +} + function normalizeBlocked(b) { if (b && typeof b === "object" && b.name) { // Key order matches SWI json_write_dict (alpha) so corpus stringify compares. @@ -245,6 +320,45 @@ export function removalOrphans(catalog, pkg) { return { ok: readSaved(state, saved, 3) }; } +export function safeUpgrade(catalog, pkg, ver) { + const cat = catalogToTerm(catalog); + const { ok, state, saved } = runPred("safe_upgrade/4", [cat, internAtom(pkg), vTerm(ver), undefined]); + if (!ok) return { fail: true }; + return { ok: normalizeVerdict(readSaved(state, saved, 4)) }; +} + +export function upgradeSet(catalog, pkg, ver) { + const cat = catalogToTerm(catalog); + const { ok, state, saved } = runPred("upgrade_set_result/4", [cat, internAtom(pkg), vTerm(ver), undefined]); + if (!ok) return { fail: true }; + return normalizeUpgrade(readSaved(state, saved, 4)); +} + +export function freezeAudit(catalog) { + const cat = catalogToTerm(catalog); + const { ok, state, saved } = runPred("freeze_audit/2", [cat, undefined]); + if (!ok) return { fail: true }; + return { ok: readSaved(state, saved, 2) || [] }; +} + +export function dependents(catalog, pkg) { + const cat = catalogToTerm(catalog); + const { ok, state, saved } = runPred("dependents/3", [cat, internAtom(pkg), undefined]); + if (!ok) return { fail: true }; + return { ok: readSaved(state, saved, 3) }; +} + +export function dependentsInstalled(catalog, pkg) { + const cat = catalogToTerm(catalog); + const { ok, state, saved } = runPred("dependents_installed/3", [cat, internAtom(pkg), undefined]); + if (!ok) return { fail: true }; + return { ok: readSaved(state, saved, 3) }; +} + +function pkgVerArgs(args) { + return { pkg: args[0], ver: args[1] }; +} + export function runCase(row) { const cat = row.catalog; const q = row.query; @@ -254,5 +368,16 @@ export function runCase(row) { if (q === "explain_blocked") return explainBlocked(cat, args); if (q === "layer_closure") return layerClosure(cat, args); if (q === "removal_orphans") return removalOrphans(cat, args); + if (q === "safe_upgrade") { + const a = pkgVerArgs(args); + return safeUpgrade(cat, a.pkg, a.ver); + } + if (q === "upgrade_set") { + const a = pkgVerArgs(args); + return upgradeSet(cat, a.pkg, a.ver); + } + if (q === "freeze_audit") return freezeAudit(cat); + if (q === "dependents") return dependents(cat, args); + if (q === "dependents_installed") return dependentsInstalled(cat, args); throw new Error("unknown query " + q); }