mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 19:05:45 +00: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:
1 parent
6396851958
commit
76fa5304a8
8 files changed
+245
-107
No files matched your search
@@ -5,7 +5,7 @@ import type {
|
||||
JavaScriptSemanticEventOperation,
|
||||
JavaScriptSemanticTimerOperation,
|
||||
} from "./javascriptSemanticIr.js";
|
||||
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
||||
import { createSemanticCallableIdStack } from "./javascriptSemanticCallableStack.js";
|
||||
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
|
||||
import {
|
||||
resolveSemanticBindingState,
|
||||
@@ -94,15 +94,13 @@ export const collectJavaScriptSemanticAsyncEffects = (
|
||||
const events: JavaScriptSemanticEventOperation[] = [];
|
||||
const timers: TimerCandidate[] = [];
|
||||
const callableIds = new Set(callables.map(({ callableId }) => callableId));
|
||||
const callableStack: string[] = [];
|
||||
const callableStack = createSemanticCallableIdStack(callableIds);
|
||||
const ancestors: t.Node[] = [];
|
||||
traverseJavaScriptAst(program, {
|
||||
enter: (node) => {
|
||||
const callableId = semanticCallableIdForNode(node);
|
||||
if (callableId !== null && callableIds.has(callableId))
|
||||
callableStack.push(callableId);
|
||||
enter: (node, parent) => {
|
||||
callableStack.enter(node, parent);
|
||||
if (t.isCallExpression(node) || t.isOptionalCallExpression(node)) {
|
||||
const ownerCallableId = callableStack.at(-1) ?? null;
|
||||
const ownerCallableId = callableStack.callables.at(-1) ?? null;
|
||||
collectEvent(node, ownerCallableId, state, events);
|
||||
collectTimer({
|
||||
node,
|
||||
@@ -115,10 +113,8 @@ export const collectJavaScriptSemanticAsyncEffects = (
|
||||
ancestors.push(node);
|
||||
},
|
||||
exit: (node) => {
|
||||
const callableId = semanticCallableIdForNode(node);
|
||||
ancestors.pop();
|
||||
if (callableId !== null && callableStack.at(-1) === callableId)
|
||||
callableStack.pop();
|
||||
callableStack.exit(node);
|
||||
},
|
||||
});
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user