mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
* refactor(javascript): validate transferable file projections * test(javascript): consume decoded module and static facts * fix(javascript): isolate source analysis and retain bounded partial evidence * test(javascript): verify cleanup retention and repeated source paths
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { JavaScriptSemanticIr } from "./javascriptSemanticIr.js";
|
|
|
|
/** Module facts needed after file-local semantic projection has finished. */
|
|
export type JavaScriptModuleSemanticIr = Pick<
|
|
JavaScriptSemanticIr,
|
|
| "scopes"
|
|
| "bindings"
|
|
| "callables"
|
|
| "moduleLinks"
|
|
| "coverage"
|
|
| "limitations"
|
|
>;
|
|
|
|
/** Retain facts consumed by source-module and export-return composition. */
|
|
export const projectJavaScriptModuleSemantics = (
|
|
ir: JavaScriptSemanticIr,
|
|
): JavaScriptModuleSemanticIr => {
|
|
const scopes = ir.scopes.filter(({ kind }) => kind === "program");
|
|
const programScopeId = scopes[0]?.scopeId;
|
|
const localNames = new Set(ir.moduleLinks.map(({ localName }) => localName));
|
|
const callableIds = new Set(
|
|
ir.moduleLinks.map(({ callableId }) => callableId),
|
|
);
|
|
return {
|
|
scopes,
|
|
bindings: ir.bindings.filter(
|
|
({ name, scopeId }) => scopeId === programScopeId && localNames.has(name),
|
|
),
|
|
callables: ir.callables.filter(({ callableId }) =>
|
|
callableIds.has(callableId),
|
|
),
|
|
moduleLinks: ir.moduleLinks,
|
|
coverage: ir.coverage,
|
|
limitations: ir.limitations,
|
|
};
|
|
};
|