@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
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type AstNode, getNodeIndices, getNodeText } from '../../parsing';
|
|
6
6
|
import { annotateError } from '../ast-annotations';
|
|
7
|
-
import { type ErrorReporter, RSErrorCode } from '../error';
|
|
7
|
+
import { type ErrorReporter, type EvalStackFrame, RSErrorCode } from '../error';
|
|
8
8
|
import { labelRSLangNode } from '../labels';
|
|
9
9
|
import { TokenID } from '../parser/token';
|
|
10
10
|
|
|
@@ -95,16 +95,59 @@ export class Evaluator {
|
|
|
95
95
|
this.iterationCounter = 0;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Surface highlight target in the root expression under evaluation.
|
|
100
|
+
* Nested call sites live in callee ASTs — only the outermost call is in the root.
|
|
101
|
+
*/
|
|
102
|
+
private surfaceErrorNode(fault: AstNode): AstNode {
|
|
103
|
+
return this.callSiteStack[0] ?? fault;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Builds innermost-first frames for called `F#`/`P#` bodies only.
|
|
108
|
+
* The root expression is represented by the surface `from`/`to`, not a stack frame.
|
|
109
|
+
* Returns `undefined` when the fault is in the root expression (no function call).
|
|
110
|
+
*/
|
|
111
|
+
private buildEvalStack(fault: AstNode): readonly EvalStackFrame[] | undefined {
|
|
112
|
+
if (this.callSiteStack.length === 0) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const frames: EvalStackFrame[] = [];
|
|
116
|
+
const innermostCall = this.callSiteStack[this.callSiteStack.length - 1];
|
|
117
|
+
if (!innermostCall) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
frames.push({
|
|
121
|
+
alias: getNodeText(innermostCall.children[0]),
|
|
122
|
+
from: fault.from,
|
|
123
|
+
to: fault.to
|
|
124
|
+
});
|
|
125
|
+
// Call sites at index ≥ 1 live in a callee body; index 0 is the root call site.
|
|
126
|
+
for (let index = this.callSiteStack.length - 1; index >= 1; index--) {
|
|
127
|
+
const callSite = this.callSiteStack[index];
|
|
128
|
+
const outerCall = this.callSiteStack[index - 1];
|
|
129
|
+
if (!callSite || !outerCall) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
frames.push({
|
|
133
|
+
alias: getNodeText(outerCall.children[0]),
|
|
134
|
+
from: callSite.from,
|
|
135
|
+
to: callSite.to
|
|
136
|
+
});
|
|
101
137
|
}
|
|
102
|
-
return
|
|
138
|
+
return frames;
|
|
103
139
|
}
|
|
104
140
|
|
|
105
141
|
private onError(code: RSErrorCode, node: AstNode, params?: string[]): null {
|
|
106
|
-
const target = this.
|
|
107
|
-
|
|
142
|
+
const target = this.surfaceErrorNode(node);
|
|
143
|
+
const stack = this.buildEvalStack(node);
|
|
144
|
+
this.reporter?.({
|
|
145
|
+
code,
|
|
146
|
+
from: target.from,
|
|
147
|
+
to: target.to,
|
|
148
|
+
...(params !== undefined ? { params } : {}),
|
|
149
|
+
...(stack !== undefined ? { stack } : {})
|
|
150
|
+
});
|
|
108
151
|
if (this.annotateErrors) {
|
|
109
152
|
annotateError(target, code, params);
|
|
110
153
|
}
|
package/src/rslang/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { readErrorAnnotation, readTypeAnnotation } from './ast-annotations';
|
|
2
|
-
export { RSErrorCode, type RSErrorDescription } from './error';
|
|
2
|
+
export { type EvalStackFrame, formatEvalCallStack,RSErrorCode, type RSErrorDescription } from './error';
|
|
3
3
|
export { type CalculatorEvaluateOptions, type CalculatorResult, RSCalculator } from './eval/calculator';
|
|
4
4
|
export { makeValuePath, type Value, type ValuePath } from './eval/value';
|
|
5
5
|
export { printValue } from './eval/value-api';
|