greybel-interpreter 1.0.0 → 1.0.3

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.d.ts CHANGED
@@ -95,8 +95,10 @@ export default class OperationContext {
95
95
  isExit(): boolean;
96
96
  isPending(): boolean;
97
97
  setPending(pending: boolean): OperationContext;
98
+ lookupAllOfType(validate: (type: ContextType) => boolean): OperationContext[];
98
99
  exit(): Promise<OperationContext>;
99
100
  lookupType(allowedTypes: Array<ContextType>): OperationContext;
101
+ lookupAllScopes(): OperationContext[];
100
102
  lookupApi(): OperationContext;
101
103
  lookupGlobals(): OperationContext;
102
104
  lookupLocals(): OperationContext;
package/dist/context.js CHANGED
@@ -143,7 +143,7 @@ var Debugger = /** @class */ (function () {
143
143
  resolve();
144
144
  }
145
145
  else {
146
- process.nextTick(check);
146
+ setTimeout(check, 10);
147
147
  }
148
148
  };
149
149
  check();
@@ -234,6 +234,21 @@ var OperationContext = /** @class */ (function () {
234
234
  this.processState.isPending = pending;
235
235
  return this;
236
236
  };
237
+ OperationContext.prototype.lookupAllOfType = function (validate) {
238
+ var me = this;
239
+ var result = [];
240
+ if (validate(me.type)) {
241
+ result.push(me);
242
+ }
243
+ var current = me.previous;
244
+ while (current) {
245
+ if (validate(current.type)) {
246
+ result.push(current);
247
+ }
248
+ current = current.previous;
249
+ }
250
+ return result;
251
+ };
237
252
  OperationContext.prototype.exit = function () {
238
253
  var _this = this;
239
254
  if (this.processState.isPending) {
@@ -245,7 +260,7 @@ var OperationContext = /** @class */ (function () {
245
260
  resolve(_this);
246
261
  }
247
262
  else {
248
- process.nextTick(check);
263
+ setTimeout(check, 10);
249
264
  }
250
265
  };
251
266
  check();
@@ -266,6 +281,11 @@ var OperationContext = /** @class */ (function () {
266
281
  }
267
282
  return null;
268
283
  };
284
+ OperationContext.prototype.lookupAllScopes = function () {
285
+ return this.lookupAllOfType(function (type) {
286
+ return [ContextType.Global, ContextType.Function].includes(type);
287
+ });
288
+ };
269
289
  OperationContext.prototype.lookupApi = function () {
270
290
  return this.lookupType(OperationContext.lookupApiType);
271
291
  };
@@ -56,6 +56,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
57
  var default_1 = __importDefault(require("../types/default"));
58
58
  var operation_1 = __importDefault(require("./operation"));
59
+ var reference_1 = __importDefault(require("./reference"));
59
60
  var Return = /** @class */ (function (_super) {
60
61
  __extends(Return, _super);
61
62
  function Return(item, target) {
@@ -69,11 +70,16 @@ var Return = /** @class */ (function (_super) {
69
70
  return __generator(this, function (_b) {
70
71
  switch (_b.label) {
71
72
  case 0:
73
+ if (!this.item.argument) return [3 /*break*/, 2];
72
74
  _a = this;
73
75
  return [4 /*yield*/, visit(this.item.argument)];
74
76
  case 1:
75
77
  _a.arg = _b.sent();
76
- return [2 /*return*/, this];
78
+ return [3 /*break*/, 3];
79
+ case 2:
80
+ this.arg = new reference_1.default(default_1.default.Void);
81
+ _b.label = 3;
82
+ case 3: return [2 /*return*/, this];
77
83
  }
78
84
  });
79
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",