mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
refactor(javascript): share computed-key callable ownership
Give calls, captures, object operations, promises and effects one callable-owner tracker. Suspend a method while its computed key is evaluated in the enclosing callable; remove the capture-only downstream repair. Co-authored-by: Alex Desir <adesir089@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
|
||||
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
||||
import { semanticTopLevelEffectFollowsCapture } from "./javascriptSemanticMutationInitializers.js";
|
||||
import { createSemanticCallableIdStack } from "./javascriptSemanticCallableStack.js";
|
||||
import {
|
||||
resolveSemanticBindingState,
|
||||
type JavaScriptSemanticAnalysisState,
|
||||
@@ -882,21 +883,20 @@ export const traverseDataEffects = (
|
||||
context: DataEffectTraversalContext,
|
||||
visit: (node: t.Node, parent: t.Node | null) => void,
|
||||
): void => {
|
||||
context.callableStack.length = 0;
|
||||
const callableStack = createSemanticCallableIdStack(
|
||||
context.callableIds,
|
||||
context.callableStack,
|
||||
);
|
||||
context.ancestors.length = 0;
|
||||
traverseJavaScriptAst(program, {
|
||||
enter: (node, parent) => {
|
||||
const callableId = semanticCallableIdForNode(node);
|
||||
if (callableId !== null && context.callableIds.has(callableId))
|
||||
context.callableStack.push(callableId);
|
||||
callableStack.enter(node, parent);
|
||||
visit(node, parent);
|
||||
context.ancestors.push(node);
|
||||
},
|
||||
exit: (node) => {
|
||||
context.ancestors.pop();
|
||||
const callableId = semanticCallableIdForNode(node);
|
||||
if (callableId !== null && context.callableStack.at(-1) === callableId)
|
||||
context.callableStack.pop();
|
||||
callableStack.exit(node);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user