diff --git a/ams/tracker.py b/ams/tracker.py index ef74574..5e287f8 100644 --- a/ams/tracker.py +++ b/ams/tracker.py @@ -218,14 +218,14 @@ 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": owner = None + runner_owner = _constructor_runner(name, owner, class_runner, bases, known_classes) + if runner_owner: + mappings[name] = (runner_owner, "class_constructor") + continue if not owner: candidate = [o for o in owners if owner_name(o) == name] owner, mapping = (candidate[0] if len(candidate) == 1 else None), "inferred" diff --git a/tests/test_tracker.py b/tests/test_tracker.py index 2a63b46..182df56 100644 --- a/tests/test_tracker.py +++ b/tests/test_tracker.py @@ -266,14 +266,18 @@ def test_shared_runner_methods_follow_per_type_verdicts(tmp_path): def test_class_constructor_runners_map_piklib61_types(tmp_path): snap = Snapshot({"binary": {"name": "p61.dll", "sha256": SHA}, - "types": [{"script_name": "INTEGER", "cpp_class": None}, {"script_name": "CONDITION", "cpp_class": None}], + "types": [{"script_name": "INTEGER", "cpp_class": "CMC_Behaviour"}, # Pinokio's factory misparse + {"script_name": "CONDITION", "cpp_class": None}], "methods": [{"owner": "CMC_Variable", "runner": "CMC_Variable_Runner", "name": "inc", "id": None}, - {"owner": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner", "name": "check", "id": None}], + {"owner": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner", "name": "check", "id": None}, + {"owner": "CMC_Behaviour", "runner": "CMC_Behaviour_Runner", "name": "run", "id": None}], "field_inheritance": [{"class": "CMC_Integer", "base_class": "CMC_Variable"}, {"class": "CMC_Condition", "base_class": "CMC_BasicCondition"}], "runner_map": {"by_class": [{"class": "CMC_Variable", "runner": "CMC_Variable_Runner"}, + {"class": "CMC_Behaviour", "runner": "CMC_Behaviour_Runner"}, {"class": "CMC_BasicCondition", "runner": "CMC_BasicCondition_Runner"}]}}) result = build_tracker([snap], emulator(tmp_path)) assert row(result, "INTEGER", "INC")["original"][0]["mapping"] == "class_constructor" assert row(result, "CONDITION", "CHECK")["original"] + assert "RUN" not in {m["name"] for m in typ(result, "INTEGER")["methods"]} assert not {"VARIABLE", "BASICCONDITION"} & {t["name"] for t in result["types"]}