greybel-interpreter 2.2.18 → 2.2.20
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 +1 -0
- package/dist/context.js +8 -4
- package/dist/operations/assign.js +3 -0
- package/dist/operations/call.js +3 -0
- package/dist/operations/function-reference.js +4 -0
- package/dist/operations/resolve.d.ts +1 -1
- package/dist/operations/resolve.js +2 -2
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export declare class OperationContext {
|
|
|
92
92
|
injected: boolean;
|
|
93
93
|
readonly api: OperationContext;
|
|
94
94
|
readonly locals: OperationContext;
|
|
95
|
+
readonly outer: OperationContext;
|
|
95
96
|
readonly globals: OperationContext;
|
|
96
97
|
private static readonly lookupApiType;
|
|
97
98
|
private static readonly lookupGlobalsType;
|
package/dist/context.js
CHANGED
|
@@ -40,7 +40,7 @@ class Scope extends map_1.CustomMap {
|
|
|
40
40
|
this.context = context;
|
|
41
41
|
}
|
|
42
42
|
get(path) {
|
|
43
|
-
var _a, _b;
|
|
43
|
+
var _a, _b, _c;
|
|
44
44
|
if (path instanceof base_1.CustomValue) {
|
|
45
45
|
return this.get(new path_1.Path([path]));
|
|
46
46
|
}
|
|
@@ -52,10 +52,13 @@ class Scope extends map_1.CustomMap {
|
|
|
52
52
|
if (this.has(path)) {
|
|
53
53
|
return super.get(path);
|
|
54
54
|
}
|
|
55
|
-
else if ((_a = this.context.
|
|
55
|
+
else if ((_a = this.context.outer) === null || _a === void 0 ? void 0 : _a.scope.has(path)) {
|
|
56
|
+
return this.context.outer.scope.get(path);
|
|
57
|
+
}
|
|
58
|
+
else if ((_b = this.context.globals) === null || _b === void 0 ? void 0 : _b.scope.has(path)) {
|
|
56
59
|
return this.context.globals.scope.get(path);
|
|
57
60
|
}
|
|
58
|
-
else if ((
|
|
61
|
+
else if ((_c = this.context.api) === null || _c === void 0 ? void 0 : _c.scope.has(path)) {
|
|
59
62
|
return this.context.api.scope.get(path);
|
|
60
63
|
}
|
|
61
64
|
else if (path.count() === 1 && map_1.CustomMap.getIntrinsics().has(current)) {
|
|
@@ -149,7 +152,7 @@ class FunctionState {
|
|
|
149
152
|
exports.FunctionState = FunctionState;
|
|
150
153
|
class OperationContext {
|
|
151
154
|
constructor(options = {}) {
|
|
152
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
155
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
153
156
|
this.target = (_a = options.target) !== null && _a !== void 0 ? _a : 'unknown';
|
|
154
157
|
this.stackTrace = (_b = options.stackTrace) !== null && _b !== void 0 ? _b : [];
|
|
155
158
|
this.previous = (_c = options.previous) !== null && _c !== void 0 ? _c : null;
|
|
@@ -168,6 +171,7 @@ class OperationContext {
|
|
|
168
171
|
this.api = this.lookupApi();
|
|
169
172
|
this.globals = this.lookupGlobals();
|
|
170
173
|
this.locals = (_o = this.lookupLocals()) !== null && _o !== void 0 ? _o : this;
|
|
174
|
+
this.outer = (_q = (_p = this.locals.previous) === null || _p === void 0 ? void 0 : _p.lookupLocals()) !== null && _q !== void 0 ? _q : null;
|
|
171
175
|
}
|
|
172
176
|
isIgnoredInDebugging(op) {
|
|
173
177
|
return op instanceof operation_1.OperationBlock || op instanceof noop_1.Noop;
|
|
@@ -29,6 +29,9 @@ class Assign extends operation_1.Operation {
|
|
|
29
29
|
handle(ctx) {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const resolveResult = yield this.left.getResult(ctx);
|
|
32
|
+
if (ctx.isExit()) {
|
|
33
|
+
return default_1.DefaultType.Void;
|
|
34
|
+
}
|
|
32
35
|
const rightValue = yield this.right.handle(ctx);
|
|
33
36
|
if (!(resolveResult.handle instanceof resolve_1.ResolveNil)) {
|
|
34
37
|
const resultValueCtx = resolveResult.handle;
|
package/dist/operations/call.js
CHANGED
|
@@ -32,6 +32,9 @@ class Call extends operation_1.Operation {
|
|
|
32
32
|
handle(ctx) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const resolveResult = yield this.fnRef.getResult(ctx);
|
|
35
|
+
if (ctx.isExit()) {
|
|
36
|
+
return default_1.DefaultType.Void;
|
|
37
|
+
}
|
|
35
38
|
const valueRef = yield this.fnRef.handle(ctx, resolveResult, false);
|
|
36
39
|
const fnArgs = [];
|
|
37
40
|
for (let index = 0; index < this.args.length; index++) {
|
|
@@ -10,6 +10,7 @@ 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");
|
|
13
14
|
const operation_1 = require("./operation");
|
|
14
15
|
const resolve_1 = require("./resolve");
|
|
15
16
|
class FunctionReference extends operation_1.Operation {
|
|
@@ -27,6 +28,9 @@ class FunctionReference extends operation_1.Operation {
|
|
|
27
28
|
handle(ctx) {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
30
|
const refResult = yield this.ref.getResult(ctx);
|
|
31
|
+
if (ctx.isExit()) {
|
|
32
|
+
return default_1.DefaultType.Void;
|
|
33
|
+
}
|
|
30
34
|
if (!(refResult.handle instanceof resolve_1.ResolveNil)) {
|
|
31
35
|
if (refResult.path.count() === 0) {
|
|
32
36
|
return refResult.handle;
|
|
@@ -50,6 +50,6 @@ export declare class Resolve extends Operation {
|
|
|
50
50
|
constructor(item: ASTBase, target?: string);
|
|
51
51
|
buildProcessor(node: ASTBase, visit: CPSVisit): Promise<void>;
|
|
52
52
|
build(visit: CPSVisit): Promise<Resolve>;
|
|
53
|
-
getResult(ctx: OperationContext): Promise<ResolveResult>;
|
|
53
|
+
getResult(ctx: OperationContext): Promise<ResolveResult | null>;
|
|
54
54
|
handle(ctx: OperationContext, result?: ResolveResult, autoCall?: boolean): Promise<CustomValue>;
|
|
55
55
|
}
|
|
@@ -157,7 +157,7 @@ class Resolve extends operation_1.Operation {
|
|
|
157
157
|
const lastIndex = maxIndex - 1;
|
|
158
158
|
for (let index = 0; index < maxIndex; index++) {
|
|
159
159
|
if (ctx.isExit()) {
|
|
160
|
-
return null;
|
|
160
|
+
return new ResolveResult(null, default_1.DefaultType.Void);
|
|
161
161
|
}
|
|
162
162
|
const current = this.path.at(index);
|
|
163
163
|
if (current instanceof OperationSegment) {
|
|
@@ -215,7 +215,7 @@ class Resolve extends operation_1.Operation {
|
|
|
215
215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
216
|
if (result === null) {
|
|
217
217
|
result = yield this.getResult(ctx);
|
|
218
|
-
if (
|
|
218
|
+
if (ctx.isExit()) {
|
|
219
219
|
return default_1.DefaultType.Void;
|
|
220
220
|
}
|
|
221
221
|
}
|