@ibyar/expressions 0.5.2 → 0.5.62
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/LICENSE +1 -1
- package/README.md +4 -3
- package/api/abstract.d.ts +5 -6
- package/api/abstract.js +8 -3
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +227 -0
- package/api/class/class.js +662 -0
- package/api/class/class.js.map +1 -0
- package/api/class/decorator.d.ts +20 -0
- package/api/class/decorator.js +48 -0
- package/api/class/decorator.js.map +1 -0
- package/api/computing/call.d.ts +3 -1
- package/api/computing/call.js +16 -4
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +15 -0
- package/api/computing/debugger.js +35 -0
- package/api/computing/debugger.js.map +1 -0
- package/api/computing/new.d.ts +2 -1
- package/api/computing/new.js +4 -0
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +6 -6
- package/api/computing/rest.js +5 -2
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +6 -1
- package/api/computing/return.js +8 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -1
- package/api/computing/spread.js +5 -2
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +6 -1
- package/api/computing/throw.js +7 -0
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -1
- package/api/computing/yield.js +3 -0
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +12 -12
- package/api/definition/array.js +31 -25
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +8 -2
- package/api/definition/bind.js +7 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +40 -51
- package/api/definition/function.js +292 -309
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -2
- package/api/definition/member.js +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +15 -12
- package/api/definition/object.js +43 -13
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +7 -3
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +44 -50
- package/api/definition/values.js +87 -149
- package/api/definition/values.js.map +1 -1
- package/api/deserialize/deserialize.d.ts +7 -1
- package/api/deserialize/deserialize.js +9 -1
- package/api/deserialize/deserialize.js.map +1 -1
- package/api/deserialize/type-store.d.ts +2 -2
- package/api/deserialize/type-store.js.map +1 -1
- package/api/expression.d.ts +159 -18
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +2 -0
- package/api/index.js +2 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +29 -0
- package/api/module/common.js +71 -0
- package/api/module/common.js.map +1 -0
- package/api/module/export.d.ts +129 -25
- package/api/module/export.js +333 -58
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +114 -25
- package/api/module/import.js +279 -68
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +2 -2
- package/api/operators/assignment.js +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +2 -2
- package/api/operators/await.js +1 -1
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +2 -2
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -2
- package/api/operators/chaining.js +1 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -2
- package/api/operators/comma.js +2 -2
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +9 -2
- package/api/operators/grouping.js +8 -1
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +2 -2
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +14 -2
- package/api/operators/pipeline.js +13 -1
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -2
- package/api/operators/ternary.js +1 -1
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +3 -3
- package/api/operators/unary.js +7 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +2 -2
- package/api/operators/update.js +1 -1
- package/api/operators/update.js.map +1 -1
- package/api/{app/program.d.ts → program.d.ts} +8 -9
- package/api/program.js +45 -0
- package/api/program.js.map +1 -0
- package/api/statement/control/block.d.ts +8 -5
- package/api/statement/control/block.js +26 -23
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +8 -1
- package/api/statement/control/empty.js +7 -0
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +7 -2
- package/api/statement/control/if.js +6 -1
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +10 -5
- package/api/statement/control/switch.js +22 -9
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +46 -13
- package/api/statement/control/terminate.js +89 -20
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +17 -16
- package/api/statement/declarations/declares.js +24 -19
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +10 -5
- package/api/statement/iterations/for.js +42 -23
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +9 -3
- package/api/statement/iterations/while.js +27 -13
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +5 -0
- package/api/utils.js +4 -0
- package/api/utils.js.map +1 -0
- package/package.json +5 -5
- package/scope/finalizer.d.ts +4 -0
- package/scope/finalizer.js +11 -0
- package/scope/finalizer.js.map +1 -0
- package/scope/proxy.d.ts +5 -3
- package/scope/proxy.js +26 -26
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +108 -51
- package/scope/scope.js +72 -134
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +117 -26
- package/scope/stack.js +154 -102
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +204 -0
- package/v8/enums.js +406 -0
- package/v8/enums.js.map +1 -0
- package/v8/index.d.ts +2 -1
- package/v8/index.js +2 -1
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +213 -0
- package/v8/inline.js +2375 -0
- package/v8/inline.js.map +1 -0
- package/v8/nodes.d.ts +8 -7
- package/v8/nodes.js +39 -64
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +49 -151
- package/v8/parser.js +839 -1607
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +39 -3
- package/v8/stream.js +685 -171
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +244 -9
- package/v8/token.js +315 -47
- package/v8/token.js.map +1 -1
- package/visit/visitor.d.ts +3 -0
- package/visit/visitor.js +4 -7
- package/visit/visitor.js.map +1 -1
- package/api/app/class.d.ts +0 -117
- package/api/app/class.js +0 -292
- package/api/app/class.js.map +0 -1
- package/api/app/program.js +0 -39
- package/api/app/program.js.map +0 -1
- package/api/module/module.d.ts +0 -26
- package/api/module/module.js +0 -63
- package/api/module/module.js.map +0 -1
- package/v8/app.d.ts +0 -0
- package/v8/app.js +0 -2
- package/v8/app.js.map +0 -1
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Scope
|
|
1
|
+
import type { DeclarationExpression, ExpressionNode, NodeDeserializer, CanFindScope, ExpressionEventPath, VisitNodeType } from '../expression.js';
|
|
2
|
+
import type { Scope } from '../../scope/scope.js';
|
|
3
3
|
import type { Stack } from '../../scope/stack.js';
|
|
4
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* An identifier is a sequence of characters in the code that identifies a variable, function, or property.
|
|
7
|
+
* In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),
|
|
8
|
+
* but may not start with a digit.
|
|
9
|
+
* An identifier differs from a string in that a string is data,
|
|
10
|
+
* while an identifier is part of the code. In JavaScript,
|
|
11
|
+
* there is no way to convert identifiers to strings,
|
|
12
|
+
* but sometimes it is possible to parse strings into identifiers.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Identifier extends AbstractExpressionNode implements DeclarationExpression, CanFindScope {
|
|
6
15
|
protected name: string | number;
|
|
7
16
|
static fromJSON(node: Identifier): Identifier;
|
|
8
17
|
constructor(name: string | number);
|
|
@@ -12,17 +21,37 @@ export declare class Identifier extends AbstractExpressionNode implements CanDec
|
|
|
12
21
|
get(stack: Stack, thisContext?: any): any;
|
|
13
22
|
findScope<T extends object>(stack: Stack): Scope<T>;
|
|
14
23
|
findScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;
|
|
15
|
-
declareVariable(stack: Stack,
|
|
24
|
+
declareVariable(stack: Stack, propertyValue: any): any;
|
|
25
|
+
getDeclarationName(): string;
|
|
16
26
|
dependency(computed?: true): ExpressionNode[];
|
|
17
27
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
18
28
|
toString(): string;
|
|
19
29
|
toJson(): object;
|
|
20
30
|
}
|
|
31
|
+
export declare class ThisExpression extends Identifier {
|
|
32
|
+
static fromJSON(node: ThisExpression): ThisExpression;
|
|
33
|
+
constructor();
|
|
34
|
+
}
|
|
21
35
|
export declare class Literal<T> extends AbstractExpressionNode implements CanFindScope {
|
|
22
36
|
protected value: T;
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
protected raw?: string | undefined;
|
|
38
|
+
protected regex?: {
|
|
39
|
+
pattern: string;
|
|
40
|
+
flags: string;
|
|
41
|
+
} | undefined;
|
|
42
|
+
protected bigint?: string | undefined;
|
|
43
|
+
static fromJSON(node: Literal<any>): Literal<string> | Literal<number> | Literal<boolean> | Literal<RegExp> | Literal<bigint> | Literal<null> | Literal<undefined>;
|
|
44
|
+
constructor(value: T, raw?: string | undefined, regex?: {
|
|
45
|
+
pattern: string;
|
|
46
|
+
flags: string;
|
|
47
|
+
} | undefined, bigint?: string | undefined);
|
|
25
48
|
getValue(): T;
|
|
49
|
+
getRegex(): {
|
|
50
|
+
pattern: string;
|
|
51
|
+
flags: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
getBigint(): string | undefined;
|
|
54
|
+
geRaw(): string | undefined;
|
|
26
55
|
shareVariables(scopeList: Scope<any>[]): void;
|
|
27
56
|
set(): void;
|
|
28
57
|
get(): T;
|
|
@@ -33,20 +62,12 @@ export declare class Literal<T> extends AbstractExpressionNode implements CanFin
|
|
|
33
62
|
toString(): string;
|
|
34
63
|
toJson(): object;
|
|
35
64
|
}
|
|
36
|
-
export declare class StringLiteral extends Literal<string> {
|
|
37
|
-
static fromJSON(node: StringLiteral): StringLiteral;
|
|
38
|
-
private quote;
|
|
39
|
-
constructor(value: string, quote?: string);
|
|
40
|
-
getQuote(): string;
|
|
41
|
-
toString(): string;
|
|
42
|
-
toJson(): object;
|
|
43
|
-
}
|
|
44
65
|
export declare class TemplateLiteralExpressionNode extends AbstractExpressionNode {
|
|
45
66
|
protected quasis: string[];
|
|
46
67
|
protected expressions: ExpressionNode[];
|
|
47
68
|
protected tag?: ExpressionNode | undefined;
|
|
48
69
|
static fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode;
|
|
49
|
-
static visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType
|
|
70
|
+
static visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType): void;
|
|
50
71
|
constructor(quasis: string[], expressions: ExpressionNode[], tag?: ExpressionNode | undefined);
|
|
51
72
|
getTag(): ExpressionNode | undefined;
|
|
52
73
|
getExpressions(): ExpressionNode[];
|
|
@@ -68,50 +89,20 @@ export declare class TaggedTemplateExpression extends TemplateLiteralExpressionN
|
|
|
68
89
|
constructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]);
|
|
69
90
|
getTag(): ExpressionNode;
|
|
70
91
|
}
|
|
71
|
-
export declare class NumberLiteral extends Literal<number> {
|
|
72
|
-
static fromJSON(node: NumberLiteral): NumberLiteral;
|
|
73
|
-
constructor(value: number);
|
|
74
|
-
}
|
|
75
|
-
export declare class BigIntLiteral extends Literal<bigint> {
|
|
76
|
-
static fromJSON(node: BigIntLiteral): BigIntLiteral;
|
|
77
|
-
toString(): string;
|
|
78
|
-
toJson(): object;
|
|
79
|
-
}
|
|
80
|
-
export declare class RegExpLiteral extends Literal<RegExp> {
|
|
81
|
-
static fromJSON(node: RegExpLiteral & {
|
|
82
|
-
regex: {
|
|
83
|
-
pattern: string;
|
|
84
|
-
flags: string;
|
|
85
|
-
};
|
|
86
|
-
}): RegExpLiteral;
|
|
87
|
-
toString(): string;
|
|
88
|
-
toJson(): object;
|
|
89
|
-
}
|
|
90
92
|
export declare const TRUE: string;
|
|
91
93
|
export declare const FALSE: string;
|
|
92
|
-
export declare class BooleanLiteral extends Literal<boolean> {
|
|
93
|
-
static fromJSON(node: BooleanLiteral): BooleanLiteral;
|
|
94
|
-
}
|
|
95
94
|
export declare const NULL: string;
|
|
96
95
|
export declare const UNDEFINED: string;
|
|
97
|
-
export declare
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
export declare class ThisExpression extends Identifier {
|
|
103
|
-
static fromJSON(node: ThisExpression): ThisExpression;
|
|
104
|
-
constructor();
|
|
105
|
-
}
|
|
106
|
-
export declare const NullNode: NullishLiteral;
|
|
107
|
-
export declare const UndefinedNode: NullishLiteral;
|
|
108
|
-
export declare const TrueNode: BooleanLiteral;
|
|
109
|
-
export declare const FalseNode: BooleanLiteral;
|
|
96
|
+
export declare const NullNode: Literal<null>;
|
|
97
|
+
export declare const UndefinedNode: Literal<undefined>;
|
|
98
|
+
export declare const TrueNode: Literal<boolean>;
|
|
99
|
+
export declare const FalseNode: Literal<boolean>;
|
|
110
100
|
export declare const ThisNode: ThisExpression;
|
|
111
101
|
export declare const GlobalThisNode: Identifier;
|
|
112
102
|
export declare const SymbolNode: Identifier;
|
|
113
103
|
export declare const OfNode: Identifier;
|
|
114
104
|
export declare const AsNode: Identifier;
|
|
105
|
+
export declare const DefaultNode: Identifier;
|
|
115
106
|
export declare const GetIdentifier: Identifier;
|
|
116
107
|
export declare const SetIdentifier: Identifier;
|
|
117
108
|
export declare const AsyncIdentifier: Identifier;
|
|
@@ -120,3 +111,6 @@ export declare const ConstructorIdentifier: Identifier;
|
|
|
120
111
|
export declare const NameIdentifier: Identifier;
|
|
121
112
|
export declare const EvalIdentifier: Identifier;
|
|
122
113
|
export declare const ArgumentsIdentifier: Identifier;
|
|
114
|
+
export declare const YieldIdentifier: Identifier;
|
|
115
|
+
export declare const SuperIdentifier: Identifier;
|
|
116
|
+
export declare const LetIdentifier: Identifier;
|
package/api/definition/values.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
var Identifier_1, Literal_1
|
|
1
|
+
var Identifier_1, Literal_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
3
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
4
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
|
+
/**
|
|
6
|
+
* An identifier is a sequence of characters in the code that identifies a variable, function, or property.
|
|
7
|
+
* In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),
|
|
8
|
+
* but may not start with a digit.
|
|
9
|
+
* An identifier differs from a string in that a string is data,
|
|
10
|
+
* while an identifier is part of the code. In JavaScript,
|
|
11
|
+
* there is no way to convert identifiers to strings,
|
|
12
|
+
* but sometimes it is possible to parse strings into identifiers.
|
|
13
|
+
*/
|
|
5
14
|
let Identifier = Identifier_1 = class Identifier extends AbstractExpressionNode {
|
|
6
15
|
constructor(name) {
|
|
7
16
|
super();
|
|
@@ -30,8 +39,11 @@ let Identifier = Identifier_1 = class Identifier extends AbstractExpressionNode
|
|
|
30
39
|
scope = stack.findScope(this.name);
|
|
31
40
|
return scope.getScope(this.name);
|
|
32
41
|
}
|
|
33
|
-
declareVariable(stack,
|
|
34
|
-
return stack.declareVariable(
|
|
42
|
+
declareVariable(stack, propertyValue) {
|
|
43
|
+
return stack.declareVariable(this.name, propertyValue);
|
|
44
|
+
}
|
|
45
|
+
getDeclarationName() {
|
|
46
|
+
return this.toString();
|
|
35
47
|
}
|
|
36
48
|
dependency(computed) {
|
|
37
49
|
return [this];
|
|
@@ -52,17 +64,48 @@ Identifier = Identifier_1 = __decorate([
|
|
|
52
64
|
__metadata("design:paramtypes", [Object])
|
|
53
65
|
], Identifier);
|
|
54
66
|
export { Identifier };
|
|
67
|
+
let ThisExpression = class ThisExpression extends Identifier {
|
|
68
|
+
static fromJSON(node) {
|
|
69
|
+
return ThisNode;
|
|
70
|
+
}
|
|
71
|
+
constructor() {
|
|
72
|
+
super('this');
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
ThisExpression = __decorate([
|
|
76
|
+
Deserializer('ThisExpression'),
|
|
77
|
+
__metadata("design:paramtypes", [])
|
|
78
|
+
], ThisExpression);
|
|
79
|
+
export { ThisExpression };
|
|
55
80
|
let Literal = Literal_1 = class Literal extends AbstractExpressionNode {
|
|
56
|
-
constructor(value) {
|
|
81
|
+
constructor(value, raw, regex, bigint) {
|
|
57
82
|
super();
|
|
58
83
|
this.value = value;
|
|
84
|
+
this.raw = raw;
|
|
85
|
+
this.regex = regex;
|
|
86
|
+
this.bigint = bigint;
|
|
59
87
|
}
|
|
60
88
|
static fromJSON(node) {
|
|
61
|
-
|
|
89
|
+
if (node.bigint) {
|
|
90
|
+
return new Literal_1(BigInt(node.bigint), node.raw, undefined, node.bigint);
|
|
91
|
+
}
|
|
92
|
+
else if (node.regex) {
|
|
93
|
+
return new Literal_1(RegExp(node.regex.pattern, node.regex.flags), node.raw, node.regex);
|
|
94
|
+
}
|
|
95
|
+
return new Literal_1(node.value, node.raw);
|
|
62
96
|
}
|
|
63
97
|
getValue() {
|
|
64
98
|
return this.value;
|
|
65
99
|
}
|
|
100
|
+
getRegex() {
|
|
101
|
+
return this.regex;
|
|
102
|
+
}
|
|
103
|
+
getBigint() {
|
|
104
|
+
return this.bigint;
|
|
105
|
+
}
|
|
106
|
+
geRaw() {
|
|
107
|
+
return this.raw;
|
|
108
|
+
}
|
|
66
109
|
shareVariables(scopeList) { }
|
|
67
110
|
set() {
|
|
68
111
|
throw new Error(`${this.constructor.name}#set() has no implementation.`);
|
|
@@ -84,55 +127,32 @@ let Literal = Literal_1 = class Literal extends AbstractExpressionNode {
|
|
|
84
127
|
return computed ? [{ computed: false, path: this.toString() }] : [];
|
|
85
128
|
}
|
|
86
129
|
toString() {
|
|
87
|
-
return String(this.value);
|
|
130
|
+
return this.raw ?? String(this.value);
|
|
88
131
|
}
|
|
89
132
|
toJson() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
__metadata("design:paramtypes", [Object])
|
|
96
|
-
], Literal);
|
|
97
|
-
export { Literal };
|
|
98
|
-
let StringLiteral = StringLiteral_1 = class StringLiteral extends Literal {
|
|
99
|
-
constructor(value, quote) {
|
|
100
|
-
super(value);
|
|
101
|
-
const firstChar = value.charAt(0);
|
|
102
|
-
if (quote) {
|
|
103
|
-
this.quote = quote;
|
|
104
|
-
this.value = value;
|
|
105
|
-
}
|
|
106
|
-
else if (firstChar === '"' || firstChar == `'` || firstChar === '`') {
|
|
107
|
-
this.quote = firstChar;
|
|
108
|
-
this.value = `"${value.substring(1, value.length - 1)}"`;
|
|
133
|
+
if (this.bigint) {
|
|
134
|
+
return {
|
|
135
|
+
bigint: this.bigint,
|
|
136
|
+
raw: this.raw,
|
|
137
|
+
};
|
|
109
138
|
}
|
|
110
|
-
else {
|
|
111
|
-
|
|
112
|
-
|
|
139
|
+
else if (this.regex) {
|
|
140
|
+
return {
|
|
141
|
+
regex: { pattern: this.regex?.pattern, flags: this.regex?.flags },
|
|
142
|
+
raw: this.raw,
|
|
143
|
+
};
|
|
113
144
|
}
|
|
114
|
-
}
|
|
115
|
-
static fromJSON(node) {
|
|
116
|
-
return new StringLiteral_1(node.value, node.quote);
|
|
117
|
-
}
|
|
118
|
-
getQuote() {
|
|
119
|
-
return this.quote;
|
|
120
|
-
}
|
|
121
|
-
toString() {
|
|
122
|
-
return `${this.quote}${this.value}${this.quote}`;
|
|
123
|
-
}
|
|
124
|
-
toJson() {
|
|
125
145
|
return {
|
|
126
146
|
value: this.value,
|
|
127
|
-
|
|
147
|
+
raw: this.raw,
|
|
128
148
|
};
|
|
129
149
|
}
|
|
130
150
|
};
|
|
131
|
-
|
|
132
|
-
Deserializer('
|
|
133
|
-
__metadata("design:paramtypes", [String, String])
|
|
134
|
-
],
|
|
135
|
-
export {
|
|
151
|
+
Literal = Literal_1 = __decorate([
|
|
152
|
+
Deserializer('Literal'),
|
|
153
|
+
__metadata("design:paramtypes", [Object, String, Object, String])
|
|
154
|
+
], Literal);
|
|
155
|
+
export { Literal };
|
|
136
156
|
class TemplateArray extends Array {
|
|
137
157
|
constructor(strings) {
|
|
138
158
|
super(...strings);
|
|
@@ -149,9 +169,9 @@ export class TemplateLiteralExpressionNode extends AbstractExpressionNode {
|
|
|
149
169
|
static fromJSON(node, deserializer) {
|
|
150
170
|
return new TemplateLiteralExpressionNode(node.quasis, node.expressions.map(deserializer), node.tag ? deserializer(node.tag) : void 0);
|
|
151
171
|
}
|
|
152
|
-
static visit(node, visitNode
|
|
172
|
+
static visit(node, visitNode) {
|
|
153
173
|
node.tag && visitNode(node.tag);
|
|
154
|
-
|
|
174
|
+
node.expressions.forEach(visitNode);
|
|
155
175
|
}
|
|
156
176
|
getTag() {
|
|
157
177
|
return this.tag;
|
|
@@ -226,117 +246,32 @@ TaggedTemplateExpression = __decorate([
|
|
|
226
246
|
__metadata("design:paramtypes", [Object, Array, Array])
|
|
227
247
|
], TaggedTemplateExpression);
|
|
228
248
|
export { TaggedTemplateExpression };
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
export { NumberLiteral };
|
|
242
|
-
let BigIntLiteral = BigIntLiteral_1 = class BigIntLiteral extends Literal {
|
|
243
|
-
static fromJSON(node) {
|
|
244
|
-
return new BigIntLiteral_1(BigInt(String(node.value)));
|
|
245
|
-
}
|
|
246
|
-
toString() {
|
|
247
|
-
return `${this.value}n`;
|
|
248
|
-
}
|
|
249
|
-
toJson() {
|
|
250
|
-
return { value: this.value.toString() };
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
BigIntLiteral = BigIntLiteral_1 = __decorate([
|
|
254
|
-
Deserializer('BigIntLiteral')
|
|
255
|
-
], BigIntLiteral);
|
|
256
|
-
export { BigIntLiteral };
|
|
257
|
-
let RegExpLiteral = RegExpLiteral_1 = class RegExpLiteral extends Literal {
|
|
258
|
-
static fromJSON(node) {
|
|
259
|
-
return new RegExpLiteral_1(new RegExp(node.regex.pattern, node.regex.flags));
|
|
260
|
-
}
|
|
261
|
-
toString() {
|
|
262
|
-
return `${this.value}n`;
|
|
263
|
-
}
|
|
264
|
-
toJson() {
|
|
265
|
-
return {
|
|
266
|
-
regex: {
|
|
267
|
-
pattern: this.value.source,
|
|
268
|
-
flags: this.value.flags
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
;
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
RegExpLiteral = RegExpLiteral_1 = __decorate([
|
|
275
|
-
Deserializer('RegExpLiteral')
|
|
276
|
-
], RegExpLiteral);
|
|
277
|
-
export { RegExpLiteral };
|
|
249
|
+
// @Deserializer('BigIntLiteral')
|
|
250
|
+
// export class BigIntLiteral extends Literal<bigint> {
|
|
251
|
+
// static fromJSON(node: BigIntLiteral): BigIntLiteral {
|
|
252
|
+
// return new BigIntLiteral(BigInt(String(node.value)));
|
|
253
|
+
// }
|
|
254
|
+
// toString(): string {
|
|
255
|
+
// return `${this.value}n`;
|
|
256
|
+
// }
|
|
257
|
+
// toJson(): object {
|
|
258
|
+
// return { value: this.value.toString() };
|
|
259
|
+
// }
|
|
260
|
+
// }
|
|
278
261
|
export const TRUE = String(true);
|
|
279
262
|
export const FALSE = String(false);
|
|
280
|
-
let BooleanLiteral = class BooleanLiteral extends Literal {
|
|
281
|
-
static fromJSON(node) {
|
|
282
|
-
switch (String(node.value)) {
|
|
283
|
-
case TRUE: return TrueNode;
|
|
284
|
-
case FALSE:
|
|
285
|
-
default:
|
|
286
|
-
return FalseNode;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
BooleanLiteral = __decorate([
|
|
291
|
-
Deserializer('BooleanLiteral')
|
|
292
|
-
], BooleanLiteral);
|
|
293
|
-
export { BooleanLiteral };
|
|
294
263
|
export const NULL = String(null);
|
|
295
264
|
export const UNDEFINED = String(undefined);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
case UNDEFINED:
|
|
301
|
-
default: return UndefinedNode;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
toString() {
|
|
305
|
-
if (typeof this.value === 'undefined') {
|
|
306
|
-
return UNDEFINED;
|
|
307
|
-
}
|
|
308
|
-
return NULL;
|
|
309
|
-
}
|
|
310
|
-
toJson() {
|
|
311
|
-
return { value: this.toString() };
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
NullishLiteral = __decorate([
|
|
315
|
-
Deserializer('NullishLiteral')
|
|
316
|
-
], NullishLiteral);
|
|
317
|
-
export { NullishLiteral };
|
|
318
|
-
let ThisExpression = class ThisExpression extends Identifier {
|
|
319
|
-
static fromJSON(node) {
|
|
320
|
-
return ThisNode;
|
|
321
|
-
}
|
|
322
|
-
constructor() {
|
|
323
|
-
super('this');
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
ThisExpression = __decorate([
|
|
327
|
-
Deserializer('ThisExpression'),
|
|
328
|
-
__metadata("design:paramtypes", [])
|
|
329
|
-
], ThisExpression);
|
|
330
|
-
export { ThisExpression };
|
|
331
|
-
export const NullNode = Object.freeze(new NullishLiteral(null));
|
|
332
|
-
export const UndefinedNode = Object.freeze(new NullishLiteral(undefined));
|
|
333
|
-
export const TrueNode = Object.freeze(new BooleanLiteral(true));
|
|
334
|
-
export const FalseNode = Object.freeze(new BooleanLiteral(false));
|
|
265
|
+
export const NullNode = Object.freeze(new Literal(null));
|
|
266
|
+
export const UndefinedNode = Object.freeze(new Literal(undefined));
|
|
267
|
+
export const TrueNode = Object.freeze(new Literal(true));
|
|
268
|
+
export const FalseNode = Object.freeze(new Literal(false));
|
|
335
269
|
export const ThisNode = Object.freeze(new ThisExpression());
|
|
336
270
|
export const GlobalThisNode = Object.freeze(new Identifier('globalThis'));
|
|
337
271
|
export const SymbolNode = Object.freeze(new Identifier('Symbol'));
|
|
338
272
|
export const OfNode = Object.freeze(new Identifier('of'));
|
|
339
273
|
export const AsNode = Object.freeze(new Identifier('as'));
|
|
274
|
+
export const DefaultNode = Object.freeze(new Identifier('default'));
|
|
340
275
|
export const GetIdentifier = Object.freeze(new Identifier('get'));
|
|
341
276
|
export const SetIdentifier = Object.freeze(new Identifier('set'));
|
|
342
277
|
export const AsyncIdentifier = Object.freeze(new Identifier('async'));
|
|
@@ -345,4 +280,7 @@ export const ConstructorIdentifier = Object.freeze(new Identifier('constructor')
|
|
|
345
280
|
export const NameIdentifier = Object.freeze(new Identifier('name'));
|
|
346
281
|
export const EvalIdentifier = Object.freeze(new Identifier('eval'));
|
|
347
282
|
export const ArgumentsIdentifier = Object.freeze(new Identifier('arguments'));
|
|
283
|
+
export const YieldIdentifier = Object.freeze(new Identifier('yield'));
|
|
284
|
+
export const SuperIdentifier = Object.freeze(new Identifier('super'));
|
|
285
|
+
export const LetIdentifier = Object.freeze(new Identifier('let'));
|
|
348
286
|
//# sourceMappingURL=values.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/values.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAA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,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAe,CAAC","sourcesContent":["import type {\n\tCanDeclareExpression, ExpressionNode,\n\tNodeDeserializer, CanFindScope, ExpressionEventPath, VisitNodeType, VisitNodeListType\n} from '../expression.js';\nimport type { Scope, ScopeType } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { AbstractExpressionNode } from '../abstract.js';\n\n/**\n * An identifier is a sequence of characters in the code that identifies a variable, function, or property.\n * In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),\n * but may not start with a digit.\n * An identifier differs from a string in that a string is data,\n * while an identifier is part of the code. In JavaScript,\n * there is no way to convert identifiers to strings,\n * but sometimes it is possible to parse strings into identifiers.\n */\n@Deserializer('Identifier')\nexport class Identifier extends AbstractExpressionNode implements CanDeclareExpression, CanFindScope {\n\tstatic fromJSON(node: Identifier): Identifier {\n\t\treturn new Identifier(node.name);\n\t}\n\tconstructor(protected name: string | number) {\n\t\tsuper();\n\t}\n\tgetName() {\n\t\treturn this.name;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack, value: any) {\n\t\treturn stack.set(this.name, value) ? value : void 0;\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tif (thisContext) {\n\t\t\treturn thisContext[this.name];\n\t\t}\n\t\treturn stack.get(this.name);\n\t}\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope(this.name);\n\t\t}\n\t\tscope = stack.findScope(this.name);\n\t\treturn scope.getScope(this.name);\n\t}\n\tdeclareVariable(stack: Stack, scopeType: ScopeType, propertyValue: any): any {\n\t\treturn stack.declareVariable(scopeType, this.name, propertyValue);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [this];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tconst path: ExpressionEventPath[] = [{ computed: false, path: this.toString() }];\n\t\treturn computed ? [{ computed, path: this.toString(), computedPath: [path] }] : path;\n\t}\n\ttoString(): string {\n\t\treturn String(this.name);\n\t}\n\ttoJson(): object {\n\t\treturn { name: this.name };\n\t}\n}\n\n@Deserializer('Literal')\nexport class Literal<T> extends AbstractExpressionNode implements CanFindScope {\n\tstatic fromJSON(node: Literal<any>):\n\t\tLiteral<string>\n\t\t| Literal<number>\n\t\t| Literal<bigint>\n\t\t| Literal<boolean>\n\t\t| Literal<RegExp>\n\t\t| Literal<null | undefined> {\n\t\treturn new Literal(node.value);\n\t}\n\tconstructor(protected value: T) {\n\t\tsuper();\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset() {\n\t\tthrow new Error(`${this.constructor.name}#set() has no implementation.`);\n\t}\n\tget(): T {\n\t\treturn this.value;\n\t}\n\tfindScope<V extends object>(stack: Stack): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope: Scope<any>): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope?: Scope<any>): Scope<V> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope<V>(this.value as any);\n\t\t}\n\t\tscope = stack.findScope<V>(this.value as any);\n\t\treturn scope.getScope<V>(this.value as any);\n\t}\n\tdependency(computed: true): ExpressionNode[] {\n\t\treturn computed ? [this] : [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn computed ? [{ computed: false, path: this.toString() }] : [];\n\t}\n\ttoString(): string {\n\t\treturn String(this.value);\n\t}\n\ttoJson(): object {\n\t\treturn { value: this.value };\n\t}\n}\n\n@Deserializer('StringLiteral')\nexport class StringLiteral extends Literal<string> {\n\tstatic fromJSON(node: StringLiteral): StringLiteral {\n\t\treturn new StringLiteral(node.value, node.quote);\n\t}\n\tprivate quote: string;\n\tconstructor(value: string, quote?: string) {\n\t\tsuper(value);\n\t\tconst firstChar = value.charAt(0);\n\t\tif (quote) {\n\t\t\tthis.quote = quote;\n\t\t\tthis.value = value;\n\t\t} else if (firstChar === '\"' || firstChar == `'` || firstChar === '`') {\n\t\t\tthis.quote = firstChar;\n\t\t\tthis.value = `\"${value.substring(1, value.length - 1)}\"`;\n\t\t} else {\n\t\t\tthis.quote = '';\n\t\t\tthis.value = value;\n\t\t}\n\t}\n\tgetQuote() {\n\t\treturn this.quote;\n\t}\n\ttoString(): string {\n\t\treturn `${this.quote}${this.value}${this.quote}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t\tquote: this.quote\n\t\t};\n\t}\n}\n\nclass TemplateArray extends Array<string> implements TemplateStringsArray {\n\traw: readonly string[];\n\tconstructor(strings: string[]) {\n\t\tsuper(...strings);\n\t\tthis.raw = strings;\n\t}\n}\n\nexport class TemplateLiteralExpressionNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode {\n\t\treturn new TemplateLiteralExpressionNode(\n\t\t\tnode.quasis,\n\t\t\tnode.expressions.map(deserializer),\n\t\t\tnode.tag ? deserializer(node.tag) : void 0\n\t\t);\n\t}\n\tstatic visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType, visitNodeList: VisitNodeListType): void {\n\t\tnode.tag && visitNode(node.tag);\n\t\tvisitNodeList(node.expressions);\n\t}\n\tconstructor(protected quasis: string[], protected expressions: ExpressionNode[], protected tag?: ExpressionNode,) {\n\t\tsuper();\n\t}\n\tgetTag() {\n\t\treturn this.tag;\n\t}\n\tgetExpressions() {\n\t\treturn this.expressions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.expressions.forEach(value => value.shareVariables(scopeList));\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`TemplateLiteralExpressionNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst tagged: Function = this.tag?.get(stack) || String.raw;\n\t\tconst templateStringsArray = new TemplateArray(this.quasis);\n\t\ttemplateStringsArray.raw = templateStringsArray;\n\t\tconst values = this.expressions.map(expr => expr.get(stack));\n\t\treturn tagged(templateStringsArray, ...values);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tlet str = this.tag?.toString() || '';\n\t\tstr += '`';\n\t\tlet i = 0;\n\t\tfor (; i < this.quasis.length - 1; i++) {\n\t\t\tstr += this.quasis[i];\n\t\t\tstr += '${';\n\t\t\tstr += this.expressions[i].toString();\n\t\t\tstr += '}';\n\t\t}\n\t\tstr += this.quasis[i];\n\t\tstr += '`';\n\t\treturn str;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tquasis: this.quasis,\n\t\t\texpressions: this.expressions.map(expr => expr.toJSON()),\n\t\t\ttag: this.tag?.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('TemplateLiteral')\nexport class TemplateLiteral extends TemplateLiteralExpressionNode {\n\tprotected tag: undefined;\n\tconstructor(quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions);\n\t}\n\toverride getTag(): undefined {\n\t\treturn undefined;\n\t}\n}\n\n@Deserializer('TaggedTemplateExpression')\nexport class TaggedTemplateExpression extends TemplateLiteralExpressionNode {\n\tprotected tag: ExpressionNode;\n\tconstructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions, tag);\n\t}\n\toverride getTag(): ExpressionNode {\n\t\treturn super.getTag()!;\n\t}\n}\n\n\n@Deserializer('NumberLiteral')\nexport class NumberLiteral extends Literal<number> {\n\tstatic fromJSON(node: NumberLiteral): NumberLiteral {\n\t\treturn new NumberLiteral(node.value);\n\t}\n\tconstructor(value: number) {\n\t\tsuper(value);\n\t}\n}\n\n@Deserializer('BigIntLiteral')\nexport class BigIntLiteral extends Literal<bigint> {\n\tstatic fromJSON(node: BigIntLiteral): BigIntLiteral {\n\t\treturn new BigIntLiteral(BigInt(String(node.value)));\n\t}\n\ttoString(): string {\n\t\treturn `${this.value}n`;\n\t}\n\ttoJson(): object {\n\t\treturn { value: this.value.toString() };\n\t}\n}\n@Deserializer('RegExpLiteral')\nexport class RegExpLiteral extends Literal<RegExp> {\n\tstatic fromJSON(node: RegExpLiteral & { regex: { pattern: string, flags: string } }): RegExpLiteral {\n\t\treturn new RegExpLiteral(new RegExp(node.regex.pattern, node.regex.flags));\n\t}\n\ttoString(): string {\n\t\treturn `${this.value}n`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tregex: {\n\t\t\t\tpattern: this.value.source,\n\t\t\t\tflags: this.value.flags\n\t\t\t}\n\t\t};;\n\t}\n}\n\nexport const TRUE = String(true);\nexport const FALSE = String(false);\n@Deserializer('BooleanLiteral')\nexport class BooleanLiteral extends Literal<boolean> {\n\tstatic fromJSON(node: BooleanLiteral): BooleanLiteral {\n\t\tswitch (String(node.value)) {\n\t\t\tcase TRUE: return TrueNode;\n\t\t\tcase FALSE:\n\t\t\tdefault:\n\t\t\t\treturn FalseNode;\n\t\t}\n\t}\n}\n\nexport const NULL = String(null);\nexport const UNDEFINED = String(undefined);\n\n@Deserializer('NullishLiteral')\nexport class NullishLiteral extends Literal<null | undefined> {\n\tstatic fromJSON(node: NullishLiteral): NullishLiteral {\n\t\tswitch (String(node.value)) {\n\t\t\tcase NULL: return NullNode;\n\t\t\tcase UNDEFINED:\n\t\t\tdefault: return UndefinedNode;\n\t\t}\n\t}\n\n\ttoString(): string {\n\t\tif (typeof this.value === 'undefined') {\n\t\t\treturn UNDEFINED;\n\t\t}\n\t\treturn NULL;\n\t}\n\ttoJson(): object {\n\t\treturn { value: this.toString() };\n\t}\n}\n\n@Deserializer('ThisExpression')\nexport class ThisExpression extends Identifier {\n\tstatic fromJSON(node: ThisExpression): ThisExpression {\n\t\treturn ThisNode;\n\t}\n\tconstructor() {\n\t\tsuper('this');\n\t}\n}\n\nexport const NullNode = Object.freeze(new NullishLiteral(null)) as NullishLiteral;\nexport const UndefinedNode = Object.freeze(new NullishLiteral(undefined)) as NullishLiteral;\nexport const TrueNode = Object.freeze(new BooleanLiteral(true)) as BooleanLiteral;\nexport const FalseNode = Object.freeze(new BooleanLiteral(false)) as BooleanLiteral;\nexport const ThisNode = Object.freeze(new ThisExpression()) as ThisExpression;\nexport const GlobalThisNode = Object.freeze(new Identifier('globalThis')) as Identifier;\nexport const SymbolNode = Object.freeze(new Identifier('Symbol')) as Identifier;\nexport const OfNode = Object.freeze(new Identifier('of')) as Identifier;\nexport const AsNode = Object.freeze(new Identifier('as')) as Identifier;\nexport const GetIdentifier = Object.freeze(new Identifier('get')) as Identifier;\nexport const SetIdentifier = Object.freeze(new Identifier('set')) as Identifier;\nexport const AsyncIdentifier = Object.freeze(new Identifier('async')) as Identifier;\nexport const AwaitIdentifier = Object.freeze(new Identifier('await')) as Identifier;\nexport const ConstructorIdentifier = Object.freeze(new Identifier('constructor')) as Identifier;\nexport const NameIdentifier = Object.freeze(new Identifier('name')) as Identifier;\nexport const EvalIdentifier = Object.freeze(new Identifier('eval')) as Identifier;\nexport const ArgumentsIdentifier = Object.freeze(new Identifier('arguments')) as Identifier;\n"]}
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/values.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;;GAQG;AAEH,IAAa,UAAU,kBAAvB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AAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,aAAa,CAAC,CAAe,CAAC;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAe,CAAC;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,CAAe,CAAC;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAe,CAAC;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAe,CAAC","sourcesContent":["import type {\n\tDeclarationExpression, ExpressionNode, NodeDeserializer,\n\tCanFindScope, ExpressionEventPath, VisitNodeType\n} from '../expression.js';\nimport type { Scope } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { AbstractExpressionNode } from '../abstract.js';\n\n/**\n * An identifier is a sequence of characters in the code that identifies a variable, function, or property.\n * In JavaScript, identifiers are case-sensitive and can contain Unicode letters, $, _, and digits (0-9),\n * but may not start with a digit.\n * An identifier differs from a string in that a string is data,\n * while an identifier is part of the code. In JavaScript,\n * there is no way to convert identifiers to strings,\n * but sometimes it is possible to parse strings into identifiers.\n */\n@Deserializer('Identifier')\nexport class Identifier extends AbstractExpressionNode implements DeclarationExpression, CanFindScope {\n\tstatic fromJSON(node: Identifier): Identifier {\n\t\treturn new Identifier(node.name);\n\t}\n\tconstructor(protected name: string | number) {\n\t\tsuper();\n\t}\n\tgetName() {\n\t\treturn this.name;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack, value: any) {\n\t\treturn stack.set(this.name, value) ? value : void 0;\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tif (thisContext) {\n\t\t\treturn thisContext[this.name];\n\t\t}\n\t\treturn stack.get(this.name);\n\t}\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope?: Scope<any>): Scope<T> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope(this.name);\n\t\t}\n\t\tscope = stack.findScope(this.name);\n\t\treturn scope.getScope(this.name);\n\t}\n\tdeclareVariable(stack: Stack, propertyValue: any): any {\n\t\treturn stack.declareVariable(this.name, propertyValue);\n\t}\n\tgetDeclarationName(): string {\n\t\treturn this.toString();\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [this];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tconst path: ExpressionEventPath[] = [{ computed: false, path: this.toString() }];\n\t\treturn computed ? [{ computed, path: this.toString(), computedPath: [path] }] : path;\n\t}\n\ttoString(): string {\n\t\treturn String(this.name);\n\t}\n\ttoJson(): object {\n\t\treturn { name: this.name };\n\t}\n}\n\n@Deserializer('ThisExpression')\nexport class ThisExpression extends Identifier {\n\tstatic fromJSON(node: ThisExpression): ThisExpression {\n\t\treturn ThisNode;\n\t}\n\tconstructor() {\n\t\tsuper('this');\n\t}\n}\n\n@Deserializer('Literal')\nexport class Literal<T> extends AbstractExpressionNode implements CanFindScope {\n\tstatic fromJSON(node: Literal<any>):\n\t\tLiteral<string>\n\t\t| Literal<number>\n\t\t| Literal<boolean>\n\t\t| Literal<RegExp>\n\t\t| Literal<bigint>\n\t\t| Literal<null>\n\t\t| Literal<undefined> {\n\t\tif (node.bigint) {\n\t\t\treturn new Literal(BigInt(node.bigint), node.raw, undefined, node.bigint);\n\t\t} else if (node.regex) {\n\t\t\treturn new Literal(RegExp(node.regex.pattern, node.regex.flags), node.raw, node.regex);\n\t\t}\n\t\treturn new Literal(node.value, node.raw);\n\t}\n\tconstructor(protected value: T, protected raw?: string, protected regex?: { pattern: string, flags: string }, protected bigint?: string) {\n\t\tsuper();\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tgetRegex() {\n\t\treturn this.regex;\n\t}\n\tgetBigint() {\n\t\treturn this.bigint;\n\t}\n\tgeRaw() {\n\t\treturn this.raw;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset() {\n\t\tthrow new Error(`${this.constructor.name}#set() has no implementation.`);\n\t}\n\tget(): T {\n\t\treturn this.value;\n\t}\n\tfindScope<V extends object>(stack: Stack): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope: Scope<any>): Scope<V>;\n\tfindScope<V extends object>(stack: Stack, scope?: Scope<any>): Scope<V> | undefined {\n\t\tif (scope) {\n\t\t\treturn scope.getScope<V>(this.value as any);\n\t\t}\n\t\tscope = stack.findScope<V>(this.value as any);\n\t\treturn scope.getScope<V>(this.value as any);\n\t}\n\tdependency(computed: true): ExpressionNode[] {\n\t\treturn computed ? [this] : [];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn computed ? [{ computed: false, path: this.toString() }] : [];\n\t}\n\ttoString(): string {\n\t\treturn this.raw ?? String(this.value);\n\t}\n\ttoJson(): object {\n\t\tif (this.bigint) {\n\t\t\treturn {\n\t\t\t\tbigint: this.bigint,\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t} else if (this.regex) {\n\t\t\treturn {\n\t\t\t\tregex: { pattern: this.regex?.pattern, flags: this.regex?.flags },\n\t\t\t\traw: this.raw,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t\traw: this.raw,\n\t\t};\n\t}\n}\n\nclass TemplateArray extends Array<string> implements TemplateStringsArray {\n\traw: readonly string[];\n\tconstructor(strings: string[]) {\n\t\tsuper(...strings);\n\t\tthis.raw = strings;\n\t}\n}\n\nexport class TemplateLiteralExpressionNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode {\n\t\treturn new TemplateLiteralExpressionNode(\n\t\t\tnode.quasis,\n\t\t\tnode.expressions.map(deserializer),\n\t\t\tnode.tag ? deserializer(node.tag) : void 0\n\t\t);\n\t}\n\tstatic visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType): void {\n\t\tnode.tag && visitNode(node.tag);\n\t\tnode.expressions.forEach(visitNode);\n\t}\n\tconstructor(protected quasis: string[], protected expressions: ExpressionNode[], protected tag?: ExpressionNode,) {\n\t\tsuper();\n\t}\n\tgetTag() {\n\t\treturn this.tag;\n\t}\n\tgetExpressions() {\n\t\treturn this.expressions;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.expressions.forEach(value => value.shareVariables(scopeList));\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`TemplateLiteralExpressionNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst tagged: Function = this.tag?.get(stack) || String.raw;\n\t\tconst templateStringsArray = new TemplateArray(this.quasis);\n\t\ttemplateStringsArray.raw = templateStringsArray;\n\t\tconst values = this.expressions.map(expr => expr.get(stack));\n\t\treturn tagged(templateStringsArray, ...values);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.expressions.flatMap(exp => exp.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tlet str = this.tag?.toString() || '';\n\t\tstr += '`';\n\t\tlet i = 0;\n\t\tfor (; i < this.quasis.length - 1; i++) {\n\t\t\tstr += this.quasis[i];\n\t\t\tstr += '${';\n\t\t\tstr += this.expressions[i].toString();\n\t\t\tstr += '}';\n\t\t}\n\t\tstr += this.quasis[i];\n\t\tstr += '`';\n\t\treturn str;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tquasis: this.quasis,\n\t\t\texpressions: this.expressions.map(expr => expr.toJSON()),\n\t\t\ttag: this.tag?.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('TemplateLiteral')\nexport class TemplateLiteral extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: undefined;\n\tconstructor(quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions);\n\t}\n\toverride getTag(): undefined {\n\t\treturn undefined;\n\t}\n}\n\n@Deserializer('TaggedTemplateExpression')\nexport class TaggedTemplateExpression extends TemplateLiteralExpressionNode {\n\tdeclare protected tag: ExpressionNode;\n\tconstructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]) {\n\t\tsuper(quasis, expressions, tag);\n\t}\n\toverride getTag(): ExpressionNode {\n\t\treturn super.getTag()!;\n\t}\n}\n\n\n// @Deserializer('BigIntLiteral')\n// export class BigIntLiteral extends Literal<bigint> {\n// \tstatic fromJSON(node: BigIntLiteral): BigIntLiteral {\n// \t\treturn new BigIntLiteral(BigInt(String(node.value)));\n// \t}\n// \ttoString(): string {\n// \t\treturn `${this.value}n`;\n// \t}\n// \ttoJson(): object {\n// \t\treturn { value: this.value.toString() };\n// \t}\n// }\n\n\nexport const TRUE = String(true);\nexport const FALSE = String(false);\n\nexport const NULL = String(null);\nexport const UNDEFINED = String(undefined);\n\nexport const NullNode = Object.freeze(new Literal<null>(null)) as Literal<null>;\nexport const UndefinedNode = Object.freeze(new Literal<undefined>(undefined)) as Literal<undefined>;\nexport const TrueNode = Object.freeze(new Literal<boolean>(true)) as Literal<boolean>;\nexport const FalseNode = Object.freeze(new Literal<boolean>(false)) as Literal<boolean>;\nexport const ThisNode = Object.freeze(new ThisExpression()) as ThisExpression;\nexport const GlobalThisNode = Object.freeze(new Identifier('globalThis')) as Identifier;\nexport const SymbolNode = Object.freeze(new Identifier('Symbol')) as Identifier;\nexport const OfNode = Object.freeze(new Identifier('of')) as Identifier;\nexport const AsNode = Object.freeze(new Identifier('as')) as Identifier;\nexport const DefaultNode = Object.freeze(new Identifier('default')) as Identifier;\nexport const GetIdentifier = Object.freeze(new Identifier('get')) as Identifier;\nexport const SetIdentifier = Object.freeze(new Identifier('set')) as Identifier;\nexport const AsyncIdentifier = Object.freeze(new Identifier('async')) as Identifier;\nexport const AwaitIdentifier = Object.freeze(new Identifier('await')) as Identifier;\nexport const ConstructorIdentifier = Object.freeze(new Identifier('constructor')) as Identifier;\nexport const NameIdentifier = Object.freeze(new Identifier('name')) as Identifier;\nexport const EvalIdentifier = Object.freeze(new Identifier('eval')) as Identifier;\nexport const ArgumentsIdentifier = Object.freeze(new Identifier('arguments')) as Identifier;\nexport const YieldIdentifier = Object.freeze(new Identifier('yield')) as Identifier;\nexport const SuperIdentifier = Object.freeze(new Identifier('super')) as Identifier;\nexport const LetIdentifier = Object.freeze(new Identifier('let')) as Identifier;\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { ExpressionNode } from '../expression.js';
|
|
1
|
+
import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';
|
|
2
2
|
export declare function Deserializer(type: string): Function;
|
|
3
|
+
export declare function getDeserializerType(target: ExpressionNodConstructor<ExpressionNode>): string;
|
|
3
4
|
export declare function serializeNode(node: ExpressionNode): string;
|
|
5
|
+
/**
|
|
6
|
+
* convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`
|
|
7
|
+
* @param node as type `NodeJsonType`
|
|
8
|
+
* @returns ExpressionNode
|
|
9
|
+
*/
|
|
4
10
|
export declare function deserialize(node: ExpressionNode): ExpressionNode;
|
|
5
11
|
export declare function deserializeNode(node: string): ExpressionNode;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { expressionTypes } from './type-store.js';
|
|
2
2
|
export function Deserializer(type) {
|
|
3
3
|
return (target) => {
|
|
4
|
-
|
|
4
|
+
target.type = type;
|
|
5
5
|
expressionTypes.set(type, target);
|
|
6
6
|
return target;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
export function getDeserializerType(target) {
|
|
10
|
+
return target.type;
|
|
11
|
+
}
|
|
9
12
|
export function serializeNode(node) {
|
|
10
13
|
return JSON.stringify(node);
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`
|
|
17
|
+
* @param node as type `NodeJsonType`
|
|
18
|
+
* @returns ExpressionNode
|
|
19
|
+
*/
|
|
12
20
|
export function deserialize(node) {
|
|
13
21
|
const fromJSON = expressionTypes.get(node.type)?.fromJSON;
|
|
14
22
|
if (fromJSON) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/deserialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"deserialize.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/deserialize.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,CAAC,MAAgD,EAAE,EAAE;QAC3D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAgD;IACnF,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAoB;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAGD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAoB;IAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAO,IAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACjE,IAAI,QAAQ,EAAE;QACb,OAAO,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KACnC;SAAM;QACN,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACrF;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","sourcesContent":["import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';\nimport { expressionTypes } from './type-store.js';\n\n\n\nexport function Deserializer(type: string): Function {\n\treturn (target: ExpressionNodConstructor<ExpressionNode>) => {\n\t\ttarget.type = type;\n\t\texpressionTypes.set(type, target);\n\t\treturn target;\n\t};\n}\n\nexport function getDeserializerType(target: ExpressionNodConstructor<ExpressionNode>) {\n\treturn target.type;\n}\n\nexport function serializeNode(node: ExpressionNode) {\n\treturn JSON.stringify(node);\n}\n\n\n/**\n * convert from json expression `JSON.stringify(node)` or `serializeNode` to `ExpressionNode`\n * @param node as type `NodeJsonType`\n * @returns ExpressionNode\n */\nexport function deserialize(node: ExpressionNode) {\n\tconst fromJSON = expressionTypes.get((<any>node).type)?.fromJSON;\n\tif (fromJSON) {\n\t\treturn fromJSON(node, deserialize);\n\t} else {\n\t\tthrow new Error(`Couldn't find Expression class for name: ${JSON.stringify(node)}.`);\n\t}\n}\n\nexport function deserializeNode(node: string) {\n\tconst exp = JSON.parse(node);\n\treturn deserialize(exp);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExpressionNode,
|
|
2
|
-
export declare const expressionTypes: Map<string,
|
|
1
|
+
import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';
|
|
2
|
+
export declare const expressionTypes: Map<string, ExpressionNodConstructor<ExpressionNode>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-store.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/type-store.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"type-store.js","sourceRoot":"","sources":["../../../../src/expressions/api/deserialize/type-store.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAA0D,IAAI,GAAG,EAAE,CAAC","sourcesContent":["import type { ExpressionNode, ExpressionNodConstructor } from '../expression.js';\n\n\nexport const expressionTypes: Map<string, ExpressionNodConstructor<ExpressionNode>> = new Map();\n"]}
|