@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.
Files changed (251) hide show
  1. package/README.md +48 -1
  2. package/api/abstract.d.ts +1 -0
  3. package/api/abstract.d.ts.map +1 -0
  4. package/api/abstract.js +12 -0
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +1 -0
  7. package/api/class/class.d.ts.map +1 -0
  8. package/api/class/class.js +603 -472
  9. package/api/class/class.js.map +1 -1
  10. package/api/class/decorator.d.ts +1 -0
  11. package/api/class/decorator.d.ts.map +1 -0
  12. package/api/class/decorator.js +53 -41
  13. package/api/class/decorator.js.map +1 -1
  14. package/api/computing/call.d.ts +1 -0
  15. package/api/computing/call.d.ts.map +1 -0
  16. package/api/computing/call.js +83 -69
  17. package/api/computing/call.js.map +1 -1
  18. package/api/computing/debugger.d.ts +1 -0
  19. package/api/computing/debugger.d.ts.map +1 -0
  20. package/api/computing/debugger.js +40 -28
  21. package/api/computing/debugger.js.map +1 -1
  22. package/api/computing/new.d.ts +1 -0
  23. package/api/computing/new.d.ts.map +1 -0
  24. package/api/computing/new.js +81 -68
  25. package/api/computing/new.js.map +1 -1
  26. package/api/computing/rest.d.ts +1 -0
  27. package/api/computing/rest.d.ts.map +1 -0
  28. package/api/computing/rest.js +54 -42
  29. package/api/computing/rest.js.map +1 -1
  30. package/api/computing/return.d.ts +1 -0
  31. package/api/computing/return.d.ts.map +1 -0
  32. package/api/computing/return.js +52 -40
  33. package/api/computing/return.js.map +1 -1
  34. package/api/computing/spread.d.ts +1 -0
  35. package/api/computing/spread.d.ts.map +1 -0
  36. package/api/computing/spread.js +70 -58
  37. package/api/computing/spread.js.map +1 -1
  38. package/api/computing/throw.d.ts +1 -0
  39. package/api/computing/throw.d.ts.map +1 -0
  40. package/api/computing/throw.js +216 -175
  41. package/api/computing/throw.js.map +1 -1
  42. package/api/computing/yield.d.ts +1 -0
  43. package/api/computing/yield.d.ts.map +1 -0
  44. package/api/computing/yield.js +60 -47
  45. package/api/computing/yield.js.map +1 -1
  46. package/api/definition/array.d.ts +1 -0
  47. package/api/definition/array.d.ts.map +1 -0
  48. package/api/definition/array.js +147 -122
  49. package/api/definition/array.js.map +1 -1
  50. package/api/definition/bind.d.ts +1 -0
  51. package/api/definition/bind.d.ts.map +1 -0
  52. package/api/definition/bind.js +85 -70
  53. package/api/definition/bind.js.map +1 -1
  54. package/api/definition/comment.d.ts +1 -0
  55. package/api/definition/comment.d.ts.map +1 -0
  56. package/api/definition/comment.js +44 -32
  57. package/api/definition/comment.js.map +1 -1
  58. package/api/definition/function.d.ts +1 -0
  59. package/api/definition/function.d.ts.map +1 -0
  60. package/api/definition/function.js +500 -443
  61. package/api/definition/function.js.map +1 -1
  62. package/api/definition/member.d.ts +1 -0
  63. package/api/definition/member.d.ts.map +1 -0
  64. package/api/definition/member.js +104 -89
  65. package/api/definition/member.js.map +1 -1
  66. package/api/definition/object.d.ts +1 -0
  67. package/api/definition/object.d.ts.map +1 -0
  68. package/api/definition/object.js +243 -200
  69. package/api/definition/object.js.map +1 -1
  70. package/api/definition/statement.d.ts +1 -0
  71. package/api/definition/statement.d.ts.map +1 -0
  72. package/api/definition/statement.js +56 -44
  73. package/api/definition/statement.js.map +1 -1
  74. package/api/definition/values.d.ts +1 -0
  75. package/api/definition/values.d.ts.map +1 -0
  76. package/api/definition/values.js +228 -160
  77. package/api/definition/values.js.map +1 -1
  78. package/api/deserialize/deserialize.d.ts +2 -1
  79. package/api/deserialize/deserialize.d.ts.map +1 -0
  80. package/api/deserialize/deserialize.js +5 -7
  81. package/api/deserialize/deserialize.js.map +1 -1
  82. package/api/deserialize/type-store.d.ts +1 -0
  83. package/api/deserialize/type-store.d.ts.map +1 -0
  84. package/api/expression.d.ts +1 -0
  85. package/api/expression.d.ts.map +1 -0
  86. package/api/index.d.ts +1 -0
  87. package/api/index.d.ts.map +1 -0
  88. package/api/module/common.d.ts +1 -0
  89. package/api/module/common.d.ts.map +1 -0
  90. package/api/module/common.js +63 -50
  91. package/api/module/common.js.map +1 -1
  92. package/api/module/export.d.ts +1 -0
  93. package/api/module/export.d.ts.map +1 -0
  94. package/api/module/export.js +343 -290
  95. package/api/module/export.js.map +1 -1
  96. package/api/module/import.d.ts +1 -0
  97. package/api/module/import.d.ts.map +1 -0
  98. package/api/module/import.js +318 -253
  99. package/api/module/import.js.map +1 -1
  100. package/api/operators/assignment.d.ts +1 -0
  101. package/api/operators/assignment.d.ts.map +1 -0
  102. package/api/operators/assignment.js +88 -75
  103. package/api/operators/assignment.js.map +1 -1
  104. package/api/operators/await.d.ts +1 -0
  105. package/api/operators/await.d.ts.map +1 -0
  106. package/api/operators/await.js +54 -42
  107. package/api/operators/await.js.map +1 -1
  108. package/api/operators/binary.d.ts +1 -0
  109. package/api/operators/binary.d.ts.map +1 -0
  110. package/api/operators/binary.js +78 -64
  111. package/api/operators/binary.js.map +1 -1
  112. package/api/operators/chaining.d.ts +1 -0
  113. package/api/operators/chaining.d.ts.map +1 -0
  114. package/api/operators/chaining.js +56 -44
  115. package/api/operators/chaining.js.map +1 -1
  116. package/api/operators/comma.d.ts +1 -0
  117. package/api/operators/comma.d.ts.map +1 -0
  118. package/api/operators/comma.js +53 -41
  119. package/api/operators/comma.js.map +1 -1
  120. package/api/operators/grouping.d.ts +1 -0
  121. package/api/operators/grouping.d.ts.map +1 -0
  122. package/api/operators/grouping.js +51 -39
  123. package/api/operators/grouping.js.map +1 -1
  124. package/api/operators/logical.d.ts +1 -0
  125. package/api/operators/logical.d.ts.map +1 -0
  126. package/api/operators/logical.js +51 -37
  127. package/api/operators/logical.js.map +1 -1
  128. package/api/operators/pipeline.d.ts +1 -0
  129. package/api/operators/pipeline.d.ts.map +1 -0
  130. package/api/operators/pipeline.js +95 -81
  131. package/api/operators/pipeline.js.map +1 -1
  132. package/api/operators/ternary.d.ts +1 -0
  133. package/api/operators/ternary.d.ts.map +1 -0
  134. package/api/operators/ternary.js +69 -55
  135. package/api/operators/ternary.js.map +1 -1
  136. package/api/operators/types.d.ts +1 -0
  137. package/api/operators/types.d.ts.map +1 -0
  138. package/api/operators/unary.d.ts +1 -0
  139. package/api/operators/unary.d.ts.map +1 -0
  140. package/api/operators/unary.js +97 -82
  141. package/api/operators/unary.js.map +1 -1
  142. package/api/operators/update.d.ts +1 -0
  143. package/api/operators/update.d.ts.map +1 -0
  144. package/api/operators/update.js +78 -62
  145. package/api/operators/update.js.map +1 -1
  146. package/api/program.d.ts +1 -0
  147. package/api/program.d.ts.map +1 -0
  148. package/api/program.js +53 -40
  149. package/api/program.js.map +1 -1
  150. package/api/statement/control/block.d.ts +1 -0
  151. package/api/statement/control/block.d.ts.map +1 -0
  152. package/api/statement/control/block.js +65 -53
  153. package/api/statement/control/block.js.map +1 -1
  154. package/api/statement/control/empty.d.ts +1 -1
  155. package/api/statement/control/empty.d.ts.map +1 -0
  156. package/api/statement/control/empty.js +43 -33
  157. package/api/statement/control/empty.js.map +1 -1
  158. package/api/statement/control/if.d.ts +1 -0
  159. package/api/statement/control/if.d.ts.map +1 -0
  160. package/api/statement/control/if.js +79 -65
  161. package/api/statement/control/if.js.map +1 -1
  162. package/api/statement/control/switch.d.ts +1 -0
  163. package/api/statement/control/switch.d.ts.map +1 -0
  164. package/api/statement/control/switch.js +180 -141
  165. package/api/statement/control/switch.js.map +1 -1
  166. package/api/statement/control/terminate.d.ts +1 -2
  167. package/api/statement/control/terminate.d.ts.map +1 -0
  168. package/api/statement/control/terminate.js +117 -78
  169. package/api/statement/control/terminate.js.map +1 -1
  170. package/api/statement/control/with.d.ts +1 -0
  171. package/api/statement/control/with.d.ts.map +1 -0
  172. package/api/statement/control/with.js +72 -59
  173. package/api/statement/control/with.js.map +1 -1
  174. package/api/statement/declarations/declares.d.ts +1 -0
  175. package/api/statement/declarations/declares.d.ts.map +1 -0
  176. package/api/statement/declarations/declares.js +148 -121
  177. package/api/statement/declarations/declares.js.map +1 -1
  178. package/api/statement/iterations/for.d.ts +1 -0
  179. package/api/statement/iterations/for.d.ts.map +1 -0
  180. package/api/statement/iterations/for.js +337 -277
  181. package/api/statement/iterations/for.js.map +1 -1
  182. package/api/statement/iterations/while.d.ts +1 -0
  183. package/api/statement/iterations/while.d.ts.map +1 -0
  184. package/api/statement/iterations/while.js +152 -125
  185. package/api/statement/iterations/while.js.map +1 -1
  186. package/api/utils.d.ts +1 -0
  187. package/api/utils.d.ts.map +1 -0
  188. package/index.d.ts +1 -0
  189. package/index.d.ts.map +1 -0
  190. package/package.json +5 -5
  191. package/scope/builder.d.ts +27 -0
  192. package/scope/builder.d.ts.map +1 -0
  193. package/scope/builder.js +73 -0
  194. package/scope/builder.js.map +1 -0
  195. package/scope/event.d.ts +1 -0
  196. package/scope/event.d.ts.map +1 -0
  197. package/scope/finalizer.d.ts +1 -0
  198. package/scope/finalizer.d.ts.map +1 -0
  199. package/scope/index.d.ts +1 -0
  200. package/scope/index.d.ts.map +1 -0
  201. package/scope/pool.d.ts +1 -0
  202. package/scope/pool.d.ts.map +1 -0
  203. package/scope/proxy.d.ts +1 -0
  204. package/scope/proxy.d.ts.map +1 -0
  205. package/scope/proxy.js +1 -0
  206. package/scope/proxy.js.map +1 -1
  207. package/scope/scope.d.ts +1 -0
  208. package/scope/scope.d.ts.map +1 -0
  209. package/scope/scope.js +17 -11
  210. package/scope/scope.js.map +1 -1
  211. package/scope/stack.d.ts +1 -0
  212. package/scope/stack.d.ts.map +1 -0
  213. package/scope/stack.js +22 -14
  214. package/scope/stack.js.map +1 -1
  215. package/v8/enums.d.ts +1 -0
  216. package/v8/enums.d.ts.map +1 -0
  217. package/v8/enums.js +11 -11
  218. package/v8/enums.js.map +1 -1
  219. package/v8/factory.d.ts +1 -0
  220. package/v8/factory.d.ts.map +1 -0
  221. package/v8/factory.js +3 -1
  222. package/v8/factory.js.map +1 -1
  223. package/v8/index.d.ts +1 -0
  224. package/v8/index.d.ts.map +1 -0
  225. package/v8/inline.d.ts +1 -0
  226. package/v8/inline.d.ts.map +1 -0
  227. package/v8/inline.js +9 -5
  228. package/v8/inline.js.map +1 -1
  229. package/v8/language.d.ts +1 -0
  230. package/v8/language.d.ts.map +1 -0
  231. package/v8/node.d.ts +1 -0
  232. package/v8/node.d.ts.map +1 -0
  233. package/v8/parser.d.ts +1 -0
  234. package/v8/parser.d.ts.map +1 -0
  235. package/v8/parser.js +5 -5
  236. package/v8/parser.js.map +1 -1
  237. package/v8/stream.d.ts +1 -0
  238. package/v8/stream.d.ts.map +1 -0
  239. package/v8/stream.js +17 -7
  240. package/v8/stream.js.map +1 -1
  241. package/v8/token.d.ts +1 -0
  242. package/v8/token.d.ts.map +1 -0
  243. package/v8/token.js +363 -358
  244. package/v8/token.js.map +1 -1
  245. package/visit/index.d.ts +1 -0
  246. package/visit/index.d.ts.map +1 -0
  247. package/visit/visitor.d.ts +1 -0
  248. package/visit/visitor.d.ts.map +1 -0
  249. package/v8/nodes.d.ts +0 -0
  250. package/v8/nodes.js +0 -2
  251. package/v8/nodes.js.map +0 -1
