@rsconcept/domain 3.0.1 → 3.1.0
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/{analyzer-CzFaWR7w.d.ts → analyzer-B35QsI3L.d.ts} +2 -2
- package/dist/{ast-annotations-x4PJ_Lhc.d.ts → ast-annotations-DclU1Ser.d.ts} +2 -2
- package/dist/{calculator-uPaTV3hc.d.ts → calculator-B-1p712X.d.ts} +2 -2
- package/dist/{diagnostics-DKyMf6q-.d.ts → diagnostics-D4_B7rt2.d.ts} +3 -3
- package/dist/{error-B0EkIx4K.d.ts → error-S1JghCNN.d.ts} +30 -2
- package/dist/{index-CnuO4w8e.d.ts → index-D-w-bgei.d.ts} +4 -4
- package/dist/{index-DCO4mxiO.d.ts → index-DzvllU3P.d.ts} +4 -4
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/index.d.ts +2 -2
- package/dist/library/oss-api.d.ts +1 -1
- package/dist/library/rsengine.d.ts +3 -3
- package/dist/library/rsform-api/index.d.ts +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.d.ts +3 -3
- package/dist/library/rsmodel-api.js +16 -2
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +1 -1
- package/dist/library/structure-planner.d.ts +2 -2
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +2 -2
- package/dist/rslang/error.js +16 -1
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/evaluator.d.ts +12 -2
- package/dist/rslang/eval/evaluator.js +37 -5
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/index.d.ts +6 -6
- package/dist/rslang/index.js +2 -2
- package/dist/rslang/parser/syntax-errors/index.d.ts +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/library/rsmodel-api.test.ts +79 -0
- package/src/library/rsmodel-api.ts +30 -2
- package/src/rslang/error.test.ts +23 -0
- package/src/rslang/error.ts +42 -0
- package/src/rslang/eval/evaluator.test.ts +56 -1
- package/src/rslang/eval/evaluator.ts +50 -7
- package/src/rslang/index.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-D-D6Rq3T.js";
|
|
2
2
|
import "./index-D5RahF1K.js";
|
|
3
3
|
import { f as ExpressionType, g as TypeClass } from "./typification-hWUoWCba.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as RSErrorDescription } from "./error-S1JghCNN.js";
|
|
5
5
|
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
6
6
|
//#region src/rslang/semantic/analyzer.d.ts
|
|
7
7
|
interface AnalysisBase {
|
|
@@ -35,4 +35,4 @@ declare class RSLangAnalyzer {
|
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
export { RSLangAnalyzer as a, AnalysisOptions as i, AnalysisFast as n, AnalysisFull as r, AnalysisBase as t };
|
|
38
|
-
//# sourceMappingURL=analyzer-
|
|
38
|
+
//# sourceMappingURL=analyzer-B35QsI3L.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-D-D6Rq3T.js";
|
|
2
2
|
import "./index-D5RahF1K.js";
|
|
3
3
|
import { f as ExpressionType } from "./typification-hWUoWCba.js";
|
|
4
|
-
import {
|
|
4
|
+
import { i as RSErrorCode, o as RSErrorInfo } from "./error-S1JghCNN.js";
|
|
5
5
|
//#region src/rslang/ast-annotations.d.ts
|
|
6
6
|
/** Appends {@link ExpressionType} onto the node's `annotation.rsType`. */
|
|
7
7
|
declare function annotateType(node: AstNode, type: ExpressionType): void;
|
|
@@ -13,4 +13,4 @@ declare function annotateError(node: AstNode, code: RSErrorCode, params?: readon
|
|
|
13
13
|
declare function readErrorAnnotation(node: AstNode): RSErrorInfo | null;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { readTypeAnnotation as i, annotateType as n, readErrorAnnotation as r, annotateError as t };
|
|
16
|
-
//# sourceMappingURL=ast-annotations-
|
|
16
|
+
//# sourceMappingURL=ast-annotations-DclU1Ser.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-D-D6Rq3T.js";
|
|
2
2
|
import "./index-D5RahF1K.js";
|
|
3
3
|
import { f as ExpressionType } from "./typification-hWUoWCba.js";
|
|
4
|
-
import {
|
|
4
|
+
import { a as RSErrorDescription } from "./error-S1JghCNN.js";
|
|
5
5
|
import { l as Value } from "./value-XpJOVzMP.js";
|
|
6
6
|
//#region src/rslang/eval/calculator.d.ts
|
|
7
7
|
/** Result of calculator evaluation. */
|
|
@@ -36,4 +36,4 @@ declare class RSCalculator {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { CalculatorResult as n, RSCalculator as r, CalculatorEvaluateOptions as t };
|
|
39
|
-
//# sourceMappingURL=calculator-
|
|
39
|
+
//# sourceMappingURL=calculator-B-1p712X.d.ts.map
|
|
@@ -2,8 +2,8 @@ import { t as Graph } from "./graph-CL73WdW1.js";
|
|
|
2
2
|
import "./index-DntDUXW1.js";
|
|
3
3
|
import { f as ExpressionType, y as TypePath } from "./typification-hWUoWCba.js";
|
|
4
4
|
import { l as Value } from "./value-XpJOVzMP.js";
|
|
5
|
-
import { a as RSLangAnalyzer, t as AnalysisBase } from "./analyzer-
|
|
6
|
-
import "./index-
|
|
5
|
+
import { a as RSLangAnalyzer, t as AnalysisBase } from "./analyzer-B35QsI3L.js";
|
|
6
|
+
import "./index-D-w-bgei.js";
|
|
7
7
|
import { i as LibraryItemReference, n as CurrentVersion, r as LibraryItem, s as VersionInfo } from "./library-CYun28Xz.js";
|
|
8
8
|
//#region src/library/rsform.d.ts
|
|
9
9
|
/** Represents {@link Constituenta} type. */
|
|
@@ -314,4 +314,4 @@ declare function detectDependencyCycleDiagnostics(graph: Graph, resolveAlias: (i
|
|
|
314
314
|
declare function modelStatusCstDiagnostic(status: EvalStatus, cstType: CstType): CstDiagnostic | null;
|
|
315
315
|
//#endregion
|
|
316
316
|
export { RSFormStats as C, TypeInfo as E, RSForm as S, TermForm as T, Attribution as _, detectDependencyCycleDiagnostics as a, CstStatus as b, modelStatusCstDiagnostic as c, DEFAULT_VALUE_TEXT as d, EvalStatus as f, ArgumentValue as g, TYPE_BASIC as h, assignSchemaDiagnostics as i, BasicBinding as l, RSModelStats as m, DiagnosticKind as n, formatDependencyCycle as o, RSModel as p, RSDiagnosticCode as r, hasCstDiagnostic as s, CstDiagnostic as t, BasicsContext as u, Constituenta as v, Substitution as w, CstType as x, CstClass as y };
|
|
317
|
-
//# sourceMappingURL=diagnostics-
|
|
317
|
+
//# sourceMappingURL=diagnostics-D4_B7rt2.d.ts.map
|
|
@@ -14,13 +14,41 @@ interface RSErrorInfo {
|
|
|
14
14
|
code: RSErrorCode;
|
|
15
15
|
params?: readonly string[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* One frame of an evaluation call chain.
|
|
19
|
+
*
|
|
20
|
+
* Spans are relative to the formal definition of {@link alias}.
|
|
21
|
+
* Frames are ordered innermost-first: fault locus, then each caller outward.
|
|
22
|
+
* The root expression under evaluation is not a frame — its highlight is
|
|
23
|
+
* {@link RSErrorDescription.from}/{@link RSErrorDescription.to}; {@link RSErrorDescription.stack}
|
|
24
|
+
* is absent when the fault is in that root expression.
|
|
25
|
+
*/
|
|
26
|
+
interface EvalStackFrame {
|
|
27
|
+
/** Constituent whose formal definition contains this span. */
|
|
28
|
+
alias: string;
|
|
29
|
+
/** Half-open span `[from, to)` in that definition. */
|
|
30
|
+
from: number;
|
|
31
|
+
to: number;
|
|
32
|
+
}
|
|
17
33
|
/** Represents RSLang expression error description. */
|
|
18
34
|
interface RSErrorDescription extends RSErrorInfo {
|
|
19
35
|
from: number;
|
|
20
36
|
to: number;
|
|
37
|
+
/**
|
|
38
|
+
* Evaluation call chain when the fault is inside a called `F#`/`P#` body.
|
|
39
|
+
* Absent for parse/semantic errors and for evaluation errors in the root expression.
|
|
40
|
+
*/
|
|
41
|
+
stack?: readonly EvalStackFrame[];
|
|
21
42
|
}
|
|
22
43
|
/** Error reporter function type. */
|
|
23
44
|
type ErrorReporter = (error: RSErrorDescription) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Formats an evaluation call chain for display (`F5 → F12`).
|
|
47
|
+
*
|
|
48
|
+
* Uses callee aliases from outermost call to innermost fault container.
|
|
49
|
+
* Returns an empty string when there is no nested call to show.
|
|
50
|
+
*/
|
|
51
|
+
declare function formatEvalCallStack(stack: readonly EvalStackFrame[] | undefined): string;
|
|
24
52
|
/** Represents RSLang expression error types. */
|
|
25
53
|
declare const RSErrorCode: {
|
|
26
54
|
readonly unknownSyntax: 33792;
|
|
@@ -106,5 +134,5 @@ declare function getRSErrorPrefix(code: RSErrorCode): string;
|
|
|
106
134
|
/** Checks if error is critical. */
|
|
107
135
|
declare function isCritical(code: RSErrorCode): boolean;
|
|
108
136
|
//#endregion
|
|
109
|
-
export {
|
|
110
|
-
//# sourceMappingURL=error-
|
|
137
|
+
export { RSErrorDescription as a, getRSErrorPrefix as c, RSErrorCode as i, isCritical as l, EvalStackFrame as n, RSErrorInfo as o, RSErrorClass as r, formatEvalCallStack as s, ErrorReporter as t };
|
|
138
|
+
//# sourceMappingURL=error-S1JghCNN.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./typification-hWUoWCba.js";
|
|
2
|
-
import "./error-
|
|
3
|
-
import "./ast-annotations-
|
|
2
|
+
import "./error-S1JghCNN.js";
|
|
3
|
+
import "./ast-annotations-DclU1Ser.js";
|
|
4
4
|
import "./value-XpJOVzMP.js";
|
|
5
|
-
import "./calculator-
|
|
5
|
+
import "./calculator-B-1p712X.js";
|
|
6
6
|
import "./value-api-Dw8UkwCD.js";
|
|
7
7
|
import "./parser-DkejtiOR.js";
|
|
8
8
|
import "./token-DeXAmzwr.js";
|
|
9
9
|
import "./value-class-CNI-lqXJ.js";
|
|
10
|
-
import "./analyzer-
|
|
10
|
+
import "./analyzer-B35QsI3L.js";
|
|
11
11
|
import "./arguments-extractor-CXWRT5Ou.js";
|
|
12
12
|
import "./typification-parser-DFxj4JiQ.js";
|
|
13
13
|
import "./typification-graph-CSxDt18X.js";
|
|
@@ -4,10 +4,10 @@ import { t as AstNode } from "./ast-D-D6Rq3T.js";
|
|
|
4
4
|
import "./index-D5RahF1K.js";
|
|
5
5
|
import { f as ExpressionType, g as TypeClass, y as TypePath } from "./typification-hWUoWCba.js";
|
|
6
6
|
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
7
|
-
import { r as AnalysisFull } from "./analyzer-
|
|
8
|
-
import "./index-
|
|
7
|
+
import { r as AnalysisFull } from "./analyzer-B35QsI3L.js";
|
|
8
|
+
import "./index-D-w-bgei.js";
|
|
9
9
|
import { r as LibraryItem } from "./library-CYun28Xz.js";
|
|
10
|
-
import { C as RSFormStats, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-
|
|
10
|
+
import { C as RSFormStats, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-D4_B7rt2.js";
|
|
11
11
|
import { t as AliasMapping } from "./api-DgecYHjR.js";
|
|
12
12
|
//#region src/library/rsform-api/types.d.ts
|
|
13
13
|
/** Fields needed to restore formal dependency order. */
|
|
@@ -375,4 +375,4 @@ declare function insertItemAfter<T extends {
|
|
|
375
375
|
}>(items: T[], item: T, insertAfter: number | null | undefined): void;
|
|
376
376
|
//#endregion
|
|
377
377
|
export { removeAliasReference as $, canProduceStructure as A, filterAttributions as B, restoreConstituentOrder as C, inferTemplatedType as D, inferTemplate as E, isBasicConcept as F, MappableFields as G, remapAttributionsUnderSubstitution as H, isFunctional as I, applyMappingToConstituents as J, addAliasReference as K, isLogical as L, guessCstType as M, inferClass as N, normalizeExpression as O, isBaseSet as P, maxAliasIndex as Q, isTemplateCst as R, buildFormalDependencyGraph as S, inferStatus as T, getAnalysisFor as U, importAttributions as V, refineAnalysisForDependencyCycles as W, buildSequentialAliasMapping as X, argumentValuesToMapping as Y, generateAlias as Z, findCstByStructure as _, buildDefinitionReferenceGraph as a, DiagnosticSourceFields as at, calculateSchemaStats as b, resolveConstituentTextChange as c, SchemaIssueFields as ct, SynthesizableFields as d, SpawnPathFields as dt, validateAliasFormat as et, inlineSynthesis as f, StructureCapableFields as ft, remapSubstitutionsAfterImport as g, applyConstituentSubstitutions as h, TextResolvableFields as ht, TextChangeOptions as i, DescribableFields as it, getCstTypePrefix as j, canHaveManualTypification as k, InlineSynthesisInput as l, SearchableFields as lt, SubstitutionResult as m, TemplateSourceFields as mt, moveIdsInOrder as n, AliasTypedFields as nt, buildTermReferenceGraph as o, FormalOrderFields as ot, sortItemsForInlineSynthesis as p, TemplateParamSourceFields as pt, allocateImportAliases as q, reorderItemsByIds as r, BasicTextCheckFields as rt, resolveAllConstituentTexts as s, ModelEvalFields as st, insertItemAfter as t, validateNewAlias as tt, InlineSynthesisResult as u, SemanticRelations as ut, getStructureName as v, applyFilterCategory as w, isSchemaIssue as x, inferNewSpawnPosition as y, typeClassForCstType as z };
|
|
378
|
-
//# sourceMappingURL=index-
|
|
378
|
+
//# sourceMappingURL=index-DzvllU3P.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -5,22 +5,22 @@ import { a as TOKEN_ERROR, c as flattenAst, d as printAst, f as visitAstDFS, i a
|
|
|
5
5
|
import { t as Branded } from "./branded-ZlzIcxzu.js";
|
|
6
6
|
import { n as generateStub, t as applyHash_fnv1a } from "./hash-Y8I4c6Al.js";
|
|
7
7
|
import { A as makeTypePath, b as Typification, d as EmptySetT, f as ExpressionType, g as TypeClass, m as LogicT, t as AnyTypificationT, v as TypeID, y as TypePath } from "./typification-hWUoWCba.js";
|
|
8
|
-
import {
|
|
9
|
-
import { i as readTypeAnnotation, r as readErrorAnnotation } from "./ast-annotations-
|
|
8
|
+
import { a as RSErrorDescription, i as RSErrorCode, n as EvalStackFrame, s as formatEvalCallStack } from "./error-S1JghCNN.js";
|
|
9
|
+
import { i as readTypeAnnotation, r as readErrorAnnotation } from "./ast-annotations-DclU1Ser.js";
|
|
10
10
|
import { d as ValuePath, l as Value, o as TUPLE_ID, p as makeValuePath } from "./value-XpJOVzMP.js";
|
|
11
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "./calculator-
|
|
11
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "./calculator-B-1p712X.js";
|
|
12
12
|
import { d as printValue } from "./value-api-Dw8UkwCD.js";
|
|
13
13
|
import { t as parser } from "./parser-DkejtiOR.js";
|
|
14
14
|
import { t as TokenID } from "./token-DeXAmzwr.js";
|
|
15
15
|
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
16
|
-
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "./analyzer-
|
|
16
|
+
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "./analyzer-B35QsI3L.js";
|
|
17
17
|
import { n as ArgumentsType } from "./arguments-extractor-CXWRT5Ou.js";
|
|
18
18
|
import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "./typification-parser-DFxj4JiQ.js";
|
|
19
19
|
import { n as TypificationNodeData, t as TypificationGraph } from "./typification-graph-CSxDt18X.js";
|
|
20
20
|
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "./library-CYun28Xz.js";
|
|
21
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-
|
|
21
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "./diagnostics-D4_B7rt2.js";
|
|
22
22
|
import { FolderNode, FolderTree } from "./library/folder-tree.js";
|
|
23
23
|
import { n as OssLayout, r as Position2D } from "./oss-layout-3glgAqfn.js";
|
|
24
24
|
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./library/oss.js";
|
|
25
25
|
import { RSEngine } from "./library/rsengine.js";
|
|
26
|
-
export { AccessPolicy, type AnalysisBase, type AnalysisFast, type AnalysisFull, AnyTypificationT, type ArgumentValue, type ArgumentsType, type AstNode, type AstNodeBase, type Attribution, type BasicBinding, type BasicsContext, type Block, type Branded, type CMSyntaxNode, type CalculatorEvaluateOptions, type CalculatorResult, type Constituenta, CstClass, type CstDiagnostic, CstStatus, type CstSubstituteInfo, CstType, type CurrentVersion, DEFAULT_VALUE_TEXT, DiagnosticKind, EmptySetT, type EntityReference, EvalStatus, type ExpressionType, type FlatAST, type FlatAstNode, FolderNode, FolderTree, Grammeme, Graph, type LibraryItem, type LibraryItemReference, LibraryItemType, LocationHead, LogicT, NodeType, type Operation, type OperationInput, type OperationSchema, type OperationSchemaStats, type OperationSynthesis, OperationType, type OssItem, type OssLayout, type Position2D, RSCalculator, RSDiagnosticCode, RSEngine, RSErrorCode, type RSErrorDescription, type RSForm, type RSFormStats, RSLangAnalyzer, type RSModel, type RSModelStats, ReferenceType, type Substitution, type SubstitutionErrorDescription, SubstitutionErrorType, type SyntacticReference, TOKEN_ERROR, TUPLE_ID, type TermContext, type TermForm, TokenID, TypeClass, TypeID, type TypeInfo, type TypePath, type Typification, TypificationGraph, type TypificationNodeData, type Value, ValueClass, type ValuePath, type VersionInfo, type WordForm, applyAsciiTypeSubstitutions, applyHash_fnv1a, assignSchemaDiagnostics, buildTree, detectDependencyCycleDiagnostics, findByUid, flattenAst, formatDependencyCycle, generateStub, getNodeIndices, getNodeText, hasCstDiagnostic, makeTypePath, makeValuePath, modelStatusCstDiagnostic, parseTypeText, printAst, printTree, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser, supportedGrammemes, visitAstDFS };
|
|
26
|
+
export { AccessPolicy, type AnalysisBase, type AnalysisFast, type AnalysisFull, AnyTypificationT, type ArgumentValue, type ArgumentsType, type AstNode, type AstNodeBase, type Attribution, type BasicBinding, type BasicsContext, type Block, type Branded, type CMSyntaxNode, type CalculatorEvaluateOptions, type CalculatorResult, type Constituenta, CstClass, type CstDiagnostic, CstStatus, type CstSubstituteInfo, CstType, type CurrentVersion, DEFAULT_VALUE_TEXT, DiagnosticKind, EmptySetT, type EntityReference, type EvalStackFrame, EvalStatus, type ExpressionType, type FlatAST, type FlatAstNode, FolderNode, FolderTree, Grammeme, Graph, type LibraryItem, type LibraryItemReference, LibraryItemType, LocationHead, LogicT, NodeType, type Operation, type OperationInput, type OperationSchema, type OperationSchemaStats, type OperationSynthesis, OperationType, type OssItem, type OssLayout, type Position2D, RSCalculator, RSDiagnosticCode, RSEngine, RSErrorCode, type RSErrorDescription, type RSForm, type RSFormStats, RSLangAnalyzer, type RSModel, type RSModelStats, ReferenceType, type Substitution, type SubstitutionErrorDescription, SubstitutionErrorType, type SyntacticReference, TOKEN_ERROR, TUPLE_ID, type TermContext, type TermForm, TokenID, TypeClass, TypeID, type TypeInfo, type TypePath, type Typification, TypificationGraph, type TypificationNodeData, type Value, ValueClass, type ValuePath, type VersionInfo, type WordForm, applyAsciiTypeSubstitutions, applyHash_fnv1a, assignSchemaDiagnostics, buildTree, detectDependencyCycleDiagnostics, findByUid, flattenAst, formatDependencyCycle, formatEvalCallStack, generateStub, getNodeIndices, getNodeText, hasCstDiagnostic, makeTypePath, makeValuePath, modelStatusCstDiagnostic, parseTypeText, printAst, printTree, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser, supportedGrammemes, visitAstDFS };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { AnyTypificationT, EmptySetT, LogicT, TypeClass, TypeID, makeTypePath }
|
|
|
7
7
|
import { parser } from "./rslang/parser/parser.js";
|
|
8
8
|
import { readErrorAnnotation, readTypeAnnotation } from "./rslang/ast-annotations.js";
|
|
9
9
|
import { CstClass, CstStatus, CstType } from "./library/rsform.js";
|
|
10
|
-
import { RSErrorCode } from "./rslang/error.js";
|
|
10
|
+
import { RSErrorCode, formatEvalCallStack } from "./rslang/error.js";
|
|
11
11
|
import { applyHash_fnv1a, generateStub } from "./shared/hash.js";
|
|
12
12
|
import { C as printValue, o as TUPLE_ID, u as makeValuePath } from "./value-COprb2Je.js";
|
|
13
13
|
import { RSCalculator } from "./rslang/eval/calculator.js";
|
|
@@ -21,4 +21,4 @@ import { FolderNode, FolderTree } from "./library/folder-tree.js";
|
|
|
21
21
|
import { AccessPolicy, LibraryItemType, LocationHead } from "./library/library.js";
|
|
22
22
|
import { NodeType, OperationType, SubstitutionErrorType } from "./library/oss.js";
|
|
23
23
|
import { RSEngine } from "./library/rsengine.js";
|
|
24
|
-
export { AccessPolicy, AnyTypificationT, CstClass, CstStatus, CstType, DEFAULT_VALUE_TEXT, DiagnosticKind, EmptySetT, EvalStatus, FolderNode, FolderTree, Grammeme, Graph, LibraryItemType, LocationHead, LogicT, NodeType, OperationType, RSCalculator, RSDiagnosticCode, RSEngine, RSErrorCode, RSLangAnalyzer, ReferenceType, SubstitutionErrorType, TOKEN_ERROR, TUPLE_ID, TokenID, TypeClass, TypeID, TypificationGraph, ValueClass, applyAsciiTypeSubstitutions, applyHash_fnv1a, assignSchemaDiagnostics, buildTree, detectDependencyCycleDiagnostics, findByUid, flattenAst, formatDependencyCycle, generateStub, getNodeIndices, getNodeText, hasCstDiagnostic, makeTypePath, makeValuePath, modelStatusCstDiagnostic, parseTypeText, printAst, printTree, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser, supportedGrammemes, visitAstDFS };
|
|
24
|
+
export { AccessPolicy, AnyTypificationT, CstClass, CstStatus, CstType, DEFAULT_VALUE_TEXT, DiagnosticKind, EmptySetT, EvalStatus, FolderNode, FolderTree, Grammeme, Graph, LibraryItemType, LocationHead, LogicT, NodeType, OperationType, RSCalculator, RSDiagnosticCode, RSEngine, RSErrorCode, RSLangAnalyzer, ReferenceType, SubstitutionErrorType, TOKEN_ERROR, TUPLE_ID, TokenID, TypeClass, TypeID, TypificationGraph, ValueClass, applyAsciiTypeSubstitutions, applyHash_fnv1a, assignSchemaDiagnostics, buildTree, detectDependencyCycleDiagnostics, findByUid, flattenAst, formatDependencyCycle, formatEvalCallStack, generateStub, getNodeIndices, getNodeText, hasCstDiagnostic, makeTypePath, makeValuePath, modelStatusCstDiagnostic, parseTypeText, printAst, printTree, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser, supportedGrammemes, visitAstDFS };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as detectDependencyCycleDiagnostics, c as modelStatusCstDiagnostic, i as assignSchemaDiagnostics, n as DiagnosticKind, o as formatDependencyCycle, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic } from "../diagnostics-
|
|
1
|
+
import { a as detectDependencyCycleDiagnostics, c as modelStatusCstDiagnostic, i as assignSchemaDiagnostics, n as DiagnosticKind, o as formatDependencyCycle, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic } from "../diagnostics-D4_B7rt2.js";
|
|
2
2
|
export { CstDiagnostic, DiagnosticKind, RSDiagnosticCode, assignSchemaDiagnostics, detectDependencyCycleDiagnostics, formatDependencyCycle, hasCstDiagnostic, modelStatusCstDiagnostic };
|
package/dist/library/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "../library-CYun28Xz.js";
|
|
2
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-
|
|
2
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, a as detectDependencyCycleDiagnostics, b as CstStatus, c as modelStatusCstDiagnostic, d as DEFAULT_VALUE_TEXT, f as EvalStatus, g as ArgumentValue, i as assignSchemaDiagnostics, l as BasicBinding, m as RSModelStats, n as DiagnosticKind, o as formatDependencyCycle, p as RSModel, r as RSDiagnosticCode, s as hasCstDiagnostic, t as CstDiagnostic, u as BasicsContext, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-D4_B7rt2.js";
|
|
3
3
|
import { FolderNode, FolderTree } from "./folder-tree.js";
|
|
4
4
|
import { n as OssLayout, r as Position2D } from "../oss-layout-3glgAqfn.js";
|
|
5
5
|
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./oss.js";
|
|
6
6
|
import { RSEngine } from "./rsengine.js";
|
|
7
|
-
import { mt as TemplateSourceFields } from "../index-
|
|
7
|
+
import { mt as TemplateSourceFields } from "../index-DzvllU3P.js";
|
|
8
8
|
//#region src/library/template-instantiation.d.ts
|
|
9
9
|
/**
|
|
10
10
|
* Payload for one {@link Constituenta} to create when instantiating an expression-bank template.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
2
|
-
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-
|
|
2
|
+
import { S as RSForm, v as Constituenta, w as Substitution } from "../diagnostics-D4_B7rt2.js";
|
|
3
3
|
import { NodeType, OperationSchema, SubstitutionErrorDescription } from "./oss.js";
|
|
4
4
|
//#region src/library/oss-api.d.ts
|
|
5
5
|
declare function constructNodeID(type: NodeType, itemID: number): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as AstNode } from "../ast-D-D6Rq3T.js";
|
|
2
2
|
import "../index-D5RahF1K.js";
|
|
3
3
|
import { l as Value } from "../value-XpJOVzMP.js";
|
|
4
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-
|
|
5
|
-
import "../index-
|
|
6
|
-
import { S as RSForm, f as EvalStatus, l as BasicBinding, p as RSModel, u as BasicsContext, x as CstType } from "../diagnostics-
|
|
4
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-B-1p712X.js";
|
|
5
|
+
import "../index-D-w-bgei.js";
|
|
6
|
+
import { S as RSForm, f as EvalStatus, l as BasicBinding, p as RSModel, u as BasicsContext, x as CstType } from "../diagnostics-D4_B7rt2.js";
|
|
7
7
|
//#region src/library/rsengine.d.ts
|
|
8
8
|
/** Services for {@link RSEngine}. */
|
|
9
9
|
interface RSEngineServices {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as removeAliasReference, A as canProduceStructure, B as filterAttributions, C as restoreConstituentOrder, D as inferTemplatedType, E as inferTemplate, F as isBasicConcept, G as MappableFields, H as remapAttributionsUnderSubstitution, I as isFunctional, J as applyMappingToConstituents, K as addAliasReference, L as isLogical, M as guessCstType, N as inferClass, O as normalizeExpression, P as isBaseSet, Q as maxAliasIndex, R as isTemplateCst, S as buildFormalDependencyGraph, T as inferStatus, U as getAnalysisFor, V as importAttributions, W as refineAnalysisForDependencyCycles, X as buildSequentialAliasMapping, Y as argumentValuesToMapping, Z as generateAlias, _ as findCstByStructure, a as buildDefinitionReferenceGraph, at as DiagnosticSourceFields, b as calculateSchemaStats, c as resolveConstituentTextChange, ct as SchemaIssueFields, d as SynthesizableFields, dt as SpawnPathFields, et as validateAliasFormat, f as inlineSynthesis, ft as StructureCapableFields, g as remapSubstitutionsAfterImport, h as applyConstituentSubstitutions, ht as TextResolvableFields, i as TextChangeOptions, it as DescribableFields, j as getCstTypePrefix, k as canHaveManualTypification, l as InlineSynthesisInput, lt as SearchableFields, m as SubstitutionResult, mt as TemplateSourceFields, n as moveIdsInOrder, nt as AliasTypedFields, o as buildTermReferenceGraph, ot as FormalOrderFields, p as sortItemsForInlineSynthesis, pt as TemplateParamSourceFields, q as allocateImportAliases, r as reorderItemsByIds, rt as BasicTextCheckFields, s as resolveAllConstituentTexts, st as ModelEvalFields, t as insertItemAfter, tt as validateNewAlias, u as InlineSynthesisResult, ut as SemanticRelations, v as getStructureName, w as applyFilterCategory, x as isSchemaIssue, y as inferNewSpawnPosition, z as typeClassForCstType } from "../../index-
|
|
1
|
+
import { $ as removeAliasReference, A as canProduceStructure, B as filterAttributions, C as restoreConstituentOrder, D as inferTemplatedType, E as inferTemplate, F as isBasicConcept, G as MappableFields, H as remapAttributionsUnderSubstitution, I as isFunctional, J as applyMappingToConstituents, K as addAliasReference, L as isLogical, M as guessCstType, N as inferClass, O as normalizeExpression, P as isBaseSet, Q as maxAliasIndex, R as isTemplateCst, S as buildFormalDependencyGraph, T as inferStatus, U as getAnalysisFor, V as importAttributions, W as refineAnalysisForDependencyCycles, X as buildSequentialAliasMapping, Y as argumentValuesToMapping, Z as generateAlias, _ as findCstByStructure, a as buildDefinitionReferenceGraph, at as DiagnosticSourceFields, b as calculateSchemaStats, c as resolveConstituentTextChange, ct as SchemaIssueFields, d as SynthesizableFields, dt as SpawnPathFields, et as validateAliasFormat, f as inlineSynthesis, ft as StructureCapableFields, g as remapSubstitutionsAfterImport, h as applyConstituentSubstitutions, ht as TextResolvableFields, i as TextChangeOptions, it as DescribableFields, j as getCstTypePrefix, k as canHaveManualTypification, l as InlineSynthesisInput, lt as SearchableFields, m as SubstitutionResult, mt as TemplateSourceFields, n as moveIdsInOrder, nt as AliasTypedFields, o as buildTermReferenceGraph, ot as FormalOrderFields, p as sortItemsForInlineSynthesis, pt as TemplateParamSourceFields, q as allocateImportAliases, r as reorderItemsByIds, rt as BasicTextCheckFields, s as resolveAllConstituentTexts, st as ModelEvalFields, t as insertItemAfter, tt as validateNewAlias, u as InlineSynthesisResult, ut as SemanticRelations, v as getStructureName, w as applyFilterCategory, x as isSchemaIssue, y as inferNewSpawnPosition, z as typeClassForCstType } from "../../index-DzvllU3P.js";
|
|
2
2
|
export { type AliasTypedFields, type BasicTextCheckFields, type DescribableFields, type DiagnosticSourceFields, type FormalOrderFields, type InlineSynthesisInput, type InlineSynthesisResult, type MappableFields, type ModelEvalFields, type SchemaIssueFields, type SearchableFields, type SemanticRelations, type SpawnPathFields, type StructureCapableFields, type SubstitutionResult, type SynthesizableFields, type TemplateParamSourceFields, type TemplateSourceFields, type TextChangeOptions, type TextResolvableFields, addAliasReference, allocateImportAliases, applyConstituentSubstitutions, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, buildDefinitionReferenceGraph, buildFormalDependencyGraph, buildSequentialAliasMapping, buildTermReferenceGraph, calculateSchemaStats, canHaveManualTypification, canProduceStructure, filterAttributions, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, importAttributions, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, inlineSynthesis, insertItemAfter, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, maxAliasIndex, moveIdsInOrder, normalizeExpression, refineAnalysisForDependencyCycles, remapAttributionsUnderSubstitution, remapSubstitutionsAfterImport, removeAliasReference, reorderItemsByIds, resolveAllConstituentTexts, resolveConstituentTextChange, restoreConstituentOrder, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
|
package/dist/library/rsform.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-
|
|
1
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-D4_B7rt2.js";
|
|
2
2
|
export { ArgumentValue, Attribution, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats, Substitution, TermForm, TypeInfo };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { b as Typification, f as ExpressionType } from "../typification-hWUoWCba.js";
|
|
2
2
|
import { d as ValuePath, l as Value } from "../value-XpJOVzMP.js";
|
|
3
|
-
import "../index-
|
|
4
|
-
import { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, x as CstType } from "../diagnostics-
|
|
3
|
+
import "../index-D-w-bgei.js";
|
|
4
|
+
import { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, x as CstType } from "../diagnostics-D4_B7rt2.js";
|
|
5
5
|
import { RSEngine } from "./rsengine.js";
|
|
6
|
-
import { st as ModelEvalFields } from "../index-
|
|
6
|
+
import { st as ModelEvalFields } from "../index-DzvllU3P.js";
|
|
7
7
|
//#region src/library/rsmodel-api.d.ts
|
|
8
8
|
/** Evaluate if parsed data is a basic binding data. */
|
|
9
9
|
declare function validateBasicBindingData(data: unknown): data is Record<string, string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypeID } from "../rslang/semantic/typification.js";
|
|
2
2
|
import { CstType } from "./rsform.js";
|
|
3
|
-
import { O as setNestedValue, _ as extractValue, b as isTupleValue, f as tuple, l as compare, x as makeDefaultValue } from "../value-COprb2Je.js";
|
|
3
|
+
import { O as setNestedValue, _ as extractValue, b as isTupleValue, d as set, f as tuple, l as compare, x as makeDefaultValue } from "../value-COprb2Je.js";
|
|
4
4
|
import "../rslang/index.js";
|
|
5
5
|
import { Q as isBasicConcept, S as calculateSchemaStats, Z as isBaseSet, s as modelStatusCstDiagnostic } from "../diagnostics-D1Cp21nP.js";
|
|
6
6
|
import { EvalStatus } from "./rsmodel.js";
|
|
@@ -44,6 +44,7 @@ function generateRandomValue(type, basics, cstByAlias, setElementsCount = DEFAUL
|
|
|
44
44
|
return tuple(factors);
|
|
45
45
|
}
|
|
46
46
|
case TypeID.collection: {
|
|
47
|
+
if (!canGenerateRandomValue(type.base, basics, cstByAlias)) return null;
|
|
47
48
|
const result = [];
|
|
48
49
|
const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));
|
|
49
50
|
for (let i = 0; i < randomElementsCount; i++) {
|
|
@@ -51,7 +52,7 @@ function generateRandomValue(type, basics, cstByAlias, setElementsCount = DEFAUL
|
|
|
51
52
|
if (sample === null) return null;
|
|
52
53
|
result.push(sample);
|
|
53
54
|
}
|
|
54
|
-
return result;
|
|
55
|
+
return set(result);
|
|
55
56
|
}
|
|
56
57
|
case TypeID.anyTypification: return null;
|
|
57
58
|
}
|
|
@@ -186,6 +187,19 @@ function addValueElement(value, path, type, currentType) {
|
|
|
186
187
|
if (path.length === 0 && type.typeID !== TypeID.collection) return makeDefaultValue(type);
|
|
187
188
|
return setNestedValue(value, path, [makeDefaultValue(currentType.base), ...extractValue(value, path) ?? []]);
|
|
188
189
|
}
|
|
190
|
+
function canGenerateRandomValue(type, basics, cstByAlias) {
|
|
191
|
+
switch (type.typeID) {
|
|
192
|
+
case TypeID.integer: return true;
|
|
193
|
+
case TypeID.basic: {
|
|
194
|
+
const cst = cstByAlias.get(type.baseID);
|
|
195
|
+
const binding = cst ? basics.get(cst.id) : void 0;
|
|
196
|
+
return Object.keys(binding ?? {}).length > 0;
|
|
197
|
+
}
|
|
198
|
+
case TypeID.tuple: return type.factors.every((factor) => canGenerateRandomValue(factor, basics, cstByAlias));
|
|
199
|
+
case TypeID.collection: return canGenerateRandomValue(type.base, basics, cstByAlias);
|
|
200
|
+
case TypeID.anyTypification: return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
189
203
|
function countBaseElements(cst, engine) {
|
|
190
204
|
if (!isBasicConcept(cst.cst_type)) return 0;
|
|
191
205
|
const value = engine.getCstValue(cst.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { modelStatusCstDiagnostic } from './diagnostics';\nimport { type RSEngine } from './rsengine';\nimport { CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept, type ModelEvalFields } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n return result;\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean {\n return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;\n}\n\n/** Filters items whose evaluation status contributes to model issues. */\nexport function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[] {\n return items.filter(cst => isModelIssue(engine, cst));\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (value === null) {\n return null;\n }\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value, path);\n if (!Array.isArray(arrayValue)) {\n return null;\n }\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction countBaseElements(cst: ModelEvalFields, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C,SAAgB,yBAAyB,MAA+C;CACtF,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC;AAChH;;AAGA,SAAgB,eAAe,MAAqD;CAClF,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,IAAI,GACtC,OAAO,OAAO,CAAC,KAAK;CAEtB,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAA8B;CAC9D,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,SAAS,IAAI;CAE7B,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO;CAET,OAAO,KAAK,OAAM,SAAQ,kBAAkB,IAAI,CAAC;AACnD;AAEA,SAAgB,oBACd,MACA,QACA,YACA,mBAA2B,mCACb;CACd,QAAQ,KAAK,QAAb;EACE,KAAK,OAAO,SACV,OAAO,KAAK,MAAM,KAAK,OAAO,IAAK,GAA4C,IAAI;EACrF,KAAK,OAAO,OAAO;GACjB,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM;GACtC,MAAM,UAAU,MAAM,OAAO,IAAI,IAAI,EAAE,IAAI;GAC3C,MAAM,MAAM,OAAO,KAAK,WAAW,CAAC,CAAC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Y,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
1
|
+
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, set, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { modelStatusCstDiagnostic } from './diagnostics';\nimport { type RSEngine } from './rsengine';\nimport { CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept, type ModelEvalFields } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n // Empty set is a valid sample only when the element domain itself is generatable.\n // When the count happens to be 0 we would otherwise skip sampling and miss empty basics.\n if (!canGenerateRandomValue(type.base, basics, cstByAlias)) {\n return null;\n }\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n // Sets must be unique; sampling with replacement can produce duplicates.\n return set(result);\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean {\n return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;\n}\n\n/** Filters items whose evaluation status contributes to model issues. */\nexport function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[] {\n return items.filter(cst => isModelIssue(engine, cst));\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (value === null) {\n return null;\n }\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value, path);\n if (!Array.isArray(arrayValue)) {\n return null;\n }\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction canGenerateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>\n): boolean {\n switch (type.typeID) {\n case TypeID.integer:\n return true;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n return Object.keys(binding ?? {}).length > 0;\n }\n case TypeID.tuple:\n return type.factors.every(factor => canGenerateRandomValue(factor, basics, cstByAlias));\n case TypeID.collection:\n return canGenerateRandomValue(type.base, basics, cstByAlias);\n case TypeID.anyTypification:\n return false;\n }\n}\n\nfunction countBaseElements(cst: ModelEvalFields, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C,SAAgB,yBAAyB,MAA+C;CACtF,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC;AAChH;;AAGA,SAAgB,eAAe,MAAqD;CAClF,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,IAAI,GACtC,OAAO,OAAO,CAAC,KAAK;CAEtB,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAA8B;CAC9D,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,SAAS,IAAI;CAE7B,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO;CAET,OAAO,KAAK,OAAM,SAAQ,kBAAkB,IAAI,CAAC;AACnD;AAEA,SAAgB,oBACd,MACA,QACA,YACA,mBAA2B,mCACb;CACd,QAAQ,KAAK,QAAb;EACE,KAAK,OAAO,SACV,OAAO,KAAK,MAAM,KAAK,OAAO,IAAK,GAA4C,IAAI;EACrF,KAAK,OAAO,OAAO;GACjB,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM;GACtC,MAAM,UAAU,MAAM,OAAO,IAAI,IAAI,EAAE,IAAI;GAC3C,MAAM,MAAM,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM;GACjD,IAAI,IAAI,WAAW,GACjB,OAAO;GAET,OAAO,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,MAAM;EAClD;EACA,KAAK,OAAO,OAAO;G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IAAI,EAAE,IAAI;GAC3C,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;EAC7C;EACA,KAAK,OAAO,OACV,OAAO,KAAK,QAAQ,OAAM,WAAU,uBAAuB,QAAQ,QAAQ,UAAU,CAAC;EACxF,KAAK,OAAO,YACV,OAAO,uBAAuB,KAAK,MAAM,QAAQ,UAAU;EAC7D,KAAK,OAAO,iBACV,OAAO;CACX;AACF;AAEA,SAAS,kBAAkB,KAAsB,QAA0B;CACzE,IAAI,CAAC,eAAe,IAAI,QAAQ,GAC9B,OAAO;CAET,MAAM,QAAQ,OAAO,YAAY,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-
|
|
1
|
+
import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-D4_B7rt2.js";
|
|
2
2
|
export { BasicBinding, BasicsContext, DEFAULT_VALUE_TEXT, EvalStatus, RSModel, RSModelStats, TYPE_BASIC };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { b as Typification, y as TypePath } from "../typification-hWUoWCba.js";
|
|
2
|
-
import "../index-
|
|
3
|
-
import { S as RSForm, v as Constituenta } from "../diagnostics-
|
|
2
|
+
import "../index-D-w-bgei.js";
|
|
3
|
+
import { S as RSForm, v as Constituenta } from "../diagnostics-D4_B7rt2.js";
|
|
4
4
|
//#region src/library/structure-planner.d.ts
|
|
5
5
|
/** Represents a node in the structure planner. */
|
|
6
6
|
interface SPNode {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-
|
|
1
|
+
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-DclU1Ser.js";
|
|
2
2
|
export { annotateError, annotateType, readErrorAnnotation, readTypeAnnotation };
|
package/dist/rslang/error.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { ErrorReporter, RSErrorClass, RSErrorCode, RSErrorDescription, RSErrorInfo, getRSErrorPrefix, isCritical };
|
|
1
|
+
import { a as RSErrorDescription, c as getRSErrorPrefix, i as RSErrorCode, l as isCritical, n as EvalStackFrame, o as RSErrorInfo, r as RSErrorClass, s as formatEvalCallStack, t as ErrorReporter } from "../error-S1JghCNN.js";
|
|
2
|
+
export { ErrorReporter, EvalStackFrame, RSErrorClass, RSErrorCode, RSErrorDescription, RSErrorInfo, formatEvalCallStack, getRSErrorPrefix, isCritical };
|
package/dist/rslang/error.js
CHANGED
|
@@ -8,6 +8,21 @@ const RSErrorClass = {
|
|
|
8
8
|
EVALUATION: 3,
|
|
9
9
|
UNKNOWN: 4
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Formats an evaluation call chain for display (`F5 → F12`).
|
|
13
|
+
*
|
|
14
|
+
* Uses callee aliases from outermost call to innermost fault container.
|
|
15
|
+
* Returns an empty string when there is no nested call to show.
|
|
16
|
+
*/
|
|
17
|
+
function formatEvalCallStack(stack) {
|
|
18
|
+
if (!stack || stack.length === 0) return "";
|
|
19
|
+
const aliases = [];
|
|
20
|
+
for (let index = stack.length - 1; index >= 0; index--) {
|
|
21
|
+
const frame = stack[index];
|
|
22
|
+
if (frame) aliases.push(frame.alias);
|
|
23
|
+
}
|
|
24
|
+
return aliases.join(" → ");
|
|
25
|
+
}
|
|
11
26
|
/** Represents RSLang expression error types. */
|
|
12
27
|
const RSErrorCode = {
|
|
13
28
|
unknownSyntax: 33792,
|
|
@@ -116,6 +131,6 @@ function isCritical(code) {
|
|
|
116
131
|
return true;
|
|
117
132
|
}
|
|
118
133
|
//#endregion
|
|
119
|
-
export { RSErrorClass, RSErrorCode, getRSErrorPrefix, isCritical };
|
|
134
|
+
export { RSErrorClass, RSErrorCode, formatEvalCallStack, getRSErrorPrefix, isCritical };
|
|
120
135
|
|
|
121
136
|
//# sourceMappingURL=error.js.map
|
package/dist/rslang/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n forbiddenCharacter: 0x8401, // 33793\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedQuantifierBody: 0x841b, // 33819\n expectedDeclarativeBody: 0x841c, // 33820\n expectedImperativeBody: 0x841d, // 33821\n expectedRecursiveBody: 0x841e, // 33822\n expectedQuantifierDomain: 0x841f, // 33823\n expectedRightOperand: 0x8420, // 33824\n expectedUnaryOperand: 0x8421, // 33825\n globalFuncParenCall: 0x8422, // 33826\n expectedArgument: 0x8423, // 33827\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n localDoubleDeclare: 0x8803, // 34819\n\n typesNotEqual: 0x880a, // 34826\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n invalidReduce: 0x8810, // 34832\n invalidEnumeration: 0x8813, // 34835\n projectionSetArgumentNotSet: 0x8830, // 34864\n projectionSetArgumentNotTupleSet: 0x8831, // 34865\n projectionSetIndexOutOfRange: 0x8832, // 34866\n projectionTupleArgumentNotTuple: 0x8833, // 34867\n projectionTupleIndexOutOfRange: 0x8834, // 34868\n invalidCortegeDeclare: 0x8814, // 34836\n localOutOfScope: 0x8815, // 34837\n invalidElementPredicate: 0x8816, // 34838\n invalidEmptySetUsage: 0x8817, // 34839\n invalidArgsArity: 0x8818, // 34840\n invalidArgumentType: 0x8819, // 34841\n globalStructure: 0x881c, // 34844\n radicalUsage: 0x8821, // 34849\n invalidFilterArgumentType: 0x8822, // 34850\n invalidFilterArity: 0x8823, // 34851\n arithmeticNotSupported: 0x8824, // 34852\n typesNotCompatible: 0x8825, // 34853\n orderingNotSupported: 0x8826, // 34854\n expectedLogic: 0x8827, // 34855\n expectedSetexpr: 0x8828, // 34856\n invalidArgumentCortegeDeclare: 0x8829, // 34857\n invalidQuantifierDomain: 0x882a, // 34858\n invalidFilterParameterType: 0x882b, // 34859\n invalidFilterIndex: 0x882c, // 34860\n invalidFilterBooleanEchelon: 0x882d, // 34861\n localOutOfScopeParentheses: 0x882e, // 34862\n localUndeclaredInSubexpr: 0x882f, // 34863\n\n globalNoValue: 0x8840, // 34880\n invalidPropertyUsage: 0x8841, // 34881\n\n // Value evaluation (runtime)\n calcUnknownError: 0x8100, // 35328\n setOverflow: 0x8101, // 35329\n booleanBaseLimit: 0x8102, // 35330\n calcGlobalMissing: 0x8103, // 35331\n iterationsLimit: 0x8104, // 35332\n calcInvalidDebool: 0x8105, // 35333\n iterateInfinity: 0x8106, // 35334\n calculationNotSupported: 0x8107, // 35335\n calcInvalidData: 0x8108, // 35336\n\n cstEmptyDerived: 0x8861, // 34913\n definitionNotAllowed: 0x8862, // 34914\n\n // Schema diagnostics surfaced in expression analysis (same value as RSDiagnosticCode.schemaDependencyCycle).\n schemaDependencyCycle: 0x8906 // 35078\n} as const;\nexport type RSErrorCode = (typeof RSErrorCode)[keyof typeof RSErrorCode];\n\nconst ERROR_EVALUATION_MASK = 0x0100;\nconst ERROR_LEXER_MASK = 0x0200;\nconst ERROR_PARSER_MASK = 0x0400;\nconst ERROR_SEMANTIC_MASK = 0x0800;\n\n/** Infers error class from error type (code). */\nfunction inferErrorClass(error: RSErrorCode): RSErrorClass {\n if ((error & ERROR_EVALUATION_MASK) !== 0) {\n return RSErrorClass.EVALUATION;\n } else if ((error & ERROR_LEXER_MASK) !== 0) {\n return RSErrorClass.LEXER;\n } else if ((error & ERROR_PARSER_MASK) !== 0) {\n return RSErrorClass.PARSER;\n } else if ((error & ERROR_SEMANTIC_MASK) !== 0) {\n return RSErrorClass.SEMANTIC;\n } else {\n return RSErrorClass.UNKNOWN;\n }\n}\n\n/** Generate ErrorID label. */\nexport function getRSErrorPrefix(code: RSErrorCode): string {\n const id = code.toString(16).toUpperCase();\n // prettier-ignore\n switch (inferErrorClass(code)) {\n case RSErrorClass.LEXER: return 'L' + id;\n case RSErrorClass.PARSER: return 'P' + id;\n case RSErrorClass.SEMANTIC: return 'S' + id;\n case RSErrorClass.EVALUATION: return 'E' + id;\n case RSErrorClass.UNKNOWN: return 'U' + id;\n }\n}\n\n/** Checks if error is critical. */\nexport function isCritical(code: RSErrorCode): boolean {\n if ((code & 0xf000) === 0x2000) {\n return false;\n }\n return true;\n}\n"],"mappings":";;;AAGA,MAAa,eAAe;CAC1B,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;AACX;;
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/**\n * One frame of an evaluation call chain.\n *\n * Spans are relative to the formal definition of {@link alias}.\n * Frames are ordered innermost-first: fault locus, then each caller outward.\n * The root expression under evaluation is not a frame — its highlight is\n * {@link RSErrorDescription.from}/{@link RSErrorDescription.to}; {@link RSErrorDescription.stack}\n * is absent when the fault is in that root expression.\n */\nexport interface EvalStackFrame {\n /** Constituent whose formal definition contains this span. */\n alias: string;\n /** Half-open span `[from, to)` in that definition. */\n from: number;\n to: number;\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n /**\n * Evaluation call chain when the fault is inside a called `F#`/`P#` body.\n * Absent for parse/semantic errors and for evaluation errors in the root expression.\n */\n stack?: readonly EvalStackFrame[];\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/**\n * Formats an evaluation call chain for display (`F5 → F12`).\n *\n * Uses callee aliases from outermost call to innermost fault container.\n * Returns an empty string when there is no nested call to show.\n */\nexport function formatEvalCallStack(stack: readonly EvalStackFrame[] | undefined): string {\n if (!stack || stack.length === 0) {\n return '';\n }\n const aliases: string[] = [];\n for (let index = stack.length - 1; index >= 0; index--) {\n const frame = stack[index];\n if (frame) {\n aliases.push(frame.alias);\n }\n }\n return aliases.join(' → ');\n}\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n forbiddenCharacter: 0x8401, // 33793\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedQuantifierBody: 0x841b, // 33819\n expectedDeclarativeBody: 0x841c, // 33820\n expectedImperativeBody: 0x841d, // 33821\n expectedRecursiveBody: 0x841e, // 33822\n expectedQuantifierDomain: 0x841f, // 33823\n expectedRightOperand: 0x8420, // 33824\n expectedUnaryOperand: 0x8421, // 33825\n globalFuncParenCall: 0x8422, // 33826\n expectedArgument: 0x8423, // 33827\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n localDoubleDeclare: 0x8803, // 34819\n\n typesNotEqual: 0x880a, // 34826\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n invalidReduce: 0x8810, // 34832\n invalidEnumeration: 0x8813, // 34835\n projectionSetArgumentNotSet: 0x8830, // 34864\n projectionSetArgumentNotTupleSet: 0x8831, // 34865\n projectionSetIndexOutOfRange: 0x8832, // 34866\n projectionTupleArgumentNotTuple: 0x8833, // 34867\n projectionTupleIndexOutOfRange: 0x8834, // 34868\n invalidCortegeDeclare: 0x8814, // 34836\n localOutOfScope: 0x8815, // 34837\n invalidElementPredicate: 0x8816, // 34838\n invalidEmptySetUsage: 0x8817, // 34839\n invalidArgsArity: 0x8818, // 34840\n invalidArgumentType: 0x8819, // 34841\n globalStructure: 0x881c, // 34844\n radicalUsage: 0x8821, // 34849\n invalidFilterArgumentType: 0x8822, // 34850\n invalidFilterArity: 0x8823, // 34851\n arithmeticNotSupported: 0x8824, // 34852\n typesNotCompatible: 0x8825, // 34853\n orderingNotSupported: 0x8826, // 34854\n expectedLogic: 0x8827, // 34855\n expectedSetexpr: 0x8828, // 34856\n invalidArgumentCortegeDeclare: 0x8829, // 34857\n invalidQuantifierDomain: 0x882a, // 34858\n invalidFilterParameterType: 0x882b, // 34859\n invalidFilterIndex: 0x882c, // 34860\n invalidFilterBooleanEchelon: 0x882d, // 34861\n localOutOfScopeParentheses: 0x882e, // 34862\n localUndeclaredInSubexpr: 0x882f, // 34863\n\n globalNoValue: 0x8840, // 34880\n invalidPropertyUsage: 0x8841, // 34881\n\n // Value evaluation (runtime)\n calcUnknownError: 0x8100, // 35328\n setOverflow: 0x8101, // 35329\n booleanBaseLimit: 0x8102, // 35330\n calcGlobalMissing: 0x8103, // 35331\n iterationsLimit: 0x8104, // 35332\n calcInvalidDebool: 0x8105, // 35333\n iterateInfinity: 0x8106, // 35334\n calculationNotSupported: 0x8107, // 35335\n calcInvalidData: 0x8108, // 35336\n\n cstEmptyDerived: 0x8861, // 34913\n definitionNotAllowed: 0x8862, // 34914\n\n // Schema diagnostics surfaced in expression analysis (same value as RSDiagnosticCode.schemaDependencyCycle).\n schemaDependencyCycle: 0x8906 // 35078\n} as const;\nexport type RSErrorCode = (typeof RSErrorCode)[keyof typeof RSErrorCode];\n\nconst ERROR_EVALUATION_MASK = 0x0100;\nconst ERROR_LEXER_MASK = 0x0200;\nconst ERROR_PARSER_MASK = 0x0400;\nconst ERROR_SEMANTIC_MASK = 0x0800;\n\n/** Infers error class from error type (code). */\nfunction inferErrorClass(error: RSErrorCode): RSErrorClass {\n if ((error & ERROR_EVALUATION_MASK) !== 0) {\n return RSErrorClass.EVALUATION;\n } else if ((error & ERROR_LEXER_MASK) !== 0) {\n return RSErrorClass.LEXER;\n } else if ((error & ERROR_PARSER_MASK) !== 0) {\n return RSErrorClass.PARSER;\n } else if ((error & ERROR_SEMANTIC_MASK) !== 0) {\n return RSErrorClass.SEMANTIC;\n } else {\n return RSErrorClass.UNKNOWN;\n }\n}\n\n/** Generate ErrorID label. */\nexport function getRSErrorPrefix(code: RSErrorCode): string {\n const id = code.toString(16).toUpperCase();\n // prettier-ignore\n switch (inferErrorClass(code)) {\n case RSErrorClass.LEXER: return 'L' + id;\n case RSErrorClass.PARSER: return 'P' + id;\n case RSErrorClass.SEMANTIC: return 'S' + id;\n case RSErrorClass.EVALUATION: return 'E' + id;\n case RSErrorClass.UNKNOWN: return 'U' + id;\n }\n}\n\n/** Checks if error is critical. */\nexport function isCritical(code: RSErrorCode): boolean {\n if ((code & 0xf000) === 0x2000) {\n return false;\n }\n return true;\n}\n"],"mappings":";;;AAGA,MAAa,eAAe;CAC1B,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;AACX;;;;;;;AA8CA,SAAgB,oBAAoB,OAAsD;CACxF,IAAI,CAAC,SAAS,MAAM,WAAW,GAC7B,OAAO;CAET,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS;EACtD,MAAM,QAAQ,MAAM;EACpB,IAAI,OACF,QAAQ,KAAK,MAAM,KAAK;CAE5B;CACA,OAAO,QAAQ,KAAK,KAAK;AAC3B;;AAGA,MAAa,cAAc;CACzB,eAAe;CACf,oBAAoB;CACpB,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,sBAAsB;CACtB,wBAAwB;CACxB,mBAAmB;CACnB,wBAAwB;CACxB,yBAAyB;CACzB,wBAAwB;CACxB,uBAAuB;CACvB,0BAA0B;CAC1B,sBAAsB;CACtB,sBAAsB;CACtB,qBAAqB;CACrB,kBAAkB;CAClB,eAAe;CACf,cAAc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,aAAa,OAAO,OAAO,MAAM;EACtC,KAAK,aAAa,QAAQ,OAAO,MAAM;EACvC,KAAK,aAAa,UAAU,OAAO,MAAM;EACzC,KAAK,aAAa,YAAY,OAAO,MAAM;EAC3C,KAAK,aAAa,SAAS,OAAO,MAAM;CAC1C;AACF;;AAGA,SAAgB,WAAW,MAA4B;CACrD,KAAK,OAAO,WAAY,MACtB,OAAO;CAET,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-
|
|
1
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-B-1p712X.js";
|
|
2
2
|
export { CalculatorEvaluateOptions, CalculatorResult, RSCalculator };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "../../ast-D-D6Rq3T.js";
|
|
2
2
|
import "../../index-D5RahF1K.js";
|
|
3
|
-
import { t as ErrorReporter } from "../../error-
|
|
3
|
+
import { t as ErrorReporter } from "../../error-S1JghCNN.js";
|
|
4
4
|
import { l as Value, u as ValueContext } from "../../value-XpJOVzMP.js";
|
|
5
5
|
//#region src/rslang/eval/evaluator.d.ts
|
|
6
6
|
/** AST context. */
|
|
@@ -23,7 +23,17 @@ declare class Evaluator {
|
|
|
23
23
|
constructor(context: ValueContext, astContext: ASTContext);
|
|
24
24
|
run(ast: AstNode, reporter?: ErrorReporter, annotateErrors?: boolean, disableCache?: boolean): Value | null;
|
|
25
25
|
private clear;
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Surface highlight target in the root expression under evaluation.
|
|
28
|
+
* Nested call sites live in callee ASTs — only the outermost call is in the root.
|
|
29
|
+
*/
|
|
30
|
+
private surfaceErrorNode;
|
|
31
|
+
/**
|
|
32
|
+
* Builds innermost-first frames for called `F#`/`P#` bodies only.
|
|
33
|
+
* The root expression is represented by the surface `from`/`to`, not a stack frame.
|
|
34
|
+
* Returns `undefined` when the fault is in the root expression (no function call).
|
|
35
|
+
*/
|
|
36
|
+
private buildEvalStack;
|
|
27
37
|
private onError;
|
|
28
38
|
private tick;
|
|
29
39
|
private dispatchDeclare;
|