@kernlang/core 4.0.0 → 4.0.1-canary.224.1.1a92ac0a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assignment-operators-ts.d.ts +12 -0
- package/dist/assignment-operators-ts.js +39 -0
- package/dist/assignment-operators-ts.js.map +1 -0
- package/dist/assignment-operators.d.ts +0 -2
- package/dist/assignment-operators.js +0 -30
- package/dist/assignment-operators.js.map +1 -1
- package/dist/closure-classifier.d.ts +54 -0
- package/dist/closure-classifier.js +58 -0
- package/dist/closure-classifier.js.map +1 -0
- package/dist/closure-eligibility.d.ts +116 -0
- package/dist/closure-eligibility.js +498 -4
- package/dist/closure-eligibility.js.map +1 -1
- package/dist/closure-python-lowering.d.ts +23 -0
- package/dist/closure-python-lowering.js +44 -8
- package/dist/closure-python-lowering.js.map +1 -1
- package/dist/codegen/body-ts.js +332 -73
- package/dist/codegen/body-ts.js.map +1 -1
- package/dist/codegen/functions.d.ts +2 -1
- package/dist/codegen/functions.js +7 -3
- package/dist/codegen/functions.js.map +1 -1
- package/dist/codegen/ground-layer.js +16 -7
- package/dist/codegen/ground-layer.js.map +1 -1
- package/dist/codegen/host-namespace-ir.d.ts +7 -0
- package/dist/codegen/host-namespace-ir.js +636 -0
- package/dist/codegen/host-namespace-ir.js.map +1 -0
- package/dist/codegen/host-namespace.d.ts +3 -0
- package/dist/codegen/host-namespace.js +60 -0
- package/dist/codegen/host-namespace.js.map +1 -0
- package/dist/codegen/kern-stdlib.d.ts +30 -4
- package/dist/codegen/kern-stdlib.js +95 -1
- package/dist/codegen/kern-stdlib.js.map +1 -1
- package/dist/codegen/regex-fold-table.d.ts +2 -0
- package/dist/codegen/regex-fold-table.js +2210 -0
- package/dist/codegen/regex-fold-table.js.map +1 -0
- package/dist/codegen/regex-normalize.d.ts +446 -0
- package/dist/codegen/regex-normalize.js +1825 -0
- package/dist/codegen/regex-normalize.js.map +1 -0
- package/dist/codegen/type-system.d.ts +18 -12
- package/dist/codegen/type-system.js +85 -49
- package/dist/codegen/type-system.js.map +1 -1
- package/dist/codegen-core.js +437 -357
- package/dist/codegen-core.js.map +1 -1
- package/dist/codegen-expression.d.ts +6 -1
- package/dist/codegen-expression.js +606 -41
- package/dist/codegen-expression.js.map +1 -1
- package/dist/constructor-super.js +5 -1
- package/dist/constructor-super.js.map +1 -1
- package/dist/core-runtime/index.js +95 -6
- package/dist/core-runtime/index.js.map +1 -1
- package/dist/generated/utils/import-metadata.js +1 -1
- package/dist/generated/utils/import-metadata.js.map +1 -1
- package/dist/generated/utils/migrate-literals.d.ts +0 -1
- package/dist/generated/utils/migrate-literals.js +3 -5
- package/dist/generated/utils/migrate-literals.js.map +1 -1
- package/dist/generated/utils/python-sidecar.js +3 -3
- package/dist/generated/utils/python-sidecar.js.map +1 -1
- package/dist/generated/utils/version-detect.js +1 -1
- package/dist/generated/utils/version-detect.js.map +1 -1
- package/dist/index.d.ts +17 -12
- package/dist/index.js +74 -11
- package/dist/index.js.map +1 -1
- package/dist/ir/semantics/to-numeric-fixtures.d.ts +67 -0
- package/dist/ir/semantics/to-numeric-fixtures.js +309 -0
- package/dist/ir/semantics/to-numeric-fixtures.js.map +1 -0
- package/dist/ir/semantics/to-numeric.d.ts +108 -0
- package/dist/ir/semantics/to-numeric.js +234 -0
- package/dist/ir/semantics/to-numeric.js.map +1 -0
- package/dist/native-eligibility-ast.js +9 -4
- package/dist/native-eligibility-ast.js.map +1 -1
- package/dist/native-eligibility.d.ts +12 -3
- package/dist/native-eligibility.js +8 -6
- package/dist/native-eligibility.js.map +1 -1
- package/dist/node.d.ts +40 -0
- package/dist/node.js +44 -0
- package/dist/node.js.map +1 -0
- package/dist/parser-core.d.ts +12 -0
- package/dist/parser-core.js +2 -2
- package/dist/parser-core.js.map +1 -1
- package/dist/parser-expression.d.ts +10 -2
- package/dist/parser-expression.js +230 -40
- package/dist/parser-expression.js.map +1 -1
- package/dist/parser-validate-expressions.d.ts +2 -1
- package/dist/parser-validate-expressions.js +5 -5
- package/dist/parser-validate-expressions.js.map +1 -1
- package/dist/parser-validate-native-eligible.d.ts +9 -2
- package/dist/parser-validate-native-eligible.js +15 -7
- package/dist/parser-validate-native-eligible.js.map +1 -1
- package/dist/parser.d.ts +4 -4
- package/dist/parser.js +8 -8
- package/dist/parser.js.map +1 -1
- package/dist/semantic-substrate.js +1 -1
- package/dist/semantic-substrate.js.map +1 -1
- package/dist/semantic-validator.d.ts +2 -0
- package/dist/semantic-validator.js +70 -9
- package/dist/semantic-validator.js.map +1 -1
- package/dist/spec.d.ts +1 -1
- package/dist/spec.js +1 -1
- package/dist/spec.js.map +1 -1
- package/dist/typescript-closure-classifier.d.ts +18 -0
- package/dist/typescript-closure-classifier.js +81 -0
- package/dist/typescript-closure-classifier.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Slice 0.9 — TypeScript-AST helper split out of `assignment-operators.ts`.
|
|
2
|
+
*
|
|
3
|
+
* `supportedCompoundAssignmentOperator` maps a `ts.SyntaxKind` token to a KERN
|
|
4
|
+
* compound-assignment operator. It is the ONLY assignment-operator helper that
|
|
5
|
+
* depends on `typescript`, so it lives here (the Node/codegen side) rather than
|
|
6
|
+
* in `assignment-operators.ts`. That keeps `assignment-operators.ts` — and the
|
|
7
|
+
* `@kernlang/core` barrel that re-exports its string predicates — free of the
|
|
8
|
+
* `typescript` import (R1 barrel-isolation). Reachable only via the Node subpath
|
|
9
|
+
* (`@kernlang/core/node`) or direct module import. */
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import type { SupportedAssignOperator } from './generated/utils/assignment-operators.js';
|
|
12
|
+
export declare function supportedCompoundAssignmentOperator(kind: ts.SyntaxKind): SupportedAssignOperator | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Slice 0.9 — TypeScript-AST helper split out of `assignment-operators.ts`.
|
|
2
|
+
*
|
|
3
|
+
* `supportedCompoundAssignmentOperator` maps a `ts.SyntaxKind` token to a KERN
|
|
4
|
+
* compound-assignment operator. It is the ONLY assignment-operator helper that
|
|
5
|
+
* depends on `typescript`, so it lives here (the Node/codegen side) rather than
|
|
6
|
+
* in `assignment-operators.ts`. That keeps `assignment-operators.ts` — and the
|
|
7
|
+
* `@kernlang/core` barrel that re-exports its string predicates — free of the
|
|
8
|
+
* `typescript` import (R1 barrel-isolation). Reachable only via the Node subpath
|
|
9
|
+
* (`@kernlang/core/node`) or direct module import. */
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
export function supportedCompoundAssignmentOperator(kind) {
|
|
12
|
+
switch (kind) {
|
|
13
|
+
case ts.SyntaxKind.PlusEqualsToken:
|
|
14
|
+
return '+=';
|
|
15
|
+
case ts.SyntaxKind.MinusEqualsToken:
|
|
16
|
+
return '-=';
|
|
17
|
+
case ts.SyntaxKind.AsteriskEqualsToken:
|
|
18
|
+
return '*=';
|
|
19
|
+
case ts.SyntaxKind.SlashEqualsToken:
|
|
20
|
+
return '/=';
|
|
21
|
+
case ts.SyntaxKind.PercentEqualsToken:
|
|
22
|
+
return '%=';
|
|
23
|
+
case ts.SyntaxKind.AsteriskAsteriskEqualsToken:
|
|
24
|
+
return '**=';
|
|
25
|
+
case ts.SyntaxKind.AmpersandEqualsToken:
|
|
26
|
+
return '&=';
|
|
27
|
+
case ts.SyntaxKind.BarEqualsToken:
|
|
28
|
+
return '|=';
|
|
29
|
+
case ts.SyntaxKind.CaretEqualsToken:
|
|
30
|
+
return '^=';
|
|
31
|
+
case ts.SyntaxKind.LessThanLessThanEqualsToken:
|
|
32
|
+
return '<<=';
|
|
33
|
+
case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
|
34
|
+
return '>>=';
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=assignment-operators-ts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assignment-operators-ts.js","sourceRoot":"","sources":["../src/assignment-operators-ts.ts"],"names":[],"mappings":"AAAA;;;;;;;;uDAQuD;AAEvD,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,MAAM,UAAU,mCAAmC,CAAC,IAAmB;IACrE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe;YAChC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB;YACjC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB;YACpC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB;YACjC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,kBAAkB;YACnC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,2BAA2B;YAC5C,OAAO,KAAK,CAAC;QACf,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB;YACrC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc;YAC/B,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB;YACjC,OAAO,IAAI,CAAC;QACd,KAAK,EAAE,CAAC,UAAU,CAAC,2BAA2B;YAC5C,OAAO,KAAK,CAAC;QACf,KAAK,EAAE,CAAC,UAAU,CAAC,iCAAiC;YAClD,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
1
|
import type { PostfixMutationOperator, SupportedAssignOperator } from './generated/utils/assignment-operators.js';
|
|
3
2
|
export type { PostfixMutationOperator, SupportedAssignOperator, } from './generated/utils/assignment-operators.js';
|
|
4
3
|
export declare const SUPPORTED_ASSIGN_OPERATORS: readonly SupportedAssignOperator[];
|
|
5
4
|
export declare function isSupportedAssignOperator(op: string): op is SupportedAssignOperator;
|
|
6
5
|
export declare function isPostfixMutationOperator(op: string): op is PostfixMutationOperator;
|
|
7
|
-
export declare function supportedCompoundAssignmentOperator(kind: ts.SyntaxKind): SupportedAssignOperator | null;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Facade. Source of truth: packages/core/src/kern/utils/assignment-operators.kern.
|
|
2
|
-
import ts from 'typescript';
|
|
3
1
|
import { SUPPORTED_ASSIGN_OPERATORS as GENERATED_SUPPORTED_ASSIGN_OPERATORS, isPostfixMutationOperator as isGeneratedPostfixMutationOperator, isSupportedAssignOperator as isGeneratedSupportedAssignOperator, } from './generated/utils/assignment-operators.js';
|
|
4
2
|
export const SUPPORTED_ASSIGN_OPERATORS = GENERATED_SUPPORTED_ASSIGN_OPERATORS;
|
|
5
3
|
export function isSupportedAssignOperator(op) {
|
|
@@ -8,32 +6,4 @@ export function isSupportedAssignOperator(op) {
|
|
|
8
6
|
export function isPostfixMutationOperator(op) {
|
|
9
7
|
return isGeneratedPostfixMutationOperator(op);
|
|
10
8
|
}
|
|
11
|
-
export function supportedCompoundAssignmentOperator(kind) {
|
|
12
|
-
switch (kind) {
|
|
13
|
-
case ts.SyntaxKind.PlusEqualsToken:
|
|
14
|
-
return '+=';
|
|
15
|
-
case ts.SyntaxKind.MinusEqualsToken:
|
|
16
|
-
return '-=';
|
|
17
|
-
case ts.SyntaxKind.AsteriskEqualsToken:
|
|
18
|
-
return '*=';
|
|
19
|
-
case ts.SyntaxKind.SlashEqualsToken:
|
|
20
|
-
return '/=';
|
|
21
|
-
case ts.SyntaxKind.PercentEqualsToken:
|
|
22
|
-
return '%=';
|
|
23
|
-
case ts.SyntaxKind.AsteriskAsteriskEqualsToken:
|
|
24
|
-
return '**=';
|
|
25
|
-
case ts.SyntaxKind.AmpersandEqualsToken:
|
|
26
|
-
return '&=';
|
|
27
|
-
case ts.SyntaxKind.BarEqualsToken:
|
|
28
|
-
return '|=';
|
|
29
|
-
case ts.SyntaxKind.CaretEqualsToken:
|
|
30
|
-
return '^=';
|
|
31
|
-
case ts.SyntaxKind.LessThanLessThanEqualsToken:
|
|
32
|
-
return '<<=';
|
|
33
|
-
case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
|
34
|
-
return '>>=';
|
|
35
|
-
default:
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
9
|
//# sourceMappingURL=assignment-operators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment-operators.js","sourceRoot":"","sources":["../src/assignment-operators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assignment-operators.js","sourceRoot":"","sources":["../src/assignment-operators.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,IAAI,oCAAoC,EAClE,yBAAyB,IAAI,kCAAkC,EAC/D,yBAAyB,IAAI,kCAAkC,GAChE,MAAM,2CAA2C,CAAC;AAOnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,oCAA0E,CAAC;AAErH,MAAM,UAAU,yBAAyB,CAAC,EAAU;IAClD,OAAO,kCAAkC,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,EAAU;IAClD,OAAO,kCAAkC,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Slice 0.9 — browser-safe closure-classifier capability seam.
|
|
2
|
+
*
|
|
3
|
+
* Block-bodied arrow functions (`(x) => { … }`) need a TypeScript-AST analysis
|
|
4
|
+
* to (a) confirm the raw text parses as a single statement block and (b) decide
|
|
5
|
+
* whether the v1 closure gate accepts it. That analysis lives in
|
|
6
|
+
* `closure-eligibility.ts`, which statically imports `typescript` (~10MB).
|
|
7
|
+
*
|
|
8
|
+
* To keep the parser browser-safe, `parser-expression.ts` depends ONLY on this
|
|
9
|
+
* dependency-free capability interface — never on `closure-eligibility.ts`. The
|
|
10
|
+
* TypeScript-backed implementation is provided out-of-band by
|
|
11
|
+
* `typescript-closure-classifier.ts` (Node/codegen side) and injected through
|
|
12
|
+
* `parseExpression(input, { closureClassifier })`.
|
|
13
|
+
*
|
|
14
|
+
* When no classifier is injected, the default `unavailableClosureClassifier` is
|
|
15
|
+
* active: ordinary expressions and expression-bodied arrows parse normally, and
|
|
16
|
+
* ONLY block-bodied arrows fail closed with `closure-parser-unavailable`. */
|
|
17
|
+
/** A synchronous capability for analyzing the raw text of a block-bodied arrow
|
|
18
|
+
* body (`{ … }`, braces included). Intentionally minimal and target-agnostic:
|
|
19
|
+
* the interface is expressed in core-own types so no `ts.*` type leaks into the
|
|
20
|
+
* browser-safe surface (the parsed-block value is opaque `unknown`). */
|
|
21
|
+
export interface ClosureClassifier {
|
|
22
|
+
/** Whether this classifier can actually analyze block bodies. The default
|
|
23
|
+
* unavailable classifier reports `false`, which makes the parser fail closed
|
|
24
|
+
* on block-bodied arrows before any parse/classify call. */
|
|
25
|
+
readonly available: boolean;
|
|
26
|
+
/** Parse the raw block into an opaque AST node, or `null` if it does not
|
|
27
|
+
* parse cleanly as a single statement block. */
|
|
28
|
+
parseBlock(raw: string): unknown | null;
|
|
29
|
+
/** Return the v1 closure-gate reject reason (e.g. `closure-this`), or `null`
|
|
30
|
+
* if the block is accepted. */
|
|
31
|
+
classifyBlock(raw: string): string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Target-agnostic fail-closed reason for block-bodied arrows when no closure
|
|
34
|
+
* classifier capability is injected (R2). Must NOT name a runtime
|
|
35
|
+
* (typescript/node/browser/deno/bun) — it describes the missing CAPABILITY. */
|
|
36
|
+
export declare const CLOSURE_PARSER_UNAVAILABLE_REASON = "closure-parser-unavailable";
|
|
37
|
+
/** The full fail-closed diagnostic message thrown by the parser when a
|
|
38
|
+
* block-bodied arrow is encountered without a classifier capability. */
|
|
39
|
+
export declare const CLOSURE_PARSER_UNAVAILABLE_MESSAGE: string;
|
|
40
|
+
/** Dependency-free default. Active whenever no classifier is injected — keeps
|
|
41
|
+
* the parser spine free of `typescript`. `available: false` makes the parser
|
|
42
|
+
* fail closed on block-bodied arrows; `classifyBlock` reports the
|
|
43
|
+
* target-agnostic reason for any caller that inspects it directly. */
|
|
44
|
+
export declare const unavailableClosureClassifier: ClosureClassifier;
|
|
45
|
+
/** Analysis-only classifier: ACCEPTS every block-bodied arrow without
|
|
46
|
+
* validating it (review fix, slice 0.9 r2). For re-parse-for-shape-analysis
|
|
47
|
+
* sites — the semantic validator and the `super(...)`-detection predicate —
|
|
48
|
+
* which inspect the expression STRUCTURE around a block arrow in text the
|
|
49
|
+
* main parse pipeline has already gated. Without it, those sites' swallowing
|
|
50
|
+
* catches turned a block-bodied arrow into silently-skipped diagnostics /
|
|
51
|
+
* misclassified constructors. The lambda IR it produces is NOT
|
|
52
|
+
* emission-trusted: never inject this where the parsed result flows to a
|
|
53
|
+
* code generator — emitters keep the real (TypeScript-backed) classifier. */
|
|
54
|
+
export declare const analysisClosureClassifier: ClosureClassifier;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Slice 0.9 — browser-safe closure-classifier capability seam.
|
|
2
|
+
*
|
|
3
|
+
* Block-bodied arrow functions (`(x) => { … }`) need a TypeScript-AST analysis
|
|
4
|
+
* to (a) confirm the raw text parses as a single statement block and (b) decide
|
|
5
|
+
* whether the v1 closure gate accepts it. That analysis lives in
|
|
6
|
+
* `closure-eligibility.ts`, which statically imports `typescript` (~10MB).
|
|
7
|
+
*
|
|
8
|
+
* To keep the parser browser-safe, `parser-expression.ts` depends ONLY on this
|
|
9
|
+
* dependency-free capability interface — never on `closure-eligibility.ts`. The
|
|
10
|
+
* TypeScript-backed implementation is provided out-of-band by
|
|
11
|
+
* `typescript-closure-classifier.ts` (Node/codegen side) and injected through
|
|
12
|
+
* `parseExpression(input, { closureClassifier })`.
|
|
13
|
+
*
|
|
14
|
+
* When no classifier is injected, the default `unavailableClosureClassifier` is
|
|
15
|
+
* active: ordinary expressions and expression-bodied arrows parse normally, and
|
|
16
|
+
* ONLY block-bodied arrows fail closed with `closure-parser-unavailable`. */
|
|
17
|
+
/** Target-agnostic fail-closed reason for block-bodied arrows when no closure
|
|
18
|
+
* classifier capability is injected (R2). Must NOT name a runtime
|
|
19
|
+
* (typescript/node/browser/deno/bun) — it describes the missing CAPABILITY. */
|
|
20
|
+
export const CLOSURE_PARSER_UNAVAILABLE_REASON = 'closure-parser-unavailable';
|
|
21
|
+
/** The full fail-closed diagnostic message thrown by the parser when a
|
|
22
|
+
* block-bodied arrow is encountered without a classifier capability. */
|
|
23
|
+
export const CLOSURE_PARSER_UNAVAILABLE_MESSAGE = `${CLOSURE_PARSER_UNAVAILABLE_REASON}: block-bodied arrow functions require a closure classifier ` +
|
|
24
|
+
`capability, which is not provided in this environment. Use an expression-bodied arrow, or pass a ` +
|
|
25
|
+
`closure classifier to parseExpression.`;
|
|
26
|
+
/** Dependency-free default. Active whenever no classifier is injected — keeps
|
|
27
|
+
* the parser spine free of `typescript`. `available: false` makes the parser
|
|
28
|
+
* fail closed on block-bodied arrows; `classifyBlock` reports the
|
|
29
|
+
* target-agnostic reason for any caller that inspects it directly. */
|
|
30
|
+
export const unavailableClosureClassifier = {
|
|
31
|
+
available: false,
|
|
32
|
+
parseBlock() {
|
|
33
|
+
return null;
|
|
34
|
+
},
|
|
35
|
+
classifyBlock() {
|
|
36
|
+
return CLOSURE_PARSER_UNAVAILABLE_REASON;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/** Analysis-only classifier: ACCEPTS every block-bodied arrow without
|
|
40
|
+
* validating it (review fix, slice 0.9 r2). For re-parse-for-shape-analysis
|
|
41
|
+
* sites — the semantic validator and the `super(...)`-detection predicate —
|
|
42
|
+
* which inspect the expression STRUCTURE around a block arrow in text the
|
|
43
|
+
* main parse pipeline has already gated. Without it, those sites' swallowing
|
|
44
|
+
* catches turned a block-bodied arrow into silently-skipped diagnostics /
|
|
45
|
+
* misclassified constructors. The lambda IR it produces is NOT
|
|
46
|
+
* emission-trusted: never inject this where the parsed result flows to a
|
|
47
|
+
* code generator — emitters keep the real (TypeScript-backed) classifier. */
|
|
48
|
+
export const analysisClosureClassifier = {
|
|
49
|
+
available: true,
|
|
50
|
+
parseBlock(raw) {
|
|
51
|
+
// Opaque non-null: shape analysis never reads the parsed block itself.
|
|
52
|
+
return raw;
|
|
53
|
+
},
|
|
54
|
+
classifyBlock() {
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=closure-classifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closure-classifier.js","sourceRoot":"","sources":["../src/closure-classifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;8EAe8E;AAmB9E;;gFAEgF;AAChF,MAAM,CAAC,MAAM,iCAAiC,GAAG,4BAA4B,CAAC;AAE9E;yEACyE;AACzE,MAAM,CAAC,MAAM,kCAAkC,GAC7C,GAAG,iCAAiC,8DAA8D;IAClG,mGAAmG;IACnG,wCAAwC,CAAC;AAE3C;;;uEAGuE;AACvE,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,SAAS,EAAE,KAAK;IAChB,UAAU;QACR,OAAO,IAAI,CAAC;IACd,CAAC;IACD,aAAa;QACX,OAAO,iCAAiC,CAAC;IAC3C,CAAC;CACF,CAAC;AAEF;;;;;;;;8EAQ8E;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,SAAS,EAAE,IAAI;IACf,UAAU,CAAC,GAAW;QACpB,uEAAuE;QACvE,OAAO,GAAG,CAAC;IACb,CAAC;IACD,aAAa;QACX,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC"}
|
|
@@ -50,6 +50,122 @@ import ts from 'typescript';
|
|
|
50
50
|
* closure-python-lowering.ts (which now imports this). Route behavior is
|
|
51
51
|
* unchanged: the lowerer still validates the same way. */
|
|
52
52
|
export declare function parseClosureBlockAst(raw: string): ts.Block | null;
|
|
53
|
+
export interface LegacyParamSignature {
|
|
54
|
+
/** Simple identifier binding name, or `null` for destructuring / non-identifier
|
|
55
|
+
* patterns (which contribute no single legacy-param name — structured bindings
|
|
56
|
+
* flow through the `param` child path instead). */
|
|
57
|
+
name: string | null;
|
|
58
|
+
/** Default-value expression text (`param.initializer`), or `null` when absent. */
|
|
59
|
+
default: string | null;
|
|
60
|
+
}
|
|
61
|
+
/** BLOCKER 2 + IMPORTANT 3 — parse a legacy `params="..."` string with the REAL
|
|
62
|
+
* TypeScript parser and return one entry per parameter. Owns the
|
|
63
|
+
* `ts.createSourceFile` call (this module already statically imports
|
|
64
|
+
* `typescript`) so `host-namespace-ir.ts` need not — that keeps the core
|
|
65
|
+
* barrel's `typescript`-importer pin at 5 (browser-spine-import-graph.test.ts).
|
|
66
|
+
*
|
|
67
|
+
* Wrapping the raw list in `function _(<params>){}` and reading each
|
|
68
|
+
* `ParameterDeclaration` auto-handles every case a hand-rolled char-scanner
|
|
69
|
+
* mis-split: `==`/`===`/`<=`/`>=` inside a default, regex literals with commas,
|
|
70
|
+
* nested generics, template literals.
|
|
71
|
+
*
|
|
72
|
+
* Fails CLOSED on malformed input: if `source.parseDiagnostics` is non-empty
|
|
73
|
+
* (e.g. `params="process = ("`), returns `null` instead of producing phantom
|
|
74
|
+
* recovery-AST bindings — so a caller never treats a host root (`process`) as
|
|
75
|
+
* shadowed by a binding the user never actually wrote. A successful-but-empty
|
|
76
|
+
* parse (no params) returns `[]`. */
|
|
77
|
+
export declare function parseLegacyParamSignature(raw: string): LegacyParamSignature[] | null;
|
|
78
|
+
export interface ClosureBlockMemberAccess {
|
|
79
|
+
root: string;
|
|
80
|
+
member: string;
|
|
81
|
+
locallyShadowed: boolean;
|
|
82
|
+
}
|
|
83
|
+
export declare function collectClosureBlockLocalBindingNames(raw: string): Set<string>;
|
|
84
|
+
export declare function collectClosureBlockMemberAccesses(raw: string): ClosureBlockMemberAccess[];
|
|
85
|
+
/** Slice 2 review fix (round 3) — a regex-host violation found INSIDE a
|
|
86
|
+
* block-bodied arrow. Carries the EXACT fail-close `message` the EXPRESSION-level
|
|
87
|
+
* path would emit, so the TS-verbatim block leg agrees with that path (and with
|
|
88
|
+
* the Python leg, which lowers the body through the IR) BY CONSTRUCTION rather
|
|
89
|
+
* than re-deriving the truth table:
|
|
90
|
+
* - `bareRegexp` — a bare VALUE reference to `RegExp` (`return RegExp`,
|
|
91
|
+
* `const R = RegExp`, `{ x: RegExp }`, `({ RegExp })`, `[RegExp]`, a ternary
|
|
92
|
+
* branch, an argument). The generic member scan never sees these (no
|
|
93
|
+
* identifier-rooted `Root.member`), so they slip the verbatim TS leg. The
|
|
94
|
+
* MEMBER-OBJECT position (`RegExp.prototype`, `RegExp[$1]`) is deliberately
|
|
95
|
+
* EXCLUDED — the generic scan owns it and emits the GENERIC host-namespace
|
|
96
|
+
* message there (matching the expression-level member-receiver screen).
|
|
97
|
+
* `message` is always `REGEX_HOST_REGEXP_FAILCLOSE`. `locallyShadowed`
|
|
98
|
+
* reports a block-scope re-declaration so the caller can also honor an outer
|
|
99
|
+
* user binding.
|
|
100
|
+
* - `regexLiteralAccess` — a property/element access on a regex LITERAL
|
|
101
|
+
* (`/x/.source`, `/x/["flags"]`, `/x/.test(s)`, `/x/.exec(s)`,
|
|
102
|
+
* `/x/.compile(y)`). The receiver is a literal (never user-bindable), so it
|
|
103
|
+
* never honors a binding (`locallyShadowed` is always false). `message` is
|
|
104
|
+
* the shared classifier's verdict: `null` when the access is PORTABLE
|
|
105
|
+
* (`/x/.test(s)` — NO violation pushed) or the exact fail-close message
|
|
106
|
+
* otherwise (regex-host for reads/non-portable methods, `REGEX_EXEC_FAILCLOSE`
|
|
107
|
+
* for `.exec`, `REGEX_TEST_G_FAILCLOSE` for `/g`-literal `.test`). */
|
|
108
|
+
export interface ClosureBlockRegexHostViolation {
|
|
109
|
+
kind: 'bareRegexp' | 'regexLiteralAccess';
|
|
110
|
+
root: string;
|
|
111
|
+
locallyShadowed: boolean;
|
|
112
|
+
/** The exact fail-close message to throw (mirrors the expression-level path). */
|
|
113
|
+
message: string;
|
|
114
|
+
}
|
|
115
|
+
/** Walk a closure block's TS AST and collect the regex-host violations the
|
|
116
|
+
* generic member-access scan cannot see (bare `RegExp` VALUE references and
|
|
117
|
+
* regex-LITERAL property/element accesses). Tracks REAL JS block scope: each
|
|
118
|
+
* block predeclares its top-level let/const/function/class names BEFORE visiting
|
|
119
|
+
* its refs, so a name shadows only within its own block + nested blocks. A
|
|
120
|
+
* parse failure yields an empty list (the gate already rejected such bodies). */
|
|
121
|
+
export declare function collectClosureBlockRegexHostViolations(raw: string): ClosureBlockRegexHostViolation[];
|
|
122
|
+
/** A bare-identifier operand of a `typeof` expression found inside a closure
|
|
123
|
+
* block (`typeof Date`, `typeof process`). The host-root decision is made by the
|
|
124
|
+
* CONSUMER (`typescript-closure-classifier.ts`), so this collector stays free of
|
|
125
|
+
* host-namespace coupling — it only reports the operand `name` and whether a
|
|
126
|
+
* block-scope local shadows it. RegExp is NOT special-cased here: a bare `RegExp`
|
|
127
|
+
* in `typeof` position is already a value reference caught by
|
|
128
|
+
* `collectClosureBlockRegexHostViolations` (round-6 removed the `typeof` exemption
|
|
129
|
+
* in `isRegExpNonValuePosition`), so it fails-close there with the regex message.
|
|
130
|
+
* This collector covers the OTHER reserved host roots with the generic message. */
|
|
131
|
+
export interface ClosureBlockTypeofOperand {
|
|
132
|
+
name: string;
|
|
133
|
+
locallyShadowed: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** Walk a closure block and collect every `typeof <bare identifier>` operand,
|
|
136
|
+
* tracking REAL JS block scope identically to
|
|
137
|
+
* {@link collectClosureBlockRegexHostViolations}: each block predeclares its
|
|
138
|
+
* top-level let/const/function/class names (incl. destructuring) BEFORE visiting
|
|
139
|
+
* its refs, so a block-local shadow is honored for the whole block. Only the
|
|
140
|
+
* bare-identifier operand of a `typeof` is reported, AFTER recursively peeling
|
|
141
|
+
* the transparent TS-AST wrappers via {@link unwrapRegexReceiverTS} — so a
|
|
142
|
+
* WRAPPED operand (`typeof (Date as any)`, `typeof (Date!)`, parenthesized
|
|
143
|
+
* `typeof (Date)`, nested `typeof (Date as any as unknown)`) records the
|
|
144
|
+
* underlying `Date` name, identically to the ValueIR legs that peel
|
|
145
|
+
* `typeAssert`/`nonNull` via `unwrapTransparentReceiverIR` (round-7 closes the
|
|
146
|
+
* wrapped-operand bypass on this leg too). `typeof Date.now` (a member operand)
|
|
147
|
+
* is owned by the generic member-access scan, and any operand that does NOT
|
|
148
|
+
* unwrap to a bare identifier records nothing. A parse failure yields an empty
|
|
149
|
+
* list (the gate already rejected such bodies). */
|
|
150
|
+
export declare function collectClosureBlockTypeofOperands(raw: string): ClosureBlockTypeofOperand[];
|
|
151
|
+
/** Flatten a binding NAME (plain identifier OR an object/array destructuring
|
|
152
|
+
* pattern) to the identifier names it binds. `const { RegExp } = x` →
|
|
153
|
+
* `['RegExp']`, `const [a, , b] = arr` → `['a','b']`. Exported so the Python
|
|
154
|
+
* closure lowerer's block-scope tracker (`blockTopLevelDeclaredNames` in
|
|
155
|
+
* closure-python-lowering.ts) extracts shadow names the SAME way as the TS-AST
|
|
156
|
+
* closure walk here — a destructured `RegExp` shadow is then honored
|
|
157
|
+
* symmetrically on both legs (no fail-open on one target). */
|
|
158
|
+
export declare function bindingPatternIdentifierNames(name: ts.BindingName): string[];
|
|
159
|
+
/** Collect the raw source text of every CALL expression nested anywhere in a
|
|
160
|
+
* closure block, via the shared TS AST (`parseClosureBlockAst`) — never a
|
|
161
|
+
* string scan. Returned to consumers that re-parse each call into their own
|
|
162
|
+
* IR (the TS body emitter's bound-regex-method fail-close), so those callers
|
|
163
|
+
* need no static `typescript` import of their own. Keeping the `ts` AST walk
|
|
164
|
+
* quarantined in this Node-only module is what keeps `body-ts.js` OFF the
|
|
165
|
+
* browser-spine TS-importer pin (`browser-spine-import-graph.test.ts`). A
|
|
166
|
+
* parse failure yields an empty list (the gate already rejected such bodies,
|
|
167
|
+
* so this is defensive). */
|
|
168
|
+
export declare function collectClosureBlockCallTexts(raw: string): string[];
|
|
53
169
|
/** Collect the set of free identifier NAMES referenced in a closure block —
|
|
54
170
|
* identifiers used in the block that are NOT declared inside the block and
|
|
55
171
|
* NOT in `paramNames` (the closure's own parameters). These are exactly the
|