greybel-interpreter 1.4.6 → 1.4.7

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 (101) hide show
  1. package/.editorconfig +14 -14
  2. package/.eslintrc +47 -47
  3. package/LICENSE +21 -21
  4. package/README.md +2 -2
  5. package/dist/context.d.ts +110 -110
  6. package/dist/context.js +306 -306
  7. package/dist/cps.d.ts +14 -14
  8. package/dist/cps.js +160 -160
  9. package/dist/handler/error.d.ts +6 -6
  10. package/dist/handler/error.js +12 -12
  11. package/dist/handler/output.d.ts +18 -18
  12. package/dist/handler/output.js +29 -29
  13. package/dist/handler/resource.d.ts +12 -12
  14. package/dist/handler/resource.js +28 -28
  15. package/dist/handler-container.d.ts +14 -14
  16. package/dist/handler-container.js +14 -14
  17. package/dist/index.d.ts +46 -46
  18. package/dist/index.js +132 -132
  19. package/dist/interpreter.d.ts +42 -42
  20. package/dist/interpreter.js +218 -218
  21. package/dist/operations/assign.d.ts +13 -13
  22. package/dist/operations/assign.js +46 -46
  23. package/dist/operations/block.d.ts +12 -12
  24. package/dist/operations/block.js +52 -52
  25. package/dist/operations/break.d.ts +10 -10
  26. package/dist/operations/break.js +23 -23
  27. package/dist/operations/call.d.ts +13 -13
  28. package/dist/operations/call.js +49 -49
  29. package/dist/operations/chunk.d.ts +12 -12
  30. package/dist/operations/chunk.js +33 -33
  31. package/dist/operations/continue.d.ts +10 -10
  32. package/dist/operations/continue.js +23 -23
  33. package/dist/operations/debugger-statement.d.ts +10 -10
  34. package/dist/operations/debugger-statement.js +21 -21
  35. package/dist/operations/evaluate.d.ts +40 -40
  36. package/dist/operations/evaluate.js +334 -334
  37. package/dist/operations/for.d.ts +14 -14
  38. package/dist/operations/for.js +81 -81
  39. package/dist/operations/function-reference.d.ts +12 -12
  40. package/dist/operations/function-reference.js +44 -44
  41. package/dist/operations/function.d.ts +14 -14
  42. package/dist/operations/function.js +72 -72
  43. package/dist/operations/if-statement.d.ts +19 -19
  44. package/dist/operations/if-statement.js +85 -85
  45. package/dist/operations/import.d.ts +17 -17
  46. package/dist/operations/import.js +57 -57
  47. package/dist/operations/include.d.ts +13 -13
  48. package/dist/operations/include.js +41 -41
  49. package/dist/operations/list.d.ts +11 -11
  50. package/dist/operations/list.js +42 -42
  51. package/dist/operations/literal.d.ts +11 -11
  52. package/dist/operations/literal.js +40 -40
  53. package/dist/operations/map.d.ts +11 -11
  54. package/dist/operations/map.js +44 -44
  55. package/dist/operations/negated-binary.d.ts +11 -11
  56. package/dist/operations/negated-binary.js +42 -42
  57. package/dist/operations/new-instance.d.ts +11 -11
  58. package/dist/operations/new-instance.js +39 -39
  59. package/dist/operations/noop.d.ts +9 -9
  60. package/dist/operations/noop.js +19 -19
  61. package/dist/operations/not.d.ts +11 -11
  62. package/dist/operations/not.js +35 -35
  63. package/dist/operations/operation.d.ts +13 -13
  64. package/dist/operations/operation.js +9 -9
  65. package/dist/operations/reference.d.ts +9 -9
  66. package/dist/operations/reference.js +19 -19
  67. package/dist/operations/resolve.d.ts +38 -38
  68. package/dist/operations/resolve.js +210 -210
  69. package/dist/operations/return.d.ts +11 -11
  70. package/dist/operations/return.js +45 -45
  71. package/dist/operations/while.d.ts +13 -13
  72. package/dist/operations/while.js +65 -65
  73. package/dist/types/base.d.ts +9 -9
  74. package/dist/types/base.js +5 -5
  75. package/dist/types/boolean.d.ts +13 -13
  76. package/dist/types/boolean.js +34 -34
  77. package/dist/types/default.d.ts +8 -8
  78. package/dist/types/default.js +14 -14
  79. package/dist/types/function.d.ts +32 -32
  80. package/dist/types/function.js +104 -104
  81. package/dist/types/interface.d.ts +24 -24
  82. package/dist/types/interface.js +83 -83
  83. package/dist/types/list.d.ts +29 -29
  84. package/dist/types/list.js +158 -158
  85. package/dist/types/map.d.ts +33 -33
  86. package/dist/types/map.js +200 -200
  87. package/dist/types/nil.d.ts +11 -11
  88. package/dist/types/nil.js +33 -33
  89. package/dist/types/number.d.ts +25 -25
  90. package/dist/types/number.js +69 -69
  91. package/dist/types/string.d.ts +31 -31
  92. package/dist/types/string.js +121 -121
  93. package/dist/types/with-intrinsics.d.ts +15 -15
  94. package/dist/types/with-intrinsics.js +19 -19
  95. package/dist/utils/deep-equal.d.ts +1 -1
  96. package/dist/utils/deep-equal.js +37 -37
  97. package/dist/utils/object-value.d.ts +7 -7
  98. package/dist/utils/object-value.js +42 -42
  99. package/dist/utils/path.d.ts +10 -10
  100. package/dist/utils/path.js +32 -32
  101. package/package.json +58 -58
