mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
9ac76d3d94
Index unshadowed direct-eval sites once at the semantic owner. Distinguish lexical rebinding, non-strict eval-introduced names, and possible mutation of reachable objects. Reuse existing effect timing and capture proofs; retain original definitions and module origins without inventing assignments or parsing or executing eval payloads. Query object uncertainty conservatively across the owning activation so aliases remain covered when names are shadowed or leave block scope. Retain no binding-by-eval table. Use the shared facts for values, read provenance, reference effects and child argument shapes. Preserve indirect/optional/shadowed eval controls, unrelated activations, immutable shapes, strict-mode bindings and prior primitive captures. Remove obsolete reference plumbing and the source-wide eval blocker. Validation: 306 focused checks across 16 files pass, including compiled CLI and stdio MCP return projections, constructor uncertainty and child-process consumers. Against the preceding SQLite commit, 9 of 23 selected checks fail and 14 controls pass. Static/docs/test discovery (1559 files) pass. Two source reviews found no remaining scoped blocker after alias and sloppy-name fixes. No analyzed JavaScript, SQLite engine, heavy test or profiler was executed. Conservative object reachability can intentionally lose exactness; large-case opaque-query CPU and memory remain unmeasured. Fixes #4875
114 lines
3.4 KiB
TypeScript
114 lines
3.4 KiB
TypeScript
import type * as t from "@babel/types";
|
|
|
|
import { collectJavaScriptSemanticAsyncEffects } from "./javascriptSemanticAsyncEffects.js";
|
|
import { collectJavaScriptSemanticCalls } from "./javascriptSemanticCalls.js";
|
|
import { collectJavaScriptSemanticChildProcesses } from "./javascriptSemanticChildProcesses.js";
|
|
import { collectJavaScriptSemanticFingerprintsSteps } from "./javascriptSemanticFingerprints.js";
|
|
import { collectJavaScriptSemanticDataEffects } from "./javascriptSemanticDataEffects.js";
|
|
import type {
|
|
JavaScriptSemanticCallable,
|
|
JavaScriptSemanticIr,
|
|
JavaScriptSemanticReference,
|
|
} from "./javascriptSemanticIr.js";
|
|
import { collectJavaScriptSemanticPromises } from "./javascriptSemanticPromises.js";
|
|
import { collectJavaScriptSemanticObjects } from "./javascriptSemanticObjects.js";
|
|
import { collectJavaScriptSemanticResources } from "./javascriptSemanticResources.js";
|
|
import type { JavaScriptSemanticAnalysisState } from "./javascriptSemanticState.js";
|
|
|
|
type DerivedSemanticAnalysis = Pick<
|
|
JavaScriptSemanticIr,
|
|
| "argumentFlows"
|
|
| "callResultFlows"
|
|
| "callReturnFlows"
|
|
| "callSites"
|
|
| "boundaryOperations"
|
|
| "childProcessInteractions"
|
|
| "childProcessSpawns"
|
|
| "closureCaptures"
|
|
| "configurationOperations"
|
|
| "eventOperations"
|
|
| "frontiers"
|
|
| "functionFingerprints"
|
|
| "objectOperations"
|
|
| "promiseOperations"
|
|
| "requestOperations"
|
|
| "resourceOperations"
|
|
| "timerOperations"
|
|
>;
|
|
|
|
/** Compose bounded semantic passes after lexical definitions are available. */
|
|
/**
|
|
* Collect derived semantics with a yield between collectors. Each collector
|
|
* completes before the next starts, so results equal the synchronous form.
|
|
*/
|
|
export function* collectJavaScriptDerivedSemanticsSteps(
|
|
program: t.Program,
|
|
state: JavaScriptSemanticAnalysisState,
|
|
callables: readonly JavaScriptSemanticCallable[],
|
|
references: readonly JavaScriptSemanticReference[],
|
|
parserPartial: boolean,
|
|
): Generator<void, DerivedSemanticAnalysis> {
|
|
const calls = collectJavaScriptSemanticCalls(program, state, callables);
|
|
yield;
|
|
const promiseOperations = collectJavaScriptSemanticPromises(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const asyncEffects = collectJavaScriptSemanticAsyncEffects(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const childProcesses = collectJavaScriptSemanticChildProcesses(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const dataEffects = collectJavaScriptSemanticDataEffects(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const resourceOperations = collectJavaScriptSemanticResources(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const objectOperations = collectJavaScriptSemanticObjects(
|
|
program,
|
|
state,
|
|
callables,
|
|
);
|
|
yield;
|
|
const functionFingerprints =
|
|
yield* collectJavaScriptSemanticFingerprintsSteps({
|
|
state,
|
|
callables,
|
|
calls,
|
|
promises: promiseOperations,
|
|
events: asyncEffects.eventOperations,
|
|
timers: asyncEffects.timerOperations,
|
|
childProcessSpawns: childProcesses.childProcessSpawns,
|
|
childProcessInteractions: childProcesses.childProcessInteractions,
|
|
requestOperations: dataEffects.requestOperations,
|
|
resourceOperations,
|
|
parserPartial,
|
|
});
|
|
return {
|
|
...calls,
|
|
promiseOperations,
|
|
...asyncEffects,
|
|
...childProcesses,
|
|
...dataEffects,
|
|
resourceOperations,
|
|
objectOperations,
|
|
functionFingerprints,
|
|
};
|
|
}
|