fix(parsers): preserve format boundaries and query occurrence identity

Normalize parsed facts at their owning boundaries across PE exports and certificates, ELF section names, GPU bundles, IL2CPP generic types, dyld slice selection, source maps, environment replay, and JavaScript mapped arguments. Preserve partial facts and explicit unsupported cases; clarify the corresponding documentation.

Validation: 831 affected tests passed with one existing skip across 23 files; build, typecheck/lint, documentation, formatting, and 2133-file test discovery passed. Format controls are synthetic; real Unity, GPU, and ARM-device execution is unverified.

Fixes #6709
Fixes #6688
Fixes #6719
Fixes #6718
Fixes #6704
Fixes #6703
Fixes #6692
Fixes #6723
Fixes #6687
Fixes #6726
Fixes #6696
Fixes #6691
Fixes #6727
This commit is contained in:
morluto committed 2026-10-23 22:01:16 +08:00
1 parent 4193bc5bf8
commit 5f702dd6cc
60 files changed
+2069 -211

No files matched your search

+36
View File
@@ -526,6 +526,10 @@ function* readTypes(tables: MetadataTables): Generator<
properties: [] as MetadataOwnerRange[],
events: [] as MetadataOwnerRange[],
};
const genericContainerCount =
tables.linkFacts === undefined
? 0
: entriesIn(section("genericContainers"), GENERIC_CONTAINER_RECORD_BYTES);
for (let index = 0; index < counts.typeDefinitions; index++) {
if (index % 256 === 0) yield;
const at = typeDefinitions.offset + index * sizes.typeDefinitions;
@@ -536,6 +540,33 @@ function* readTypes(tables: MetadataTables): Generator<
12 +
typeDefinitionTypeIndices * widths.type +
widths.generic_container;
if (tables.linkFacts !== undefined) {
const genericContainerIndex = readIndex(
bytes,
at + 8 + typeDefinitionTypeIndices * widths.type,
widths.generic_container,
);
if (
genericContainerIndex < -1 ||
genericContainerIndex >= genericContainerCount
)
throw new Il2cppMetadataFormatFailure(
"index-out-of-range",
`type ${index} generic container ${genericContainerIndex} is outside the ${genericContainerCount} available rows`,
);
if (genericContainerIndex !== -1) {
const genericContainerAt =
section("genericContainers").offset +
genericContainerIndex * GENERIC_CONTAINER_RECORD_BYTES;
const argumentCount = bytes.readInt32LE(genericContainerAt + 4);
if (argumentCount < 0)
throw new Il2cppMetadataFormatFailure(
"index-out-of-range",
`type ${index} generic container ${genericContainerIndex} has negative argument count ${argumentCount}`,
);
tables.linkFacts.genericTypeArgumentCounts[index] = argumentCount;
}
}
const countsAt = starts + 32;
const type = {
name: readString(bytes.readInt32LE(at), `type ${index} name`),
@@ -730,6 +761,8 @@ export interface Il2cppMetadataLinkFacts {
readonly returnTypes: Int32Array;
readonly fieldTypes: Int32Array;
readonly parameterTypes: Int32Array;
/** Total class generic argument count per TypeDefinition, including enclosing types. */
readonly genericTypeArgumentCounts: Int32Array;
/** Demand-read names from this stable metadata snapshot, by GenericParameterIndex. */
readonly genericParameterName: (index: number) => string | undefined;
}
@@ -835,6 +868,9 @@ function* readMetadataCoreSteps(
returnTypes: new Int32Array(tables.counts.methods),
fieldTypes: new Int32Array(tables.members.counts.fields),
parameterTypes: new Int32Array(tables.members.counts.parameters),
genericTypeArgumentCounts: new Int32Array(
tables.counts.typeDefinitions,
),
genericParameterName: createGenericParameterReader(tables),
},
};