mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
fix(javascript): preserve builtin identity and share alias traversal
Track module writes and escapes at their owner, preserve capture and reassignment ordering, and share CommonJS/default namespace identity without erasing parent-slot changes. Carry write sites into ambient alias resolution and use parsed write targets across consumers. Deduplicate returned-reference work with cycle context; retain unchanged temporal selection identity so provenance memoization stays effective. Reviewed fixes include #2041, #2465, #2830, #2881, and #2948. Remove superseded mutation representations and the ineffective per-markValue dedup layer. Validation: 380 focused JavaScript tests passed under a 384 MiB heap cap, including the previously aborting 30-level/128-call alias regression. Six public CLI/MCP builtin tests passed. Exact pdf.js completed-workflow performance remains unmeasured.
This commit is contained in:
1 parent
0f4c484be5
commit
04672f2b91
34 files changed
+3778
-321
No files matched your search
@@ -94,6 +94,41 @@ export const semanticObjectPatternKeys = (
|
||||
return key === null ? [] : [key];
|
||||
});
|
||||
|
||||
/** Return the syntactic node whose target this construct writes. */
|
||||
export const semanticWriteSiteTarget = (node: t.Node): t.Node | null => {
|
||||
if (t.isAssignmentExpression(node)) return node.left;
|
||||
if (t.isUpdateExpression(node)) return node.argument;
|
||||
if (t.isUnaryExpression(node, { operator: "delete" })) return node.argument;
|
||||
if (t.isForOfStatement(node) || t.isForInStatement(node)) return node.left;
|
||||
return null;
|
||||
};
|
||||
|
||||
/** Whether a write site reads the previous target value before writing. */
|
||||
export const semanticWriteSiteReadsFirst = (site: t.Node): boolean =>
|
||||
(t.isAssignmentExpression(site) && site.operator !== "=") ||
|
||||
t.isUpdateExpression(site);
|
||||
|
||||
/** Find the owning write site through inert TypeScript and parenthesis wrappers. */
|
||||
export const semanticWrappedWriteSite = (
|
||||
node: t.Node,
|
||||
parent: t.Node,
|
||||
ancestors: readonly t.Node[],
|
||||
): t.Node | null => {
|
||||
const chain =
|
||||
ancestors.at(-1) === parent ? ancestors : [...ancestors, parent];
|
||||
for (let index = chain.length - 1; index >= 0; index -= 1) {
|
||||
const candidate = chain[index];
|
||||
if (candidate === undefined) return null;
|
||||
const target = semanticWriteSiteTarget(candidate);
|
||||
if (target !== null)
|
||||
return unwrapJavaScriptExpression(target).node === node
|
||||
? candidate
|
||||
: null;
|
||||
if (unwrapJavaScriptExpression(candidate).depth === 0) return null;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/** Visit binding and member leaves in direct and destructuring write targets. */
|
||||
export function* semanticWriteTargets(
|
||||
root: t.Node,
|
||||
|
||||
Reference in new issue
Block a user