greybel-interpreter 1.0.0 → 1.0.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.
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
@@ -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) {
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",