greybel-interpreter 4.3.1 → 4.4.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.
- package/dist/vm.js +13 -14
- package/package.json +1 -1
package/dist/vm.js
CHANGED
|
@@ -187,7 +187,7 @@ class VM {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
resume(done) {
|
|
190
|
-
var _a, _b, _c, _d, _e
|
|
190
|
+
var _a, _b, _c, _d, _e;
|
|
191
191
|
try {
|
|
192
192
|
while (true) {
|
|
193
193
|
if (!this.isPending()) {
|
|
@@ -231,7 +231,7 @@ class VM {
|
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
case instruction_1.OpCode.GET_SUPER: {
|
|
234
|
-
this.pushStack(
|
|
234
|
+
this.pushStack(frame.locals.get(string_1.Super, this.contextTypeIntrinsics));
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
237
|
case instruction_1.OpCode.IMPORT: {
|
|
@@ -245,7 +245,7 @@ class VM {
|
|
|
245
245
|
const key = this.popStack();
|
|
246
246
|
const base = this.popStack();
|
|
247
247
|
if (!(base instanceof with_intrinsics_1.CustomValueWithIntrinsics)) {
|
|
248
|
-
throw new error_1.RuntimeError(
|
|
248
|
+
throw new error_1.RuntimeError('Invalid left value in assignment!', this);
|
|
249
249
|
}
|
|
250
250
|
base.set(key, value);
|
|
251
251
|
break;
|
|
@@ -265,7 +265,7 @@ class VM {
|
|
|
265
265
|
const fn = this.popStack();
|
|
266
266
|
if (fn instanceof function_1.CustomFunction) {
|
|
267
267
|
if (callInstruction.length > fn.arguments.length) {
|
|
268
|
-
throw new
|
|
268
|
+
throw new error_1.RuntimeError('Too many arguments.', this);
|
|
269
269
|
}
|
|
270
270
|
const newFrame = this.getFrame().fork({
|
|
271
271
|
code: fn.value,
|
|
@@ -285,13 +285,14 @@ class VM {
|
|
|
285
285
|
}
|
|
286
286
|
const propertyName = this.popStack();
|
|
287
287
|
const context = this.popStack();
|
|
288
|
-
const
|
|
288
|
+
const ret = context.getWithOrigin(propertyName, this.contextTypeIntrinsics);
|
|
289
|
+
const fn = ret.value;
|
|
289
290
|
if (fn instanceof function_1.CustomFunction) {
|
|
290
291
|
const newFrame = this.getFrame().fork({
|
|
291
292
|
type: context_1.ContextType.Function,
|
|
292
293
|
code: fn.value,
|
|
293
294
|
self: context,
|
|
294
|
-
super:
|
|
295
|
+
super: ret.origin instanceof map_1.CustomMap ? ((_b = ret.origin.getIsa()) !== null && _b !== void 0 ? _b : default_1.DefaultType.Void) : null,
|
|
295
296
|
outer: fn.outer
|
|
296
297
|
});
|
|
297
298
|
(0, call_1.callWithContext)(newFrame, fn, args);
|
|
@@ -306,10 +307,7 @@ class VM {
|
|
|
306
307
|
args[i] = this.popStack();
|
|
307
308
|
}
|
|
308
309
|
const property = this.popStack();
|
|
309
|
-
const context = frame.
|
|
310
|
-
if (!(context instanceof with_intrinsics_1.CustomValueWithIntrinsics)) {
|
|
311
|
-
throw new error_1.RuntimeError(`Unknown path ${property.toString()}.`, this);
|
|
312
|
-
}
|
|
310
|
+
const context = frame.locals.get(string_1.Super, this.contextTypeIntrinsics);
|
|
313
311
|
const ret = context.getWithOrigin(property, this.contextTypeIntrinsics);
|
|
314
312
|
const fn = ret.value;
|
|
315
313
|
if (fn instanceof function_1.CustomFunction) {
|
|
@@ -317,7 +315,7 @@ class VM {
|
|
|
317
315
|
type: context_1.ContextType.Function,
|
|
318
316
|
code: fn.value,
|
|
319
317
|
self: frame.self,
|
|
320
|
-
super: ret.origin instanceof map_1.CustomMap ? ((
|
|
318
|
+
super: ret.origin instanceof map_1.CustomMap ? ((_c = ret.origin.getIsa()) !== null && _c !== void 0 ? _c : default_1.DefaultType.Void) : null,
|
|
321
319
|
outer: fn.outer
|
|
322
320
|
});
|
|
323
321
|
(0, call_1.callWithContext)(newFrame, fn, args);
|
|
@@ -443,7 +441,7 @@ class VM {
|
|
|
443
441
|
type: context_1.ContextType.Function,
|
|
444
442
|
code: ret.value.value,
|
|
445
443
|
self: context,
|
|
446
|
-
super: ret.origin instanceof map_1.CustomMap ? ((
|
|
444
|
+
super: ret.origin instanceof map_1.CustomMap ? ((_d = ret.origin.getIsa()) !== null && _d !== void 0 ? _d : default_1.DefaultType.Void) : null,
|
|
447
445
|
outer: ret.value.outer
|
|
448
446
|
});
|
|
449
447
|
(0, call_1.callWithContext)(newFrame, ret.value, []);
|
|
@@ -456,13 +454,14 @@ class VM {
|
|
|
456
454
|
case instruction_1.OpCode.GET_SUPER_PROPERTY: {
|
|
457
455
|
const getPropertyInstruction = instruction;
|
|
458
456
|
const property = this.popStack();
|
|
459
|
-
const
|
|
457
|
+
const context = frame.locals.get(string_1.Super, this.contextTypeIntrinsics);
|
|
458
|
+
const ret = context.getWithOrigin(property, this.contextTypeIntrinsics);
|
|
460
459
|
if (ret.value instanceof function_1.CustomFunction && getPropertyInstruction.invoke) {
|
|
461
460
|
const newFrame = this.getFrame().fork({
|
|
462
461
|
type: context_1.ContextType.Function,
|
|
463
462
|
code: ret.value.value,
|
|
464
463
|
self: frame.self,
|
|
465
|
-
super: ret.origin instanceof map_1.CustomMap ? ((
|
|
464
|
+
super: ret.origin instanceof map_1.CustomMap ? ((_e = ret.origin.getIsa()) !== null && _e !== void 0 ? _e : default_1.DefaultType.Void) : null,
|
|
466
465
|
outer: ret.value.outer
|
|
467
466
|
});
|
|
468
467
|
(0, call_1.callWithContext)(newFrame, ret.value, []);
|