greybel-interpreter 1.7.0 → 1.7.2

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 (95) hide show
  1. package/dist/context.d.ts +9 -9
  2. package/dist/context.js +19 -22
  3. package/dist/cps.d.ts +3 -3
  4. package/dist/cps.js +56 -59
  5. package/dist/handler/output.d.ts +6 -7
  6. package/dist/handler/output.js +6 -11
  7. package/dist/handler-container.d.ts +1 -1
  8. package/dist/handler-container.js +2 -1
  9. package/dist/index.d.ts +42 -42
  10. package/dist/index.js +43 -46
  11. package/dist/interpreter.d.ts +9 -9
  12. package/dist/interpreter.js +33 -59
  13. package/dist/operations/assign.d.ts +5 -5
  14. package/dist/operations/assign.js +9 -11
  15. package/dist/operations/block.d.ts +4 -4
  16. package/dist/operations/block.js +6 -8
  17. package/dist/operations/break.d.ts +4 -4
  18. package/dist/operations/break.js +6 -8
  19. package/dist/operations/call.d.ts +5 -5
  20. package/dist/operations/call.js +12 -14
  21. package/dist/operations/chunk.d.ts +6 -6
  22. package/dist/operations/chunk.js +8 -10
  23. package/dist/operations/continue.d.ts +4 -4
  24. package/dist/operations/continue.js +6 -8
  25. package/dist/operations/debugger-statement.d.ts +5 -5
  26. package/dist/operations/debugger-statement.js +6 -8
  27. package/dist/operations/envar.d.ts +5 -5
  28. package/dist/operations/envar.js +6 -8
  29. package/dist/operations/evaluate.d.ts +6 -5
  30. package/dist/operations/evaluate.js +109 -112
  31. package/dist/operations/for.d.ts +6 -6
  32. package/dist/operations/for.js +15 -17
  33. package/dist/operations/function-reference.d.ts +5 -5
  34. package/dist/operations/function-reference.js +8 -10
  35. package/dist/operations/function.d.ts +5 -5
  36. package/dist/operations/function.js +17 -20
  37. package/dist/operations/if-statement.d.ts +6 -6
  38. package/dist/operations/if-statement.js +12 -15
  39. package/dist/operations/import.d.ts +7 -7
  40. package/dist/operations/import.js +15 -18
  41. package/dist/operations/include.d.ts +5 -5
  42. package/dist/operations/include.js +4 -6
  43. package/dist/operations/list.d.ts +5 -5
  44. package/dist/operations/list.js +6 -8
  45. package/dist/operations/literal.d.ts +5 -5
  46. package/dist/operations/literal.js +12 -14
  47. package/dist/operations/map.d.ts +5 -5
  48. package/dist/operations/map.js +8 -10
  49. package/dist/operations/negated-binary.d.ts +5 -5
  50. package/dist/operations/negated-binary.js +7 -9
  51. package/dist/operations/new-instance.d.ts +5 -5
  52. package/dist/operations/new-instance.js +8 -10
  53. package/dist/operations/noop.d.ts +5 -5
  54. package/dist/operations/noop.js +6 -8
  55. package/dist/operations/not.d.ts +5 -5
  56. package/dist/operations/not.js +6 -8
  57. package/dist/operations/operation.d.ts +3 -3
  58. package/dist/operations/operation.js +2 -1
  59. package/dist/operations/reference.d.ts +4 -4
  60. package/dist/operations/reference.js +4 -6
  61. package/dist/operations/resolve.d.ts +6 -6
  62. package/dist/operations/resolve.js +27 -30
  63. package/dist/operations/return.d.ts +5 -5
  64. package/dist/operations/return.js +8 -10
  65. package/dist/operations/while.d.ts +6 -6
  66. package/dist/operations/while.js +9 -11
  67. package/dist/types/base.d.ts +1 -1
  68. package/dist/types/base.js +2 -1
  69. package/dist/types/boolean.d.ts +2 -2
  70. package/dist/types/boolean.js +4 -7
  71. package/dist/types/default.d.ts +7 -7
  72. package/dist/types/default.js +9 -8
  73. package/dist/types/function.d.ts +5 -5
  74. package/dist/types/function.js +27 -30
  75. package/dist/types/interface.d.ts +4 -4
  76. package/dist/types/interface.js +10 -13
  77. package/dist/types/list.d.ts +4 -4
  78. package/dist/types/list.js +21 -24
  79. package/dist/types/map.d.ts +5 -5
  80. package/dist/types/map.js +26 -29
  81. package/dist/types/nil.d.ts +2 -2
  82. package/dist/types/nil.js +4 -7
  83. package/dist/types/number.d.ts +4 -4
  84. package/dist/types/number.js +8 -11
  85. package/dist/types/string.d.ts +4 -4
  86. package/dist/types/string.js +19 -22
  87. package/dist/types/with-intrinsics.d.ts +4 -4
  88. package/dist/types/with-intrinsics.js +2 -5
  89. package/dist/utils/deep-equal.d.ts +1 -1
  90. package/dist/utils/deep-equal.js +4 -3
  91. package/dist/utils/object-value.d.ts +2 -2
  92. package/dist/utils/object-value.js +6 -8
  93. package/dist/utils/path.d.ts +1 -1
  94. package/dist/utils/path.js +2 -1
  95. package/package.json +2 -3
