@ibyar/expressions 0.8.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -1
- 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 +603 -472
- 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 +53 -41
- 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 +83 -69
- 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 +40 -28
- 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 +81 -68
- 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 +54 -42
- 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 +52 -40
- 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 +70 -58
- 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 +216 -175
- 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 +60 -47
- 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 +147 -122
- 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 +85 -70
- 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 +44 -32
- 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 +500 -443
- 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 +104 -89
- 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 +243 -200
- 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 +56 -44
- 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 +228 -160
- 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 +63 -50
- 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 +343 -290
- 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 +318 -253
- 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 +88 -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 +54 -42
- 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 +78 -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 +56 -44
- 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 +53 -41
- 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 +51 -39
- 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 +51 -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 +95 -81
- 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 +69 -55
- 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 +97 -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 +78 -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 +53 -40
- 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 +65 -53
- 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 +43 -33
- 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 +79 -65
- 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 +180 -141
- 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 +117 -78
- 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 +72 -59
- 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 +148 -121
- 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 +337 -277
- 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 +152 -125
- 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/builder.d.ts +27 -0
- package/scope/builder.d.ts.map +1 -0
- package/scope/builder.js +73 -0
- package/scope/builder.js.map +1 -0
- 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 +22 -14
- 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 +11 -11
- 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 +3 -1
- 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 +9 -5
- 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 +17 -7
- 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 +363 -358
- 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
- package/v8/nodes.d.ts +0 -0
- package/v8/nodes.js +0 -2
- package/v8/nodes.js.map +0 -1
package/api/definition/object.js
CHANGED
|
@@ -1,214 +1,257 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __metadata } from "tslib";
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
3
2
|
import { Identifier } from './values.js';
|
|
4
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
4
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
6
5
|
import { RestElement } from '../computing/rest.js';
|
|
7
|
-
let Property =
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
6
|
+
let Property = (() => {
|
|
7
|
+
let _classDecorators = [Deserializer('Property')];
|
|
8
|
+
let _classDescriptor;
|
|
9
|
+
let _classExtraInitializers = [];
|
|
10
|
+
let _classThis;
|
|
11
|
+
let _classSuper = AbstractExpressionNode;
|
|
12
|
+
var Property = class extends _classSuper {
|
|
13
|
+
static { _classThis = this; }
|
|
14
|
+
static {
|
|
15
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
16
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
17
|
+
Property = _classThis = _classDescriptor.value;
|
|
18
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
19
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
20
|
+
}
|
|
21
|
+
key;
|
|
22
|
+
value;
|
|
23
|
+
kind;
|
|
24
|
+
method;
|
|
25
|
+
shorthand;
|
|
26
|
+
computed;
|
|
27
|
+
static fromJSON(node, deserializer) {
|
|
28
|
+
return new Property(deserializer(node.key), deserializer(node.value), node.kind, node.method, node.shorthand, node.computed, node.range, node.loc);
|
|
29
|
+
}
|
|
30
|
+
static visit(node, visitNode) {
|
|
31
|
+
visitNode(node.key);
|
|
32
|
+
visitNode(node.value);
|
|
33
|
+
}
|
|
34
|
+
constructor(key, value, kind, method, shorthand, computed, range, loc) {
|
|
35
|
+
super(range, loc);
|
|
36
|
+
this.key = key;
|
|
37
|
+
this.value = value;
|
|
38
|
+
this.kind = kind;
|
|
39
|
+
this.method = method;
|
|
40
|
+
this.shorthand = shorthand;
|
|
41
|
+
this.computed = computed;
|
|
42
|
+
}
|
|
43
|
+
getKey() {
|
|
44
|
+
return this.key;
|
|
45
|
+
}
|
|
46
|
+
getValue() {
|
|
47
|
+
return this.value;
|
|
48
|
+
}
|
|
49
|
+
set(stack, value) {
|
|
50
|
+
this.key.set(stack, value);
|
|
51
|
+
}
|
|
52
|
+
get(stack, thisContext) {
|
|
53
|
+
const name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);
|
|
54
|
+
let value;
|
|
55
|
+
switch (this.kind) {
|
|
56
|
+
case 'get':
|
|
57
|
+
const get = this.value.get(stack);
|
|
58
|
+
Object.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });
|
|
59
|
+
value = get;
|
|
60
|
+
break;
|
|
61
|
+
case 'set':
|
|
62
|
+
const set = this.value.get(stack);
|
|
63
|
+
Object.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });
|
|
64
|
+
value = set;
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
case 'init':
|
|
68
|
+
value = this.value.get(stack);
|
|
69
|
+
Object.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
declareVariable(stack, objectValue) {
|
|
75
|
+
const propertyName = this.shorthand ? this.key.getName() : this.key.get(stack);
|
|
76
|
+
const propertyValue = objectValue[propertyName];
|
|
77
|
+
this.value.declareVariable(stack, propertyValue);
|
|
78
|
+
}
|
|
79
|
+
dependency(computed) {
|
|
80
|
+
return this.key.dependency(computed).concat(this.value.dependency(computed));
|
|
81
|
+
}
|
|
82
|
+
dependencyPath(computed) {
|
|
83
|
+
return this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));
|
|
84
|
+
}
|
|
85
|
+
toString() {
|
|
86
|
+
const key = this.computed ? `[${this.key.toString()}]` : this.key.toString();
|
|
87
|
+
if (this.shorthand) {
|
|
88
|
+
return key;
|
|
89
|
+
}
|
|
90
|
+
let value = '';
|
|
91
|
+
switch (this.kind) {
|
|
92
|
+
case 'get':
|
|
93
|
+
case 'set':
|
|
82
94
|
const expression = this.value;
|
|
95
|
+
value += this.kind;
|
|
83
96
|
value += ' ' + key;
|
|
84
97
|
value += expression.paramsAndBodyToString();
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
break;
|
|
99
|
+
case 'init':
|
|
100
|
+
if (this.method) {
|
|
101
|
+
const expression = this.value;
|
|
102
|
+
value += ' ' + key;
|
|
103
|
+
value += expression.paramsAndBodyToString();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
value += this.value.toString();
|
|
107
|
+
return `${key}: ${value}`;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
default:
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
toJson() {
|
|
116
|
+
return {
|
|
117
|
+
key: this.key.toJSON(),
|
|
118
|
+
value: this.value.toJSON(),
|
|
119
|
+
kind: this.kind
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
return Property = _classThis;
|
|
124
|
+
})();
|
|
108
125
|
export { Property };
|
|
109
|
-
let ObjectExpression =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
126
|
+
let ObjectExpression = (() => {
|
|
127
|
+
let _classDecorators = [Deserializer('ObjectExpression')];
|
|
128
|
+
let _classDescriptor;
|
|
129
|
+
let _classExtraInitializers = [];
|
|
130
|
+
let _classThis;
|
|
131
|
+
let _classSuper = AbstractExpressionNode;
|
|
132
|
+
var ObjectExpression = class extends _classSuper {
|
|
133
|
+
static { _classThis = this; }
|
|
134
|
+
static {
|
|
135
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
136
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
137
|
+
ObjectExpression = _classThis = _classDescriptor.value;
|
|
138
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
139
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
140
|
+
}
|
|
141
|
+
properties;
|
|
142
|
+
static fromJSON(node, deserializer) {
|
|
143
|
+
return new ObjectExpression(node.properties.map(deserializer), node.range, node.loc);
|
|
144
|
+
}
|
|
145
|
+
static visit(node, visitNode) {
|
|
146
|
+
node.properties.forEach(visitNode);
|
|
147
|
+
}
|
|
148
|
+
constructor(properties, range, loc) {
|
|
149
|
+
super(range, loc);
|
|
150
|
+
this.properties = properties;
|
|
151
|
+
}
|
|
152
|
+
getProperties() {
|
|
153
|
+
return this.properties;
|
|
154
|
+
}
|
|
155
|
+
set(stack) {
|
|
156
|
+
throw new Error('ObjectExpression#set() has no implementation.');
|
|
157
|
+
}
|
|
158
|
+
get(stack) {
|
|
159
|
+
const newObject = {};
|
|
160
|
+
for (const property of this.properties) {
|
|
161
|
+
property.get(stack, newObject);
|
|
162
|
+
}
|
|
163
|
+
return newObject;
|
|
164
|
+
}
|
|
165
|
+
dependency(computed) {
|
|
166
|
+
return this.properties.flatMap(property => property.dependency(computed));
|
|
167
|
+
}
|
|
168
|
+
dependencyPath(computed) {
|
|
169
|
+
return this.properties.flatMap(property => property.dependencyPath(computed));
|
|
170
|
+
}
|
|
171
|
+
toString() {
|
|
172
|
+
return `{ ${this.properties.map(item => item.toString()).join(', ')} }`;
|
|
173
|
+
}
|
|
174
|
+
toJson() {
|
|
175
|
+
return {
|
|
176
|
+
properties: this.properties.map(item => item.toJSON())
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
return ObjectExpression = _classThis;
|
|
181
|
+
})();
|
|
152
182
|
export { ObjectExpression };
|
|
153
|
-
let ObjectPattern =
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
183
|
+
let ObjectPattern = (() => {
|
|
184
|
+
let _classDecorators = [Deserializer('ObjectPattern')];
|
|
185
|
+
let _classDescriptor;
|
|
186
|
+
let _classExtraInitializers = [];
|
|
187
|
+
let _classThis;
|
|
188
|
+
let _classSuper = AbstractExpressionNode;
|
|
189
|
+
var ObjectPattern = class extends _classSuper {
|
|
190
|
+
static { _classThis = this; }
|
|
191
|
+
static {
|
|
192
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
193
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
194
|
+
ObjectPattern = _classThis = _classDescriptor.value;
|
|
195
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
196
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
197
|
+
}
|
|
198
|
+
properties;
|
|
199
|
+
static fromJSON(node, deserializer) {
|
|
200
|
+
return new ObjectPattern(node.properties.map(deserializer), node.range, node.loc);
|
|
201
|
+
}
|
|
202
|
+
static visit(node, visitNode) {
|
|
203
|
+
node.properties.forEach(visitNode);
|
|
204
|
+
}
|
|
205
|
+
constructor(properties, range, loc) {
|
|
206
|
+
super(range, loc);
|
|
207
|
+
this.properties = properties;
|
|
208
|
+
}
|
|
209
|
+
getProperties() {
|
|
210
|
+
return this.properties;
|
|
211
|
+
}
|
|
212
|
+
set(stack, objectValue) {
|
|
213
|
+
throw new Error('ObjectPattern#set() has no implementation.');
|
|
214
|
+
}
|
|
215
|
+
get(scopeProvider) {
|
|
216
|
+
throw new Error('ObjectPattern#get() has no implementation.');
|
|
217
|
+
}
|
|
218
|
+
declareVariable(stack, objectValue) {
|
|
219
|
+
for (const property of this.properties) {
|
|
220
|
+
if (property instanceof RestElement) {
|
|
221
|
+
objectValue = this.getFromObject(stack, objectValue);
|
|
222
|
+
}
|
|
223
|
+
property.declareVariable(stack, objectValue);
|
|
177
224
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
restObject[key] = objectValue[key];
|
|
225
|
+
}
|
|
226
|
+
getFromObject(stack, objectValue) {
|
|
227
|
+
const keys = [];
|
|
228
|
+
keys.push(...Object.keys(objectValue));
|
|
229
|
+
keys.push(...Object.getOwnPropertySymbols(objectValue));
|
|
230
|
+
const restObject = {};
|
|
231
|
+
const context = stack.lastScope().getContext();
|
|
232
|
+
for (const key of keys) {
|
|
233
|
+
if (!(key in context)) {
|
|
234
|
+
restObject[key] = objectValue[key];
|
|
235
|
+
}
|
|
190
236
|
}
|
|
237
|
+
return restObject;
|
|
238
|
+
}
|
|
239
|
+
dependency(computed) {
|
|
240
|
+
return this.properties.flatMap(property => property.dependency(computed));
|
|
241
|
+
}
|
|
242
|
+
dependencyPath(computed) {
|
|
243
|
+
return this.properties.flatMap(property => property.dependencyPath(computed));
|
|
244
|
+
}
|
|
245
|
+
toString() {
|
|
246
|
+
return `{ ${this.properties.map(item => item.toString()).join(', ')} }`;
|
|
247
|
+
}
|
|
248
|
+
toJson() {
|
|
249
|
+
return {
|
|
250
|
+
properties: this.properties.map(item => item.toJSON())
|
|
251
|
+
};
|
|
191
252
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return this.properties.flatMap(property => property.dependency(computed));
|
|
196
|
-
}
|
|
197
|
-
dependencyPath(computed) {
|
|
198
|
-
return this.properties.flatMap(property => property.dependencyPath(computed));
|
|
199
|
-
}
|
|
200
|
-
toString() {
|
|
201
|
-
return `{ ${this.properties.map(item => item.toString()).join(', ')} }`;
|
|
202
|
-
}
|
|
203
|
-
toJson() {
|
|
204
|
-
return {
|
|
205
|
-
properties: this.properties.map(item => item.toJSON())
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
ObjectPattern = ObjectPattern_1 = __decorate([
|
|
210
|
-
Deserializer('ObjectPattern'),
|
|
211
|
-
__metadata("design:paramtypes", [Array, Array, Object])
|
|
212
|
-
], ObjectPattern);
|
|
253
|
+
};
|
|
254
|
+
return ObjectPattern = _classThis;
|
|
255
|
+
})();
|
|
213
256
|
export { ObjectPattern };
|
|
214
257
|
//# sourceMappingURL=object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/object.ts"],"names":[],"mappings":";;AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,aA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SAAS,EAAsB,CAAC,UAAU,EAAG,CAAC;QACpE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACvB,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,EAAE;gBACtB,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;aACnC;SACD;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,UAAU,CAAC,QAAe;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,cAAc,CAAC,QAAe;QAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,QAAQ;QACP,OAAO,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACzE,CAAC;IACD,MAAM;QACL,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SACtD,CAAC;IACH,CAAC;CACD,CAAA;AA7DY,aAAa;IADzB,YAAY,CAAC,eAAe,CAAC;;GACjB,aAAa,CA6DzB;SA7DY,aAAa","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, DeclarationExpression,\n\tExpressionEventPath, VisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Identifier } from './values.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { RestElement } from '../computing/rest.js';\nimport { FunctionDeclaration } from './function.js';\n\n@Deserializer('Property')\nexport class Property extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: Property, deserializer: NodeDeserializer): Property {\n\t\treturn new Property(\n\t\t\tdeserializer(node.key),\n\t\t\tdeserializer(node.value) as DeclarationExpression,\n\t\t\tnode.kind,\n\t\t\tnode.method,\n\t\t\tnode.shorthand,\n\t\t\tnode.computed,\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: Property, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.key);\n\t\tvisitNode(node.value);\n\t}\n\tconstructor(\n\t\tprotected key: ExpressionNode,\n\t\tprotected value: DeclarationExpression | ExpressionNode,\n\t\tprotected kind: 'init' | 'get' | 'set',\n\t\tprotected method: boolean,\n\t\tprotected shorthand: boolean,\n\t\tprotected computed: boolean,\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthis.key.set(stack, value);\n\t}\n\tget(stack: Stack, thisContext: ThisType<any>): any {\n\t\tconst name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);\n\t\tlet value: any;\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\t\tconst get: () => any = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });\n\t\t\t\tvalue = get;\n\t\t\t\tbreak;\n\t\t\tcase 'set':\n\t\t\t\tconst set: (v: any) => void = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });\n\t\t\t\tvalue = set;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tcase 'init':\n\t\t\t\tvalue = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tconst propertyName = this.shorthand ? (this.key as Identifier).getName() : this.key.get(stack);\n\t\tconst propertyValue = objectValue[propertyName];\n\t\t(this.value as DeclarationExpression).declareVariable(stack, propertyValue);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.key.dependency(computed).concat(this.value.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tconst key = this.computed ? `[${this.key.toString()}]` : this.key.toString();\n\t\tif (this.shorthand) {\n\t\t\treturn key;\n\t\t}\n\t\tlet value = '';\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\tcase 'set':\n\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\tvalue += this.kind;\n\t\t\t\tvalue += ' ' + key\n\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\tbreak;\n\t\t\tcase 'init':\n\t\t\t\tif (this.method) {\n\t\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\t\tvalue += ' ' + key\n\t\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\t} else {\n\t\t\t\t\tvalue += this.value.toString();\n\t\t\t\t\treturn `${key}: ${value}`;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tvalue: this.value.toJSON(),\n\t\t\tkind: this.kind\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectExpression')\nexport class ObjectExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ObjectExpression, deserializer: NodeDeserializer): ObjectExpression {\n\t\treturn new ObjectExpression(\n\t\t\tnode.properties.map(deserializer) as Property[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectExpression, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: Property[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack) {\n\t\tthrow new Error('ObjectExpression#set() has no implementation.');\n\t}\n\tget(stack: Stack) {\n\t\tconst newObject = {};\n\t\tfor (const property of this.properties) {\n\t\t\tproperty.get(stack, newObject);\n\t\t}\n\t\treturn newObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectPattern')\nexport class ObjectPattern extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: ObjectPattern, deserializer: NodeDeserializer): ObjectPattern {\n\t\treturn new ObjectPattern(\n\t\t\tnode.properties.map(deserializer) as (Property | RestElement)[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectPattern, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: (Property | RestElement)[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack, objectValue: any) {\n\t\tthrow new Error('ObjectPattern#set() has no implementation.');\n\t}\n\tget(scopeProvider: Stack) {\n\t\tthrow new Error('ObjectPattern#get() has no implementation.');\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tfor (const property of this.properties) {\n\t\t\tif (property instanceof RestElement) {\n\t\t\t\tobjectValue = this.getFromObject(stack, objectValue);\n\t\t\t}\n\t\t\tproperty.declareVariable(stack, objectValue);\n\t\t}\n\t}\n\tprivate getFromObject(stack: Stack, objectValue: { [key: PropertyKey]: any }) {\n\t\tconst keys: PropertyKey[] = [];\n\t\tkeys.push(...Object.keys(objectValue));\n\t\tkeys.push(...Object.getOwnPropertySymbols(objectValue));\n\t\tconst restObject: typeof objectValue = {};\n\t\tconst context = stack.lastScope<typeof objectValue>().getContext()!;\n\t\tfor (const key of keys) {\n\t\t\tif (!(key in context)) {\n\t\t\t\trestObject[key] = objectValue[key];\n\t\t\t}\n\t\t}\n\t\treturn restObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/object.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;IAItC,QAAQ;4BADpB,YAAY,CAAC,UAAU,CAAC;;;;sBACK,sBAAsB;wBAA9B,SAAQ,WAAsB;;;;YAApD,6KA0GC;;;YA1GY,uDAAQ;;QAkBT,GAAG;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E;oBACtB,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;iBACnC;aACD;YACD,OAAO,UAAU,CAAC;QACnB,CAAC;QACD,UAAU,CAAC,QAAe;YACzB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3E,CAAC;QACD,cAAc,CAAC,QAAe;YAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/E,CAAC;QACD,QAAQ;YACP,OAAO,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACzE,CAAC;QACD,MAAM;YACL,OAAO;gBACN,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aACtD,CAAC;QACH,CAAC;;;;SA5DW,aAAa","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, DeclarationExpression,\n\tExpressionEventPath, VisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Identifier } from './values.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { RestElement } from '../computing/rest.js';\nimport { FunctionDeclaration } from './function.js';\n\n@Deserializer('Property')\nexport class Property extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: Property, deserializer: NodeDeserializer): Property {\n\t\treturn new Property(\n\t\t\tdeserializer(node.key),\n\t\t\tdeserializer(node.value) as DeclarationExpression,\n\t\t\tnode.kind,\n\t\t\tnode.method,\n\t\t\tnode.shorthand,\n\t\t\tnode.computed,\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: Property, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.key);\n\t\tvisitNode(node.value);\n\t}\n\tconstructor(\n\t\tprotected key: ExpressionNode,\n\t\tprotected value: DeclarationExpression | ExpressionNode,\n\t\tprotected kind: 'init' | 'get' | 'set',\n\t\tprotected method: boolean,\n\t\tprotected shorthand: boolean,\n\t\tprotected computed: boolean,\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthis.key.set(stack, value);\n\t}\n\tget(stack: Stack, thisContext: ThisType<any>): any {\n\t\tconst name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);\n\t\tlet value: any;\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\t\tconst get: () => any = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });\n\t\t\t\tvalue = get;\n\t\t\t\tbreak;\n\t\t\tcase 'set':\n\t\t\t\tconst set: (v: any) => void = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });\n\t\t\t\tvalue = set;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tcase 'init':\n\t\t\t\tvalue = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tconst propertyName = this.shorthand ? (this.key as Identifier).getName() : this.key.get(stack);\n\t\tconst propertyValue = objectValue[propertyName];\n\t\t(this.value as DeclarationExpression).declareVariable(stack, propertyValue);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.key.dependency(computed).concat(this.value.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tconst key = this.computed ? `[${this.key.toString()}]` : this.key.toString();\n\t\tif (this.shorthand) {\n\t\t\treturn key;\n\t\t}\n\t\tlet value = '';\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\tcase 'set':\n\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\tvalue += this.kind;\n\t\t\t\tvalue += ' ' + key\n\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\tbreak;\n\t\t\tcase 'init':\n\t\t\t\tif (this.method) {\n\t\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\t\tvalue += ' ' + key\n\t\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\t} else {\n\t\t\t\t\tvalue += this.value.toString();\n\t\t\t\t\treturn `${key}: ${value}`;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tvalue: this.value.toJSON(),\n\t\t\tkind: this.kind\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectExpression')\nexport class ObjectExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ObjectExpression, deserializer: NodeDeserializer): ObjectExpression {\n\t\treturn new ObjectExpression(\n\t\t\tnode.properties.map(deserializer) as Property[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectExpression, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: Property[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack) {\n\t\tthrow new Error('ObjectExpression#set() has no implementation.');\n\t}\n\tget(stack: Stack) {\n\t\tconst newObject = {};\n\t\tfor (const property of this.properties) {\n\t\t\tproperty.get(stack, newObject);\n\t\t}\n\t\treturn newObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectPattern')\nexport class ObjectPattern extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: ObjectPattern, deserializer: NodeDeserializer): ObjectPattern {\n\t\treturn new ObjectPattern(\n\t\t\tnode.properties.map(deserializer) as (Property | RestElement)[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectPattern, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: (Property | RestElement)[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack, objectValue: any) {\n\t\tthrow new Error('ObjectPattern#set() has no implementation.');\n\t}\n\tget(scopeProvider: Stack) {\n\t\tthrow new Error('ObjectPattern#get() has no implementation.');\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tfor (const property of this.properties) {\n\t\t\tif (property instanceof RestElement) {\n\t\t\t\tobjectValue = this.getFromObject(stack, objectValue);\n\t\t\t}\n\t\t\tproperty.declareVariable(stack, objectValue);\n\t\t}\n\t}\n\tprivate getFromObject(stack: Stack, objectValue: { [key: PropertyKey]: any }) {\n\t\tconst keys: PropertyKey[] = [];\n\t\tkeys.push(...Object.keys(objectValue));\n\t\tkeys.push(...Object.getOwnPropertySymbols(objectValue));\n\t\tconst restObject: typeof objectValue = {};\n\t\tconst context = stack.lastScope<typeof objectValue>().getContext()!;\n\t\tfor (const key of keys) {\n\t\t\tif (!(key in context)) {\n\t\t\t\trestObject[key] = objectValue[key];\n\t\t\t}\n\t\t}\n\t\treturn restObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement.d.ts","sourceRoot":"","sources":["../../../../src/expressions/api/definition/statement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAAE,cAAc,EAChC,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAClD,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBACa,mBAAoB,SAAQ,sBAAsB;IAY7D,OAAO,CAAC,IAAI;IAXb,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,EAAE,YAAY,EAAE,gBAAgB,GAAG,mBAAmB;IAO/F,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,mBAAmB,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;gBAI9D,IAAI,EAAE,cAAc,EAAE,EAC9B,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,GAAG,CAAC,EAAE,cAAc;IAGrB,OAAO;IAGP,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG;IAG5B,GAAG,CAAC,KAAK,EAAE,KAAK;IAKhB,UAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,cAAc,EAAE;IAG7C,cAAc,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,mBAAmB,EAAE;IAGtD,QAAQ,IAAI,MAAM;IAMlB,MAAM,IAAI,MAAM;CAGhB"}
|