greybel-interpreter 2.8.3 → 2.8.5
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 -0
- package/dist/context.js +11 -10
- package/dist/operations/call.js +10 -1
- package/dist/operations/if-statement.js +5 -0
- package/package.json +3 -2
package/dist/context.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ export interface ExitObserver {
|
|
|
46
46
|
export declare class ProcessState extends EventEmitter {
|
|
47
47
|
isPending: boolean;
|
|
48
48
|
last: OperationContext;
|
|
49
|
+
private observer;
|
|
50
|
+
private observerWithExitOccurence;
|
|
51
|
+
constructor();
|
|
49
52
|
createExitObserver(): ExitObserver;
|
|
50
53
|
}
|
|
51
54
|
export declare class LoopState {
|
package/dist/context.js
CHANGED
|
@@ -19,6 +19,7 @@ const default_1 = require("./types/default");
|
|
|
19
19
|
const map_1 = require("./types/map");
|
|
20
20
|
const path_1 = require("./utils/path");
|
|
21
21
|
const set_immediate_1 = require("./utils/set-immediate");
|
|
22
|
+
const uuid_1 = require("uuid");
|
|
22
23
|
var ContextType;
|
|
23
24
|
(function (ContextType) {
|
|
24
25
|
ContextType[ContextType["Api"] = 0] = "Api";
|
|
@@ -124,22 +125,22 @@ class Debugger {
|
|
|
124
125
|
exports.Debugger = Debugger;
|
|
125
126
|
class ProcessState extends events_1.EventEmitter {
|
|
126
127
|
constructor() {
|
|
127
|
-
super(
|
|
128
|
+
super();
|
|
128
129
|
this.isPending = false;
|
|
129
130
|
/* eslint-disable no-use-before-define */
|
|
130
131
|
this.last = null;
|
|
132
|
+
this.observer = new Set();
|
|
133
|
+
this.observerWithExitOccurence = new Set();
|
|
134
|
+
this.once('exit', () => {
|
|
135
|
+
this.observerWithExitOccurence = new Set(this.observer);
|
|
136
|
+
});
|
|
131
137
|
}
|
|
132
138
|
createExitObserver() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
isExit = true;
|
|
136
|
-
};
|
|
137
|
-
this.once('exit', listener);
|
|
139
|
+
const id = (0, uuid_1.v4)();
|
|
140
|
+
this.observer.add(id);
|
|
138
141
|
return {
|
|
139
|
-
occured: () =>
|
|
140
|
-
close: () =>
|
|
141
|
-
this.off('exit', listener);
|
|
142
|
-
}
|
|
142
|
+
occured: () => this.observerWithExitOccurence.has(id),
|
|
143
|
+
close: () => this.observer.delete(id)
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
}
|
package/dist/operations/call.js
CHANGED
|
@@ -32,15 +32,24 @@ class Call extends operation_1.Operation {
|
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
const exitObserver = ctx.processState.createExitObserver();
|
|
34
34
|
const resolveResult = yield this.fnRef.getResult(ctx);
|
|
35
|
-
exitObserver.close();
|
|
36
35
|
if (exitObserver.occured()) {
|
|
36
|
+
exitObserver.close();
|
|
37
37
|
return default_1.DefaultType.Void;
|
|
38
38
|
}
|
|
39
39
|
const valueRef = yield this.fnRef.handle(ctx, resolveResult, false);
|
|
40
40
|
const fnArgs = [];
|
|
41
41
|
for (let index = 0; index < this.args.length; index++) {
|
|
42
|
+
if (exitObserver.occured()) {
|
|
43
|
+
exitObserver.close();
|
|
44
|
+
return default_1.DefaultType.Void;
|
|
45
|
+
}
|
|
42
46
|
fnArgs.push(yield this.args[index].handle(ctx));
|
|
43
47
|
}
|
|
48
|
+
if (exitObserver.occured()) {
|
|
49
|
+
exitObserver.close();
|
|
50
|
+
return default_1.DefaultType.Void;
|
|
51
|
+
}
|
|
52
|
+
exitObserver.close();
|
|
44
53
|
if (valueRef instanceof function_1.CustomFunction) {
|
|
45
54
|
const func = valueRef;
|
|
46
55
|
if (this.fnRef.path.isSuper() && ctx.functionState.context) {
|
|
@@ -67,14 +67,19 @@ class IfStatement extends operation_1.OperationBlock {
|
|
|
67
67
|
}
|
|
68
68
|
handle(ctx) {
|
|
69
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const exitObserver = ctx.processState.createExitObserver();
|
|
70
71
|
for (let index = 0; index < this.clauses.length; index++) {
|
|
71
72
|
const clause = this.clauses[index];
|
|
72
73
|
const clauseResult = yield ctx.step(clause.condition);
|
|
74
|
+
if (exitObserver.occured()) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
73
77
|
if (clauseResult.toTruthy()) {
|
|
74
78
|
yield clause.block.handle(ctx);
|
|
75
79
|
break;
|
|
76
80
|
}
|
|
77
81
|
}
|
|
82
|
+
exitObserver.close();
|
|
78
83
|
return default_1.DefaultType.Void;
|
|
79
84
|
});
|
|
80
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"greybel-core": "^0.10.0",
|
|
52
52
|
"greyscript-core": "^0.10.0",
|
|
53
|
-
"lru-cache": "^10.0.1"
|
|
53
|
+
"lru-cache": "^10.0.1",
|
|
54
|
+
"uuid": "^9.0.1"
|
|
54
55
|
},
|
|
55
56
|
"keywords": [
|
|
56
57
|
"greyscript",
|