@@ -8,14 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NegatedBinary = void 0;
15
13
  const greyscript_core_1 = require("greyscript-core");
16
- const number_1 = __importDefault(require("../types/number"));
17
- const operation_1 = __importDefault(require("./operation"));
18
- class NegatedBinary extends operation_1.default {
14
+ const number_1 = require("../types/number");
15
+ const operation_1 = require("./operation");
16
+ class NegatedBinary extends operation_1.Operation {
19
17
  constructor(item, target) {
20
18
  super(null, target);
21
19
  this.item = item;
@@ -30,13 +28,13 @@ class NegatedBinary extends operation_1.default {
30
28
  return __awaiter(this, void 0, void 0, function* () {
31
29
  switch (this.item.operator) {
32
30
  case greyscript_core_1.Operator.Minus:
33
- return new number_1.default(-(yield this.arg.handle(ctx)).toNumber());
31
+ return new number_1.CustomNumber(-(yield this.arg.handle(ctx)).toNumber());
34
32
  case greyscript_core_1.Operator.Plus:
35
- return new number_1.default(+(yield this.arg.handle(ctx)).toNumber());
33
+ return new number_1.CustomNumber(+(yield this.arg.handle(ctx)).toNumber());
36
34
  default:
37
35
  throw new Error('Unexpected negation operator.');
38
36
  }
39
37
  });
40
38
  }
41
39
  }
42
- exports.default = NegatedBinary;
40
+ exports.NegatedBinary = NegatedBinary;
@@ -1,11 +1,11 @@
1
1
  import { ASTUnaryExpression } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class NewInstance extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class NewInstance extends Operation {
6
6
  readonly item: ASTUnaryExpression;
7
7
  arg: Operation;
8
8
  constructor(item: ASTUnaryExpression, target?: string);
9
9
  build(visit: CPSVisit): Promise<Operation>;
10
- handle(ctx: context): Promise<CustomValue>;
10
+ handle(ctx: OperationContext): Promise<CustomValue>;
11
11
  }
@@ -8,14 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const default_1 = __importDefault(require("../types/default"));
16
- const map_1 = __importDefault(require("../types/map"));
17
- const operation_1 = __importDefault(require("./operation"));
18
- class NewInstance extends operation_1.default {
12
+ exports.NewInstance = void 0;
13
+ const default_1 = require("../types/default");
14
+ const map_1 = require("../types/map");
15
+ const operation_1 = require("./operation");
16
+ class NewInstance extends operation_1.Operation {
19
17
  constructor(item, target) {
20
18
  super(null, target);
21
19
  this.item = item;
@@ -29,11 +27,11 @@ class NewInstance extends operation_1.default {
29
27
  handle(ctx) {
30
28
  return __awaiter(this, void 0, void 0, function* () {
31
29
  const resolvedArg = yield this.arg.handle(ctx);
32
- if (resolvedArg instanceof map_1.default) {
30
+ if (resolvedArg instanceof map_1.CustomMap) {
33
31
  return resolvedArg.createInstance();
34
32
  }
35
- return default_1.default.Void;
33
+ return default_1.DefaultType.Void;
36
34
  });
37
35
  }
38
36
  }
39
- exports.default = NewInstance;
37
+ exports.NewInstance = NewInstance;
@@ -1,7 +1,7 @@
1
- import context from '../context';
2
- import CustomValue from '../types/base';
3
- import Operation, { CPSVisit } from './operation';
4
- export default class Noop extends Operation {
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class Noop extends Operation {
5
5
  build(_visit: CPSVisit): Promise<Operation>;
6
- handle(_ctx: context): Promise<CustomValue>;
6
+ handle(_ctx: OperationContext): Promise<CustomValue>;
7
7
  }
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const default_1 = __importDefault(require("../types/default"));
7
- const operation_1 = __importDefault(require("./operation"));
8
- class Noop extends operation_1.default {
3
+ exports.Noop = void 0;
4
+ const default_1 = require("../types/default");
5
+ const operation_1 = require("./operation");
6
+ class Noop extends operation_1.Operation {
9
7
  build(_visit) {
10
8
  return Promise.resolve(this);
11
9
  }
12
10
  handle(_ctx) {
13
- return Promise.resolve(default_1.default.Void);
11
+ return Promise.resolve(default_1.DefaultType.Void);
14
12
  }
15
13
  }
16
- exports.default = Noop;
14
+ exports.Noop = Noop;
@@ -1,11 +1,11 @@
1
1
  import { ASTUnaryExpression } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class Not extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class Not extends Operation {
6
6
  readonly item: ASTUnaryExpression;
7
7
  arg: Operation;
8
8
  constructor(item: ASTUnaryExpression, target?: string);
9
9
  build(visit: CPSVisit): Promise<Operation>;
10
- handle(ctx: context): Promise<CustomValue>;
10
+ handle(ctx: OperationContext): Promise<CustomValue>;
11
11
  }
@@ -8,13 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const boolean_1 = __importDefault(require("../types/boolean"));
16
- const operation_1 = __importDefault(require("./operation"));
17
- class Not extends operation_1.default {
12
+ exports.Not = void 0;
13
+ const boolean_1 = require("../types/boolean");
14
+ const operation_1 = require("./operation");
15
+ class Not extends operation_1.Operation {
18
16
  constructor(item, target) {
19
17
  super(null, target);
20
18
  this.item = item;
@@ -28,8 +26,8 @@ class Not extends operation_1.default {
28
26
  handle(ctx) {
29
27
  return __awaiter(this, void 0, void 0, function* () {
30
28
  const result = yield this.arg.handle(ctx);
31
- return new boolean_1.default(!result.toTruthy());
29
+ return new boolean_1.CustomBoolean(!result.toTruthy());
32
30
  });
33
31
  }
34
32
  }
35
- exports.default = Not;
33
+ exports.Not = Not;
@@ -1,10 +1,10 @@
1
1
  import { ASTBase } from 'greyscript-core';
2
- import OperationContext from '../context';
3
- import CustomValue from '../types/base';
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
4
  export interface CPSVisit {
5
5
  (item: ASTBase): Promise<Operation>;
6
6
  }
7
- export default abstract class Operation {
7
+ export declare abstract class Operation {
8
8
  readonly item: ASTBase;
9
9
  readonly target: string;
10
10
  constructor(item: ASTBase, target?: string);
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Operation = void 0;
3
4
  class Operation {
4
5
  constructor(item, target = null) {
5
6
  this.item = item;
6
7
  this.target = target;
7
8
  }
8
9
  }
9
- exports.default = Operation;
10
+ exports.Operation = Operation;
@@ -1,7 +1,7 @@
1
- import OperationContext from '../context';
2
- import CustomValue from '../types/base';
3
- import Operation, { CPSVisit } from './operation';
4
- export default class Reference extends Operation {
1
+ import { OperationContext } from '../context';
2
+ import { CustomValue } from '../types/base';
3
+ import { CPSVisit, Operation } from './operation';
4
+ export declare class Reference extends Operation {
5
5
  readonly value: CustomValue;
6
6
  constructor(value: CustomValue);
7
7
  build(_visit: CPSVisit): Promise<Reference>;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const operation_1 = __importDefault(require("./operation"));
7
- class Reference extends operation_1.default {
3
+ exports.Reference = void 0;
4
+ const operation_1 = require("./operation");
5
+ class Reference extends operation_1.Operation {
8
6
  constructor(value) {
9
7
  super(null, 'native');
10
8
  this.value = value;
@@ -16,4 +14,4 @@ class Reference extends operation_1.default {
16
14
  return Promise.resolve(this.value);
17
15
  }
18
16
  }
19
- exports.default = Reference;
17
+ exports.Reference = Reference;
@@ -1,8 +1,8 @@
1
1
  import { ASTBase } from 'greyscript-core';
2
- import OperationContext from '../context';
3
- import CustomValue from '../types/base';
4
- import Path from '../utils/path';
5
- import Operation, { CPSVisit } from './operation';
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { Path } from '../utils/path';
5
+ import { CPSVisit, Operation } from './operation';
6
6
  export declare class SliceSegment {
7
7
  readonly left: Operation;
8
8
  readonly right: Operation;
@@ -25,7 +25,7 @@ export declare class OperationSegment {
25
25
  readonly op: Operation;
26
26
  constructor(op: Operation);
27
27
  }
28
- export declare type Segment = SliceSegment | IdentifierSegment | IndexSegment | OperationSegment;
28
+ export type Segment = SliceSegment | IdentifierSegment | IndexSegment | OperationSegment;
29
29
  export declare class SegmentContainer {
30
30
  path: Array<Segment>;
31
31
  constructor();
@@ -40,7 +40,7 @@ export declare class ResolveResult {
40
40
  readonly handle: CustomValue;
41
41
  constructor(path: Path<CustomValue>, handle: CustomValue);
42
42
  }
43
- export default class Resolve extends Operation {
43
+ export declare class Resolve extends Operation {
44
44
  readonly item: ASTBase;
45
45
  path: SegmentContainer;
46
46
  last: Segment;
@@ -8,20 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ResolveResult = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
12
+ exports.Resolve = exports.ResolveResult = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
16
13
  const greyscript_core_1 = require("greyscript-core");
17
- const default_1 = __importDefault(require("../types/default"));
18
- const function_1 = __importDefault(require("../types/function"));
19
- const list_1 = __importDefault(require("../types/list"));
20
- const map_1 = __importDefault(require("../types/map"));
21
- const string_1 = __importDefault(require("../types/string"));
14
+ const default_1 = require("../types/default");
15
+ const function_1 = require("../types/function");
16
+ const list_1 = require("../types/list");
17
+ const map_1 = require("../types/map");
18
+ const string_1 = require("../types/string");
22
19
  const with_intrinsics_1 = require("../types/with-intrinsics");
23
- const path_1 = __importDefault(require("../utils/path"));
24
- const operation_1 = __importDefault(require("./operation"));
20
+ const path_1 = require("../utils/path");
21
+ const operation_1 = require("./operation");
25
22
  class SliceSegment {
26
23
  constructor(left, right) {
27
24
  this.left = left;
@@ -32,7 +29,7 @@ exports.SliceSegment = SliceSegment;
32
29
  class PathSegment {
33
30
  toPath(_ctx) {
34
31
  return __awaiter(this, void 0, void 0, function* () {
35
- return Promise.resolve(default_1.default.Void);
32
+ return Promise.resolve(default_1.DefaultType.Void);
36
33
  });
37
34
  }
38
35
  }
@@ -43,7 +40,7 @@ class IdentifierSegment extends PathSegment {
43
40
  this.value = value;
44
41
  }
45
42
  toPath(_ctx) {
46
- return Promise.resolve(new string_1.default(this.value));
43
+ return Promise.resolve(new string_1.CustomString(this.value));
47
44
  }
48
45
  }
49
46
  exports.IdentifierSegment = IdentifierSegment;
@@ -96,7 +93,7 @@ class ResolveResult {
96
93
  }
97
94
  }
98
95
  exports.ResolveResult = ResolveResult;
99
- class Resolve extends operation_1.default {
96
+ class Resolve extends operation_1.Operation {
100
97
  constructor(item, target) {
101
98
  super(null, target);
102
99
  this.item = item;
@@ -150,8 +147,8 @@ class Resolve extends operation_1.default {
150
147
  }
151
148
  getResult(ctx) {
152
149
  return __awaiter(this, void 0, void 0, function* () {
153
- let traversedPath = new path_1.default();
154
- let handle = default_1.default.Void;
150
+ let traversedPath = new path_1.Path();
151
+ let handle = default_1.DefaultType.Void;
155
152
  const maxIndex = this.path.count();
156
153
  const lastIndex = maxIndex - 1;
157
154
  for (let index = 0; index < maxIndex; index++) {
@@ -166,7 +163,7 @@ class Resolve extends operation_1.default {
166
163
  break;
167
164
  }
168
165
  const previous = handle;
169
- if (handle !== default_1.default.Void) {
166
+ if (handle !== default_1.DefaultType.Void) {
170
167
  if (handle instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
171
168
  const customValueCtx = handle;
172
169
  handle = customValueCtx.get(traversedPath);
@@ -178,24 +175,24 @@ class Resolve extends operation_1.default {
178
175
  else {
179
176
  handle = ctx.get(traversedPath);
180
177
  }
181
- if (handle instanceof function_1.default) {
178
+ if (handle instanceof function_1.CustomFunction) {
182
179
  if (index === 1 &&
183
180
  traversedPath.toString() === 'super' &&
184
181
  ctx.functionState.context &&
185
- previous instanceof map_1.default) {
182
+ previous instanceof map_1.CustomMap) {
186
183
  handle = yield handle.run(ctx.functionState.context, [], ctx, previous.isa);
187
184
  }
188
185
  else {
189
- handle = yield handle.run(previous || default_1.default.Void, [], ctx);
186
+ handle = yield handle.run(previous || default_1.DefaultType.Void, [], ctx);
190
187
  }
191
188
  }
192
- traversedPath = new path_1.default();
189
+ traversedPath = new path_1.Path();
193
190
  }
194
191
  else if (current instanceof SliceSegment) {
195
192
  const sliceSegment = current;
196
193
  const left = yield sliceSegment.left.handle(ctx);
197
194
  const right = yield sliceSegment.right.handle(ctx);
198
- if (handle instanceof list_1.default || handle instanceof string_1.default) {
195
+ if (handle instanceof list_1.CustomList || handle instanceof string_1.CustomString) {
199
196
  handle = handle.slice(left, right);
200
197
  }
201
198
  else {
@@ -211,19 +208,19 @@ class Resolve extends operation_1.default {
211
208
  if (result === null) {
212
209
  result = yield this.getResult(ctx);
213
210
  }
214
- if (result.handle !== default_1.default.Void) {
211
+ if (result.handle !== default_1.DefaultType.Void) {
215
212
  if (result.path.count() === 0) {
216
- if (autoCall && result.handle instanceof function_1.default) {
217
- return result.handle.run(default_1.default.Void, [], ctx);
213
+ if (autoCall && result.handle instanceof function_1.CustomFunction) {
214
+ return result.handle.run(default_1.DefaultType.Void, [], ctx);
218
215
  }
219
216
  return result.handle;
220
217
  }
221
218
  const customValueCtx = result.handle;
222
219
  const child = customValueCtx.get(result.path);
223
- if (autoCall && child instanceof function_1.default) {
220
+ if (autoCall && child instanceof function_1.CustomFunction) {
224
221
  if (this.path.isSuper() &&
225
222
  ctx.functionState.context &&
226
- customValueCtx instanceof map_1.default) {
223
+ customValueCtx instanceof map_1.CustomMap) {
227
224
  return child.run(ctx.functionState.context, [], ctx, customValueCtx.isa);
228
225
  }
229
226
  return child.run(customValueCtx, [], ctx);
@@ -231,11 +228,11 @@ class Resolve extends operation_1.default {
231
228
  return child;
232
229
  }
233
230
  const handle = ctx.get(result.path);
234
- if (autoCall && handle instanceof function_1.default) {
235
- return handle.run(default_1.default.Void, [], ctx);
231
+ if (autoCall && handle instanceof function_1.CustomFunction) {
232
+ return handle.run(default_1.DefaultType.Void, [], ctx);
236
233
  }
237
234
  return handle;
238
235
  });
239
236
  }
240
237
  }
241
- exports.default = Resolve;
238
+ exports.Resolve = Resolve;
@@ -1,11 +1,11 @@
1
1
  import { ASTReturnStatement } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class Return extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class Return extends Operation {
6
6
  readonly item: ASTReturnStatement;
7
7
  arg: Operation;
8
8
  constructor(item: ASTReturnStatement, target?: string);
9
9
  build(visit: CPSVisit): Promise<Operation>;
10
- handle(ctx: context): Promise<CustomValue>;
10
+ handle(ctx: OperationContext): Promise<CustomValue>;
11
11
  }
@@ -8,14 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const default_1 = __importDefault(require("../types/default"));
16
- const operation_1 = __importDefault(require("./operation"));
17
- const reference_1 = __importDefault(require("./reference"));
18
- class Return extends operation_1.default {
12
+ exports.Return = void 0;
13
+ const default_1 = require("../types/default");
14
+ const operation_1 = require("./operation");
15
+ const reference_1 = require("./reference");
16
+ class Return extends operation_1.Operation {
19
17
  constructor(item, target) {
20
18
  super(null, target);
21
19
  this.item = item;
@@ -26,7 +24,7 @@ class Return extends operation_1.default {
26
24
  this.arg = yield visit(this.item.argument);
27
25
  }
28
26
  else {
29
- this.arg = new reference_1.default(default_1.default.Void);
27
+ this.arg = new reference_1.Reference(default_1.DefaultType.Void);
30
28
  }
31
29
  return this;
32
30
  });
@@ -38,8 +36,8 @@ class Return extends operation_1.default {
38
36
  ctx.functionState.value = yield this.arg.handle(ctx);
39
37
  ctx.functionState.isReturn = true;
40
38
  }
41
- return default_1.default.Void;
39
+ return default_1.DefaultType.Void;
42
40
  });
43
41
  }
44
42
  }
45
- exports.default = Return;
43
+ exports.Return = Return;
@@ -1,13 +1,13 @@
1
1
  import { ASTWhileStatement } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Block from './block';
5
- import Operation, { CPSVisit } from './operation';
6
- export default class While extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { Block } from './block';
5
+ import { CPSVisit, Operation } from './operation';
6
+ export declare class While extends Operation {
7
7
  readonly item: ASTWhileStatement;
8
8
  block: Block;
9
9
  condition: Operation;
10
10
  constructor(item: ASTWhileStatement, target?: string);
11
11
  build(visit: CPSVisit): Promise<Operation>;
12
- handle(ctx: context): Promise<CustomValue>;
12
+ handle(ctx: OperationContext): Promise<CustomValue>;
13
13
  }
@@ -8,15 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.While = void 0;
15
13
  const context_1 = require("../context");
16
- const default_1 = __importDefault(require("../types/default"));
17
- const block_1 = __importDefault(require("./block"));
18
- const operation_1 = __importDefault(require("./operation"));
19
- class While extends operation_1.default {
14
+ const default_1 = require("../types/default");
15
+ const block_1 = require("./block");
16
+ const operation_1 = require("./operation");
17
+ class While extends operation_1.Operation {
20
18
  constructor(item, target) {
21
19
  super(null, target);
22
20
  this.item = item;
@@ -24,7 +22,7 @@ class While extends operation_1.default {
24
22
  build(visit) {
25
23
  return __awaiter(this, void 0, void 0, function* () {
26
24
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
27
- this.block = new block_1.default(this.item, stack);
25
+ this.block = new block_1.Block(this.item, stack);
28
26
  this.condition = yield visit(this.item.condition);
29
27
  return this;
30
28
  });
@@ -42,13 +40,13 @@ class While extends operation_1.default {
42
40
  try {
43
41
  const conditionResult = yield this.condition.handle(whileCtx);
44
42
  if (!conditionResult.toTruthy()) {
45
- resolve(default_1.default.Void);
43
+ resolve(default_1.DefaultType.Void);
46
44
  return;
47
45
  }
48
46
  loopState.isContinue = false;
49
47
  yield this.block.handle(whileCtx);
50
48
  if (loopState.isBreak || ctx.isExit()) {
51
- resolve(default_1.default.Void);
49
+ resolve(default_1.DefaultType.Void);
52
50
  return;
53
51
  }
54
52
  process.nextTick(iteration);
@@ -62,4 +60,4 @@ class While extends operation_1.default {
62
60
  });
63
61
  }
64
62
  }
65
- exports.default = While;
63
+ exports.While = While;
@@ -1,4 +1,4 @@
1
- export default abstract class CustomValue {
1
+ export declare abstract class CustomValue {
2
2
  abstract value: any;
3
3
  abstract getCustomType(): string;
4
4
  abstract toNumber(): number;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomValue = void 0;
3
4
  class CustomValue {
4
5
  }
5
- exports.default = CustomValue;
6
+ exports.CustomValue = CustomValue;
@@ -1,5 +1,5 @@
1
- import CustomValue from './base';
2
- export default class CustomBoolean extends CustomValue {
1
+ import { CustomValue } from './base';
2
+ export declare class CustomBoolean extends CustomValue {
3
3
  readonly value: boolean;
4
4
  constructor(value: boolean);
5
5
  getCustomType(): string;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DefaultFalse = exports.DefaultTrue = void 0;
7
- const base_1 = __importDefault(require("./base"));
8
- class CustomBoolean extends base_1.default {
3
+ exports.DefaultFalse = exports.DefaultTrue = exports.CustomBoolean = void 0;
4
+ const base_1 = require("./base");
5
+ class CustomBoolean extends base_1.CustomValue {
9
6
  constructor(value) {
10
7
  super();
11
8
  this.value = !!value;
@@ -35,6 +32,6 @@ class CustomBoolean extends base_1.default {
35
32
  return v instanceof CustomBoolean;
36
33
  }
37
34
  }
38
- exports.default = CustomBoolean;
35
+ exports.CustomBoolean = CustomBoolean;
39
36
  exports.DefaultTrue = new CustomBoolean(true);
40
37
  exports.DefaultFalse = new CustomBoolean(false);
@@ -1,8 +1,8 @@
1
- export default class Defaults {
2
- static readonly Void: import("./nil").default;
3
- static readonly True: import("./boolean").default;
4
- static readonly False: import("./boolean").default;
5
- static readonly NegativeOne: import("./number").default;
6
- static readonly PositiveOne: import("./number").default;
7
- static readonly Zero: import("./number").default;
1
+ export declare class DefaultType {
2
+ static readonly Void: import("./nil").CustomNil;
3
+ static readonly True: import("./boolean").CustomBoolean;
4
+ static readonly False: import("./boolean").CustomBoolean;
5
+ static readonly NegativeOne: import("./number").CustomNumber;
6
+ static readonly PositiveOne: import("./number").CustomNumber;
7
+ static readonly Zero: import("./number").CustomNumber;
8
8
  }
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultType = void 0;
3
4
  const boolean_1 = require("./boolean");
4
5
  const nil_1 = require("./nil");
5
6
  const number_1 = require("./number");
6
- class Defaults {
7
+ class DefaultType {
7
8
  }
8
- exports.default = Defaults;
9
- Defaults.Void = nil_1.Void;
10
- Defaults.True = boolean_1.DefaultTrue;
11
- Defaults.False = boolean_1.DefaultFalse;
12
- Defaults.NegativeOne = number_1.NegativeOne;
13
- Defaults.PositiveOne = number_1.PositiveOne;
14
- Defaults.Zero = number_1.Zero;
9
+ DefaultType.Void = nil_1.Void;
10
+ DefaultType.True = boolean_1.DefaultTrue;
11
+ DefaultType.False = boolean_1.DefaultFalse;
12
+ DefaultType.NegativeOne = number_1.NegativeOne;
13
+ DefaultType.PositiveOne = number_1.PositiveOne;
14
+ DefaultType.Zero = number_1.Zero;
15
+ exports.DefaultType = DefaultType;