greybel-interpreter 2.6.5 → 2.6.7
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/operations/for.js +23 -30
- package/dist/operations/while.js +18 -27
- package/package.json +3 -3
package/dist/operations/for.js
CHANGED
|
@@ -49,39 +49,32 @@ class For extends operation_1.OperationBlock {
|
|
|
49
49
|
const idxIdentifier = new string_1.CustomString(`__${identifier}_idx`);
|
|
50
50
|
const varIdentifier = new string_1.CustomString(identifier);
|
|
51
51
|
let iteratorResult = iterator.next();
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const iteration = () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
try {
|
|
54
|
+
if (iteratorResult.done) {
|
|
55
|
+
resolve(default_1.DefaultType.Void);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const current = iteratorResult.value;
|
|
59
|
+
loopState.isContinue = false;
|
|
60
|
+
forCtx.set(idxIdentifier, new number_1.CustomNumber(iterator.index - 1));
|
|
61
|
+
forCtx.set(varIdentifier, current);
|
|
62
|
+
yield this.block.handle(forCtx);
|
|
63
|
+
if (loopState.isBreak ||
|
|
64
|
+
forCtx.functionState.isReturn ||
|
|
65
|
+
ctx.isExit()) {
|
|
66
|
+
resolve(default_1.DefaultType.Void);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const idxValue = forCtx.get(idxIdentifier).toNumber();
|
|
70
|
+
iterator.index += idxValue - (iterator.index - 1);
|
|
71
|
+
iteratorResult = iterator.next();
|
|
72
|
+
(0, set_immediate_1.setImmediate)(iteration);
|
|
55
73
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
forCtx.set(idxIdentifier, new number_1.CustomNumber(iterator.index - 1));
|
|
59
|
-
forCtx.set(varIdentifier, current);
|
|
60
|
-
yield this.block.handle(forCtx);
|
|
61
|
-
if (loopState.isBreak ||
|
|
62
|
-
forCtx.functionState.isReturn ||
|
|
63
|
-
ctx.isExit()) {
|
|
64
|
-
return false;
|
|
74
|
+
catch (err) {
|
|
75
|
+
reject(err);
|
|
65
76
|
}
|
|
66
|
-
const idxValue = forCtx.get(idxIdentifier).toNumber();
|
|
67
|
-
iterator.index += idxValue - (iterator.index - 1);
|
|
68
|
-
iteratorResult = iterator.next();
|
|
69
|
-
return true;
|
|
70
77
|
});
|
|
71
|
-
const iteration = function () {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
try {
|
|
74
|
-
if (!(yield next())) {
|
|
75
|
-
resolve(default_1.DefaultType.Void);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
(0, set_immediate_1.setImmediate)(iteration);
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
reject(err);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
78
|
iteration();
|
|
86
79
|
});
|
|
87
80
|
});
|
package/dist/operations/while.js
CHANGED
|
@@ -37,36 +37,27 @@ class While extends operation_1.OperationBlock {
|
|
|
37
37
|
const loopState = new context_1.LoopState();
|
|
38
38
|
whileCtx.loopState = loopState;
|
|
39
39
|
return new Promise((resolve, reject) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const iteration = () => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
try {
|
|
42
|
+
const conditionResult = yield whileCtx.step(this.condition);
|
|
43
|
+
if (!conditionResult.toTruthy()) {
|
|
44
|
+
resolve(default_1.DefaultType.Void);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
loopState.isContinue = false;
|
|
48
|
+
yield this.block.handle(whileCtx);
|
|
49
|
+
if (loopState.isBreak ||
|
|
50
|
+
whileCtx.functionState.isReturn ||
|
|
51
|
+
ctx.isExit()) {
|
|
52
|
+
resolve(default_1.DefaultType.Void);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
(0, set_immediate_1.setImmediate)(iteration);
|
|
45
56
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (loopState.isBreak ||
|
|
49
|
-
whileCtx.functionState.isReturn ||
|
|
50
|
-
ctx.isExit()) {
|
|
51
|
-
resolve(default_1.DefaultType.Void);
|
|
52
|
-
return false;
|
|
57
|
+
catch (err) {
|
|
58
|
+
reject(err);
|
|
53
59
|
}
|
|
54
|
-
return true;
|
|
55
60
|
});
|
|
56
|
-
const iteration = function () {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
try {
|
|
59
|
-
if (!(yield next())) {
|
|
60
|
-
resolve(default_1.DefaultType.Void);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
(0, set_immediate_1.setImmediate)(iteration);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
reject(err);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
61
|
iteration();
|
|
71
62
|
});
|
|
72
63
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "greybel-interpreter",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"description": "Interpreter",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"typescript": "^5.0.4"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"greybel-core": "^0.9.
|
|
52
|
-
"greyscript-core": "^0.9.
|
|
51
|
+
"greybel-core": "^0.9.15",
|
|
52
|
+
"greyscript-core": "^0.9.16",
|
|
53
53
|
"lru-cache": "^10.0.1"
|
|
54
54
|
},
|
|
55
55
|
"keywords": [
|