feat: map Piklib 6.1 types through constructor-created runners

Piklib 6.1 predates CMC_RunnerFactory; each class constructor creates its
own runner. The extractor records class -> runner from those call sites
(runner_map.by_class) and the tracker walks the snapshot's constructor
chain from a type's class to the nearest one creating a runner, so 6.1
variable and condition types no longer fall into pseudo-types either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Patryk Gensch
2026-10-24 18:59:58 +02:00
co-authored by Claude Opus 5.5
parent edae0929d7
commit 11f4b6fc37
4 changed files with 71 additions and 4 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
'use strict';
const MAPPING={explicit:'Jawne (klasa C++ z fabryki)',runner_factory:'CMC_RunnerFactory (typ → runner)',inferred:'Wywnioskowane z nazwy'};
const MAPPING={explicit:'Jawne (klasa C++ z fabryki)',runner_factory:'CMC_RunnerFactory (typ → runner)',class_constructor:'Runner tworzony w konstruktorze klasy',inferred:'Wywnioskowane z nazwy'};
const $ = id => document.getElementById(id);
const labels = {missing:'Brak rejestracji',registered:'Zarejestrowana',stub_candidate:'Podejrzenie stubu',partial:'Częściowa',implemented:'Zaimplementowana',unverified:'Niezweryfikowana',asm_reviewed:'Przegląd ASM',runtime_tested:'Test zachowania',stale:'Dowód wymaga aktualizacji'};
let data, selected = null;
+24
View File
@@ -182,6 +182,23 @@ BASE_SCOPE = "*"
BUILTIN_SCOPE, BUILTIN_TYPE_ID = "@", 0
def _constructor_runner(name, cpp_class, class_runner, bases, known_classes):
"""Runner owner for engines whose class constructors create their runner (Piklib 6.1):
the nearest class up this snapshot's constructor chain that creates one."""
if not class_runner:
return None
if not cpp_class:
candidates = [c for c in known_classes if owner_name(c) == name]
cpp_class = candidates[0] if len(candidates) == 1 else None
seen = set()
while cpp_class and cpp_class not in seen:
if cpp_class in class_runner:
return class_runner[cpp_class]
seen.add(cpp_class)
cpp_class = bases.get(cpp_class)
return None
def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
"""Script scope -> (method owner, provenance) for one binary.
@@ -190,6 +207,9 @@ def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
6.1, plugins, older extractions) the C++ class or its name is the best available guess."""
runner_map = snap.raw.get("runner_map") or {}
by_type_id = {e["type_id"]: e["runner"].removesuffix("_Runner") for e in runner_map.get("by_type_id", [])}
class_runner = {e["class"]: e["runner"].removesuffix("_Runner") for e in runner_map.get("by_class", [])}
bases = {e["class"]: e["base_class"] for e in snap.field_inheritance}
known_classes = set(class_runner) | set(bases) | set(bases.values())
mappings = {}
if BUILTIN_TYPE_ID in by_type_id:
mappings[BUILTIN_SCOPE] = (by_type_id[BUILTIN_TYPE_ID], "runner_factory")
@@ -198,6 +218,10 @@ def script_owners(snap: Snapshot, owners) -> dict[str, tuple[str, str]]:
if t.get("type_id") in by_type_id:
mappings[name] = (by_type_id[t["type_id"]], "runner_factory")
continue
runner_owner = _constructor_runner(name, t.get("cpp_class"), class_runner, bases, known_classes)
if runner_owner:
mappings[name] = (runner_owner, "class_constructor")
continue
owner, mapping = t.get("cpp_class"), "explicit"
# Known extractor failure: unrelated factory entries all mapped to Behaviour.
if owner == "CMC_Behaviour" and name != "BEHAVIOUR":