greybel-interpreter 1.4.4 → 1.4.6
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.
- package/dist/context.d.ts +3 -2
- package/dist/context.js +113 -190
- package/dist/cps.js +135 -188
- package/dist/handler/error.js +6 -29
- package/dist/handler/output.js +15 -38
- package/dist/handler/resource.js +16 -39
- package/dist/handler-container.js +6 -8
- package/dist/index.d.ts +4 -3
- package/dist/index.js +10 -9
- package/dist/interpreter.d.ts +5 -4
- package/dist/interpreter.js +109 -203
- package/dist/operations/assign.d.ts +1 -1
- package/dist/operations/assign.js +28 -93
- package/dist/operations/block.d.ts +1 -1
- package/dist/operations/block.js +33 -89
- package/dist/operations/break.d.ts +1 -1
- package/dist/operations/break.js +11 -29
- package/dist/operations/call.d.ts +1 -1
- package/dist/operations/call.js +31 -106
- package/dist/operations/chunk.d.ts +1 -1
- package/dist/operations/chunk.js +15 -67
- package/dist/operations/continue.d.ts +1 -1
- package/dist/operations/continue.js +11 -29
- package/dist/operations/debugger-statement.d.ts +1 -1
- package/dist/operations/debugger-statement.js +11 -29
- package/dist/operations/evaluate.d.ts +1 -1
- package/dist/operations/evaluate.js +143 -247
- package/dist/operations/for.d.ts +1 -1
- package/dist/operations/for.js +62 -133
- package/dist/operations/function-reference.d.ts +1 -1
- package/dist/operations/function-reference.js +25 -84
- package/dist/operations/function.d.ts +1 -1
- package/dist/operations/function.js +49 -177
- package/dist/operations/if-statement.d.ts +1 -1
- package/dist/operations/if-statement.js +58 -154
- package/dist/operations/import.d.ts +1 -1
- package/dist/operations/import.js +35 -97
- package/dist/operations/include.d.ts +1 -1
- package/dist/operations/include.js +19 -73
- package/dist/operations/list.d.ts +1 -1
- package/dist/operations/list.js +24 -93
- package/dist/operations/literal.d.ts +1 -1
- package/dist/operations/literal.js +15 -33
- package/dist/operations/map.d.ts +1 -1
- package/dist/operations/map.js +26 -153
- package/dist/operations/negated-binary.d.ts +1 -1
- package/dist/operations/negated-binary.js +24 -91
- package/dist/operations/new-instance.d.ts +1 -1
- package/dist/operations/new-instance.js +21 -82
- package/dist/operations/noop.d.ts +1 -1
- package/dist/operations/noop.js +10 -27
- package/dist/operations/not.d.ts +1 -1
- package/dist/operations/not.js +17 -78
- package/dist/operations/operation.d.ts +2 -2
- package/dist/operations/operation.js +3 -5
- package/dist/operations/reference.d.ts +1 -1
- package/dist/operations/reference.js +10 -28
- package/dist/operations/resolve.d.ts +1 -1
- package/dist/operations/resolve.js +161 -281
- package/dist/operations/return.d.ts +1 -1
- package/dist/operations/return.js +27 -89
- package/dist/operations/while.d.ts +1 -1
- package/dist/operations/while.js +45 -116
- package/dist/types/base.d.ts +9 -0
- package/dist/types/base.js +5 -0
- package/dist/types/boolean.d.ts +3 -1
- package/dist/types/boolean.js +24 -36
- package/dist/types/default.d.ts +6 -9
- package/dist/types/default.js +11 -17
- package/dist/types/function.d.ts +1 -1
- package/dist/types/function.js +60 -130
- package/dist/types/interface.d.ts +2 -1
- package/dist/types/interface.js +44 -64
- package/dist/types/list.d.ts +4 -6
- package/dist/types/list.js +77 -128
- package/dist/types/map.d.ts +11 -15
- package/dist/types/map.js +101 -267
- package/dist/types/nil.d.ts +2 -1
- package/dist/types/nil.js +23 -36
- package/dist/types/number.d.ts +16 -2
- package/dist/types/number.js +60 -37
- package/dist/types/string.d.ts +4 -6
- package/dist/types/string.js +66 -90
- package/dist/types/{generics.d.ts → with-intrinsics.d.ts} +6 -9
- package/dist/types/with-intrinsics.js +19 -0
- package/dist/utils/deep-equal.js +9 -34
- package/dist/utils/object-value.d.ts +7 -0
- package/dist/utils/object-value.js +42 -0
- package/dist/utils/path.js +16 -43
- package/package.json +3 -3
- package/dist/intrinsics-container.d.ts +0 -7
- package/dist/intrinsics-container.js +0 -19
- package/dist/types/generics.js +0 -40
package/dist/types/interface.js
CHANGED
|
@@ -1,103 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
6
|
exports.CustomInterfaceIterator = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
CustomInterfaceIterator.prototype.next = function () {
|
|
7
|
+
const path_1 = __importDefault(require("../utils/path"));
|
|
8
|
+
const base_1 = __importDefault(require("./base"));
|
|
9
|
+
const default_1 = __importDefault(require("./default"));
|
|
10
|
+
const with_intrinsics_1 = require("./with-intrinsics");
|
|
11
|
+
class CustomInterfaceIterator {
|
|
12
|
+
next() {
|
|
29
13
|
return {
|
|
30
14
|
value: default_1.default.Void,
|
|
31
15
|
done: true
|
|
32
16
|
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
36
19
|
exports.CustomInterfaceIterator = CustomInterfaceIterator;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_this.interfaceFns = new Map();
|
|
44
|
-
return _this;
|
|
20
|
+
class CustomInterface extends with_intrinsics_1.CustomObject {
|
|
21
|
+
constructor(type) {
|
|
22
|
+
super();
|
|
23
|
+
this.value = {};
|
|
24
|
+
this.type = type;
|
|
25
|
+
this.interfaceFns = new Map();
|
|
45
26
|
}
|
|
46
|
-
|
|
27
|
+
getCustomType() {
|
|
47
28
|
return this.type;
|
|
48
|
-
}
|
|
49
|
-
|
|
29
|
+
}
|
|
30
|
+
toString() {
|
|
50
31
|
return this.type;
|
|
51
|
-
}
|
|
52
|
-
|
|
32
|
+
}
|
|
33
|
+
fork() {
|
|
53
34
|
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
35
|
+
}
|
|
36
|
+
toNumber() {
|
|
56
37
|
return Number.NaN;
|
|
57
|
-
}
|
|
58
|
-
|
|
38
|
+
}
|
|
39
|
+
toInt() {
|
|
59
40
|
return 0;
|
|
60
|
-
}
|
|
61
|
-
|
|
41
|
+
}
|
|
42
|
+
toTruthy() {
|
|
62
43
|
return true;
|
|
63
|
-
}
|
|
64
|
-
|
|
44
|
+
}
|
|
45
|
+
[Symbol.iterator]() {
|
|
65
46
|
return new CustomInterfaceIterator();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (path instanceof
|
|
47
|
+
}
|
|
48
|
+
has(path) {
|
|
49
|
+
if (path instanceof base_1.default) {
|
|
69
50
|
return this.has(new path_1.default([path]));
|
|
70
51
|
}
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
const traversalPath = path.clone();
|
|
53
|
+
const current = traversalPath.next();
|
|
73
54
|
if (current !== null) {
|
|
74
55
|
return this.interfaceFns.has(current.toString());
|
|
75
56
|
}
|
|
76
57
|
return false;
|
|
77
|
-
}
|
|
78
|
-
|
|
58
|
+
}
|
|
59
|
+
set(_path, _newValue) {
|
|
79
60
|
throw new Error('Cannot set property on an interface.');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (path instanceof
|
|
61
|
+
}
|
|
62
|
+
get(path) {
|
|
63
|
+
if (path instanceof base_1.default) {
|
|
83
64
|
return this.get(new path_1.default([path]));
|
|
84
65
|
}
|
|
85
66
|
if (path.count() === 0) {
|
|
86
67
|
return this;
|
|
87
68
|
}
|
|
88
|
-
|
|
89
|
-
|
|
69
|
+
const traversalPath = path.clone();
|
|
70
|
+
const current = traversalPath.next();
|
|
90
71
|
if (current !== null) {
|
|
91
72
|
if (this.interfaceFns.has(current.toString())) {
|
|
92
73
|
return this.interfaceFns.get(current.toString());
|
|
93
74
|
}
|
|
94
75
|
}
|
|
95
|
-
throw new Error(
|
|
96
|
-
}
|
|
97
|
-
|
|
76
|
+
throw new Error(`Unknown path in interface ${path.toString()}.`);
|
|
77
|
+
}
|
|
78
|
+
addFunction(name, fn) {
|
|
98
79
|
this.interfaceFns.set(name, fn);
|
|
99
80
|
return this;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}(generics_1.CustomObject));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
103
83
|
exports.default = CustomInterface;
|
package/dist/types/list.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectValue from '../utils/object-value';
|
|
2
2
|
import Path from '../utils/path';
|
|
3
|
-
import
|
|
4
|
-
import { CustomObject
|
|
3
|
+
import CustomValue from './base';
|
|
4
|
+
import { CustomObject } from './with-intrinsics';
|
|
5
5
|
export declare class CustomListIterator implements Iterator<CustomValue> {
|
|
6
6
|
value: Array<CustomValue>;
|
|
7
7
|
index: number;
|
|
@@ -9,10 +9,8 @@ export declare class CustomListIterator implements Iterator<CustomValue> {
|
|
|
9
9
|
next(): IteratorResult<CustomValue>;
|
|
10
10
|
}
|
|
11
11
|
export default class CustomList extends CustomObject {
|
|
12
|
+
static readonly intrinsics: ObjectValue;
|
|
12
13
|
static getItemIndex(item: CustomList, index: number): number;
|
|
13
|
-
private static intrinsics;
|
|
14
|
-
static getIntrinsics(): IntrinsicsContainer;
|
|
15
|
-
static addIntrinsic(name: string, fn: CustomFunction): void;
|
|
16
14
|
readonly value: Array<CustomValue>;
|
|
17
15
|
constructor(value?: Array<CustomValue>);
|
|
18
16
|
getCustomType(): string;
|
package/dist/types/list.js
CHANGED
|
@@ -1,61 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
4
|
};
|
|
45
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
6
|
exports.CustomListIterator = void 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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"));
|
|
11
|
+
const with_intrinsics_1 = require("./with-intrinsics");
|
|
12
|
+
class CustomListIterator {
|
|
13
|
+
constructor(value) {
|
|
14
|
+
const me = this;
|
|
54
15
|
me.value = value;
|
|
55
16
|
me.index = 0;
|
|
56
17
|
}
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
next() {
|
|
19
|
+
const me = this;
|
|
59
20
|
if (me.index === me.value.length) {
|
|
60
21
|
return {
|
|
61
22
|
value: null,
|
|
@@ -66,128 +27,118 @@ var CustomListIterator = /** @class */ (function () {
|
|
|
66
27
|
value: me.value[me.index++],
|
|
67
28
|
done: false
|
|
68
29
|
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
72
32
|
exports.CustomListIterator = CustomListIterator;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
CustomList.getItemIndex = function (item, index) {
|
|
82
|
-
var n = index | 0;
|
|
33
|
+
class CustomList extends with_intrinsics_1.CustomObject {
|
|
34
|
+
constructor(value = []) {
|
|
35
|
+
super();
|
|
36
|
+
this.value = [...value];
|
|
37
|
+
}
|
|
38
|
+
static getItemIndex(item, index) {
|
|
39
|
+
let n = index | 0;
|
|
83
40
|
if (n < 0)
|
|
84
41
|
n += item.value.length;
|
|
85
42
|
if (n < 0 || n >= item.value.length)
|
|
86
43
|
return -1;
|
|
87
44
|
return n;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return this.intrinsics;
|
|
91
|
-
};
|
|
92
|
-
CustomList.addIntrinsic = function (name, fn) {
|
|
93
|
-
this.intrinsics.add(name, fn);
|
|
94
|
-
};
|
|
95
|
-
CustomList.prototype.getCustomType = function () {
|
|
45
|
+
}
|
|
46
|
+
getCustomType() {
|
|
96
47
|
return 'list';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return
|
|
100
|
-
}
|
|
101
|
-
|
|
48
|
+
}
|
|
49
|
+
toString() {
|
|
50
|
+
return `[ ${this.value.join(', ')} ]`;
|
|
51
|
+
}
|
|
52
|
+
fork() {
|
|
102
53
|
return new CustomList(this.value);
|
|
103
|
-
}
|
|
104
|
-
|
|
54
|
+
}
|
|
55
|
+
toNumber() {
|
|
105
56
|
return 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
57
|
+
}
|
|
58
|
+
toInt() {
|
|
108
59
|
return 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
60
|
+
}
|
|
61
|
+
toTruthy() {
|
|
111
62
|
return this.value.length > 0;
|
|
112
|
-
}
|
|
113
|
-
|
|
63
|
+
}
|
|
64
|
+
slice(a, b) {
|
|
114
65
|
return new CustomList(this.value.slice(a.toNumber(), b.toNumber()));
|
|
115
|
-
}
|
|
116
|
-
|
|
66
|
+
}
|
|
67
|
+
extend(list) {
|
|
117
68
|
if (list instanceof CustomList) {
|
|
118
69
|
list = list.value;
|
|
119
70
|
}
|
|
120
|
-
for (
|
|
71
|
+
for (let index = 0; index < list.length; index++) {
|
|
121
72
|
this.value.push(list[index]);
|
|
122
73
|
}
|
|
123
74
|
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
75
|
+
}
|
|
76
|
+
[Symbol.iterator]() {
|
|
126
77
|
return new CustomListIterator(this.value);
|
|
127
|
-
}
|
|
128
|
-
|
|
78
|
+
}
|
|
79
|
+
getItemIndex(index) {
|
|
129
80
|
return CustomList.getItemIndex(this, index);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (path instanceof
|
|
81
|
+
}
|
|
82
|
+
has(path) {
|
|
83
|
+
if (path instanceof base_1.default) {
|
|
133
84
|
return this.has(new path_1.default([path]));
|
|
134
85
|
}
|
|
135
|
-
|
|
136
|
-
|
|
86
|
+
const traversalPath = path.clone();
|
|
87
|
+
const current = traversalPath.next();
|
|
137
88
|
if (current instanceof number_1.default) {
|
|
138
|
-
|
|
139
|
-
|
|
89
|
+
const currentIndex = this.getItemIndex(current.toInt());
|
|
90
|
+
const sub = this.value[currentIndex];
|
|
140
91
|
if (sub) {
|
|
141
92
|
if (traversalPath.count() > 0 &&
|
|
142
|
-
sub instanceof
|
|
93
|
+
sub instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
143
94
|
return sub.has(traversalPath);
|
|
144
95
|
}
|
|
145
96
|
return traversalPath.count() === 0;
|
|
146
97
|
}
|
|
147
98
|
}
|
|
148
99
|
return false;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (path instanceof
|
|
100
|
+
}
|
|
101
|
+
set(path, newValue) {
|
|
102
|
+
if (path instanceof base_1.default) {
|
|
152
103
|
return this.set(new path_1.default([path]), newValue);
|
|
153
104
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
105
|
+
const traversalPath = path.clone();
|
|
106
|
+
const last = traversalPath.last();
|
|
107
|
+
const current = traversalPath.next();
|
|
157
108
|
if (current instanceof number_1.default) {
|
|
158
|
-
|
|
159
|
-
|
|
109
|
+
const currentIndex = this.getItemIndex(current.toInt());
|
|
110
|
+
const sub = this.value[currentIndex];
|
|
160
111
|
if (sub) {
|
|
161
112
|
if (traversalPath.count() > 0 &&
|
|
162
|
-
sub instanceof
|
|
113
|
+
sub instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
163
114
|
sub.set(traversalPath, newValue);
|
|
164
115
|
return;
|
|
165
116
|
}
|
|
166
117
|
}
|
|
167
|
-
throw new Error(
|
|
118
|
+
throw new Error(`Cannot set path ${path.toString()}.`);
|
|
168
119
|
}
|
|
169
120
|
if (last instanceof number_1.default) {
|
|
170
|
-
|
|
121
|
+
const lastIndex = this.getItemIndex(last.toInt());
|
|
171
122
|
if (lastIndex >= 0 && lastIndex < this.value.length) {
|
|
172
123
|
this.value[lastIndex] = newValue;
|
|
173
124
|
return;
|
|
174
125
|
}
|
|
175
|
-
throw new Error(
|
|
126
|
+
throw new Error(`Index error (list index ${lastIndex} out of range).`);
|
|
176
127
|
}
|
|
177
|
-
throw new Error(
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (path instanceof
|
|
128
|
+
throw new Error(`Index is not a number.`);
|
|
129
|
+
}
|
|
130
|
+
get(path) {
|
|
131
|
+
if (path instanceof base_1.default) {
|
|
181
132
|
return this.get(new path_1.default([path]));
|
|
182
133
|
}
|
|
183
|
-
|
|
184
|
-
|
|
134
|
+
const traversalPath = path.clone();
|
|
135
|
+
const current = traversalPath.next();
|
|
185
136
|
if (current instanceof number_1.default) {
|
|
186
|
-
|
|
137
|
+
const currentIndex = this.getItemIndex(current.toInt());
|
|
187
138
|
if (currentIndex >= 0 && currentIndex < this.value.length) {
|
|
188
|
-
|
|
139
|
+
const sub = this.value[currentIndex];
|
|
189
140
|
if (traversalPath.count() > 0) {
|
|
190
|
-
if (sub instanceof
|
|
141
|
+
if (sub instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
191
142
|
return sub.get(traversalPath);
|
|
192
143
|
}
|
|
193
144
|
}
|
|
@@ -195,15 +146,13 @@ var CustomList = /** @class */ (function (_super) {
|
|
|
195
146
|
return sub;
|
|
196
147
|
}
|
|
197
148
|
}
|
|
198
|
-
throw new Error(
|
|
149
|
+
throw new Error(`Index error (list index ${currentIndex} out of range).`);
|
|
199
150
|
}
|
|
200
|
-
else if (path.count() === 1 &&
|
|
201
|
-
CustomList.getIntrinsics().
|
|
202
|
-
return CustomList.getIntrinsics().get(current.toString());
|
|
151
|
+
else if (path.count() === 1 && CustomList.getIntrinsics().has(current)) {
|
|
152
|
+
return CustomList.getIntrinsics().get(current);
|
|
203
153
|
}
|
|
204
|
-
throw new Error(
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return CustomList;
|
|
208
|
-
}(generics_1.CustomObject));
|
|
154
|
+
throw new Error(`Unknown path in list ${path.toString()}.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
209
157
|
exports.default = CustomList;
|
|
158
|
+
CustomList.intrinsics = new object_value_1.default();
|
package/dist/types/map.d.ts
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ObjectValue from '../utils/object-value';
|
|
2
2
|
import Path from '../utils/path';
|
|
3
|
-
import
|
|
4
|
-
import { CustomObject, CustomValue } from './generics';
|
|
3
|
+
import CustomValue from './base';
|
|
5
4
|
import CustomString from './string';
|
|
5
|
+
import { CustomObject } from './with-intrinsics';
|
|
6
6
|
export declare const CLASS_ID_PROPERTY: CustomString;
|
|
7
7
|
export declare const ISA_PROPERTY: CustomString;
|
|
8
|
-
export declare const getValue: (map: Map<CustomValue, CustomValue>, mapKey: CustomValue) => CustomValue;
|
|
9
|
-
export declare const hasValue: (map: Map<CustomValue, CustomValue>, mapKey: CustomValue) => boolean;
|
|
10
|
-
export declare const setValue: (map: Map<CustomValue, CustomValue>, mapKey: CustomValue, mapValue: CustomValue) => void;
|
|
11
8
|
export declare class CustomMapIterator implements Iterator<CustomValue> {
|
|
12
|
-
value:
|
|
9
|
+
value: ObjectValue;
|
|
13
10
|
index: number;
|
|
14
|
-
constructor(value:
|
|
11
|
+
constructor(value: ObjectValue);
|
|
15
12
|
next(): IteratorResult<CustomMap>;
|
|
16
13
|
}
|
|
17
14
|
export default class CustomMap extends CustomObject {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly value: Map<CustomValue, CustomValue>;
|
|
22
|
-
readonly isa: Map<CustomValue, CustomValue>;
|
|
15
|
+
static readonly intrinsics: ObjectValue;
|
|
16
|
+
value: ObjectValue;
|
|
17
|
+
readonly isa: ObjectValue;
|
|
23
18
|
private isInstance;
|
|
24
|
-
|
|
19
|
+
static createWithInitialValue(value: ObjectValue): CustomMap;
|
|
20
|
+
constructor(value?: ObjectValue, isa?: ObjectValue);
|
|
25
21
|
getCustomType(): string;
|
|
26
22
|
toString(): string;
|
|
27
23
|
fork(): CustomMap;
|
|
@@ -29,7 +25,7 @@ export default class CustomMap extends CustomObject {
|
|
|
29
25
|
toInt(): number;
|
|
30
26
|
toTruthy(): boolean;
|
|
31
27
|
[Symbol.iterator](): CustomMapIterator;
|
|
32
|
-
extend(map: CustomMap |
|
|
28
|
+
extend(map: CustomMap | ObjectValue): CustomMap;
|
|
33
29
|
has(path: Path<CustomValue> | CustomValue): boolean;
|
|
34
30
|
set(path: Path<CustomValue> | CustomValue, newValue: CustomValue): void;
|
|
35
31
|
get(path: Path<CustomValue> | CustomValue): CustomValue;
|