greybel-interpreter 3.0.3 → 3.1.0

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.
Files changed (83) hide show
  1. package/dist/context/types.d.ts +8 -0
  2. package/dist/context/types.js +2 -0
  3. package/dist/context.d.ts +17 -5
  4. package/dist/context.js +47 -28
  5. package/dist/cps.js +6 -5
  6. package/dist/handler/output.d.ts +2 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +3 -3
  9. package/dist/interpreter.d.ts +8 -3
  10. package/dist/interpreter.js +43 -44
  11. package/dist/operations/assign-globals.d.ts +11 -0
  12. package/dist/operations/assign-globals.js +31 -0
  13. package/dist/operations/assign-locals.d.ts +11 -0
  14. package/dist/operations/assign-locals.js +31 -0
  15. package/dist/operations/assign-outer.d.ts +11 -0
  16. package/dist/operations/assign-outer.js +31 -0
  17. package/dist/operations/assign-self.d.ts +11 -0
  18. package/dist/operations/assign-self.js +41 -0
  19. package/dist/operations/assign.js +16 -3
  20. package/dist/operations/block.js +3 -1
  21. package/dist/operations/call.js +16 -8
  22. package/dist/operations/chunk.js +0 -2
  23. package/dist/operations/evaluate.js +1 -1
  24. package/dist/operations/for.js +5 -1
  25. package/dist/operations/function-reference.js +6 -3
  26. package/dist/operations/function.d.ts +1 -1
  27. package/dist/operations/function.js +10 -6
  28. package/dist/operations/if-statement.js +5 -0
  29. package/dist/operations/import.js +1 -1
  30. package/dist/operations/reference-globals.d.ts +7 -0
  31. package/dist/operations/reference-globals.js +13 -0
  32. package/dist/operations/reference-locals.d.ts +7 -0
  33. package/dist/operations/reference-locals.js +13 -0
  34. package/dist/operations/reference-outer.d.ts +7 -0
  35. package/dist/operations/reference-outer.js +13 -0
  36. package/dist/operations/reference-self.d.ts +7 -0
  37. package/dist/operations/reference-self.js +13 -0
  38. package/dist/operations/resolve-globals.d.ts +5 -0
  39. package/dist/operations/resolve-globals.js +24 -0
  40. package/dist/operations/resolve-locals.d.ts +5 -0
  41. package/dist/operations/resolve-locals.js +24 -0
  42. package/dist/operations/resolve-outer.d.ts +5 -0
  43. package/dist/operations/resolve-outer.js +24 -0
  44. package/dist/operations/resolve-self.d.ts +5 -0
  45. package/dist/operations/resolve-self.js +24 -0
  46. package/dist/operations/resolve.d.ts +1 -1
  47. package/dist/operations/resolve.js +30 -18
  48. package/dist/operations/while.js +5 -1
  49. package/dist/types/base.d.ts +3 -1
  50. package/dist/types/function.d.ts +12 -6
  51. package/dist/types/function.js +47 -33
  52. package/dist/types/list.d.ts +6 -3
  53. package/dist/types/list.js +26 -7
  54. package/dist/types/map.d.ts +6 -3
  55. package/dist/types/map.js +64 -8
  56. package/dist/types/nil.d.ts +1 -0
  57. package/dist/types/nil.js +3 -0
  58. package/dist/types/number.d.ts +6 -3
  59. package/dist/types/number.js +20 -8
  60. package/dist/types/string.d.ts +6 -3
  61. package/dist/types/string.js +20 -9
  62. package/dist/types/with-intrinsics.d.ts +9 -1
  63. package/dist/types/with-intrinsics.js +6 -0
  64. package/dist/utils/create-assign.d.ts +3 -0
  65. package/dist/utils/create-assign.js +25 -0
  66. package/dist/utils/create-resolve.d.ts +5 -0
  67. package/dist/utils/create-resolve.js +51 -0
  68. package/dist/utils/deep-equal.js +9 -4
  69. package/dist/utils/error.d.ts +1 -1
  70. package/dist/utils/error.js +2 -2
  71. package/dist/utils/get-super.d.ts +3 -0
  72. package/dist/utils/get-super.js +12 -0
  73. package/dist/utils/hash.d.ts +3 -0
  74. package/dist/utils/hash.js +41 -0
  75. package/dist/utils/lookup-path.d.ts +3 -0
  76. package/dist/utils/lookup-path.js +16 -0
  77. package/dist/utils/next-tick.d.ts +1 -0
  78. package/dist/utils/next-tick.js +10 -0
  79. package/dist/utils/object-value.d.ts +11 -1
  80. package/dist/utils/object-value.js +54 -27
  81. package/dist/utils/uuid.d.ts +1 -0
  82. package/dist/utils/uuid.js +36 -0
  83. package/package.json +5 -4
