greybel-interpreter 2.2.17 → 2.2.19

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.
@@ -8,6 +8,7 @@ import { CustomValue } from './types/base';
8
8
  import { CustomString } from './types/string';
9
9
  import { ObjectValue } from './utils/object-value';
10
10
  export declare const PARAMS_PROPERTY: CustomString;
11
+ export declare const IS_GREYBEL_PROPERTY: CustomString;
11
12
  export interface InterpreterOptions {
12
13
  target?: string;
13
14
  api?: ObjectValue;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Interpreter = exports.PARAMS_PROPERTY = void 0;
12
+ exports.Interpreter = exports.IS_GREYBEL_PROPERTY = exports.PARAMS_PROPERTY = void 0;
13
13
  const events_1 = require("events");
14
14
  const greybel_core_1 = require("greybel-core");
15
15
  const context_1 = require("./context");
@@ -24,7 +24,9 @@ const number_1 = require("./types/number");
24
24
  const string_1 = require("./types/string");
25
25
  const error_1 = require("./utils/error");
26
26
  const object_value_1 = require("./utils/object-value");
27
+ const boolean_1 = require("./types/boolean");
27
28
  exports.PARAMS_PROPERTY = new string_1.CustomString('params');
29
+ exports.IS_GREYBEL_PROPERTY = new string_1.CustomString('IS_GREYBEL');
28
30
  class Interpreter extends events_1.EventEmitter {
29
31
  constructor(options) {
30
32
  var _a, _b, _c, _d, _e, _f;
@@ -158,6 +160,7 @@ class Interpreter extends events_1.EventEmitter {
158
160
  this.apiContext.set(new string_1.CustomString('funcRef'), funcRefIntrinsics);
159
161
  this.apiContext.extend(this.api);
160
162
  const newParams = new list_1.CustomList(this.params.map((item) => new string_1.CustomString(item)));
163
+ this.globalContext.scope.set(exports.IS_GREYBEL_PROPERTY, new boolean_1.CustomBoolean(true));
161
164
  this.globalContext.scope.set(exports.PARAMS_PROPERTY, newParams);
162
165
  this.globalContext.set(new string_1.CustomString('globals'), this.globalContext.scope);
163
166
  try {
@@ -29,6 +29,9 @@ class Assign extends operation_1.Operation {
29
29
  handle(ctx) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const resolveResult = yield this.left.getResult(ctx);
32
+ if (ctx.isExit()) {
33
+ return default_1.DefaultType.Void;
34
+ }
32
35
  const rightValue = yield this.right.handle(ctx);
33
36
  if (!(resolveResult.handle instanceof resolve_1.ResolveNil)) {
34
37
  const resultValueCtx = resolveResult.handle;
@@ -32,6 +32,9 @@ class Call extends operation_1.Operation {
32
32
  handle(ctx) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  const resolveResult = yield this.fnRef.getResult(ctx);
35
+ if (ctx.isExit()) {
36
+ return default_1.DefaultType.Void;
37
+ }
35
38
  const valueRef = yield this.fnRef.handle(ctx, resolveResult, false);
36
39
  const fnArgs = [];
37
40
  for (let index = 0; index < this.args.length; index++) {
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FunctionReference = void 0;
13
+ const default_1 = require("../types/default");
13
14
  const operation_1 = require("./operation");
14
15
  const resolve_1 = require("./resolve");
15
16
  class FunctionReference extends operation_1.Operation {
@@ -27,6 +28,9 @@ class FunctionReference extends operation_1.Operation {
27
28
  handle(ctx) {
28
29
  return __awaiter(this, void 0, void 0, function* () {
29
30
  const refResult = yield this.ref.getResult(ctx);
31
+ if (ctx.isExit()) {
32
+ return default_1.DefaultType.Void;
33
+ }
30
34
  if (!(refResult.handle instanceof resolve_1.ResolveNil)) {
31
35
  if (refResult.path.count() === 0) {
32
36
  return refResult.handle;
@@ -50,6 +50,6 @@ export declare class Resolve extends Operation {
50
50
  constructor(item: ASTBase, target?: string);
51
51
  buildProcessor(node: ASTBase, visit: CPSVisit): Promise<void>;
52
52
  build(visit: CPSVisit): Promise<Resolve>;
53
- getResult(ctx: OperationContext): Promise<ResolveResult>;
53
+ getResult(ctx: OperationContext): Promise<ResolveResult | null>;
54
54
  handle(ctx: OperationContext, result?: ResolveResult, autoCall?: boolean): Promise<CustomValue>;
55
55
  }
@@ -157,7 +157,7 @@ class Resolve extends operation_1.Operation {
157
157
  const lastIndex = maxIndex - 1;
158
158
  for (let index = 0; index < maxIndex; index++) {
159
159
  if (ctx.isExit()) {
160
- return null;
160
+ return new ResolveResult(null, default_1.DefaultType.Void);
161
161
  }
162
162
  const current = this.path.at(index);
163
163
  if (current instanceof OperationSegment) {
@@ -215,7 +215,7 @@ class Resolve extends operation_1.Operation {
215
215
  return __awaiter(this, void 0, void 0, function* () {
216
216
  if (result === null) {
217
217
  result = yield this.getResult(ctx);
218
- if (result === null && ctx.isExit()) {
218
+ if (ctx.isExit()) {
219
219
  return default_1.DefaultType.Void;
220
220
  }
221
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greybel-interpreter",
3
- "version": "2.2.17",
3
+ "version": "2.2.19",
4
4
  "description": "Interpreter",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",