greybel-interpreter 4.0.13 → 4.0.15

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.
@@ -375,7 +375,7 @@ class BytecodeGenerator {
375
375
  yield this.processSubNode(node.index);
376
376
  this.push({
377
377
  op: instruction_1.OpCode.GET_SUPER_PROPERTY,
378
- source: this.getSourceLocation(base),
378
+ source: this.getSourceLocation(node.index),
379
379
  invoke: isInvoke
380
380
  });
381
381
  }
@@ -898,7 +898,7 @@ class BytecodeGenerator {
898
898
  yield pushArgs();
899
899
  this.push({
900
900
  op: instruction_1.OpCode.CALL_SUPER_PROPERTY,
901
- source: this.getSourceLocation(node),
901
+ source: this.getSourceLocation(node.base),
902
902
  length: node.arguments.length
903
903
  });
904
904
  }
@@ -912,7 +912,7 @@ class BytecodeGenerator {
912
912
  yield pushArgs();
913
913
  this.push({
914
914
  op: instruction_1.OpCode.CALL_WITH_CONTEXT,
915
- source: this.getSourceLocation(node),
915
+ source: this.getSourceLocation(left.identifier),
916
916
  length: node.arguments.length
917
917
  });
918
918
  }
@@ -924,7 +924,7 @@ class BytecodeGenerator {
924
924
  yield pushArgs();
925
925
  this.push({
926
926
  op: instruction_1.OpCode.CALL_SUPER_PROPERTY,
927
- source: this.getSourceLocation(node),
927
+ source: this.getSourceLocation(left.index),
928
928
  length: node.arguments.length
929
929
  });
930
930
  }
@@ -934,7 +934,7 @@ class BytecodeGenerator {
934
934
  yield pushArgs();
935
935
  this.push({
936
936
  op: instruction_1.OpCode.CALL_WITH_CONTEXT,
937
- source: this.getSourceLocation(node),
937
+ source: this.getSourceLocation(left.index),
938
938
  length: node.arguments.length
939
939
  });
940
940
  }
@@ -944,7 +944,7 @@ class BytecodeGenerator {
944
944
  yield pushArgs();
945
945
  this.push({
946
946
  op: instruction_1.OpCode.CALL,
947
- source: this.getSourceLocation(node),
947
+ source: this.getSourceLocation(left),
948
948
  length: node.arguments.length
949
949
  });
950
950
  }
@@ -953,7 +953,7 @@ class BytecodeGenerator {
953
953
  yield pushArgs();
954
954
  this.push({
955
955
  op: instruction_1.OpCode.CALL,
956
- source: this.getSourceLocation(node),
956
+ source: this.getSourceLocation(left),
957
957
  length: node.arguments.length
958
958
  });
959
959
  }
package/dist/context.js CHANGED
@@ -137,7 +137,7 @@ class OperationContext {
137
137
  this.set(new string_1.CustomString('super'), this.super);
138
138
  }
139
139
  getCurrentInstruction() {
140
- return this.code[this.ip - 1];
140
+ return this.code[this.ip];
141
141
  }
142
142
  fork(options) {
143
143
  return new OperationContext({
@@ -1,6 +1,9 @@
1
1
  import { ASTRange } from 'miniscript-core';
2
2
  import { Instruction } from '../byte-compiler/instruction';
3
3
  interface RuntimeVM {
4
+ getFrame(): {
5
+ getCurrentInstruction: () => Instruction;
6
+ };
4
7
  getStacktrace?: () => Instruction[];
5
8
  target: string;
6
9
  }
@@ -5,7 +5,7 @@ class RuntimeError extends Error {
5
5
  constructor(message, vm, source) {
6
6
  var _a;
7
7
  super(message);
8
- this.target = vm === null || vm === void 0 ? void 0 : vm.target;
8
+ this.target = vm === null || vm === void 0 ? void 0 : vm.getFrame().getCurrentInstruction().source.path;
9
9
  this.stackTrace = (_a = vm === null || vm === void 0 ? void 0 : vm.getStacktrace()) !== null && _a !== void 0 ? _a : [];
10
10
  this.stack = this.createTrace();
11
11
  this.source = source;
@@ -305,7 +305,7 @@ function evalNotEqual(a, b) {
305
305
  else if (a instanceof nil_1.CustomNil) {
306
306
  return new boolean_1.CustomBoolean(!(b instanceof nil_1.CustomNil));
307
307
  }
308
- return default_1.DefaultType.False;
308
+ return default_1.DefaultType.True;
309
309
  }
310
310
  exports.evalNotEqual = evalNotEqual;
311
311
  function evalMod(a, b) {
package/dist/vm.js CHANGED
@@ -144,6 +144,7 @@ class VM {
144
144
  return this.stack[--this.sp];
145
145
  }
146
146
  createFrame(options) {
147
+ this.getFrame().ip--;
147
148
  const ctx = this.getFrame().fork({
148
149
  code: options.code,
149
150
  type: context_1.ContextType.Function,
@@ -155,7 +156,9 @@ class VM {
155
156
  return ctx;
156
157
  }
157
158
  popFrame() {
158
- return this.frames.pop();
159
+ const frame = this.frames.pop();
160
+ this.getFrame().ip++;
161
+ return frame;
159
162
  }
160
163
  exec() {
161
164
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -176,7 +179,7 @@ class VM {
176
179
  const instruction = frame.code[frame.ip++];
177
180
  switch (instruction.op) {
178
181
  case instruction_1.OpCode.NOOP: {
179
- continue;
182
+ break;
180
183
  }
181
184
  case instruction_1.OpCode.PUSH: {
182
185
  const pushInstruction = instruction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "4.0.13",
3
+ "version": "4.0.15",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",