greybel-interpreter 1.4.2 → 1.4.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.
Files changed (99) hide show
  1. package/.editorconfig +14 -14
  2. package/.eslintrc +47 -47
  3. package/LICENSE +21 -21
  4. package/README.md +2 -2
  5. package/dist/context.d.ts +109 -109
  6. package/dist/context.js +383 -383
  7. package/dist/cps.d.ts +14 -14
  8. package/dist/cps.js +213 -213
  9. package/dist/handler/error.d.ts +6 -6
  10. package/dist/handler/error.js +35 -35
  11. package/dist/handler/output.d.ts +18 -18
  12. package/dist/handler/output.js +52 -52
  13. package/dist/handler/resource.d.ts +12 -12
  14. package/dist/handler/resource.js +51 -51
  15. package/dist/handler-container.d.ts +14 -14
  16. package/dist/handler-container.js +16 -16
  17. package/dist/index.d.ts +45 -45
  18. package/dist/index.js +131 -131
  19. package/dist/interpreter.d.ts +41 -41
  20. package/dist/interpreter.js +312 -312
  21. package/dist/intrinsics-container.d.ts +7 -7
  22. package/dist/intrinsics-container.js +19 -19
  23. package/dist/operations/assign.d.ts +13 -13
  24. package/dist/operations/assign.js +111 -111
  25. package/dist/operations/block.d.ts +12 -12
  26. package/dist/operations/block.js +108 -108
  27. package/dist/operations/break.d.ts +10 -10
  28. package/dist/operations/break.js +41 -41
  29. package/dist/operations/call.d.ts +13 -13
  30. package/dist/operations/call.js +124 -124
  31. package/dist/operations/chunk.d.ts +12 -12
  32. package/dist/operations/chunk.js +85 -85
  33. package/dist/operations/continue.d.ts +10 -10
  34. package/dist/operations/continue.js +41 -41
  35. package/dist/operations/debugger-statement.d.ts +10 -10
  36. package/dist/operations/debugger-statement.js +39 -39
  37. package/dist/operations/evaluate.d.ts +40 -40
  38. package/dist/operations/evaluate.js +438 -438
  39. package/dist/operations/for.d.ts +14 -14
  40. package/dist/operations/for.js +152 -152
  41. package/dist/operations/function-reference.d.ts +12 -12
  42. package/dist/operations/function-reference.js +103 -103
  43. package/dist/operations/function.d.ts +14 -14
  44. package/dist/operations/function.js +200 -200
  45. package/dist/operations/if-statement.d.ts +19 -19
  46. package/dist/operations/if-statement.js +181 -181
  47. package/dist/operations/import.d.ts +17 -17
  48. package/dist/operations/import.js +119 -119
  49. package/dist/operations/include.d.ts +13 -13
  50. package/dist/operations/include.js +95 -95
  51. package/dist/operations/list.d.ts +11 -11
  52. package/dist/operations/list.js +111 -111
  53. package/dist/operations/literal.d.ts +11 -11
  54. package/dist/operations/literal.js +58 -58
  55. package/dist/operations/map.d.ts +11 -11
  56. package/dist/operations/map.js +171 -171
  57. package/dist/operations/negated-binary.d.ts +11 -11
  58. package/dist/operations/negated-binary.js +109 -109
  59. package/dist/operations/new-instance.d.ts +11 -11
  60. package/dist/operations/new-instance.js +100 -100
  61. package/dist/operations/noop.d.ts +9 -9
  62. package/dist/operations/noop.js +36 -36
  63. package/dist/operations/not.d.ts +11 -11
  64. package/dist/operations/not.js +96 -96
  65. package/dist/operations/operation.d.ts +13 -13
  66. package/dist/operations/operation.js +11 -11
  67. package/dist/operations/reference.d.ts +9 -9
  68. package/dist/operations/reference.js +37 -37
  69. package/dist/operations/resolve.d.ts +38 -38
  70. package/dist/operations/resolve.js +330 -330
  71. package/dist/operations/return.d.ts +11 -11
  72. package/dist/operations/return.js +107 -107
  73. package/dist/operations/while.d.ts +13 -13
  74. package/dist/operations/while.js +136 -136
  75. package/dist/types/boolean.d.ts +11 -11
  76. package/dist/types/boolean.js +46 -46
  77. package/dist/types/default.d.ts +11 -11
  78. package/dist/types/default.js +20 -20
  79. package/dist/types/function.d.ts +32 -32
  80. package/dist/types/function.js +174 -174
  81. package/dist/types/generics.d.ts +18 -18
  82. package/dist/types/generics.js +40 -40
  83. package/dist/types/interface.d.ts +23 -23
  84. package/dist/types/interface.js +103 -103
  85. package/dist/types/list.d.ts +31 -31
  86. package/dist/types/list.js +209 -209
  87. package/dist/types/map.d.ts +37 -37
  88. package/dist/types/map.js +366 -366
  89. package/dist/types/nil.d.ts +10 -10
  90. package/dist/types/nil.js +46 -46
  91. package/dist/types/number.d.ts +11 -11
  92. package/dist/types/number.js +46 -46
  93. package/dist/types/string.d.ts +33 -33
  94. package/dist/types/string.js +145 -145
  95. package/dist/utils/deep-equal.d.ts +1 -1
  96. package/dist/utils/deep-equal.js +62 -62
  97. package/dist/utils/path.d.ts +10 -10
  98. package/dist/utils/path.js +59 -59
  99. package/package.json +58 -58
