@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
|
@@ -56,7 +56,13 @@ Parser.prototype.parseUseExpr = function () {
|
|
|
56
56
|
let typeRef = null;
|
|
57
57
|
let closureAnnotation = null;
|
|
58
58
|
if (check(this.state, TOKEN_TYPES.COLON)) {
|
|
59
|
-
if (peek(this.state, 1).type === TOKEN_TYPES.
|
|
59
|
+
if (peek(this.state, 1).type === TOKEN_TYPES.OR) {
|
|
60
|
+
// Zero-param closure annotation: :||
|
|
61
|
+
advance(this.state); // consume :
|
|
62
|
+
advance(this.state); // consume || (OR token)
|
|
63
|
+
closureAnnotation = [];
|
|
64
|
+
}
|
|
65
|
+
else if (peek(this.state, 1).type === TOKEN_TYPES.PIPE_BAR) {
|
|
60
66
|
// Closure annotation: :|param: type, ...|
|
|
61
67
|
advance(this.state); // consume :
|
|
62
68
|
advance(this.state); // consume opening |
|
|
@@ -93,4 +99,3 @@ Parser.prototype.parseUseExpr = function () {
|
|
|
93
99
|
span: makeSpan(start, current(this.state).span.end),
|
|
94
100
|
};
|
|
95
101
|
};
|
|
96
|
-
//# sourceMappingURL=parser-use.js.map
|
package/dist/parser/parser.d.ts
CHANGED
package/dist/parser/parser.js
CHANGED
package/dist/parser/state.d.ts
CHANGED
|
@@ -43,4 +43,3 @@ export declare function skipNewlines(state: ParserState): void;
|
|
|
43
43
|
export declare function skipNewlinesIfFollowedBy(state: ParserState, tokenType: string): boolean;
|
|
44
44
|
/** @internal */
|
|
45
45
|
export declare function makeSpan(start: SourceLocation, end: SourceLocation): SourceSpan;
|
|
46
|
-
//# sourceMappingURL=state.d.ts.map
|
package/dist/parser/state.js
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
*
|
|
18
18
|
* [ASSUMPTION] validateDefaultValueType _functionName Parameter
|
|
19
19
|
* - Parameter accepted but unused (prefixed with _ to satisfy eslint)
|
|
20
|
-
* - Kept for API consistency with
|
|
20
|
+
* - Kept for API consistency with marshalArgs signature
|
|
21
21
|
*/
|
|
22
22
|
import type { BodyNode, SourceLocation } from '../../types.js';
|
|
23
|
-
import type {
|
|
23
|
+
import type { TypeStructure, RillTypeValue, RillValue } from './values.js';
|
|
24
24
|
interface RuntimeContextLike {
|
|
25
25
|
readonly parent?: RuntimeContextLike | undefined;
|
|
26
26
|
readonly variables: Map<string, RillValue>;
|
|
@@ -31,7 +31,7 @@ interface RuntimeContextLike {
|
|
|
31
31
|
* Callable function signature.
|
|
32
32
|
* Used for both host-provided functions and runtime callables.
|
|
33
33
|
*/
|
|
34
|
-
export type CallableFn = (args:
|
|
34
|
+
export type CallableFn = (args: Record<string, RillValue>, ctx: RuntimeContextLike, location?: SourceLocation) => RillValue | Promise<RillValue>;
|
|
35
35
|
/**
|
|
36
36
|
* Unified parameter definition for all callable types (script closures and host functions).
|
|
37
37
|
*
|
|
@@ -42,7 +42,7 @@ export type CallableFn = (args: RillValue[], ctx: RuntimeContextLike, location?:
|
|
|
42
42
|
*/
|
|
43
43
|
export interface RillParam {
|
|
44
44
|
readonly name: string;
|
|
45
|
-
readonly type:
|
|
45
|
+
readonly type: TypeStructure | undefined;
|
|
46
46
|
readonly defaultValue: RillValue | undefined;
|
|
47
47
|
readonly annotations: Record<string, RillValue>;
|
|
48
48
|
}
|
|
@@ -57,6 +57,8 @@ export interface RillFunction {
|
|
|
57
57
|
readonly fn: CallableFn;
|
|
58
58
|
readonly annotations?: Record<string, RillValue>;
|
|
59
59
|
readonly returnType: RillTypeValue;
|
|
60
|
+
/** When true, RILL-R003 generic receiver validation is skipped for this method. */
|
|
61
|
+
readonly skipReceiverValidation?: boolean;
|
|
60
62
|
}
|
|
61
63
|
/** Common fields for all callable types */
|
|
62
64
|
interface CallableBase {
|
|
@@ -112,6 +114,16 @@ export declare function isApplicationCallable(value: RillValue): value is Applic
|
|
|
112
114
|
* @param isProperty If true, auto-invokes when accessed from dict (property-style)
|
|
113
115
|
*/
|
|
114
116
|
export declare function callable(fn: CallableFn, isProperty?: boolean): ApplicationCallable;
|
|
117
|
+
/**
|
|
118
|
+
* Convert a RillFunction to an ApplicationCallable.
|
|
119
|
+
*
|
|
120
|
+
* Validates the input and produces a callable value accepted by the loader.
|
|
121
|
+
* Pure function with no side effects.
|
|
122
|
+
*
|
|
123
|
+
* @param def - Host function definition to convert
|
|
124
|
+
* @returns ApplicationCallable with __type, kind, isProperty, and preserved annotations
|
|
125
|
+
*/
|
|
126
|
+
export declare function toCallable(def: RillFunction, isProperty?: boolean): ApplicationCallable;
|
|
115
127
|
/** Type guard for dict (plain object, not array, not callable, not tuple) */
|
|
116
128
|
export declare function isDict(value: RillValue): value is Record<string, RillValue>;
|
|
117
129
|
/** Format a callable for display */
|
|
@@ -129,19 +141,19 @@ export declare function formatCallable(callable: RillCallable): string;
|
|
|
129
141
|
*/
|
|
130
142
|
export declare function callableEquals(a: ScriptCallable, b: ScriptCallable, valueEquals?: (a: RillValue, b: RillValue) => boolean): boolean;
|
|
131
143
|
/**
|
|
132
|
-
* Build a
|
|
144
|
+
* Build a TypeStructure closure variant from a closure's parameter list.
|
|
133
145
|
*
|
|
134
146
|
* Called at closure creation time to build the structural type for `$fn.^input`.
|
|
135
147
|
* - Typed params use param.type directly when present
|
|
136
|
-
* - Untyped params (type: undefined) map to {
|
|
137
|
-
* - Return type is always {
|
|
148
|
+
* - Untyped params (type: undefined) map to { kind: 'any' }
|
|
149
|
+
* - Return type is always { kind: 'any' }
|
|
138
150
|
*
|
|
139
151
|
* No validation: parser already validates type names.
|
|
140
152
|
*
|
|
141
153
|
* @param params - Closure parameter definitions (RillParam[])
|
|
142
|
-
* @returns Frozen
|
|
154
|
+
* @returns Frozen TypeStructure with closure variant
|
|
143
155
|
*/
|
|
144
|
-
export declare function paramsToStructuralType(params: readonly RillParam[]):
|
|
156
|
+
export declare function paramsToStructuralType(params: readonly RillParam[]): TypeStructure;
|
|
145
157
|
/**
|
|
146
158
|
* Validate defaultValue type matches declared parameter type.
|
|
147
159
|
*
|
|
@@ -154,19 +166,46 @@ export declare function paramsToStructuralType(params: readonly RillParam[]): Ri
|
|
|
154
166
|
*/
|
|
155
167
|
export declare function validateDefaultValueType(param: RillParam, _functionName: string): void;
|
|
156
168
|
/**
|
|
157
|
-
*
|
|
169
|
+
* Options for marshalArgs error reporting.
|
|
170
|
+
*/
|
|
171
|
+
export interface MarshalOptions {
|
|
172
|
+
/** Function name included in error messages */
|
|
173
|
+
readonly functionName: string;
|
|
174
|
+
/** Source location for error reporting */
|
|
175
|
+
readonly location: SourceLocation | undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Hydrate missing dict/ordered field-level defaults into a value.
|
|
179
|
+
*
|
|
180
|
+
* When a param has type `dict(a: string = "x", b: number)` and the caller
|
|
181
|
+
* passes `[b: 2]`, this fills in `a` with its default `"x"`. Fields without
|
|
182
|
+
* defaults are left absent so Stage 3 catches them with RILL-R001.
|
|
183
|
+
*
|
|
184
|
+
* Pure function: no class context, no evaluator, no side effects.
|
|
185
|
+
*/
|
|
186
|
+
export declare function hydrateFieldDefaults(value: RillValue, type: TypeStructure): RillValue;
|
|
187
|
+
/**
|
|
188
|
+
* Unified marshaling entry point for all 3 invocation paths.
|
|
189
|
+
*
|
|
190
|
+
* Builds a named argument map from positional args, hydrates defaults,
|
|
191
|
+
* type-checks each field, and returns a Record<string, RillValue>.
|
|
192
|
+
*
|
|
193
|
+
* Stages:
|
|
194
|
+
* 1. Excess args check (RILL-R045)
|
|
195
|
+
* 2. Default hydration + missing required check (RILL-R044)
|
|
196
|
+
* 2.5. Dict/ordered field-level default hydration
|
|
197
|
+
* 3. Type check per field (RILL-R001)
|
|
158
198
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
199
|
+
* Preconditions (enforced by caller):
|
|
200
|
+
* - args contains already-evaluated RillValue[]
|
|
201
|
+
* - pipe value already inserted as first element by caller
|
|
202
|
+
* - boundDict already prepended as first element by caller
|
|
203
|
+
* - params is defined (caller skips marshalArgs for untyped callables)
|
|
163
204
|
*
|
|
164
|
-
* @param args -
|
|
205
|
+
* @param args - Positional arguments (already evaluated)
|
|
165
206
|
* @param params - Parameter definitions
|
|
166
|
-
* @param
|
|
167
|
-
* @
|
|
168
|
-
* @throws RuntimeError with RILL-R001 on validation failure
|
|
207
|
+
* @param options - Error context: functionName and location
|
|
208
|
+
* @returns Named argument map keyed by param name
|
|
169
209
|
*/
|
|
170
|
-
export declare function
|
|
210
|
+
export declare function marshalArgs(args: RillValue[], params: readonly RillParam[], options?: MarshalOptions): Record<string, RillValue>;
|
|
171
211
|
export {};
|
|
172
|
-
//# sourceMappingURL=callable.d.ts.map
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*
|
|
18
18
|
* [ASSUMPTION] validateDefaultValueType _functionName Parameter
|
|
19
19
|
* - Parameter accepted but unused (prefixed with _ to satisfy eslint)
|
|
20
|
-
* - Kept for API consistency with
|
|
20
|
+
* - Kept for API consistency with marshalArgs signature
|
|
21
21
|
*/
|
|
22
22
|
import { RuntimeError } from '../../types.js';
|
|
23
23
|
import { astEquals } from './equals.js';
|
|
24
|
-
import { formatValue,
|
|
24
|
+
import { formatValue, formatStructure, inferType, isOrdered, createOrdered, copyValue, isTuple, paramToFieldDef, structureEquals, structureMatches, anyTypeValue, hasCollectionFields, emptyForType, } from './values.js';
|
|
25
25
|
/** Type guard for any callable */
|
|
26
26
|
export function isCallable(value) {
|
|
27
27
|
return (typeof value === 'object' &&
|
|
@@ -61,6 +61,35 @@ export function callable(fn, isProperty = false) {
|
|
|
61
61
|
isProperty,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Convert a RillFunction to an ApplicationCallable.
|
|
66
|
+
*
|
|
67
|
+
* Validates the input and produces a callable value accepted by the loader.
|
|
68
|
+
* Pure function with no side effects.
|
|
69
|
+
*
|
|
70
|
+
* @param def - Host function definition to convert
|
|
71
|
+
* @returns ApplicationCallable with __type, kind, isProperty, and preserved annotations
|
|
72
|
+
*/
|
|
73
|
+
export function toCallable(def, isProperty = false) {
|
|
74
|
+
if (def == null) {
|
|
75
|
+
throw new TypeError('RillFunction cannot be null or undefined');
|
|
76
|
+
}
|
|
77
|
+
if (typeof def.fn !== 'function') {
|
|
78
|
+
throw new TypeError('RillFunction.fn must be a function');
|
|
79
|
+
}
|
|
80
|
+
if (!Array.isArray(def.params)) {
|
|
81
|
+
throw new TypeError('RillFunction.params must be an array');
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
__type: 'callable',
|
|
85
|
+
kind: 'application',
|
|
86
|
+
isProperty,
|
|
87
|
+
fn: def.fn,
|
|
88
|
+
params: def.params,
|
|
89
|
+
returnType: def.returnType,
|
|
90
|
+
annotations: def.annotations ?? {},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
64
93
|
/** Type guard for dict (plain object, not array, not callable, not tuple) */
|
|
65
94
|
export function isDict(value) {
|
|
66
95
|
return (typeof value === 'object' &&
|
|
@@ -116,14 +145,14 @@ export function callableEquals(a, b, valueEquals = (x, y) => formatValue(x) ===
|
|
|
116
145
|
return false;
|
|
117
146
|
if (ap.name !== bp.name)
|
|
118
147
|
return false;
|
|
119
|
-
// Compare type via
|
|
148
|
+
// Compare type via structureEquals; absent type (any-typed) matches absent type
|
|
120
149
|
if (ap.type === undefined && bp.type !== undefined)
|
|
121
150
|
return false;
|
|
122
151
|
if (ap.type !== undefined && bp.type === undefined)
|
|
123
152
|
return false;
|
|
124
153
|
if (ap.type !== undefined &&
|
|
125
154
|
bp.type !== undefined &&
|
|
126
|
-
!
|
|
155
|
+
!structureEquals(ap.type, bp.type))
|
|
127
156
|
return false;
|
|
128
157
|
if (!valueEquals(ap.defaultValue ?? null, bp.defaultValue ?? null)) {
|
|
129
158
|
return false;
|
|
@@ -146,24 +175,24 @@ export function callableEquals(a, b, valueEquals = (x, y) => formatValue(x) ===
|
|
|
146
175
|
return true;
|
|
147
176
|
}
|
|
148
177
|
/**
|
|
149
|
-
* Build a
|
|
178
|
+
* Build a TypeStructure closure variant from a closure's parameter list.
|
|
150
179
|
*
|
|
151
180
|
* Called at closure creation time to build the structural type for `$fn.^input`.
|
|
152
181
|
* - Typed params use param.type directly when present
|
|
153
|
-
* - Untyped params (type: undefined) map to {
|
|
154
|
-
* - Return type is always {
|
|
182
|
+
* - Untyped params (type: undefined) map to { kind: 'any' }
|
|
183
|
+
* - Return type is always { kind: 'any' }
|
|
155
184
|
*
|
|
156
185
|
* No validation: parser already validates type names.
|
|
157
186
|
*
|
|
158
187
|
* @param params - Closure parameter definitions (RillParam[])
|
|
159
|
-
* @returns Frozen
|
|
188
|
+
* @returns Frozen TypeStructure with closure variant
|
|
160
189
|
*/
|
|
161
190
|
export function paramsToStructuralType(params) {
|
|
162
|
-
const closureParams = params.map((param) =>
|
|
191
|
+
const closureParams = params.map((param) => paramToFieldDef(param.name, param.type ?? { kind: 'any' }, param.defaultValue));
|
|
163
192
|
return Object.freeze({
|
|
164
|
-
|
|
193
|
+
kind: 'closure',
|
|
165
194
|
params: closureParams,
|
|
166
|
-
ret: {
|
|
195
|
+
ret: { kind: 'any' },
|
|
167
196
|
});
|
|
168
197
|
}
|
|
169
198
|
/**
|
|
@@ -182,61 +211,180 @@ export function validateDefaultValueType(param, _functionName) {
|
|
|
182
211
|
// Skip validation when type is undefined (any-typed, all defaults valid)
|
|
183
212
|
if (param.type === undefined)
|
|
184
213
|
return;
|
|
185
|
-
if (!
|
|
214
|
+
if (!structureMatches(param.defaultValue, param.type)) {
|
|
186
215
|
const actualType = inferType(param.defaultValue);
|
|
187
|
-
const expectedType =
|
|
216
|
+
const expectedType = formatStructure(param.type);
|
|
188
217
|
throw new Error(`Invalid defaultValue for parameter '${param.name}': expected ${expectedType}, got ${actualType}`);
|
|
189
218
|
}
|
|
190
219
|
}
|
|
191
220
|
/**
|
|
192
|
-
*
|
|
221
|
+
* Hydrate missing dict/ordered field-level defaults into a value.
|
|
222
|
+
*
|
|
223
|
+
* When a param has type `dict(a: string = "x", b: number)` and the caller
|
|
224
|
+
* passes `[b: 2]`, this fills in `a` with its default `"x"`. Fields without
|
|
225
|
+
* defaults are left absent so Stage 3 catches them with RILL-R001.
|
|
226
|
+
*
|
|
227
|
+
* Pure function: no class context, no evaluator, no side effects.
|
|
228
|
+
*/
|
|
229
|
+
export function hydrateFieldDefaults(value, type) {
|
|
230
|
+
if (type.kind === 'dict' && type.fields && isDict(value)) {
|
|
231
|
+
const t = type;
|
|
232
|
+
const dictValue = value;
|
|
233
|
+
// Seed with all input entries so extra keys survive (structural match allows extras)
|
|
234
|
+
const result = { ...dictValue };
|
|
235
|
+
for (const [fieldName, fieldDef] of Object.entries(t.fields)) {
|
|
236
|
+
if (fieldName in dictValue) {
|
|
237
|
+
result[fieldName] = hydrateFieldDefaults(dictValue[fieldName], fieldDef.type);
|
|
238
|
+
}
|
|
239
|
+
else if (fieldDef.defaultValue !== undefined) {
|
|
240
|
+
result[fieldName] = hydrateFieldDefaults(copyValue(fieldDef.defaultValue), fieldDef.type);
|
|
241
|
+
}
|
|
242
|
+
else if (hasCollectionFields(fieldDef.type)) {
|
|
243
|
+
result[fieldName] = hydrateFieldDefaults(emptyForType(fieldDef.type), fieldDef.type);
|
|
244
|
+
}
|
|
245
|
+
// Missing without default and not collection: leave absent for Stage 3
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
if (type.kind === 'ordered' &&
|
|
250
|
+
type.fields &&
|
|
251
|
+
isOrdered(value)) {
|
|
252
|
+
const t = type;
|
|
253
|
+
const lookup = new Map(value.entries.map(([k, v]) => [k, v]));
|
|
254
|
+
const fieldNames = new Set(t.fields.map((f) => f.name ?? ''));
|
|
255
|
+
const resultEntries = [];
|
|
256
|
+
for (const field of t.fields) {
|
|
257
|
+
const name = field.name ?? '';
|
|
258
|
+
if (lookup.has(name)) {
|
|
259
|
+
resultEntries.push([
|
|
260
|
+
name,
|
|
261
|
+
hydrateFieldDefaults(lookup.get(name), field.type),
|
|
262
|
+
]);
|
|
263
|
+
}
|
|
264
|
+
else if (field.defaultValue !== undefined) {
|
|
265
|
+
resultEntries.push([
|
|
266
|
+
name,
|
|
267
|
+
hydrateFieldDefaults(copyValue(field.defaultValue), field.type),
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
270
|
+
else if (hasCollectionFields(field.type)) {
|
|
271
|
+
resultEntries.push([
|
|
272
|
+
name,
|
|
273
|
+
hydrateFieldDefaults(emptyForType(field.type), field.type),
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
// Missing without default and not collection: leave absent for Stage 3
|
|
277
|
+
}
|
|
278
|
+
// Append extra entries not declared in type.fields (structural match allows extras)
|
|
279
|
+
for (const [k, v] of value.entries) {
|
|
280
|
+
if (!fieldNames.has(k)) {
|
|
281
|
+
resultEntries.push([k, v]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return createOrdered(resultEntries);
|
|
285
|
+
}
|
|
286
|
+
if (type.kind === 'tuple' &&
|
|
287
|
+
type.elements &&
|
|
288
|
+
isTuple(value)) {
|
|
289
|
+
const elements = type.elements;
|
|
290
|
+
const entries = value.entries;
|
|
291
|
+
// All fields present: recurse into nested types for present positions
|
|
292
|
+
if (entries.length >= elements.length) {
|
|
293
|
+
const resultEntries = elements.map((el, i) => hydrateFieldDefaults(entries[i], el.type));
|
|
294
|
+
// Preserve any extra trailing entries beyond the type definition
|
|
295
|
+
for (let i = elements.length; i < entries.length; i++) {
|
|
296
|
+
resultEntries.push(entries[i]);
|
|
297
|
+
}
|
|
298
|
+
return { __rill_tuple: true, entries: resultEntries };
|
|
299
|
+
}
|
|
300
|
+
// Value shorter: fill missing trailing positions with defaults
|
|
301
|
+
const resultEntries = [];
|
|
302
|
+
for (let i = 0; i < elements.length; i++) {
|
|
303
|
+
const el = elements[i];
|
|
304
|
+
if (i < entries.length) {
|
|
305
|
+
resultEntries.push(hydrateFieldDefaults(entries[i], el.type));
|
|
306
|
+
}
|
|
307
|
+
else if (el.defaultValue !== undefined) {
|
|
308
|
+
resultEntries.push(hydrateFieldDefaults(copyValue(el.defaultValue), el.type));
|
|
309
|
+
}
|
|
310
|
+
else if (hasCollectionFields(el.type)) {
|
|
311
|
+
resultEntries.push(hydrateFieldDefaults(emptyForType(el.type), el.type));
|
|
312
|
+
}
|
|
313
|
+
// Missing without default and not collection: leave absent (shorter tuple) for Stage 3
|
|
314
|
+
}
|
|
315
|
+
return { __rill_tuple: true, entries: resultEntries };
|
|
316
|
+
}
|
|
317
|
+
return value;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Unified marshaling entry point for all 3 invocation paths.
|
|
193
321
|
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* Skips type check when param.type is undefined (any-typed).
|
|
197
|
-
* Applies defaultValue in-place on the args array before validation.
|
|
322
|
+
* Builds a named argument map from positional args, hydrates defaults,
|
|
323
|
+
* type-checks each field, and returns a Record<string, RillValue>.
|
|
198
324
|
*
|
|
199
|
-
*
|
|
325
|
+
* Stages:
|
|
326
|
+
* 1. Excess args check (RILL-R045)
|
|
327
|
+
* 2. Default hydration + missing required check (RILL-R044)
|
|
328
|
+
* 2.5. Dict/ordered field-level default hydration
|
|
329
|
+
* 3. Type check per field (RILL-R001)
|
|
330
|
+
*
|
|
331
|
+
* Preconditions (enforced by caller):
|
|
332
|
+
* - args contains already-evaluated RillValue[]
|
|
333
|
+
* - pipe value already inserted as first element by caller
|
|
334
|
+
* - boundDict already prepended as first element by caller
|
|
335
|
+
* - params is defined (caller skips marshalArgs for untyped callables)
|
|
336
|
+
*
|
|
337
|
+
* @param args - Positional arguments (already evaluated)
|
|
200
338
|
* @param params - Parameter definitions
|
|
201
|
-
* @param
|
|
202
|
-
* @
|
|
203
|
-
* @throws RuntimeError with RILL-R001 on validation failure
|
|
339
|
+
* @param options - Error context: functionName and location
|
|
340
|
+
* @returns Named argument map keyed by param name
|
|
204
341
|
*/
|
|
205
|
-
export function
|
|
206
|
-
|
|
342
|
+
export function marshalArgs(args, params, options) {
|
|
343
|
+
const functionName = options?.functionName ?? '<anonymous>';
|
|
344
|
+
const location = options?.location;
|
|
345
|
+
// Stage 1: Excess args check
|
|
207
346
|
if (args.length > params.length) {
|
|
208
|
-
throw new RuntimeError('RILL-
|
|
347
|
+
throw new RuntimeError('RILL-R045', `Function expects ${params.length} arguments, got ${args.length}`, location, {
|
|
209
348
|
functionName,
|
|
210
349
|
expectedCount: params.length,
|
|
211
350
|
actualCount: args.length,
|
|
212
351
|
});
|
|
213
352
|
}
|
|
214
|
-
|
|
353
|
+
const result = {};
|
|
354
|
+
// Stage 2 + 3: Hydrate defaults, check required, type-check
|
|
215
355
|
for (let i = 0; i < params.length; i++) {
|
|
216
356
|
const param = params[i];
|
|
217
357
|
if (param === undefined)
|
|
218
358
|
continue;
|
|
219
|
-
let
|
|
220
|
-
//
|
|
221
|
-
if (
|
|
359
|
+
let value = args[i];
|
|
360
|
+
// Hydrate default when no positional arg was supplied
|
|
361
|
+
if (value === undefined) {
|
|
222
362
|
if (param.defaultValue !== undefined) {
|
|
223
|
-
|
|
224
|
-
|
|
363
|
+
value = param.defaultValue;
|
|
364
|
+
}
|
|
365
|
+
else if (param.type !== undefined && hasCollectionFields(param.type)) {
|
|
366
|
+
// Collection-typed param with field-level defaults: synthesize empty
|
|
367
|
+
// collection so Stage 2.5 (hydrateFieldDefaults) can fill in defaults
|
|
368
|
+
value = emptyForType(param.type);
|
|
225
369
|
}
|
|
226
370
|
else {
|
|
227
|
-
// Missing required
|
|
228
|
-
throw new RuntimeError('RILL-
|
|
371
|
+
// Stage 2: Missing required parameter
|
|
372
|
+
throw new RuntimeError('RILL-R044', `Missing argument for parameter '${param.name}'`, location, {
|
|
229
373
|
functionName,
|
|
230
374
|
paramName: param.name,
|
|
231
375
|
});
|
|
232
376
|
}
|
|
233
377
|
}
|
|
234
|
-
//
|
|
378
|
+
// Stage 2.5: Hydrate dict/ordered field-level defaults
|
|
379
|
+
if (param.type !== undefined) {
|
|
380
|
+
value = hydrateFieldDefaults(value, param.type);
|
|
381
|
+
}
|
|
382
|
+
// Stage 3: Type check when param.type is defined
|
|
235
383
|
if (param.type !== undefined) {
|
|
236
|
-
if (!
|
|
237
|
-
const expectedType =
|
|
238
|
-
const actualType = inferType(
|
|
239
|
-
throw new RuntimeError('RILL-R001', `
|
|
384
|
+
if (!structureMatches(value, param.type)) {
|
|
385
|
+
const expectedType = formatStructure(param.type);
|
|
386
|
+
const actualType = inferType(value);
|
|
387
|
+
throw new RuntimeError('RILL-R001', `Parameter type mismatch: ${param.name} expects ${expectedType}, got ${actualType}`, location, {
|
|
240
388
|
functionName,
|
|
241
389
|
paramName: param.name,
|
|
242
390
|
expectedType,
|
|
@@ -244,6 +392,7 @@ export function validateCallableArgs(args, params, functionName, location) {
|
|
|
244
392
|
});
|
|
245
393
|
}
|
|
246
394
|
}
|
|
395
|
+
result[param.name] = value;
|
|
247
396
|
}
|
|
397
|
+
return result;
|
|
248
398
|
}
|
|
249
|
-
//# sourceMappingURL=callable.js.map
|
|
@@ -6,18 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { RuntimeContext, RuntimeOptions } from './types.js';
|
|
8
8
|
import { type RillValue } from './values.js';
|
|
9
|
-
import { type RillFunction } from './callable.js';
|
|
10
9
|
export declare const UNVALIDATED_METHOD_PARAMS: Set<string>;
|
|
11
|
-
export declare const UNVALIDATED_METHOD_RECEIVERS: Set<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Build a ReadonlyMap of frozen ApplicationCallable dicts from an array of
|
|
14
|
-
* [typeName, methods] pairs. Accepts pairs (not a plain object) so the same
|
|
15
|
-
* typeName can appear more than once — duplicate method names across entries
|
|
16
|
-
* for the same type trigger an Error (EC-6).
|
|
17
|
-
*
|
|
18
|
-
* Re-exported from the public barrel index for host integration use.
|
|
19
|
-
*/
|
|
20
|
-
export declare function buildTypeMethodDicts(pairs: Array<[string, Record<string, RillFunction>]>): ReadonlyMap<string, Readonly<Record<string, RillValue>>>;
|
|
21
10
|
/**
|
|
22
11
|
* Create a runtime context for script execution.
|
|
23
12
|
* This is the main entry point for configuring the Rill runtime.
|
|
@@ -62,4 +51,3 @@ export declare function pushCallFrame(ctx: RuntimeContext, frame: import('../../
|
|
|
62
51
|
* Pop frame from call stack after function/closure returns.
|
|
63
52
|
*/
|
|
64
53
|
export declare function popCallFrame(ctx: RuntimeContext): void;
|
|
65
|
-
//# sourceMappingURL=context.d.ts.map
|