greybel-interpreter 1.4.4 → 1.4.6

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 (93) hide show
  1. package/dist/context.d.ts +3 -2
  2. package/dist/context.js +113 -190
  3. package/dist/cps.js +135 -188
  4. package/dist/handler/error.js +6 -29
  5. package/dist/handler/output.js +15 -38
  6. package/dist/handler/resource.js +16 -39
  7. package/dist/handler-container.js +6 -8
  8. package/dist/index.d.ts +4 -3
  9. package/dist/index.js +10 -9
  10. package/dist/interpreter.d.ts +5 -4
  11. package/dist/interpreter.js +109 -203
  12. package/dist/operations/assign.d.ts +1 -1
  13. package/dist/operations/assign.js +28 -93
  14. package/dist/operations/block.d.ts +1 -1
  15. package/dist/operations/block.js +33 -89
  16. package/dist/operations/break.d.ts +1 -1
  17. package/dist/operations/break.js +11 -29
  18. package/dist/operations/call.d.ts +1 -1
  19. package/dist/operations/call.js +31 -106
  20. package/dist/operations/chunk.d.ts +1 -1
  21. package/dist/operations/chunk.js +15 -67
  22. package/dist/operations/continue.d.ts +1 -1
  23. package/dist/operations/continue.js +11 -29
  24. package/dist/operations/debugger-statement.d.ts +1 -1
  25. package/dist/operations/debugger-statement.js +11 -29
  26. package/dist/operations/evaluate.d.ts +1 -1
  27. package/dist/operations/evaluate.js +143 -247
  28. package/dist/operations/for.d.ts +1 -1
  29. package/dist/operations/for.js +62 -133
  30. package/dist/operations/function-reference.d.ts +1 -1
  31. package/dist/operations/function-reference.js +25 -84
  32. package/dist/operations/function.d.ts +1 -1
  33. package/dist/operations/function.js +49 -177
  34. package/dist/operations/if-statement.d.ts +1 -1
  35. package/dist/operations/if-statement.js +58 -154
  36. package/dist/operations/import.d.ts +1 -1
  37. package/dist/operations/import.js +35 -97
  38. package/dist/operations/include.d.ts +1 -1
  39. package/dist/operations/include.js +19 -73
  40. package/dist/operations/list.d.ts +1 -1
  41. package/dist/operations/list.js +24 -93
  42. package/dist/operations/literal.d.ts +1 -1
  43. package/dist/operations/literal.js +15 -33
  44. package/dist/operations/map.d.ts +1 -1
  45. package/dist/operations/map.js +26 -153
  46. package/dist/operations/negated-binary.d.ts +1 -1
  47. package/dist/operations/negated-binary.js +24 -91
  48. package/dist/operations/new-instance.d.ts +1 -1
  49. package/dist/operations/new-instance.js +21 -82
  50. package/dist/operations/noop.d.ts +1 -1
  51. package/dist/operations/noop.js +10 -27
  52. package/dist/operations/not.d.ts +1 -1
  53. package/dist/operations/not.js +17 -78
  54. package/dist/operations/operation.d.ts +2 -2
  55. package/dist/operations/operation.js +3 -5
  56. package/dist/operations/reference.d.ts +1 -1
  57. package/dist/operations/reference.js +10 -28
  58. package/dist/operations/resolve.d.ts +1 -1
  59. package/dist/operations/resolve.js +161 -281
  60. package/dist/operations/return.d.ts +1 -1
  61. package/dist/operations/return.js +27 -89
  62. package/dist/operations/while.d.ts +1 -1
  63. package/dist/operations/while.js +45 -116
  64. package/dist/types/base.d.ts +9 -0
  65. package/dist/types/base.js +5 -0
  66. package/dist/types/boolean.d.ts +3 -1
  67. package/dist/types/boolean.js +24 -36
  68. package/dist/types/default.d.ts +6 -9
  69. package/dist/types/default.js +11 -17
  70. package/dist/types/function.d.ts +1 -1
  71. package/dist/types/function.js +60 -130
  72. package/dist/types/interface.d.ts +2 -1
  73. package/dist/types/interface.js +44 -64
  74. package/dist/types/list.d.ts +4 -6
  75. package/dist/types/list.js +77 -128
  76. package/dist/types/map.d.ts +11 -15
  77. package/dist/types/map.js +101 -267
  78. package/dist/types/nil.d.ts +2 -1
  79. package/dist/types/nil.js +23 -36
  80. package/dist/types/number.d.ts +16 -2
  81. package/dist/types/number.js +60 -37
  82. package/dist/types/string.d.ts +4 -6
  83. package/dist/types/string.js +66 -90
  84. package/dist/types/{generics.d.ts → with-intrinsics.d.ts} +6 -9
  85. package/dist/types/with-intrinsics.js +19 -0
  86. package/dist/utils/deep-equal.js +9 -34
  87. package/dist/utils/object-value.d.ts +7 -0
  88. package/dist/utils/object-value.js +42 -0
  89. package/dist/utils/path.js +16 -43
  90. package/package.json +3 -3
  91. package/dist/intrinsics-container.d.ts +0 -7
  92. package/dist/intrinsics-container.js +0 -19
  93. package/dist/types/generics.js +0 -40
