greybel-interpreter 0.5.0 → 0.5.1
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.
|
@@ -154,58 +154,62 @@ var LogicalAndBinaryExpression = /** @class */ (function (_super) {
|
|
|
154
154
|
});
|
|
155
155
|
};
|
|
156
156
|
LogicalAndBinaryExpression.prototype.get = function (operationContext) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
return value.get(operationContext);
|
|
164
|
-
};
|
|
165
|
-
var evaluate = function (node) { return __awaiter(_this, void 0, void 0, function () {
|
|
166
|
-
var left, right, _a, result;
|
|
167
|
-
return __generator(this, function (_b) {
|
|
168
|
-
switch (_b.label) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var me, evaluate, result;
|
|
159
|
+
var _this = this;
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
switch (_a.label) {
|
|
169
162
|
case 0:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
163
|
+
me = this;
|
|
164
|
+
evaluate = function (node) { return __awaiter(_this, void 0, void 0, function () {
|
|
165
|
+
var expr, _a, binaryResult, _b, _c, _d, logicalResult, _e, _f, _g;
|
|
166
|
+
return __generator(this, function (_h) {
|
|
167
|
+
switch (_h.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
if (!(0, typer_1.isCustomValue)(node)) return [3 /*break*/, 1];
|
|
170
|
+
return [2 /*return*/, node];
|
|
171
|
+
case 1:
|
|
172
|
+
if (!(node instanceof LogicalAndBinaryExpression)) return [3 /*break*/, 8];
|
|
173
|
+
expr = node.expr;
|
|
174
|
+
if (!exports.OPERATIONS[expr.operator]) {
|
|
175
|
+
operationContext.debugger.raise('Unexpected expression type', me, expr);
|
|
176
|
+
}
|
|
177
|
+
_a = expr.type;
|
|
178
|
+
switch (_a) {
|
|
179
|
+
case greyscript_core_1.ASTType.BinaryExpression: return [3 /*break*/, 2];
|
|
180
|
+
case greyscript_core_1.ASTType.LogicalExpression: return [3 /*break*/, 5];
|
|
181
|
+
}
|
|
182
|
+
return [3 /*break*/, 8];
|
|
183
|
+
case 2:
|
|
184
|
+
_c = (_b = exports.OPERATIONS)[expr.operator];
|
|
185
|
+
return [4 /*yield*/, evaluate(expr.left)];
|
|
186
|
+
case 3:
|
|
187
|
+
_d = [_h.sent()];
|
|
188
|
+
return [4 /*yield*/, evaluate(expr.right)];
|
|
189
|
+
case 4:
|
|
190
|
+
binaryResult = _c.apply(_b, _d.concat([_h.sent()]));
|
|
191
|
+
return [2 /*return*/, Number.isNaN(binaryResult) ? null : binaryResult];
|
|
192
|
+
case 5:
|
|
193
|
+
_f = (_e = exports.OPERATIONS)[expr.operator];
|
|
194
|
+
return [4 /*yield*/, evaluate(expr.left)];
|
|
195
|
+
case 6:
|
|
196
|
+
_g = [_h.sent()];
|
|
197
|
+
return [4 /*yield*/, evaluate(expr.right)];
|
|
198
|
+
case 7:
|
|
199
|
+
logicalResult = _f.apply(_e, _g.concat([_h.sent()]));
|
|
200
|
+
return [2 /*return*/, logicalResult];
|
|
201
|
+
case 8: return [2 /*return*/, node.get(operationContext)];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}); };
|
|
205
|
+
operationContext.debugger.debug('Line', me.ast.start.line, 'LogicalAndBinaryExpression', 'get', 'expr', me.expr);
|
|
206
|
+
return [4 /*yield*/, evaluate(me)];
|
|
207
|
+
case 1:
|
|
208
|
+
result = _a.sent();
|
|
209
|
+
return [2 /*return*/, (0, typer_1.cast)(result)];
|
|
204
210
|
}
|
|
205
211
|
});
|
|
206
|
-
});
|
|
207
|
-
operationContext.debugger.debug('Line', me.ast.start.line, 'LogicalAndBinaryExpression', 'get', 'expr', me.expr);
|
|
208
|
-
return evaluate(me.expr);
|
|
212
|
+
});
|
|
209
213
|
};
|
|
210
214
|
return LogicalAndBinaryExpression;
|
|
211
215
|
}(expression_1.Expression));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"typescript": "^4.5.4"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"greybel-core": "^0.2.
|
|
38
|
-
"greyscript-core": "^0.2.
|
|
37
|
+
"greybel-core": "^0.2.3",
|
|
38
|
+
"greyscript-core": "^0.2.4",
|
|
39
39
|
"uuid": "^8.3.2"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|