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
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processStatementQueue = processStatementQueue;
|
|
4
4
|
exports.processDeclarations = processDeclarations;
|
|
5
|
-
const
|
|
5
|
+
const ScriptingSourceTreeExp_1 = require("../../abstractions/scripting/ScriptingSourceTreeExp");
|
|
6
6
|
const reportEngineError_1 = require("../reportEngineError");
|
|
7
7
|
const EngineError_1 = require("../EngineError");
|
|
8
8
|
const process_statement_common_1 = require("./process-statement-common");
|
|
9
|
+
const eval_tree_sync_1 = require("./eval-tree-sync");
|
|
9
10
|
const statement_queue_1 = require("./statement-queue");
|
|
11
|
+
const Parser_1 = require("../../parsers/scripting-exp/Parser");
|
|
10
12
|
const SYNC_EVAL_TIMEOUT = 1000;
|
|
11
13
|
// --- Helper function to process the entire queue synchronously
|
|
12
14
|
function processStatementQueue(statements, evalContext, thread) {
|
|
13
|
-
var _a;
|
|
15
|
+
var _a, _b, _c;
|
|
14
16
|
if (!thread) {
|
|
15
17
|
// --- Create the main thread for the queue
|
|
16
18
|
thread = (0, process_statement_common_1.ensureMainThread)(evalContext);
|
|
@@ -21,7 +23,7 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
21
23
|
evalContext.startTick = new Date().valueOf();
|
|
22
24
|
// --- Fill the queue with items
|
|
23
25
|
const queue = new statement_queue_1.StatementQueue();
|
|
24
|
-
queue.push((0, statement_queue_1.mapStatementsToQueueItems)(statements));
|
|
26
|
+
queue.push((0, statement_queue_1.mapStatementsToQueueItems)((0, process_statement_common_1.toStatementItems)(statements)));
|
|
25
27
|
// --- Prepare queue diagnostics information
|
|
26
28
|
const diagInfo = {
|
|
27
29
|
processedStatements: 0,
|
|
@@ -43,7 +45,10 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
43
45
|
thread.breakLabelValue = queue.length > 0 ? queue.peek().label : -1;
|
|
44
46
|
let outcome;
|
|
45
47
|
try {
|
|
46
|
-
|
|
48
|
+
// --- Sign that the statement is about to start
|
|
49
|
+
(_a = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementStarted) === null || _a === void 0 ? void 0 : _a.call(evalContext, evalContext, queueItem.statement);
|
|
50
|
+
// --- Execute the statement
|
|
51
|
+
outcome = processStatement(queueItem.statement, (_b = queueItem.execInfo) !== null && _b !== void 0 ? _b : {}, evalContext, thread);
|
|
47
52
|
}
|
|
48
53
|
catch (err) {
|
|
49
54
|
if (thread.tryBlocks && thread.tryBlocks.length > 0) {
|
|
@@ -63,7 +68,8 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
63
68
|
(0, reportEngineError_1.reportEngineError)(err);
|
|
64
69
|
}
|
|
65
70
|
else {
|
|
66
|
-
|
|
71
|
+
// TODO: Provide source code information
|
|
72
|
+
(0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err /* queueItem!.statement?.source */), err);
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -78,6 +84,8 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
78
84
|
diagInfo.clearToLabels++;
|
|
79
85
|
}
|
|
80
86
|
}
|
|
87
|
+
// --- Sign that the statement has been completed
|
|
88
|
+
(_c = evalContext === null || evalContext === void 0 ? void 0 : evalContext.onStatementCompleted) === null || _c === void 0 ? void 0 : _c.call(evalContext, evalContext, queueItem.statement);
|
|
81
89
|
// --- Provide diagnostics
|
|
82
90
|
if (queue.length > diagInfo.maxQueueLength) {
|
|
83
91
|
diagInfo.maxQueueLength = queue.length;
|
|
@@ -90,6 +98,7 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
90
98
|
}
|
|
91
99
|
diagInfo.processedStatements++;
|
|
92
100
|
}
|
|
101
|
+
// --- Done.
|
|
93
102
|
return diagInfo;
|
|
94
103
|
}
|
|
95
104
|
/**
|
|
@@ -99,128 +108,94 @@ function processStatementQueue(statements, evalContext, thread) {
|
|
|
99
108
|
* @param thread Logical thread to use for statement processing
|
|
100
109
|
* @returns Items to put back into the queue of statements
|
|
101
110
|
*/
|
|
102
|
-
function processStatement(statement, evalContext, thread) {
|
|
103
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
111
|
+
function processStatement(statement, execInfo, evalContext, thread) {
|
|
112
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
104
113
|
// --- These items should be put in the statement queue after return
|
|
105
114
|
let toUnshift = [];
|
|
106
115
|
let clearToLabel;
|
|
107
116
|
// --- Process the statement according to its type
|
|
108
117
|
switch (statement.type) {
|
|
109
|
-
case
|
|
110
|
-
// --- Get module information
|
|
111
|
-
const thisModule = statement.module;
|
|
112
|
-
if (!thisModule) {
|
|
113
|
-
throw new Error("Missing module");
|
|
114
|
-
}
|
|
115
|
-
const parentModule = (_a = statement.module) === null || _a === void 0 ? void 0 : _a.parent;
|
|
116
|
-
if (!parentModule) {
|
|
117
|
-
throw new Error("Missing parent module");
|
|
118
|
-
}
|
|
119
|
-
// --- At this point the imported module is set
|
|
120
|
-
// if (!statement.module!.executed) {
|
|
121
|
-
// // --- Run the module, it has not been executed yet
|
|
122
|
-
// const childEvalContext = createEvalContext({
|
|
123
|
-
// cancellationToken: evalContext.cancellationToken,
|
|
124
|
-
// timeout: evalContext.timeout ?? 1000
|
|
125
|
-
// });
|
|
126
|
-
// statement.module!.executed = true;
|
|
127
|
-
// executeScriptModule(statement.module!, childEvalContext);
|
|
128
|
-
// }
|
|
129
|
-
// --- Import the module's exported variables into the parent module
|
|
130
|
-
const topVars = evalContext.mainThread.blocks[0].vars;
|
|
131
|
-
const topConst = evalContext.mainThread.blocks[0].constVars;
|
|
132
|
-
for (const modImports of Object.values(statement.imports)) {
|
|
133
|
-
for (const key of Object.keys(modImports)) {
|
|
134
|
-
if (key in topVars) {
|
|
135
|
-
throw new Error(`Import ${key} already exists`);
|
|
136
|
-
}
|
|
137
|
-
topVars[key] = statement.module.exports.get(modImports[key]);
|
|
138
|
-
topConst.add(key);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case "FuncD":
|
|
118
|
+
case ScriptingSourceTreeExp_1.T_FUNCTION_DECLARATION:
|
|
143
119
|
// --- Function declarations are already hoisted, nothing to do
|
|
144
120
|
break;
|
|
145
|
-
case
|
|
121
|
+
case ScriptingSourceTreeExp_1.T_VAR_STATEMENT:
|
|
146
122
|
if (thread !== evalContext.mainThread) {
|
|
147
123
|
throw new Error("'var' declarations are not allowed within functions");
|
|
148
124
|
}
|
|
149
125
|
break;
|
|
150
|
-
case
|
|
126
|
+
case ScriptingSourceTreeExp_1.T_EMPTY_STATEMENT:
|
|
151
127
|
// --- Nothing to do
|
|
152
128
|
break;
|
|
153
|
-
case
|
|
129
|
+
case ScriptingSourceTreeExp_1.T_BLOCK_STATEMENT:
|
|
154
130
|
// --- No statement, nothing to process
|
|
155
|
-
if (statement.
|
|
131
|
+
if (statement.stmts.length === 0)
|
|
156
132
|
break;
|
|
157
133
|
// --- Create a new block scope
|
|
158
|
-
(
|
|
134
|
+
(_a = thread.blocks) !== null && _a !== void 0 ? _a : (thread.blocks = []);
|
|
159
135
|
thread.blocks.push({ vars: {} });
|
|
160
136
|
// --- Hoist function declarations to the innermost block scope
|
|
161
|
-
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.
|
|
162
|
-
// ---
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statement.statements, closing]);
|
|
137
|
+
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.stmts);
|
|
138
|
+
// --- Queue the block scope's body...
|
|
139
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
140
|
+
...(0, process_statement_common_1.toStatementItems)(statement.stmts),
|
|
141
|
+
// --- ...and an empty statement to remove the block scope
|
|
142
|
+
(0, process_statement_common_1.closing)(),
|
|
143
|
+
]);
|
|
169
144
|
break;
|
|
170
|
-
case
|
|
145
|
+
case ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT:
|
|
171
146
|
// --- Just evaluate it
|
|
172
|
-
const statementValue = (0, eval_tree_sync_1.evalBinding)(statement.
|
|
147
|
+
const statementValue = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
|
|
173
148
|
if (thread.blocks && thread.blocks.length !== 0) {
|
|
174
149
|
thread.blocks[thread.blocks.length - 1].returnValue = statementValue;
|
|
175
150
|
}
|
|
176
151
|
break;
|
|
177
|
-
case
|
|
152
|
+
case ScriptingSourceTreeExp_1.T_ARROW_EXPRESSION_STATEMENT:
|
|
178
153
|
// --- Compile the arrow expression
|
|
179
|
-
const arrowFuncValue = (0, eval_tree_sync_1.executeArrowExpressionSync)(statement.
|
|
154
|
+
const arrowFuncValue = (0, eval_tree_sync_1.executeArrowExpressionSync)(statement.expr, evalContext, thread, ...((_b = evalContext.eventArgs) !== null && _b !== void 0 ? _b : []));
|
|
180
155
|
if (thread.blocks && thread.blocks.length !== 0) {
|
|
181
156
|
thread.blocks[thread.blocks.length - 1].returnValue = arrowFuncValue;
|
|
182
157
|
}
|
|
183
158
|
break;
|
|
184
|
-
case
|
|
159
|
+
case ScriptingSourceTreeExp_1.T_LET_STATEMENT: {
|
|
185
160
|
// --- Create a new variable in the innermost scope
|
|
186
161
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
187
162
|
if (!block) {
|
|
188
163
|
throw new Error("Missing block scope");
|
|
189
164
|
}
|
|
190
|
-
processDeclarations(block, evalContext, thread, statement.
|
|
165
|
+
processDeclarations(block, evalContext, thread, statement.decls);
|
|
191
166
|
break;
|
|
192
167
|
}
|
|
193
|
-
case
|
|
168
|
+
case ScriptingSourceTreeExp_1.T_CONST_STATEMENT: {
|
|
194
169
|
// --- Create a new variable in the innermost scope
|
|
195
170
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
196
171
|
if (!block) {
|
|
197
172
|
throw new Error("Missing block scope");
|
|
198
173
|
}
|
|
199
|
-
processDeclarations(block, evalContext, thread, statement.
|
|
174
|
+
processDeclarations(block, evalContext, thread, statement.decls, true);
|
|
200
175
|
break;
|
|
201
176
|
}
|
|
202
|
-
case
|
|
177
|
+
case ScriptingSourceTreeExp_1.T_IF_STATEMENT:
|
|
203
178
|
// --- Evaluate the condition
|
|
204
|
-
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.
|
|
179
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
|
|
205
180
|
if (condition) {
|
|
206
|
-
toUnshift = (0, statement_queue_1.mapToItem)(statement.
|
|
181
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.thenB);
|
|
207
182
|
}
|
|
208
|
-
else if (statement.
|
|
209
|
-
toUnshift = (0, statement_queue_1.mapToItem)(statement.
|
|
183
|
+
else if (statement.elseB) {
|
|
184
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.elseB);
|
|
210
185
|
}
|
|
211
186
|
break;
|
|
212
|
-
case
|
|
187
|
+
case ScriptingSourceTreeExp_1.T_RETURN_STATEMENT: {
|
|
213
188
|
// --- Check if return is valid here
|
|
214
189
|
let blockScope = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
215
190
|
if (blockScope === undefined) {
|
|
216
191
|
throw new Error("Return requires a block scope");
|
|
217
192
|
}
|
|
218
193
|
// --- Store the return value
|
|
219
|
-
thread.returnValue = statement.
|
|
220
|
-
? (0, eval_tree_sync_1.evalBinding)(statement.
|
|
194
|
+
thread.returnValue = statement.expr
|
|
195
|
+
? (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread)
|
|
221
196
|
: undefined;
|
|
222
197
|
// --- Check for try blocks
|
|
223
|
-
if (((
|
|
198
|
+
if (((_c = thread.tryBlocks) !== null && _c !== void 0 ? _c : []).length > 0) {
|
|
224
199
|
// --- Mark the loop's try scope to exit with "return"
|
|
225
200
|
const returnTryScope = thread.tryBlocks[0];
|
|
226
201
|
returnTryScope.exitType = "return";
|
|
@@ -238,11 +213,11 @@ function processStatement(statement, evalContext, thread) {
|
|
|
238
213
|
}
|
|
239
214
|
break;
|
|
240
215
|
}
|
|
241
|
-
case
|
|
216
|
+
case ScriptingSourceTreeExp_1.T_WHILE_STATEMENT: {
|
|
242
217
|
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
243
|
-
let loopScope =
|
|
218
|
+
let loopScope = execInfo.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
|
|
244
219
|
// --- Evaluate the loop condition
|
|
245
|
-
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.
|
|
220
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
|
|
246
221
|
if (condition) {
|
|
247
222
|
toUnshift = (0, process_statement_common_1.provideLoopBody)(loopScope, statement, thread.breakLabelValue);
|
|
248
223
|
}
|
|
@@ -252,14 +227,14 @@ function processStatement(statement, evalContext, thread) {
|
|
|
252
227
|
}
|
|
253
228
|
break;
|
|
254
229
|
}
|
|
255
|
-
case
|
|
256
|
-
if (!
|
|
230
|
+
case ScriptingSourceTreeExp_1.T_DO_WHILE_STATEMENT: {
|
|
231
|
+
if (!execInfo.guard) {
|
|
257
232
|
// --- First loop execution (do-while is a post-test loop)
|
|
258
233
|
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.createLoopScope)(thread), statement, thread.breakLabelValue);
|
|
259
234
|
break;
|
|
260
235
|
}
|
|
261
236
|
// --- Evaluate the loop condition
|
|
262
|
-
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.
|
|
237
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread);
|
|
263
238
|
if (condition) {
|
|
264
239
|
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.innermostLoopScope)(thread), statement, thread.breakLabelValue);
|
|
265
240
|
}
|
|
@@ -269,7 +244,7 @@ function processStatement(statement, evalContext, thread) {
|
|
|
269
244
|
}
|
|
270
245
|
break;
|
|
271
246
|
}
|
|
272
|
-
case
|
|
247
|
+
case ScriptingSourceTreeExp_1.T_CONTINUE_STATEMENT: {
|
|
273
248
|
// --- Search for the innermost non-switch loop scope, release the switch scopes
|
|
274
249
|
if (!thread.loops || thread.loops.length === 0) {
|
|
275
250
|
throw new Error("Missing loop scope");
|
|
@@ -286,7 +261,7 @@ function processStatement(statement, evalContext, thread) {
|
|
|
286
261
|
throw new Error("Missing loop scope");
|
|
287
262
|
}
|
|
288
263
|
if (loopScope.tryBlockDepth >= 0 &&
|
|
289
|
-
loopScope.tryBlockDepth < ((
|
|
264
|
+
loopScope.tryBlockDepth < ((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length) {
|
|
290
265
|
// --- Mark the loop's try scope to exit with "continue"
|
|
291
266
|
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
292
267
|
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "continue";
|
|
@@ -301,7 +276,7 @@ function processStatement(statement, evalContext, thread) {
|
|
|
301
276
|
}
|
|
302
277
|
break;
|
|
303
278
|
}
|
|
304
|
-
case
|
|
279
|
+
case ScriptingSourceTreeExp_1.T_BREAK_STATEMENT: {
|
|
305
280
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
306
281
|
if (loopScope === undefined) {
|
|
307
282
|
throw new Error("Missing loop scope");
|
|
@@ -313,7 +288,7 @@ function processStatement(statement, evalContext, thread) {
|
|
|
313
288
|
}
|
|
314
289
|
// --- Break is in a loop construct
|
|
315
290
|
if (loopScope.tryBlockDepth >= 0 &&
|
|
316
|
-
loopScope.tryBlockDepth < ((
|
|
291
|
+
loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
|
|
317
292
|
// --- Mark the loop's try scope to exit with "break"
|
|
318
293
|
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
319
294
|
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "break";
|
|
@@ -328,17 +303,17 @@ function processStatement(statement, evalContext, thread) {
|
|
|
328
303
|
}
|
|
329
304
|
break;
|
|
330
305
|
}
|
|
331
|
-
case
|
|
332
|
-
if (!
|
|
306
|
+
case ScriptingSourceTreeExp_1.T_FOR_STATEMENT:
|
|
307
|
+
if (!execInfo.guard) {
|
|
333
308
|
// --- Init the loop with a new scope
|
|
334
309
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
335
310
|
// --- Create a new block for the loop variables
|
|
336
|
-
(
|
|
311
|
+
(_f = thread.blocks) !== null && _f !== void 0 ? _f : (thread.blocks = []);
|
|
337
312
|
thread.blocks.push({ vars: {} });
|
|
338
|
-
const guardStatement =
|
|
313
|
+
const guardStatement = (0, process_statement_common_1.guard)(statement);
|
|
339
314
|
if (statement.init) {
|
|
340
315
|
// --- Unshift the initialization part and the guarded for-loop
|
|
341
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.init, guardStatement]);
|
|
316
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([{ statement: statement.init }, guardStatement]);
|
|
342
317
|
}
|
|
343
318
|
else {
|
|
344
319
|
// --- No init, unshift only the guard statement
|
|
@@ -347,21 +322,31 @@ function processStatement(statement, evalContext, thread) {
|
|
|
347
322
|
}
|
|
348
323
|
else {
|
|
349
324
|
// --- Initialization already done. Evaluate the condition
|
|
350
|
-
if (!statement.
|
|
325
|
+
if (!statement.cond || (0, eval_tree_sync_1.evalBinding)(statement.cond, evalContext, thread)) {
|
|
351
326
|
// --- Stay in the loop, inject the body, the update expression, and the loop guard
|
|
352
327
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
353
|
-
if (statement.
|
|
328
|
+
if (statement.upd) {
|
|
354
329
|
const updateStmt = {
|
|
355
|
-
|
|
356
|
-
|
|
330
|
+
statement: {
|
|
331
|
+
type: ScriptingSourceTreeExp_1.T_EXPRESSION_STATEMENT,
|
|
332
|
+
nodeId: (0, Parser_1.createXmlUiTreeNodeId)(),
|
|
333
|
+
expr: statement.upd,
|
|
334
|
+
},
|
|
357
335
|
};
|
|
358
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
336
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
337
|
+
{ statement: statement.body },
|
|
338
|
+
updateStmt,
|
|
339
|
+
{ statement, execInfo },
|
|
340
|
+
]);
|
|
359
341
|
}
|
|
360
342
|
else {
|
|
361
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
343
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
344
|
+
{ statement: statement.body },
|
|
345
|
+
{ statement, execInfo },
|
|
346
|
+
]);
|
|
362
347
|
}
|
|
363
348
|
// --- The next queue label is for "break"
|
|
364
|
-
loopScope.breakLabel = (
|
|
349
|
+
loopScope.breakLabel = (_g = thread.breakLabelValue) !== null && _g !== void 0 ? _g : -1;
|
|
365
350
|
// --- The guard action's label is for "continue"
|
|
366
351
|
loopScope.continueLabel = toUnshift[1].label;
|
|
367
352
|
}
|
|
@@ -371,10 +356,10 @@ function processStatement(statement, evalContext, thread) {
|
|
|
371
356
|
}
|
|
372
357
|
}
|
|
373
358
|
break;
|
|
374
|
-
case
|
|
375
|
-
if (!
|
|
359
|
+
case ScriptingSourceTreeExp_1.T_FOR_IN_STATEMENT:
|
|
360
|
+
if (!execInfo.guard) {
|
|
376
361
|
// --- Get the object keys
|
|
377
|
-
const keyedObject = (0, eval_tree_sync_1.evalBinding)(statement.
|
|
362
|
+
const keyedObject = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
|
|
378
363
|
if (keyedObject == undefined) {
|
|
379
364
|
// --- Nothing to do, no object to traverse
|
|
380
365
|
break;
|
|
@@ -382,32 +367,32 @@ function processStatement(statement, evalContext, thread) {
|
|
|
382
367
|
// --- Init the loop with a new scope
|
|
383
368
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
384
369
|
// --- Create a new block for the loop variables
|
|
385
|
-
(
|
|
370
|
+
(_h = thread.blocks) !== null && _h !== void 0 ? _h : (thread.blocks = []);
|
|
386
371
|
thread.blocks.push({ vars: {} });
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
372
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
373
|
+
{ statement, execInfo: { guard: true, keys: Object.keys(keyedObject), keyIndex: 0 } },
|
|
374
|
+
]);
|
|
390
375
|
}
|
|
391
376
|
else {
|
|
392
377
|
// --- Just for the sake of extra safety
|
|
393
|
-
if (
|
|
378
|
+
if (execInfo.keyIndex === undefined || execInfo.keys === undefined) {
|
|
394
379
|
throw new Error("Keys information expected in for..in loop");
|
|
395
380
|
}
|
|
396
381
|
// --- Any key left?
|
|
397
|
-
if (
|
|
382
|
+
if (execInfo.keyIndex < execInfo.keys.length) {
|
|
398
383
|
// --- Set the binding variable to the next key
|
|
399
|
-
const propValue =
|
|
400
|
-
switch (statement.
|
|
384
|
+
const propValue = execInfo.keys[execInfo.keyIndex++];
|
|
385
|
+
switch (statement.varB) {
|
|
401
386
|
case "none": {
|
|
402
387
|
const assigmentExpr = {
|
|
403
|
-
type:
|
|
388
|
+
type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
|
|
404
389
|
leftValue: {
|
|
405
|
-
type:
|
|
406
|
-
name: statement.id,
|
|
390
|
+
type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
|
|
391
|
+
name: statement.id.name,
|
|
407
392
|
},
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
type:
|
|
393
|
+
op: "=",
|
|
394
|
+
expr: {
|
|
395
|
+
type: ScriptingSourceTreeExp_1.T_LITERAL,
|
|
411
396
|
value: propValue,
|
|
412
397
|
},
|
|
413
398
|
};
|
|
@@ -422,19 +407,22 @@ function processStatement(statement, evalContext, thread) {
|
|
|
422
407
|
if (!block) {
|
|
423
408
|
throw new Error("Missing block scope");
|
|
424
409
|
}
|
|
425
|
-
block.vars[statement.id] = propValue;
|
|
426
|
-
if (statement.
|
|
427
|
-
(
|
|
428
|
-
block.constVars.add(statement.id);
|
|
410
|
+
block.vars[statement.id.name] = propValue;
|
|
411
|
+
if (statement.varB === "const") {
|
|
412
|
+
(_j = block.constVars) !== null && _j !== void 0 ? _j : (block.constVars = new Set());
|
|
413
|
+
block.constVars.add(statement.id.name);
|
|
429
414
|
}
|
|
430
415
|
}
|
|
431
416
|
break;
|
|
432
417
|
}
|
|
433
418
|
// --- Inject the loop body
|
|
434
419
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
435
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
420
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
421
|
+
{ statement: statement.body },
|
|
422
|
+
{ statement, execInfo },
|
|
423
|
+
]);
|
|
436
424
|
// --- The next queue label is for "break"
|
|
437
|
-
loopScope.breakLabel = (
|
|
425
|
+
loopScope.breakLabel = (_k = thread.breakLabelValue) !== null && _k !== void 0 ? _k : -1;
|
|
438
426
|
// --- The guard action's label is for "continue"
|
|
439
427
|
loopScope.continueLabel = toUnshift[1].label;
|
|
440
428
|
}
|
|
@@ -444,10 +432,10 @@ function processStatement(statement, evalContext, thread) {
|
|
|
444
432
|
}
|
|
445
433
|
}
|
|
446
434
|
break;
|
|
447
|
-
case
|
|
448
|
-
if (!
|
|
435
|
+
case ScriptingSourceTreeExp_1.T_FOR_OF_STATEMENT:
|
|
436
|
+
if (!execInfo.guard) {
|
|
449
437
|
// --- Get the object keys
|
|
450
|
-
const iteratorObject = (0, eval_tree_sync_1.evalBinding)(statement.
|
|
438
|
+
const iteratorObject = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
|
|
451
439
|
if (iteratorObject == null || typeof iteratorObject[Symbol.iterator] !== "function") {
|
|
452
440
|
// --- The object is not an iterator
|
|
453
441
|
throw new Error("Object in for..of is not iterable");
|
|
@@ -455,18 +443,19 @@ function processStatement(statement, evalContext, thread) {
|
|
|
455
443
|
// --- Init the loop with a new scope
|
|
456
444
|
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
457
445
|
// --- Create a new block for the loop variables
|
|
458
|
-
(
|
|
446
|
+
(_l = thread.blocks) !== null && _l !== void 0 ? _l : (thread.blocks = []);
|
|
459
447
|
thread.blocks.push({ vars: {} });
|
|
460
|
-
|
|
461
|
-
|
|
448
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
449
|
+
{ statement, execInfo: { guard: true, iterator: iteratorObject[Symbol.iterator]() } },
|
|
450
|
+
]);
|
|
462
451
|
}
|
|
463
452
|
else {
|
|
464
453
|
// --- Just for the sake of extra safety
|
|
465
|
-
if (
|
|
454
|
+
if (execInfo.iterator === undefined) {
|
|
466
455
|
throw new Error("Iterator expected in for..of loop");
|
|
467
456
|
}
|
|
468
457
|
// --- Any iteration left?
|
|
469
|
-
const nextIteration =
|
|
458
|
+
const nextIteration = execInfo.iterator.next();
|
|
470
459
|
if (nextIteration.done) {
|
|
471
460
|
// --- The for..of loop is complete. Remove the loop's scope from the evaluation context
|
|
472
461
|
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
@@ -474,17 +463,17 @@ function processStatement(statement, evalContext, thread) {
|
|
|
474
463
|
}
|
|
475
464
|
// --- Set the binding variable to the next key
|
|
476
465
|
const propValue = nextIteration.value;
|
|
477
|
-
switch (statement.
|
|
466
|
+
switch (statement.varB) {
|
|
478
467
|
case "none": {
|
|
479
468
|
const assigmentExpr = {
|
|
480
|
-
type:
|
|
469
|
+
type: ScriptingSourceTreeExp_1.T_ASSIGNMENT_EXPRESSION,
|
|
481
470
|
leftValue: {
|
|
482
|
-
type:
|
|
483
|
-
name: statement.id,
|
|
471
|
+
type: ScriptingSourceTreeExp_1.T_IDENTIFIER,
|
|
472
|
+
name: statement.id.name,
|
|
484
473
|
},
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
type:
|
|
474
|
+
op: "=",
|
|
475
|
+
expr: {
|
|
476
|
+
type: ScriptingSourceTreeExp_1.T_LITERAL,
|
|
488
477
|
value: propValue,
|
|
489
478
|
},
|
|
490
479
|
};
|
|
@@ -499,28 +488,31 @@ function processStatement(statement, evalContext, thread) {
|
|
|
499
488
|
if (!block) {
|
|
500
489
|
throw new Error("Missing block scope");
|
|
501
490
|
}
|
|
502
|
-
block.vars[statement.id] = propValue;
|
|
503
|
-
if (statement.
|
|
504
|
-
(
|
|
505
|
-
block.constVars.add(statement.id);
|
|
491
|
+
block.vars[statement.id.name] = propValue;
|
|
492
|
+
if (statement.varB === "const") {
|
|
493
|
+
(_m = block.constVars) !== null && _m !== void 0 ? _m : (block.constVars = new Set());
|
|
494
|
+
block.constVars.add(statement.id.name);
|
|
506
495
|
}
|
|
507
496
|
}
|
|
508
497
|
break;
|
|
509
498
|
}
|
|
510
499
|
// --- Inject the loop body
|
|
511
500
|
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
512
|
-
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
501
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
502
|
+
{ statement: statement.body },
|
|
503
|
+
{ statement, execInfo },
|
|
504
|
+
]);
|
|
513
505
|
// --- The next queue label is for "break"
|
|
514
|
-
loopScope.breakLabel = (
|
|
506
|
+
loopScope.breakLabel = (_o = thread.breakLabelValue) !== null && _o !== void 0 ? _o : -1;
|
|
515
507
|
// --- The guard action's label is for "continue"
|
|
516
508
|
loopScope.continueLabel = toUnshift[1].label;
|
|
517
509
|
}
|
|
518
510
|
break;
|
|
519
|
-
case
|
|
520
|
-
throw new EngineError_1.ThrowStatementError((0, eval_tree_sync_1.evalBinding)(statement.
|
|
511
|
+
case ScriptingSourceTreeExp_1.T_THROW_STATEMENT: {
|
|
512
|
+
throw new EngineError_1.ThrowStatementError((0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread));
|
|
521
513
|
}
|
|
522
|
-
case
|
|
523
|
-
if (!
|
|
514
|
+
case ScriptingSourceTreeExp_1.T_TRY_STATEMENT: {
|
|
515
|
+
if (!execInfo.guard) {
|
|
524
516
|
// --- Execute the try block
|
|
525
517
|
toUnshift = (0, process_statement_common_1.provideTryBody)(thread, (0, process_statement_common_1.createTryScope)(thread, statement));
|
|
526
518
|
break;
|
|
@@ -535,10 +527,10 @@ function processStatement(statement, evalContext, thread) {
|
|
|
535
527
|
// --- Remove the "try" block's scope
|
|
536
528
|
thread.blocks.pop();
|
|
537
529
|
// --- Go on with catch or finally
|
|
538
|
-
if (statement.
|
|
539
|
-
if (tryScope.statement.
|
|
530
|
+
if (statement.catchB) {
|
|
531
|
+
if (tryScope.statement.catchV) {
|
|
540
532
|
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
541
|
-
block.vars[tryScope.statement.
|
|
533
|
+
block.vars[tryScope.statement.catchV.name] =
|
|
542
534
|
tryScope.errorToThrow instanceof EngineError_1.ThrowStatementError
|
|
543
535
|
? tryScope.errorToThrow.errorObject
|
|
544
536
|
: tryScope.errorToThrow;
|
|
@@ -547,7 +539,7 @@ function processStatement(statement, evalContext, thread) {
|
|
|
547
539
|
tryScope.processingPhase = "catch";
|
|
548
540
|
toUnshift = (0, process_statement_common_1.provideCatchBody)(thread, tryScope);
|
|
549
541
|
}
|
|
550
|
-
else if (tryScope.statement.
|
|
542
|
+
else if (tryScope.statement.finallyB) {
|
|
551
543
|
// --- No catch, move on finally
|
|
552
544
|
tryScope.processingPhase = "finally";
|
|
553
545
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
@@ -572,14 +564,14 @@ function processStatement(statement, evalContext, thread) {
|
|
|
572
564
|
case "try":
|
|
573
565
|
// --- We completed the try block successfully
|
|
574
566
|
tryScope.processingPhase = "finally";
|
|
575
|
-
if (statement.
|
|
567
|
+
if (statement.finallyB) {
|
|
576
568
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
577
569
|
}
|
|
578
570
|
break;
|
|
579
571
|
case "catch":
|
|
580
572
|
// --- We completed the catch block successfully, remove the handled error
|
|
581
573
|
tryScope.processingPhase = "finally";
|
|
582
|
-
if (statement.
|
|
574
|
+
if (statement.finallyB) {
|
|
583
575
|
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
584
576
|
}
|
|
585
577
|
break;
|
|
@@ -622,9 +614,9 @@ function processStatement(statement, evalContext, thread) {
|
|
|
622
614
|
}
|
|
623
615
|
break;
|
|
624
616
|
}
|
|
625
|
-
case
|
|
617
|
+
case ScriptingSourceTreeExp_1.T_SWITCH_STATEMENT: {
|
|
626
618
|
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
627
|
-
if (
|
|
619
|
+
if (execInfo.guard) {
|
|
628
620
|
// --- Complete the switch
|
|
629
621
|
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
630
622
|
}
|
|
@@ -633,18 +625,18 @@ function processStatement(statement, evalContext, thread) {
|
|
|
633
625
|
loopScope.isSwitch = true;
|
|
634
626
|
thread.blocks.push({ vars: {} });
|
|
635
627
|
// --- Evaluate the switch value
|
|
636
|
-
const switchValue = (0, eval_tree_sync_1.evalBinding)(statement.
|
|
628
|
+
const switchValue = (0, eval_tree_sync_1.evalBinding)(statement.expr, evalContext, thread);
|
|
637
629
|
// --- Find the matching label
|
|
638
630
|
let matchingIndex = -1;
|
|
639
631
|
for (let i = 0; i < statement.cases.length; i++) {
|
|
640
632
|
const currentCase = statement.cases[i];
|
|
641
633
|
// --- Check for default case
|
|
642
|
-
if (currentCase.
|
|
634
|
+
if (currentCase.caseE === undefined) {
|
|
643
635
|
matchingIndex = i;
|
|
644
636
|
break;
|
|
645
637
|
}
|
|
646
638
|
// --- Check for matching case
|
|
647
|
-
const caseValue = (0, eval_tree_sync_1.evalBinding)(currentCase.
|
|
639
|
+
const caseValue = (0, eval_tree_sync_1.evalBinding)(currentCase.caseE, evalContext, thread);
|
|
648
640
|
if (caseValue === switchValue) {
|
|
649
641
|
matchingIndex = i;
|
|
650
642
|
break;
|
|
@@ -654,19 +646,21 @@ function processStatement(statement, evalContext, thread) {
|
|
|
654
646
|
const statementFlow = [];
|
|
655
647
|
if (matchingIndex >= 0) {
|
|
656
648
|
for (let i = matchingIndex; i < statement.cases.length; i++) {
|
|
657
|
-
statementFlow.push(...statement.cases[i].
|
|
649
|
+
statementFlow.push(...statement.cases[i].stmts);
|
|
658
650
|
}
|
|
659
651
|
}
|
|
660
652
|
// --- Queue the statement flow and the guard
|
|
661
|
-
|
|
662
|
-
|
|
653
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([
|
|
654
|
+
...(0, process_statement_common_1.toStatementItems)(statementFlow),
|
|
655
|
+
(0, process_statement_common_1.guard)(statement),
|
|
656
|
+
]);
|
|
663
657
|
loopScope.breakLabel = toUnshift[toUnshift.length - 1].label;
|
|
664
658
|
}
|
|
665
659
|
break;
|
|
666
660
|
}
|
|
667
661
|
}
|
|
668
662
|
// --- The statement may remove the innermost scope
|
|
669
|
-
if (
|
|
663
|
+
if (execInfo.removeBlockScope) {
|
|
670
664
|
if (thread.blocks && thread.blocks.length > 0) {
|
|
671
665
|
thread.blocks.pop();
|
|
672
666
|
}
|
|
@@ -682,9 +676,9 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
|
|
|
682
676
|
if (useValue) {
|
|
683
677
|
value = baseValue;
|
|
684
678
|
}
|
|
685
|
-
else if (decl.
|
|
679
|
+
else if (decl.expr) {
|
|
686
680
|
//TODO illesg here, functionInvocation for global function (e.g. window.confirm... )
|
|
687
|
-
value = (0, eval_tree_sync_1.evalBinding)(decl.
|
|
681
|
+
value = (0, eval_tree_sync_1.evalBinding)(decl.expr, evalContext, thread);
|
|
688
682
|
}
|
|
689
683
|
visitDeclaration(block, decl, value, addConst);
|
|
690
684
|
}
|
|
@@ -694,11 +688,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
|
|
|
694
688
|
if (decl.id) {
|
|
695
689
|
visitIdDeclaration(block, decl.id, baseValue, addConst);
|
|
696
690
|
}
|
|
697
|
-
else if (decl.
|
|
698
|
-
visitArrayDestruct(block, decl.
|
|
691
|
+
else if (decl.aDestr) {
|
|
692
|
+
visitArrayDestruct(block, decl.aDestr, baseValue, addConst);
|
|
699
693
|
}
|
|
700
|
-
else if (decl.
|
|
701
|
-
visitObjectDestruct(block, decl.
|
|
694
|
+
else if (decl.oDestr) {
|
|
695
|
+
visitObjectDestruct(block, decl.oDestr, baseValue, addConst);
|
|
702
696
|
}
|
|
703
697
|
else {
|
|
704
698
|
throw new Error("Unknown declaration specifier");
|
|
@@ -724,11 +718,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
|
|
|
724
718
|
if (arrDecl.id) {
|
|
725
719
|
visitIdDeclaration(block, arrDecl.id, value, addConst);
|
|
726
720
|
}
|
|
727
|
-
else if (arrDecl.
|
|
728
|
-
visitArrayDestruct(block, arrDecl.
|
|
721
|
+
else if (arrDecl.aDestr) {
|
|
722
|
+
visitArrayDestruct(block, arrDecl.aDestr, value, addConst);
|
|
729
723
|
}
|
|
730
|
-
else if (arrDecl.
|
|
731
|
-
visitObjectDestruct(block, arrDecl.
|
|
724
|
+
else if (arrDecl.oDestr) {
|
|
725
|
+
visitObjectDestruct(block, arrDecl.oDestr, value, addConst);
|
|
732
726
|
}
|
|
733
727
|
}
|
|
734
728
|
}
|
|
@@ -738,11 +732,11 @@ function processDeclarations(block, evalContext, thread, declarations, addConst
|
|
|
738
732
|
for (let i = 0; i < objectD.length; i++) {
|
|
739
733
|
const objDecl = objectD[i];
|
|
740
734
|
const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[objDecl.id];
|
|
741
|
-
if (objDecl.
|
|
742
|
-
visitArrayDestruct(block, objDecl.
|
|
735
|
+
if (objDecl.aDestr) {
|
|
736
|
+
visitArrayDestruct(block, objDecl.aDestr, value, addConst);
|
|
743
737
|
}
|
|
744
|
-
else if (objDecl.
|
|
745
|
-
visitObjectDestruct(block, objDecl.
|
|
738
|
+
else if (objDecl.oDestr) {
|
|
739
|
+
visitObjectDestruct(block, objDecl.oDestr, value, addConst);
|
|
746
740
|
}
|
|
747
741
|
else {
|
|
748
742
|
visitIdDeclaration(block, (_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id, value, addConst);
|