@@ -1,438 +1,438 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
- var _b, _c, _d, _e, _f, _g, _h, _j;
57
- Object.defineProperty(exports, "__esModule", { value: true });
58
- exports.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.StringProcessorHandler = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
59
- var greyscript_core_1 = require("greyscript-core");
60
- var boolean_1 = __importDefault(require("../types/boolean"));
61
- var default_1 = __importDefault(require("../types/default"));
62
- var function_1 = __importDefault(require("../types/function"));
63
- var interface_1 = __importDefault(require("../types/interface"));
64
- var list_1 = __importDefault(require("../types/list"));
65
- var map_1 = __importDefault(require("../types/map"));
66
- var nil_1 = __importDefault(require("../types/nil"));
67
- var number_1 = __importDefault(require("../types/number"));
68
- var string_1 = __importDefault(require("../types/string"));
69
- var deep_equal_1 = __importDefault(require("../utils/deep-equal"));
70
- var operation_1 = __importDefault(require("./operation"));
71
- exports.GenericProcessorHandler = (_b = {},
72
- _b[greyscript_core_1.Operator.And] = function (a, b) { return new boolean_1.default(a.toTruthy() && b.toTruthy()); },
73
- _b[greyscript_core_1.Operator.Or] = function (a, b) { return new boolean_1.default(a.toTruthy() || b.toTruthy()); },
74
- _b);
75
- exports.NumberProcessorHandler = (_c = {},
76
- _c[greyscript_core_1.Operator.Plus] = function (a, b) { return new number_1.default(a.toNumber() + b.toNumber()); },
77
- _c[greyscript_core_1.Operator.Minus] = function (a, b) { return new number_1.default(a.toNumber() - b.toNumber()); },
78
- _c[greyscript_core_1.Operator.Slash] = function (a, b) { return new number_1.default(a.toNumber() / b.toNumber()); },
79
- _c[greyscript_core_1.Operator.Asterik] = function (a, b) { return new number_1.default(a.toNumber() * b.toNumber()); },
80
- _c[greyscript_core_1.Operator.Xor] = function (a, b) { return new number_1.default(a.toInt() ^ b.toInt()); },
81
- _c[greyscript_core_1.Operator.BitwiseOr] = function (a, b) { return new number_1.default(a.toInt() | b.toInt()); },
82
- _c[greyscript_core_1.Operator.LessThan] = function (a, b) { return new boolean_1.default(a.toNumber() < b.toNumber()); },
83
- _c[greyscript_core_1.Operator.GreaterThan] = function (a, b) {
84
- return new boolean_1.default(a.toNumber() > b.toNumber());
85
- },
86
- _c[greyscript_core_1.Operator.LeftShift] = function (a, b) { return new number_1.default(a.toInt() << b.toInt()); },
87
- _c[greyscript_core_1.Operator.RightShift] = function (a, b) { return new number_1.default(a.toInt() >> b.toInt()); },
88
- _c[greyscript_core_1.Operator.UnsignedRightShift] = function (a, b) {
89
- return new number_1.default(a.toInt() >> b.toInt());
90
- },
91
- _c[greyscript_core_1.Operator.BitwiseAnd] = function (a, b) { return new number_1.default(a.toInt() & b.toInt()); },
92
- _c[greyscript_core_1.Operator.PercentSign] = function (a, b) {
93
- return new number_1.default(a.toNumber() % b.toNumber());
94
- },
95
- _c[greyscript_core_1.Operator.GreaterThanOrEqual] = function (a, b) {
96
- return new boolean_1.default(a.toNumber() >= b.toNumber());
97
- },
98
- _c[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a.toNumber() === b.toNumber()); },
99
- _c[greyscript_core_1.Operator.LessThanOrEqual] = function (a, b) {
100
- return new boolean_1.default(a.toNumber() <= b.toNumber());
101
- },
102
- _c[greyscript_core_1.Operator.NotEqual] = function (a, b) {
103
- return new boolean_1.default(a.toNumber() !== b.toNumber());
104
- },
105
- _c);
106
- var multiplyString = function (a, b) {
107
- var multiStr = new Array(b.toNumber()).fill(a.toString()).join('');
108
- return new string_1.default(multiStr);
109
- };
110
- exports.multiplyString = multiplyString;
111
- exports.StringProcessorHandler = (_d = {},
112
- _d[greyscript_core_1.Operator.Plus] = function (a, b) { return new string_1.default(a.toString() + b.toString()); },
113
- _d[greyscript_core_1.Operator.Asterik] = function (a, b) { return (0, exports.multiplyString)(a, b); },
114
- _d[greyscript_core_1.Operator.LessThan] = function (a, b) {
115
- return new boolean_1.default(a.toString().length < b.toString().length);
116
- },
117
- _d[greyscript_core_1.Operator.GreaterThan] = function (a, b) {
118
- return new boolean_1.default(a.toString().length > b.toString().length);
119
- },
120
- _d[greyscript_core_1.Operator.GreaterThanOrEqual] = function (a, b) {
121
- return new boolean_1.default(a.toString().length >= b.toString().length);
122
- },
123
- _d[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a.toString() === b.toString()); },
124
- _d[greyscript_core_1.Operator.LessThanOrEqual] = function (a, b) {
125
- return new boolean_1.default(a.toString().length <= b.toString().length);
126
- },
127
- _d[greyscript_core_1.Operator.NotEqual] = function (a, b) {
128
- return new boolean_1.default(a.toString() !== b.toString());
129
- },
130
- _d);
131
- exports.ListProcessorHandler = (_e = {},
132
- _e[greyscript_core_1.Operator.Plus] = function (left, right) {
133
- if (right instanceof list_1.default) {
134
- return left.fork().extend(right);
135
- }
136
- return left;
137
- },
138
- _e[greyscript_core_1.Operator.LessThan] = function (left, right) {
139
- if (right instanceof list_1.default) {
140
- return new boolean_1.default(left.value.length < right.value.length);
141
- }
142
- return default_1.default.Void;
143
- },
144
- _e[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
145
- if (right instanceof list_1.default) {
146
- return new boolean_1.default(left.value.length > right.value.length);
147
- }
148
- return default_1.default.Void;
149
- },
150
- _e[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
151
- if (right instanceof list_1.default) {
152
- return new boolean_1.default(left.value.length >= right.value.length);
153
- }
154
- return default_1.default.Void;
155
- },
156
- _e[greyscript_core_1.Operator.Equal] = function (left, right) {
157
- if (right instanceof list_1.default) {
158
- return new boolean_1.default((0, deep_equal_1.default)(left, right));
159
- }
160
- return default_1.default.Void;
161
- },
162
- _e[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
163
- if (right instanceof list_1.default) {
164
- return new boolean_1.default(left.value.length <= right.value.length);
165
- }
166
- return default_1.default.Void;
167
- },
168
- _e[greyscript_core_1.Operator.NotEqual] = function (left, right) {
169
- if (right instanceof list_1.default) {
170
- return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
171
- }
172
- return default_1.default.Void;
173
- },
174
- _e);
175
- exports.MapProcessorHandler = (_f = {},
176
- _f[greyscript_core_1.Operator.Plus] = function (left, right) {
177
- if (right instanceof map_1.default) {
178
- return left.fork().extend(right);
179
- }
180
- return left;
181
- },
182
- _f[greyscript_core_1.Operator.LessThan] = function (left, right) {
183
- if (right instanceof map_1.default) {
184
- return new boolean_1.default(left.value.size < right.value.size);
185
- }
186
- return default_1.default.Void;
187
- },
188
- _f[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
189
- if (right instanceof map_1.default) {
190
- return new boolean_1.default(left.value.size > right.value.size);
191
- }
192
- return default_1.default.Void;
193
- },
194
- _f[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
195
- if (right instanceof map_1.default) {
196
- return new boolean_1.default(left.value.size >= right.value.size);
197
- }
198
- return default_1.default.Void;
199
- },
200
- _f[greyscript_core_1.Operator.Equal] = function (left, right) {
201
- if (right instanceof map_1.default) {
202
- return new boolean_1.default((0, deep_equal_1.default)(left, right));
203
- }
204
- return default_1.default.Void;
205
- },
206
- _f[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
207
- if (right instanceof map_1.default) {
208
- return new boolean_1.default(left.value.size <= right.value.size);
209
- }
210
- return default_1.default.Void;
211
- },
212
- _f[greyscript_core_1.Operator.NotEqual] = function (left, right) {
213
- if (right instanceof map_1.default) {
214
- return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
215
- }
216
- return default_1.default.Void;
217
- },
218
- _f);
219
- exports.InterfaceProcessorHandler = (_g = {},
220
- _g[greyscript_core_1.Operator.Equal] = function (left, right) {
221
- return new boolean_1.default(left.value === right.value);
222
- },
223
- _g[greyscript_core_1.Operator.NotEqual] = function (left, right) {
224
- return new boolean_1.default(left.value !== right.value);
225
- },
226
- _g);
227
- exports.NilProcessorHandler = (_h = {},
228
- _h[greyscript_core_1.Operator.Equal] = function (_a, b) { return new boolean_1.default(b instanceof nil_1.default); },
229
- _h[greyscript_core_1.Operator.NotEqual] = function (_a, b) { return new boolean_1.default(!(b instanceof nil_1.default)); },
230
- _h);
231
- exports.FunctionProcessorHandler = (_j = {},
232
- _j[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a === b); },
233
- _j[greyscript_core_1.Operator.NotEqual] = function (a, b) { return new boolean_1.default(a !== b); },
234
- _j);
235
- var handleNumber = function (op, a, b) {
236
- if (op in exports.NumberProcessorHandler) {
237
- return exports.NumberProcessorHandler[op](a, b);
238
- }
239
- else if (op in exports.GenericProcessorHandler) {
240
- return exports.GenericProcessorHandler[op](a, b);
241
- }
242
- return default_1.default.Void;
243
- };
244
- exports.handleNumber = handleNumber;
245
- var handleString = function (op, a, b) {
246
- if (op in exports.StringProcessorHandler) {
247
- return exports.StringProcessorHandler[op](a, b);
248
- }
249
- else if (op in exports.GenericProcessorHandler) {
250
- return exports.GenericProcessorHandler[op](a, b);
251
- }
252
- return default_1.default.Void;
253
- };
254
- exports.handleString = handleString;
255
- var handleList = function (op, a, b) {
256
- var left = a;
257
- var right = b;
258
- if (op in exports.ListProcessorHandler) {
259
- return exports.ListProcessorHandler[op](left, right);
260
- }
261
- else if (op in exports.GenericProcessorHandler) {
262
- return exports.GenericProcessorHandler[op](a, b);
263
- }
264
- return default_1.default.Void;
265
- };
266
- exports.handleList = handleList;
267
- var handleMap = function (op, a, b) {
268
- var left = a;
269
- var right = b;
270
- if (op in exports.MapProcessorHandler) {
271
- return exports.MapProcessorHandler[op](left, right);
272
- }
273
- else if (op in exports.GenericProcessorHandler) {
274
- return exports.GenericProcessorHandler[op](a, b);
275
- }
276
- return default_1.default.Void;
277
- };
278
- exports.handleMap = handleMap;
279
- var handleInterface = function (op, a, b) {
280
- var left = a;
281
- var right = b;
282
- if (op in exports.InterfaceProcessorHandler) {
283
- return exports.InterfaceProcessorHandler[op](left, right);
284
- }
285
- else if (op in exports.GenericProcessorHandler) {
286
- return exports.GenericProcessorHandler[op](a, b);
287
- }
288
- return default_1.default.Void;
289
- };
290
- exports.handleInterface = handleInterface;
291
- var handleNil = function (op, a, b) {
292
- if (op in exports.NilProcessorHandler) {
293
- return exports.NilProcessorHandler[op](a, b);
294
- }
295
- else if (op in exports.GenericProcessorHandler) {
296
- return exports.GenericProcessorHandler[op](a, b);
297
- }
298
- return default_1.default.Void;
299
- };
300
- exports.handleNil = handleNil;
301
- var handleFunction = function (op, a, b) {
302
- if (op in exports.FunctionProcessorHandler) {
303
- return exports.FunctionProcessorHandler[op](a, b);
304
- }
305
- else if (op in exports.GenericProcessorHandler) {
306
- return exports.GenericProcessorHandler[op](a, b);
307
- }
308
- return default_1.default.Void;
309
- };
310
- exports.handleFunction = handleFunction;
311
- var handle = function (op, a, b) {
312
- if (a instanceof boolean_1.default) {
313
- a = new number_1.default(a.toInt());
314
- }
315
- if (b instanceof boolean_1.default) {
316
- b = new number_1.default(b.toInt());
317
- }
318
- if (op === greyscript_core_1.Operator.Equal && a.getCustomType() !== b.getCustomType()) {
319
- return default_1.default.False;
320
- }
321
- else if (op === greyscript_core_1.Operator.NotEqual && a.getCustomType() !== b.getCustomType()) {
322
- return default_1.default.True;
323
- }
324
- if (a instanceof string_1.default || b instanceof string_1.default) {
325
- return (0, exports.handleString)(op, a, b);
326
- }
327
- else if (a instanceof number_1.default || b instanceof number_1.default) {
328
- return (0, exports.handleNumber)(op, a, b);
329
- }
330
- else if (a instanceof list_1.default) {
331
- return (0, exports.handleList)(op, a, b);
332
- }
333
- else if (a instanceof map_1.default) {
334
- return (0, exports.handleMap)(op, a, b);
335
- }
336
- else if (a instanceof interface_1.default) {
337
- return (0, exports.handleInterface)(op, a, b);
338
- }
339
- else if (a instanceof function_1.default) {
340
- return (0, exports.handleFunction)(op, a, b);
341
- }
342
- else if (a instanceof nil_1.default) {
343
- return (0, exports.handleNil)(op, a, b);
344
- }
345
- return default_1.default.Void;
346
- };
347
- exports.handle = handle;
348
- var Evaluate = /** @class */ (function (_super) {
349
- __extends(Evaluate, _super);
350
- function Evaluate(item, target) {
351
- var _this = _super.call(this, null, target) || this;
352
- _this.item = item;
353
- return _this;
354
- }
355
- Evaluate.prototype.build = function (visit) {
356
- return __awaiter(this, void 0, void 0, function () {
357
- var _b, _c;
358
- return __generator(this, function (_d) {
359
- switch (_d.label) {
360
- case 0:
361
- this.type = this.item.type;
362
- this.op = this.item.operator;
363
- _b = this;
364
- return [4 /*yield*/, visit(this.item.left)];
365
- case 1:
366
- _b.left = _d.sent();
367
- _c = this;
368
- return [4 /*yield*/, visit(this.item.right)];
369
- case 2:
370
- _c.right = _d.sent();
371
- return [2 /*return*/, this];
372
- }
373
- });
374
- });
375
- };
376
- Evaluate.prototype.resolveBinaryExpression = function (ctx, expr) {
377
- return __awaiter(this, void 0, void 0, function () {
378
- var left, right;
379
- return __generator(this, function (_b) {
380
- switch (_b.label) {
381
- case 0: return [4 /*yield*/, this.resolve(ctx, expr.left)];
382
- case 1:
383
- left = _b.sent();
384
- return [4 /*yield*/, this.resolve(ctx, expr.right)];
385
- case 2:
386
- right = _b.sent();
387
- return [2 /*return*/, (0, exports.handle)(expr.op, left, right)];
388
- }
389
- });
390
- });
391
- };
392
- Evaluate.prototype.resolveLogicalExpression = function (ctx, expr) {
393
- return __awaiter(this, void 0, void 0, function () {
394
- var left, right;
395
- return __generator(this, function (_b) {
396
- switch (_b.label) {
397
- case 0: return [4 /*yield*/, this.resolve(ctx, expr.left)];
398
- case 1:
399
- left = _b.sent();
400
- if (expr.op === greyscript_core_1.Operator.And && !left.toTruthy()) {
401
- return [2 /*return*/, new boolean_1.default(false)];
402
- }
403
- else if (expr.op === greyscript_core_1.Operator.Or && left.toTruthy()) {
404
- return [2 /*return*/, new boolean_1.default(true)];
405
- }
406
- return [4 /*yield*/, this.resolve(ctx, expr.right)];
407
- case 2:
408
- right = _b.sent();
409
- return [2 /*return*/, (0, exports.handle)(expr.op, left, right)];
410
- }
411
- });
412
- });
413
- };
414
- Evaluate.prototype.resolve = function (ctx, op) {
415
- return __awaiter(this, void 0, void 0, function () {
416
- var expr;
417
- return __generator(this, function (_b) {
418
- if (op instanceof Evaluate) {
419
- expr = op;
420
- switch (expr.type) {
421
- case greyscript_core_1.ASTType.BinaryExpression:
422
- return [2 /*return*/, this.resolveBinaryExpression(ctx, expr)];
423
- case greyscript_core_1.ASTType.LogicalExpression:
424
- return [2 /*return*/, this.resolveLogicalExpression(ctx, expr)];
425
- default:
426
- break;
427
- }
428
- }
429
- return [2 /*return*/, op.handle(ctx)];
430
- });
431
- });
432
- };
433
- Evaluate.prototype.handle = function (ctx) {
434
- return this.resolve(ctx, this);
435
- };
436
- return Evaluate;
437
- }(operation_1.default));
438
- exports.default = Evaluate;
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __importDefault = (this && this.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ var _b, _c, _d, _e, _f, _g, _h, _j;
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.StringProcessorHandler = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
59
+ var greyscript_core_1 = require("greyscript-core");
60
+ var boolean_1 = __importDefault(require("../types/boolean"));
61
+ var default_1 = __importDefault(require("../types/default"));
62
+ var function_1 = __importDefault(require("../types/function"));
63
+ var interface_1 = __importDefault(require("../types/interface"));
64
+ var list_1 = __importDefault(require("../types/list"));
65
+ var map_1 = __importDefault(require("../types/map"));
66
+ var nil_1 = __importDefault(require("../types/nil"));
67
+ var number_1 = __importDefault(require("../types/number"));
68
+ var string_1 = __importDefault(require("../types/string"));
69
+ var deep_equal_1 = __importDefault(require("../utils/deep-equal"));
70
+ var operation_1 = __importDefault(require("./operation"));
71
+ exports.GenericProcessorHandler = (_b = {},
72
+ _b[greyscript_core_1.Operator.And] = function (a, b) { return new boolean_1.default(a.toTruthy() && b.toTruthy()); },
73
+ _b[greyscript_core_1.Operator.Or] = function (a, b) { return new boolean_1.default(a.toTruthy() || b.toTruthy()); },
74
+ _b);
75
+ exports.NumberProcessorHandler = (_c = {},
76
+ _c[greyscript_core_1.Operator.Plus] = function (a, b) { return new number_1.default(a.toNumber() + b.toNumber()); },
77
+ _c[greyscript_core_1.Operator.Minus] = function (a, b) { return new number_1.default(a.toNumber() - b.toNumber()); },
78
+ _c[greyscript_core_1.Operator.Slash] = function (a, b) { return new number_1.default(a.toNumber() / b.toNumber()); },
79
+ _c[greyscript_core_1.Operator.Asterik] = function (a, b) { return new number_1.default(a.toNumber() * b.toNumber()); },
80
+ _c[greyscript_core_1.Operator.Xor] = function (a, b) { return new number_1.default(a.toInt() ^ b.toInt()); },
81
+ _c[greyscript_core_1.Operator.BitwiseOr] = function (a, b) { return new number_1.default(a.toInt() | b.toInt()); },
82
+ _c[greyscript_core_1.Operator.LessThan] = function (a, b) { return new boolean_1.default(a.toNumber() < b.toNumber()); },
83
+ _c[greyscript_core_1.Operator.GreaterThan] = function (a, b) {
84
+ return new boolean_1.default(a.toNumber() > b.toNumber());
85
+ },
86
+ _c[greyscript_core_1.Operator.LeftShift] = function (a, b) { return new number_1.default(a.toInt() << b.toInt()); },
87
+ _c[greyscript_core_1.Operator.RightShift] = function (a, b) { return new number_1.default(a.toInt() >> b.toInt()); },
88
+ _c[greyscript_core_1.Operator.UnsignedRightShift] = function (a, b) {
89
+ return new number_1.default(a.toInt() >> b.toInt());
90
+ },
91
+ _c[greyscript_core_1.Operator.BitwiseAnd] = function (a, b) { return new number_1.default(a.toInt() & b.toInt()); },
92
+ _c[greyscript_core_1.Operator.PercentSign] = function (a, b) {
93
+ return new number_1.default(a.toNumber() % b.toNumber());
94
+ },
95
+ _c[greyscript_core_1.Operator.GreaterThanOrEqual] = function (a, b) {
96
+ return new boolean_1.default(a.toNumber() >= b.toNumber());
97
+ },
98
+ _c[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a.toNumber() === b.toNumber()); },
99
+ _c[greyscript_core_1.Operator.LessThanOrEqual] = function (a, b) {
100
+ return new boolean_1.default(a.toNumber() <= b.toNumber());
101
+ },
102
+ _c[greyscript_core_1.Operator.NotEqual] = function (a, b) {
103
+ return new boolean_1.default(a.toNumber() !== b.toNumber());
104
+ },
105
+ _c);
106
+ var multiplyString = function (a, b) {
107
+ var multiStr = new Array(b.toNumber()).fill(a.toString()).join('');
108
+ return new string_1.default(multiStr);
109
+ };
110
+ exports.multiplyString = multiplyString;
111
+ exports.StringProcessorHandler = (_d = {},
112
+ _d[greyscript_core_1.Operator.Plus] = function (a, b) { return new string_1.default(a.toString() + b.toString()); },
113
+ _d[greyscript_core_1.Operator.Asterik] = function (a, b) { return (0, exports.multiplyString)(a, b); },
114
+ _d[greyscript_core_1.Operator.LessThan] = function (a, b) {
115
+ return new boolean_1.default(a.toString().length < b.toString().length);
116
+ },
117
+ _d[greyscript_core_1.Operator.GreaterThan] = function (a, b) {
118
+ return new boolean_1.default(a.toString().length > b.toString().length);
119
+ },
120
+ _d[greyscript_core_1.Operator.GreaterThanOrEqual] = function (a, b) {
121
+ return new boolean_1.default(a.toString().length >= b.toString().length);
122
+ },
123
+ _d[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a.toString() === b.toString()); },
124
+ _d[greyscript_core_1.Operator.LessThanOrEqual] = function (a, b) {
125
+ return new boolean_1.default(a.toString().length <= b.toString().length);
126
+ },
127
+ _d[greyscript_core_1.Operator.NotEqual] = function (a, b) {
128
+ return new boolean_1.default(a.toString() !== b.toString());
129
+ },
130
+ _d);
131
+ exports.ListProcessorHandler = (_e = {},
132
+ _e[greyscript_core_1.Operator.Plus] = function (left, right) {
133
+ if (right instanceof list_1.default) {
134
+ return left.fork().extend(right);
135
+ }
136
+ return left;
137
+ },
138
+ _e[greyscript_core_1.Operator.LessThan] = function (left, right) {
139
+ if (right instanceof list_1.default) {
140
+ return new boolean_1.default(left.value.length < right.value.length);
141
+ }
142
+ return default_1.default.Void;
143
+ },
144
+ _e[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
145
+ if (right instanceof list_1.default) {
146
+ return new boolean_1.default(left.value.length > right.value.length);
147
+ }
148
+ return default_1.default.Void;
149
+ },
150
+ _e[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
151
+ if (right instanceof list_1.default) {
152
+ return new boolean_1.default(left.value.length >= right.value.length);
153
+ }
154
+ return default_1.default.Void;
155
+ },
156
+ _e[greyscript_core_1.Operator.Equal] = function (left, right) {
157
+ if (right instanceof list_1.default) {
158
+ return new boolean_1.default((0, deep_equal_1.default)(left, right));
159
+ }
160
+ return default_1.default.Void;
161
+ },
162
+ _e[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
163
+ if (right instanceof list_1.default) {
164
+ return new boolean_1.default(left.value.length <= right.value.length);
165
+ }
166
+ return default_1.default.Void;
167
+ },
168
+ _e[greyscript_core_1.Operator.NotEqual] = function (left, right) {
169
+ if (right instanceof list_1.default) {
170
+ return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
171
+ }
172
+ return default_1.default.Void;
173
+ },
174
+ _e);
175
+ exports.MapProcessorHandler = (_f = {},
176
+ _f[greyscript_core_1.Operator.Plus] = function (left, right) {
177
+ if (right instanceof map_1.default) {
178
+ return left.fork().extend(right);
179
+ }
180
+ return left;
181
+ },
182
+ _f[greyscript_core_1.Operator.LessThan] = function (left, right) {
183
+ if (right instanceof map_1.default) {
184
+ return new boolean_1.default(left.value.size < right.value.size);
185
+ }
186
+ return default_1.default.Void;
187
+ },
188
+ _f[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
189
+ if (right instanceof map_1.default) {
190
+ return new boolean_1.default(left.value.size > right.value.size);
191
+ }
192
+ return default_1.default.Void;
193
+ },
194
+ _f[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
195
+ if (right instanceof map_1.default) {
196
+ return new boolean_1.default(left.value.size >= right.value.size);
197
+ }
198
+ return default_1.default.Void;
199
+ },
200
+ _f[greyscript_core_1.Operator.Equal] = function (left, right) {
201
+ if (right instanceof map_1.default) {
202
+ return new boolean_1.default((0, deep_equal_1.default)(left, right));
203
+ }
204
+ return default_1.default.Void;
205
+ },
206
+ _f[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
207
+ if (right instanceof map_1.default) {
208
+ return new boolean_1.default(left.value.size <= right.value.size);
209
+ }
210
+ return default_1.default.Void;
211
+ },
212
+ _f[greyscript_core_1.Operator.NotEqual] = function (left, right) {
213
+ if (right instanceof map_1.default) {
214
+ return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
215
+ }
216
+ return default_1.default.Void;
217
+ },
218
+ _f);
219
+ exports.InterfaceProcessorHandler = (_g = {},
220
+ _g[greyscript_core_1.Operator.Equal] = function (left, right) {
221
+ return new boolean_1.default(left.value === right.value);
222
+ },
223
+ _g[greyscript_core_1.Operator.NotEqual] = function (left, right) {
224
+ return new boolean_1.default(left.value !== right.value);
225
+ },
226
+ _g);
227
+ exports.NilProcessorHandler = (_h = {},
228
+ _h[greyscript_core_1.Operator.Equal] = function (_a, b) { return new boolean_1.default(b instanceof nil_1.default); },
229
+ _h[greyscript_core_1.Operator.NotEqual] = function (_a, b) { return new boolean_1.default(!(b instanceof nil_1.default)); },
230
+ _h);
231
+ exports.FunctionProcessorHandler = (_j = {},
232
+ _j[greyscript_core_1.Operator.Equal] = function (a, b) { return new boolean_1.default(a === b); },
233
+ _j[greyscript_core_1.Operator.NotEqual] = function (a, b) { return new boolean_1.default(a !== b); },
234
+ _j);
235
+ var handleNumber = function (op, a, b) {
236
+ if (op in exports.NumberProcessorHandler) {
237
+ return exports.NumberProcessorHandler[op](a, b);
238
+ }
239
+ else if (op in exports.GenericProcessorHandler) {
240
+ return exports.GenericProcessorHandler[op](a, b);
241
+ }
242
+ return default_1.default.Void;
243
+ };
244
+ exports.handleNumber = handleNumber;
245
+ var handleString = function (op, a, b) {
246
+ if (op in exports.StringProcessorHandler) {
247
+ return exports.StringProcessorHandler[op](a, b);
248
+ }
249
+ else if (op in exports.GenericProcessorHandler) {
250
+ return exports.GenericProcessorHandler[op](a, b);
251
+ }
252
+ return default_1.default.Void;
253
+ };
254
+ exports.handleString = handleString;
255
+ var handleList = function (op, a, b) {
256
+ var left = a;
257
+ var right = b;
258
+ if (op in exports.ListProcessorHandler) {
259
+ return exports.ListProcessorHandler[op](left, right);
260
+ }
261
+ else if (op in exports.GenericProcessorHandler) {
262
+ return exports.GenericProcessorHandler[op](a, b);
263
+ }
264
+ return default_1.default.Void;
265
+ };
266
+ exports.handleList = handleList;
267
+ var handleMap = function (op, a, b) {
268
+ var left = a;
269
+ var right = b;
270
+ if (op in exports.MapProcessorHandler) {
271
+ return exports.MapProcessorHandler[op](left, right);
272
+ }
273
+ else if (op in exports.GenericProcessorHandler) {
274
+ return exports.GenericProcessorHandler[op](a, b);
275
+ }
276
+ return default_1.default.Void;
277
+ };
278
+ exports.handleMap = handleMap;
279
+ var handleInterface = function (op, a, b) {
280
+ var left = a;
281
+ var right = b;
282
+ if (op in exports.InterfaceProcessorHandler) {
283
+ return exports.InterfaceProcessorHandler[op](left, right);
284
+ }
285
+ else if (op in exports.GenericProcessorHandler) {
286
+ return exports.GenericProcessorHandler[op](a, b);
287
+ }
288
+ return default_1.default.Void;
289
+ };
290
+ exports.handleInterface = handleInterface;
291
+ var handleNil = function (op, a, b) {
292
+ if (op in exports.NilProcessorHandler) {
293
+ return exports.NilProcessorHandler[op](a, b);
294
+ }
295
+ else if (op in exports.GenericProcessorHandler) {
296
+ return exports.GenericProcessorHandler[op](a, b);
297
+ }
298
+ return default_1.default.Void;
299
+ };
300
+ exports.handleNil = handleNil;
301
+ var handleFunction = function (op, a, b) {
302
+ if (op in exports.FunctionProcessorHandler) {
303
+ return exports.FunctionProcessorHandler[op](a, b);
304
+ }
305
+ else if (op in exports.GenericProcessorHandler) {
306
+ return exports.GenericProcessorHandler[op](a, b);
307
+ }
308
+ return default_1.default.Void;
309
+ };
310
+ exports.handleFunction = handleFunction;
311
+ var handle = function (op, a, b) {
312
+ if (a instanceof boolean_1.default) {
313
+ a = new number_1.default(a.toInt());
314
+ }
315
+ if (b instanceof boolean_1.default) {
316
+ b = new number_1.default(b.toInt());
317
+ }
318
+ if (op === greyscript_core_1.Operator.Equal && a.getCustomType() !== b.getCustomType()) {
319
+ return default_1.default.False;
320
+ }
321
+ else if (op === greyscript_core_1.Operator.NotEqual && a.getCustomType() !== b.getCustomType()) {
322
+ return default_1.default.True;
323
+ }
324
+ if (a instanceof string_1.default || b instanceof string_1.default) {
325
+ return (0, exports.handleString)(op, a, b);
326
+ }
327
+ else if (a instanceof number_1.default || b instanceof number_1.default) {
328
+ return (0, exports.handleNumber)(op, a, b);
329
+ }
330
+ else if (a instanceof list_1.default) {
331
+ return (0, exports.handleList)(op, a, b);
332
+ }
333
+ else if (a instanceof map_1.default) {
334
+ return (0, exports.handleMap)(op, a, b);
335
+ }
336
+ else if (a instanceof interface_1.default) {
337
+ return (0, exports.handleInterface)(op, a, b);
338
+ }
339
+ else if (a instanceof function_1.default) {
340
+ return (0, exports.handleFunction)(op, a, b);
341
+ }
342
+ else if (a instanceof nil_1.default) {
343
+ return (0, exports.handleNil)(op, a, b);
344
+ }
345
+ return default_1.default.Void;
346
+ };
347
+ exports.handle = handle;
348
+ var Evaluate = /** @class */ (function (_super) {
349
+ __extends(Evaluate, _super);
350
+ function Evaluate(item, target) {
351
+ var _this = _super.call(this, null, target) || this;
352
+ _this.item = item;
353
+ return _this;
354
+ }
355
+ Evaluate.prototype.build = function (visit) {
356
+ return __awaiter(this, void 0, void 0, function () {
357
+ var _b, _c;
358
+ return __generator(this, function (_d) {
359
+ switch (_d.label) {
360
+ case 0:
361
+ this.type = this.item.type;
362
+ this.op = this.item.operator;
363
+ _b = this;
364
+ return [4 /*yield*/, visit(this.item.left)];
365
+ case 1:
366
+ _b.left = _d.sent();
367
+ _c = this;
368
+ return [4 /*yield*/, visit(this.item.right)];
369
+ case 2:
370
+ _c.right = _d.sent();
371
+ return [2 /*return*/, this];
372
+ }
373
+ });
374
+ });
375
+ };
376
+ Evaluate.prototype.resolveBinaryExpression = function (ctx, expr) {
377
+ return __awaiter(this, void 0, void 0, function () {
378
+ var left, right;
379
+ return __generator(this, function (_b) {
380
+ switch (_b.label) {
381
+ case 0: return [4 /*yield*/, this.resolve(ctx, expr.left)];
382
+ case 1:
383
+ left = _b.sent();
384
+ return [4 /*yield*/, this.resolve(ctx, expr.right)];
385
+ case 2:
386
+ right = _b.sent();
387
+ return [2 /*return*/, (0, exports.handle)(expr.op, left, right)];
388
+ }
389
+ });
390
+ });
391
+ };
392
+ Evaluate.prototype.resolveLogicalExpression = function (ctx, expr) {
393
+ return __awaiter(this, void 0, void 0, function () {
394
+ var left, right;
395
+ return __generator(this, function (_b) {
396
+ switch (_b.label) {
397
+ case 0: return [4 /*yield*/, this.resolve(ctx, expr.left)];
398
+ case 1:
399
+ left = _b.sent();
400
+ if (expr.op === greyscript_core_1.Operator.And && !left.toTruthy()) {
401
+ return [2 /*return*/, new boolean_1.default(false)];
402
+ }
403
+ else if (expr.op === greyscript_core_1.Operator.Or && left.toTruthy()) {
404
+ return [2 /*return*/, new boolean_1.default(true)];
405
+ }
406
+ return [4 /*yield*/, this.resolve(ctx, expr.right)];
407
+ case 2:
408
+ right = _b.sent();
409
+ return [2 /*return*/, (0, exports.handle)(expr.op, left, right)];
410
+ }
411
+ });
412
+ });
413
+ };
414
+ Evaluate.prototype.resolve = function (ctx, op) {
415
+ return __awaiter(this, void 0, void 0, function () {
416
+ var expr;
417
+ return __generator(this, function (_b) {
418
+ if (op instanceof Evaluate) {
419
+ expr = op;
420
+ switch (expr.type) {
421
+ case greyscript_core_1.ASTType.BinaryExpression:
422
+ return [2 /*return*/, this.resolveBinaryExpression(ctx, expr)];
423
+ case greyscript_core_1.ASTType.LogicalExpression:
424
+ return [2 /*return*/, this.resolveLogicalExpression(ctx, expr)];
425
+ default:
426
+ break;
427
+ }
428
+ }
429
+ return [2 /*return*/, op.handle(ctx)];
430
+ });
431
+ });
432
+ };
433
+ Evaluate.prototype.handle = function (ctx) {
434
+ return this.resolve(ctx, this);
435
+ };
436
+ return Evaluate;
437
+ }(operation_1.default));
438
+ exports.default = Evaluate;