@@ -1,214 +1,257 @@
1
- var Property_1, ObjectExpression_1, ObjectPattern_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 = Property_1 = class Property extends AbstractExpressionNode {
8
- static fromJSON(node, deserializer) {
9
- return new Property_1(deserializer(node.key), deserializer(node.value), node.kind, node.method, node.shorthand, node.computed, node.range, node.loc);
10
- }
11
- static visit(node, visitNode) {
12
- visitNode(node.key);
13
- visitNode(node.value);
14
- }
15
- constructor(key, value, kind, method, shorthand, computed, range, loc) {
16
- super(range, loc);
17
- this.key = key;
18
- this.value = value;
19
- this.kind = kind;
20
- this.method = method;
21
- this.shorthand = shorthand;
22
- this.computed = computed;
23
- }
24
- getKey() {
25
- return this.key;
26
- }
27
- getValue() {
28
- return this.value;
29
- }
30
- set(stack, value) {
31
- this.key.set(stack, value);
32
- }
33
- get(stack, thisContext) {
34
- const name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);
35
- let value;
36
- switch (this.kind) {
37
- case 'get':
38
- const get = this.value.get(stack);
39
- Object.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });
40
- value = get;
41
- break;
42
- case 'set':
43
- const set = this.value.get(stack);
44
- Object.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });
45
- value = set;
46
- break;
47
- default:
48
- case 'init':
49
- value = this.value.get(stack);
50
- Object.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });
51
- break;
52
- }
53
- return value;
54
- }
55
- declareVariable(stack, objectValue) {
56
- const propertyName = this.shorthand ? this.key.getName() : this.key.get(stack);
57
- const propertyValue = objectValue[propertyName];
58
- this.value.declareVariable(stack, propertyValue);
59
- }
60
- dependency(computed) {
61
- return this.key.dependency(computed).concat(this.value.dependency(computed));
62
- }
63
- dependencyPath(computed) {
64
- return this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));
65
- }
66
- toString() {
67
- const key = this.computed ? `[${this.key.toString()}]` : this.key.toString();
68
- if (this.shorthand) {
69
- return key;
70
- }
71
- let value = '';
72
- switch (this.kind) {
73
- case 'get':
74
- case 'set':
75
- const expression = this.value;
76
- value += this.kind;
77
- value += ' ' + key;
78
- value += expression.paramsAndBodyToString();
79
- break;
80
- case 'init':
81
- if (this.method) {
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
- else {
87
- value += this.value.toString();
88
- return `${key}: ${value}`;
89
- }
90
- break;
91
- default:
92
- break;
93
- }
94
- return value;
95
- }
96
- toJson() {
97
- return {
98
- key: this.key.toJSON(),
99
- value: this.value.toJSON(),
100
- kind: this.kind
101
- };
102
- }
103
- };
104
- Property = Property_1 = __decorate([
105
- Deserializer('Property'),
106
- __metadata("design:paramtypes", [Object, Object, String, Boolean, Boolean, Boolean, Array, Object])
107
- ], Property);
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 = ObjectExpression_1 = class ObjectExpression extends AbstractExpressionNode {
110
- static fromJSON(node, deserializer) {
111
- return new ObjectExpression_1(node.properties.map(deserializer), node.range, node.loc);
112
- }
113
- static visit(node, visitNode) {
114
- node.properties.forEach(visitNode);
115
- }
116
- constructor(properties, range, loc) {
117
- super(range, loc);
118
- this.properties = properties;
119
- }
120
- getProperties() {
121
- return this.properties;
122
- }
123
- set(stack) {
124
- throw new Error('ObjectExpression#set() has no implementation.');
125
- }
126
- get(stack) {
127
- const newObject = {};
128
- for (const property of this.properties) {
129
- property.get(stack, newObject);
130
- }
131
- return newObject;
132
- }
133
- dependency(computed) {
134
- return this.properties.flatMap(property => property.dependency(computed));
135
- }
136
- dependencyPath(computed) {
137
- return this.properties.flatMap(property => property.dependencyPath(computed));
138
- }
139
- toString() {
140
- return `{ ${this.properties.map(item => item.toString()).join(', ')} }`;
141
- }
142
- toJson() {
143
- return {
144
- properties: this.properties.map(item => item.toJSON())
145
- };
146
- }
147
- };
148
- ObjectExpression = ObjectExpression_1 = __decorate([
149
- Deserializer('ObjectExpression'),
150
- __metadata("design:paramtypes", [Array, Array, Object])
151
- ], ObjectExpression);
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 = ObjectPattern_1 = class ObjectPattern extends AbstractExpressionNode {
154
- static fromJSON(node, deserializer) {
155
- return new ObjectPattern_1(node.properties.map(deserializer), node.range, node.loc);
156
- }
157
- static visit(node, visitNode) {
158
- node.properties.forEach(visitNode);
159
- }
160
- constructor(properties, range, loc) {
161
- super(range, loc);
162
- this.properties = properties;
163
- }
164
- getProperties() {
165
- return this.properties;
166
- }
167
- set(stack, objectValue) {
168
- throw new Error('ObjectPattern#set() has no implementation.');
169
- }
170
- get(scopeProvider) {
171
- throw new Error('ObjectPattern#get() has no implementation.');
172
- }
173
- declareVariable(stack, objectValue) {
174
- for (const property of this.properties) {
175
- if (property instanceof RestElement) {
176
- objectValue = this.getFromObject(stack, objectValue);
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
- property.declareVariable(stack, objectValue);
179
- }
180
- }
181
- getFromObject(stack, objectValue) {
182
- const keys = [];
183
- keys.push(...Object.keys(objectValue));
184
- keys.push(...Object.getOwnPropertySymbols(objectValue));
185
- const restObject = {};
186
- const context = stack.lastScope().getContext();
187
- for (const key of keys) {
188
- if (!(key in context)) {
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
- return restObject;
193
- }
194
- dependency(computed) {
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,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;AAI5C,IAAM,QAAQ,gBAAd,MAAM,QAAS,SAAQ,sBAAsB;IACnD,MAAM,CAAC,QAAQ,CAAC,IAAc,EAAE,YAA8B;QAC7D,OAAO,IAAI,UAAQ,CAClB,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EACtB,YAAY,CAAC,IAAI,CAAC,KAAK,CAA0B,EACjD,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,GAAG,CACR,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAc,EAAE,SAAwB;QACpD,SA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I,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;QACH,KAAK;QACL,IAAI;QACJ,MAAM;QACN,SAAS;QACT,QAAQ;QAtBnB,MAAM,CAAC,QAAQ,CAAC,IAAc,EAAE,YAA8B;YAC7D,OAAO,IAAI,QAAQ,CAClB,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EACtB,YAAY,CAAC,IAAI,CAAC,KAAK,CAA0B,EACjD,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,GAAG,CACR,CAAC;QACH,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,IAAc,EAAE,SAAwB;YACpD,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,YACW,GAAmB,EACnB,KAA6C,EAC7C,IAA4B,EAC5B,MAAe,EACf,SAAkB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AAC;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"]}
@@ -14,3 +14,4 @@ export declare class ExpressionStatement extends AbstractExpressionNode {
14
14
  toString(): string;
15
15
  toJson(): object;
16
16
  }
17
+ //# sourceMappingURL=statement.d.ts.map
@@ -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"}