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
@@ -1,7 +1,7 @@
1
- import OperationContext from '../context';
2
- import Operation from '../operations/operation';
3
- import CustomValue from './base';
4
- import CustomMap from './map';
1
+ import { OperationContext } from '../context';
2
+ import { Operation } from '../operations/operation';
3
+ import { CustomValue } from './base';
4
+ import { CustomMap } from './map';
5
5
  export interface Callback {
6
6
  (ctx: OperationContext, self: CustomValue, args: Map<string, CustomValue>, next?: CustomValue): Promise<NonNullable<CustomValue>>;
7
7
  }
@@ -11,7 +11,7 @@ export declare class Argument {
11
11
  static createWithCustomValue(name: string, defaultValue: CustomValue): Argument;
12
12
  constructor(name: string, defaultValue?: Operation | CustomValue);
13
13
  }
14
- export default class CustomFunction extends CustomValue {
14
+ export declare class CustomFunction extends CustomValue {
15
15
  readonly scope?: OperationContext;
16
16
  readonly name: string;
17
17
  readonly value: Callback;
@@ -8,45 +8,34 @@ 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.Argument = void 0;
12
+ exports.CustomFunction = exports.Argument = void 0;
16
13
  const context_1 = require("../context");
17
- const operation_1 = __importDefault(require("../operations/operation"));
18
- const reference_1 = __importDefault(require("../operations/reference"));
19
- const base_1 = __importDefault(require("./base"));
20
- const default_1 = __importDefault(require("./default"));
21
- const map_1 = __importDefault(require("./map"));
22
- const nil_1 = __importDefault(require("./nil"));
14
+ const operation_1 = require("../operations/operation");
15
+ const reference_1 = require("../operations/reference");
16
+ const base_1 = require("./base");
17
+ const default_1 = require("./default");
18
+ const map_1 = require("./map");
19
+ const nil_1 = require("./nil");
23
20
  class Argument {
24
- constructor(name, defaultValue = default_1.default.Void) {
21
+ static createWithCustomValue(name, defaultValue) {
22
+ return new Argument(name, new reference_1.Reference(defaultValue));
23
+ }
24
+ constructor(name, defaultValue = default_1.DefaultType.Void) {
25
25
  this.name = name;
26
- if (defaultValue instanceof base_1.default) {
27
- this.defaultValue = new reference_1.default(defaultValue);
26
+ if (defaultValue instanceof base_1.CustomValue) {
27
+ this.defaultValue = new reference_1.Reference(defaultValue);
28
28
  }
29
- else if (defaultValue instanceof operation_1.default) {
29
+ else if (defaultValue instanceof operation_1.Operation) {
30
30
  this.defaultValue = defaultValue;
31
31
  }
32
32
  else {
33
33
  throw new Error('Invalid defaultValue in argument.');
34
34
  }
35
35
  }
36
- static createWithCustomValue(name, defaultValue) {
37
- return new Argument(name, new reference_1.default(defaultValue));
38
- }
39
36
  }
40
37
  exports.Argument = Argument;
41
- class CustomFunction extends base_1.default {
42
- constructor(scope, name, callback, injectSelf = false) {
43
- super();
44
- this.scope = scope;
45
- this.name = name;
46
- this.value = callback;
47
- this.injectSelf = injectSelf;
48
- this.argumentDefs = [];
49
- }
38
+ class CustomFunction extends base_1.CustomValue {
50
39
  static createExternalAnonymous(callback) {
51
40
  return new CustomFunction(null, 'anonymous', callback);
52
41
  }
@@ -56,11 +45,19 @@ class CustomFunction extends base_1.default {
56
45
  static createExternalWithSelf(name, callback) {
57
46
  return new CustomFunction(null, name, callback, true).addArgument('self');
58
47
  }
48
+ constructor(scope, name, callback, injectSelf = false) {
49
+ super();
50
+ this.scope = scope;
51
+ this.name = name;
52
+ this.value = callback;
53
+ this.injectSelf = injectSelf;
54
+ this.argumentDefs = [];
55
+ }
59
56
  setInjectSelf(injectSelf) {
60
57
  this.injectSelf = injectSelf;
61
58
  return this;
62
59
  }
63
- addArgument(name, defaultValue = default_1.default.Void) {
60
+ addArgument(name, defaultValue = default_1.DefaultType.Void) {
64
61
  this.argumentDefs.push(new Argument(name, defaultValue));
65
62
  return this;
66
63
  }
@@ -97,16 +94,16 @@ class CustomFunction extends base_1.default {
97
94
  state: context_1.ContextState.Default
98
95
  });
99
96
  const argMap = new Map();
100
- if (this.injectSelf && !(self instanceof nil_1.default)) {
97
+ if (this.injectSelf && !(self instanceof nil_1.CustomNil)) {
101
98
  args.unshift(self);
102
99
  }
103
100
  for (let index = 0; index < this.argumentDefs.length; index++) {
104
101
  const item = this.argumentDefs[index];
105
102
  argMap.set(item.name, args[index] || (yield item.defaultValue.handle(fnCtx)));
106
103
  }
107
- const isa = next || (self instanceof map_1.default ? self.isa : null);
104
+ const isa = next || (self instanceof map_1.CustomMap ? self.isa : null);
108
105
  return this.value(fnCtx || callContext, self, argMap, isa);
109
106
  });
110
107
  }
111
108
  }
112
- exports.default = CustomFunction;
109
+ exports.CustomFunction = CustomFunction;
@@ -1,11 +1,11 @@
1
- import Path from '../utils/path';
2
- import CustomValue from './base';
3
- import CustomFunction from './function';
1
+ import { Path } from '../utils/path';
2
+ import { CustomValue } from './base';
3
+ import { CustomFunction } from './function';
4
4
  import { CustomObject } from './with-intrinsics';
5
5
  export declare class CustomInterfaceIterator implements Iterator<CustomValue> {
6
6
  next(): IteratorResult<CustomValue>;
7
7
  }
8
- export default class CustomInterface extends CustomObject {
8
+ export declare class CustomInterface extends CustomObject {
9
9
  private readonly interfaceFns;
10
10
  private readonly type;
11
11
  readonly value: Object;
@@ -1,17 +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
- exports.CustomInterfaceIterator = void 0;
7
- const path_1 = __importDefault(require("../utils/path"));
8
- const base_1 = __importDefault(require("./base"));
9
- const default_1 = __importDefault(require("./default"));
3
+ exports.CustomInterface = exports.CustomInterfaceIterator = void 0;
4
+ const path_1 = require("../utils/path");
5
+ const base_1 = require("./base");
6
+ const default_1 = require("./default");
10
7
  const with_intrinsics_1 = require("./with-intrinsics");
11
8
  class CustomInterfaceIterator {
12
9
  next() {
13
10
  return {
14
- value: default_1.default.Void,
11
+ value: default_1.DefaultType.Void,
15
12
  done: true
16
13
  };
17
14
  }
@@ -52,8 +49,8 @@ class CustomInterface extends with_intrinsics_1.CustomObject {
52
49
  return new CustomInterfaceIterator();
53
50
  }
54
51
  has(path) {
55
- if (path instanceof base_1.default) {
56
- return this.has(new path_1.default([path]));
52
+ if (path instanceof base_1.CustomValue) {
53
+ return this.has(new path_1.Path([path]));
57
54
  }
58
55
  const traversalPath = path.clone();
59
56
  const current = traversalPath.next();
@@ -66,8 +63,8 @@ class CustomInterface extends with_intrinsics_1.CustomObject {
66
63
  throw new Error('Cannot set property on an interface.');
67
64
  }
68
65
  get(path) {
69
- if (path instanceof base_1.default) {
70
- return this.get(new path_1.default([path]));
66
+ if (path instanceof base_1.CustomValue) {
67
+ return this.get(new path_1.Path([path]));
71
68
  }
72
69
  if (path.count() === 0) {
73
70
  return this;
@@ -86,4 +83,4 @@ class CustomInterface extends with_intrinsics_1.CustomObject {
86
83
  return this;
87
84
  }
88
85
  }
89
- exports.default = CustomInterface;
86
+ exports.CustomInterface = CustomInterface;
@@ -1,6 +1,6 @@
1
- import ObjectValue from '../utils/object-value';
2
- import Path from '../utils/path';
3
- import CustomValue from './base';
1
+ import { ObjectValue } from '../utils/object-value';
2
+ import { Path } from '../utils/path';
3
+ import { CustomValue } from './base';
4
4
  import { CustomObject } from './with-intrinsics';
5
5
  export declare class CustomListIterator implements Iterator<CustomValue> {
6
6
  value: Array<CustomValue>;
@@ -8,7 +8,7 @@ export declare class CustomListIterator implements Iterator<CustomValue> {
8
8
  constructor(value: Array<CustomValue>);
9
9
  next(): IteratorResult<CustomValue>;
10
10
  }
11
- export default class CustomList extends CustomObject {
11
+ export declare class CustomList extends CustomObject {
12
12
  static readonly intrinsics: ObjectValue;
13
13
  static getItemIndex(item: CustomList, index: number): number;
14
14
  readonly value: Array<CustomValue>;
@@ -1,13 +1,10 @@
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.CustomListIterator = void 0;
7
- const object_value_1 = __importDefault(require("../utils/object-value"));
8
- const path_1 = __importDefault(require("../utils/path"));
9
- const base_1 = __importDefault(require("./base"));
10
- const number_1 = __importDefault(require("./number"));
3
+ exports.CustomList = exports.CustomListIterator = void 0;
4
+ const object_value_1 = require("../utils/object-value");
5
+ const path_1 = require("../utils/path");
6
+ const base_1 = require("./base");
7
+ const number_1 = require("./number");
11
8
  const with_intrinsics_1 = require("./with-intrinsics");
12
9
  class CustomListIterator {
13
10
  constructor(value) {
@@ -31,10 +28,6 @@ class CustomListIterator {
31
28
  }
32
29
  exports.CustomListIterator = CustomListIterator;
33
30
  class CustomList extends with_intrinsics_1.CustomObject {
34
- constructor(value = []) {
35
- super();
36
- this.value = [...value];
37
- }
38
31
  static getItemIndex(item, index) {
39
32
  let n = index | 0;
40
33
  if (n < 0)
@@ -43,6 +36,10 @@ class CustomList extends with_intrinsics_1.CustomObject {
43
36
  return -1;
44
37
  return n;
45
38
  }
39
+ constructor(value = []) {
40
+ super();
41
+ this.value = [...value];
42
+ }
46
43
  getCustomType() {
47
44
  return 'list';
48
45
  }
@@ -86,12 +83,12 @@ class CustomList extends with_intrinsics_1.CustomObject {
86
83
  return CustomList.getItemIndex(this, index);
87
84
  }
88
85
  has(path) {
89
- if (path instanceof base_1.default) {
90
- return this.has(new path_1.default([path]));
86
+ if (path instanceof base_1.CustomValue) {
87
+ return this.has(new path_1.Path([path]));
91
88
  }
92
89
  const traversalPath = path.clone();
93
90
  const current = traversalPath.next();
94
- if (current instanceof number_1.default) {
91
+ if (current instanceof number_1.CustomNumber) {
95
92
  const currentIndex = this.getItemIndex(current.toInt());
96
93
  const sub = this.value[currentIndex];
97
94
  if (sub) {
@@ -105,13 +102,13 @@ class CustomList extends with_intrinsics_1.CustomObject {
105
102
  return false;
106
103
  }
107
104
  set(path, newValue) {
108
- if (path instanceof base_1.default) {
109
- return this.set(new path_1.default([path]), newValue);
105
+ if (path instanceof base_1.CustomValue) {
106
+ return this.set(new path_1.Path([path]), newValue);
110
107
  }
111
108
  const traversalPath = path.clone();
112
109
  const last = traversalPath.last();
113
110
  const current = traversalPath.next();
114
- if (current instanceof number_1.default) {
111
+ if (current instanceof number_1.CustomNumber) {
115
112
  const currentIndex = this.getItemIndex(current.toInt());
116
113
  const sub = this.value[currentIndex];
117
114
  if (sub) {
@@ -123,7 +120,7 @@ class CustomList extends with_intrinsics_1.CustomObject {
123
120
  }
124
121
  throw new Error(`Cannot set path ${path.toString()}.`);
125
122
  }
126
- if (last instanceof number_1.default) {
123
+ if (last instanceof number_1.CustomNumber) {
127
124
  const lastIndex = this.getItemIndex(last.toInt());
128
125
  if (lastIndex >= 0 && lastIndex < this.value.length) {
129
126
  this.value[lastIndex] = newValue;
@@ -134,12 +131,12 @@ class CustomList extends with_intrinsics_1.CustomObject {
134
131
  throw new Error(`Index is not a number.`);
135
132
  }
136
133
  get(path) {
137
- if (path instanceof base_1.default) {
138
- return this.get(new path_1.default([path]));
134
+ if (path instanceof base_1.CustomValue) {
135
+ return this.get(new path_1.Path([path]));
139
136
  }
140
137
  const traversalPath = path.clone();
141
138
  const current = traversalPath.next();
142
- if (current instanceof number_1.default) {
139
+ if (current instanceof number_1.CustomNumber) {
143
140
  const currentIndex = this.getItemIndex(current.toInt());
144
141
  if (currentIndex >= 0 && currentIndex < this.value.length) {
145
142
  const sub = this.value[currentIndex];
@@ -160,5 +157,5 @@ class CustomList extends with_intrinsics_1.CustomObject {
160
157
  throw new Error(`Unknown path in list ${path.toString()}.`);
161
158
  }
162
159
  }
163
- exports.default = CustomList;
164
- CustomList.intrinsics = new object_value_1.default();
160
+ CustomList.intrinsics = new object_value_1.ObjectValue();
161
+ exports.CustomList = CustomList;
@@ -1,7 +1,7 @@
1
- import ObjectValue from '../utils/object-value';
2
- import Path from '../utils/path';
3
- import CustomValue from './base';
4
- import CustomString from './string';
1
+ import { ObjectValue } from '../utils/object-value';
2
+ import { Path } from '../utils/path';
3
+ import { CustomValue } from './base';
4
+ import { CustomString } from './string';
5
5
  import { CustomObject } from './with-intrinsics';
6
6
  export declare const CLASS_ID_PROPERTY: CustomString;
7
7
  export declare const ISA_PROPERTY: CustomString;
@@ -13,7 +13,7 @@ export declare class CustomMapIterator implements Iterator<CustomValue> {
13
13
  constructor(value: ObjectValue);
14
14
  next(): IteratorResult<CustomMap>;
15
15
  }
16
- export default class CustomMap extends CustomObject {
16
+ export declare class CustomMap extends CustomObject {
17
17
  static readonly intrinsics: ObjectValue;
18
18
  value: ObjectValue;
19
19
  readonly isa: CustomMap | null;
package/dist/types/map.js CHANGED
@@ -1,23 +1,20 @@
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.CustomMapIterator = exports.CUSTOM_MAP_MAX_DEPTH_VALUE = exports.CUSTOM_MAP_MAX_DEPTH = exports.ISA_PROPERTY = exports.CLASS_ID_PROPERTY = void 0;
7
- const object_value_1 = __importDefault(require("../utils/object-value"));
8
- const path_1 = __importDefault(require("../utils/path"));
9
- const base_1 = __importDefault(require("./base"));
3
+ exports.CustomMap = exports.CustomMapIterator = exports.CUSTOM_MAP_MAX_DEPTH_VALUE = exports.CUSTOM_MAP_MAX_DEPTH = exports.ISA_PROPERTY = exports.CLASS_ID_PROPERTY = void 0;
4
+ const object_value_1 = require("../utils/object-value");
5
+ const path_1 = require("../utils/path");
6
+ const base_1 = require("./base");
10
7
  const nil_1 = require("./nil");
11
- const string_1 = __importDefault(require("./string"));
8
+ const string_1 = require("./string");
12
9
  const with_intrinsics_1 = require("./with-intrinsics");
13
- exports.CLASS_ID_PROPERTY = new string_1.default('classID');
14
- exports.ISA_PROPERTY = new string_1.default('__isa');
10
+ exports.CLASS_ID_PROPERTY = new string_1.CustomString('classID');
11
+ exports.ISA_PROPERTY = new string_1.CustomString('__isa');
15
12
  exports.CUSTOM_MAP_MAX_DEPTH = 2;
16
13
  exports.CUSTOM_MAP_MAX_DEPTH_VALUE = '{...}';
17
14
  class CustomMapIterator {
18
15
  constructor(value) {
19
16
  const me = this;
20
- me.value = new object_value_1.default(value);
17
+ me.value = new object_value_1.ObjectValue(value);
21
18
  me.index = 0;
22
19
  }
23
20
  next() {
@@ -31,9 +28,9 @@ class CustomMapIterator {
31
28
  }
32
29
  const key = keys[me.index++];
33
30
  return {
34
- value: new CustomMap(new object_value_1.default([
35
- [new string_1.default('key'), key],
36
- [new string_1.default('value'), me.value.get(key)]
31
+ value: new CustomMap(new object_value_1.ObjectValue([
32
+ [new string_1.CustomString('key'), key],
33
+ [new string_1.CustomString('value'), me.value.get(key)]
37
34
  ])),
38
35
  done: false
39
36
  };
@@ -41,17 +38,17 @@ class CustomMapIterator {
41
38
  }
42
39
  exports.CustomMapIterator = CustomMapIterator;
43
40
  class CustomMap extends with_intrinsics_1.CustomObject {
44
- constructor(value, isa = null) {
45
- super();
46
- this.isInstance = false;
47
- this.value = new object_value_1.default(value);
48
- this.isa = isa;
49
- }
50
41
  static createWithInitialValue(value) {
51
42
  const map = new CustomMap();
52
43
  map.value = value;
53
44
  return map;
54
45
  }
46
+ constructor(value, isa = null) {
47
+ super();
48
+ this.isInstance = false;
49
+ this.value = new object_value_1.ObjectValue(value);
50
+ this.isa = isa;
51
+ }
55
52
  getCustomType() {
56
53
  if (this.value.has(exports.CLASS_ID_PROPERTY)) {
57
54
  return this.value.get(exports.CLASS_ID_PROPERTY).toString();
@@ -111,8 +108,8 @@ class CustomMap extends with_intrinsics_1.CustomObject {
111
108
  return this;
112
109
  }
113
110
  has(path) {
114
- if (path instanceof base_1.default) {
115
- return this.has(new path_1.default([path]));
111
+ if (path instanceof base_1.CustomValue) {
112
+ return this.has(new path_1.Path([path]));
116
113
  }
117
114
  const traversalPath = path.clone();
118
115
  const current = traversalPath.next();
@@ -130,8 +127,8 @@ class CustomMap extends with_intrinsics_1.CustomObject {
130
127
  return false;
131
128
  }
132
129
  set(path, newValue) {
133
- if (path instanceof base_1.default) {
134
- return this.set(new path_1.default([path]), newValue);
130
+ if (path instanceof base_1.CustomValue) {
131
+ return this.set(new path_1.Path([path]), newValue);
135
132
  }
136
133
  const traversalPath = path.clone();
137
134
  const last = traversalPath.last();
@@ -150,8 +147,8 @@ class CustomMap extends with_intrinsics_1.CustomObject {
150
147
  }
151
148
  get(path) {
152
149
  var _a, _b;
153
- if (path instanceof base_1.default) {
154
- return this.get(new path_1.default([path]));
150
+ if (path instanceof base_1.CustomValue) {
151
+ return this.get(new path_1.Path([path]));
155
152
  }
156
153
  const traversalPath = path.clone();
157
154
  const current = traversalPath.next();
@@ -188,10 +185,10 @@ class CustomMap extends with_intrinsics_1.CustomObject {
188
185
  throw new Error(`Unknown path in map ${path.toString()}.`);
189
186
  }
190
187
  createInstance() {
191
- const newInstance = new CustomMap(new object_value_1.default(), this);
188
+ const newInstance = new CustomMap(new object_value_1.ObjectValue(), this);
192
189
  newInstance.isInstance = true;
193
190
  return newInstance;
194
191
  }
195
192
  }
196
- exports.default = CustomMap;
197
- CustomMap.intrinsics = new object_value_1.default();
193
+ CustomMap.intrinsics = new object_value_1.ObjectValue();
194
+ exports.CustomMap = CustomMap;
@@ -1,5 +1,5 @@
1
- import CustomValue from './base';
2
- export default class CustomNil extends CustomValue {
1
+ import { CustomValue } from './base';
2
+ export declare class CustomNil extends CustomValue {
3
3
  value: null;
4
4
  getCustomType(): string;
5
5
  toJSON(): string;
package/dist/types/nil.js CHANGED
@@ -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.Void = void 0;
7
- const base_1 = __importDefault(require("./base"));
8
- class CustomNil extends base_1.default {
3
+ exports.Void = exports.CustomNil = void 0;
4
+ const base_1 = require("./base");
5
+ class CustomNil extends base_1.CustomValue {
9
6
  constructor() {
10
7
  super(...arguments);
11
8
  this.value = null;
@@ -35,5 +32,5 @@ class CustomNil extends base_1.default {
35
32
  return v instanceof CustomNil;
36
33
  }
37
34
  }
38
- exports.default = CustomNil;
35
+ exports.CustomNil = CustomNil;
39
36
  exports.Void = new CustomNil();
@@ -1,11 +1,11 @@
1
- import ObjectValue from '../utils/object-value';
2
- import Path from '../utils/path';
3
- import CustomValue from './base';
1
+ import { ObjectValue } from '../utils/object-value';
2
+ import { Path } from '../utils/path';
3
+ import { CustomValue } from './base';
4
4
  import { CustomValueWithIntrinsics } from './with-intrinsics';
5
5
  export declare class CustomNumberIterator implements Iterator<CustomValue> {
6
6
  next(): IteratorResult<CustomValue>;
7
7
  }
8
- export default class CustomNumber extends CustomValueWithIntrinsics {
8
+ export declare class CustomNumber extends CustomValueWithIntrinsics {
9
9
  static readonly intrinsics: ObjectValue;
10
10
  readonly value: number;
11
11
  constructor(value: number);
@@ -1,12 +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
- exports.Zero = exports.PositiveOne = exports.NegativeOne = exports.CustomNumberIterator = void 0;
7
- const object_value_1 = __importDefault(require("../utils/object-value"));
8
- const path_1 = __importDefault(require("../utils/path"));
9
- const base_1 = __importDefault(require("./base"));
3
+ exports.Zero = exports.PositiveOne = exports.NegativeOne = exports.CustomNumber = exports.CustomNumberIterator = void 0;
4
+ const object_value_1 = require("../utils/object-value");
5
+ const path_1 = require("../utils/path");
6
+ const base_1 = require("./base");
10
7
  const nil_1 = require("./nil");
11
8
  const with_intrinsics_1 = require("./with-intrinsics");
12
9
  class CustomNumberIterator {
@@ -57,8 +54,8 @@ class CustomNumber extends with_intrinsics_1.CustomValueWithIntrinsics {
57
54
  throw new Error('Mutable operations are not allowed on a number.');
58
55
  }
59
56
  get(path) {
60
- if (path instanceof base_1.default) {
61
- return this.get(new path_1.default([path]));
57
+ if (path instanceof base_1.CustomValue) {
58
+ return this.get(new path_1.Path([path]));
62
59
  }
63
60
  const traversalPath = path.clone();
64
61
  const current = traversalPath.next();
@@ -68,8 +65,8 @@ class CustomNumber extends with_intrinsics_1.CustomValueWithIntrinsics {
68
65
  return nil_1.Void;
69
66
  }
70
67
  }
71
- exports.default = CustomNumber;
72
- CustomNumber.intrinsics = new object_value_1.default();
68
+ CustomNumber.intrinsics = new object_value_1.ObjectValue();
69
+ exports.CustomNumber = CustomNumber;
73
70
  exports.NegativeOne = new CustomNumber(-1);
74
71
  exports.PositiveOne = new CustomNumber(1);
75
72
  exports.Zero = new CustomNumber(0);
@@ -1,6 +1,6 @@
1
- import ObjectValue from '../utils/object-value';
2
- import Path from '../utils/path';
3
- import CustomValue from './base';
1
+ import { ObjectValue } from '../utils/object-value';
2
+ import { Path } from '../utils/path';
3
+ import { CustomValue } from './base';
4
4
  import { CustomValueWithIntrinsics } from './with-intrinsics';
5
5
  export declare class CustomStringIterator implements Iterator<CustomValue> {
6
6
  value: string;
@@ -8,7 +8,7 @@ export declare class CustomStringIterator implements Iterator<CustomValue> {
8
8
  constructor(value: string);
9
9
  next(): IteratorResult<CustomValue>;
10
10
  }
11
- export default class CustomString extends CustomValueWithIntrinsics {
11
+ export declare class CustomString extends CustomValueWithIntrinsics {
12
12
  static readonly intrinsics: ObjectValue;
13
13
  static getCharIndex(item: CustomString, index: number): number;
14
14
  readonly value: string;
@@ -1,14 +1,11 @@
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.CustomStringIterator = void 0;
7
- const object_value_1 = __importDefault(require("../utils/object-value"));
8
- const path_1 = __importDefault(require("../utils/path"));
9
- const base_1 = __importDefault(require("./base"));
10
- const default_1 = __importDefault(require("./default"));
11
- const number_1 = __importDefault(require("./number"));
3
+ exports.CustomString = exports.CustomStringIterator = void 0;
4
+ const object_value_1 = require("../utils/object-value");
5
+ const path_1 = require("../utils/path");
6
+ const base_1 = require("./base");
7
+ const default_1 = require("./default");
8
+ const number_1 = require("./number");
12
9
  const with_intrinsics_1 = require("./with-intrinsics");
13
10
  class CustomStringIterator {
14
11
  constructor(value) {
@@ -32,10 +29,6 @@ class CustomStringIterator {
32
29
  }
33
30
  exports.CustomStringIterator = CustomStringIterator;
34
31
  class CustomString extends with_intrinsics_1.CustomValueWithIntrinsics {
35
- constructor(value) {
36
- super();
37
- this.value = value;
38
- }
39
32
  static getCharIndex(item, index) {
40
33
  let n = index | 0;
41
34
  if (n < 0)
@@ -44,6 +37,10 @@ class CustomString extends with_intrinsics_1.CustomValueWithIntrinsics {
44
37
  return -1;
45
38
  return n;
46
39
  }
40
+ constructor(value) {
41
+ super();
42
+ this.value = value;
43
+ }
47
44
  getCustomType() {
48
45
  return 'string';
49
46
  }
@@ -88,12 +85,12 @@ class CustomString extends with_intrinsics_1.CustomValueWithIntrinsics {
88
85
  return CustomString.getCharIndex(this, index);
89
86
  }
90
87
  has(path) {
91
- if (path instanceof base_1.default) {
92
- return this.has(new path_1.default([path]));
88
+ if (path instanceof base_1.CustomValue) {
89
+ return this.has(new path_1.Path([path]));
93
90
  }
94
91
  const traversalPath = path.clone();
95
92
  const current = traversalPath.next();
96
- if (current instanceof number_1.default) {
93
+ if (current instanceof number_1.CustomNumber) {
97
94
  const index = current.toInt();
98
95
  return !!this.value[index];
99
96
  }
@@ -103,12 +100,12 @@ class CustomString extends with_intrinsics_1.CustomValueWithIntrinsics {
103
100
  throw new Error('Mutable operations are not allowed on a string.');
104
101
  }
105
102
  get(path) {
106
- if (path instanceof base_1.default) {
107
- return this.get(new path_1.default([path]));
103
+ if (path instanceof base_1.CustomValue) {
104
+ return this.get(new path_1.Path([path]));
108
105
  }
109
106
  const traversalPath = path.clone();
110
107
  const current = traversalPath.next();
111
- if (current instanceof number_1.default) {
108
+ if (current instanceof number_1.CustomNumber) {
112
109
  const currentIndex = this.getCharIndex(current.toInt());
113
110
  const segment = this.value[currentIndex];
114
111
  if (segment) {
@@ -120,8 +117,8 @@ class CustomString extends with_intrinsics_1.CustomValueWithIntrinsics {
120
117
  CustomString.getIntrinsics().has(current)) {
121
118
  return CustomString.intrinsics.get(current);
122
119
  }
123
- return default_1.default.Void;
120
+ return default_1.DefaultType.Void;
124
121
  }
125
122
  }
126
- exports.default = CustomString;
127
- CustomString.intrinsics = new object_value_1.default();
123
+ CustomString.intrinsics = new object_value_1.ObjectValue();
124
+ exports.CustomString = CustomString;
@@ -1,7 +1,7 @@
1
- import ObjectValue from '../utils/object-value';
2
- import Path from '../utils/path';
3
- import CustomValue from './base';
4
- import CustomFunction from './function';
1
+ import { ObjectValue } from '../utils/object-value';
2
+ import { Path } from '../utils/path';
3
+ import { CustomValue } from './base';
4
+ import { CustomFunction } from './function';
5
5
  export declare abstract class CustomValueWithIntrinsics extends CustomValue {
6
6
  abstract has(path: Path<CustomValue> | CustomValue): boolean;
7
7
  abstract set(path: Path<CustomValue> | CustomValue, value: CustomValue): void;