@ibyar/expressions 0.8.5 → 1.0.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/api/abstract.d.ts +1 -0
- package/api/abstract.d.ts.map +1 -0
- package/api/abstract.js +12 -0
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +1 -0
- package/api/class/class.d.ts.map +1 -0
- package/api/class/class.js +563 -482
- package/api/class/class.js.map +1 -1
- package/api/class/decorator.d.ts +1 -0
- package/api/class/decorator.d.ts.map +1 -0
- package/api/class/decorator.js +49 -42
- package/api/class/decorator.js.map +1 -1
- package/api/computing/call.d.ts +1 -0
- package/api/computing/call.d.ts.map +1 -0
- package/api/computing/call.js +79 -70
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +1 -0
- package/api/computing/debugger.d.ts.map +1 -0
- package/api/computing/debugger.js +36 -29
- package/api/computing/debugger.js.map +1 -1
- package/api/computing/new.d.ts +1 -0
- package/api/computing/new.d.ts.map +1 -0
- package/api/computing/new.js +77 -69
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +1 -0
- package/api/computing/rest.d.ts.map +1 -0
- package/api/computing/rest.js +50 -43
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +1 -0
- package/api/computing/return.d.ts.map +1 -0
- package/api/computing/return.js +48 -41
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +1 -0
- package/api/computing/spread.d.ts.map +1 -0
- package/api/computing/spread.js +66 -59
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +1 -0
- package/api/computing/throw.d.ts.map +1 -0
- package/api/computing/throw.js +204 -178
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +1 -0
- package/api/computing/yield.d.ts.map +1 -0
- package/api/computing/yield.js +56 -48
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +1 -0
- package/api/definition/array.d.ts.map +1 -0
- package/api/definition/array.js +139 -124
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +1 -0
- package/api/definition/bind.d.ts.map +1 -0
- package/api/definition/bind.js +81 -71
- package/api/definition/bind.js.map +1 -1
- package/api/definition/comment.d.ts +1 -0
- package/api/definition/comment.d.ts.map +1 -0
- package/api/definition/comment.js +40 -33
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +1 -0
- package/api/definition/function.d.ts.map +1 -0
- package/api/definition/function.js +484 -447
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +1 -0
- package/api/definition/member.d.ts.map +1 -0
- package/api/definition/member.js +100 -90
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +1 -0
- package/api/definition/object.d.ts.map +1 -0
- package/api/definition/object.js +230 -202
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +1 -0
- package/api/definition/statement.d.ts.map +1 -0
- package/api/definition/statement.js +52 -45
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +1 -0
- package/api/definition/values.d.ts.map +1 -0
- package/api/definition/values.js +210 -167
- package/api/definition/values.js.map +1 -1
- package/api/deserialize/deserialize.d.ts +2 -1
- package/api/deserialize/deserialize.d.ts.map +1 -0
- package/api/deserialize/deserialize.js +5 -7
- package/api/deserialize/deserialize.js.map +1 -1
- package/api/deserialize/type-store.d.ts +1 -0
- package/api/deserialize/type-store.d.ts.map +1 -0
- package/api/expression.d.ts +1 -0
- package/api/expression.d.ts.map +1 -0
- package/api/index.d.ts +1 -0
- package/api/index.d.ts.map +1 -0
- package/api/module/common.d.ts +1 -0
- package/api/module/common.d.ts.map +1 -0
- package/api/module/common.js +59 -51
- package/api/module/common.js.map +1 -1
- package/api/module/export.d.ts +1 -0
- package/api/module/export.d.ts.map +1 -0
- package/api/module/export.js +327 -294
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +1 -0
- package/api/module/import.d.ts.map +1 -0
- package/api/module/import.js +298 -258
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +1 -0
- package/api/operators/assignment.d.ts.map +1 -0
- package/api/operators/assignment.js +84 -75
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +1 -0
- package/api/operators/await.d.ts.map +1 -0
- package/api/operators/await.js +50 -43
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +1 -0
- package/api/operators/binary.d.ts.map +1 -0
- package/api/operators/binary.js +74 -64
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +1 -0
- package/api/operators/chaining.d.ts.map +1 -0
- package/api/operators/chaining.js +52 -45
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +1 -0
- package/api/operators/comma.d.ts.map +1 -0
- package/api/operators/comma.js +49 -42
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +1 -0
- package/api/operators/grouping.d.ts.map +1 -0
- package/api/operators/grouping.js +47 -40
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +1 -0
- package/api/operators/logical.d.ts.map +1 -0
- package/api/operators/logical.js +47 -37
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +1 -0
- package/api/operators/pipeline.d.ts.map +1 -0
- package/api/operators/pipeline.js +91 -82
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +1 -0
- package/api/operators/ternary.d.ts.map +1 -0
- package/api/operators/ternary.js +65 -56
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/types.d.ts +1 -0
- package/api/operators/types.d.ts.map +1 -0
- package/api/operators/unary.d.ts +1 -0
- package/api/operators/unary.d.ts.map +1 -0
- package/api/operators/unary.js +93 -82
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +1 -0
- package/api/operators/update.d.ts.map +1 -0
- package/api/operators/update.js +74 -62
- package/api/operators/update.js.map +1 -1
- package/api/program.d.ts +1 -0
- package/api/program.d.ts.map +1 -0
- package/api/program.js +49 -41
- package/api/program.js.map +1 -1
- package/api/statement/control/block.d.ts +1 -0
- package/api/statement/control/block.d.ts.map +1 -0
- package/api/statement/control/block.js +61 -54
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +1 -1
- package/api/statement/control/empty.d.ts.map +1 -0
- package/api/statement/control/empty.js +39 -34
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +1 -0
- package/api/statement/control/if.d.ts.map +1 -0
- package/api/statement/control/if.js +75 -66
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +1 -0
- package/api/statement/control/switch.d.ts.map +1 -0
- package/api/statement/control/switch.js +168 -144
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +1 -2
- package/api/statement/control/terminate.d.ts.map +1 -0
- package/api/statement/control/terminate.js +105 -81
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/control/with.d.ts +1 -0
- package/api/statement/control/with.d.ts.map +1 -0
- package/api/statement/control/with.js +68 -60
- package/api/statement/control/with.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +1 -0
- package/api/statement/declarations/declares.d.ts.map +1 -0
- package/api/statement/declarations/declares.js +140 -123
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +1 -0
- package/api/statement/iterations/for.d.ts.map +1 -0
- package/api/statement/iterations/for.js +320 -280
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +1 -0
- package/api/statement/iterations/while.d.ts.map +1 -0
- package/api/statement/iterations/while.js +144 -127
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +1 -0
- package/api/utils.d.ts.map +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/scope/event.d.ts +1 -0
- package/scope/event.d.ts.map +1 -0
- package/scope/finalizer.d.ts +1 -0
- package/scope/finalizer.d.ts.map +1 -0
- package/scope/index.d.ts +1 -0
- package/scope/index.d.ts.map +1 -0
- package/scope/pool.d.ts +1 -0
- package/scope/pool.d.ts.map +1 -0
- package/scope/proxy.d.ts +1 -0
- package/scope/proxy.d.ts.map +1 -0
- package/scope/proxy.js +1 -0
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +1 -0
- package/scope/scope.d.ts.map +1 -0
- package/scope/scope.js +17 -11
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +1 -0
- package/scope/stack.d.ts.map +1 -0
- package/scope/stack.js +21 -13
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +1 -0
- package/v8/enums.d.ts.map +1 -0
- package/v8/enums.js +15 -13
- package/v8/enums.js.map +1 -1
- package/v8/factory.d.ts +1 -0
- package/v8/factory.d.ts.map +1 -0
- package/v8/factory.js +6 -4
- package/v8/factory.js.map +1 -1
- package/v8/index.d.ts +1 -0
- package/v8/index.d.ts.map +1 -0
- package/v8/inline.d.ts +1 -0
- package/v8/inline.d.ts.map +1 -0
- package/v8/inline.js +10 -6
- package/v8/inline.js.map +1 -1
- package/v8/language.d.ts +1 -0
- package/v8/language.d.ts.map +1 -0
- package/v8/node.d.ts +1 -0
- package/v8/node.d.ts.map +1 -0
- package/v8/parser.d.ts +1 -0
- package/v8/parser.d.ts.map +1 -0
- package/v8/parser.js +5 -5
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +1 -0
- package/v8/stream.d.ts.map +1 -0
- package/v8/stream.js +19 -8
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +1 -0
- package/v8/token.d.ts.map +1 -0
- package/v8/token.js +365 -359
- package/v8/token.js.map +1 -1
- package/visit/index.d.ts +1 -0
- package/visit/index.d.ts.map +1 -0
- package/visit/visitor.d.ts +1 -0
- package/visit/visitor.d.ts.map +1 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
3
2
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
3
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
4
|
import { SpreadElement } from '../computing/spread.js';
|
|
@@ -16,91 +15,101 @@ import { MemberExpression } from '../definition/member.js';
|
|
|
16
15
|
* param |> func(arg1, ?, arg3)
|
|
17
16
|
* param |> func(arg1, ?, arg3, arg4, ?, arg6)
|
|
18
17
|
*/
|
|
19
|
-
let PipelineExpression =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
18
|
+
export let PipelineExpression = (() => {
|
|
19
|
+
let _classDecorators = [Deserializer('PipelineExpression')];
|
|
20
|
+
let _classDescriptor;
|
|
21
|
+
let _classExtraInitializers = [];
|
|
22
|
+
let _classThis;
|
|
23
|
+
var PipelineExpression = class extends AbstractExpressionNode {
|
|
24
|
+
static {
|
|
25
|
+
__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers);
|
|
26
|
+
PipelineExpression = _classThis = _classDescriptor.value;
|
|
27
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
28
|
+
}
|
|
29
|
+
left;
|
|
30
|
+
right;
|
|
31
|
+
static fromJSON(node, deserializer) {
|
|
32
|
+
return new PipelineExpression(deserializer(node.left), deserializer(node.right), node.arguments.map(arg => typeof arg === 'string' ? arg : deserializer(arg)), node.range, node.loc);
|
|
33
|
+
}
|
|
34
|
+
static visit(node, visitNode) {
|
|
35
|
+
visitNode(node.left);
|
|
36
|
+
visitNode(node.right);
|
|
37
|
+
node.arguments.forEach(arg => typeof arg == 'object' && visitNode(arg));
|
|
38
|
+
}
|
|
39
|
+
arguments;
|
|
40
|
+
constructor(left, right, params = [], range, loc) {
|
|
41
|
+
super(range, loc);
|
|
42
|
+
this.left = left;
|
|
43
|
+
this.right = right;
|
|
44
|
+
this.arguments = params;
|
|
45
|
+
}
|
|
46
|
+
getLeft() {
|
|
47
|
+
return this.left;
|
|
48
|
+
}
|
|
49
|
+
getRight() {
|
|
50
|
+
return this.right;
|
|
51
|
+
}
|
|
52
|
+
getArguments() {
|
|
53
|
+
return this.arguments;
|
|
54
|
+
}
|
|
55
|
+
set(stack, value) {
|
|
56
|
+
throw new Error(`PipelineNode#set() has no implementation.`);
|
|
57
|
+
}
|
|
58
|
+
get(stack) {
|
|
59
|
+
const paramValue = this.left.get(stack);
|
|
60
|
+
const parameters = [];
|
|
61
|
+
let indexed = false;
|
|
62
|
+
for (const arg of this.arguments) {
|
|
63
|
+
if (arg === '?') {
|
|
64
|
+
parameters.push(paramValue);
|
|
65
|
+
indexed = true;
|
|
66
|
+
}
|
|
67
|
+
else if (arg === '...?') {
|
|
68
|
+
parameters.push(...paramValue);
|
|
69
|
+
indexed = true;
|
|
64
70
|
}
|
|
65
71
|
else {
|
|
66
|
-
|
|
72
|
+
if (arg instanceof SpreadElement) {
|
|
73
|
+
const paramScope = stack.pushBlockScopeFor(parameters);
|
|
74
|
+
arg.get(stack);
|
|
75
|
+
stack.clearTo(paramScope);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
parameters.push(arg.get(stack));
|
|
79
|
+
}
|
|
67
80
|
}
|
|
68
81
|
}
|
|
82
|
+
if (!indexed) {
|
|
83
|
+
parameters.unshift(paramValue);
|
|
84
|
+
}
|
|
85
|
+
const funCallBack = this.right.get(stack);
|
|
86
|
+
if (this.right instanceof MemberExpression) {
|
|
87
|
+
const thisArg = this.right.getObject().get(stack);
|
|
88
|
+
return funCallBack.apply(thisArg, parameters);
|
|
89
|
+
}
|
|
90
|
+
return funCallBack(...parameters);
|
|
91
|
+
}
|
|
92
|
+
dependency(computed) {
|
|
93
|
+
return this.right.dependency(computed)
|
|
94
|
+
.concat(this.left.dependency(computed), this.arguments.filter(arg => (arg !== '?' && arg !== '...?'))
|
|
95
|
+
.flatMap(param => param.dependency(computed)));
|
|
96
|
+
}
|
|
97
|
+
dependencyPath(computed) {
|
|
98
|
+
return this.right.dependencyPath(computed)
|
|
99
|
+
.concat(this.left.dependencyPath(computed), this.arguments.filter(arg => (arg !== '?' && arg !== '...?'))
|
|
100
|
+
.flatMap(param => param.dependencyPath(computed)));
|
|
69
101
|
}
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
toString() {
|
|
103
|
+
return `${this.left.toString()} |> ${this.right.toString()}${this.arguments.flatMap(arg => `:${arg.toString()}`).join('')}`;
|
|
72
104
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
105
|
+
toJson() {
|
|
106
|
+
return {
|
|
107
|
+
left: this.left.toJSON(),
|
|
108
|
+
right: this.right.toJSON(),
|
|
109
|
+
arguments: this.arguments.map(arg => typeof arg === 'string' ? arg : arg.toJSON())
|
|
110
|
+
};
|
|
77
111
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return this.right.dependency(computed)
|
|
82
|
-
.concat(this.left.dependency(computed), this.arguments.filter(arg => (arg !== '?' && arg !== '...?'))
|
|
83
|
-
.flatMap(param => param.dependency(computed)));
|
|
84
|
-
}
|
|
85
|
-
dependencyPath(computed) {
|
|
86
|
-
return this.right.dependencyPath(computed)
|
|
87
|
-
.concat(this.left.dependencyPath(computed), this.arguments.filter(arg => (arg !== '?' && arg !== '...?'))
|
|
88
|
-
.flatMap(param => param.dependencyPath(computed)));
|
|
89
|
-
}
|
|
90
|
-
toString() {
|
|
91
|
-
return `${this.left.toString()} |> ${this.right.toString()}${this.arguments.flatMap(arg => `:${arg.toString()}`).join('')}`;
|
|
92
|
-
}
|
|
93
|
-
toJson() {
|
|
94
|
-
return {
|
|
95
|
-
left: this.left.toJSON(),
|
|
96
|
-
right: this.right.toJSON(),
|
|
97
|
-
arguments: this.arguments.map(arg => typeof arg === 'string' ? arg : arg.toJSON())
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
PipelineExpression = PipelineExpression_1 = __decorate([
|
|
102
|
-
Deserializer('PipelineExpression'),
|
|
103
|
-
__metadata("design:paramtypes", [Object, Object, Array, Array, Object])
|
|
104
|
-
], PipelineExpression);
|
|
105
|
-
export { PipelineExpression };
|
|
112
|
+
};
|
|
113
|
+
return PipelineExpression = _classThis;
|
|
114
|
+
})();
|
|
106
115
|
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../../src/expressions/api/operators/pipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../../src/expressions/api/operators/pipeline.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;;;;GAWG;AAEH,MAAM,KAAO,kBAAkB;4BAD9B,YAAY,CAAC,oBAAoB,CAAC;;;;QACtB,kBAAkB,QAAC,SAAQ,sBAAsB;;YAA9D,4IA8FC;YA9FY,kBAAkB;YAAlB,uDAAkB;;QAi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1B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;aAClF,CAAC;QACH,CAAC;;WA7FW,kBAAkB","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, ExpressionEventPath,\n\tVisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { SpreadElement } from '../computing/spread.js';\nimport { MemberExpression } from '../definition/member.js';\n\n/**\n * pipeline ('|>') operator support syntax:\n * param |> func\n * param |> func:arg1:arg2:arg3\n * param |> func:arg1:?:arg3\n * param |> func:arg1:?:arg3:?:arg5\n * param |> func:arg1:...?:arg3\n * \n * param |> func(arg1, arg2, arg3)\n * param |> func(arg1, ?, arg3)\n * param |> func(arg1, ?, arg3, arg4, ?, arg6)\n */\n@Deserializer('PipelineExpression')\nexport class PipelineExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: PipelineExpression, deserializer: NodeDeserializer): PipelineExpression {\n\t\treturn new PipelineExpression(\n\t\t\tdeserializer(node.left),\n\t\t\tdeserializer(node.right),\n\t\t\tnode.arguments.map(arg => typeof arg === 'string' ? arg : deserializer(arg)),\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: PipelineExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.left);\n\t\tvisitNode(node.right);\n\t\tnode.arguments.forEach(arg => typeof arg == 'object' && visitNode(arg));\n\t}\n\tprivate arguments: (ExpressionNode | '?' | '...?')[];\n\tconstructor(\n\t\tprivate left: ExpressionNode,\n\t\tprivate right: ExpressionNode,\n\t\tparams: (ExpressionNode | '?' | '...?')[] = [],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t\tthis.arguments = params;\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tgetArguments() {\n\t\treturn this.arguments;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`PipelineNode#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tconst paramValue = this.left.get(stack);\n\t\tconst parameters: any[] = [];\n\t\tlet indexed = false;\n\t\tfor (const arg of this.arguments) {\n\t\t\tif (arg === '?') {\n\t\t\t\tparameters.push(paramValue);\n\t\t\t\tindexed = true;\n\t\t\t} else if (arg === '...?') {\n\t\t\t\tparameters.push(...paramValue);\n\t\t\t\tindexed = true;\n\t\t\t} else {\n\t\t\t\tif (arg instanceof SpreadElement) {\n\t\t\t\t\tconst paramScope = stack.pushBlockScopeFor(parameters);\n\t\t\t\t\targ.get(stack);\n\t\t\t\t\tstack.clearTo(paramScope);\n\t\t\t\t} else {\n\t\t\t\t\tparameters.push(arg.get(stack));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!indexed) {\n\t\t\tparameters.unshift(paramValue);\n\t\t}\n\t\tconst funCallBack = this.right.get(stack) as Function;\n\t\tif (this.right instanceof MemberExpression) {\n\t\t\tconst thisArg = this.right.getObject().get(stack);\n\t\t\treturn funCallBack.apply(thisArg, parameters);\n\t\t}\n\t\treturn funCallBack(...parameters);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.right.dependency(computed)\n\t\t\t.concat(\n\t\t\t\tthis.left.dependency(computed),\n\t\t\t\t(this.arguments.filter(arg => (arg !== '?' && arg !== '...?')) as ExpressionNode[])\n\t\t\t\t\t.flatMap(param => param.dependency!(computed))\n\t\t\t);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.right.dependencyPath(computed)\n\t\t\t.concat(\n\t\t\t\tthis.left.dependencyPath(computed),\n\t\t\t\t(this.arguments.filter(arg => (arg !== '?' && arg !== '...?')) as ExpressionNode[])\n\t\t\t\t\t.flatMap(param => param.dependencyPath!(computed))\n\t\t\t);\n\t}\n\ttoString() {\n\t\treturn `${this.left.toString()} |> ${this.right.toString()}${this.arguments.flatMap(arg => `:${arg.toString()}`).join('')}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON(),\n\t\t\targuments: this.arguments.map(arg => typeof arg === 'string' ? arg : arg.toJSON())\n\t\t};\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ternary.d.ts","sourceRoot":"","sources":["../../../../src/expressions/api/operators/ternary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAAE,cAAc,EAAE,mBAAmB,EACrD,aAAa,EAAE,cAAc,EAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,qBACa,qBAAsB,SAAQ,sBAAsB;IAgB/D,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAjBnB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,GAAG,qBAAqB;IASnG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;gBAMhE,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,cAAc,EACzB,UAAU,EAAE,cAAc,EAClC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,GAAG,CAAC,EAAE,cAAc;IAGrB,OAAO;IAGP,YAAY;IAGZ,aAAa;IAGb,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG;IAG5B,GAAG,CAAC,KAAK,EAAE,KAAK;IAGhB,UAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,cAAc,EAAE;IAO7C,cAAc,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,mBAAmB,EAAE;IAOtD,QAAQ;IAGR,MAAM,IAAI,MAAM;CAOhB"}
|
package/api/operators/ternary.js
CHANGED
|
@@ -1,59 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
3
2
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
3
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
|
-
let ConditionalExpression =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
4
|
+
export let ConditionalExpression = (() => {
|
|
5
|
+
let _classDecorators = [Deserializer('ConditionalExpression')];
|
|
6
|
+
let _classDescriptor;
|
|
7
|
+
let _classExtraInitializers = [];
|
|
8
|
+
let _classThis;
|
|
9
|
+
var ConditionalExpression = class extends AbstractExpressionNode {
|
|
10
|
+
static {
|
|
11
|
+
__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers);
|
|
12
|
+
ConditionalExpression = _classThis = _classDescriptor.value;
|
|
13
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
14
|
+
}
|
|
15
|
+
test;
|
|
16
|
+
alternate;
|
|
17
|
+
consequent;
|
|
18
|
+
static fromJSON(node, deserializer) {
|
|
19
|
+
return new ConditionalExpression(deserializer(node.test), deserializer(node.alternate), deserializer(node.consequent), node.range, node.loc);
|
|
20
|
+
}
|
|
21
|
+
static visit(node, visitNode) {
|
|
22
|
+
visitNode(node.test);
|
|
23
|
+
visitNode(node.alternate);
|
|
24
|
+
visitNode(node.consequent);
|
|
25
|
+
}
|
|
26
|
+
constructor(test, alternate, consequent, range, loc) {
|
|
27
|
+
super(range, loc);
|
|
28
|
+
this.test = test;
|
|
29
|
+
this.alternate = alternate;
|
|
30
|
+
this.consequent = consequent;
|
|
31
|
+
}
|
|
32
|
+
getTest() {
|
|
33
|
+
return this.test;
|
|
34
|
+
}
|
|
35
|
+
getAlternate() {
|
|
36
|
+
return this.alternate;
|
|
37
|
+
}
|
|
38
|
+
getConsequent() {
|
|
39
|
+
return this.consequent;
|
|
40
|
+
}
|
|
41
|
+
set(stack, value) {
|
|
42
|
+
throw new Error(`ConditionalExpression#set() has no implementation.`);
|
|
43
|
+
}
|
|
44
|
+
get(stack) {
|
|
45
|
+
return this.test.get(stack) ? this.consequent.get(stack) : this.alternate.get(stack);
|
|
46
|
+
}
|
|
47
|
+
dependency(computed) {
|
|
48
|
+
return this.test.dependency(computed)
|
|
49
|
+
.concat(this.alternate.dependency(computed), this.consequent.dependency(computed));
|
|
50
|
+
}
|
|
51
|
+
dependencyPath(computed) {
|
|
52
|
+
return this.test.dependencyPath(computed)
|
|
53
|
+
.concat(this.alternate.dependencyPath(computed), this.consequent.dependencyPath(computed));
|
|
54
|
+
}
|
|
55
|
+
toString() {
|
|
56
|
+
return `${this.test.toString()} ? (${this.alternate.toString()}):(${this.consequent.toString()})`;
|
|
57
|
+
}
|
|
58
|
+
toJson() {
|
|
59
|
+
return {
|
|
60
|
+
test: this.test.toJSON(),
|
|
61
|
+
alternate: this.alternate.toJSON(),
|
|
62
|
+
consequent: this.consequent.toJSON()
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return ConditionalExpression = _classThis;
|
|
67
|
+
})();
|
|
59
68
|
//# sourceMappingURL=ternary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary.js","sourceRoot":"","sources":["../../../../src/expressions/api/operators/ternary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ternary.js","sourceRoot":"","sources":["../../../../src/expressions/api/operators/ternary.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,MAAM,KAAO,qBAAqB;4BADjC,YAAY,CAAC,uBAAuB,CAAC;;;;QACzB,qBAAqB,QAAC,SAAQ,sBAAsB;;YAAjE,4IA8DC;YA9DY,qBAAqB;YAArB,uDAAqB;;QAgBxB,IAAI;QACJ,SAAS;QACT,UAAU;QAjBnB,MAAM,CAAC,QAAQ,CAAC,IAA2B,EAAE,YAA8B;YAC1E,OAAO,IAAI,qBAAqB,CAC/B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAC5B,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,EAC7B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,GAAG,CACR,CAAC;QACH,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,IAA2B,EAAE,SAAwB;YACjE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC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,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CACxC,CAAC;QACJ,CAAC;QACD,QAAQ;YACP,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC;QACnG,CAAC;QACD,MAAM;YACL,OAAO;gBACN,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACxB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;gBAClC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;aACpC,CAAC;QACH,CAAC;;WA7DW,qBAAqB","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, ExpressionEventPath,\n\tVisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\n\n@Deserializer('ConditionalExpression')\nexport class ConditionalExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ConditionalExpression, deserializer: NodeDeserializer): ConditionalExpression {\n\t\treturn new ConditionalExpression(\n\t\t\tdeserializer(node.test),\n\t\t\tdeserializer(node.alternate),\n\t\t\tdeserializer(node.consequent),\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ConditionalExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.test);\n\t\tvisitNode(node.alternate);\n\t\tvisitNode(node.consequent);\n\t}\n\tconstructor(\n\t\tprivate test: ExpressionNode,\n\t\tprivate alternate: ExpressionNode,\n\t\tprivate consequent: ExpressionNode,\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetTest() {\n\t\treturn this.test;\n\t}\n\tgetAlternate() {\n\t\treturn this.alternate;\n\t}\n\tgetConsequent() {\n\t\treturn this.consequent;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ConditionalExpression#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\treturn this.test.get(stack) ? this.consequent.get(stack) : this.alternate.get(stack);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.test.dependency(computed)\n\t\t\t.concat(\n\t\t\t\tthis.alternate.dependency(computed),\n\t\t\t\tthis.consequent.dependency(computed)\n\t\t\t);\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.test.dependencyPath(computed)\n\t\t\t.concat(\n\t\t\t\tthis.alternate.dependencyPath(computed),\n\t\t\t\tthis.consequent.dependencyPath(computed)\n\t\t\t);\n\t}\n\ttoString() {\n\t\treturn `${this.test.toString()} ? (${this.alternate.toString()}):(${this.consequent.toString()})`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\ttest: this.test.toJSON(),\n\t\t\talternate: this.alternate.toJSON(),\n\t\t\tconsequent: this.consequent.toJSON()\n\t\t};\n\t}\n}\n"]}
|
package/api/operators/types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/expressions/api/operators/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,GAAG,CAAC;CACtB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,GAAG,CAAC"}
|
package/api/operators/unary.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../../../../src/expressions/api/operators/unary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAAE,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|
-
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
3
2
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
4
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
4
|
import { MemberExpression } from '../definition/member.js';
|
|
6
5
|
import { Literal } from '../definition/values.js';
|
|
7
|
-
let UnaryExpression =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.operator = operator;
|
|
17
|
-
this.argument = argument;
|
|
18
|
-
}
|
|
19
|
-
getOperator() {
|
|
20
|
-
return this.operator;
|
|
21
|
-
}
|
|
22
|
-
getArgument() {
|
|
23
|
-
return this.argument;
|
|
24
|
-
}
|
|
25
|
-
set(stack, value) {
|
|
26
|
-
return this.argument.set(stack, value);
|
|
27
|
-
}
|
|
28
|
-
get(stack, thisContext) {
|
|
29
|
-
switch (this.operator) {
|
|
30
|
-
case 'delete': return this.executeDelete(stack, thisContext);
|
|
31
|
-
default:
|
|
32
|
-
const value = this.argument.get(stack);
|
|
33
|
-
return UnaryExpression_1.Evaluations[this.operator](value);
|
|
6
|
+
let UnaryExpression = (() => {
|
|
7
|
+
let _classDecorators = [Deserializer('UnaryExpression')];
|
|
8
|
+
let _classDescriptor;
|
|
9
|
+
let _classExtraInitializers = [];
|
|
10
|
+
let _classThis;
|
|
11
|
+
var UnaryExpression = class extends AbstractExpressionNode {
|
|
12
|
+
static {
|
|
13
|
+
__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers);
|
|
14
|
+
UnaryExpression = _classThis = _classDescriptor.value;
|
|
34
15
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
operator;
|
|
17
|
+
argument;
|
|
18
|
+
static fromJSON(node, deserializer) {
|
|
19
|
+
return new UnaryExpression(node.operator, deserializer(node.argument), node.range, node.loc);
|
|
20
|
+
}
|
|
21
|
+
static visit(node, visitNode) {
|
|
22
|
+
visitNode(node.argument);
|
|
23
|
+
}
|
|
24
|
+
static Evaluations = {
|
|
25
|
+
'+': (value) => { return +value; },
|
|
26
|
+
'-': (value) => { return -value; },
|
|
27
|
+
'~': (value) => { return ~value; },
|
|
28
|
+
'!': (value) => { return !value; },
|
|
29
|
+
'void': (value) => { return void value; },
|
|
30
|
+
'typeof': (value) => { return typeof value; },
|
|
31
|
+
};
|
|
32
|
+
constructor(operator, argument, range, loc) {
|
|
33
|
+
super(range, loc);
|
|
34
|
+
this.operator = operator;
|
|
35
|
+
this.argument = argument;
|
|
36
|
+
}
|
|
37
|
+
getOperator() {
|
|
38
|
+
return this.operator;
|
|
39
|
+
}
|
|
40
|
+
getArgument() {
|
|
41
|
+
return this.argument;
|
|
42
|
+
}
|
|
43
|
+
set(stack, value) {
|
|
44
|
+
return this.argument.set(stack, value);
|
|
45
|
+
}
|
|
46
|
+
get(stack, thisContext) {
|
|
47
|
+
switch (this.operator) {
|
|
48
|
+
case 'delete': return this.executeDelete(stack, thisContext);
|
|
49
|
+
default:
|
|
50
|
+
const value = this.argument.get(stack);
|
|
51
|
+
return UnaryExpression.Evaluations[this.operator](value);
|
|
44
52
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
}
|
|
54
|
+
executeDelete(stack, thisContext) {
|
|
55
|
+
if (this.argument instanceof MemberExpression) {
|
|
56
|
+
const scope = this.argument.findScope(stack);
|
|
57
|
+
let propertyKey;
|
|
58
|
+
const right = this.argument.getProperty();
|
|
59
|
+
if (right instanceof MemberExpression) {
|
|
60
|
+
// [Symbol.asyncIterator]
|
|
61
|
+
propertyKey = this.argument.getProperty().get(stack);
|
|
62
|
+
}
|
|
63
|
+
else if (right instanceof Literal) {
|
|
64
|
+
// x[10], x['string'], x.name
|
|
65
|
+
propertyKey = right.getValue();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// x[u == 3 ? 'y': 'n']
|
|
69
|
+
propertyKey = this.argument.getProperty().get(stack);
|
|
70
|
+
}
|
|
71
|
+
return scope.delete(propertyKey);
|
|
48
72
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
dependency(computed) {
|
|
76
|
+
return this.argument.dependency(computed);
|
|
77
|
+
}
|
|
78
|
+
dependencyPath(computed) {
|
|
79
|
+
return this.argument.dependencyPath(computed);
|
|
80
|
+
}
|
|
81
|
+
toString() {
|
|
82
|
+
switch (this.operator) {
|
|
83
|
+
case 'void':
|
|
84
|
+
case 'delete':
|
|
85
|
+
case 'typeof':
|
|
86
|
+
return `${this.operator} ${this.argument.toString()}`;
|
|
87
|
+
default:
|
|
88
|
+
return `${this.operator}${this.argument.toString()}`;
|
|
52
89
|
}
|
|
53
|
-
return scope.delete(propertyKey);
|
|
54
90
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return this.argument.dependencyPath(computed);
|
|
62
|
-
}
|
|
63
|
-
toString() {
|
|
64
|
-
switch (this.operator) {
|
|
65
|
-
case 'void':
|
|
66
|
-
case 'delete':
|
|
67
|
-
case 'typeof':
|
|
68
|
-
return `${this.operator} ${this.argument.toString()}`;
|
|
69
|
-
default:
|
|
70
|
-
return `${this.operator}${this.argument.toString()}`;
|
|
91
|
+
toJson() {
|
|
92
|
+
return {
|
|
93
|
+
operator: this.operator,
|
|
94
|
+
argument: this.argument.toJSON(),
|
|
95
|
+
prefix: true
|
|
96
|
+
};
|
|
71
97
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
UnaryExpression.Evaluations = {
|
|
82
|
-
'+': (value) => { return +value; },
|
|
83
|
-
'-': (value) => { return -value; },
|
|
84
|
-
'~': (value) => { return ~value; },
|
|
85
|
-
'!': (value) => { return !value; },
|
|
86
|
-
'void': (value) => { return void value; },
|
|
87
|
-
'typeof': (value) => { return typeof value; },
|
|
88
|
-
};
|
|
89
|
-
UnaryExpression = UnaryExpression_1 = __decorate([
|
|
90
|
-
Deserializer('UnaryExpression'),
|
|
91
|
-
__metadata("design:paramtypes", [String, Object, Array, Object])
|
|
92
|
-
], UnaryExpression);
|
|
98
|
+
static {
|
|
99
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return UnaryExpression = _classThis;
|
|
103
|
+
})();
|
|
93
104
|
export { UnaryExpression };
|
|
94
105
|
//# sourceMappingURL=unary.js.map
|