xmlui 0.4.0
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/Pdf-DeGhSMXe.mjs +19537 -0
- package/dist/Pdf.css +1 -0
- package/dist/apiInterceptorWorker-CwuUhYyc.mjs +9229 -0
- package/dist/array-USo-Szhp.mjs +12 -0
- package/dist/index-C24dkfpd.mjs +1434 -0
- package/dist/index-ao27SnVp.mjs +145185 -0
- package/dist/index.css +1 -0
- package/dist/nivo-bar.es-CWh0ZlxB.mjs +1666 -0
- package/dist/nivo-geo.es-BTqNt5Db.mjs +1579 -0
- package/dist/nivo-legends.es-BuIxHGSU.mjs +6916 -0
- package/dist/nivo-pie.es-BvCBFA0L.mjs +700 -0
- package/dist/react-apexcharts.min-DqWuDOyO.mjs +8881 -0
- package/dist/scripts/bin/bootstrap.js +11 -0
- package/dist/scripts/bin/build.js +256 -0
- package/dist/scripts/bin/index.js +88 -0
- package/dist/scripts/bin/preview.js +27 -0
- package/dist/scripts/bin/start.js +41 -0
- package/dist/scripts/bin/vite-ueml-plugin.js +113 -0
- package/dist/scripts/bin/viteConfig.js +112 -0
- package/dist/scripts/src/abstractions/ActionDefs.js +2 -0
- package/dist/scripts/src/abstractions/AppContextDefs.js +2 -0
- package/dist/scripts/src/abstractions/BlockScope.js +4 -0
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -0
- package/dist/scripts/src/abstractions/ComponentDescriptorDefs.js +2 -0
- package/dist/scripts/src/abstractions/ContainerDefs.js +2 -0
- package/dist/scripts/src/abstractions/FunctionDefs.js +2 -0
- package/dist/scripts/src/abstractions/RendererDefs.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptParserError.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +2 -0
- package/dist/scripts/src/abstractions/scripting/Token.js +110 -0
- package/dist/scripts/src/components/App/App.js +253 -0
- package/dist/scripts/src/components/App/AppLayoutContext.js +9 -0
- package/dist/scripts/src/components/App/AppStateContext.js +9 -0
- package/dist/scripts/src/components/App/Sheet.js +89 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +121 -0
- package/dist/scripts/src/components/AppState/AppState.js +29 -0
- package/dist/scripts/src/components/Avatar/Avatar.js +81 -0
- package/dist/scripts/src/components/Badge/Badge.js +56 -0
- package/dist/scripts/src/components/BarChart/BarChart.js +199 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.js +11 -0
- package/dist/scripts/src/components/Button/Button.js +196 -0
- package/dist/scripts/src/components/Card/Card.js +65 -0
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +43 -0
- package/dist/scripts/src/components/Chart/Chart.js +158 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +43 -0
- package/dist/scripts/src/components/Combobox/Combobox.js +145 -0
- package/dist/scripts/src/components/ComponentProvider.js +357 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +40 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +196 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +175 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +56 -0
- package/dist/scripts/src/components/FileInput/FileInput.js +127 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +106 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +139 -0
- package/dist/scripts/src/components/Footer/Footer.js +42 -0
- package/dist/scripts/src/components/Form/Form.js +320 -0
- package/dist/scripts/src/components/Form/FormContext.js +9 -0
- package/dist/scripts/src/components/Form/formActions.js +86 -0
- package/dist/scripts/src/components/FormItem/FormItem.js +204 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +27 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +39 -0
- package/dist/scripts/src/components/FormItem/Validations.js +346 -0
- package/dist/scripts/src/components/FormSection/FormSection.js +45 -0
- package/dist/scripts/src/components/Heading/Heading.js +206 -0
- package/dist/scripts/src/components/HoverCard/HoverCard.js +45 -0
- package/dist/scripts/src/components/Icon/ApiIcon.js +10 -0
- package/dist/scripts/src/components/Icon/Attach.js +10 -0
- package/dist/scripts/src/components/Icon/Binding.js +11 -0
- package/dist/scripts/src/components/Icon/BoardIcon.js +7 -0
- package/dist/scripts/src/components/Icon/BoxIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CheckIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronLeft.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronRight.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/CodeFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CodeSandbox.js +10 -0
- package/dist/scripts/src/components/Icon/CompactListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ContentCopyIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DatabaseIcon.js +11 -0
- package/dist/scripts/src/components/Icon/DocFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DocIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DotMenuHorizontalIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DotMenuIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmailIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmptyFolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/ErrorIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ExpressionIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FillPlusCricleIcon.js +7 -0
- package/dist/scripts/src/components/Icon/FilterIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/GlobeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HomeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HyperLinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.js +101 -0
- package/dist/scripts/src/components/Icon/ImageFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/LooseListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/MoonIcon.js +10 -0
- package/dist/scripts/src/components/Icon/MoreOptionsIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PDFIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PenIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhoneIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhotoIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PlusIcon.js +7 -0
- package/dist/scripts/src/components/Icon/SearchIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ShareIcon.js +10 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Icon/TrashIcon.js +7 -0
- package/dist/scripts/src/components/Icon/TxtIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnknownFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnlinkIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UserIcon.js +7 -0
- package/dist/scripts/src/components/Icon/WarningIcon.js +7 -0
- package/dist/scripts/src/components/Icon/XlsIcon.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +249 -0
- package/dist/scripts/src/components/IconRegistryContext.js +307 -0
- package/dist/scripts/src/components/Image/Image.js +34 -0
- package/dist/scripts/src/components/Input/InputAdornment.js +14 -0
- package/dist/scripts/src/components/Input/input-abstractions.js +44 -0
- package/dist/scripts/src/components/Items/Items.js +48 -0
- package/dist/scripts/src/components/Link/Link.js +72 -0
- package/dist/scripts/src/components/List/List.js +442 -0
- package/dist/scripts/src/components/Logo/Logo.js +25 -0
- package/dist/scripts/src/components/Map/Map.js +60 -0
- package/dist/scripts/src/components/Map/world_countries.json +45307 -0
- package/dist/scripts/src/components/Markdown/Markdown.js +120 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +106 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +145 -0
- package/dist/scripts/src/components/MultiCombobox/MultiCombobox.js +249 -0
- package/dist/scripts/src/components/MultiSelect/MultiSelect.js +192 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.js +113 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +115 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.js +101 -0
- package/dist/scripts/src/components/NoResult/NoResult.js +39 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +373 -0
- package/dist/scripts/src/components/Option/Option.js +41 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +22 -0
- package/dist/scripts/src/components/Pages/Pages.js +74 -0
- package/dist/scripts/src/components/Pdf/LazyPdf.js +44 -0
- package/dist/scripts/src/components/Pdf/Pdf.js +19 -0
- package/dist/scripts/src/components/PieChart/PieChart.js +184 -0
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +29 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/scripts/src/components/Queue/Queue.js +286 -0
- package/dist/scripts/src/components/Queue/queueActions.js +87 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +144 -0
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +147 -0
- package/dist/scripts/src/components/Redirect/Redirect.js +10 -0
- package/dist/scripts/src/components/Select/Select.js +139 -0
- package/dist/scripts/src/components/Select/SelectContext.js +45 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +88 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +22 -0
- package/dist/scripts/src/components/Spinner/Spinner.js +59 -0
- package/dist/scripts/src/components/Splitter/Splitter.js +205 -0
- package/dist/scripts/src/components/Splitter/utils.js +17 -0
- package/dist/scripts/src/components/Stack/Stack.js +117 -0
- package/dist/scripts/src/components/StickyBox/StickyBox.js +33 -0
- package/dist/scripts/src/components/Switch/Switch.js +50 -0
- package/dist/scripts/src/components/Table/Table.js +499 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +169 -0
- package/dist/scripts/src/components/TableColumnDef/TableColumnDef.js +44 -0
- package/dist/scripts/src/components/TableColumnDef/TableContext.js +12 -0
- package/dist/scripts/src/components/Tabs/Tabs.js +85 -0
- package/dist/scripts/src/components/Text/Text.js +175 -0
- package/dist/scripts/src/components/TextArea/TextArea.js +194 -0
- package/dist/scripts/src/components/TextArea/TextAreaResizable.js +63 -0
- package/dist/scripts/src/components/TextArea/useComposedRef.js +50 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +145 -0
- package/dist/scripts/src/components/Theme/NotificationToast.js +39 -0
- package/dist/scripts/src/components/Theme/Theme.js +153 -0
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +125 -0
- package/dist/scripts/src/components/Toggle/Toggle.js +88 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +79 -0
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +59 -0
- package/dist/scripts/src/components/ViewComponentRegistryContext.js +34 -0
- package/dist/scripts/src/components/abstractions.js +2 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components/component-utils.js +32 -0
- package/dist/scripts/src/components/container-helpers.js +18 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +189 -0
- package/dist/scripts/src/components-core/AppContext.js +17 -0
- package/dist/scripts/src/components-core/ChildrenSlot.js +10 -0
- package/dist/scripts/src/components-core/Component.js +280 -0
- package/dist/scripts/src/components-core/ComponentDecorator.js +63 -0
- package/dist/scripts/src/components-core/CompoundComponent.js +132 -0
- package/dist/scripts/src/components-core/EngineError.js +91 -0
- package/dist/scripts/src/components-core/ErrorBoundary.js +58 -0
- package/dist/scripts/src/components-core/Fragment.js +14 -0
- package/dist/scripts/src/components-core/InvalidComponent.js +15 -0
- package/dist/scripts/src/components-core/LoaderComponent.js +78 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +341 -0
- package/dist/scripts/src/components-core/RootComponent.js +272 -0
- package/dist/scripts/src/components-core/RouteContext.js +45 -0
- package/dist/scripts/src/components-core/ScrollContext.js +9 -0
- package/dist/scripts/src/components-core/UnknownComponent.js +15 -0
- package/dist/scripts/src/components-core/abstractions/ComponentRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/LoaderRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/containers.js +18 -0
- package/dist/scripts/src/components-core/abstractions/treeAbstractions.js +2 -0
- package/dist/scripts/src/components-core/action/ApiAction.js +276 -0
- package/dist/scripts/src/components-core/action/DownloadFileAction.js +80 -0
- package/dist/scripts/src/components-core/action/NavigateAction.js +20 -0
- package/dist/scripts/src/components-core/action/TimedAction.js +21 -0
- package/dist/scripts/src/components-core/action/UploadAction.js +88 -0
- package/dist/scripts/src/components-core/action/actions.js +15 -0
- package/dist/scripts/src/components-core/appContext/date-functions.js +19 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +12 -0
- package/dist/scripts/src/components-core/component-hooks.js +25 -0
- package/dist/scripts/src/components-core/constants.js +18 -0
- package/dist/scripts/src/components-core/container/Container.js +1110 -0
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +16 -0
- package/dist/scripts/src/components-core/container/buildProxy.js +54 -0
- package/dist/scripts/src/components-core/container/collectFnVarDeps.js +26 -0
- package/dist/scripts/src/components-core/container/valueExtractor.js +195 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +75 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +46 -0
- package/dist/scripts/src/components-core/loader/DataLoader.js +160 -0
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +52 -0
- package/dist/scripts/src/components-core/loader/Loader.js +115 -0
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +32 -0
- package/dist/scripts/src/components-core/loader/PageableLoader.js +240 -0
- package/dist/scripts/src/components-core/renderers.js +45 -0
- package/dist/scripts/src/components-core/reportEngineError.js +59 -0
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +35 -0
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +34 -0
- package/dist/scripts/src/components-core/script-runner/LogicalThread.js +2 -0
- package/dist/scripts/src/components-core/script-runner/LoopScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +117 -0
- package/dist/scripts/src/components-core/script-runner/TryScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +96 -0
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +34 -0
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +40 -0
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +40 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +551 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +498 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +434 -0
- package/dist/scripts/src/components-core/script-runner/modules.js +250 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +818 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +193 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +740 -0
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +62 -0
- package/dist/scripts/src/components-core/script-runner/visitors.js +352 -0
- package/dist/scripts/src/components-core/theming/ThemeContext.js +43 -0
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +334 -0
- package/dist/scripts/src/components-core/theming/abstractions.js +11 -0
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +114 -0
- package/dist/scripts/src/components-core/theming/hvar.js +105 -0
- package/dist/scripts/src/components-core/theming/themeVars.js +62 -0
- package/dist/scripts/src/components-core/theming/themes/base-utils.js +31 -0
- package/dist/scripts/src/components-core/theming/themes/palette.js +53 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +257 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +407 -0
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +32 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +286 -0
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +34 -0
- package/dist/scripts/src/components-core/utils/LruCache.js +184 -0
- package/dist/scripts/src/components-core/utils/actionUtils.js +32 -0
- package/dist/scripts/src/components-core/utils/classnames.js +58 -0
- package/dist/scripts/src/components-core/utils/css-utils.js +127 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/extractParam.js +148 -0
- package/dist/scripts/src/components-core/utils/hooks.js +221 -0
- package/dist/scripts/src/components-core/utils/mergeProps.js +45 -0
- package/dist/scripts/src/components-core/utils/misc.js +460 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +205 -0
- package/dist/scripts/src/components-core/utils/treeUtils.js +48 -0
- package/dist/scripts/src/components-core/xmlui-parser.js +52 -0
- package/dist/scripts/src/parsers/scripting/InputStream.js +59 -0
- package/dist/scripts/src/parsers/scripting/Lexer.js +1028 -0
- package/dist/scripts/src/parsers/scripting/Parser.js +2647 -0
- package/dist/scripts/src/parsers/scripting/ParserError.js +46 -0
- package/dist/scripts/src/parsers/scripting/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +118 -0
- package/dist/scripts/src/parsers/scripting/tree-visitor.js +602 -0
- package/dist/scripts/src/parsers/style-parser/StyleInputStream.js +39 -0
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +621 -0
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +1000 -0
- package/dist/scripts/src/parsers/style-parser/errors.js +37 -0
- package/dist/scripts/src/parsers/style-parser/source-tree.js +2 -0
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +513 -0
- package/dist/scripts/src/parsers/style-parser/tokens.js +42 -0
- package/dist/scripts/src/parsers/ueml/ParserError.js +54 -0
- package/dist/scripts/src/parsers/ueml/UemlHelper.js +579 -0
- package/dist/scripts/src/parsers/ueml/UemlInputStream.js +59 -0
- package/dist/scripts/src/parsers/ueml/UemlLexer.js +868 -0
- package/dist/scripts/src/parsers/ueml/UemlParser.js +1439 -0
- package/dist/scripts/src/parsers/ueml/UemlToken.js +24 -0
- package/dist/scripts/src/parsers/ueml/fileExtensions.js +6 -0
- package/dist/scripts/src/parsers/ueml/source-tree.js +2 -0
- package/dist/scripts/src/parsers/ueml/ueml-tree.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/CharacterCodes.js +136 -0
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +100 -0
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +476 -0
- package/dist/scripts/src/parsers/xmlui-parser/scanner.js +415 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-kind.js +106 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +922 -0
- package/dist/scripts/src/parsers/xmlui-parser/utils.js +83 -0
- package/dist/xmlui.es.d.ts +1667 -0
- package/dist/xmlui.es.js +17 -0
- package/dist/xmlui.umd.js +1589 -0
- package/package.json +175 -0
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processStatementQueue = processStatementQueue;
|
|
4
|
+
exports.processDeclarations = processDeclarations;
|
|
5
|
+
const eval_tree_sync_1 = require("@components-core/script-runner/eval-tree-sync");
|
|
6
|
+
const process_statement_common_1 = require("./process-statement-common");
|
|
7
|
+
const statement_queue_1 = require("./statement-queue");
|
|
8
|
+
const reportEngineError_1 = require("../reportEngineError");
|
|
9
|
+
const EngineError_1 = require("../EngineError");
|
|
10
|
+
const SYNC_EVAL_TIMEOUT = 1000;
|
|
11
|
+
// --- Helper function to process the entire queue synchronously
|
|
12
|
+
function processStatementQueue(statements, evalContext, thread) {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!thread) {
|
|
15
|
+
// --- Create the main thread for the queue
|
|
16
|
+
thread = (0, process_statement_common_1.ensureMainThread)(evalContext);
|
|
17
|
+
}
|
|
18
|
+
// --- Hoist function declarations to the top scope
|
|
19
|
+
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statements);
|
|
20
|
+
// --- Set start tick to observe timeout
|
|
21
|
+
evalContext.startTick = new Date().valueOf();
|
|
22
|
+
// --- Fill the queue with items
|
|
23
|
+
const queue = new statement_queue_1.StatementQueue();
|
|
24
|
+
queue.push((0, statement_queue_1.mapStatementsToQueueItems)(statements));
|
|
25
|
+
// --- Prepare queue diagnostics information
|
|
26
|
+
const diagInfo = {
|
|
27
|
+
processedStatements: 0,
|
|
28
|
+
maxQueueLength: queue.length,
|
|
29
|
+
unshiftedItems: 0,
|
|
30
|
+
clearToLabels: 0,
|
|
31
|
+
maxBlocks: 0,
|
|
32
|
+
maxLoops: 0,
|
|
33
|
+
};
|
|
34
|
+
// --- Consume the queue
|
|
35
|
+
while (queue.length > 0) {
|
|
36
|
+
// --- Check sync timeout
|
|
37
|
+
if (evalContext.startTick !== undefined && new Date().valueOf() - evalContext.startTick > SYNC_EVAL_TIMEOUT) {
|
|
38
|
+
throw new Error(`Sync evaluation timeout exceeded ${SYNC_EVAL_TIMEOUT} milliseconds`);
|
|
39
|
+
}
|
|
40
|
+
// --- Process the first item
|
|
41
|
+
const queueItem = queue.dequeue();
|
|
42
|
+
thread.breakLabelValue = queue.length > 0 ? queue.peek().label : -1;
|
|
43
|
+
let outcome;
|
|
44
|
+
try {
|
|
45
|
+
outcome = processStatement(queueItem.statement, evalContext, thread);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (thread.tryBlocks && thread.tryBlocks.length > 0) {
|
|
49
|
+
// --- We have a try block to handle this error
|
|
50
|
+
const tryScope = thread.tryBlocks[thread.tryBlocks.length - 1];
|
|
51
|
+
// --- Sign the error to raise. Next time the guarded try block will execute the catch block, if there is any
|
|
52
|
+
tryScope.errorToThrow = err;
|
|
53
|
+
tryScope.errorSource = tryScope.processingPhase;
|
|
54
|
+
tryScope.processingPhase = "error";
|
|
55
|
+
// --- Let's skip the remaining parts of the current block (try/catch/finally)
|
|
56
|
+
outcome = {
|
|
57
|
+
clearToLabel: tryScope.tryLabel,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (err instanceof EngineError_1.ThrowStatementError) {
|
|
62
|
+
(0, reportEngineError_1.reportEngineError)(err);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
(0, reportEngineError_1.reportEngineError)(new EngineError_1.StatementExecutionError(err, (_a = queueItem.statement) === null || _a === void 0 ? void 0 : _a.source), err);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// --- Modify the queue's content according to the outcome
|
|
70
|
+
if (outcome) {
|
|
71
|
+
if (outcome.toUnshift) {
|
|
72
|
+
queue.unshift(outcome.toUnshift);
|
|
73
|
+
diagInfo.unshiftedItems += outcome.toUnshift.length;
|
|
74
|
+
}
|
|
75
|
+
if (outcome.clearToLabel !== undefined) {
|
|
76
|
+
queue.clearToLabel(outcome.clearToLabel);
|
|
77
|
+
diagInfo.clearToLabels++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// --- Provide diagnostics
|
|
81
|
+
if (queue.length > diagInfo.maxQueueLength) {
|
|
82
|
+
diagInfo.maxQueueLength = queue.length;
|
|
83
|
+
}
|
|
84
|
+
if (thread.blocks && thread.blocks.length > diagInfo.maxBlocks) {
|
|
85
|
+
diagInfo.maxBlocks = thread.blocks.length;
|
|
86
|
+
}
|
|
87
|
+
if (thread.loops && thread.loops.length > diagInfo.maxLoops) {
|
|
88
|
+
diagInfo.maxLoops = thread.loops.length;
|
|
89
|
+
}
|
|
90
|
+
diagInfo.processedStatements++;
|
|
91
|
+
}
|
|
92
|
+
return diagInfo;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Process the specified statement synchronously
|
|
96
|
+
* @param statement Statement to process
|
|
97
|
+
* @param evalContext Evaluation context used for processing
|
|
98
|
+
* @param thread Logical thread to use for statement processing
|
|
99
|
+
* @returns Items to put back into the queue of statements
|
|
100
|
+
*/
|
|
101
|
+
function processStatement(statement, evalContext, thread) {
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
103
|
+
// --- These items should be put in the statement queue after return
|
|
104
|
+
let toUnshift = [];
|
|
105
|
+
let clearToLabel;
|
|
106
|
+
// --- Process the statement according to its type
|
|
107
|
+
switch (statement.type) {
|
|
108
|
+
case "ImportD":
|
|
109
|
+
// --- Get module information
|
|
110
|
+
const thisModule = statement.module;
|
|
111
|
+
if (!thisModule) {
|
|
112
|
+
throw new Error("Missing module");
|
|
113
|
+
}
|
|
114
|
+
const parentModule = (_a = statement.module) === null || _a === void 0 ? void 0 : _a.parent;
|
|
115
|
+
if (!parentModule) {
|
|
116
|
+
throw new Error("Missing parent module");
|
|
117
|
+
}
|
|
118
|
+
// --- At this point the imported module is set
|
|
119
|
+
// if (!statement.module!.executed) {
|
|
120
|
+
// // --- Run the module, it has not been executed yet
|
|
121
|
+
// const childEvalContext = createEvalContext({
|
|
122
|
+
// cancellationToken: evalContext.cancellationToken,
|
|
123
|
+
// timeout: evalContext.timeout ?? 1000
|
|
124
|
+
// });
|
|
125
|
+
// statement.module!.executed = true;
|
|
126
|
+
// executeScriptModule(statement.module!, childEvalContext);
|
|
127
|
+
// }
|
|
128
|
+
// --- Import the module's exported variables into the parent module
|
|
129
|
+
const topVars = evalContext.mainThread.blocks[0].vars;
|
|
130
|
+
const topConst = evalContext.mainThread.blocks[0].constVars;
|
|
131
|
+
for (const key of Object.keys(statement.imports)) {
|
|
132
|
+
if (key in topVars) {
|
|
133
|
+
throw new Error(`Import ${key} already exists`);
|
|
134
|
+
}
|
|
135
|
+
topVars[key] = statement.module.exports.get(statement.imports[key]);
|
|
136
|
+
topConst.add(key);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case "FuncD":
|
|
140
|
+
// --- Function declarations are already hoisted, nothing to do
|
|
141
|
+
break;
|
|
142
|
+
case "EmptyS":
|
|
143
|
+
// --- Nothing to do
|
|
144
|
+
break;
|
|
145
|
+
case "BlockS":
|
|
146
|
+
// --- No statement, nothing to process
|
|
147
|
+
if (statement.statements.length === 0)
|
|
148
|
+
break;
|
|
149
|
+
// --- Create a new block scope
|
|
150
|
+
(_b = thread.blocks) !== null && _b !== void 0 ? _b : (thread.blocks = []);
|
|
151
|
+
thread.blocks.push({ vars: {} });
|
|
152
|
+
// --- Hoist function declarations to the innermost block scope
|
|
153
|
+
(0, process_statement_common_1.hoistFunctionDeclarations)(thread, statement.statements);
|
|
154
|
+
// --- Prepare an empty statement that will only remove the block scope when the entire block is processed
|
|
155
|
+
const closing = {
|
|
156
|
+
type: "EmptyS",
|
|
157
|
+
removeBlockScope: true,
|
|
158
|
+
}; // --- We need the cast as we do not provide required props
|
|
159
|
+
// --- Queue the block scope's body
|
|
160
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statement.statements, closing]);
|
|
161
|
+
break;
|
|
162
|
+
case "ExprS":
|
|
163
|
+
// --- Just evaluate it
|
|
164
|
+
const statementValue = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
|
|
165
|
+
if (thread.blocks && thread.blocks.length !== 0) {
|
|
166
|
+
thread.blocks[thread.blocks.length - 1].returnValue = statementValue;
|
|
167
|
+
}
|
|
168
|
+
break;
|
|
169
|
+
case "ArrowS":
|
|
170
|
+
// --- Compile the arrow expression
|
|
171
|
+
const arrowFuncValue = (0, eval_tree_sync_1.executeArrowExpressionSync)(statement.expression, evalContext, thread, ...((_c = evalContext.eventArgs) !== null && _c !== void 0 ? _c : []));
|
|
172
|
+
if (thread.blocks && thread.blocks.length !== 0) {
|
|
173
|
+
thread.blocks[thread.blocks.length - 1].returnValue = arrowFuncValue;
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case "LetS": {
|
|
177
|
+
// --- Create a new variable in the innermost scope
|
|
178
|
+
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
179
|
+
if (!block) {
|
|
180
|
+
throw new Error("Missing block scope");
|
|
181
|
+
}
|
|
182
|
+
processDeclarations(block, evalContext, thread, statement.declarations);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case "ConstS": {
|
|
186
|
+
// --- Create a new variable in the innermost scope
|
|
187
|
+
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
188
|
+
if (!block) {
|
|
189
|
+
throw new Error("Missing block scope");
|
|
190
|
+
}
|
|
191
|
+
processDeclarations(block, evalContext, thread, statement.declarations, true);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case "IfS":
|
|
195
|
+
// --- Evaluate the condition
|
|
196
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
|
|
197
|
+
if (condition) {
|
|
198
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.thenBranch);
|
|
199
|
+
}
|
|
200
|
+
else if (statement.elseBranch) {
|
|
201
|
+
toUnshift = (0, statement_queue_1.mapToItem)(statement.elseBranch);
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case "RetS": {
|
|
205
|
+
// --- Check if return is valid here
|
|
206
|
+
let blockScope = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
207
|
+
if (blockScope === undefined) {
|
|
208
|
+
throw new Error("Return requires a block scope");
|
|
209
|
+
}
|
|
210
|
+
// --- Store the return value
|
|
211
|
+
thread.returnValue = statement.expression ? (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread) : undefined;
|
|
212
|
+
// --- Check for try blocks
|
|
213
|
+
if (((_d = thread.tryBlocks) !== null && _d !== void 0 ? _d : []).length > 0) {
|
|
214
|
+
// --- Mark the loop's try scope to exit with "return"
|
|
215
|
+
const returnTryScope = thread.tryBlocks[0];
|
|
216
|
+
returnTryScope.exitType = "return";
|
|
217
|
+
// --- Remove the try/catch/finally block's scope
|
|
218
|
+
if (returnTryScope.processingPhase !== "postFinally") {
|
|
219
|
+
thread.blocks.pop();
|
|
220
|
+
}
|
|
221
|
+
// --- Clear the last part of the try/catch/finally block
|
|
222
|
+
const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
|
|
223
|
+
clearToLabel = tryScope.tryLabel;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
// --- Delete the remaining part of the queue
|
|
227
|
+
clearToLabel = -1;
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case "WhileS": {
|
|
232
|
+
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
233
|
+
let loopScope = statement.guard ? (0, process_statement_common_1.innermostLoopScope)(thread) : (0, process_statement_common_1.createLoopScope)(thread);
|
|
234
|
+
// --- Evaluate the loop condition
|
|
235
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
|
|
236
|
+
if (condition) {
|
|
237
|
+
toUnshift = (0, process_statement_common_1.provideLoopBody)(loopScope, statement, thread.breakLabelValue);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
// --- When the condition is not met, we're done.
|
|
241
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
case "DoWS": {
|
|
246
|
+
if (!statement.guard) {
|
|
247
|
+
// --- First loop execution (do-while is a post-test loop)
|
|
248
|
+
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.createLoopScope)(thread), statement, thread.breakLabelValue);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
// --- Evaluate the loop condition
|
|
252
|
+
const condition = !!(0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread);
|
|
253
|
+
if (condition) {
|
|
254
|
+
toUnshift = (0, process_statement_common_1.provideLoopBody)((0, process_statement_common_1.innermostLoopScope)(thread), statement, thread.breakLabelValue);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// --- When the condition is not met, we're done.
|
|
258
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case "ContS": {
|
|
263
|
+
// --- Search for the innermost non-switch loop scope, release the switch scopes
|
|
264
|
+
if (!thread.loops || thread.loops.length === 0) {
|
|
265
|
+
throw new Error("Missing loop scope");
|
|
266
|
+
}
|
|
267
|
+
let loopScope;
|
|
268
|
+
while (thread.loops.length > 0) {
|
|
269
|
+
loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
270
|
+
if (!loopScope.isSwitch) {
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
thread.loops.pop();
|
|
274
|
+
}
|
|
275
|
+
if (!loopScope) {
|
|
276
|
+
throw new Error("Missing loop scope");
|
|
277
|
+
}
|
|
278
|
+
if (loopScope.tryBlockDepth >= 0 && loopScope.tryBlockDepth < ((_e = thread.tryBlocks) !== null && _e !== void 0 ? _e : []).length) {
|
|
279
|
+
// --- Mark the loop's try scope to exit with "continue"
|
|
280
|
+
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
281
|
+
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "continue";
|
|
282
|
+
}
|
|
283
|
+
// --- Clear the last part of the try/catch/finally block
|
|
284
|
+
const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
|
|
285
|
+
clearToLabel = tryScope.tryLabel;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
clearToLabel = loopScope.continueLabel;
|
|
289
|
+
(0, process_statement_common_1.releaseLoopScope)(thread, false);
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case "BrkS": {
|
|
294
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
295
|
+
if (loopScope === undefined) {
|
|
296
|
+
throw new Error("Missing loop scope");
|
|
297
|
+
}
|
|
298
|
+
if (!!loopScope.isSwitch) {
|
|
299
|
+
// --- Break is in a switch case
|
|
300
|
+
clearToLabel = loopScope.breakLabel;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
// --- Break is in a loop construct
|
|
304
|
+
if (loopScope.tryBlockDepth >= 0 && loopScope.tryBlockDepth < ((_f = thread.tryBlocks) !== null && _f !== void 0 ? _f : []).length) {
|
|
305
|
+
// --- Mark the loop's try scope to exit with "break"
|
|
306
|
+
for (let i = loopScope.tryBlockDepth; i < thread.tryBlocks.length; i++) {
|
|
307
|
+
thread.tryBlocks[loopScope.tryBlockDepth].exitType = "break";
|
|
308
|
+
}
|
|
309
|
+
// --- Clear the last part of the try/catch/finally block
|
|
310
|
+
const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
|
|
311
|
+
clearToLabel = tryScope.tryLabel;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
clearToLabel = loopScope.breakLabel;
|
|
315
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
316
|
+
}
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case "ForS":
|
|
320
|
+
if (!statement.guard) {
|
|
321
|
+
// --- Init the loop with a new scope
|
|
322
|
+
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
323
|
+
// --- Create a new block for the loop variables
|
|
324
|
+
(_g = thread.blocks) !== null && _g !== void 0 ? _g : (thread.blocks = []);
|
|
325
|
+
thread.blocks.push({ vars: {} });
|
|
326
|
+
const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
|
|
327
|
+
if (statement.init) {
|
|
328
|
+
// --- Unshift the initialization part and the guarded for-loop
|
|
329
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.init, guardStatement]);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
// --- No init, unshift only the guard statement
|
|
333
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([guardStatement]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
// --- Initialization already done. Evaluate the condition
|
|
338
|
+
if (!statement.condition || (0, eval_tree_sync_1.evalBinding)(statement.condition, evalContext, thread)) {
|
|
339
|
+
// --- Stay in the loop, inject the body, the update expression, and the loop guard
|
|
340
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
341
|
+
if (statement.update) {
|
|
342
|
+
const updateStmt = {
|
|
343
|
+
type: "ExprS",
|
|
344
|
+
expression: statement.update,
|
|
345
|
+
};
|
|
346
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, updateStmt, Object.assign({}, statement)]);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
|
|
350
|
+
}
|
|
351
|
+
// --- The next queue label is for "break"
|
|
352
|
+
loopScope.breakLabel = (_h = thread.breakLabelValue) !== null && _h !== void 0 ? _h : -1;
|
|
353
|
+
// --- The guard action's label is for "continue"
|
|
354
|
+
loopScope.continueLabel = toUnshift[1].label;
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// --- The condition is not met, we're done. Remove the loop's scope from the evaluation context
|
|
358
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
362
|
+
case "ForInS":
|
|
363
|
+
if (!statement.guard) {
|
|
364
|
+
// --- Get the object keys
|
|
365
|
+
const keyedObject = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
|
|
366
|
+
if (keyedObject == undefined) {
|
|
367
|
+
// --- Nothing to do, no object to traverse
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
// --- Init the loop with a new scope
|
|
371
|
+
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
372
|
+
// --- Create a new block for the loop variables
|
|
373
|
+
(_j = thread.blocks) !== null && _j !== void 0 ? _j : (thread.blocks = []);
|
|
374
|
+
thread.blocks.push({ vars: {} });
|
|
375
|
+
statement.keys = Object.keys(keyedObject);
|
|
376
|
+
statement.keyIndex = 0;
|
|
377
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
// --- Just for the sake of extra safety
|
|
381
|
+
if (statement.keyIndex === undefined || statement.keys === undefined) {
|
|
382
|
+
throw new Error("Keys information expected in for..in loop");
|
|
383
|
+
}
|
|
384
|
+
// --- Any key left?
|
|
385
|
+
if (statement.keyIndex < statement.keys.length) {
|
|
386
|
+
// --- Set the binding variable to the next key
|
|
387
|
+
const propValue = statement.keys[statement.keyIndex++];
|
|
388
|
+
switch (statement.varBinding) {
|
|
389
|
+
case "none": {
|
|
390
|
+
const assigmentExpr = {
|
|
391
|
+
type: "AsgnE",
|
|
392
|
+
leftValue: {
|
|
393
|
+
type: "IdE",
|
|
394
|
+
name: statement.id,
|
|
395
|
+
},
|
|
396
|
+
operator: "=",
|
|
397
|
+
operand: {
|
|
398
|
+
type: "LitE",
|
|
399
|
+
value: propValue,
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
(0, eval_tree_sync_1.evalBinding)(assigmentExpr, evalContext, thread);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case "const":
|
|
406
|
+
case "let":
|
|
407
|
+
{
|
|
408
|
+
// --- Create a new variable in the innermost scope
|
|
409
|
+
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
410
|
+
if (!block) {
|
|
411
|
+
throw new Error("Missing block scope");
|
|
412
|
+
}
|
|
413
|
+
block.vars[statement.id] = propValue;
|
|
414
|
+
if (statement.varBinding === "const") {
|
|
415
|
+
(_k = block.constVars) !== null && _k !== void 0 ? _k : (block.constVars = new Set());
|
|
416
|
+
block.constVars.add(statement.id);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
// --- Inject the loop body
|
|
422
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
423
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
|
|
424
|
+
// --- The next queue label is for "break"
|
|
425
|
+
loopScope.breakLabel = (_l = thread.breakLabelValue) !== null && _l !== void 0 ? _l : -1;
|
|
426
|
+
// --- The guard action's label is for "continue"
|
|
427
|
+
loopScope.continueLabel = toUnshift[1].label;
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
// --- The for..in loop is complete. Remove the loop's scope from the evaluation context
|
|
431
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
break;
|
|
435
|
+
case "ForOfS":
|
|
436
|
+
if (!statement.guard) {
|
|
437
|
+
// --- Get the object keys
|
|
438
|
+
const iteratorObject = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
|
|
439
|
+
if (iteratorObject == null || typeof iteratorObject[Symbol.iterator] !== "function") {
|
|
440
|
+
// --- The object is not an iterator
|
|
441
|
+
throw new Error("Object in for..of is not iterable");
|
|
442
|
+
}
|
|
443
|
+
// --- Init the loop with a new scope
|
|
444
|
+
(0, process_statement_common_1.createLoopScope)(thread, 1);
|
|
445
|
+
// --- Create a new block for the loop variables
|
|
446
|
+
(_m = thread.blocks) !== null && _m !== void 0 ? _m : (thread.blocks = []);
|
|
447
|
+
thread.blocks.push({ vars: {} });
|
|
448
|
+
statement.iterator = iteratorObject[Symbol.iterator]();
|
|
449
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([Object.assign(Object.assign({}, statement), { guard: true })]);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
// --- Just for the sake of extra safety
|
|
453
|
+
if (statement.iterator === undefined) {
|
|
454
|
+
throw new Error("Iterator expected in for..of loop");
|
|
455
|
+
}
|
|
456
|
+
// --- Any iteration left?
|
|
457
|
+
const nextIteration = statement.iterator.next();
|
|
458
|
+
if (nextIteration.done) {
|
|
459
|
+
// --- The for..of loop is complete. Remove the loop's scope from the evaluation context
|
|
460
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
// --- Set the binding variable to the next key
|
|
464
|
+
const propValue = nextIteration.value;
|
|
465
|
+
switch (statement.varBinding) {
|
|
466
|
+
case "none": {
|
|
467
|
+
const assigmentExpr = {
|
|
468
|
+
type: "AsgnE",
|
|
469
|
+
leftValue: {
|
|
470
|
+
type: "IdE",
|
|
471
|
+
name: statement.id,
|
|
472
|
+
},
|
|
473
|
+
operator: "=",
|
|
474
|
+
operand: {
|
|
475
|
+
type: "LitE",
|
|
476
|
+
value: propValue,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
(0, eval_tree_sync_1.evalBinding)(assigmentExpr, evalContext, thread);
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
case "const":
|
|
483
|
+
case "let":
|
|
484
|
+
{
|
|
485
|
+
// --- Create a new variable in the innermost scope
|
|
486
|
+
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
487
|
+
if (!block) {
|
|
488
|
+
throw new Error("Missing block scope");
|
|
489
|
+
}
|
|
490
|
+
block.vars[statement.id] = propValue;
|
|
491
|
+
if (statement.varBinding === "const") {
|
|
492
|
+
(_o = block.constVars) !== null && _o !== void 0 ? _o : (block.constVars = new Set());
|
|
493
|
+
block.constVars.add(statement.id);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
// --- Inject the loop body
|
|
499
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
500
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([statement.body, Object.assign({}, statement)]);
|
|
501
|
+
// --- The next queue label is for "break"
|
|
502
|
+
loopScope.breakLabel = (_p = thread.breakLabelValue) !== null && _p !== void 0 ? _p : -1;
|
|
503
|
+
// --- The guard action's label is for "continue"
|
|
504
|
+
loopScope.continueLabel = toUnshift[1].label;
|
|
505
|
+
}
|
|
506
|
+
break;
|
|
507
|
+
case "ThrowS": {
|
|
508
|
+
throw new EngineError_1.ThrowStatementError((0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread));
|
|
509
|
+
}
|
|
510
|
+
case "TryS": {
|
|
511
|
+
if (!statement.guard) {
|
|
512
|
+
// --- Execute the try block
|
|
513
|
+
toUnshift = (0, process_statement_common_1.provideTryBody)(thread, (0, process_statement_common_1.createTryScope)(thread, statement));
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
// --- Evaluate try
|
|
517
|
+
const tryScope = (0, process_statement_common_1.innermostTryScope)(thread);
|
|
518
|
+
switch (tryScope.processingPhase) {
|
|
519
|
+
case "error":
|
|
520
|
+
// --- There was an error we may handle with catch
|
|
521
|
+
switch (tryScope.errorSource) {
|
|
522
|
+
case "try":
|
|
523
|
+
// --- Remove the "try" block's scope
|
|
524
|
+
thread.blocks.pop();
|
|
525
|
+
// --- Go on with catch or finally
|
|
526
|
+
if (statement.catchBlock) {
|
|
527
|
+
if (tryScope.statement.catchVariable) {
|
|
528
|
+
const block = (0, process_statement_common_1.innermostBlockScope)(thread);
|
|
529
|
+
block.vars[tryScope.statement.catchVariable] =
|
|
530
|
+
tryScope.errorToThrow instanceof EngineError_1.ThrowStatementError
|
|
531
|
+
? tryScope.errorToThrow.errorObject
|
|
532
|
+
: tryScope.errorToThrow;
|
|
533
|
+
}
|
|
534
|
+
delete tryScope.errorToThrow;
|
|
535
|
+
tryScope.processingPhase = "catch";
|
|
536
|
+
toUnshift = (0, process_statement_common_1.provideCatchBody)(thread, tryScope);
|
|
537
|
+
}
|
|
538
|
+
else if (tryScope.statement.finallyBlock) {
|
|
539
|
+
// --- No catch, move on finally
|
|
540
|
+
tryScope.processingPhase = "finally";
|
|
541
|
+
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
542
|
+
}
|
|
543
|
+
break;
|
|
544
|
+
case "catch":
|
|
545
|
+
// --- Remove the "catch" block's scope
|
|
546
|
+
thread.blocks.pop();
|
|
547
|
+
// --- Move to the finally block
|
|
548
|
+
tryScope.processingPhase = "finally";
|
|
549
|
+
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
550
|
+
break;
|
|
551
|
+
case "finally":
|
|
552
|
+
// --- Remove the "finally" block's scope
|
|
553
|
+
thread.blocks.pop();
|
|
554
|
+
// --- Move to the post finally execution
|
|
555
|
+
tryScope.processingPhase = "postFinally";
|
|
556
|
+
toUnshift = (0, process_statement_common_1.provideFinallyErrorBody)(tryScope);
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
break;
|
|
560
|
+
case "try":
|
|
561
|
+
// --- We completed the try block successfully
|
|
562
|
+
tryScope.processingPhase = "finally";
|
|
563
|
+
if (statement.finallyBlock) {
|
|
564
|
+
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
565
|
+
}
|
|
566
|
+
break;
|
|
567
|
+
case "catch":
|
|
568
|
+
// --- We completed the catch block successfully, remove the handled error
|
|
569
|
+
tryScope.processingPhase = "finally";
|
|
570
|
+
if (statement.finallyBlock) {
|
|
571
|
+
toUnshift = (0, process_statement_common_1.provideFinallyBody)(thread, tryScope);
|
|
572
|
+
}
|
|
573
|
+
break;
|
|
574
|
+
case "finally":
|
|
575
|
+
tryScope.processingPhase = "postFinally";
|
|
576
|
+
toUnshift = (0, process_statement_common_1.provideFinallyErrorBody)(tryScope);
|
|
577
|
+
break;
|
|
578
|
+
case "postFinally":
|
|
579
|
+
// --- We completed the finally block successfully
|
|
580
|
+
const innermostTry = thread.tryBlocks.pop();
|
|
581
|
+
// --- Is there any special exit type?
|
|
582
|
+
switch (innermostTry.exitType) {
|
|
583
|
+
case "break": {
|
|
584
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
585
|
+
if (loopScope === undefined) {
|
|
586
|
+
throw new Error("Missing loop scope");
|
|
587
|
+
}
|
|
588
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
589
|
+
clearToLabel = loopScope.breakLabel;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
case "continue": {
|
|
593
|
+
const loopScope = (0, process_statement_common_1.innermostLoopScope)(thread);
|
|
594
|
+
if (loopScope === undefined) {
|
|
595
|
+
throw new Error("Missing loop scope");
|
|
596
|
+
}
|
|
597
|
+
clearToLabel = loopScope.continueLabel;
|
|
598
|
+
(0, process_statement_common_1.releaseLoopScope)(thread, false);
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
case "return":
|
|
602
|
+
clearToLabel = -1;
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
// --- Should we raise an error?
|
|
606
|
+
if (innermostTry.errorToThrow) {
|
|
607
|
+
throw innermostTry.errorToThrow;
|
|
608
|
+
}
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
case "SwitchS": {
|
|
614
|
+
// --- Create or get the loop's scope (guard is falsy for the first execution)
|
|
615
|
+
if (statement.guard) {
|
|
616
|
+
// --- Complete the switch
|
|
617
|
+
(0, process_statement_common_1.releaseLoopScope)(thread);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
let loopScope = (0, process_statement_common_1.createLoopScope)(thread);
|
|
621
|
+
loopScope.isSwitch = true;
|
|
622
|
+
thread.blocks.push({ vars: {} });
|
|
623
|
+
// --- Evaluate the switch value
|
|
624
|
+
const switchValue = (0, eval_tree_sync_1.evalBinding)(statement.expression, evalContext, thread);
|
|
625
|
+
// --- Find the matching label
|
|
626
|
+
let matchingIndex = -1;
|
|
627
|
+
for (let i = 0; i < statement.cases.length; i++) {
|
|
628
|
+
const currentCase = statement.cases[i];
|
|
629
|
+
// --- Check for default case
|
|
630
|
+
if (currentCase.caseExpression === undefined) {
|
|
631
|
+
matchingIndex = i;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
// --- Check for matching case
|
|
635
|
+
const caseValue = (0, eval_tree_sync_1.evalBinding)(currentCase.caseExpression, evalContext, thread);
|
|
636
|
+
if (caseValue === switchValue) {
|
|
637
|
+
matchingIndex = i;
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// --- Merge all statements from the matching label
|
|
642
|
+
const statementFlow = [];
|
|
643
|
+
if (matchingIndex >= 0) {
|
|
644
|
+
for (let i = matchingIndex; i < statement.cases.length; i++) {
|
|
645
|
+
statementFlow.push(...statement.cases[i].statements);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// --- Queue the statement flow and the guard
|
|
649
|
+
const guardStatement = Object.assign(Object.assign({}, statement), { guard: true });
|
|
650
|
+
toUnshift = (0, statement_queue_1.mapStatementsToQueueItems)([...statementFlow, guardStatement]);
|
|
651
|
+
loopScope.breakLabel = toUnshift[toUnshift.length - 1].label;
|
|
652
|
+
}
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
// --- The statement may remove the innermost scope
|
|
657
|
+
if (statement.removeBlockScope) {
|
|
658
|
+
if (thread.blocks && thread.blocks.length > 0) {
|
|
659
|
+
thread.blocks.pop();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
// --- Done.
|
|
663
|
+
return { toUnshift, clearToLabel };
|
|
664
|
+
}
|
|
665
|
+
// --- Process a variable declaration
|
|
666
|
+
function processDeclarations(block, evalContext, thread, declarations, addConst = false, useValue = false, baseValue = undefined) {
|
|
667
|
+
for (let i = 0; i < declarations.length; i++) {
|
|
668
|
+
let value;
|
|
669
|
+
const decl = declarations[i];
|
|
670
|
+
if (useValue) {
|
|
671
|
+
value = baseValue;
|
|
672
|
+
}
|
|
673
|
+
else if (decl.expression) {
|
|
674
|
+
//TODO illesg here, functionInvocation for global function (e.g. window.confirm... )
|
|
675
|
+
value = (0, eval_tree_sync_1.evalBinding)(decl.expression, evalContext, thread);
|
|
676
|
+
}
|
|
677
|
+
visitDeclaration(block, decl, value, addConst);
|
|
678
|
+
}
|
|
679
|
+
// --- Visit a variable
|
|
680
|
+
function visitDeclaration(block, decl, baseValue, addConst) {
|
|
681
|
+
// --- Process each declaration
|
|
682
|
+
if (decl.id) {
|
|
683
|
+
visitIdDeclaration(block, decl.id, baseValue, addConst);
|
|
684
|
+
}
|
|
685
|
+
else if (decl.arrayDestruct) {
|
|
686
|
+
visitArrayDestruct(block, decl.arrayDestruct, baseValue, addConst);
|
|
687
|
+
}
|
|
688
|
+
else if (decl.objectDestruct) {
|
|
689
|
+
visitObjectDestruct(block, decl.objectDestruct, baseValue, addConst);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
throw new Error("Unknown declaration specifier");
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
// --- Visits a single ID declaration
|
|
696
|
+
function visitIdDeclaration(block, id, baseValue, addConst) {
|
|
697
|
+
var _a;
|
|
698
|
+
if (block.vars[id]) {
|
|
699
|
+
throw new Error(`Variable ${id} is already declared in the current scope.`);
|
|
700
|
+
}
|
|
701
|
+
block.vars[id] = baseValue;
|
|
702
|
+
if (addConst) {
|
|
703
|
+
(_a = block.constVars) !== null && _a !== void 0 ? _a : (block.constVars = new Set());
|
|
704
|
+
block.constVars.add(id);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
// --- Visits an array destructure declaration
|
|
708
|
+
function visitArrayDestruct(block, arrayD, baseValue, addConst) {
|
|
709
|
+
for (let i = 0; i < arrayD.length; i++) {
|
|
710
|
+
const arrDecl = arrayD[i];
|
|
711
|
+
const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[i];
|
|
712
|
+
if (arrDecl.id) {
|
|
713
|
+
visitIdDeclaration(block, arrDecl.id, value, addConst);
|
|
714
|
+
}
|
|
715
|
+
else if (arrDecl.arrayDestruct) {
|
|
716
|
+
visitArrayDestruct(block, arrDecl.arrayDestruct, value, addConst);
|
|
717
|
+
}
|
|
718
|
+
else if (arrDecl.objectDestruct) {
|
|
719
|
+
visitObjectDestruct(block, arrDecl.objectDestruct, value, addConst);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
// --- Visits an object destructure declaration
|
|
724
|
+
function visitObjectDestruct(block, objectD, baseValue, addConst) {
|
|
725
|
+
var _a;
|
|
726
|
+
for (let i = 0; i < objectD.length; i++) {
|
|
727
|
+
const objDecl = objectD[i];
|
|
728
|
+
const value = baseValue === null || baseValue === void 0 ? void 0 : baseValue[objDecl.id];
|
|
729
|
+
if (objDecl.arrayDestruct) {
|
|
730
|
+
visitArrayDestruct(block, objDecl.arrayDestruct, value, addConst);
|
|
731
|
+
}
|
|
732
|
+
else if (objDecl.objectDestruct) {
|
|
733
|
+
visitObjectDestruct(block, objDecl.objectDestruct, value, addConst);
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
visitIdDeclaration(block, (_a = objDecl.alias) !== null && _a !== void 0 ? _a : objDecl.id, value, addConst);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|