@@ -1,19 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,216 +8,162 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
9
  });
25
10
  };
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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
54
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
13
  };
56
- var _b, _c, _d, _e, _f, _g, _h, _j;
57
14
  Object.defineProperty(exports, "__esModule", { value: true });
58
15
  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('');
16
+ const greyscript_core_1 = require("greyscript-core");
17
+ const boolean_1 = __importDefault(require("../types/boolean"));
18
+ const default_1 = __importDefault(require("../types/default"));
19
+ const function_1 = __importDefault(require("../types/function"));
20
+ const interface_1 = __importDefault(require("../types/interface"));
21
+ const list_1 = __importDefault(require("../types/list"));
22
+ const map_1 = __importDefault(require("../types/map"));
23
+ const nil_1 = __importDefault(require("../types/nil"));
24
+ const number_1 = __importDefault(require("../types/number"));
25
+ const string_1 = __importDefault(require("../types/string"));
26
+ const deep_equal_1 = __importDefault(require("../utils/deep-equal"));
27
+ const operation_1 = __importDefault(require("./operation"));
28
+ exports.GenericProcessorHandler = {
29
+ [greyscript_core_1.Operator.And]: (a, b) => new boolean_1.default(a.toTruthy() && b.toTruthy()),
30
+ [greyscript_core_1.Operator.Or]: (a, b) => new boolean_1.default(a.toTruthy() || b.toTruthy())
31
+ };
32
+ exports.NumberProcessorHandler = {
33
+ [greyscript_core_1.Operator.Plus]: (a, b) => new number_1.default(a.toNumber() + b.toNumber()),
34
+ [greyscript_core_1.Operator.Minus]: (a, b) => new number_1.default(a.toNumber() - b.toNumber()),
35
+ [greyscript_core_1.Operator.Slash]: (a, b) => new number_1.default(a.toNumber() / b.toNumber()),
36
+ [greyscript_core_1.Operator.Asterik]: (a, b) => new number_1.default(a.toNumber() * b.toNumber()),
37
+ [greyscript_core_1.Operator.Xor]: (a, b) => new number_1.default(a.toInt() ^ b.toInt()),
38
+ [greyscript_core_1.Operator.BitwiseOr]: (a, b) => new number_1.default(a.toInt() | b.toInt()),
39
+ [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.default(a.toNumber() < b.toNumber()),
40
+ [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.default(a.toNumber() > b.toNumber()),
41
+ [greyscript_core_1.Operator.LeftShift]: (a, b) => new number_1.default(a.toInt() << b.toInt()),
42
+ [greyscript_core_1.Operator.RightShift]: (a, b) => new number_1.default(a.toInt() >> b.toInt()),
43
+ [greyscript_core_1.Operator.UnsignedRightShift]: (a, b) => new number_1.default(a.toInt() >> b.toInt()),
44
+ [greyscript_core_1.Operator.BitwiseAnd]: (a, b) => new number_1.default(a.toInt() & b.toInt()),
45
+ [greyscript_core_1.Operator.PercentSign]: (a, b) => new number_1.default(a.toNumber() % b.toNumber()),
46
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.default(a.toNumber() >= b.toNumber()),
47
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a.toNumber() === b.toNumber()),
48
+ [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.default(a.toNumber() <= b.toNumber()),
49
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a.toNumber() !== b.toNumber())
50
+ };
51
+ const multiplyString = (a, b) => {
52
+ const multiStr = new Array(b.toNumber()).fill(a.toString()).join('');
108
53
  return new string_1.default(multiStr);
109
54
  };
110
55
  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) {
56
+ exports.StringProcessorHandler = {
57
+ [greyscript_core_1.Operator.Plus]: (a, b) => new string_1.default(a.toString() + b.toString()),
58
+ [greyscript_core_1.Operator.Asterik]: (a, b) => (0, exports.multiplyString)(a, b),
59
+ [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.default(a.toString().length < b.toString().length),
60
+ [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.default(a.toString().length > b.toString().length),
61
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.default(a.toString().length >= b.toString().length),
62
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a.toString() === b.toString()),
63
+ [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.default(a.toString().length <= b.toString().length),
64
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a.toString() !== b.toString())
65
+ };
66
+ exports.ListProcessorHandler = {
67
+ [greyscript_core_1.Operator.Plus]: (left, right) => {
133
68
  if (right instanceof list_1.default) {
134
69
  return left.fork().extend(right);
135
70
  }
136
71
  return left;
137
72
  },
138
- _e[greyscript_core_1.Operator.LessThan] = function (left, right) {
73
+ [greyscript_core_1.Operator.LessThan]: (left, right) => {
139
74
  if (right instanceof list_1.default) {
140
75
  return new boolean_1.default(left.value.length < right.value.length);
141
76
  }
142
77
  return default_1.default.Void;
143
78
  },
144
- _e[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
79
+ [greyscript_core_1.Operator.GreaterThan]: (left, right) => {
145
80
  if (right instanceof list_1.default) {
146
81
  return new boolean_1.default(left.value.length > right.value.length);
147
82
  }
148
83
  return default_1.default.Void;
149
84
  },
150
- _e[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
85
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (left, right) => {
151
86
  if (right instanceof list_1.default) {
152
87
  return new boolean_1.default(left.value.length >= right.value.length);
153
88
  }
154
89
  return default_1.default.Void;
155
90
  },
156
- _e[greyscript_core_1.Operator.Equal] = function (left, right) {
91
+ [greyscript_core_1.Operator.Equal]: (left, right) => {
157
92
  if (right instanceof list_1.default) {
158
93
  return new boolean_1.default((0, deep_equal_1.default)(left, right));
159
94
  }
160
95
  return default_1.default.Void;
161
96
  },
162
- _e[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
97
+ [greyscript_core_1.Operator.LessThanOrEqual]: (left, right) => {
163
98
  if (right instanceof list_1.default) {
164
99
  return new boolean_1.default(left.value.length <= right.value.length);
165
100
  }
166
101
  return default_1.default.Void;
167
102
  },
168
- _e[greyscript_core_1.Operator.NotEqual] = function (left, right) {
103
+ [greyscript_core_1.Operator.NotEqual]: (left, right) => {
169
104
  if (right instanceof list_1.default) {
170
105
  return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
171
106
  }
172
107
  return default_1.default.Void;
173
- },
174
- _e);
175
- exports.MapProcessorHandler = (_f = {},
176
- _f[greyscript_core_1.Operator.Plus] = function (left, right) {
108
+ }
109
+ };
110
+ exports.MapProcessorHandler = {
111
+ [greyscript_core_1.Operator.Plus]: (left, right) => {
177
112
  if (right instanceof map_1.default) {
178
113
  return left.fork().extend(right);
179
114
  }
180
115
  return left;
181
116
  },
182
- _f[greyscript_core_1.Operator.LessThan] = function (left, right) {
117
+ [greyscript_core_1.Operator.LessThan]: (left, right) => {
183
118
  if (right instanceof map_1.default) {
184
119
  return new boolean_1.default(left.value.size < right.value.size);
185
120
  }
186
121
  return default_1.default.Void;
187
122
  },
188
- _f[greyscript_core_1.Operator.GreaterThan] = function (left, right) {
123
+ [greyscript_core_1.Operator.GreaterThan]: (left, right) => {
189
124
  if (right instanceof map_1.default) {
190
125
  return new boolean_1.default(left.value.size > right.value.size);
191
126
  }
192
127
  return default_1.default.Void;
193
128
  },
194
- _f[greyscript_core_1.Operator.GreaterThanOrEqual] = function (left, right) {
129
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (left, right) => {
195
130
  if (right instanceof map_1.default) {
196
131
  return new boolean_1.default(left.value.size >= right.value.size);
197
132
  }
198
133
  return default_1.default.Void;
199
134
  },
200
- _f[greyscript_core_1.Operator.Equal] = function (left, right) {
135
+ [greyscript_core_1.Operator.Equal]: (left, right) => {
201
136
  if (right instanceof map_1.default) {
202
137
  return new boolean_1.default((0, deep_equal_1.default)(left, right));
203
138
  }
204
139
  return default_1.default.Void;
205
140
  },
206
- _f[greyscript_core_1.Operator.LessThanOrEqual] = function (left, right) {
141
+ [greyscript_core_1.Operator.LessThanOrEqual]: (left, right) => {
207
142
  if (right instanceof map_1.default) {
208
143
  return new boolean_1.default(left.value.size <= right.value.size);
209
144
  }
210
145
  return default_1.default.Void;
211
146
  },
212
- _f[greyscript_core_1.Operator.NotEqual] = function (left, right) {
147
+ [greyscript_core_1.Operator.NotEqual]: (left, right) => {
213
148
  if (right instanceof map_1.default) {
214
149
  return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
215
150
  }
216
151
  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) {
152
+ }
153
+ };
154
+ exports.InterfaceProcessorHandler = {
155
+ [greyscript_core_1.Operator.Equal]: (left, right) => new boolean_1.default(left.value === right.value),
156
+ [greyscript_core_1.Operator.NotEqual]: (left, right) => new boolean_1.default(left.value !== right.value)
157
+ };
158
+ exports.NilProcessorHandler = {
159
+ [greyscript_core_1.Operator.Equal]: (_a, b) => new boolean_1.default(b instanceof nil_1.default),
160
+ [greyscript_core_1.Operator.NotEqual]: (_a, b) => new boolean_1.default(!(b instanceof nil_1.default))
161
+ };
162
+ exports.FunctionProcessorHandler = {
163
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a === b),
164
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a !== b)
165
+ };
166
+ const handleNumber = (op, a, b) => {
236
167
  if (op in exports.NumberProcessorHandler) {
237
168
  return exports.NumberProcessorHandler[op](a, b);
238
169
  }
@@ -242,7 +173,7 @@ var handleNumber = function (op, a, b) {
242
173
  return default_1.default.Void;
243
174
  };
244
175
  exports.handleNumber = handleNumber;
245
- var handleString = function (op, a, b) {
176
+ const handleString = (op, a, b) => {
246
177
  if (op in exports.StringProcessorHandler) {
247
178
  return exports.StringProcessorHandler[op](a, b);
248
179
  }
@@ -252,9 +183,9 @@ var handleString = function (op, a, b) {
252
183
  return default_1.default.Void;
253
184
  };
254
185
  exports.handleString = handleString;
255
- var handleList = function (op, a, b) {
256
- var left = a;
257
- var right = b;
186
+ const handleList = (op, a, b) => {
187
+ const left = a;
188
+ const right = b;
258
189
  if (op in exports.ListProcessorHandler) {
259
190
  return exports.ListProcessorHandler[op](left, right);
260
191
  }
@@ -264,9 +195,9 @@ var handleList = function (op, a, b) {
264
195
  return default_1.default.Void;
265
196
  };
266
197
  exports.handleList = handleList;
267
- var handleMap = function (op, a, b) {
268
- var left = a;
269
- var right = b;
198
+ const handleMap = (op, a, b) => {
199
+ const left = a;
200
+ const right = b;
270
201
  if (op in exports.MapProcessorHandler) {
271
202
  return exports.MapProcessorHandler[op](left, right);
272
203
  }
@@ -276,9 +207,9 @@ var handleMap = function (op, a, b) {
276
207
  return default_1.default.Void;
277
208
  };
278
209
  exports.handleMap = handleMap;
279
- var handleInterface = function (op, a, b) {
280
- var left = a;
281
- var right = b;
210
+ const handleInterface = (op, a, b) => {
211
+ const left = a;
212
+ const right = b;
282
213
  if (op in exports.InterfaceProcessorHandler) {
283
214
  return exports.InterfaceProcessorHandler[op](left, right);
284
215
  }
@@ -288,7 +219,7 @@ var handleInterface = function (op, a, b) {
288
219
  return default_1.default.Void;
289
220
  };
290
221
  exports.handleInterface = handleInterface;
291
- var handleNil = function (op, a, b) {
222
+ const handleNil = (op, a, b) => {
292
223
  if (op in exports.NilProcessorHandler) {
293
224
  return exports.NilProcessorHandler[op](a, b);
294
225
  }
@@ -298,7 +229,7 @@ var handleNil = function (op, a, b) {
298
229
  return default_1.default.Void;
299
230
  };
300
231
  exports.handleNil = handleNil;
301
- var handleFunction = function (op, a, b) {
232
+ const handleFunction = (op, a, b) => {
302
233
  if (op in exports.FunctionProcessorHandler) {
303
234
  return exports.FunctionProcessorHandler[op](a, b);
304
235
  }
@@ -308,7 +239,7 @@ var handleFunction = function (op, a, b) {
308
239
  return default_1.default.Void;
309
240
  };
310
241
  exports.handleFunction = handleFunction;
311
- var handle = function (op, a, b) {
242
+ const handle = (op, a, b) => {
312
243
  if (a instanceof boolean_1.default) {
313
244
  a = new number_1.default(a.toInt());
314
245
  }
@@ -318,7 +249,8 @@ var handle = function (op, a, b) {
318
249
  if (op === greyscript_core_1.Operator.Equal && a.getCustomType() !== b.getCustomType()) {
319
250
  return default_1.default.False;
320
251
  }
321
- else if (op === greyscript_core_1.Operator.NotEqual && a.getCustomType() !== b.getCustomType()) {
252
+ else if (op === greyscript_core_1.Operator.NotEqual &&
253
+ a.getCustomType() !== b.getCustomType()) {
322
254
  return default_1.default.True;
323
255
  }
324
256
  if (a instanceof string_1.default || b instanceof string_1.default) {
@@ -345,94 +277,58 @@ var handle = function (op, a, b) {
345
277
  return default_1.default.Void;
346
278
  };
347
279
  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
- });
280
+ class Evaluate extends operation_1.default {
281
+ constructor(item, target) {
282
+ super(null, target);
283
+ this.item = item;
284
+ }
285
+ build(visit) {
286
+ return __awaiter(this, void 0, void 0, function* () {
287
+ this.type = this.item.type;
288
+ this.op = this.item.operator;
289
+ this.left = yield visit(this.item.left);
290
+ this.right = yield visit(this.item.right);
291
+ return this;
374
292
  });
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
- });
293
+ }
294
+ resolveBinaryExpression(ctx, expr) {
295
+ return __awaiter(this, void 0, void 0, function* () {
296
+ const left = yield this.resolve(ctx, expr.left);
297
+ const right = yield this.resolve(ctx, expr.right);
298
+ return (0, exports.handle)(expr.op, left, right);
390
299
  });
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
- });
300
+ }
301
+ resolveLogicalExpression(ctx, expr) {
302
+ return __awaiter(this, void 0, void 0, function* () {
303
+ const left = yield this.resolve(ctx, expr.left);
304
+ if (expr.op === greyscript_core_1.Operator.And && !left.toTruthy()) {
305
+ return new boolean_1.default(false);
306
+ }
307
+ else if (expr.op === greyscript_core_1.Operator.Or && left.toTruthy()) {
308
+ return new boolean_1.default(true);
309
+ }
310
+ const right = yield this.resolve(ctx, expr.right);
311
+ return (0, exports.handle)(expr.op, left, right);
412
312
  });
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
- }
313
+ }
314
+ resolve(ctx, op) {
315
+ return __awaiter(this, void 0, void 0, function* () {
316
+ if (op instanceof Evaluate) {
317
+ const expr = op;
318
+ switch (expr.type) {
319
+ case greyscript_core_1.ASTType.BinaryExpression:
320
+ return this.resolveBinaryExpression(ctx, expr);
321
+ case greyscript_core_1.ASTType.LogicalExpression:
322
+ return this.resolveLogicalExpression(ctx, expr);
323
+ default:
324
+ break;
428
325
  }
429
- return [2 /*return*/, op.handle(ctx)];
430
- });
326
+ }
327
+ return op.handle(ctx);
431
328
  });
432
- };
433
- Evaluate.prototype.handle = function (ctx) {
329
+ }
330
+ handle(ctx) {
434
331
  return this.resolve(ctx, this);
435
- };
436
- return Evaluate;
437
- }(operation_1.default));
332
+ }
333
+ }
438
334
  exports.default = Evaluate;
@@ -1,6 +1,6 @@
1
1
  import { ASTForGenericStatement, ASTIdentifier } from 'greyscript-core';
2
2
  import context from '../context';
3
- import { CustomValue } from '../types/generics';
3
+ import CustomValue from '../types/base';
4
4
  import Block from './block';
5
5
  import Operation, { CPSVisit } from './operation';
6
6
  export default class For extends Operation {