fix(apple): derive dispatch coverage from located decode facts
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import type { ObjcSwiftMetadata } from "../domain/native/objcSwiftMetadata.js";
|
||||
import type { PointerFixups } from "./AppleMachoFixups.js";
|
||||
import type { DecodeIssue } from "./AppleDispatchDecodeFacts.js";
|
||||
import type { FacetDecodeFacts } from "./AppleDispatchDecodeFacts.js";
|
||||
|
||||
const describeFixups = (fixups: PointerFixups): string => {
|
||||
if (fixups.kind === "chained")
|
||||
@@ -13,13 +15,25 @@ const describeFixups = (fixups: PointerFixups): string => {
|
||||
export const pushDispatchCoverage = (input: {
|
||||
readonly result: ObjcSwiftMetadata;
|
||||
readonly failures: readonly string[];
|
||||
readonly categoryIssues: readonly DecodeIssue[];
|
||||
readonly examined: number;
|
||||
readonly categoriesExamined: number;
|
||||
readonly truncated: boolean;
|
||||
readonly fixups: PointerFixups;
|
||||
readonly vtables: FacetDecodeFacts;
|
||||
readonly swift: FacetDecodeFacts;
|
||||
}): void => {
|
||||
const { result, failures, examined, categoriesExamined, truncated, fixups } =
|
||||
input;
|
||||
const {
|
||||
result,
|
||||
failures,
|
||||
categoryIssues,
|
||||
examined,
|
||||
categoriesExamined,
|
||||
truncated,
|
||||
fixups,
|
||||
vtables,
|
||||
swift,
|
||||
} = input;
|
||||
result.coverage.push({
|
||||
facet: "objc_class_method_ivar_metadata",
|
||||
status: failures.length > 0 || truncated ? "partial" : "complete",
|
||||
@@ -48,17 +62,22 @@ export const pushDispatchCoverage = (input: {
|
||||
(item) => item.decode.status === "decoded",
|
||||
).length,
|
||||
});
|
||||
const categoryFailures = failures.filter((failure) =>
|
||||
/^(?:Properties of|Category at)/u.test(failure),
|
||||
const categoryFailures = categoryIssues.map(
|
||||
({ code, location, message }) =>
|
||||
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`,
|
||||
);
|
||||
result.coverage.push({
|
||||
facet: "objc_properties_categories",
|
||||
status:
|
||||
truncated ||
|
||||
categoryFailures.length > 0 ||
|
||||
result.objc_categories.some(({ decode }) => decode.status !== "decoded")
|
||||
? "partial"
|
||||
: "complete",
|
||||
reason: categoryFailures.join("; ") || null,
|
||||
reason:
|
||||
[...categoryFailures, ...(truncated ? ["max_records_reached"] : [])].join(
|
||||
"; ",
|
||||
) || null,
|
||||
examined: categoriesExamined,
|
||||
decoded: result.objc_categories.filter(
|
||||
({ decode }) => decode.status === "decoded",
|
||||
@@ -66,8 +85,14 @@ export const pushDispatchCoverage = (input: {
|
||||
});
|
||||
result.coverage.push({
|
||||
facet: "pointer_fixups",
|
||||
status: fixups.failures.length > 0 ? "partial" : "complete",
|
||||
reason: [describeFixups(fixups), ...fixups.failures].join("; "),
|
||||
status: fixups.issues.length > 0 ? "partial" : "complete",
|
||||
reason: [
|
||||
describeFixups(fixups),
|
||||
...fixups.issues.map(
|
||||
({ code, location, message }) =>
|
||||
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`,
|
||||
),
|
||||
].join("; "),
|
||||
examined: 0,
|
||||
decoded: 0,
|
||||
});
|
||||
@@ -79,4 +104,63 @@ export const pushDispatchCoverage = (input: {
|
||||
examined: 0,
|
||||
decoded: 0,
|
||||
});
|
||||
result.coverage.push({
|
||||
facet: "swift_conformances_static_witness_slots",
|
||||
status:
|
||||
swift.exhaustive &&
|
||||
!truncated &&
|
||||
!result.swift_conformances.some(
|
||||
({ decode }) => decode.status !== "decoded",
|
||||
) &&
|
||||
!result.swift_dispatch_slots.some(
|
||||
({ table_kind, decode }) =>
|
||||
table_kind === "witness_table" && decode.status !== "decoded",
|
||||
)
|
||||
? "complete"
|
||||
: "partial",
|
||||
reason:
|
||||
[
|
||||
...swift.issues.map(formatIssue),
|
||||
...(truncated ? ["max_records_reached"] : []),
|
||||
...(result.swift_conformances.some(
|
||||
({ decode }) => decode.status !== "decoded",
|
||||
) ||
|
||||
result.swift_dispatch_slots.some(
|
||||
({ table_kind, decode }) =>
|
||||
table_kind === "witness_table" && decode.status !== "decoded",
|
||||
)
|
||||
? ["swift_records_unresolved"]
|
||||
: []),
|
||||
].join("; ") || null,
|
||||
examined: swift.examined,
|
||||
decoded: swift.decoded,
|
||||
});
|
||||
result.coverage.push({
|
||||
facet: "swift_class_vtable_descriptors",
|
||||
status:
|
||||
vtables.exhaustive &&
|
||||
!truncated &&
|
||||
!result.swift_dispatch_slots.some(
|
||||
({ table_kind, decode }) =>
|
||||
table_kind === "class_vtable" && decode.status !== "decoded",
|
||||
)
|
||||
? "complete"
|
||||
: "partial",
|
||||
reason:
|
||||
[
|
||||
...vtables.issues.map(formatIssue),
|
||||
...(truncated ? ["max_records_reached"] : []),
|
||||
...(result.swift_dispatch_slots.some(
|
||||
({ table_kind, decode }) =>
|
||||
table_kind === "class_vtable" && decode.status !== "decoded",
|
||||
)
|
||||
? ["vtable_implementations_unresolved"]
|
||||
: []),
|
||||
].join("; ") || null,
|
||||
examined: vtables.examined,
|
||||
decoded: vtables.decoded,
|
||||
});
|
||||
};
|
||||
|
||||
const formatIssue = ({ code, location, message }: DecodeIssue): string =>
|
||||
`${code}${location === undefined ? "" : ` at ${location}`}: ${message}`;
|
||||
|
||||
Reference in New Issue
Block a user