UNPKG

1.71 kBTypeScriptView Raw
1import type { Nullable } from '../core.js';
2import type { Reference } from '../references.js';
3import type { ScopeBlock } from './scope.js';
4
5declare const CAPTURED_ARGS: unique symbol;
6
7export interface VMArguments {
8 length: number;
9 positional: PositionalArguments;
10 named: NamedArguments;
11
12 at(pos: number): Reference;
13 capture(): CapturedArguments;
14}
15
16export interface CapturedArguments {
17 positional: CapturedPositionalArguments;
18 named: CapturedNamedArguments;
19 [CAPTURED_ARGS]: true;
20}
21
22export interface PositionalArguments {
23 length: number;
24 at(position: number): Reference;
25 capture(): CapturedPositionalArguments;
26}
27
28export interface CapturedPositionalArguments extends Array<Reference> {
29 [CAPTURED_ARGS]: true;
30}
31
32export interface NamedArguments {
33 names: readonly string[];
34 length: number;
35 has(name: string): boolean;
36 get(name: string): Reference;
37 capture(): CapturedNamedArguments;
38}
39
40export interface BlockArguments {
41 names: readonly string[];
42 length: number;
43 has(name: string): boolean;
44 get(name: string): Nullable<ScopeBlock>;
45 capture(): CapturedBlockArguments;
46}
47
48export interface CapturedBlockArguments {
49 names: readonly string[];
50 length: number;
51 has(name: string): boolean;
52 get(name: string): Nullable<ScopeBlock>;
53}
54
55export interface CapturedNamedArguments extends Record<string, Reference> {
56 [CAPTURED_ARGS]: true;
57}
58
59export interface Arguments {
60 positional: readonly unknown[];
61 named: Record<string, unknown>;
62}
63
64export interface ArgumentsDebug {
65 positional: readonly unknown[];
66 named: Record<string, unknown>;
67}
68
69export interface ArgumentError {
70 error: any;
71}
72
73export function isArgumentError(arg: unknown): arg is ArgumentError;