greybel-interpreter 1.9.2 → 1.9.4
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.
|
@@ -30,7 +30,7 @@ class Assign extends operation_1.Operation {
|
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const resolveResult = yield this.left.getResult(ctx);
|
|
32
32
|
const rightValue = yield this.right.handle(ctx);
|
|
33
|
-
if (resolveResult.handle
|
|
33
|
+
if (!(resolveResult.handle instanceof resolve_1.ResolveNil)) {
|
|
34
34
|
const resultValueCtx = resolveResult.handle;
|
|
35
35
|
resultValueCtx.set(resolveResult.path, rightValue);
|
|
36
36
|
}
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FunctionReference = void 0;
|
|
13
|
-
const default_1 = require("../types/default");
|
|
14
13
|
const operation_1 = require("./operation");
|
|
15
14
|
const resolve_1 = require("./resolve");
|
|
16
15
|
class FunctionReference extends operation_1.Operation {
|
|
@@ -28,7 +27,7 @@ class FunctionReference extends operation_1.Operation {
|
|
|
28
27
|
handle(ctx) {
|
|
29
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
29
|
const refResult = yield this.ref.getResult(ctx);
|
|
31
|
-
if (refResult.handle
|
|
30
|
+
if (!(refResult.handle instanceof resolve_1.ResolveNil)) {
|
|
32
31
|
if (refResult.path.count() === 0) {
|
|
33
32
|
return refResult.handle;
|
|
34
33
|
}
|
|
@@ -3,6 +3,7 @@ import { OperationContext } from '../context';
|
|
|
3
3
|
import { CustomValue } from '../types/base';
|
|
4
4
|
import { Path } from '../utils/path';
|
|
5
5
|
import { CPSVisit, Operation } from './operation';
|
|
6
|
+
import { CustomNil } from '../types/nil';
|
|
6
7
|
export declare class SliceSegment {
|
|
7
8
|
readonly left: Operation;
|
|
8
9
|
readonly right: Operation;
|
|
@@ -35,6 +36,8 @@ export declare class SegmentContainer {
|
|
|
35
36
|
isSuper(): boolean;
|
|
36
37
|
getLast(): Segment;
|
|
37
38
|
}
|
|
39
|
+
export declare class ResolveNil extends CustomNil {
|
|
40
|
+
}
|
|
38
41
|
export declare class ResolveResult {
|
|
39
42
|
readonly path: Path<CustomValue>;
|
|
40
43
|
readonly handle: CustomValue;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Resolve = exports.ResolveResult = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
|
|
12
|
+
exports.Resolve = exports.ResolveResult = exports.ResolveNil = exports.SegmentContainer = exports.OperationSegment = exports.IndexSegment = exports.IdentifierSegment = exports.PathSegment = exports.SliceSegment = void 0;
|
|
13
13
|
const greyscript_core_1 = require("greyscript-core");
|
|
14
14
|
const default_1 = require("../types/default");
|
|
15
15
|
const function_1 = require("../types/function");
|
|
@@ -19,6 +19,7 @@ const string_1 = require("../types/string");
|
|
|
19
19
|
const with_intrinsics_1 = require("../types/with-intrinsics");
|
|
20
20
|
const path_1 = require("../utils/path");
|
|
21
21
|
const operation_1 = require("./operation");
|
|
22
|
+
const nil_1 = require("../types/nil");
|
|
22
23
|
class SliceSegment {
|
|
23
24
|
constructor(left, right) {
|
|
24
25
|
this.left = left;
|
|
@@ -86,6 +87,9 @@ class SegmentContainer {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
exports.SegmentContainer = SegmentContainer;
|
|
90
|
+
class ResolveNil extends nil_1.CustomNil {
|
|
91
|
+
}
|
|
92
|
+
exports.ResolveNil = ResolveNil;
|
|
89
93
|
class ResolveResult {
|
|
90
94
|
constructor(path, handle) {
|
|
91
95
|
this.path = path;
|
|
@@ -148,7 +152,7 @@ class Resolve extends operation_1.Operation {
|
|
|
148
152
|
getResult(ctx) {
|
|
149
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
154
|
let traversedPath = new path_1.Path();
|
|
151
|
-
let handle =
|
|
155
|
+
let handle = new ResolveNil();
|
|
152
156
|
const maxIndex = this.path.count();
|
|
153
157
|
const lastIndex = maxIndex - 1;
|
|
154
158
|
for (let index = 0; index < maxIndex; index++) {
|
|
@@ -163,13 +167,13 @@ class Resolve extends operation_1.Operation {
|
|
|
163
167
|
break;
|
|
164
168
|
}
|
|
165
169
|
const previous = handle;
|
|
166
|
-
if (handle
|
|
170
|
+
if (!(handle instanceof ResolveNil)) {
|
|
167
171
|
if (handle instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
168
172
|
const customValueCtx = handle;
|
|
169
173
|
handle = customValueCtx.get(traversedPath);
|
|
170
174
|
}
|
|
171
175
|
else {
|
|
172
|
-
throw new Error(
|
|
176
|
+
throw new Error(`Unknown path ${traversedPath.toString()}.`);
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
else {
|
|
@@ -208,24 +212,26 @@ class Resolve extends operation_1.Operation {
|
|
|
208
212
|
if (result === null) {
|
|
209
213
|
result = yield this.getResult(ctx);
|
|
210
214
|
}
|
|
211
|
-
if (result.handle
|
|
215
|
+
if (!(result.handle instanceof ResolveNil)) {
|
|
212
216
|
if (result.path.count() === 0) {
|
|
213
217
|
if (autoCall && result.handle instanceof function_1.CustomFunction) {
|
|
214
218
|
return result.handle.run(default_1.DefaultType.Void, [], ctx);
|
|
215
219
|
}
|
|
216
220
|
return result.handle;
|
|
217
221
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
if (result.handle instanceof with_intrinsics_1.CustomValueWithIntrinsics) {
|
|
223
|
+
const customValueCtx = result.handle;
|
|
224
|
+
const child = customValueCtx.get(result.path);
|
|
225
|
+
if (autoCall && child instanceof function_1.CustomFunction) {
|
|
226
|
+
if (this.path.isSuper() &&
|
|
227
|
+
ctx.functionState.context &&
|
|
228
|
+
customValueCtx instanceof map_1.CustomMap) {
|
|
229
|
+
return child.run(ctx.functionState.context, [], ctx, customValueCtx.isa);
|
|
230
|
+
}
|
|
231
|
+
return child.run(customValueCtx, [], ctx);
|
|
225
232
|
}
|
|
226
|
-
return child
|
|
233
|
+
return child;
|
|
227
234
|
}
|
|
228
|
-
return child;
|
|
229
235
|
}
|
|
230
236
|
const handle = ctx.get(result.path);
|
|
231
237
|
if (autoCall && handle instanceof function_1.CustomFunction) {
|