Files
reverse-engineering-anything/src/native/AppleDispatchDecodeFacts.ts
T
Kaoru0822andClaude Opus 5.5 c02945bc44 feat(native): decode Swift nominal type declarations from __swift5_types (#6257)
* feat(native): decode Swift nominal type declarations from __swift5_types

Fill swift_decls from the nominal type context descriptors that survive
stripping: kind (class, struct, enum, actor), own and qualified name,
module, generic flag, anonymous-context flag, metadata accessor and
descriptor location, with evidence citing the type record. Unresolved
parent contexts keep qualified_name null and the entry partial.

One shared reader walks each context once; class vtable recovery now
consumes its descriptors instead of re-reading the records, so a type
record that cannot be read keeps both facets partial. Remove the
never-populated swift_decls fields that descriptors do not carry.

Fixes #5341

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(native): bound Swift context walks and decode vtables in record order

Address review of the nominal-type reader:

- Cache intrinsic context depth (distance to the module) so a cached
  parent cannot bypass the 32-context bound, and never cache a stop that
  depends on where the walk began. Bound qualified names to 4096
  characters so nesting cannot multiply name storage.
- Visit each descriptor as soon as its kind and name are read, so a
  class vtable spends the record budget in record order instead of after
  every later declaration.
- Report an accessor outside executable mapped code as null and keep the
  declaration partial.
- Forward a name failure to vtable coverage only when the record is a
  class or its kind is unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 00:19:15 -07:00

37 lines
897 B
TypeScript

/** Stable internal decode issues used to derive public facet coverage. */
export type DispatchFacet =
| "objc_class_method_ivar_metadata"
| "binary_relative_pointers"
| "objc_properties_categories"
| "pointer_fixups"
| "swift_conformances_static_witness_slots"
| "swift_declarations"
| "swift_class_vtable_descriptors";
export interface DecodeIssue {
readonly facet: DispatchFacet;
readonly code: string;
readonly location?: string;
readonly message: string;
}
export interface FacetDecodeFacts {
readonly facet: DispatchFacet;
readonly examined: number;
readonly decoded: number;
readonly exhaustive: boolean;
readonly issues: readonly DecodeIssue[];
}
export const issue = (
facet: DispatchFacet,
code: string,
message: string,
location?: string,
): DecodeIssue => ({
facet,
code,
message,
...(location === undefined ? {} : { location }),
});