@ibyar/expressions 0.5.0 → 0.5.4
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 +96 -1
- package/api/abstract.d.ts +3 -4
- package/api/abstract.js +1 -1
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +196 -0
- package/api/class/class.js +594 -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/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 +3 -3
- package/api/computing/rest.js +5 -2
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +2 -1
- package/api/computing/return.js +3 -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 +2 -1
- package/api/computing/throw.js +3 -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 +6 -7
- package/api/definition/array.js +13 -13
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +2 -2
- package/api/definition/bind.js +1 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +8 -8
- package/api/definition/function.js +25 -25
- 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 +7 -7
- package/api/definition/object.js +9 -9
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +2 -2
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +5 -4
- package/api/definition/values.js +7 -4
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +9 -12
- package/api/expression.js.map +1 -1
- package/api/{app → module/app}/program.d.ts +8 -9
- package/api/module/app/program.js +45 -0
- package/api/module/app/program.js.map +1 -0
- package/api/module/export.d.ts +60 -25
- package/api/module/export.js +230 -60
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +66 -25
- package/api/module/import.js +236 -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 +2 -2
- package/api/operators/grouping.js +1 -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 +2 -2
- package/api/operators/pipeline.js +1 -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 +4 -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/statement/control/block.d.ts +3 -3
- package/api/statement/control/block.js +2 -2
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +1 -1
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +2 -2
- package/api/statement/control/if.js +1 -1
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +4 -5
- package/api/statement/control/switch.js +5 -6
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +3 -3
- package/api/statement/control/terminate.js +2 -2
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +13 -11
- package/api/statement/declarations/declares.js +26 -18
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +5 -5
- package/api/statement/iterations/for.js +7 -7
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +3 -3
- package/api/statement/iterations/while.js +2 -2
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +3 -0
- package/api/utils.js +2 -0
- package/api/utils.js.map +1 -0
- package/package.json +4 -4
- package/scope/event.d.ts +2 -2
- package/scope/event.js +8 -14
- package/scope/event.js.map +1 -1
- 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 +2 -1
- package/scope/proxy.js +18 -2
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +57 -40
- package/scope/scope.js +123 -106
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +41 -24
- package/scope/stack.js +148 -102
- package/scope/stack.js.map +1 -1
- package/v8/app.js.map +1 -1
- package/v8/parser.d.ts +1 -1
- package/v8/parser.js +3 -2
- package/v8/parser.js.map +1 -1
- 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
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
var Super_1, MetaProperty_1, PrivateIdentifier_1, StaticBlock_1, MethodDefinition_1, PropertyDefinition_1, AccessorProperty_1, ClassBody_1, ClassDeclaration_1, ClassExpression_1;
|
|
2
|
+
import { __decorate as __decorate_1, __metadata } from "tslib";
|
|
3
|
+
import { __decorate } from 'tslib';
|
|
4
|
+
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
|
+
import { Deserializer } from '../deserialize/deserialize.js';
|
|
6
|
+
import { Identifier } from '../definition/values.js';
|
|
7
|
+
import { MemberExpression } from '../definition/member.js';
|
|
8
|
+
import { FunctionExpression } from '../definition/function.js';
|
|
9
|
+
import { BlockStatement } from '../statement/control/block.js';
|
|
10
|
+
import { CallExpression } from '../computing/call.js';
|
|
11
|
+
const TEMP_CLASS_NAME = Symbol('temp_class_name');
|
|
12
|
+
const SUPER = Symbol('super');
|
|
13
|
+
const NEW_TARGET = Symbol('new.target');
|
|
14
|
+
const IMPORT_META = Symbol('import.meta');
|
|
15
|
+
const STACK = Symbol('stack');
|
|
16
|
+
const GET_PARAMETERS = Symbol('getParameters');
|
|
17
|
+
const GET_SUPER_PROPERTY = Symbol('getSuperProperty');
|
|
18
|
+
const CALL_SUPER_Method = Symbol('callSuperMethod');
|
|
19
|
+
const CONSTRUCTOR = Symbol('constructor');
|
|
20
|
+
const PRIVATE_SYMBOL = Symbol('#private');
|
|
21
|
+
const INIT_PRIVATE_SYMBOL = Symbol('#init_private');
|
|
22
|
+
const STATIC_INITIALIZATION_BLOCK = Symbol('static_block');
|
|
23
|
+
let Super = Super_1 = class Super extends AbstractExpressionNode {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
static fromJSON(node) {
|
|
28
|
+
return Super_1.INSTANCE;
|
|
29
|
+
}
|
|
30
|
+
shareVariables(scopeList) { }
|
|
31
|
+
set(stack, value) {
|
|
32
|
+
throw new Error('Super.#set() Method not implemented.');
|
|
33
|
+
}
|
|
34
|
+
get(stack, thisContext) {
|
|
35
|
+
throw new Error('Super.#get() Method not implemented.');
|
|
36
|
+
}
|
|
37
|
+
dependency(computed) {
|
|
38
|
+
throw new Error('Super.#dependency() Method not implemented.');
|
|
39
|
+
}
|
|
40
|
+
dependencyPath(computed) {
|
|
41
|
+
throw new Error('Super.#dependencyPath() Method not implemented.');
|
|
42
|
+
}
|
|
43
|
+
toString() {
|
|
44
|
+
return `super`;
|
|
45
|
+
}
|
|
46
|
+
toJson() {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Super.INSTANCE = new Super_1();
|
|
51
|
+
Super = Super_1 = __decorate_1([
|
|
52
|
+
Deserializer('Super'),
|
|
53
|
+
__metadata("design:paramtypes", [])
|
|
54
|
+
], Super);
|
|
55
|
+
export { Super };
|
|
56
|
+
let MetaProperty = MetaProperty_1 = class MetaProperty extends MemberExpression {
|
|
57
|
+
constructor(meta, property) {
|
|
58
|
+
super(meta, property, false);
|
|
59
|
+
this.meta = meta;
|
|
60
|
+
}
|
|
61
|
+
static getJsonName(identifier) {
|
|
62
|
+
return Reflect.get(identifier, 'name');
|
|
63
|
+
}
|
|
64
|
+
static fromJSON(node, deserializer) {
|
|
65
|
+
if (MetaProperty_1.getJsonName(node.meta) === 'new' && MetaProperty_1.getJsonName(node.property) === 'target') {
|
|
66
|
+
return MetaProperty_1.NewTarget;
|
|
67
|
+
}
|
|
68
|
+
else if (MetaProperty_1.getJsonName(node.meta) === 'import' && MetaProperty_1.getJsonName(node.property) === 'meta') {
|
|
69
|
+
return MetaProperty_1.ImportMeta;
|
|
70
|
+
}
|
|
71
|
+
return new MetaProperty_1(deserializer(node.meta), deserializer(node.property));
|
|
72
|
+
}
|
|
73
|
+
static visit(node, visitNode) {
|
|
74
|
+
visitNode(node.meta);
|
|
75
|
+
visitNode(node.property);
|
|
76
|
+
}
|
|
77
|
+
getMeta() {
|
|
78
|
+
return this.meta;
|
|
79
|
+
}
|
|
80
|
+
shareVariables(scopeList) { }
|
|
81
|
+
get(stack, thisContext) {
|
|
82
|
+
if (MetaProperty_1.getJsonName(this.meta) === 'new' && MetaProperty_1.getJsonName(this.property) === 'target') {
|
|
83
|
+
return stack.get(NEW_TARGET);
|
|
84
|
+
}
|
|
85
|
+
else if (MetaProperty_1.getJsonName(this.meta) === 'import' && MetaProperty_1.getJsonName(this.property) === 'meta') {
|
|
86
|
+
const importObject = stack.getModule()?.get('import');
|
|
87
|
+
return importObject['meta'];
|
|
88
|
+
}
|
|
89
|
+
return super.get(stack, thisContext);
|
|
90
|
+
}
|
|
91
|
+
toString() {
|
|
92
|
+
return `${this.meta.toString()}.${this.property.toString()}`;
|
|
93
|
+
}
|
|
94
|
+
toJson() {
|
|
95
|
+
return {
|
|
96
|
+
meta: this.meta.toJSON(),
|
|
97
|
+
property: this.property.toJSON(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
MetaProperty.NewTarget = new MetaProperty_1(new Identifier('new'), new Identifier('target'));
|
|
102
|
+
MetaProperty.ImportMeta = new MetaProperty_1(new Identifier('import'), new Identifier('meta'));
|
|
103
|
+
MetaProperty = MetaProperty_1 = __decorate_1([
|
|
104
|
+
Deserializer('MetaProperty'),
|
|
105
|
+
__metadata("design:paramtypes", [Identifier, Identifier])
|
|
106
|
+
], MetaProperty);
|
|
107
|
+
export { MetaProperty };
|
|
108
|
+
let PrivateIdentifier = PrivateIdentifier_1 = class PrivateIdentifier extends AbstractExpressionNode {
|
|
109
|
+
constructor(name) {
|
|
110
|
+
super();
|
|
111
|
+
this.name = name;
|
|
112
|
+
}
|
|
113
|
+
static fromJSON(node) {
|
|
114
|
+
return new PrivateIdentifier_1(node.name);
|
|
115
|
+
}
|
|
116
|
+
getName() {
|
|
117
|
+
return this.name;
|
|
118
|
+
}
|
|
119
|
+
set(stack, value) {
|
|
120
|
+
const privateScope = stack.findScope(PRIVATE_SYMBOL);
|
|
121
|
+
privateScope.getScope(PRIVATE_SYMBOL)?.set(this.name, value);
|
|
122
|
+
}
|
|
123
|
+
get(stack, thisContext) {
|
|
124
|
+
const privateObj = stack.get(PRIVATE_SYMBOL);
|
|
125
|
+
return privateObj[this.name];
|
|
126
|
+
}
|
|
127
|
+
dependency(computed) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
dependencyPath(computed) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
shareVariables(scopeList) { }
|
|
134
|
+
toString() {
|
|
135
|
+
return `#${this.name}`;
|
|
136
|
+
}
|
|
137
|
+
toJson() {
|
|
138
|
+
return {
|
|
139
|
+
name: this.name
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
PrivateIdentifier = PrivateIdentifier_1 = __decorate_1([
|
|
144
|
+
Deserializer('PrivateIdentifier'),
|
|
145
|
+
__metadata("design:paramtypes", [String])
|
|
146
|
+
], PrivateIdentifier);
|
|
147
|
+
export { PrivateIdentifier };
|
|
148
|
+
let StaticBlock = StaticBlock_1 = class StaticBlock extends BlockStatement {
|
|
149
|
+
static fromJSON(node, deserializer) {
|
|
150
|
+
return new StaticBlock_1(deserializer(node.body), node.isStatement);
|
|
151
|
+
}
|
|
152
|
+
constructor(body, isStatement) {
|
|
153
|
+
super(body, isStatement);
|
|
154
|
+
}
|
|
155
|
+
get(stack, classConstructor) {
|
|
156
|
+
const constructor = classConstructor;
|
|
157
|
+
constructor[STATIC_INITIALIZATION_BLOCK].push(() => super.get(stack));
|
|
158
|
+
}
|
|
159
|
+
toString() {
|
|
160
|
+
return `static ${super.toString()}`;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
StaticBlock = StaticBlock_1 = __decorate_1([
|
|
164
|
+
Deserializer('StaticBlock'),
|
|
165
|
+
__metadata("design:paramtypes", [Array, Boolean])
|
|
166
|
+
], StaticBlock);
|
|
167
|
+
export { StaticBlock };
|
|
168
|
+
export class AbstractDefinition extends AbstractExpressionNode {
|
|
169
|
+
constructor(key, decorators, computed, isStatic, value) {
|
|
170
|
+
super();
|
|
171
|
+
this.key = key;
|
|
172
|
+
this.decorators = decorators;
|
|
173
|
+
this.computed = computed;
|
|
174
|
+
this.value = value;
|
|
175
|
+
this.static = isStatic;
|
|
176
|
+
}
|
|
177
|
+
getKey() {
|
|
178
|
+
return this.key;
|
|
179
|
+
}
|
|
180
|
+
getValue() {
|
|
181
|
+
return this.value;
|
|
182
|
+
}
|
|
183
|
+
isComputed() {
|
|
184
|
+
return this.computed;
|
|
185
|
+
}
|
|
186
|
+
isStatic() {
|
|
187
|
+
return this.static;
|
|
188
|
+
}
|
|
189
|
+
getDecorators() {
|
|
190
|
+
return this.decorators;
|
|
191
|
+
}
|
|
192
|
+
shareVariables(scopeList) { }
|
|
193
|
+
set(stack, value) {
|
|
194
|
+
throw new Error('AbstractDefinition.#set() Method not implemented.');
|
|
195
|
+
}
|
|
196
|
+
dependency(computed) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
dependencyPath(computed) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends AbstractDefinition {
|
|
204
|
+
constructor(kind, key, value, decorators, computed, isStatic) {
|
|
205
|
+
super(key, decorators, computed, isStatic, value);
|
|
206
|
+
this.kind = kind;
|
|
207
|
+
}
|
|
208
|
+
static fromJSON(node, deserializer) {
|
|
209
|
+
return new MethodDefinition_1(node.kind, deserializer(node.key), deserializer(node.value), node.decorators.map(deserializer), node.computed, node.static);
|
|
210
|
+
}
|
|
211
|
+
static visit(node, visitNode) {
|
|
212
|
+
visitNode(node.key);
|
|
213
|
+
visitNode(node.value);
|
|
214
|
+
node.decorators.forEach(visitNode);
|
|
215
|
+
}
|
|
216
|
+
getKind() {
|
|
217
|
+
return this.kind;
|
|
218
|
+
}
|
|
219
|
+
getValue() {
|
|
220
|
+
return this.value;
|
|
221
|
+
}
|
|
222
|
+
get(stack, classConstructor) {
|
|
223
|
+
if (this.kind === 'constructor') {
|
|
224
|
+
this.initConstructor(stack, classConstructor);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const target = this.static ? classConstructor : classConstructor.prototype;
|
|
228
|
+
const value = this.value?.get(stack);
|
|
229
|
+
const name = this.computed ? this.key.get(stack) : this.key.getName();
|
|
230
|
+
const ref = this.key instanceof PrivateIdentifier ? target[INIT_PRIVATE_SYMBOL] : target;
|
|
231
|
+
switch (this.kind) {
|
|
232
|
+
case 'method':
|
|
233
|
+
ref[name] = value;
|
|
234
|
+
break;
|
|
235
|
+
case 'set':
|
|
236
|
+
Object.defineProperty(ref, name, {
|
|
237
|
+
configurable: true,
|
|
238
|
+
enumerable: false,
|
|
239
|
+
set: value,
|
|
240
|
+
});
|
|
241
|
+
break;
|
|
242
|
+
case 'get':
|
|
243
|
+
Object.defineProperty(ref, name, {
|
|
244
|
+
configurable: true,
|
|
245
|
+
enumerable: false,
|
|
246
|
+
get: value,
|
|
247
|
+
});
|
|
248
|
+
break;
|
|
249
|
+
default:
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
const decorators = this.decorators.map(decorator => decorator.get(stack));
|
|
253
|
+
__decorate(decorators, target, name, null);
|
|
254
|
+
}
|
|
255
|
+
initConstructor(stack, classConstructor) {
|
|
256
|
+
let superIndex = this.value.getBody()
|
|
257
|
+
.findIndex(call => call instanceof CallExpression && Super.INSTANCE === call.getCallee());
|
|
258
|
+
if (superIndex === -1) {
|
|
259
|
+
superIndex = this.value.getBody().length;
|
|
260
|
+
}
|
|
261
|
+
const superCall = this.value.getBody()[superIndex];
|
|
262
|
+
const blockBeforeSuper = new BlockStatement(this.value.getBody().slice(0, superIndex), false);
|
|
263
|
+
const blockAfterSuper = new BlockStatement(this.value.getBody().slice(superIndex + 1), false);
|
|
264
|
+
if (superCall) {
|
|
265
|
+
classConstructor[GET_PARAMETERS] = function (params) {
|
|
266
|
+
const scope = stack.pushBlockScope();
|
|
267
|
+
this.value.setParameter(stack, params);
|
|
268
|
+
blockBeforeSuper.get(stack);
|
|
269
|
+
const parameters = superCall.getCallParameters(stack);
|
|
270
|
+
stack.clearTo(scope);
|
|
271
|
+
return parameters;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
classConstructor.prototype[CONSTRUCTOR] = function (params) {
|
|
275
|
+
const scope = this[STACK].pushBlockScope();
|
|
276
|
+
blockAfterSuper.get(this[STACK]);
|
|
277
|
+
stack.clearTo(scope);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
toString() {
|
|
281
|
+
let str = this.decorators.map(decorator => decorator.toString()).join(' ');
|
|
282
|
+
if (str.length) {
|
|
283
|
+
str += ' ';
|
|
284
|
+
}
|
|
285
|
+
let name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
|
|
286
|
+
switch (this.kind) {
|
|
287
|
+
case 'constructor':
|
|
288
|
+
str += 'constructor ';
|
|
289
|
+
break;
|
|
290
|
+
case 'get':
|
|
291
|
+
str += `get ${name} `;
|
|
292
|
+
break;
|
|
293
|
+
case 'set':
|
|
294
|
+
str += `set ${name} `;
|
|
295
|
+
break;
|
|
296
|
+
default:
|
|
297
|
+
str = `${name} `;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
str += this.value.toString();
|
|
301
|
+
return str;
|
|
302
|
+
}
|
|
303
|
+
toJson() {
|
|
304
|
+
return {
|
|
305
|
+
kind: this.kind,
|
|
306
|
+
key: this.key.toJSON(),
|
|
307
|
+
value: this.value.toJSON(),
|
|
308
|
+
decorators: this.decorators.map(decorator => decorator.toJSON()),
|
|
309
|
+
computed: this.computed,
|
|
310
|
+
static: this.static,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
MethodDefinition = MethodDefinition_1 = __decorate_1([
|
|
315
|
+
Deserializer('MethodDefinition'),
|
|
316
|
+
__metadata("design:paramtypes", [String, Object, FunctionExpression, Array, Boolean, Boolean])
|
|
317
|
+
], MethodDefinition);
|
|
318
|
+
export { MethodDefinition };
|
|
319
|
+
let PropertyDefinition = PropertyDefinition_1 = class PropertyDefinition extends AbstractDefinition {
|
|
320
|
+
static fromJSON(node, deserializer) {
|
|
321
|
+
return new PropertyDefinition_1(deserializer(node.key), node.decorators.map(deserializer), node.computed, node.static, node.value && deserializer(node.value));
|
|
322
|
+
}
|
|
323
|
+
static visit(node, visitNode) {
|
|
324
|
+
visitNode(node.key);
|
|
325
|
+
node.value && visitNode(node.value);
|
|
326
|
+
}
|
|
327
|
+
constructor(key, decorators, computed, isStatic, value) {
|
|
328
|
+
super(key, decorators, computed, isStatic, value);
|
|
329
|
+
}
|
|
330
|
+
get(stack, classConstructor) {
|
|
331
|
+
const target = this.static ? classConstructor : classConstructor.prototype;
|
|
332
|
+
const value = this.value?.get(stack);
|
|
333
|
+
const name = this.computed ? this.key.get(stack) : this.key.getName();
|
|
334
|
+
const ref = this.key instanceof PrivateIdentifier ? target[INIT_PRIVATE_SYMBOL] : target;
|
|
335
|
+
ref[name] = value;
|
|
336
|
+
const decorators = this.decorators.map(decorator => decorator.get(stack));
|
|
337
|
+
__decorate(decorators, target, name, null);
|
|
338
|
+
}
|
|
339
|
+
toString() {
|
|
340
|
+
const decorators = this.decorators.map(decorator => decorator.toString()).join('\n');
|
|
341
|
+
const name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
|
|
342
|
+
if (this.value) {
|
|
343
|
+
return `${name} = ${this.value.toString()};`;
|
|
344
|
+
}
|
|
345
|
+
return `${decorators.length ? decorators + ' ' : ''}${name};`;
|
|
346
|
+
}
|
|
347
|
+
toJson() {
|
|
348
|
+
return {
|
|
349
|
+
key: this.key.toJSON(),
|
|
350
|
+
value: this.value?.toJSON(),
|
|
351
|
+
decorators: this.decorators.map(decorator => decorator.toJSON()),
|
|
352
|
+
computed: this.computed,
|
|
353
|
+
static: this.static,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
PropertyDefinition = PropertyDefinition_1 = __decorate_1([
|
|
358
|
+
Deserializer('PropertyDefinition'),
|
|
359
|
+
__metadata("design:paramtypes", [Object, Array, Boolean, Boolean, Object])
|
|
360
|
+
], PropertyDefinition);
|
|
361
|
+
export { PropertyDefinition };
|
|
362
|
+
let AccessorProperty = AccessorProperty_1 = class AccessorProperty extends AbstractDefinition {
|
|
363
|
+
static fromJSON(node, deserializer) {
|
|
364
|
+
return new AccessorProperty_1(deserializer(node.key), node.decorators.map(deserializer), node.computed, node.static, node.value ? deserializer(node.value) : void 0);
|
|
365
|
+
}
|
|
366
|
+
static visit(node, visitNode) {
|
|
367
|
+
visitNode(node.key);
|
|
368
|
+
node.value && visitNode(node.value);
|
|
369
|
+
node.decorators.forEach(visitNode);
|
|
370
|
+
}
|
|
371
|
+
constructor(key, decorators, computed, isStatic, value) {
|
|
372
|
+
super(key, decorators, computed, isStatic, value);
|
|
373
|
+
}
|
|
374
|
+
get(stack, classConstructor) {
|
|
375
|
+
const target = this.static ? classConstructor : classConstructor.prototype;
|
|
376
|
+
const value = this.value?.get(stack);
|
|
377
|
+
const name = this.computed ? this.key.get(stack) : this.key.getName();
|
|
378
|
+
target[INIT_PRIVATE_SYMBOL][name] = value;
|
|
379
|
+
Object.defineProperty(target, name, {
|
|
380
|
+
configurable: true,
|
|
381
|
+
enumerable: false,
|
|
382
|
+
set: function (setValue) {
|
|
383
|
+
this[PRIVATE_SYMBOL][name] = setValue;
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
Object.defineProperty(target, name, {
|
|
387
|
+
configurable: true,
|
|
388
|
+
enumerable: false,
|
|
389
|
+
get: function () {
|
|
390
|
+
return this[PRIVATE_SYMBOL][name];
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
const decorators = this.decorators.map(decorator => decorator.get(stack));
|
|
394
|
+
__decorate(decorators, target, name, null);
|
|
395
|
+
}
|
|
396
|
+
toString() {
|
|
397
|
+
const decorators = this.decorators.map(decorator => decorator.toString()).join('\n');
|
|
398
|
+
const name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
|
|
399
|
+
if (this.value) {
|
|
400
|
+
return `${name} = ${this.value.toString()};`;
|
|
401
|
+
}
|
|
402
|
+
return `${decorators.length ? decorators + ' ' : ''}accessor ${name};`;
|
|
403
|
+
}
|
|
404
|
+
toJson() {
|
|
405
|
+
return {
|
|
406
|
+
key: this.key.toJSON(),
|
|
407
|
+
decorators: this.decorators.map(decorator => decorator.toJSON()),
|
|
408
|
+
computed: this.computed,
|
|
409
|
+
static: this.static,
|
|
410
|
+
value: this.value?.toJSON(),
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
AccessorProperty = AccessorProperty_1 = __decorate_1([
|
|
415
|
+
Deserializer('AccessorProperty'),
|
|
416
|
+
__metadata("design:paramtypes", [Object, Array, Boolean, Boolean, Object])
|
|
417
|
+
], AccessorProperty);
|
|
418
|
+
export { AccessorProperty };
|
|
419
|
+
let ClassBody = ClassBody_1 = class ClassBody extends AbstractExpressionNode {
|
|
420
|
+
constructor(body) {
|
|
421
|
+
super();
|
|
422
|
+
this.body = body;
|
|
423
|
+
}
|
|
424
|
+
static fromJSON(node, deserializer) {
|
|
425
|
+
return new ClassBody_1(node.body.map(deserializer));
|
|
426
|
+
}
|
|
427
|
+
static visit(node, visitNode) {
|
|
428
|
+
node.body.forEach(visitNode);
|
|
429
|
+
}
|
|
430
|
+
getBody() {
|
|
431
|
+
return this.body;
|
|
432
|
+
}
|
|
433
|
+
shareVariables(scopeList) { }
|
|
434
|
+
set(stack, value) {
|
|
435
|
+
throw new Error('Method not implemented.');
|
|
436
|
+
}
|
|
437
|
+
get(stack, classConstructor) {
|
|
438
|
+
this.body.forEach(definition => definition.get(stack, classConstructor));
|
|
439
|
+
}
|
|
440
|
+
dependency(computed) {
|
|
441
|
+
throw new Error('Method not implemented.');
|
|
442
|
+
}
|
|
443
|
+
dependencyPath(computed) {
|
|
444
|
+
throw new Error('Method not implemented.');
|
|
445
|
+
}
|
|
446
|
+
toString() {
|
|
447
|
+
return this.body.map(definition => definition.toString()).join('\n');
|
|
448
|
+
}
|
|
449
|
+
toJson() {
|
|
450
|
+
return {
|
|
451
|
+
body: this.body.map(method => method.toJSON())
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
ClassBody = ClassBody_1 = __decorate_1([
|
|
456
|
+
Deserializer('ClassBody'),
|
|
457
|
+
__metadata("design:paramtypes", [Array])
|
|
458
|
+
], ClassBody);
|
|
459
|
+
export { ClassBody };
|
|
460
|
+
export class Class extends AbstractExpressionNode {
|
|
461
|
+
constructor(body, decorators, id, superClass) {
|
|
462
|
+
super();
|
|
463
|
+
this.body = body;
|
|
464
|
+
this.decorators = decorators;
|
|
465
|
+
this.id = id;
|
|
466
|
+
this.superClass = superClass;
|
|
467
|
+
}
|
|
468
|
+
getBody() {
|
|
469
|
+
return this.body;
|
|
470
|
+
}
|
|
471
|
+
getDecorators() {
|
|
472
|
+
return this.decorators;
|
|
473
|
+
}
|
|
474
|
+
getId() {
|
|
475
|
+
return this.id;
|
|
476
|
+
}
|
|
477
|
+
getSuperClass() {
|
|
478
|
+
return this.superClass;
|
|
479
|
+
}
|
|
480
|
+
shareVariables(scopeList) {
|
|
481
|
+
this.sharedVariables = scopeList;
|
|
482
|
+
}
|
|
483
|
+
set(stack) {
|
|
484
|
+
throw new Error(`Class.#set() has no implementation.`);
|
|
485
|
+
}
|
|
486
|
+
get(stack) {
|
|
487
|
+
const className = this.id?.get(stack);
|
|
488
|
+
const parentClass = this.superClass?.get(stack) ?? class {
|
|
489
|
+
};
|
|
490
|
+
let classConstructor = this.createClass(stack, parentClass, className);
|
|
491
|
+
this.body.get(stack, classConstructor);
|
|
492
|
+
classConstructor[PRIVATE_SYMBOL] = Object.assign(classConstructor[PRIVATE_SYMBOL], classConstructor[INIT_PRIVATE_SYMBOL]);
|
|
493
|
+
Reflect.deleteProperty(classConstructor, INIT_PRIVATE_SYMBOL);
|
|
494
|
+
const decorators = this.decorators.map(decorator => decorator.get(stack));
|
|
495
|
+
classConstructor = __decorate(decorators, classConstructor);
|
|
496
|
+
return classConstructor;
|
|
497
|
+
}
|
|
498
|
+
createClass(stack, parentClass, className = TEMP_CLASS_NAME) {
|
|
499
|
+
var _a, _b, _c, _d, _e, _f;
|
|
500
|
+
const TEMP = {
|
|
501
|
+
[className]: (_a = class extends parentClass {
|
|
502
|
+
constructor(...params) {
|
|
503
|
+
const parameters = TEMP[className][GET_PARAMETERS](params);
|
|
504
|
+
super(...parameters);
|
|
505
|
+
this[_e] = {};
|
|
506
|
+
this[_f] = {};
|
|
507
|
+
this[PRIVATE_SYMBOL] = Object.assign(this[PRIVATE_SYMBOL], this[INIT_PRIVATE_SYMBOL]);
|
|
508
|
+
this[STACK] = stack.copyStack();
|
|
509
|
+
const instanceStack = this[STACK];
|
|
510
|
+
instanceStack.pushBlockScope();
|
|
511
|
+
instanceStack.declareVariable('this', this);
|
|
512
|
+
instanceStack.declareVariable(NEW_TARGET, new.target);
|
|
513
|
+
instanceStack.declareVariable(PRIVATE_SYMBOL, this[PRIVATE_SYMBOL]);
|
|
514
|
+
instanceStack.declareVariable(CALL_SUPER_Method, (name) => super[name]());
|
|
515
|
+
instanceStack.declareVariable(GET_SUPER_PROPERTY, (name) => super[name]);
|
|
516
|
+
instanceStack.pushReactiveScope();
|
|
517
|
+
this[CONSTRUCTOR]();
|
|
518
|
+
}
|
|
519
|
+
static [GET_PARAMETERS](args) {
|
|
520
|
+
return [];
|
|
521
|
+
}
|
|
522
|
+
[(_b = STATIC_INITIALIZATION_BLOCK, _c = INIT_PRIVATE_SYMBOL, _d = PRIVATE_SYMBOL, _e = PRIVATE_SYMBOL, _f = INIT_PRIVATE_SYMBOL, CONSTRUCTOR)]() { }
|
|
523
|
+
},
|
|
524
|
+
_a[_b] = [],
|
|
525
|
+
_a[_c] = {},
|
|
526
|
+
_a[_d] = {},
|
|
527
|
+
(() => {
|
|
528
|
+
_a[STATIC_INITIALIZATION_BLOCK].forEach(block => block());
|
|
529
|
+
})(),
|
|
530
|
+
_a)
|
|
531
|
+
};
|
|
532
|
+
return TEMP[className];
|
|
533
|
+
}
|
|
534
|
+
dependency(computed) {
|
|
535
|
+
throw new Error('Method not implemented.');
|
|
536
|
+
}
|
|
537
|
+
dependencyPath(computed) {
|
|
538
|
+
throw new Error('Method not implemented.');
|
|
539
|
+
}
|
|
540
|
+
toString() {
|
|
541
|
+
const decorators = this.decorators.map(decorator => decorator.toString()).join('\n');
|
|
542
|
+
let classDeclaration = 'class ';
|
|
543
|
+
if (this.id) {
|
|
544
|
+
classDeclaration += this.id.toString();
|
|
545
|
+
}
|
|
546
|
+
if (this.superClass) {
|
|
547
|
+
classDeclaration += ' extends ' + this.superClass.toString();
|
|
548
|
+
}
|
|
549
|
+
return `${decorators}${classDeclaration} {${this.body.toString()}\n`;
|
|
550
|
+
}
|
|
551
|
+
toJson() {
|
|
552
|
+
return {
|
|
553
|
+
body: this.body.toJSON(),
|
|
554
|
+
decorators: this.decorators.map(decorator => decorator.toJSON()),
|
|
555
|
+
id: this.id?.toJSON(),
|
|
556
|
+
superClass: this.superClass?.toJSON(),
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
let ClassDeclaration = ClassDeclaration_1 = class ClassDeclaration extends Class {
|
|
561
|
+
static fromJSON(node, deserializer) {
|
|
562
|
+
return new ClassDeclaration_1(deserializer(node.body), deserializer(node.id), node.superClass && deserializer(node.superClass));
|
|
563
|
+
}
|
|
564
|
+
static visit(node, visitNode) {
|
|
565
|
+
visitNode(node.body);
|
|
566
|
+
node.id && visitNode(node.id);
|
|
567
|
+
node.superClass && visitNode(node.superClass);
|
|
568
|
+
}
|
|
569
|
+
declareVariable(stack, propertyValue) {
|
|
570
|
+
this.id && stack.declareVariable(this.id.getName(), propertyValue);
|
|
571
|
+
}
|
|
572
|
+
getDeclarationName() {
|
|
573
|
+
return this.id?.getDeclarationName();
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
ClassDeclaration = ClassDeclaration_1 = __decorate_1([
|
|
577
|
+
Deserializer('ClassDeclaration')
|
|
578
|
+
], ClassDeclaration);
|
|
579
|
+
export { ClassDeclaration };
|
|
580
|
+
let ClassExpression = ClassExpression_1 = class ClassExpression extends Class {
|
|
581
|
+
static fromJSON(node, deserializer) {
|
|
582
|
+
return new ClassExpression_1(deserializer(node.body), node.id && deserializer(node.id), node.superClass && deserializer(node.superClass));
|
|
583
|
+
}
|
|
584
|
+
static visit(node, visitNode) {
|
|
585
|
+
visitNode(node.body);
|
|
586
|
+
node.id && visitNode(node.id);
|
|
587
|
+
node.superClass && visitNode(node.superClass);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
ClassExpression = ClassExpression_1 = __decorate_1([
|
|
591
|
+
Deserializer('ClassExpression')
|
|
592
|
+
], ClassExpression);
|
|
593
|
+
export { ClassExpression };
|
|
594
|
+
//# sourceMappingURL=class.js.map
|