@@ -1,85 +1,85 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Clause = void 0;
16
- const greyscript_core_1 = require("greyscript-core");
17
- const boolean_1 = __importDefault(require("../types/boolean"));
18
- const default_1 = __importDefault(require("../types/default"));
19
- const block_1 = __importDefault(require("./block"));
20
- const operation_1 = __importDefault(require("./operation"));
21
- const reference_1 = __importDefault(require("./reference"));
22
- class Clause {
23
- constructor(condition, block) {
24
- this.condition = condition;
25
- this.block = block;
26
- }
27
- }
28
- exports.Clause = Clause;
29
- class IfStatement extends operation_1.default {
30
- constructor(item, target) {
31
- super(null, target);
32
- this.item = item;
33
- }
34
- buildIfClause(node, visit) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const condition = yield visit(node.condition);
37
- const stack = yield Promise.all(node.body.map((child) => visit(child)));
38
- const block = new block_1.default(stack);
39
- this.clauses.push(new Clause(condition, block));
40
- });
41
- }
42
- buildElseClause(node, visit) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const condition = new reference_1.default(new boolean_1.default(true));
45
- const stack = yield Promise.all(node.body.map((child) => visit(child)));
46
- const block = new block_1.default(stack);
47
- this.clauses.push(new Clause(condition, block));
48
- });
49
- }
50
- build(visit) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- this.clauses = [];
53
- for (let index = 0; index < this.item.clauses.length; index++) {
54
- const child = this.item.clauses[index];
55
- switch (child.type) {
56
- case greyscript_core_1.ASTType.IfClause:
57
- case greyscript_core_1.ASTType.IfShortcutClause:
58
- case greyscript_core_1.ASTType.ElseifClause:
59
- case greyscript_core_1.ASTType.ElseifShortcutClause:
60
- yield this.buildIfClause(child, visit);
61
- break;
62
- case greyscript_core_1.ASTType.ElseClause:
63
- case greyscript_core_1.ASTType.ElseShortcutClause:
64
- yield this.buildElseClause(child, visit);
65
- break;
66
- }
67
- }
68
- return this;
69
- });
70
- }
71
- handle(ctx) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- for (let index = 0; index < this.clauses.length; index++) {
74
- const clause = this.clauses[index];
75
- const clauseResult = yield clause.condition.handle(ctx);
76
- if (clauseResult.toTruthy()) {
77
- yield clause.block.handle(ctx);
78
- break;
79
- }
80
- }
81
- return default_1.default.Void;
82
- });
83
- }
84
- }
85
- exports.default = IfStatement;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Clause = void 0;
16
+ const greyscript_core_1 = require("greyscript-core");
17
+ const boolean_1 = __importDefault(require("../types/boolean"));
18
+ const default_1 = __importDefault(require("../types/default"));
19
+ const block_1 = __importDefault(require("./block"));
20
+ const operation_1 = __importDefault(require("./operation"));
21
+ const reference_1 = __importDefault(require("./reference"));
22
+ class Clause {
23
+ constructor(condition, block) {
24
+ this.condition = condition;
25
+ this.block = block;
26
+ }
27
+ }
28
+ exports.Clause = Clause;
29
+ class IfStatement extends operation_1.default {
30
+ constructor(item, target) {
31
+ super(null, target);
32
+ this.item = item;
33
+ }
34
+ buildIfClause(node, visit) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const condition = yield visit(node.condition);
37
+ const stack = yield Promise.all(node.body.map((child) => visit(child)));
38
+ const block = new block_1.default(stack);
39
+ this.clauses.push(new Clause(condition, block));
40
+ });
41
+ }
42
+ buildElseClause(node, visit) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const condition = new reference_1.default(new boolean_1.default(true));
45
+ const stack = yield Promise.all(node.body.map((child) => visit(child)));
46
+ const block = new block_1.default(stack);
47
+ this.clauses.push(new Clause(condition, block));
48
+ });
49
+ }
50
+ build(visit) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ this.clauses = [];
53
+ for (let index = 0; index < this.item.clauses.length; index++) {
54
+ const child = this.item.clauses[index];
55
+ switch (child.type) {
56
+ case greyscript_core_1.ASTType.IfClause:
57
+ case greyscript_core_1.ASTType.IfShortcutClause:
58
+ case greyscript_core_1.ASTType.ElseifClause:
59
+ case greyscript_core_1.ASTType.ElseifShortcutClause:
60
+ yield this.buildIfClause(child, visit);
61
+ break;
62
+ case greyscript_core_1.ASTType.ElseClause:
63
+ case greyscript_core_1.ASTType.ElseShortcutClause:
64
+ yield this.buildElseClause(child, visit);
65
+ break;
66
+ }
67
+ }
68
+ return this;
69
+ });
70
+ }
71
+ handle(ctx) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ for (let index = 0; index < this.clauses.length; index++) {
74
+ const clause = this.clauses[index];
75
+ const clauseResult = yield clause.condition.handle(ctx);
76
+ if (clauseResult.toTruthy()) {
77
+ yield clause.block.handle(ctx);
78
+ break;
79
+ }
80
+ }
81
+ return default_1.default.Void;
82
+ });
83
+ }
84
+ }
85
+ exports.default = IfStatement;
@@ -1,17 +1,17 @@
1
- import { ASTFeatureImportExpression } from 'greybel-core';
2
- import { ASTBase } from 'greyscript-core';
3
- import context from '../context';
4
- import CustomValue from '../types/base';
5
- import CustomString from '../types/string';
6
- import Operation, { CPSVisit } from './operation';
7
- export declare const MODULE_PROPERTY: CustomString;
8
- export declare const EXPORTS_PROPERTY: CustomString;
9
- export default class Include extends Operation {
10
- readonly item: ASTFeatureImportExpression;
11
- code: string;
12
- chunk: ASTBase;
13
- top: Operation;
14
- constructor(item: ASTFeatureImportExpression, target: string, code: string);
15
- build(visit: CPSVisit): Promise<Operation>;
16
- handle(ctx: context): Promise<CustomValue>;
17
- }
1
+ import { ASTFeatureImportExpression } from 'greybel-core';
2
+ import { ASTBase } from 'greyscript-core';
3
+ import context from '../context';
4
+ import CustomValue from '../types/base';
5
+ import CustomString from '../types/string';
6
+ import Operation, { CPSVisit } from './operation';
7
+ export declare const MODULE_PROPERTY: CustomString;
8
+ export declare const EXPORTS_PROPERTY: CustomString;
9
+ export default class Include extends Operation {
10
+ readonly item: ASTFeatureImportExpression;
11
+ code: string;
12
+ chunk: ASTBase;
13
+ top: Operation;
14
+ constructor(item: ASTFeatureImportExpression, target: string, code: string);
15
+ build(visit: CPSVisit): Promise<Operation>;
16
+ handle(ctx: context): Promise<CustomValue>;
17
+ }
@@ -1,57 +1,57 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EXPORTS_PROPERTY = exports.MODULE_PROPERTY = void 0;
16
- const greybel_core_1 = require("greybel-core");
17
- const context_1 = require("../context");
18
- const default_1 = __importDefault(require("../types/default"));
19
- const map_1 = __importDefault(require("../types/map"));
20
- const string_1 = __importDefault(require("../types/string"));
21
- const operation_1 = __importDefault(require("./operation"));
22
- exports.MODULE_PROPERTY = new string_1.default('module');
23
- exports.EXPORTS_PROPERTY = new string_1.default('exports');
24
- class Include extends operation_1.default {
25
- constructor(item, target, code) {
26
- super(null, target);
27
- this.item = item;
28
- this.code = code;
29
- }
30
- build(visit) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const parser = new greybel_core_1.Parser(this.code);
33
- this.chunk = parser.parseChunk();
34
- this.top = yield visit(this.chunk);
35
- return this;
36
- });
37
- }
38
- handle(ctx) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const importCtx = ctx.fork({
41
- type: context_1.ContextType.External,
42
- state: context_1.ContextState.Temporary,
43
- target: this.target
44
- });
45
- const moduleMap = new map_1.default();
46
- importCtx.set(exports.MODULE_PROPERTY, moduleMap);
47
- yield this.top.handle(importCtx);
48
- const item = moduleMap.has(exports.EXPORTS_PROPERTY)
49
- ? moduleMap.get(exports.EXPORTS_PROPERTY)
50
- : default_1.default.Void;
51
- const identifier = this.item.name;
52
- ctx.set(new string_1.default(identifier.name), item);
53
- return default_1.default.Void;
54
- });
55
- }
56
- }
57
- exports.default = Include;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.EXPORTS_PROPERTY = exports.MODULE_PROPERTY = void 0;
16
+ const greybel_core_1 = require("greybel-core");
17
+ const context_1 = require("../context");
18
+ const default_1 = __importDefault(require("../types/default"));
19
+ const map_1 = __importDefault(require("../types/map"));
20
+ const string_1 = __importDefault(require("../types/string"));
21
+ const operation_1 = __importDefault(require("./operation"));
22
+ exports.MODULE_PROPERTY = new string_1.default('module');
23
+ exports.EXPORTS_PROPERTY = new string_1.default('exports');
24
+ class Include extends operation_1.default {
25
+ constructor(item, target, code) {
26
+ super(null, target);
27
+ this.item = item;
28
+ this.code = code;
29
+ }
30
+ build(visit) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const parser = new greybel_core_1.Parser(this.code);
33
+ this.chunk = parser.parseChunk();
34
+ this.top = yield visit(this.chunk);
35
+ return this;
36
+ });
37
+ }
38
+ handle(ctx) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const importCtx = ctx.fork({
41
+ type: context_1.ContextType.External,
42
+ state: context_1.ContextState.Temporary,
43
+ target: this.target
44
+ });
45
+ const moduleMap = new map_1.default();
46
+ importCtx.set(exports.MODULE_PROPERTY, moduleMap);
47
+ yield this.top.handle(importCtx);
48
+ const item = moduleMap.has(exports.EXPORTS_PROPERTY)
49
+ ? moduleMap.get(exports.EXPORTS_PROPERTY)
50
+ : default_1.default.Void;
51
+ const identifier = this.item.name;
52
+ ctx.set(new string_1.default(identifier.name), item);
53
+ return default_1.default.Void;
54
+ });
55
+ }
56
+ }
57
+ exports.default = Include;
@@ -1,13 +1,13 @@
1
- import { ASTBase } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class Include extends Operation {
6
- readonly item: ASTBase;
7
- code: string;
8
- chunk: ASTBase;
9
- top: Operation;
10
- constructor(item: ASTBase, target: string, code: string);
11
- build(visit: CPSVisit): Promise<Operation>;
12
- handle(ctx: context): Promise<CustomValue>;
13
- }
1
+ import { ASTBase } from 'greyscript-core';
2
+ import context from '../context';
3
+ import CustomValue from '../types/base';
4
+ import Operation, { CPSVisit } from './operation';
5
+ export default class Include extends Operation {
6
+ readonly item: ASTBase;
7
+ code: string;
8
+ chunk: ASTBase;
9
+ top: Operation;
10
+ constructor(item: ASTBase, target: string, code: string);
11
+ build(visit: CPSVisit): Promise<Operation>;
12
+ handle(ctx: context): Promise<CustomValue>;
13
+ }
@@ -1,41 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const greybel_core_1 = require("greybel-core");
16
- const context_1 = require("../context");
17
- const operation_1 = __importDefault(require("./operation"));
18
- class Include extends operation_1.default {
19
- constructor(item, target, code) {
20
- super(null, target);
21
- this.item = item;
22
- this.code = code;
23
- }
24
- build(visit) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const parser = new greybel_core_1.Parser(this.code);
27
- this.chunk = parser.parseChunk();
28
- this.top = yield visit(this.chunk);
29
- return this;
30
- });
31
- }
32
- handle(ctx) {
33
- const importCtx = ctx.fork({
34
- type: context_1.ContextType.External,
35
- state: context_1.ContextState.Temporary,
36
- target: this.target
37
- });
38
- return this.top.handle(importCtx);
39
- }
40
- }
41
- exports.default = Include;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const greybel_core_1 = require("greybel-core");
16
+ const context_1 = require("../context");
17
+ const operation_1 = __importDefault(require("./operation"));
18
+ class Include extends operation_1.default {
19
+ constructor(item, target, code) {
20
+ super(null, target);
21
+ this.item = item;
22
+ this.code = code;
23
+ }
24
+ build(visit) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const parser = new greybel_core_1.Parser(this.code);
27
+ this.chunk = parser.parseChunk();
28
+ this.top = yield visit(this.chunk);
29
+ return this;
30
+ });
31
+ }
32
+ handle(ctx) {
33
+ const importCtx = ctx.fork({
34
+ type: context_1.ContextType.External,
35
+ state: context_1.ContextState.Temporary,
36
+ target: this.target
37
+ });
38
+ return this.top.handle(importCtx);
39
+ }
40
+ }
41
+ exports.default = Include;
@@ -1,11 +1,11 @@
1
- import { ASTListConstructorExpression } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class List extends Operation {
6
- readonly item: ASTListConstructorExpression;
7
- fields: Array<Operation>;
8
- constructor(item: ASTListConstructorExpression, target?: string);
9
- build(visit: CPSVisit): Promise<Operation>;
10
- handle(ctx: context): Promise<CustomValue>;
11
- }
1
+ import { ASTListConstructorExpression } from 'greyscript-core';
2
+ import context from '../context';
3
+ import CustomValue from '../types/base';
4
+ import Operation, { CPSVisit } from './operation';
5
+ export default class List extends Operation {
6
+ readonly item: ASTListConstructorExpression;
7
+ fields: Array<Operation>;
8
+ constructor(item: ASTListConstructorExpression, target?: string);
9
+ build(visit: CPSVisit): Promise<Operation>;
10
+ handle(ctx: context): Promise<CustomValue>;
11
+ }
@@ -1,42 +1,42 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const list_1 = __importDefault(require("../types/list"));
16
- const operation_1 = __importDefault(require("./operation"));
17
- class List extends operation_1.default {
18
- constructor(item, target) {
19
- super(null, target);
20
- this.item = item;
21
- }
22
- build(visit) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- this.fields = yield Promise.all(this.item.fields.map((child) => {
25
- const listValue = child;
26
- return visit(listValue.value);
27
- }));
28
- return this;
29
- });
30
- }
31
- handle(ctx) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const fields = [];
34
- for (let index = 0; index < this.fields.length; index++) {
35
- const child = this.fields[index];
36
- fields.push(yield child.handle(ctx));
37
- }
38
- return new list_1.default(fields);
39
- });
40
- }
41
- }
42
- exports.default = List;
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const list_1 = __importDefault(require("../types/list"));
16
+ const operation_1 = __importDefault(require("./operation"));
17
+ class List extends operation_1.default {
18
+ constructor(item, target) {
19
+ super(null, target);
20
+ this.item = item;
21
+ }
22
+ build(visit) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ this.fields = yield Promise.all(this.item.fields.map((child) => {
25
+ const listValue = child;
26
+ return visit(listValue.value);
27
+ }));
28
+ return this;
29
+ });
30
+ }
31
+ handle(ctx) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const fields = [];
34
+ for (let index = 0; index < this.fields.length; index++) {
35
+ const child = this.fields[index];
36
+ fields.push(yield child.handle(ctx));
37
+ }
38
+ return new list_1.default(fields);
39
+ });
40
+ }
41
+ }
42
+ exports.default = List;
@@ -1,11 +1,11 @@
1
- import { ASTLiteral } from 'greyscript-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class Literal extends Operation {
6
- readonly item: ASTLiteral;
7
- value: CustomValue;
8
- constructor(item: ASTLiteral, target?: string);
9
- build(_visit: CPSVisit): Promise<Operation>;
10
- handle(_ctx: context): Promise<CustomValue>;
11
- }
1
+ import { ASTLiteral } from 'greyscript-core';
2
+ import context from '../context';
3
+ import CustomValue from '../types/base';
4
+ import Operation, { CPSVisit } from './operation';
5
+ export default class Literal extends Operation {
6
+ readonly item: ASTLiteral;
7
+ value: CustomValue;
8
+ constructor(item: ASTLiteral, target?: string);
9
+ build(_visit: CPSVisit): Promise<Operation>;
10
+ handle(_ctx: context): Promise<CustomValue>;
11
+ }
@@ -1,40 +1,40 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const greyscript_core_1 = require("greyscript-core");
7
- const boolean_1 = __importDefault(require("../types/boolean"));
8
- const default_1 = __importDefault(require("../types/default"));
9
- const number_1 = __importDefault(require("../types/number"));
10
- const string_1 = __importDefault(require("../types/string"));
11
- const operation_1 = __importDefault(require("./operation"));
12
- class Literal extends operation_1.default {
13
- constructor(item, target) {
14
- super(null, target);
15
- this.item = item;
16
- }
17
- build(_visit) {
18
- switch (this.item.type) {
19
- case greyscript_core_1.ASTType.BooleanLiteral:
20
- this.value = new boolean_1.default(this.item.value);
21
- break;
22
- case greyscript_core_1.ASTType.StringLiteral:
23
- this.value = new string_1.default(this.item.value);
24
- break;
25
- case greyscript_core_1.ASTType.NumericLiteral:
26
- this.value = new number_1.default(this.item.value);
27
- break;
28
- case greyscript_core_1.ASTType.NilLiteral:
29
- this.value = default_1.default.Void;
30
- break;
31
- default:
32
- throw new Error('Unexpected literal type.');
33
- }
34
- return Promise.resolve(this);
35
- }
36
- handle(_ctx) {
37
- return Promise.resolve(this.value);
38
- }
39
- }
40
- exports.default = Literal;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const greyscript_core_1 = require("greyscript-core");
7
+ const boolean_1 = __importDefault(require("../types/boolean"));
8
+ const default_1 = __importDefault(require("../types/default"));
9
+ const number_1 = __importDefault(require("../types/number"));
10
+ const string_1 = __importDefault(require("../types/string"));
11
+ const operation_1 = __importDefault(require("./operation"));
12
+ class Literal extends operation_1.default {
13
+ constructor(item, target) {
14
+ super(null, target);
15
+ this.item = item;
16
+ }
17
+ build(_visit) {
18
+ switch (this.item.type) {
19
+ case greyscript_core_1.ASTType.BooleanLiteral:
20
+ this.value = new boolean_1.default(this.item.value);
21
+ break;
22
+ case greyscript_core_1.ASTType.StringLiteral:
23
+ this.value = new string_1.default(this.item.value);
24
+ break;
25
+ case greyscript_core_1.ASTType.NumericLiteral:
26
+ this.value = new number_1.default(this.item.value);
27
+ break;
28
+ case greyscript_core_1.ASTType.NilLiteral:
29
+ this.value = default_1.default.Void;
30
+ break;
31
+ default:
32
+ throw new Error('Unexpected literal type.');
33
+ }
34
+ return Promise.resolve(this);
35
+ }
36
+ handle(_ctx) {
37
+ return Promise.resolve(this.value);
38
+ }
39
+ }
40
+ exports.default = Literal;