greybel-interpreter 1.7.1 → 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 +4 -4
  6. package/dist/handler/output.js +2 -2
  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 -2
@@ -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 string_1 = __importDefault(require("../types/string"));
16
- const block_1 = __importDefault(require("./block"));
17
- const operation_1 = __importDefault(require("./operation"));
18
- class Chunk extends operation_1.default {
12
+ exports.Chunk = void 0;
13
+ const string_1 = require("../types/string");
14
+ const block_1 = require("./block");
15
+ const operation_1 = require("./operation");
16
+ class Chunk extends operation_1.Operation {
19
17
  constructor(item, target) {
20
18
  super(null, target);
21
19
  this.item = item;
@@ -23,13 +21,13 @@ class Chunk extends operation_1.default {
23
21
  build(visit) {
24
22
  return __awaiter(this, void 0, void 0, function* () {
25
23
  const stack = yield Promise.all(this.item.body.map((child) => visit(child)));
26
- this.block = new block_1.default(this.item, stack);
24
+ this.block = new block_1.Block(this.item, stack);
27
25
  return this;
28
26
  });
29
27
  }
30
28
  handle(ctx) {
31
- ctx.set(new string_1.default('locals'), ctx.locals.scope);
29
+ ctx.set(new string_1.CustomString('locals'), ctx.locals.scope);
32
30
  return this.block.handle(ctx);
33
31
  }
34
32
  }
35
- exports.default = Chunk;
33
+ exports.Chunk = Chunk;
@@ -1,8 +1,8 @@
1
1
  import { ASTBase } from 'greyscript-core';
2
- import OperationContext from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class Continue extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class Continue extends Operation {
6
6
  readonly item: ASTBase;
7
7
  constructor(item: ASTBase, target?: string);
8
8
  build(_visit: CPSVisit): Promise<Continue>;
@@ -1,11 +1,9 @@
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 Continue extends operation_1.default {
3
+ exports.Continue = void 0;
4
+ const default_1 = require("../types/default");
5
+ const operation_1 = require("./operation");
6
+ class Continue extends operation_1.Operation {
9
7
  constructor(item, target) {
10
8
  super(null, target);
11
9
  this.item = item;
@@ -17,7 +15,7 @@ class Continue extends operation_1.default {
17
15
  if (ctx.loopState !== null) {
18
16
  ctx.loopState.isContinue = true;
19
17
  }
20
- return Promise.resolve(default_1.default.Void);
18
+ return Promise.resolve(default_1.DefaultType.Void);
21
19
  }
22
20
  }
23
- exports.default = Continue;
21
+ exports.Continue = Continue;
@@ -1,10 +1,10 @@
1
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 DebuggerStatement extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class DebuggerStatement extends Operation {
6
6
  readonly item: ASTBase;
7
7
  constructor(item: ASTBase, target?: string);
8
8
  build(_visit: CPSVisit): Promise<DebuggerStatement>;
9
- handle(ctx: context): Promise<CustomValue>;
9
+ handle(ctx: OperationContext): Promise<CustomValue>;
10
10
  }
@@ -1,11 +1,9 @@
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 DebuggerStatement extends operation_1.default {
3
+ exports.DebuggerStatement = void 0;
4
+ const default_1 = require("../types/default");
5
+ const operation_1 = require("./operation");
6
+ class DebuggerStatement extends operation_1.Operation {
9
7
  constructor(item, target) {
10
8
  super(null, target);
11
9
  this.item = item;
@@ -15,7 +13,7 @@ class DebuggerStatement extends operation_1.default {
15
13
  }
16
14
  handle(ctx) {
17
15
  ctx.debugger.setBreakpoint(true);
18
- return Promise.resolve(default_1.default.Void);
16
+ return Promise.resolve(default_1.DefaultType.Void);
19
17
  }
20
18
  }
21
- exports.default = DebuggerStatement;
19
+ exports.DebuggerStatement = DebuggerStatement;
@@ -1,10 +1,10 @@
1
1
  import { ASTFeatureEnvarExpression } from 'greybel-core';
2
- import context from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
5
- export default class EnvarExpression extends Operation {
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CPSVisit, Operation } from './operation';
5
+ export declare class EnvarExpression extends Operation {
6
6
  readonly item: ASTFeatureEnvarExpression;
7
7
  constructor(item: ASTFeatureEnvarExpression, target?: string);
8
8
  build(_visit: CPSVisit): Promise<Operation>;
9
- handle(ctx: context): Promise<CustomValue>;
9
+ handle(ctx: OperationContext): Promise<CustomValue>;
10
10
  }
@@ -1,11 +1,9 @@
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 string_1 = __importDefault(require("../types/string"));
7
- const operation_1 = __importDefault(require("./operation"));
8
- class EnvarExpression extends operation_1.default {
3
+ exports.EnvarExpression = void 0;
4
+ const string_1 = require("../types/string");
5
+ const operation_1 = require("./operation");
6
+ class EnvarExpression extends operation_1.Operation {
9
7
  constructor(item, target) {
10
8
  super(null, target);
11
9
  this.item = item;
@@ -15,9 +13,9 @@ class EnvarExpression extends operation_1.default {
15
13
  }
16
14
  handle(ctx) {
17
15
  if (ctx.environmentVariables.has(this.item.name)) {
18
- return Promise.resolve(new string_1.default(ctx.environmentVariables.get(this.item.name)));
16
+ return Promise.resolve(new string_1.CustomString(ctx.environmentVariables.get(this.item.name)));
19
17
  }
20
18
  throw new Error('Unknown environment variable.');
21
19
  }
22
20
  }
23
- exports.default = EnvarExpression;
21
+ exports.EnvarExpression = EnvarExpression;
@@ -1,7 +1,8 @@
1
1
  import { ASTEvaluationExpression } from 'greyscript-core';
2
- import OperationContext from '../context';
3
- import CustomValue from '../types/base';
4
- import Operation, { CPSVisit } from './operation';
2
+ import { OperationContext } from '../context';
3
+ import { CustomValue } from '../types/base';
4
+ import { CustomBoolean } from '../types/boolean';
5
+ import { CPSVisit, Operation } from './operation';
5
6
  export interface ProcessorHandlerFunction {
6
7
  (op: string, a: CustomValue, b: CustomValue): CustomValue;
7
8
  }
@@ -25,7 +26,7 @@ export declare const handleInterface: ProcessorHandlerFunction;
25
26
  export declare const handleNil: ProcessorHandlerFunction;
26
27
  export declare const handleFunction: ProcessorHandlerFunction;
27
28
  export declare const handle: (op: string, a: CustomValue, b: CustomValue) => CustomValue;
28
- export default class Evaluate extends Operation {
29
+ export declare class Evaluate extends Operation {
29
30
  readonly item: ASTEvaluationExpression;
30
31
  type: string;
31
32
  op: string;
@@ -34,7 +35,7 @@ export default class Evaluate extends Operation {
34
35
  constructor(item: ASTEvaluationExpression, target?: string);
35
36
  build(visit: CPSVisit): Promise<Operation>;
36
37
  resolveBinaryExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue>;
37
- resolveLogicalExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue>;
38
+ resolveLogicalExpression(ctx: OperationContext, expr: Evaluate): Promise<CustomValue | CustomBoolean>;
38
39
  resolve(ctx: OperationContext, op: Operation): Promise<CustomValue>;
39
40
  handle(ctx: OperationContext): Promise<CustomValue>;
40
41
  }
@@ -8,160 +8,157 @@ 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.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.StringProcessorHandler = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
12
+ exports.Evaluate = exports.handle = exports.handleFunction = exports.handleNil = exports.handleInterface = exports.handleMap = exports.handleList = exports.handleString = exports.handleNumber = exports.FunctionProcessorHandler = exports.NilProcessorHandler = exports.InterfaceProcessorHandler = exports.MapProcessorHandler = exports.ListProcessorHandler = exports.StringProcessorHandler = exports.multiplyString = exports.NumberProcessorHandler = exports.GenericProcessorHandler = void 0;
16
13
  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 function_1 = __importDefault(require("../types/function"));
20
- const interface_1 = __importDefault(require("../types/interface"));
21
- const list_1 = __importDefault(require("../types/list"));
22
- const map_1 = __importDefault(require("../types/map"));
23
- const nil_1 = __importDefault(require("../types/nil"));
24
- const number_1 = __importDefault(require("../types/number"));
25
- const string_1 = __importDefault(require("../types/string"));
26
- const deep_equal_1 = __importDefault(require("../utils/deep-equal"));
27
- const operation_1 = __importDefault(require("./operation"));
14
+ const boolean_1 = require("../types/boolean");
15
+ const default_1 = require("../types/default");
16
+ const function_1 = require("../types/function");
17
+ const interface_1 = require("../types/interface");
18
+ const list_1 = require("../types/list");
19
+ const map_1 = require("../types/map");
20
+ const nil_1 = require("../types/nil");
21
+ const number_1 = require("../types/number");
22
+ const string_1 = require("../types/string");
23
+ const deep_equal_1 = require("../utils/deep-equal");
24
+ const operation_1 = require("./operation");
28
25
  exports.GenericProcessorHandler = {
29
- [greyscript_core_1.Operator.And]: (a, b) => new boolean_1.default(a.toTruthy() && b.toTruthy()),
30
- [greyscript_core_1.Operator.Or]: (a, b) => new boolean_1.default(a.toTruthy() || b.toTruthy())
26
+ [greyscript_core_1.Operator.And]: (a, b) => new boolean_1.CustomBoolean(a.toTruthy() && b.toTruthy()),
27
+ [greyscript_core_1.Operator.Or]: (a, b) => new boolean_1.CustomBoolean(a.toTruthy() || b.toTruthy())
31
28
  };
32
29
  exports.NumberProcessorHandler = {
33
- [greyscript_core_1.Operator.Plus]: (a, b) => new number_1.default(a.toNumber() + b.toNumber()),
34
- [greyscript_core_1.Operator.Minus]: (a, b) => new number_1.default(a.toNumber() - b.toNumber()),
35
- [greyscript_core_1.Operator.Slash]: (a, b) => new number_1.default(a.toNumber() / b.toNumber()),
36
- [greyscript_core_1.Operator.Asterik]: (a, b) => new number_1.default(a.toNumber() * b.toNumber()),
37
- [greyscript_core_1.Operator.Power]: (a, b) => new number_1.default(Math.pow(a.toNumber(), b.toNumber())),
38
- [greyscript_core_1.Operator.BitwiseOr]: (a, b) => new number_1.default(a.toInt() | b.toInt()),
39
- [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.default(a.toNumber() < b.toNumber()),
40
- [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.default(a.toNumber() > b.toNumber()),
41
- [greyscript_core_1.Operator.LeftShift]: (a, b) => new number_1.default(a.toInt() << b.toInt()),
42
- [greyscript_core_1.Operator.RightShift]: (a, b) => new number_1.default(a.toInt() >> b.toInt()),
43
- [greyscript_core_1.Operator.UnsignedRightShift]: (a, b) => new number_1.default(a.toInt() >> b.toInt()),
44
- [greyscript_core_1.Operator.BitwiseAnd]: (a, b) => new number_1.default(a.toInt() & b.toInt()),
45
- [greyscript_core_1.Operator.PercentSign]: (a, b) => new number_1.default(a.toNumber() % b.toNumber()),
46
- [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.default(a.toNumber() >= b.toNumber()),
47
- [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a.toNumber() === b.toNumber()),
48
- [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.default(a.toNumber() <= b.toNumber()),
49
- [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a.toNumber() !== b.toNumber())
30
+ [greyscript_core_1.Operator.Plus]: (a, b) => new number_1.CustomNumber(a.toNumber() + b.toNumber()),
31
+ [greyscript_core_1.Operator.Minus]: (a, b) => new number_1.CustomNumber(a.toNumber() - b.toNumber()),
32
+ [greyscript_core_1.Operator.Slash]: (a, b) => new number_1.CustomNumber(a.toNumber() / b.toNumber()),
33
+ [greyscript_core_1.Operator.Asterik]: (a, b) => new number_1.CustomNumber(a.toNumber() * b.toNumber()),
34
+ [greyscript_core_1.Operator.Power]: (a, b) => new number_1.CustomNumber(Math.pow(a.toNumber(), b.toNumber())),
35
+ [greyscript_core_1.Operator.BitwiseOr]: (a, b) => new number_1.CustomNumber(a.toInt() | b.toInt()),
36
+ [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() < b.toNumber()),
37
+ [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() > b.toNumber()),
38
+ [greyscript_core_1.Operator.LeftShift]: (a, b) => new number_1.CustomNumber(a.toInt() << b.toInt()),
39
+ [greyscript_core_1.Operator.RightShift]: (a, b) => new number_1.CustomNumber(a.toInt() >> b.toInt()),
40
+ [greyscript_core_1.Operator.UnsignedRightShift]: (a, b) => new number_1.CustomNumber(a.toInt() >> b.toInt()),
41
+ [greyscript_core_1.Operator.BitwiseAnd]: (a, b) => new number_1.CustomNumber(a.toInt() & b.toInt()),
42
+ [greyscript_core_1.Operator.PercentSign]: (a, b) => new number_1.CustomNumber(a.toNumber() % b.toNumber()),
43
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() >= b.toNumber()),
44
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() === b.toNumber()),
45
+ [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() <= b.toNumber()),
46
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.CustomBoolean(a.toNumber() !== b.toNumber())
50
47
  };
51
48
  const multiplyString = (a, b) => {
52
49
  const multiStr = new Array(b.toNumber()).fill(a.toString()).join('');
53
- return new string_1.default(multiStr);
50
+ return new string_1.CustomString(multiStr);
54
51
  };
55
52
  exports.multiplyString = multiplyString;
56
53
  exports.StringProcessorHandler = {
57
- [greyscript_core_1.Operator.Plus]: (a, b) => new string_1.default(a.toString() + b.toString()),
54
+ [greyscript_core_1.Operator.Plus]: (a, b) => new string_1.CustomString(a.toString() + b.toString()),
58
55
  [greyscript_core_1.Operator.Asterik]: (a, b) => (0, exports.multiplyString)(a, b),
59
- [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.default(a.toString().length < b.toString().length),
60
- [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.default(a.toString().length > b.toString().length),
61
- [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.default(a.toString().length >= b.toString().length),
62
- [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a.toString() === b.toString()),
63
- [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.default(a.toString().length <= b.toString().length),
64
- [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a.toString() !== b.toString())
56
+ [greyscript_core_1.Operator.LessThan]: (a, b) => new boolean_1.CustomBoolean(a.toString().length < b.toString().length),
57
+ [greyscript_core_1.Operator.GreaterThan]: (a, b) => new boolean_1.CustomBoolean(a.toString().length > b.toString().length),
58
+ [greyscript_core_1.Operator.GreaterThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toString().length >= b.toString().length),
59
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.CustomBoolean(a.toString() === b.toString()),
60
+ [greyscript_core_1.Operator.LessThanOrEqual]: (a, b) => new boolean_1.CustomBoolean(a.toString().length <= b.toString().length),
61
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.CustomBoolean(a.toString() !== b.toString())
65
62
  };
66
63
  exports.ListProcessorHandler = {
67
64
  [greyscript_core_1.Operator.Plus]: (left, right) => {
68
- if (right instanceof list_1.default) {
65
+ if (right instanceof list_1.CustomList) {
69
66
  return left.fork().extend(right);
70
67
  }
71
68
  return left;
72
69
  },
73
70
  [greyscript_core_1.Operator.LessThan]: (left, right) => {
74
- if (right instanceof list_1.default) {
75
- return new boolean_1.default(left.value.length < right.value.length);
71
+ if (right instanceof list_1.CustomList) {
72
+ return new boolean_1.CustomBoolean(left.value.length < right.value.length);
76
73
  }
77
- return default_1.default.Void;
74
+ return default_1.DefaultType.Void;
78
75
  },
79
76
  [greyscript_core_1.Operator.GreaterThan]: (left, right) => {
80
- if (right instanceof list_1.default) {
81
- return new boolean_1.default(left.value.length > right.value.length);
77
+ if (right instanceof list_1.CustomList) {
78
+ return new boolean_1.CustomBoolean(left.value.length > right.value.length);
82
79
  }
83
- return default_1.default.Void;
80
+ return default_1.DefaultType.Void;
84
81
  },
85
82
  [greyscript_core_1.Operator.GreaterThanOrEqual]: (left, right) => {
86
- if (right instanceof list_1.default) {
87
- return new boolean_1.default(left.value.length >= right.value.length);
83
+ if (right instanceof list_1.CustomList) {
84
+ return new boolean_1.CustomBoolean(left.value.length >= right.value.length);
88
85
  }
89
- return default_1.default.Void;
86
+ return default_1.DefaultType.Void;
90
87
  },
91
88
  [greyscript_core_1.Operator.Equal]: (left, right) => {
92
- if (right instanceof list_1.default) {
93
- return new boolean_1.default((0, deep_equal_1.default)(left, right));
89
+ if (right instanceof list_1.CustomList) {
90
+ return new boolean_1.CustomBoolean((0, deep_equal_1.deepEqual)(left, right));
94
91
  }
95
- return default_1.default.Void;
92
+ return default_1.DefaultType.Void;
96
93
  },
97
94
  [greyscript_core_1.Operator.LessThanOrEqual]: (left, right) => {
98
- if (right instanceof list_1.default) {
99
- return new boolean_1.default(left.value.length <= right.value.length);
95
+ if (right instanceof list_1.CustomList) {
96
+ return new boolean_1.CustomBoolean(left.value.length <= right.value.length);
100
97
  }
101
- return default_1.default.Void;
98
+ return default_1.DefaultType.Void;
102
99
  },
103
100
  [greyscript_core_1.Operator.NotEqual]: (left, right) => {
104
- if (right instanceof list_1.default) {
105
- return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
101
+ if (right instanceof list_1.CustomList) {
102
+ return new boolean_1.CustomBoolean(!(0, deep_equal_1.deepEqual)(left, right));
106
103
  }
107
- return default_1.default.Void;
104
+ return default_1.DefaultType.Void;
108
105
  }
109
106
  };
110
107
  exports.MapProcessorHandler = {
111
108
  [greyscript_core_1.Operator.Plus]: (left, right) => {
112
- if (right instanceof map_1.default) {
109
+ if (right instanceof map_1.CustomMap) {
113
110
  return left.fork().extend(right);
114
111
  }
115
112
  return left;
116
113
  },
117
114
  [greyscript_core_1.Operator.LessThan]: (left, right) => {
118
- if (right instanceof map_1.default) {
119
- return new boolean_1.default(left.value.size < right.value.size);
115
+ if (right instanceof map_1.CustomMap) {
116
+ return new boolean_1.CustomBoolean(left.value.size < right.value.size);
120
117
  }
121
- return default_1.default.Void;
118
+ return default_1.DefaultType.Void;
122
119
  },
123
120
  [greyscript_core_1.Operator.GreaterThan]: (left, right) => {
124
- if (right instanceof map_1.default) {
125
- return new boolean_1.default(left.value.size > right.value.size);
121
+ if (right instanceof map_1.CustomMap) {
122
+ return new boolean_1.CustomBoolean(left.value.size > right.value.size);
126
123
  }
127
- return default_1.default.Void;
124
+ return default_1.DefaultType.Void;
128
125
  },
129
126
  [greyscript_core_1.Operator.GreaterThanOrEqual]: (left, right) => {
130
- if (right instanceof map_1.default) {
131
- return new boolean_1.default(left.value.size >= right.value.size);
127
+ if (right instanceof map_1.CustomMap) {
128
+ return new boolean_1.CustomBoolean(left.value.size >= right.value.size);
132
129
  }
133
- return default_1.default.Void;
130
+ return default_1.DefaultType.Void;
134
131
  },
135
132
  [greyscript_core_1.Operator.Equal]: (left, right) => {
136
- if (right instanceof map_1.default) {
137
- return new boolean_1.default((0, deep_equal_1.default)(left, right));
133
+ if (right instanceof map_1.CustomMap) {
134
+ return new boolean_1.CustomBoolean((0, deep_equal_1.deepEqual)(left, right));
138
135
  }
139
- return default_1.default.Void;
136
+ return default_1.DefaultType.Void;
140
137
  },
141
138
  [greyscript_core_1.Operator.LessThanOrEqual]: (left, right) => {
142
- if (right instanceof map_1.default) {
143
- return new boolean_1.default(left.value.size <= right.value.size);
139
+ if (right instanceof map_1.CustomMap) {
140
+ return new boolean_1.CustomBoolean(left.value.size <= right.value.size);
144
141
  }
145
- return default_1.default.Void;
142
+ return default_1.DefaultType.Void;
146
143
  },
147
144
  [greyscript_core_1.Operator.NotEqual]: (left, right) => {
148
- if (right instanceof map_1.default) {
149
- return new boolean_1.default(!(0, deep_equal_1.default)(left, right));
145
+ if (right instanceof map_1.CustomMap) {
146
+ return new boolean_1.CustomBoolean(!(0, deep_equal_1.deepEqual)(left, right));
150
147
  }
151
- return default_1.default.Void;
148
+ return default_1.DefaultType.Void;
152
149
  }
153
150
  };
154
151
  exports.InterfaceProcessorHandler = {
155
- [greyscript_core_1.Operator.Equal]: (left, right) => new boolean_1.default(left.value === right.value),
156
- [greyscript_core_1.Operator.NotEqual]: (left, right) => new boolean_1.default(left.value !== right.value)
152
+ [greyscript_core_1.Operator.Equal]: (left, right) => new boolean_1.CustomBoolean(left.value === right.value),
153
+ [greyscript_core_1.Operator.NotEqual]: (left, right) => new boolean_1.CustomBoolean(left.value !== right.value)
157
154
  };
158
155
  exports.NilProcessorHandler = {
159
- [greyscript_core_1.Operator.Equal]: (_a, b) => new boolean_1.default(b instanceof nil_1.default),
160
- [greyscript_core_1.Operator.NotEqual]: (_a, b) => new boolean_1.default(!(b instanceof nil_1.default))
156
+ [greyscript_core_1.Operator.Equal]: (_a, b) => new boolean_1.CustomBoolean(b instanceof nil_1.CustomNil),
157
+ [greyscript_core_1.Operator.NotEqual]: (_a, b) => new boolean_1.CustomBoolean(!(b instanceof nil_1.CustomNil))
161
158
  };
162
159
  exports.FunctionProcessorHandler = {
163
- [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.default(a === b),
164
- [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.default(a !== b)
160
+ [greyscript_core_1.Operator.Equal]: (a, b) => new boolean_1.CustomBoolean(a === b),
161
+ [greyscript_core_1.Operator.NotEqual]: (a, b) => new boolean_1.CustomBoolean(a !== b)
165
162
  };
166
163
  const handleNumber = (op, a, b) => {
167
164
  if (op in exports.NumberProcessorHandler) {
@@ -170,7 +167,7 @@ const handleNumber = (op, a, b) => {
170
167
  else if (op in exports.GenericProcessorHandler) {
171
168
  return exports.GenericProcessorHandler[op](a, b);
172
169
  }
173
- return default_1.default.Void;
170
+ return default_1.DefaultType.Void;
174
171
  };
175
172
  exports.handleNumber = handleNumber;
176
173
  const handleString = (op, a, b) => {
@@ -180,7 +177,7 @@ const handleString = (op, a, b) => {
180
177
  else if (op in exports.GenericProcessorHandler) {
181
178
  return exports.GenericProcessorHandler[op](a, b);
182
179
  }
183
- return default_1.default.Void;
180
+ return default_1.DefaultType.Void;
184
181
  };
185
182
  exports.handleString = handleString;
186
183
  const handleList = (op, a, b) => {
@@ -192,7 +189,7 @@ const handleList = (op, a, b) => {
192
189
  else if (op in exports.GenericProcessorHandler) {
193
190
  return exports.GenericProcessorHandler[op](a, b);
194
191
  }
195
- return default_1.default.Void;
192
+ return default_1.DefaultType.Void;
196
193
  };
197
194
  exports.handleList = handleList;
198
195
  const handleMap = (op, a, b) => {
@@ -204,7 +201,7 @@ const handleMap = (op, a, b) => {
204
201
  else if (op in exports.GenericProcessorHandler) {
205
202
  return exports.GenericProcessorHandler[op](a, b);
206
203
  }
207
- return default_1.default.Void;
204
+ return default_1.DefaultType.Void;
208
205
  };
209
206
  exports.handleMap = handleMap;
210
207
  const handleInterface = (op, a, b) => {
@@ -216,7 +213,7 @@ const handleInterface = (op, a, b) => {
216
213
  else if (op in exports.GenericProcessorHandler) {
217
214
  return exports.GenericProcessorHandler[op](a, b);
218
215
  }
219
- return default_1.default.Void;
216
+ return default_1.DefaultType.Void;
220
217
  };
221
218
  exports.handleInterface = handleInterface;
222
219
  const handleNil = (op, a, b) => {
@@ -226,7 +223,7 @@ const handleNil = (op, a, b) => {
226
223
  else if (op in exports.GenericProcessorHandler) {
227
224
  return exports.GenericProcessorHandler[op](a, b);
228
225
  }
229
- return default_1.default.Void;
226
+ return default_1.DefaultType.Void;
230
227
  };
231
228
  exports.handleNil = handleNil;
232
229
  const handleFunction = (op, a, b) => {
@@ -236,48 +233,48 @@ const handleFunction = (op, a, b) => {
236
233
  else if (op in exports.GenericProcessorHandler) {
237
234
  return exports.GenericProcessorHandler[op](a, b);
238
235
  }
239
- return default_1.default.Void;
236
+ return default_1.DefaultType.Void;
240
237
  };
241
238
  exports.handleFunction = handleFunction;
242
239
  const handle = (op, a, b) => {
243
- if (a instanceof boolean_1.default) {
244
- a = new number_1.default(a.toInt());
240
+ if (a instanceof boolean_1.CustomBoolean) {
241
+ a = new number_1.CustomNumber(a.toInt());
245
242
  }
246
- if (b instanceof boolean_1.default) {
247
- b = new number_1.default(b.toInt());
243
+ if (b instanceof boolean_1.CustomBoolean) {
244
+ b = new number_1.CustomNumber(b.toInt());
248
245
  }
249
246
  if (op === greyscript_core_1.Operator.Equal && a.getCustomType() !== b.getCustomType()) {
250
- return default_1.default.False;
247
+ return default_1.DefaultType.False;
251
248
  }
252
249
  else if (op === greyscript_core_1.Operator.NotEqual &&
253
250
  a.getCustomType() !== b.getCustomType()) {
254
- return default_1.default.True;
251
+ return default_1.DefaultType.True;
255
252
  }
256
- if (a instanceof string_1.default || b instanceof string_1.default) {
253
+ if (a instanceof string_1.CustomString || b instanceof string_1.CustomString) {
257
254
  return (0, exports.handleString)(op, a, b);
258
255
  }
259
- else if (a instanceof number_1.default || b instanceof number_1.default) {
256
+ else if (a instanceof number_1.CustomNumber || b instanceof number_1.CustomNumber) {
260
257
  return (0, exports.handleNumber)(op, a, b);
261
258
  }
262
- else if (a instanceof list_1.default) {
259
+ else if (a instanceof list_1.CustomList) {
263
260
  return (0, exports.handleList)(op, a, b);
264
261
  }
265
- else if (a instanceof map_1.default) {
262
+ else if (a instanceof map_1.CustomMap) {
266
263
  return (0, exports.handleMap)(op, a, b);
267
264
  }
268
- else if (a instanceof interface_1.default) {
265
+ else if (a instanceof interface_1.CustomInterface) {
269
266
  return (0, exports.handleInterface)(op, a, b);
270
267
  }
271
- else if (a instanceof function_1.default) {
268
+ else if (a instanceof function_1.CustomFunction) {
272
269
  return (0, exports.handleFunction)(op, a, b);
273
270
  }
274
- else if (a instanceof nil_1.default) {
271
+ else if (a instanceof nil_1.CustomNil) {
275
272
  return (0, exports.handleNil)(op, a, b);
276
273
  }
277
- return default_1.default.Void;
274
+ return default_1.DefaultType.Void;
278
275
  };
279
276
  exports.handle = handle;
280
- class Evaluate extends operation_1.default {
277
+ class Evaluate extends operation_1.Operation {
281
278
  constructor(item, target) {
282
279
  super(null, target);
283
280
  this.item = item;
@@ -302,10 +299,10 @@ class Evaluate extends operation_1.default {
302
299
  return __awaiter(this, void 0, void 0, function* () {
303
300
  const left = yield this.resolve(ctx, expr.left);
304
301
  if (expr.op === greyscript_core_1.Operator.And && !left.toTruthy()) {
305
- return new boolean_1.default(false);
302
+ return new boolean_1.CustomBoolean(false);
306
303
  }
307
304
  else if (expr.op === greyscript_core_1.Operator.Or && left.toTruthy()) {
308
- return new boolean_1.default(true);
305
+ return new boolean_1.CustomBoolean(true);
309
306
  }
310
307
  const right = yield this.resolve(ctx, expr.right);
311
308
  return (0, exports.handle)(expr.op, left, right);
@@ -319,7 +316,7 @@ class Evaluate extends operation_1.default {
319
316
  case greyscript_core_1.ASTType.IsaExpression: {
320
317
  const left = yield this.resolve(ctx, expr.left);
321
318
  const right = yield this.resolve(ctx, expr.right);
322
- return new boolean_1.default(left.instanceOf(right));
319
+ return new boolean_1.CustomBoolean(left.instanceOf(right));
323
320
  }
324
321
  case greyscript_core_1.ASTType.BinaryExpression:
325
322
  return this.resolveBinaryExpression(ctx, expr);
@@ -336,4 +333,4 @@ class Evaluate extends operation_1.default {
336
333
  return this.resolve(ctx, this);
337
334
  }
338
335
  }
339
- exports.default = Evaluate;
336
+ exports.Evaluate = Evaluate;
@@ -1,14 +1,14 @@
1
1
  import { ASTForGenericStatement, ASTIdentifier } 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 For 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 For extends Operation {
7
7
  readonly item: ASTForGenericStatement;
8
8
  block: Block;
9
9
  variable: ASTIdentifier;
10
10
  iterator: Operation;
11
11
  constructor(item: ASTForGenericStatement, target?: string);
12
12
  build(visit: CPSVisit): Promise<Operation>;
13
- handle(ctx: context): Promise<CustomValue>;
13
+ handle(ctx: OperationContext): Promise<CustomValue>;
14
14
  }