mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
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
137 lines
4.7 KiB
TypeScript
137 lines
4.7 KiB
TypeScript
import {
|
|
allLines,
|
|
collectionPathOf,
|
|
collectionMatch,
|
|
type SuppliedSegment,
|
|
type StateListView,
|
|
} from "../../domain/analysisView/environmentStateRules.js";
|
|
import { pagesOnly } from "../../domain/analysisView/environmentStatePaging.js";
|
|
import {
|
|
selectReplayExchange,
|
|
selectsRecordedLine,
|
|
type ObservedQuery,
|
|
type ReplayArguments,
|
|
} from "./environmentReplay.js";
|
|
import type {
|
|
EnvironmentManifestTool,
|
|
EnvironmentSource,
|
|
RecordedExchange,
|
|
} from "./environmentSource.js";
|
|
import { environmentToolArguments } from "./environmentTools.js";
|
|
|
|
/** A call's path segments: template literals and supplied values, or undefined when a path argument is missing. */
|
|
export const callSegments = (
|
|
tool: EnvironmentManifestTool,
|
|
args: ReplayArguments,
|
|
): SuppliedSegment[] | undefined => {
|
|
const names = environmentToolArguments(tool).path;
|
|
const params = new Map(tool.params.map((param) => [param.index, param]));
|
|
const segments: SuppliedSegment[] = [];
|
|
const template = tool.path_template
|
|
.slice(tool.path_template.indexOf("/") + 1)
|
|
.split("/");
|
|
for (const [index, text] of template.entries()) {
|
|
const param = params.get(index);
|
|
if (param === undefined) {
|
|
if (text !== "") segments.push({ text, supplied: false });
|
|
continue;
|
|
}
|
|
const value = args[names.get(param.name) ?? param.name];
|
|
if (typeof value !== "string") return undefined;
|
|
segments.push({ text: value, supplied: true });
|
|
}
|
|
return segments;
|
|
};
|
|
|
|
/** The checked recorded line a list or document call names exactly, chosen among them as replay chooses; later or filtered recordings never qualify. */
|
|
export const checkedLine = (
|
|
source: EnvironmentSource,
|
|
tool: EnvironmentManifestTool,
|
|
checked: readonly number[],
|
|
args: ReplayArguments,
|
|
observedQuery?: ObservedQuery,
|
|
): RecordedExchange | undefined => {
|
|
const lines = new Map<number, RecordedExchange>();
|
|
for (const ordinal of checked) {
|
|
const exchange = source.exchanges.get(ordinal);
|
|
if (
|
|
exchange !== undefined &&
|
|
selectsRecordedLine(tool, exchange, args, observedQuery)
|
|
)
|
|
lines.set(ordinal, exchange);
|
|
}
|
|
return selectReplayExchange(tool, lines, args, observedQuery)?.exchange;
|
|
};
|
|
|
|
/** For a list of a whole collection, a call that supplies no query argument answers from a checked line of the collection its path arguments name that only pages it, chosen as replay chooses; a requested page answers from its recording. */
|
|
export const unfilteredLine = (
|
|
source: EnvironmentSource,
|
|
tool: EnvironmentManifestTool,
|
|
checked: readonly number[],
|
|
args: ReplayArguments,
|
|
observedQuery?: ObservedQuery,
|
|
): RecordedExchange | undefined => {
|
|
const query = environmentToolArguments(tool).query;
|
|
const segments = callSegments(tool, args);
|
|
if (
|
|
segments === undefined ||
|
|
[...query.values()].some((argument) => args[argument] !== undefined)
|
|
)
|
|
return undefined;
|
|
const lines = new Map<number, RecordedExchange>();
|
|
for (const ordinal of checked) {
|
|
const exchange = source.exchanges.get(ordinal);
|
|
if (
|
|
exchange !== undefined &&
|
|
pagesOnly(exchange.query ?? undefined) &&
|
|
collectionMatch(collectionPathOf(exchange, false), segments) !== undefined
|
|
)
|
|
lines.set(ordinal, exchange);
|
|
}
|
|
return selectReplayExchange(tool, lines, args, observedQuery)?.exchange;
|
|
};
|
|
|
|
/** A call's query arguments by parameter name. */
|
|
export const callQuery = (
|
|
tool: EnvironmentManifestTool,
|
|
args: ReplayArguments,
|
|
): Map<string, string> =>
|
|
new Map(
|
|
[...environmentToolArguments(tool).query].flatMap(
|
|
([name, argument]): [string, string][] => {
|
|
const value = args[argument];
|
|
return value === undefined ? [] : [[name, String(value)]];
|
|
},
|
|
),
|
|
);
|
|
|
|
/** For a list with a query, a call whose every query argument has a role answers on a query or whole line of the collection its path arguments name. */
|
|
export const queryLine = (
|
|
source: EnvironmentSource,
|
|
tool: EnvironmentManifestTool,
|
|
view: StateListView,
|
|
args: ReplayArguments,
|
|
observedQuery?: ObservedQuery,
|
|
): RecordedExchange | undefined => {
|
|
const query = view.query;
|
|
const segments = callSegments(tool, args);
|
|
if (
|
|
query === undefined ||
|
|
segments === undefined ||
|
|
[...callQuery(tool, args).keys()].some(
|
|
(name) => !Object.hasOwn(query.parameters, name),
|
|
)
|
|
)
|
|
return undefined;
|
|
const lines = new Map<number, RecordedExchange>();
|
|
for (const ordinal of [...query.record_ordinals, ...allLines(view)]) {
|
|
const exchange = source.exchanges.get(ordinal);
|
|
if (
|
|
exchange !== undefined &&
|
|
collectionMatch(collectionPathOf(exchange, false), segments) !== undefined
|
|
)
|
|
lines.set(ordinal, exchange);
|
|
}
|
|
return selectReplayExchange(tool, lines, args, observedQuery)?.exchange;
|
|
};
|