xmlui 0.8.6 → 0.9.1
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/{apiInterceptorWorker-fLBfPj2T.mjs → apiInterceptorWorker-230V_-Ds.mjs} +1 -1
- package/dist/{index-wd8FRzuM.mjs → index-DUwwx3L4.mjs} +5864 -6108
- package/dist/index.css +274 -301
- package/dist/language-server.mjs +25 -1
- package/dist/{lint-B18Ko6Sy.mjs → lint-gX2osbkz.mjs} +920 -1120
- package/dist/scripts/bin/build.js +2 -2
- package/dist/scripts/bin/start.js +3 -9
- package/dist/scripts/bin/vite-xmlui-plugin.js +2 -2
- package/dist/scripts/bin/viteConfig.js +89 -63
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTreeExp.js +1 -2
- package/dist/scripts/src/components/Accordion/Accordion.js +6 -16
- package/dist/scripts/src/components/App/AppNative.js +8 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -5
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +10 -4
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +13 -19
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +2 -0
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +7 -3
- package/dist/scripts/src/components/Avatar/Avatar.js +2 -9
- package/dist/scripts/src/components/Badge/Badge.js +2 -8
- package/dist/scripts/src/components/Button/Button.js +28 -60
- package/dist/scripts/src/components/Card/Card.js +1 -6
- package/dist/scripts/src/components/Checkbox/Checkbox.js +4 -12
- package/dist/scripts/src/components/ComponentProvider.js +4 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +3 -10
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/scripts/src/components/Form/Form.js +12 -28
- package/dist/scripts/src/components/Form/FormNative.js +9 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +1 -1
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +2 -2
- package/dist/scripts/src/components/Heading/HeadingNative.js +0 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +4 -19
- package/dist/scripts/src/components/IconProvider.js +2 -2
- package/dist/scripts/src/components/Link/Link.js +2 -8
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +1 -3
- package/dist/scripts/src/components/NavGroup/NavGroup.js +34 -3
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +24 -12
- package/dist/scripts/src/components/NavLink/NavLink.js +4 -11
- package/dist/scripts/src/components/NavPanel/NavPanel.js +1 -6
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +2 -8
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -12
- package/dist/scripts/src/components/Select/Select.js +5 -13
- package/dist/scripts/src/components/Select/SelectNative.js +7 -3
- package/dist/scripts/src/components/Slider/Slider.js +2 -8
- package/dist/scripts/src/components/Spinner/Spinner.js +1 -6
- package/dist/scripts/src/components/SubNavPanel/SubNavPanel.js +22 -0
- package/dist/scripts/src/components/SubNavPanel/SubNavPanelNative.js +9 -0
- package/dist/scripts/src/components/Switch/Switch.js +6 -16
- package/dist/scripts/src/components/Table/Table.js +8 -17
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +4 -12
- package/dist/scripts/src/components/Tabs/Tabs.js +3 -10
- package/dist/scripts/src/components/Text/Text.js +10 -24
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
- package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +3 -3
- package/dist/scripts/src/components-core/DevTools.js +5 -4
- package/dist/scripts/src/components-core/RestApiProxy.js +7 -3
- package/dist/scripts/src/components-core/action/APICall.js +2 -1
- package/dist/scripts/src/components-core/rendering/Container.js +15 -11
- package/dist/scripts/src/components-core/rendering/StateContainer.js +3 -2
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +0 -2
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +1 -1
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +11 -64
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +196 -175
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +173 -231
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +129 -100
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +170 -175
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +48 -33
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +164 -170
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +5 -4
- package/dist/scripts/src/components-core/script-runner/visitors.js +124 -116
- package/dist/scripts/src/components-core/theming/themes/palette.js +1 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +300 -154
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +510 -510
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +0 -1
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +11 -11
- package/dist/scripts/src/components-core/utils/misc.js +13 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +56 -53
- package/dist/scripts/src/components-core/xmlui-parser.js +1 -1
- package/dist/scripts/src/parsers/scripting-exp/Lexer.js +1092 -0
- package/dist/scripts/src/parsers/scripting-exp/Parser.js +2635 -0
- package/dist/scripts/src/parsers/scripting-exp/ParserError.js +47 -0
- package/dist/scripts/src/parsers/scripting-exp/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting-exp/TokenType.js +2 -4
- package/dist/scripts/src/parsers/scripting-exp/code-behind-collect.js +101 -0
- package/dist/scripts/src/parsers/scripting-exp/modules.js +107 -0
- package/dist/scripts/src/parsers/{scripting → scripting-exp}/tree-visitor.js +103 -107
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +12 -12
- package/dist/style.css +245 -286
- package/dist/xmlui-metadata.mjs +2741 -2211
- package/dist/xmlui-metadata.umd.js +2740 -2212
- package/dist/xmlui-parser.d.ts +320 -232
- package/dist/xmlui-parser.mjs +19 -19
- package/dist/xmlui-standalone.umd.js +6770 -7220
- package/dist/xmlui.d.ts +322 -230
- package/dist/xmlui.mjs +1 -1
- package/package.json +10 -6
- package/dist/_commonjsHelpers-CcAunmGO.mjs +0 -33
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +0 -34
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +0 -40
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +0 -40
- package/dist/scripts/src/components-core/script-runner/syncProxy.js +0 -31
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +0 -153
- package/dist/scripts/src/parsers/scripting/modules.js +0 -284
- /package/dist/scripts/src/abstractions/scripting/{LogicalThread.js → LogicalThreadExp.js} +0 -0
- /package/dist/scripts/src/abstractions/scripting/{TryScope.js → TryScopeExp.js} +0 -0
|
@@ -11,15 +11,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.processStatementQueueAsync = processStatementQueueAsync;
|
|
13
13
|
exports.processDeclarationsAsync = processDeclarationsAsync;
|
|
14
|
+
const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
|
|
14
15
|
const EngineError_1 = require("../EngineError");
|
|
15
16
|
const reportEngineError_1 = require("../reportEngineError");
|
|
17
|
+
const statement_queue_1 = require("./statement-queue");
|
|
16
18
|
const eval_tree_async_1 = require("./eval-tree-async");
|
|
17
19
|
const process_statement_common_1 = require("./process-statement-common");
|
|
18
|
-
const
|
|
20
|
+
const Parser_1 = require("../../parsers/scripting-exp/Parser");
|
|
19
21
|
// --- Helper function to process the entire queue asynchronously
|
|
20
|
-
function processStatementQueueAsync(statements, evalContext, thread
|
|
22
|
+
function processStatementQueueAsync(statements, evalContext, thread) {
|
|
21
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c, _d;
|
|
23
25
|
if (!thread) {
|
|
24
26
|
// --- Create the main thread for the queue
|
|
25
27
|
thread = (0, process_statement_common_1.ensureMainThread)(evalContext);
|
|
@@ -28,7 +30,7 @@ function processStatementQueueAsync(statements, evalContext, thread, onStatement
|
|
|
28
30
|
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statements);
|
|
29
31
|
// --- Fill the queue with items
|
|
30
32
|
const queue = new statement_queue_1.StatementQueue();
|
|
31
|
-
queue.push((0, statement_queue_1.mapStatementsToQueueItems)(statements));
|
|
33
|
+
queue.push((0, statement_queue_1.mapStatementsToQueueItems)((0, process_statement_common_1.toStatementItems)(statements)));
|
|
32
34
|
// --- Prepare queue diagnostics information
|
|
33
35
|
const diagInfo = {
|
|
34
36
|
processedStatements: 0,
|
|
@@ -50,7 +52,10 @@ function processStatementQueueAsync(statements, evalContext, thread, onStatement
|
|
|
50
52
|
thread.breakLabelValue = queue.length > 0 ? queue.peek().label : -1;
|
|
51
53
|
let outcome;
|
|
52
54
|
try {
|
|
53
|
-
|
|
55
|
+
// --- Sign that the statement is about to start
|
|
56
|
+
yield ((_b = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementStarted) === null || _b === void 0 ? void 0 : _b.call(evalContext, evalContext, queueItem.statement));
|
|
57
|
+
// --- Execute the statement
|
|
58
|
+
outcome = yield processStatementAsync(queueItem.statement, (_c = queueItem === null || queueItem === void 0 ? void 0 : queueItem.execInfo) !== null && _c !== void 0 ? _c : {}, evalContext, thread);
|
|
54
59
|
}
|
|
55
60
|
catch (err) {
|
|
56
61
|
if (thread.tryBlocks && thread.tryBlocks.length > 0) {
|
|
@@ -70,7 +75,8 @@ function processStatementQueueAsync(statements, evalContext, thread, onStatement
|
|
|
70
75
|
(0, reportEngineError_1.reportEngineError)(err);
|
|
71
76
|
}
|
|
72
77
|
else {
|
|
73
|
-
|
|
78
|
+
// TODO: Provide source code information
|
|
79
|
+
(0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err /* queueItem!.statement?.source */), err);
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
}
|
|
@@ -85,7 +91,8 @@ function processStatementQueueAsync(statements, evalContext, thread, onStatement
|
|
|
85
91
|
diagInfo.clearToLabels++;
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
|
-
|
|
94
|
+
// --- Sign that the statement has been completed
|
|
95
|
+
yield ((_d = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementCompleted) === null || _d === void 0 ? void 0 : _d.call(evalContext, evalContext, queueItem.statement));
|
|
89
96
|
// --- Provide diagnostics
|
|
90
97
|
if (queue.length > diagInfo.maxQueueLength) {
|
|
91
98
|
diagInfo.maxQueueLength = queue.length;
|
|
@@ -98,140 +105,108 @@ function processStatementQueueAsync(statements, evalContext, thread, onStatement
|
|
|
98
105
|
}
|
|
99
106
|
diagInfo.processedStatements++;
|
|
100
107
|
}
|
|
108
|
+
// --- Done.
|
|
101
109
|
return diagInfo;
|
|
102
110
|
});
|
|
103
111
|
}
|
|
104
112
|
/**
|
|
105
113
|
* Process the specified statement asynchronously
|
|
106
114
|
* @param statement Statement to process
|
|
115
|
+
* @param execInfo Execution information
|
|
107
116
|
* @param evalContext Evaluation context used for processing
|
|
108
117
|
* @param thread Logical thread to use for statement processing
|
|
109
118
|
* @param onStatementCompleted
|
|
110
119
|
* @returns Items to put back into the queue of statements
|
|
111
120
|
*/
|
|
112
|
-
function processStatementAsync(statement, evalContext, thread
|
|
121
|
+
function processStatementAsync(statement, execInfo, evalContext, thread) {
|
|
113
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
123
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
115
124
|
// --- These items should be put in the statement queue after return
|
|
116
125
|
let toUnshift = [];
|
|
117
126
|
let clearToLabel;
|
|
118
127
|
// --- Process the statement according to its type
|
|
119
128
|
switch (statement.type) {
|
|
120
|
-
case
|
|
121
|
-
// --- Get module information
|
|
122
|
-
const thisModule = statement.module;
|
|
123
|
-
if (!thisModule) {
|
|
124
|
-
throw new Error("Missing module");
|
|
125
|
-
}
|
|
126
|
-
const parentModule = (_a = statement.module) === null || _a === void 0 ? void 0 : _a.parent;
|
|
127
|
-
if (!parentModule) {
|
|
128
|
-
throw new Error("Missing parent module");
|
|
129
|
-
}
|
|
130
|
-
// --- At this point the imported module is set
|
|
131
|
-
// if (!statement.module!.executed) {
|
|
132
|
-
// // --- Run the module, it has not been executed yet
|
|
133
|
-
// const childEvalContext = createEvalContext({
|
|
134
|
-
// cancellationToken: evalContext.cancellationToken,
|
|
135
|
-
// timeout: evalContext.timeout ?? 1000
|
|
136
|
-
// });
|
|
137
|
-
// statement.module!.executed = true;
|
|
138
|
-
// executeScriptModule(statement.module!, childEvalContext);
|
|
139
|
-
// }
|
|
140
|
-
// --- Import the module's exported variables into the parent module
|
|
141
|
-
const topVars = evalContext.mainThread.blocks[0].vars;
|
|
142
|
-
const topConst = evalContext.mainThread.blocks[0].constVars;
|
|
143
|
-
for (const modImports of Object.values(statement.imports)) {
|
|
144
|
-
for (const key of Object.keys(modImports)) {
|
|
145
|
-
if (key in topVars) {
|
|
146
|
-
throw new Error(`Import ${key} already exists`);
|
|
147
|
-
}
|
|
148
|
-
topVars[key] = statement.module.exports.get(modImports[key]);
|
|
149
|
-
topConst.add(key);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
case "FuncD":
|
|
129
|
+
case ScriptingSourceTreeExp_1.T_FUNCTION_DECLARATION:
|
|
154
130
|
// --- Function declarations are already hoisted, nothing to do
|
|
155
131
|
break;
|
|
156
|
-
case
|
|
132
|
+
case ScriptingSourceTreeExp_1.T_VAR_STATEMENT:
|
|
157
133
|
if (thread !== evalContext.mainThread) {
|
|
158
134
|
throw new Error("'var' declarations are not allowed within functions");
|
|
159
135
|
}
|
|
160
136
|
break;
|
|
161
|
-
case
|
|
137
|
+
case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
|
|
162
138
|
// --- Nothing to do
|
|
163
139
|
break;
|
|
164
|
-
case
|
|
140
|
+
case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
|
|
165
141
|
// --- No statement, nothing to process
|
|
166
|
-
if (statement.
|
|
142
|
+
if (statement.stmts.length === 0)
|
|
167
143
|
break;
|
|
168
144
|
// --- Create a new block scope
|
|
169
|
-
(
|
|
145
|
+
(_a = thread.blocks) !== null && _a !== void 0 ? _a : (thread.blocks = []);
|
|
170
146
|
thread.blocks.push({ vars: {} });
|
|
171
147
|
// --- Hoist function declarations to the innermost block scope
|
|
172
|
-
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.
|
|
173
|
-
// ---
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statement.statements, closing]);
|
|
148
|
+
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.stmts);
|
|
149
|
+
// --- Queue the block scope's body...
|
|
150
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
151
|
+
...(0, process_statement_common_1.toStatementItems)(statement.stmts),
|
|
152
|
+
// --- ...and an empty statement to remove the block scope
|
|
153
|
+
(0, process_statement_common_1.closing)(),
|
|
154
|
+
]);
|
|
180
155
|
break;
|
|
181
|
-
case
|
|
156
|
+
case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
|
|
182
157
|
// --- Just evaluate it
|
|
183
|
-
const statementValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
158
|
+
const statementValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread);
|
|
184
159
|
if (thread.blocks && thread.blocks.length !== 0) {
|
|
185
160
|
thread.blocks[thread.blocks.length - 1].returnValue = statementValue;
|
|
186
161
|
}
|
|
187
162
|
break;
|
|
188
|
-
case
|
|
163
|
+
case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION_STATEMENT:
|
|
189
164
|
// --- Compile the arrow expression
|
|
190
|
-
const arrowFuncValue = yield (0, eval_tree_async_1.executeArrowExpression)(statement.
|
|
165
|
+
const arrowFuncValue = yield (0, eval_tree_async_1.executeArrowExpression)(statement.expr, evalContext, thread, ...((_b = evalContext.eventArgs) !== null && _b !== void 0 ? _b : []));
|
|
191
166
|
if (thread.blocks && thread.blocks.length !== 0) {
|
|
192
167
|
thread.blocks[thread.blocks.length - 1].returnValue = arrowFuncValue;
|
|
193
168
|
}
|
|
194
169
|
break;
|
|
195
|
-
case
|
|
170
|
+
case ScriptingSourceTreeExp_1.T_LET_STATEMENT: {
|
|
196
171
|
// --- Create a new variable in the innermost scope
|
|
197
172
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
198
173
|
if (!block) {
|
|
199
174
|
throw new Error("Missing block scope");
|
|
200
175
|
}
|
|
201
|
-
yield processDeclarationsAsync(block, evalContext, thread,
|
|
176
|
+
yield processDeclarationsAsync(block, evalContext, thread, statement.decls);
|
|
202
177
|
break;
|
|
203
178
|
}
|
|
204
|
-
case
|
|
179
|
+
case ScriptingSourceTreeExp_1.T_CONST_STATEMENT: {
|
|
205
180
|
// --- Create a new variable in the innermost scope
|
|
206
181
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
207
182
|
if (!block) {
|
|
208
183
|
throw new Error("Missing block scope");
|
|
209
184
|
}
|
|
210
|
-
yield processDeclarationsAsync(block, evalContext, thread,
|
|
185
|
+
yield processDeclarationsAsync(block, evalContext, thread, statement.decls, true);
|
|
211
186
|
break;
|
|
212
187
|
}
|
|
213
|
-
case
|
|
188
|
+
case ScriptingSourceTreeExp_1.T_IF_STATEMENT:
|
|
214
189
|
// --- Evaluate the condition
|
|
215
|
-
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
190
|
+
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.cond, evalContext, thread));
|
|
216
191
|
if (condition) {
|
|
217
|
-
toUnshift = (0, statement_queue_1.mapToItem)(statement.
|
|
192
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.thenB);
|
|
218
193
|
}
|
|
219
|
-
else if (statement.
|
|
220
|
-
toUnshift = (0, statement_queue_1.mapToItem)(statement.
|
|
194
|
+
else if (statement.elseB) {
|
|
195
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.elseB);
|
|
221
196
|
}
|
|
222
197
|
break;
|
|
223
|
-
case
|
|
198
|
+
case ScriptingSourceTreeExp_1.T_RETURN_STATEMENT: {
|
|
224
199
|
// --- Check if return is valid here
|
|
225
200
|
let blockScope = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
226
201
|
if (blockScope === undefined) {
|
|
227
202
|
throw new Error("Return requires a block scope");
|
|
228
203
|
}
|
|
229
204
|
// --- Store the return value
|
|
230
|
-
thread.returnValue = statement.
|
|
231
|
-
? yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
205
|
+
thread.returnValue = statement.expr
|
|
206
|
+
? yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread)
|
|
232
207
|
: undefined;
|
|
233
208
|
// --- Check for try blocks
|
|
234
|
-
if (((
|
|
209
|
+
if (((_c = thread.tryBlocks) !== null && _c !== void 0 ? _c : []).length > 0) {
|
|
235
210
|
// --- Mark the loop's try scope to exit with "return"
|
|
236
211
|
const returnTryScope = thread.tryBlocks[0];
|
|
237
212
|
returnTryScope.exitType = "return";
|
|
@@ -249,11 +224,11 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
249
224
|
}
|
|
250
225
|
break;
|
|
251
226
|
}
|
|
252
|
-
case
|
|
227
|
+
case ScriptingSourceTreeExp_1.T_WHILE_STATEMENT: {
|
|
253
228
|
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
254
|
-
let loopScope =
|
|
229
|
+
let loopScope = execInfo.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
|
|
255
230
|
// --- Evaluate the loop condition
|
|
256
|
-
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
231
|
+
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.cond, evalContext, thread));
|
|
257
232
|
if (condition) {
|
|
258
233
|
toUnshift = (0, process_statement_common_1.provideLoopBody)(loopScope, statement, thread.breakLabelValue);
|
|
259
234
|
}
|
|
@@ -263,14 +238,14 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
263
238
|
}
|
|
264
239
|
break;
|
|
265
240
|
}
|
|
266
|
-
case
|
|
267
|
-
if (!
|
|
241
|
+
case ScriptingSourceTreeExp_1.T_DO_WHILE_STATEMENT: {
|
|
242
|
+
if (!execInfo.guard) {
|
|
268
243
|
// --- First loop execution (do-while is a post-test loop)
|
|
269
244
|
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.createLoopScope)(thread), statement, thread.breakLabelValue);
|
|
270
245
|
break;
|
|
271
246
|
}
|
|
272
247
|
// --- Evaluate the loop condition
|
|
273
|
-
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
248
|
+
const condition = !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.cond, evalContext, thread));
|
|
274
249
|
if (condition) {
|
|
275
250
|
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.innermostLoopScope)(thread), statement, thread.breakLabelValue);
|
|
276
251
|
}
|
|
@@ -280,7 +255,7 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
280
255
|
}
|
|
281
256
|
break;
|
|
282
257
|
}
|
|
283
|
-
case
|
|
258
|
+
case ScriptingSourceTreeExp_1.T_CONTINUE_STATEMENT: {
|
|
284
259
|
// --- Search for the innermost non-switch loop scope, release the switch scopes
|
|
285
260
|
if (!thread.loops || thread.loops.length === 0) {
|
|
286
261
|
throw new Error("Missing loop scope");
|
|
@@ -296,7 +271,8 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
296
271
|
if (!loopScope) {
|
|
297
272
|
throw new Error("Missing loop scope");
|
|
298
273
|
}
|
|
299
|
-
if (loopScope.tryBlockDepth >= 0 &&
|
|
274
|
+
if (loopScope.tryBlockDepth >= 0 &&
|
|
275
|
+
loopScope.tryBlockDepth < ((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length) {
|
|
300
276
|
// --- Mark the loop's try scope to exit with "continue"
|
|
301
277
|
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
302
278
|
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "continue";
|
|
@@ -311,7 +287,7 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
311
287
|
}
|
|
312
288
|
break;
|
|
313
289
|
}
|
|
314
|
-
case
|
|
290
|
+
case ScriptingSourceTreeExp_1.T_BREAK_STATEMENT: {
|
|
315
291
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
316
292
|
if (loopScope === undefined) {
|
|
317
293
|
throw new Error("Missing loop scope");
|
|
@@ -322,7 +298,8 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
322
298
|
break;
|
|
323
299
|
}
|
|
324
300
|
// --- Break is in a loop construct
|
|
325
|
-
if (loopScope.tryBlockDepth >= 0 &&
|
|
301
|
+
if (loopScope.tryBlockDepth >= 0 &&
|
|
302
|
+
loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
|
|
326
303
|
// --- Mark the loop's try scope to exit with "break"
|
|
327
304
|
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
328
305
|
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "break";
|
|
@@ -337,19 +314,19 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
337
314
|
}
|
|
338
315
|
break;
|
|
339
316
|
}
|
|
340
|
-
case
|
|
341
|
-
if (!
|
|
317
|
+
case ScriptingSourceTreeExp_1.T_FOR_STATEMENT:
|
|
318
|
+
if (!execInfo.guard) {
|
|
342
319
|
// --- Init the loop with a new scope
|
|
343
320
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
344
321
|
// --- Create a new block for the loop variables
|
|
345
|
-
(
|
|
322
|
+
(_f = thread.blocks) !== null && _f !== void 0 ? _f : (thread.blocks = []);
|
|
346
323
|
thread.blocks.push({
|
|
347
324
|
vars: {},
|
|
348
325
|
});
|
|
349
|
-
const guardStatement =
|
|
326
|
+
const guardStatement = (0, process_statement_common_1.guard)(statement);
|
|
350
327
|
if (statement.init) {
|
|
351
328
|
// --- Unshift the initialization part and the guarded for-loop
|
|
352
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.init, guardStatement]);
|
|
329
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([{ statement: statement.init }, guardStatement]);
|
|
353
330
|
}
|
|
354
331
|
else {
|
|
355
332
|
// --- No init, unshift only the guard statement
|
|
@@ -358,22 +335,31 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
358
335
|
}
|
|
359
336
|
else {
|
|
360
337
|
// --- Initialization already done. Evaluate the condition
|
|
361
|
-
if (!statement.
|
|
362
|
-
!!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.condition, evalContext, thread, onStatementCompleted))) {
|
|
338
|
+
if (!statement.cond || !!(yield (0, eval_tree_async_1.evalBindingAsync)(statement.cond, evalContext, thread))) {
|
|
363
339
|
// --- Stay in the loop, inject the body, the update expression, and the loop guard
|
|
364
340
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
365
|
-
if (statement.
|
|
341
|
+
if (statement.upd) {
|
|
366
342
|
const updateStmt = {
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
statement: {
|
|
344
|
+
type: ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT,
|
|
345
|
+
nodeId: (0, Parser_1.createXmlUiTreeNodeId)(),
|
|
346
|
+
expr: statement.upd,
|
|
347
|
+
},
|
|
369
348
|
};
|
|
370
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
349
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
350
|
+
{ statement: statement.body },
|
|
351
|
+
updateStmt,
|
|
352
|
+
{ statement, execInfo },
|
|
353
|
+
]);
|
|
371
354
|
}
|
|
372
355
|
else {
|
|
373
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
356
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
357
|
+
{ statement: statement.body },
|
|
358
|
+
{ statement, execInfo },
|
|
359
|
+
]);
|
|
374
360
|
}
|
|
375
361
|
// --- The next queue label is for "break"
|
|
376
|
-
loopScope.breakLabel = (
|
|
362
|
+
loopScope.breakLabel = (_g = thread.breakLabelValue) !== null && _g !== void 0 ? _g : -1;
|
|
377
363
|
// --- The guard action's label is for "continue"
|
|
378
364
|
loopScope.continueLabel = toUnshift[1].label;
|
|
379
365
|
}
|
|
@@ -383,10 +369,10 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
383
369
|
}
|
|
384
370
|
}
|
|
385
371
|
break;
|
|
386
|
-
case
|
|
387
|
-
if (!
|
|
372
|
+
case ScriptingSourceTreeExp_1.T_FOR_IN_STATEMENT:
|
|
373
|
+
if (!execInfo.guard) {
|
|
388
374
|
// --- Get the object keys
|
|
389
|
-
const keyedObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
375
|
+
const keyedObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread);
|
|
390
376
|
if (keyedObject == undefined) {
|
|
391
377
|
// --- Nothing to do, no object to traverse
|
|
392
378
|
break;
|
|
@@ -394,32 +380,32 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
394
380
|
// --- Init the loop with a new scope
|
|
395
381
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
396
382
|
// --- Create a new block for the loop variables
|
|
397
|
-
(
|
|
383
|
+
(_h = thread.blocks) !== null && _h !== void 0 ? _h : (thread.blocks = []);
|
|
398
384
|
thread.blocks.push({ vars: {} });
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
385
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
386
|
+
{ statement, execInfo: { guard: true, keys: Object.keys(keyedObject), keyIndex: 0 } },
|
|
387
|
+
]);
|
|
402
388
|
}
|
|
403
389
|
else {
|
|
404
390
|
// --- Just for the sake of extra safety
|
|
405
|
-
if (
|
|
391
|
+
if (execInfo.keyIndex === undefined || execInfo.keys === undefined) {
|
|
406
392
|
throw new Error("Keys information expected in for..in loop");
|
|
407
393
|
}
|
|
408
394
|
// --- Any key left?
|
|
409
|
-
if (
|
|
395
|
+
if (execInfo.keyIndex < execInfo.keys.length) {
|
|
410
396
|
// --- Set the binding variable to the next key
|
|
411
|
-
const propValue =
|
|
412
|
-
switch (statement.
|
|
397
|
+
const propValue = execInfo.keys[execInfo.keyIndex++];
|
|
398
|
+
switch (statement.varB) {
|
|
413
399
|
case "none": {
|
|
414
400
|
const assigmentExpr = {
|
|
415
|
-
type:
|
|
401
|
+
type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
|
|
416
402
|
leftValue: {
|
|
417
|
-
type:
|
|
418
|
-
name: statement.id,
|
|
403
|
+
type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
|
|
404
|
+
name: statement.id.name,
|
|
419
405
|
},
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
type:
|
|
406
|
+
op: "=",
|
|
407
|
+
expr: {
|
|
408
|
+
type: ScriptingSourceTreeExp_1.T_LITERAL,
|
|
423
409
|
value: propValue,
|
|
424
410
|
},
|
|
425
411
|
};
|
|
@@ -434,19 +420,22 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
434
420
|
if (!block) {
|
|
435
421
|
throw new Error("Missing block scope");
|
|
436
422
|
}
|
|
437
|
-
block.vars[statement.id] = propValue;
|
|
438
|
-
if (statement.
|
|
439
|
-
(
|
|
440
|
-
block.constVars.add(statement.id);
|
|
423
|
+
block.vars[statement.id.name] = propValue;
|
|
424
|
+
if (statement.varB === "const") {
|
|
425
|
+
(_j = block.constVars) !== null && _j !== void 0 ? _j : (block.constVars = new Set());
|
|
426
|
+
block.constVars.add(statement.id.name);
|
|
441
427
|
}
|
|
442
428
|
}
|
|
443
429
|
break;
|
|
444
430
|
}
|
|
445
431
|
// --- Inject the loop body
|
|
446
432
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
447
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
433
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
434
|
+
{ statement: statement.body },
|
|
435
|
+
{ statement, execInfo },
|
|
436
|
+
]);
|
|
448
437
|
// --- The next queue label is for "break"
|
|
449
|
-
loopScope.breakLabel = (
|
|
438
|
+
loopScope.breakLabel = (_k = thread.breakLabelValue) !== null && _k !== void 0 ? _k : -1;
|
|
450
439
|
// --- The guard action's label is for "continue"
|
|
451
440
|
loopScope.continueLabel = toUnshift[1].label;
|
|
452
441
|
}
|
|
@@ -456,10 +445,10 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
456
445
|
}
|
|
457
446
|
}
|
|
458
447
|
break;
|
|
459
|
-
case
|
|
460
|
-
if (!
|
|
448
|
+
case ScriptingSourceTreeExp_1.T_FOR_OF_STATEMENT:
|
|
449
|
+
if (!execInfo.guard) {
|
|
461
450
|
// --- Get the object keys
|
|
462
|
-
const iteratorObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
451
|
+
const iteratorObject = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread);
|
|
463
452
|
if (iteratorObject == null || typeof iteratorObject[Symbol.iterator] !== "function") {
|
|
464
453
|
// --- The object is not an iterator
|
|
465
454
|
throw new Error("Object in for..of is not iterable");
|
|
@@ -467,18 +456,19 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
467
456
|
// --- Init the loop with a new scope
|
|
468
457
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
469
458
|
// --- Create a new block for the loop variables
|
|
470
|
-
(
|
|
459
|
+
(_l = thread.blocks) !== null && _l !== void 0 ? _l : (thread.blocks = []);
|
|
471
460
|
thread.blocks.push({ vars: {} });
|
|
472
|
-
|
|
473
|
-
|
|
461
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
462
|
+
{ statement, execInfo: { guard: true, iterator: iteratorObject[Symbol.iterator]() } },
|
|
463
|
+
]);
|
|
474
464
|
}
|
|
475
465
|
else {
|
|
476
466
|
// --- Just for the sake of extra safety
|
|
477
|
-
if (
|
|
467
|
+
if (execInfo.iterator === undefined) {
|
|
478
468
|
throw new Error("Iterator expected in for..of loop");
|
|
479
469
|
}
|
|
480
470
|
// --- Any iteration left?
|
|
481
|
-
const nextIteration =
|
|
471
|
+
const nextIteration = execInfo.iterator.next();
|
|
482
472
|
if (nextIteration.done) {
|
|
483
473
|
// --- The for..of loop is complete. Remove the loop's scope from the evaluation context
|
|
484
474
|
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
@@ -486,17 +476,17 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
486
476
|
}
|
|
487
477
|
// --- Set the binding variable to the next key
|
|
488
478
|
const propValue = nextIteration.value;
|
|
489
|
-
switch (statement.
|
|
479
|
+
switch (statement.varB) {
|
|
490
480
|
case "none": {
|
|
491
481
|
const assigmentExpr = {
|
|
492
|
-
type:
|
|
482
|
+
type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
|
|
493
483
|
leftValue: {
|
|
494
|
-
type:
|
|
495
|
-
name: statement.id,
|
|
484
|
+
type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
|
|
485
|
+
name: statement.id.name,
|
|
496
486
|
},
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
type:
|
|
487
|
+
op: "=",
|
|
488
|
+
expr: {
|
|
489
|
+
type: ScriptingSourceTreeExp_1.T_LITERAL,
|
|
500
490
|
value: propValue,
|
|
501
491
|
},
|
|
502
492
|
};
|
|
@@ -511,28 +501,31 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
511
501
|
if (!block) {
|
|
512
502
|
throw new Error("Missing block scope");
|
|
513
503
|
}
|
|
514
|
-
block.vars[statement.id] = propValue;
|
|
515
|
-
if (statement.
|
|
516
|
-
(
|
|
517
|
-
block.constVars.add(statement.id);
|
|
504
|
+
block.vars[statement.id.name] = propValue;
|
|
505
|
+
if (statement.varB === "const") {
|
|
506
|
+
(_m = block.constVars) !== null && _m !== void 0 ? _m : (block.constVars = new Set());
|
|
507
|
+
block.constVars.add(statement.id.name);
|
|
518
508
|
}
|
|
519
509
|
}
|
|
520
510
|
break;
|
|
521
511
|
}
|
|
522
512
|
// --- Inject the loop body
|
|
523
513
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
524
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
514
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
515
|
+
{ statement: statement.body },
|
|
516
|
+
{ statement, execInfo },
|
|
517
|
+
]);
|
|
525
518
|
// --- The next queue label is for "break"
|
|
526
|
-
loopScope.breakLabel = (
|
|
519
|
+
loopScope.breakLabel = (_o = thread.breakLabelValue) !== null && _o !== void 0 ? _o : -1;
|
|
527
520
|
// --- The guard action's label is for "continue"
|
|
528
521
|
loopScope.continueLabel = toUnshift[1].label;
|
|
529
522
|
}
|
|
530
523
|
break;
|
|
531
|
-
case
|
|
532
|
-
throw new EngineError_1.ThrowStatementError(yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
524
|
+
case ScriptingSourceTreeExp_1.T_THROW_STATEMENT: {
|
|
525
|
+
throw new EngineError_1.ThrowStatementError(yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread));
|
|
533
526
|
}
|
|
534
|
-
case
|
|
535
|
-
if (!
|
|
527
|
+
case ScriptingSourceTreeExp_1.T_TRY_STATEMENT: {
|
|
528
|
+
if (!execInfo.guard) {
|
|
536
529
|
// --- Execute the try block
|
|
537
530
|
toUnshift = (0, process_statement_common_1.provideTryBody)(thread, (0, process_statement_common_1.createTryScope)(thread, statement));
|
|
538
531
|
break;
|
|
@@ -547,10 +540,10 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
547
540
|
// --- Remove the "try" block's scope
|
|
548
541
|
thread.blocks.pop();
|
|
549
542
|
// --- Go on with catch or finally
|
|
550
|
-
if (statement.
|
|
551
|
-
if (tryScope.statement.
|
|
543
|
+
if (statement.catchB) {
|
|
544
|
+
if (tryScope.statement.catchV) {
|
|
552
545
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
553
|
-
block.vars[tryScope.statement.
|
|
546
|
+
block.vars[tryScope.statement.catchV.name] =
|
|
554
547
|
tryScope.errorToThrow instanceof EngineError_1.ThrowStatementError
|
|
555
548
|
? tryScope.errorToThrow.errorObject
|
|
556
549
|
: tryScope.errorToThrow;
|
|
@@ -559,7 +552,7 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
559
552
|
tryScope.processingPhase = "catch";
|
|
560
553
|
toUnshift = (0, process_statement_common_1.provideCatchBody)(thread, tryScope);
|
|
561
554
|
}
|
|
562
|
-
else if (tryScope.statement.
|
|
555
|
+
else if (tryScope.statement.finallyB) {
|
|
563
556
|
// --- No catch, move on finally
|
|
564
557
|
tryScope.processingPhase = "finally";
|
|
565
558
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
@@ -584,14 +577,14 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
584
577
|
case "try":
|
|
585
578
|
// --- We completed the try block successfully
|
|
586
579
|
tryScope.processingPhase = "finally";
|
|
587
|
-
if (statement.
|
|
580
|
+
if (statement.finallyB) {
|
|
588
581
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
589
582
|
}
|
|
590
583
|
break;
|
|
591
584
|
case "catch":
|
|
592
585
|
// --- We completed the catch block successfully, remove the handled error
|
|
593
586
|
tryScope.processingPhase = "finally";
|
|
594
|
-
if (statement.
|
|
587
|
+
if (statement.finallyB) {
|
|
595
588
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
596
589
|
}
|
|
597
590
|
break;
|
|
@@ -634,9 +627,9 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
634
627
|
}
|
|
635
628
|
break;
|
|
636
629
|
}
|
|
637
|
-
case
|
|
630
|
+
case ScriptingSourceTreeExp_1.T_SWITCH_STATEMENT: {
|
|
638
631
|
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
639
|
-
if (
|
|
632
|
+
if (execInfo.guard) {
|
|
640
633
|
// --- Complete the switch
|
|
641
634
|
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
642
635
|
}
|
|
@@ -645,18 +638,18 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
645
638
|
loopScope.isSwitch = true;
|
|
646
639
|
thread.blocks.push({ vars: {} });
|
|
647
640
|
// --- Evaluate the switch value
|
|
648
|
-
const switchValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.
|
|
641
|
+
const switchValue = yield (0, eval_tree_async_1.evalBindingAsync)(statement.expr, evalContext, thread);
|
|
649
642
|
// --- Find the matching label
|
|
650
643
|
let matchingIndex = -1;
|
|
651
644
|
for (let i = 0; i < statement.cases.length; i++) {
|
|
652
645
|
const currentCase = statement.cases[i];
|
|
653
646
|
// --- Check for default case
|
|
654
|
-
if (currentCase.
|
|
647
|
+
if (currentCase.caseE === undefined) {
|
|
655
648
|
matchingIndex = i;
|
|
656
649
|
break;
|
|
657
650
|
}
|
|
658
651
|
// --- Check for matching case
|
|
659
|
-
const caseValue = yield (0, eval_tree_async_1.evalBindingAsync)(currentCase.
|
|
652
|
+
const caseValue = yield (0, eval_tree_async_1.evalBindingAsync)(currentCase.caseE, evalContext, thread);
|
|
660
653
|
if (caseValue === switchValue) {
|
|
661
654
|
matchingIndex = i;
|
|
662
655
|
break;
|
|
@@ -666,19 +659,21 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
666
659
|
const statementFlow = [];
|
|
667
660
|
if (matchingIndex >= 0) {
|
|
668
661
|
for (let i = matchingIndex; i < statement.cases.length; i++) {
|
|
669
|
-
statementFlow.push(...statement.cases[i].
|
|
662
|
+
statementFlow.push(...statement.cases[i].stmts);
|
|
670
663
|
}
|
|
671
664
|
}
|
|
672
665
|
// --- Queue the statement flow and the guard
|
|
673
|
-
|
|
674
|
-
|
|
666
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
667
|
+
...(0, process_statement_common_1.toStatementItems)(statementFlow),
|
|
668
|
+
(0, process_statement_common_1.guard)(statement),
|
|
669
|
+
]);
|
|
675
670
|
loopScope.breakLabel = toUnshift[toUnshift.length - 1].label;
|
|
676
671
|
}
|
|
677
672
|
break;
|
|
678
673
|
}
|
|
679
674
|
}
|
|
680
675
|
// --- The statement may remove the innermost scope
|
|
681
|
-
if (
|
|
676
|
+
if (execInfo.removeBlockScope) {
|
|
682
677
|
if (thread.blocks && thread.blocks.length > 0) {
|
|
683
678
|
thread.blocks.pop();
|
|
684
679
|
}
|
|
@@ -688,16 +683,16 @@ function processStatementAsync(statement, evalContext, thread, onStatementComple
|
|
|
688
683
|
});
|
|
689
684
|
}
|
|
690
685
|
// --- Process a variable declaration
|
|
691
|
-
function processDeclarationsAsync(block_1, evalContext_1, thread_1,
|
|
692
|
-
return __awaiter(this, arguments, void 0, function* (block, evalContext, thread,
|
|
686
|
+
function processDeclarationsAsync(block_1, evalContext_1, thread_1, declarations_1) {
|
|
687
|
+
return __awaiter(this, arguments, void 0, function* (block, evalContext, thread, declarations, addConst = false, useValue = false, baseValue = undefined) {
|
|
693
688
|
for (let i = 0; i < declarations.length; i++) {
|
|
694
689
|
let value;
|
|
695
690
|
const decl = declarations[i];
|
|
696
691
|
if (useValue) {
|
|
697
692
|
value = baseValue;
|
|
698
693
|
}
|
|
699
|
-
else if (decl.
|
|
700
|
-
value = yield (0, eval_tree_async_1.evalBindingAsync)(decl.
|
|
694
|
+
else if (decl.expr) {
|
|
695
|
+
value = yield (0, eval_tree_async_1.evalBindingAsync)(decl.expr, evalContext, thread);
|
|
701
696
|
}
|
|
702
697
|
visitDeclaration(block, decl, value, addConst);
|
|
703
698
|
}
|
|
@@ -707,11 +702,11 @@ function processDeclarationsAsync(block_1, evalContext_1, thread_1, onStatementC
|
|
|
707
702
|
if (decl.id) {
|
|
708
703
|
visitIdDeclaration(block, decl.id, baseValue, addConst);
|
|
709
704
|
}
|
|
710
|
-
else if (decl.
|
|
711
|
-
visitArrayDestruct(block, decl.
|
|
705
|
+
else if (decl.aDestr) {
|
|
706
|
+
visitArrayDestruct(block, decl.aDestr, baseValue, addConst);
|
|
712
707
|
}
|
|
713
|
-
else if (decl.
|
|
714
|
-
visitObjectDestruct(block, decl.
|
|
708
|
+
else if (decl.oDestr) {
|
|
709
|
+
visitObjectDestruct(block, decl.oDestr, baseValue, addConst);
|
|
715
710
|
}
|
|
716
711
|
else {
|
|
717
712
|
throw new Error("Unknown declaration specifier");
|
|
@@ -737,11 +732,11 @@ function processDeclarationsAsync(block_1, evalContext_1, thread_1, onStatementC
|
|
|
737
732
|
if (arrDecl.id) {
|
|
738
733
|
visitIdDeclaration(block, arrDecl.id, value, addConst);
|
|
739
734
|
}
|
|
740
|
-
else if (arrDecl.
|
|
741
|
-
visitArrayDestruct(block, arrDecl.
|
|
735
|
+
else if (arrDecl.aDestr) {
|
|
736
|
+
visitArrayDestruct(block, arrDecl.aDestr, value, addConst);
|
|
742
737
|
}
|
|
743
|
-
else if (arrDecl.
|
|
744
|
-
visitObjectDestruct(block, arrDecl.
|
|
738
|
+
else if (arrDecl.oDestr) {
|
|
739
|
+
visitObjectDestruct(block, arrDecl.oDestr, value, addConst);
|
|
745
740
|
}
|
|
746
741
|
}
|
|
747
742
|
}
|
|
@@ -751,11 +746,11 @@ function processDeclarationsAsync(block_1, evalContext_1, thread_1, onStatementC
|
|
|
751
746
|
for (let i = 0; i < objectD.length; i++) {
|
|
752
747
|
const objDecl = objectD[i];
|
|
753
748
|
const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[objDecl.id];
|
|
754
|
-
if (objDecl.
|
|
755
|
-
visitArrayDestruct(block, objDecl.
|
|
749
|
+
if (objDecl.aDestr) {
|
|
750
|
+
visitArrayDestruct(block, objDecl.aDestr, value, addConst);
|
|
756
751
|
}
|
|
757
|
-
else if (objDecl.
|
|
758
|
-
visitObjectDestruct(block, objDecl.
|
|
752
|
+
else if (objDecl.oDestr) {
|
|
753
|
+
visitObjectDestruct(block, objDecl.oDestr, value, addConst);
|
|
759
754
|
}
|
|
760
755
|
else {
|
|
761
756
|
visitIdDeclaration(block, (_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id, value, addConst);
|