@@ -0,0 +1,11 @@
1
+ import { ASTAssignmentStatement } from 'miniscript-core';
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class AssignSelf extends Operation {
6
+ readonly item: ASTAssignmentStatement;
7
+ right: Operation;
8
+ constructor(item: ASTAssignmentStatement, target?: string);
9
+ build(visit: CPSVisit): Promise<Operation>;
10
+ handle(ctx: OperationContext): Promise<CustomValue>;
11
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AssignSelf = void 0;
13
+ const default_1 = require("../types/default");
14
+ const function_1 = require("./function");
15
+ const operation_1 = require("./operation");
16
+ class AssignSelf extends operation_1.Operation {
17
+ constructor(item, target) {
18
+ super(null, target);
19
+ this.item = item;
20
+ }
21
+ build(visit) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ this.right = yield visit(this.item.init);
24
+ return this;
25
+ });
26
+ }
27
+ handle(ctx) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ let rightValue;
30
+ if (this.right instanceof function_1.FunctionOperation) {
31
+ rightValue = yield this.right.handle(ctx, true);
32
+ }
33
+ else {
34
+ rightValue = yield this.right.handle(ctx);
35
+ }
36
+ ctx.functionState.context = rightValue;
37
+ return default_1.DefaultType.Void;
38
+ });
39
+ }
40
+ }
41
+ exports.AssignSelf = AssignSelf;
@@ -11,6 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Assign = void 0;
13
13
  const default_1 = require("../types/default");
14
+ const create_resolve_1 = require("../utils/create-resolve");
15
+ const function_1 = require("./function");
14
16
  const operation_1 = require("./operation");
15
17
  const resolve_1 = require("./resolve");
