greybel-interpreter 1.8.2 → 1.8.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.
package/dist/context.js CHANGED
@@ -155,6 +155,8 @@ class OperationContext {
155
155
  this.cps = options.cps || null;
156
156
  this.processState = options.processState || new ProcessState();
157
157
  this.environmentVariables = options.environmentVariables || new Map();
158
+ this.functionState = new FunctionState();
159
+ this.loopState = new LoopState();
158
160
  this.api = this.lookupApi();
159
161
  this.globals = this.lookupGlobals();
160
162
  this.locals = this.lookupLocals() || this;
@@ -60,7 +60,9 @@ class For extends operation_1.OperationBlock {
60
60
  forCtx.set(idxIdentifier, new number_1.CustomNumber(index++));
61
61
  forCtx.set(varIdentifier, current);
62
62
  yield this.block.handle(forCtx);
63
- if (loopState.isBreak || ctx.isExit()) {
63
+ if (loopState.isBreak ||
64
+ forCtx.functionState.isReturn ||
65
+ ctx.isExit()) {
64
66
  resolve(default_1.DefaultType.Void);
65
67
  return;
66
68
  }
@@ -45,7 +45,9 @@ class While extends operation_1.OperationBlock {
45
45
  }
46
46
  loopState.isContinue = false;
47
47
  yield this.block.handle(whileCtx);
48
- if (loopState.isBreak || ctx.isExit()) {
48
+ if (loopState.isBreak ||
49
+ whileCtx.functionState.isReturn ||
50
+ ctx.isExit()) {
49
51
  resolve(default_1.DefaultType.Void);
50
52
  return;
51
53
  }
@@ -13,7 +13,7 @@ class RuntimeError extends Error {
13
13
  return this.stackTrace
14
14
  .map((op) => {
15
15
  var _a, _b, _c, _d;
16
- return `${op.target} at ${(_b = (_a = op.item) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 0}:${(_d = (_c = op.item) === null || _c === void 0 ? void 0 : _c.start.character) !== null && _d !== void 0 ? _d : 0}`;
16
+ return `at ${op.target}:${(_b = (_a = op.item) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 0}:${(_d = (_c = op.item) === null || _c === void 0 ? void 0 : _c.start.character) !== null && _d !== void 0 ? _d : 0}`;
17
17
  })
18
18
  .join('\n');
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",