feat(tracker): signatures and per-type validity from method facts
Original entries carry the signature read from the method body and the per-type verdict of shared runners: a method the original skips for a type via obj.getType() is no longer attributed to it, and a trivial virtual is flagged as a no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5f3006cdf0
commit
edae0929d7
+30
-1
@@ -165,6 +165,18 @@ def owner_name(owner: str) -> str:
|
||||
return canonical(owner.removeprefix("CMC_"))
|
||||
|
||||
|
||||
def signature(dispatch_row: dict) -> str | None:
|
||||
"""`(int, string/int, …) → double` from the argument getters and result allocator the
|
||||
extractor saw in the method body; None when the body was not analysed."""
|
||||
if "params" not in dispatch_row:
|
||||
return None
|
||||
args = ["/".join(p["types"]) for p in dispatch_row["params"]]
|
||||
if dispatch_row.get("variadic"):
|
||||
args.append("…")
|
||||
returns = "/".join(dispatch_row["returns"]) or "—"
|
||||
return f"({', '.join(args)}) → {returns}"
|
||||
|
||||
|
||||
BASE_SCOPE = "*"
|
||||
# getRunner(0) is the runner behind `@IF`, `@LOOP`, ... statements, not an object type.
|
||||
BUILTIN_SCOPE, BUILTIN_TYPE_ID = "@", 0
|
||||
@@ -218,6 +230,7 @@ def build_tracker(snapshots: list[Snapshot], emulator: dict, reviews: list[dict]
|
||||
"source": None, "original": [], "reviews": [], "notes": [],
|
||||
})
|
||||
|
||||
excluded = defaultdict(set) # (type, method) -> binaries whose code skips it for that type
|
||||
seen = set()
|
||||
for snap in snapshots:
|
||||
sha = snap.binary.get("sha256")
|
||||
@@ -279,6 +292,11 @@ def build_tracker(snapshots: list[Snapshot], emulator: dict, reviews: list[dict]
|
||||
type_row(name).setdefault("inherits", []).append(BASE_SCOPE)
|
||||
return
|
||||
for m in owners[current]:
|
||||
d = dispatch.get((current, m.get("id")), {}) if m.get("id") is not None else {}
|
||||
verdict = {canonical(k): v for k, v in (d.get("per_type") or {}).items()}.get(name)
|
||||
if verdict == "excluded_by_type_check":
|
||||
excluded[(name, m["name"].upper())].add(bid)
|
||||
continue
|
||||
row = method_row(name, m["name"].upper())
|
||||
if len(name_ids[(current, m["name"].upper())]) > 1:
|
||||
note = "Oryginał rejestruje tę nazwę z różnymi ID; skuteczny wybór wymaga sprawdzenia hashtable/dispatchera."
|
||||
@@ -291,9 +309,13 @@ def build_tracker(snapshots: list[Snapshot], emulator: dict, reviews: list[dict]
|
||||
# Child declarations override names from ancestors for this binary.
|
||||
if any(o["binary_id"] == bid and o["owner"] != current for o in row["original"]):
|
||||
continue
|
||||
d = dispatch.get((current, m.get("id")), {}) if m.get("id") is not None else {}
|
||||
if verdict == "trivial_virtual":
|
||||
note = "W oryginale bez efektu dla tego typu: jego vftable zostawia wywoływane metody wirtualne puste."
|
||||
if note not in row["notes"]:
|
||||
row["notes"].append(note)
|
||||
row["original"].append({"binary_id": bid, "owner": current, "method_id": m.get("id"),
|
||||
"impl_addr": d.get("impl_addr"), "case_addr": d.get("case_addr"),
|
||||
"signature": signature(d), "per_type": verdict,
|
||||
"mapping": mapping, "inherited": inherited,
|
||||
"registration_addr": m.get("registration_addr"), "string_addr": m.get("string_addr"),
|
||||
"registration_call_addr": m.get("registration_call_addr"),
|
||||
@@ -318,6 +340,11 @@ def build_tracker(snapshots: list[Snapshot], emulator: dict, reviews: list[dict]
|
||||
if row["source"] is None and method in globals_:
|
||||
row.update(globals_[method])
|
||||
row["notes"] = row["notes"] + ["Obsługa przez globalny fallback Variable."]
|
||||
for (name, method), binaries_ in excluded.items():
|
||||
row = rows.get(name, {}).get("methods", {}).get(method)
|
||||
if row is not None:
|
||||
row["notes"].append(f"Oryginał ({len(binaries_)} binarek) pomija tę metodę dla tego typu: "
|
||||
"warunek obj.getType() we wspólnym runnerze.")
|
||||
base_verbs = {m for m, row in rows.get(BASE_SCOPE, {}).get("methods", {}).items() if row["original"]}
|
||||
for name, t in rows.items():
|
||||
for method, row in t["methods"].items():
|
||||
@@ -350,6 +377,8 @@ def build_tracker(snapshots: list[Snapshot], emulator: dict, reviews: list[dict]
|
||||
row["status"] = "partial"
|
||||
elif row["reviews"] and not current:
|
||||
row["verification"] = "stale"
|
||||
for row in t["methods"].values():
|
||||
row["signatures"] = sorted({o["signature"] for o in row["original"] if o.get("signature")})
|
||||
t["methods"] = sorted(t["methods"].values(), key=lambda m: m["name"])
|
||||
t["mapping_notes"] = sorted(set(t["mapping_notes"]))
|
||||
if "inherits" in t:
|
||||
|
||||
Reference in New Issue
Block a user