16
18
  class Assign extends operation_1.Operation {
@@ -20,7 +22,7 @@ class Assign extends operation_1.Operation {
20
22
  }
21
23
  build(visit) {
22
24
  return __awaiter(this, void 0, void 0, function* () {
23
- this.left = new resolve_1.Resolve(this.item.variable);
25
+ this.left = (0, create_resolve_1.createResolve)(this.item.variable, this.target);
24
26
  yield this.left.build(visit);
25
27
  this.right = yield visit(this.item.init);
26
28
  return this;
@@ -28,11 +30,22 @@ class Assign extends operation_1.Operation {
28
30
  }
29
31
  handle(ctx) {
30
32
  return __awaiter(this, void 0, void 0, function* () {
33
+ const exitObserver = ctx.processState.createExitObserver();
31
34
  const resolveResult = yield this.left.getResult(ctx);
32
- if (ctx.isExit()) {
35
+ exitObserver.close();
36
+ if (exitObserver.occured()) {
33
37
  return default_1.DefaultType.Void;
34
38
  }
35
- const rightValue = yield this.right.handle(ctx);
39
+ if (resolveResult.path.count() === 0) {
40
+ throw new Error('Resolve path cannot be empty.');
41
+ }
42
+ let rightValue;
43
+ if (this.right instanceof function_1.FunctionOperation) {
44
+ rightValue = yield this.right.handle(ctx, true);
45
+ }
46
+ else {
47
+ rightValue = yield this.right.handle(ctx);
48
+ }
36
49
  if (!(resolveResult.handle instanceof resolve_1.ResolveNil)) {
37
50
  const resultValueCtx = resolveResult.handle;
38
51
  resultValueCtx.set(resolveResult.path, rightValue);
@@ -32,13 +32,15 @@ class Block extends operation_1.Operation {
32
32
  else if (ctx.type === context_1.ContextType.Function) {
33
33
  isEOL = () => ctx.functionState.isReturn;
34
34
  }
35
+ const exitObserver = ctx.processState.createExitObserver();
35
36
  for (let index = 0; index < this.stack.length; index++) {
36
- if (isEOL() || ctx.isExit()) {
37
+ if (isEOL() || exitObserver.occured()) {
37
38
  break;
38
39
  }
39
40
  const op = this.stack[index];
40
41
  yield ctx.step(op);
41
42
  }
43
+ exitObserver.close();
42
44
  return default_1.DefaultType.Void;
43
45
  });
44
46
  }
@@ -12,9 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Call = void 0;
13
13
  const default_1 = require("../types/default");
14
14
  const function_1 = require("../types/function");
15
- const map_1 = require("../types/map");
15
+ const create_resolve_1 = require("../utils/create-resolve");
16
16
  const operation_1 = require("./operation");
17
- const resolve_1 = require("./resolve");
18
17
  class Call extends operation_1.Operation {
19
18
  constructor(item, target) {
20
19
  super(null, target);
@@ -22,7 +21,7 @@ class Call extends operation_1.Operation {
22
21
  }
23
22
  build(visit) {
24
23
  return __awaiter(this, void 0, void 0, function* () {
25
- this.fnRef = new resolve_1.Resolve(this.item.base);
24
+ this.fnRef = (0, create_resolve_1.createResolve)(this.item.base, this.target);
26
25
  yield this.fnRef.build(visit);
27
26
  const args = this.item.arguments.map((arg) => visit(arg));
28
27
  this.args = yield Promise.all(args);
@@ -31,21 +30,30 @@ class Call extends operation_1.Operation {
31
30
  }
32
31
  handle(ctx) {
33
32
  return __awaiter(this, void 0, void 0, function* () {
33
+ const exitObserver = ctx.processState.createExitObserver();
34
34
  const resolveResult = yield this.fnRef.getResult(ctx);
35
- if (ctx.isExit()) {
35
+ if (exitObserver.occured()) {
36
+ exitObserver.close();
36
37
  return default_1.DefaultType.Void;
37
38
  }
38
39
  const valueRef = yield this.fnRef.handle(ctx, resolveResult, false);
39
40
  const fnArgs = [];
40
41
  for (let index = 0; index < this.args.length; index++) {
42
+ if (exitObserver.occured()) {
43
+ exitObserver.close();
44
+ return default_1.DefaultType.Void;
45
+ }
41
46
  fnArgs.push(yield this.args[index].handle(ctx));
42
47
  }
48
+ if (exitObserver.occured()) {
49
+ exitObserver.close();
50
+ return default_1.DefaultType.Void;
51
+ }
52
+ exitObserver.close();
43
53
  if (valueRef instanceof function_1.CustomFunction) {
44
54
  const func = valueRef;
45
- if (this.fnRef.path.isSuper() &&
46
- ctx.functionState.context &&
47
- resolveResult.handle instanceof map_1.CustomMap) {
48
- return func.run(ctx.functionState.context, fnArgs, ctx, resolveResult.handle.getIsa());
55
+ if (this.fnRef.path.isSuper() && ctx.functionState.context) {
56
+ return func.run(ctx.functionState.context, fnArgs, ctx);
49
57
  }
50
58
  return func.run(resolveResult.handle, fnArgs, ctx);
51
59
  }
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Chunk = void 0;
13
- const string_1 = require("../types/string");
14
13
  const block_1 = require("./block");
15
14
  const operation_1 = require("./operation");
16
15
  class Chunk extends operation_1.OperationBlock {
@@ -26,7 +25,6 @@ class Chunk extends operation_1.OperationBlock {
26
25
  });
27
26
  }
28
27
  handle(ctx) {
29
- ctx.set(new string_1.CustomString('locals'), ctx.locals.scope);
30
28
  return this.block.handle(ctx);
31
29
  }
32
30
  }
@@ -330,7 +330,7 @@ class Evaluate extends operation_1.Operation {
330
330
  case miniscript_core_1.ASTType.IsaExpression: {
331
331
  const left = yield this.resolve(ctx, expr.left);
332
332
  const right = yield this.resolve(ctx, expr.right);
333
- return new boolean_1.CustomBoolean(left.instanceOf(right));
333
+ return new boolean_1.CustomBoolean(left.instanceOf(right, ctx.contextTypeIntrinsics));
334
334
  }
335
335
  case miniscript_core_1.ASTType.BinaryExpression:
336
336
  return this.resolveBinaryExpression(ctx, expr);
@@ -43,6 +43,7 @@ class For extends operation_1.OperationBlock {
43
43
  return Promise.resolve(default_1.DefaultType.Void);
44
44
  }
45
45
  const loopState = new context_1.LoopState();
46
+ const exitObserver = ctx.processState.createExitObserver();
46
47
  forCtx.loopState = loopState;
47
48
  return new Promise((resolve, reject) => {
48
49
  const iterator = iteratorValue[Symbol.iterator]();
@@ -52,6 +53,7 @@ class For extends operation_1.OperationBlock {
52
53
  const iteration = () => __awaiter(this, void 0, void 0, function* () {
53
54
  try {
54
55
  if (iteratorResult.done) {
56
+ exitObserver.close();
55
57
  resolve(default_1.DefaultType.Void);
56
58
  return;
57
59
  }
@@ -62,7 +64,8 @@ class For extends operation_1.OperationBlock {
62
64
  yield this.block.handle(forCtx);
63
65
  if (loopState.isBreak ||
64
66
  forCtx.functionState.isReturn ||
65
- ctx.isExit()) {
67
+ exitObserver.occured()) {
68
+ exitObserver.close();
66
69
  resolve(default_1.DefaultType.Void);
67
70
  return;
68
71
  }
@@ -72,6 +75,7 @@ class For extends operation_1.OperationBlock {
72
75
  (0, set_immediate_1.setImmediate)(iteration);
73
76
  }
74
77
  catch (err) {
78
+ exitObserver.close();
75
79
  reject(err);
76
80
  }
77
81
  });
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FunctionReference = void 0;
13
13
  const default_1 = require("../types/default");
14
+ const create_resolve_1 = require("../utils/create-resolve");
14
15
  const operation_1 = require("./operation");
15
16
  const resolve_1 = require("./resolve");
16
17
  class FunctionReference extends operation_1.Operation {
@@ -20,15 +21,17 @@ class FunctionReference extends operation_1.Operation {
20
21
  }
21
22
  build(visit) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
- this.ref = new resolve_1.Resolve(this.item.argument);
24
+ this.ref = (0, create_resolve_1.createResolve)(this.item.argument, this.target);
24
25
  yield this.ref.build(visit);
25
26
  return this;
26
27
  });
27
28
  }
28
29
  handle(ctx) {
29
30
  return __awaiter(this, void 0, void 0, function* () {
31
+ const exitObserver = ctx.processState.createExitObserver();
30
32
  const refResult = yield this.ref.getResult(ctx);
31
- if (ctx.isExit()) {
33
+ exitObserver.close();
34
+ if (exitObserver.occured()) {
32
35
  return default_1.DefaultType.Void;
33
36
  }
34
37
  if (!(refResult.handle instanceof resolve_1.ResolveNil)) {
@@ -36,7 +39,7 @@ class FunctionReference extends operation_1.Operation {
36
39
  return refResult.handle;
37
40
  }
38
41
  const customValueCtx = refResult.handle;
39
- return customValueCtx.get(refResult.path);
42
+ return customValueCtx.get(refResult.path, ctx.contextTypeIntrinsics);
40
43
  }
41
44
  return ctx.get(refResult.path);
42
45
  });
@@ -15,5 +15,5 @@ export declare class FunctionOperation extends Operation {
15
15
  args: FunctionOperationArgument[];
16
16
  constructor(item: ASTFunctionStatement, target?: string);
17
17
  build(visit: CPSVisit): Promise<Operation>;
18
- handle(ctx: OperationContext): Promise<CustomValue>;
18
+ handle(ctx: OperationContext, assignOuter?: boolean): Promise<CustomValue>;
19
19
  }
@@ -15,6 +15,7 @@ const context_1 = require("../context");
15
15
  const default_1 = require("../types/default");
16
16
  const function_1 = require("../types/function");
17
17
  const string_1 = require("../types/string");
18
+ const with_intrinsics_1 = require("../types/with-intrinsics");
18
19
  const block_1 = require("./block");
19
20
  const operation_1 = require("./operation");
20
21
  const reference_1 = require("./reference");
@@ -53,24 +54,27 @@ class FunctionOperation extends operation_1.Operation {
53
54
  return this;
54
55
  });
55
56
  }
56
- handle(ctx) {
57
- const func = new function_1.CustomFunction(ctx, 'anonymous', (fnCtx, self, args, next) => __awaiter(this, void 0, void 0, function* () {
57
+ handle(ctx, assignOuter = false) {
58
+ const func = new function_1.CustomFunction(ctx, 'anonymous', (fnCtx, self, args) => __awaiter(this, void 0, void 0, function* () {
58
59
  const functionState = new context_1.FunctionState();
59
- fnCtx.set(exports.SELF_PROPERTY, self);
60
60
  functionState.context = self;
61
+ if (self instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
62
+ fnCtx.set(exports.SELF_PROPERTY, self);
63
+ }
64
+ const next = func.getNextContext();
61
65
  if (next) {
62
66
  fnCtx.set(exports.SUPER_PROPERTY, next);
63
67
  functionState.super = next;
64
68
  }
65
- fnCtx.set(new string_1.CustomString('locals'), fnCtx.locals.scope);
66
- fnCtx.set(new string_1.CustomString('outer'), fnCtx.previous.locals.scope);
67
69
  for (const [key, value] of args) {
70
+ if (key === function_1.SELF_NAMESPACE)
71
+ continue;
68
72
  fnCtx.set(new string_1.CustomString(key), value);
69
73
  }
70
74
  fnCtx.functionState = functionState;
71
75
  yield this.block.handle(fnCtx);
72
76
  return functionState.value;
73
- }));
77
+ }), [], assignOuter);
74
78
  for (const item of this.args) {
75
79
  func.addArgument(item.name, item.op);
76
80
  }
@@ -67,14 +67,19 @@ class IfStatement extends operation_1.OperationBlock {
67
67
  }
68
68
  handle(ctx) {
69
69
  return __awaiter(this, void 0, void 0, function* () {
70
+ const exitObserver = ctx.processState.createExitObserver();
70
71
  for (let index = 0; index < this.clauses.length; index++) {
71
72
  const clause = this.clauses[index];
72
73
  const clauseResult = yield ctx.step(clause.condition);
74
+ if (exitObserver.occured()) {
75
+ break;
76
+ }
73
77
  if (clauseResult.toTruthy()) {
74
78
  yield clause.block.handle(ctx);
75
79
  break;
76
80
  }
77
81
  }
82
+ exitObserver.close();
78
83
  return default_1.DefaultType.Void;
79
84
  });
80
85
  }
@@ -45,7 +45,7 @@ class Import extends operation_1.Operation {
45
45
  importCtx.locals.scope.set(exports.MODULE_PROPERTY, new map_1.CustomMap());
46
46
  yield this.top.handle(importCtx);
47
47
  const item = importCtx.locals.scope.has(exports.EXPORTS_PATH)
48
- ? importCtx.scope.get(exports.EXPORTS_PATH)
48
+ ? importCtx.scope.get(exports.EXPORTS_PATH, ctx.contextTypeIntrinsics)
49
49
  : default_1.DefaultType.Void;
50
50
  const identifier = this.item.name;
51
51
  ctx.set(new string_1.CustomString(identifier.name), item);
@@ -0,0 +1,7 @@
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class ReferenceGlobals extends Operation {
5
+ build(_visit: CPSVisit): Promise<ReferenceGlobals>;
6
+ handle(ctx: OperationContext): Promise<CustomValue>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceGlobals = void 0;
4
+ const operation_1 = require("./operation");
5
+ class ReferenceGlobals extends operation_1.Operation {
6
+ build(_visit) {
7
+ return Promise.resolve(this);
8
+ }
9
+ handle(ctx) {
10
+ return Promise.resolve(ctx.globals.scope);
11
+ }
12
+ }
13
+ exports.ReferenceGlobals = ReferenceGlobals;
@@ -0,0 +1,7 @@
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class ReferenceLocals extends Operation {
5
+ build(_visit: CPSVisit): Promise<ReferenceLocals>;
6
+ handle(ctx: OperationContext): Promise<CustomValue>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceLocals = void 0;
4
+ const operation_1 = require("./operation");
5
+ class ReferenceLocals extends operation_1.Operation {
6
+ build(_visit) {
7
+ return Promise.resolve(this);
8
+ }
9
+ handle(ctx) {
10
+ return Promise.resolve(ctx.locals.scope);
11
+ }
12
+ }
13
+ exports.ReferenceLocals = ReferenceLocals;
@@ -0,0 +1,7 @@
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class ReferenceOuter extends Operation {
5
+ build(_visit: CPSVisit): Promise<ReferenceOuter>;
6
+ handle(ctx: OperationContext): Promise<CustomValue>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceOuter = void 0;
4
+ const operation_1 = require("./operation");
5
+ class ReferenceOuter extends operation_1.Operation {
6
+ build(_visit) {
7
+ return Promise.resolve(this);
8
+ }
9
+ handle(ctx) {
10
+ return Promise.resolve(ctx.outer.scope);
11
+ }
12
+ }
13
+ exports.ReferenceOuter = ReferenceOuter;
@@ -0,0 +1,7 @@
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class ReferenceSelf extends Operation {
5
+ build(_visit: CPSVisit): Promise<ReferenceSelf>;
6
+ handle(ctx: OperationContext): Promise<CustomValue>;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReferenceSelf = void 0;
4
+ const operation_1 = require("./operation");
5
+ class ReferenceSelf extends operation_1.Operation {
6
+ build(_visit) {
7
+ return Promise.resolve(this);
8
+ }
9
+ handle(ctx) {
10
+ return Promise.resolve(ctx.functionState.context);
11
+ }
12
+ }
13
+ exports.ReferenceSelf = ReferenceSelf;
@@ -0,0 +1,5 @@
1
+ import { OperationContext } from '../context';
2
+ import { Resolve, ResolveResult } from './resolve';
3
+ export declare class ResolveGlobals extends Resolve {
4
+ getResult(ctx: OperationContext): Promise<ResolveResult | null>;
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResolveGlobals = void 0;
13
+ const resolve_1 = require("./resolve");
14
+ class ResolveGlobals extends resolve_1.Resolve {
15
+ getResult(ctx) {
16
+ const _super = Object.create(null, {
17
+ getResult: { get: () => super.getResult }
18
+ });
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return _super.getResult.call(this, ctx, ctx.globals.scope);
21
+ });
22
+ }
23
+ }
24
+ exports.ResolveGlobals = ResolveGlobals;
@@ -0,0 +1,5 @@
1
+ import { OperationContext } from '../context';
2
+ import { Resolve, ResolveResult } from './resolve';
3
+ export declare class ResolveLocals extends Resolve {
4
+ getResult(ctx: OperationContext): Promise<ResolveResult | null>;
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResolveLocals = void 0;
13
+ const resolve_1 = require("./resolve");
14
+ class ResolveLocals extends resolve_1.Resolve {
15
+ getResult(ctx) {
16
+ const _super = Object.create(null, {
17
+ getResult: { get: () => super.getResult }
18
+ });
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return _super.getResult.call(this, ctx, ctx.locals.scope);
21
+ });
22
+ }
23
+ }
24
+ exports.ResolveLocals = ResolveLocals;
@@ -0,0 +1,5 @@
1
+ import { OperationContext } from '../context';
2
+ import { Resolve, ResolveResult } from './resolve';
3
+ export declare class ResolveOuter extends Resolve {
4
+ getResult(ctx: OperationContext): Promise<ResolveResult | null>;
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResolveOuter = void 0;
13
+ const resolve_1 = require("./resolve");
14
+ class ResolveOuter extends resolve_1.Resolve {
15
+ getResult(ctx) {
16
+ const _super = Object.create(null, {
17
+ getResult: { get: () => super.getResult }
18
+ });
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return _super.getResult.call(this, ctx, ctx.outer.scope);
21
+ });
22
+ }
23
+ }
24
+ exports.ResolveOuter = ResolveOuter;
@@ -0,0 +1,5 @@
1
+ import { OperationContext } from '../context';
2
+ import { Resolve, ResolveResult } from './resolve';
3
+ export declare class ResolveSelf extends Resolve {
4
+ getResult(ctx: OperationContext): Promise<ResolveResult | null>;
5
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ResolveSelf = void 0;
13
+ const resolve_1 = require("./resolve");
14
+ class ResolveSelf extends resolve_1.Resolve {
15
+ getResult(ctx) {
16
+ const _super = Object.create(null, {
17
+ getResult: { get: () => super.getResult }
18
+ });
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return _super.getResult.call(this, ctx, ctx.functionState.context);
21
+ });
22
+ }
23
+ }
24
+ exports.ResolveSelf = ResolveSelf;
@@ -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 | null>;
53
+ getResult(ctx: OperationContext, handle?: CustomValue): Promise<ResolveResult | null>;
54
54
  handle(ctx: OperationContext, result?: ResolveResult, autoCall?: boolean): Promise<CustomValue>;
55
55
  }