@rcrsr/rill 0.15.0 → 0.17.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/README.md +37 -21
- package/dist/ast-nodes.d.ts +2 -13
- package/dist/ast-nodes.js +0 -1
- package/dist/ast-unions.d.ts +0 -1
- package/dist/ast-unions.js +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/error-classes.d.ts +0 -1
- package/dist/error-classes.js +0 -1
- package/dist/error-formatter.d.ts +0 -1
- package/dist/error-formatter.js +0 -1
- package/dist/error-registry.d.ts +0 -1
- package/dist/error-registry.js +32 -1
- package/dist/ext/crypto/index.d.ts +3 -4
- package/dist/ext/crypto/index.js +66 -64
- package/dist/ext/exec/index.d.ts +3 -4
- package/dist/ext/exec/index.js +17 -12
- package/dist/ext/exec/runner.d.ts +0 -1
- package/dist/ext/exec/runner.js +0 -1
- package/dist/ext/fetch/index.d.ts +3 -4
- package/dist/ext/fetch/index.js +23 -49
- package/dist/ext/fetch/request.d.ts +0 -1
- package/dist/ext/fetch/request.js +0 -1
- package/dist/ext/fs/index.d.ts +3 -4
- package/dist/ext/fs/index.js +268 -266
- package/dist/ext/fs/sandbox.d.ts +0 -1
- package/dist/ext/fs/sandbox.js +0 -1
- package/dist/ext/kv/index.d.ts +3 -4
- package/dist/ext/kv/index.js +216 -215
- package/dist/ext/kv/store.d.ts +0 -1
- package/dist/ext/kv/store.js +2 -2
- package/dist/ext-parse-bridge.d.ts +10 -0
- package/dist/ext-parse-bridge.js +10 -0
- package/dist/generated/introspection-data.d.ts +1 -2
- package/dist/generated/introspection-data.js +385 -297
- package/dist/generated/version-data.d.ts +1 -2
- package/dist/generated/version-data.js +2 -3
- package/dist/highlight-map.d.ts +0 -1
- package/dist/highlight-map.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +14 -6
- package/dist/lexer/errors.d.ts +0 -1
- package/dist/lexer/errors.js +0 -1
- package/dist/lexer/helpers.d.ts +0 -1
- package/dist/lexer/helpers.js +0 -1
- package/dist/lexer/index.d.ts +0 -1
- package/dist/lexer/index.js +0 -1
- package/dist/lexer/operators.d.ts +0 -1
- package/dist/lexer/operators.js +0 -1
- package/dist/lexer/readers.d.ts +0 -1
- package/dist/lexer/readers.js +0 -1
- package/dist/lexer/state.d.ts +0 -1
- package/dist/lexer/state.js +0 -1
- package/dist/lexer/tokenizer.d.ts +0 -1
- package/dist/lexer/tokenizer.js +0 -1
- package/dist/parser/helpers.d.ts +0 -1
- package/dist/parser/helpers.js +0 -1
- package/dist/parser/index.d.ts +0 -1
- package/dist/parser/index.js +0 -1
- package/dist/parser/parser-collect.d.ts +0 -1
- package/dist/parser/parser-collect.js +0 -1
- package/dist/parser/parser-control.d.ts +0 -1
- package/dist/parser/parser-control.js +0 -1
- package/dist/parser/parser-expr.d.ts +0 -1
- package/dist/parser/parser-expr.js +0 -1
- package/dist/parser/parser-extract.d.ts +0 -1
- package/dist/parser/parser-extract.js +0 -1
- package/dist/parser/parser-functions.d.ts +0 -1
- package/dist/parser/parser-functions.js +0 -1
- package/dist/parser/parser-literals.d.ts +0 -1
- package/dist/parser/parser-literals.js +4 -2
- package/dist/parser/parser-script.d.ts +0 -1
- package/dist/parser/parser-script.js +0 -1
- package/dist/parser/parser-shape.d.ts +2 -3
- package/dist/parser/parser-shape.js +8 -52
- package/dist/parser/parser-types.d.ts +28 -2
- package/dist/parser/parser-types.js +76 -13
- package/dist/parser/parser-use.d.ts +0 -1
- package/dist/parser/parser-use.js +7 -2
- package/dist/parser/parser-variables.d.ts +0 -1
- package/dist/parser/parser-variables.js +0 -1
- package/dist/parser/parser.d.ts +0 -1
- package/dist/parser/parser.js +0 -1
- package/dist/parser/state.d.ts +0 -1
- package/dist/parser/state.js +0 -1
- package/dist/runtime/core/callable.d.ts +59 -20
- package/dist/runtime/core/callable.js +188 -39
- package/dist/runtime/core/context.d.ts +0 -12
- package/dist/runtime/core/context.js +77 -77
- package/dist/runtime/core/equals.d.ts +0 -1
- package/dist/runtime/core/equals.js +35 -3
- package/dist/runtime/core/eval/base.d.ts +0 -1
- package/dist/runtime/core/eval/base.js +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts +0 -1
- package/dist/runtime/core/eval/evaluator.js +0 -1
- package/dist/runtime/core/eval/index.d.ts +2 -3
- package/dist/runtime/core/eval/index.js +11 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/closures.js +92 -70
- package/dist/runtime/core/eval/mixins/collections.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/collections.js +9 -4
- package/dist/runtime/core/eval/mixins/control-flow.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js +196 -188
- package/dist/runtime/core/eval/mixins/core.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/core.js +2 -3
- package/dist/runtime/core/eval/mixins/expressions.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js +35 -28
- package/dist/runtime/core/eval/mixins/extraction.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js +8 -9
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/literals.js +6 -10
- package/dist/runtime/core/eval/mixins/types.d.ts +2 -1
- package/dist/runtime/core/eval/mixins/types.js +231 -261
- package/dist/runtime/core/eval/mixins/use.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/use.js +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/variables.js +16 -15
- package/dist/runtime/core/eval/types.d.ts +0 -1
- package/dist/runtime/core/eval/types.js +0 -1
- package/dist/runtime/core/execute.d.ts +0 -1
- package/dist/runtime/core/execute.js +0 -1
- package/dist/runtime/core/field-descriptor.d.ts +4 -5
- package/dist/runtime/core/field-descriptor.js +2 -2
- package/dist/runtime/core/introspection.d.ts +0 -1
- package/dist/runtime/core/introspection.js +6 -7
- package/dist/runtime/core/markers.d.ts +12 -0
- package/dist/runtime/core/markers.js +7 -0
- package/dist/runtime/core/resolvers.d.ts +0 -1
- package/dist/runtime/core/resolvers.js +0 -1
- package/dist/runtime/core/signals.d.ts +0 -1
- package/dist/runtime/core/signals.js +0 -1
- package/dist/runtime/core/type-registrations.d.ts +136 -0
- package/dist/runtime/core/type-registrations.js +749 -0
- package/dist/runtime/core/type-structures.d.ts +128 -0
- package/dist/runtime/core/type-structures.js +12 -0
- package/dist/runtime/core/types.d.ts +15 -4
- package/dist/runtime/core/types.js +0 -1
- package/dist/runtime/core/values.d.ts +88 -146
- package/dist/runtime/core/values.js +466 -470
- package/dist/runtime/ext/builtins.d.ts +0 -1
- package/dist/runtime/ext/builtins.js +125 -80
- package/dist/runtime/ext/extensions.d.ts +30 -125
- package/dist/runtime/ext/extensions.js +0 -94
- package/dist/runtime/ext/test-context.d.ts +28 -0
- package/dist/runtime/ext/test-context.js +154 -0
- package/dist/runtime/index.d.ts +22 -9
- package/dist/runtime/index.js +18 -5
- package/dist/signature-parser.d.ts +2 -3
- package/dist/signature-parser.js +19 -17
- package/dist/source-location.d.ts +0 -1
- package/dist/source-location.js +0 -1
- package/dist/token-types.d.ts +0 -1
- package/dist/token-types.js +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/value-types.d.ts +15 -12
- package/dist/value-types.js +0 -1
- package/package.json +2 -1
- package/dist/ast-nodes.d.ts.map +0 -1
- package/dist/ast-nodes.js.map +0 -1
- package/dist/ast-unions.d.ts.map +0 -1
- package/dist/ast-unions.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/error-classes.d.ts.map +0 -1
- package/dist/error-classes.js.map +0 -1
- package/dist/error-formatter.d.ts.map +0 -1
- package/dist/error-formatter.js.map +0 -1
- package/dist/error-registry.d.ts.map +0 -1
- package/dist/error-registry.js.map +0 -1
- package/dist/ext/crypto/index.d.ts.map +0 -1
- package/dist/ext/crypto/index.js.map +0 -1
- package/dist/ext/exec/index.d.ts.map +0 -1
- package/dist/ext/exec/index.js.map +0 -1
- package/dist/ext/exec/runner.d.ts.map +0 -1
- package/dist/ext/exec/runner.js.map +0 -1
- package/dist/ext/fetch/index.d.ts.map +0 -1
- package/dist/ext/fetch/index.js.map +0 -1
- package/dist/ext/fetch/request.d.ts.map +0 -1
- package/dist/ext/fetch/request.js.map +0 -1
- package/dist/ext/fs/index.d.ts.map +0 -1
- package/dist/ext/fs/index.js.map +0 -1
- package/dist/ext/fs/sandbox.d.ts.map +0 -1
- package/dist/ext/fs/sandbox.js.map +0 -1
- package/dist/ext/kv/index.d.ts.map +0 -1
- package/dist/ext/kv/index.js.map +0 -1
- package/dist/ext/kv/store.d.ts.map +0 -1
- package/dist/ext/kv/store.js.map +0 -1
- package/dist/generated/introspection-data.d.ts.map +0 -1
- package/dist/generated/introspection-data.js.map +0 -1
- package/dist/generated/version-data.d.ts.map +0 -1
- package/dist/generated/version-data.js.map +0 -1
- package/dist/highlight-map.d.ts.map +0 -1
- package/dist/highlight-map.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lexer/errors.d.ts.map +0 -1
- package/dist/lexer/errors.js.map +0 -1
- package/dist/lexer/helpers.d.ts.map +0 -1
- package/dist/lexer/helpers.js.map +0 -1
- package/dist/lexer/index.d.ts.map +0 -1
- package/dist/lexer/index.js.map +0 -1
- package/dist/lexer/operators.d.ts.map +0 -1
- package/dist/lexer/operators.js.map +0 -1
- package/dist/lexer/readers.d.ts.map +0 -1
- package/dist/lexer/readers.js.map +0 -1
- package/dist/lexer/state.d.ts.map +0 -1
- package/dist/lexer/state.js.map +0 -1
- package/dist/lexer/tokenizer.d.ts.map +0 -1
- package/dist/lexer/tokenizer.js.map +0 -1
- package/dist/parser/helpers.d.ts.map +0 -1
- package/dist/parser/helpers.js.map +0 -1
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/parser-collect.d.ts.map +0 -1
- package/dist/parser/parser-collect.js.map +0 -1
- package/dist/parser/parser-control.d.ts.map +0 -1
- package/dist/parser/parser-control.js.map +0 -1
- package/dist/parser/parser-expr.d.ts.map +0 -1
- package/dist/parser/parser-expr.js.map +0 -1
- package/dist/parser/parser-extract.d.ts.map +0 -1
- package/dist/parser/parser-extract.js.map +0 -1
- package/dist/parser/parser-functions.d.ts.map +0 -1
- package/dist/parser/parser-functions.js.map +0 -1
- package/dist/parser/parser-literals.d.ts.map +0 -1
- package/dist/parser/parser-literals.js.map +0 -1
- package/dist/parser/parser-script.d.ts.map +0 -1
- package/dist/parser/parser-script.js.map +0 -1
- package/dist/parser/parser-shape.d.ts.map +0 -1
- package/dist/parser/parser-shape.js.map +0 -1
- package/dist/parser/parser-types.d.ts.map +0 -1
- package/dist/parser/parser-types.js.map +0 -1
- package/dist/parser/parser-use.d.ts.map +0 -1
- package/dist/parser/parser-use.js.map +0 -1
- package/dist/parser/parser-variables.d.ts.map +0 -1
- package/dist/parser/parser-variables.js.map +0 -1
- package/dist/parser/parser.d.ts.map +0 -1
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/state.d.ts.map +0 -1
- package/dist/parser/state.js.map +0 -1
- package/dist/runtime/core/callable.d.ts.map +0 -1
- package/dist/runtime/core/callable.js.map +0 -1
- package/dist/runtime/core/context.d.ts.map +0 -1
- package/dist/runtime/core/context.js.map +0 -1
- package/dist/runtime/core/equals.d.ts.map +0 -1
- package/dist/runtime/core/equals.js.map +0 -1
- package/dist/runtime/core/eval/base.d.ts.map +0 -1
- package/dist/runtime/core/eval/base.js.map +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts.map +0 -1
- package/dist/runtime/core/eval/evaluator.js.map +0 -1
- package/dist/runtime/core/eval/index.d.ts.map +0 -1
- package/dist/runtime/core/eval/index.js.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.js.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.js.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js.map +0 -1
- package/dist/runtime/core/eval/mixins/core.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/core.js.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.js.map +0 -1
- package/dist/runtime/core/eval/mixins/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/types.js.map +0 -1
- package/dist/runtime/core/eval/mixins/use.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/use.js.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.js.map +0 -1
- package/dist/runtime/core/eval/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/types.js.map +0 -1
- package/dist/runtime/core/execute.d.ts.map +0 -1
- package/dist/runtime/core/execute.js.map +0 -1
- package/dist/runtime/core/field-descriptor.d.ts.map +0 -1
- package/dist/runtime/core/field-descriptor.js.map +0 -1
- package/dist/runtime/core/introspection.d.ts.map +0 -1
- package/dist/runtime/core/introspection.js.map +0 -1
- package/dist/runtime/core/resolvers.d.ts.map +0 -1
- package/dist/runtime/core/resolvers.js.map +0 -1
- package/dist/runtime/core/signals.d.ts.map +0 -1
- package/dist/runtime/core/signals.js.map +0 -1
- package/dist/runtime/core/types.d.ts.map +0 -1
- package/dist/runtime/core/types.js.map +0 -1
- package/dist/runtime/core/values.d.ts.map +0 -1
- package/dist/runtime/core/values.js.map +0 -1
- package/dist/runtime/ext/builtins.d.ts.map +0 -1
- package/dist/runtime/ext/builtins.js.map +0 -1
- package/dist/runtime/ext/extensions.d.ts.map +0 -1
- package/dist/runtime/ext/extensions.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/signature-parser.d.ts.map +0 -1
- package/dist/signature-parser.js.map +0 -1
- package/dist/source-location.d.ts.map +0 -1
- package/dist/source-location.js.map +0 -1
- package/dist/token-types.d.ts.map +0 -1
- package/dist/token-types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/value-types.d.ts.map +0 -1
- package/dist/value-types.js.map +0 -1
|
@@ -179,4 +179,3 @@ function parseSchemeString(value, node) {
|
|
|
179
179
|
// TypeScript can't generate declarations for functions returning classes with protected members
|
|
180
180
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
181
|
export const UseMixin = createUseMixin;
|
|
182
|
-
//# sourceMappingURL=use.js.map
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
import { RuntimeError } from '../../../../types.js';
|
|
34
|
-
import {
|
|
34
|
+
import { formatStructure, inferType, isTypeValue, structureMatches, } from '../../values.js';
|
|
35
35
|
import { getVariable, hasVariable } from '../../context.js';
|
|
36
36
|
import { isDict, isCallable } from '../../callable.js';
|
|
37
37
|
/**
|
|
@@ -69,8 +69,8 @@ function createVariablesMixin(Base) {
|
|
|
69
69
|
if (explicitType !== undefined) {
|
|
70
70
|
if (typeof explicitType === 'object') {
|
|
71
71
|
// Structural type check
|
|
72
|
-
if (!
|
|
73
|
-
const expectedLabel =
|
|
72
|
+
if (!structureMatches(value, explicitType)) {
|
|
73
|
+
const expectedLabel = formatStructure(explicitType);
|
|
74
74
|
throw new RuntimeError('RILL-R001', `Type mismatch: cannot assign ${valueType} to $${name}:${expectedLabel}`, location, {
|
|
75
75
|
variableName: name,
|
|
76
76
|
expectedType: expectedLabel,
|
|
@@ -98,8 +98,8 @@ function createVariablesMixin(Base) {
|
|
|
98
98
|
if (lockedType !== undefined && lockedType !== 'any') {
|
|
99
99
|
if (typeof lockedType === 'object') {
|
|
100
100
|
// Structural locked type — validate full shape
|
|
101
|
-
if (!
|
|
102
|
-
const expectedLabel =
|
|
101
|
+
if (!structureMatches(value, lockedType)) {
|
|
102
|
+
const expectedLabel = formatStructure(lockedType);
|
|
103
103
|
throw new RuntimeError('RILL-R001', `Type mismatch: cannot assign ${valueType} to $${name} (locked as ${expectedLabel})`, location, {
|
|
104
104
|
variableName: name,
|
|
105
105
|
expectedType: expectedLabel,
|
|
@@ -120,7 +120,9 @@ function createVariablesMixin(Base) {
|
|
|
120
120
|
if (!this.ctx.variableTypes.has(name)) {
|
|
121
121
|
// Store structural type (object) directly so re-assignment checks
|
|
122
122
|
// validate the full shape. Fall back to valueType when no annotation.
|
|
123
|
-
const lockType = explicitType !== undefined
|
|
123
|
+
const lockType = explicitType !== undefined
|
|
124
|
+
? explicitType
|
|
125
|
+
: valueType;
|
|
124
126
|
this.ctx.variableTypes.set(name, lockType);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -260,7 +262,7 @@ function createVariablesMixin(Base) {
|
|
|
260
262
|
value = value.typeName;
|
|
261
263
|
}
|
|
262
264
|
else if (field === 'signature') {
|
|
263
|
-
value =
|
|
265
|
+
value = formatStructure(value.structure);
|
|
264
266
|
}
|
|
265
267
|
else {
|
|
266
268
|
throw new RuntimeError('RILL-R003', `Type value has no property "${field}"`, this.getNodeLocation(node));
|
|
@@ -317,12 +319,12 @@ function createVariablesMixin(Base) {
|
|
|
317
319
|
const finalAccess = node.existenceCheck.finalAccess;
|
|
318
320
|
const typeRef = node.existenceCheck.typeRef;
|
|
319
321
|
// Helper: check type match using structural resolution (EC-4: mismatch returns false)
|
|
320
|
-
const matchesType = (fieldValue) => {
|
|
322
|
+
const matchesType = async (fieldValue) => {
|
|
321
323
|
if (typeRef === null)
|
|
322
324
|
return true;
|
|
323
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
-
const resolved = this.resolveTypeRef(typeRef, (name) => getVariable(this.ctx, name));
|
|
325
|
-
return
|
|
326
|
+
const resolved = await this.resolveTypeRef(typeRef, (name) => getVariable(this.ctx, name));
|
|
327
|
+
return structureMatches(fieldValue, resolved.structure);
|
|
326
328
|
};
|
|
327
329
|
if (finalAccess.kind === 'literal') {
|
|
328
330
|
// Check if literal field exists in dict
|
|
@@ -331,7 +333,7 @@ function createVariablesMixin(Base) {
|
|
|
331
333
|
const exists = fieldValue !== undefined && fieldValue !== null;
|
|
332
334
|
// If type-qualified check, verify type matches
|
|
333
335
|
if (exists && typeRef !== null) {
|
|
334
|
-
return matchesType(fieldValue);
|
|
336
|
+
return await matchesType(fieldValue);
|
|
335
337
|
}
|
|
336
338
|
return exists;
|
|
337
339
|
}
|
|
@@ -361,7 +363,7 @@ function createVariablesMixin(Base) {
|
|
|
361
363
|
const exists = fieldValue !== undefined && fieldValue !== null;
|
|
362
364
|
// If type-qualified check, verify type matches
|
|
363
365
|
if (exists && typeRef !== null) {
|
|
364
|
-
return matchesType(fieldValue);
|
|
366
|
+
return await matchesType(fieldValue);
|
|
365
367
|
}
|
|
366
368
|
return exists;
|
|
367
369
|
}
|
|
@@ -388,7 +390,7 @@ function createVariablesMixin(Base) {
|
|
|
388
390
|
const exists = fieldValue !== undefined && fieldValue !== null;
|
|
389
391
|
// If type-qualified check, verify type matches
|
|
390
392
|
if (exists && typeRef !== null) {
|
|
391
|
-
return matchesType(fieldValue);
|
|
393
|
+
return await matchesType(fieldValue);
|
|
392
394
|
}
|
|
393
395
|
return exists;
|
|
394
396
|
}
|
|
@@ -552,7 +554,7 @@ function createVariablesMixin(Base) {
|
|
|
552
554
|
if (node.typeRef !== null) {
|
|
553
555
|
// Resolve TypeRef and validate against the declared type
|
|
554
556
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
555
|
-
const resolved = this.resolveTypeRef(node.typeRef, (name) => getVariable(this.ctx, name));
|
|
557
|
+
const resolved = await this.resolveTypeRef(node.typeRef, (name) => getVariable(this.ctx, name));
|
|
556
558
|
this.setVariable(node.name, input, resolved.structure, node.span.start);
|
|
557
559
|
}
|
|
558
560
|
else {
|
|
@@ -578,4 +580,3 @@ function createVariablesMixin(Base) {
|
|
|
578
580
|
// TypeScript can't generate declarations for functions returning classes with protected members
|
|
579
581
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
580
582
|
export const VariablesMixin = createVariablesMixin;
|
|
581
|
-
//# sourceMappingURL=variables.js.map
|
|
@@ -38,4 +38,3 @@ export type EvaluatorConstructor<TBase extends EvaluatorBase = EvaluatorBase> =
|
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export type Mixin<TBase extends EvaluatorBase = EvaluatorBase, TExtension extends TBase = TBase> = (Base: EvaluatorConstructor<TBase>) => EvaluatorConstructor<TExtension>;
|
|
41
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -23,4 +23,3 @@ export declare function execute(script: ScriptNode, context: RuntimeContext): Pr
|
|
|
23
23
|
* @returns A stepper for step-by-step execution
|
|
24
24
|
*/
|
|
25
25
|
export declare function createStepper(script: ScriptNode, context: RuntimeContext): ExecutionStepper;
|
|
26
|
-
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
import type { SourceLocation } from '../../types.js';
|
|
11
|
-
import type {
|
|
11
|
+
import type { RillFieldDef, TypeStructure } from './values.js';
|
|
12
12
|
/**
|
|
13
13
|
* Field descriptor — carries field name and structural type when accessing a
|
|
14
14
|
* dict-kind RillType field.
|
|
@@ -16,14 +16,13 @@ import type { RillFieldType, RillType } from './values.js';
|
|
|
16
16
|
export interface RillFieldDescriptor {
|
|
17
17
|
readonly __rill_field_descriptor: true;
|
|
18
18
|
readonly fieldName: string;
|
|
19
|
-
readonly fieldType:
|
|
19
|
+
readonly fieldType: RillFieldDef;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Build a frozen RillFieldDescriptor for the given field in a structural dict type.
|
|
23
23
|
*
|
|
24
24
|
* EC-1: Throws RILL-R003 when fieldName is absent from structuralType.fields.
|
|
25
25
|
*/
|
|
26
|
-
export declare function buildFieldDescriptor(structuralType:
|
|
27
|
-
|
|
26
|
+
export declare function buildFieldDescriptor(structuralType: TypeStructure & {
|
|
27
|
+
kind: 'dict';
|
|
28
28
|
}, fieldName: string, location: SourceLocation): RillFieldDescriptor;
|
|
29
|
-
//# sourceMappingURL=field-descriptor.d.ts.map
|
|
@@ -14,7 +14,8 @@ import { RuntimeError } from '../../types.js';
|
|
|
14
14
|
* EC-1: Throws RILL-R003 when fieldName is absent from structuralType.fields.
|
|
15
15
|
*/
|
|
16
16
|
export function buildFieldDescriptor(structuralType, fieldName, location) {
|
|
17
|
-
const
|
|
17
|
+
const fields = structuralType.fields;
|
|
18
|
+
const fieldType = fields?.[fieldName];
|
|
18
19
|
if (fieldType === undefined) {
|
|
19
20
|
throw new RuntimeError('RILL-R003', `Shape has no field "${fieldName}"`, location);
|
|
20
21
|
}
|
|
@@ -24,4 +25,3 @@ export function buildFieldDescriptor(structuralType, fieldName, location) {
|
|
|
24
25
|
fieldType,
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
//# sourceMappingURL=field-descriptor.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Functions for inspecting runtime context at runtime.
|
|
5
5
|
* These enable host applications to discover available functions and their signatures.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { formatStructure, formatValue } from './values.js';
|
|
8
8
|
import { isApplicationCallable, isRuntimeCallable, isScriptCallable, } from './callable.js';
|
|
9
9
|
import { LANGUAGE_REFERENCE } from '../../generated/introspection-data.js';
|
|
10
10
|
import { BUILTIN_FUNCTIONS } from '../ext/builtins.js';
|
|
@@ -40,7 +40,7 @@ export function getFunctions(ctx) {
|
|
|
40
40
|
if (callable.params) {
|
|
41
41
|
const params = callable.params.map((p) => ({
|
|
42
42
|
name: p.name,
|
|
43
|
-
type: p.type !== undefined ?
|
|
43
|
+
type: p.type !== undefined ? formatStructure(p.type) : 'any',
|
|
44
44
|
description: typeof p.annotations['description'] === 'string'
|
|
45
45
|
? p.annotations['description']
|
|
46
46
|
: '',
|
|
@@ -50,7 +50,7 @@ export function getFunctions(ctx) {
|
|
|
50
50
|
name,
|
|
51
51
|
description: callable.annotations?.['description'] ?? '',
|
|
52
52
|
params,
|
|
53
|
-
returnType:
|
|
53
|
+
returnType: formatStructure(callable.returnType.structure),
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -93,7 +93,7 @@ export function getFunctions(ctx) {
|
|
|
93
93
|
// Convert params to ParamMetadata using RillParam.type (IC-5)
|
|
94
94
|
const params = value.params.map((p) => ({
|
|
95
95
|
name: p.name,
|
|
96
|
-
type: p.type !== undefined ?
|
|
96
|
+
type: p.type !== undefined ? formatStructure(p.type) : 'any',
|
|
97
97
|
description: typeof p.annotations['description'] === 'string'
|
|
98
98
|
? p.annotations['description']
|
|
99
99
|
: '',
|
|
@@ -131,7 +131,7 @@ function serializeParam(p) {
|
|
|
131
131
|
parts.push(`^(description: "${desc}") `);
|
|
132
132
|
}
|
|
133
133
|
// Name and type
|
|
134
|
-
const typeName = p.type !== undefined ?
|
|
134
|
+
const typeName = p.type !== undefined ? formatStructure(p.type) : 'any';
|
|
135
135
|
parts.push(`${p.name}: ${typeName}`);
|
|
136
136
|
// Default value
|
|
137
137
|
if (p.defaultValue !== undefined) {
|
|
@@ -189,7 +189,7 @@ export function generateManifest(ctx) {
|
|
|
189
189
|
if (!isApplicationCallable(callable) || callable.params === undefined) {
|
|
190
190
|
continue;
|
|
191
191
|
}
|
|
192
|
-
const signature = serializeClosureSignature(callable.params,
|
|
192
|
+
const signature = serializeClosureSignature(callable.params, formatStructure(callable.returnType.structure), callable.annotations?.['description'] ?? undefined);
|
|
193
193
|
entries.push(` "${name}": ${signature}`);
|
|
194
194
|
}
|
|
195
195
|
if (entries.length === 0) {
|
|
@@ -252,4 +252,3 @@ export function getDocumentationCoverage(ctx) {
|
|
|
252
252
|
export function getLanguageReference() {
|
|
253
253
|
return LANGUAGE_REFERENCE;
|
|
254
254
|
}
|
|
255
|
-
//# sourceMappingURL=introspection.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared marker interfaces for forward declarations.
|
|
3
|
+
*
|
|
4
|
+
* These interfaces break circular dependencies between values.ts,
|
|
5
|
+
* type-structures.ts, and callable.ts. Actual types are defined in callable.ts.
|
|
6
|
+
*/
|
|
7
|
+
export interface CallableMarker {
|
|
8
|
+
readonly __type: 'callable';
|
|
9
|
+
}
|
|
10
|
+
export interface FieldDescriptorMarker {
|
|
11
|
+
readonly __rill_field_descriptor: true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Registration Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the TypeDefinition interface, TypeProtocol interface, and
|
|
5
|
+
* BUILT_IN_TYPES registration array. Each of the 12 built-in types
|
|
6
|
+
* carries identity predicates, protocol functions (format, eq, compare,
|
|
7
|
+
* convertTo, serialize), and a methods record populated from BUILTIN_METHODS.
|
|
8
|
+
*
|
|
9
|
+
* Dispatch functions (inferType, formatValue, deepEquals, serializeValue,
|
|
10
|
+
* deserializeValue, copyValue) iterate registrations and delegate to
|
|
11
|
+
* per-type protocol implementations.
|
|
12
|
+
*
|
|
13
|
+
* Registration order:
|
|
14
|
+
* primitives -> discriminator-based -> structural -> list -> dict fallback
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
import type { TypeStructure, RillValue, RillFieldDef, RillTuple, RillOrdered, RillVector, RillTypeValue, RillIterator } from './values.js';
|
|
19
|
+
import type { RillFunction } from './callable.js';
|
|
20
|
+
import { isTuple, isVector, isOrdered, isTypeValue, isIterator, createTuple, createOrdered, createVector } from './values.js';
|
|
21
|
+
/**
|
|
22
|
+
* Protocol functions that define per-type behavior.
|
|
23
|
+
* Every type must provide `format`. All other protocols are optional.
|
|
24
|
+
*/
|
|
25
|
+
export interface TypeProtocol {
|
|
26
|
+
format: (v: RillValue) => string;
|
|
27
|
+
structure?: ((v: RillValue) => TypeStructure) | undefined;
|
|
28
|
+
eq?: ((a: RillValue, b: RillValue) => boolean) | undefined;
|
|
29
|
+
compare?: ((a: RillValue, b: RillValue) => number) | undefined;
|
|
30
|
+
convertTo?: Record<string, (v: RillValue) => RillValue> | undefined;
|
|
31
|
+
serialize?: ((v: RillValue) => unknown) | undefined;
|
|
32
|
+
deserialize?: ((data: unknown) => RillValue) | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A single type registration record. Each of the 12 built-in types
|
|
36
|
+
* has exactly one TypeDefinition in the BUILT_IN_TYPES array.
|
|
37
|
+
*/
|
|
38
|
+
export interface TypeDefinition {
|
|
39
|
+
name: string;
|
|
40
|
+
identity: (v: RillValue) => boolean;
|
|
41
|
+
isLeaf: boolean;
|
|
42
|
+
immutable: boolean;
|
|
43
|
+
methods: Record<string, RillFunction>;
|
|
44
|
+
protocol: TypeProtocol;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* All 12 built-in type registrations.
|
|
48
|
+
*
|
|
49
|
+
* Registration order:
|
|
50
|
+
* 1. Primitives: string, number, bool
|
|
51
|
+
* 2. Discriminator-based: tuple, ordered, vector, type, closure, field_descriptor
|
|
52
|
+
* 3. Structural: iterator
|
|
53
|
+
* 4. list
|
|
54
|
+
* 5. dict (fallback, must be last)
|
|
55
|
+
*
|
|
56
|
+
* AC-1: 12 registrations, one per type.
|
|
57
|
+
* BC-2: Vector identity checked before dict fallback.
|
|
58
|
+
* EC-3: Iterator has no protocol.eq.
|
|
59
|
+
* EC-4: Bool has no protocol.compare.
|
|
60
|
+
* EC-8: Non-serializable types throw plain Error.
|
|
61
|
+
*/
|
|
62
|
+
export declare const BUILT_IN_TYPES: readonly TypeDefinition[];
|
|
63
|
+
/**
|
|
64
|
+
* Infer the Rill type name from a runtime value.
|
|
65
|
+
* Iterates registrations in order; returns first matching name.
|
|
66
|
+
* Returns 'string' as fallback (BC-1: null IS type string, not a coercion).
|
|
67
|
+
*
|
|
68
|
+
* IR-2: Return type widens from RillTypeName to string for extensibility.
|
|
69
|
+
*/
|
|
70
|
+
export declare function inferType(value: RillValue): string;
|
|
71
|
+
/**
|
|
72
|
+
* Format a value as a human-readable string.
|
|
73
|
+
* Determines type via inferType, then calls protocol.format.
|
|
74
|
+
* Falls back to String(value) when no registration matches.
|
|
75
|
+
*
|
|
76
|
+
* IR-3: Protocol dispatcher for formatting.
|
|
77
|
+
*/
|
|
78
|
+
export declare function formatValue(value: RillValue): string;
|
|
79
|
+
/**
|
|
80
|
+
* Deep equality comparison for two Rill values.
|
|
81
|
+
* Short-circuit: a === b returns true.
|
|
82
|
+
* Dispatches to left operand's protocol.eq.
|
|
83
|
+
* No protocol.eq returns false.
|
|
84
|
+
*
|
|
85
|
+
* IR-4: Container protocol.eq calls deepEquals recursively.
|
|
86
|
+
*/
|
|
87
|
+
export declare function deepEquals(a: RillValue, b: RillValue): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Serialize a Rill value for JSON transport.
|
|
90
|
+
* Dispatches to protocol.serialize; container types recurse.
|
|
91
|
+
*
|
|
92
|
+
* IR-7: Renamed from valueToJSON.
|
|
93
|
+
*/
|
|
94
|
+
export declare function serializeValue(value: RillValue): unknown;
|
|
95
|
+
/**
|
|
96
|
+
* Deserialize raw data into a Rill value.
|
|
97
|
+
* Dispatches to protocol.deserialize for the given type name.
|
|
98
|
+
* Falls back to raw value when no protocol.deserialize exists (primitives).
|
|
99
|
+
*
|
|
100
|
+
* IR-8: Raw value fallback rejects null/undefined inputs with RILL-R004.
|
|
101
|
+
* EC-9: Invalid data raises RILL-R004.
|
|
102
|
+
* EC-10: null/undefined input raises RILL-R004.
|
|
103
|
+
*/
|
|
104
|
+
export declare function deserializeValue(data: unknown, typeName: string): RillValue;
|
|
105
|
+
/**
|
|
106
|
+
* Copy a Rill value.
|
|
107
|
+
* Reads immutable flag from registration.
|
|
108
|
+
* Immutable types return same reference.
|
|
109
|
+
* Mutable types (list, dict, iterator) recurse.
|
|
110
|
+
*
|
|
111
|
+
* IR-9: Renamed from deepCopyRillValue.
|
|
112
|
+
*/
|
|
113
|
+
export declare function copyValue(value: RillValue): RillValue;
|
|
114
|
+
/**
|
|
115
|
+
* Populate registration `methods` fields from BUILTIN_METHODS.
|
|
116
|
+
*
|
|
117
|
+
* Called after builtins.ts finishes initialization to avoid circular
|
|
118
|
+
* dependency at module load time. The 6 method-bearing types (string,
|
|
119
|
+
* number, bool, list, dict, vector) receive their methods records;
|
|
120
|
+
* other types keep `methods: {}`.
|
|
121
|
+
*
|
|
122
|
+
* AC-3: Consolidates method data into registrations.
|
|
123
|
+
*
|
|
124
|
+
* MUTATION NOTE: BUILT_IN_TYPES is shallow-frozen (the array), but each
|
|
125
|
+
* registration object is mutable. This function relies on that mutability.
|
|
126
|
+
* If registration objects are ever deep-frozen (e.g. Object.freeze(reg)),
|
|
127
|
+
* this assignment will throw in strict mode. The runtime guard below catches
|
|
128
|
+
* that condition early with a clear error rather than a silent no-op.
|
|
129
|
+
*/
|
|
130
|
+
export declare function populateBuiltinMethods(builtinMethods: Record<string, Record<string, RillFunction>>): void;
|
|
131
|
+
export { createTuple, createOrdered, createVector };
|
|
132
|
+
export { isTuple, isVector, isTypeValue, isOrdered, isIterator };
|
|
133
|
+
/** @deprecated Use isIterator instead. */
|
|
134
|
+
export declare const isRillIterator: typeof isIterator;
|
|
135
|
+
export type { TypeStructure };
|
|
136
|
+
export type { RillValue, RillTuple, RillOrdered, RillVector, RillTypeValue, RillIterator, RillFieldDef, };
|