mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
fix(javascript): preserve uncertainty after references escape to calls (#1292)
* fix(javascript): preserve uncertainty after references escape to calls * fix(javascript): track iterator root escapes and preserve static captures * fix(javascript): scope comparison unknowns to their evidence * fix(javascript): track parameter origins at function body entry --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import * as t from "@babel/types";
|
||||
|
||||
import type { JavaScriptSemanticPropertyPath } from "./javascriptSemanticPropertyPaths.js";
|
||||
|
||||
import type {
|
||||
JavaScriptModuleOrigin,
|
||||
JavaScriptSemanticDefinition,
|
||||
@@ -15,6 +17,16 @@ interface JavaScriptSemanticInitializer {
|
||||
readonly entryBody?: t.BlockStatement;
|
||||
}
|
||||
|
||||
/** Additional references from destructuring copies and possible defaults. */
|
||||
interface JavaScriptSemanticReferenceInitializer extends JavaScriptSemanticInitializer {
|
||||
readonly copyKind?: "object-rest" | "array-rest";
|
||||
readonly copyProjectionOffset?: number;
|
||||
readonly copyExcludedKeys?: readonly string[];
|
||||
readonly copyStartIndex?: number;
|
||||
readonly fallbackSources?: readonly JavaScriptSemanticInitializer[];
|
||||
readonly requiredSources?: readonly JavaScriptSemanticInitializer[];
|
||||
}
|
||||
|
||||
/** Mutable binding state used only while constructing the immutable IR. */
|
||||
export interface JavaScriptSemanticBindingState {
|
||||
readonly bindingId: string;
|
||||
@@ -22,9 +34,14 @@ export interface JavaScriptSemanticBindingState {
|
||||
readonly name: string;
|
||||
kind: JavaScriptSemanticDefinition["kind"];
|
||||
mutable: boolean;
|
||||
readonly mutatedPaths: (readonly (string | number | null)[])[];
|
||||
readonly mutatedPaths: JavaScriptSemanticPropertyPath[];
|
||||
readonly escapedPaths: {
|
||||
readonly path: JavaScriptSemanticPropertyPath;
|
||||
readonly node: t.Node | undefined;
|
||||
}[];
|
||||
readonly definitions: JavaScriptSemanticDefinition[];
|
||||
readonly initializers: JavaScriptSemanticInitializer[];
|
||||
readonly referenceInitializers: JavaScriptSemanticReferenceInitializer[];
|
||||
readonly directOrigins: JavaScriptModuleOrigin[];
|
||||
}
|
||||
|
||||
@@ -40,6 +57,7 @@ export interface JavaScriptSemanticScopeState {
|
||||
|
||||
/** Shared state for semantic collection and evaluation. */
|
||||
export interface JavaScriptSemanticAnalysisState {
|
||||
readonly parentsByNode: WeakMap<t.Node, t.Node>;
|
||||
readonly scopes: JavaScriptSemanticScopeState[];
|
||||
readonly scopesById: Map<string, JavaScriptSemanticScopeState>;
|
||||
readonly scopeByNode: WeakMap<t.Node, JavaScriptSemanticScopeState>;
|
||||
|
||||
Reference in New Issue
Block a user