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,498 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPromise = isPromise;
|
|
4
|
+
exports.getCustomOperations = getCustomOperations;
|
|
5
|
+
exports.evalLiteral = evalLiteral;
|
|
6
|
+
exports.getIdentifierScope = getIdentifierScope;
|
|
7
|
+
exports.evalIdentifier = evalIdentifier;
|
|
8
|
+
exports.evalMemberAccessCore = evalMemberAccessCore;
|
|
9
|
+
exports.evalCalculatedMemberAccessCore = evalCalculatedMemberAccessCore;
|
|
10
|
+
exports.evalUnaryCore = evalUnaryCore;
|
|
11
|
+
exports.evalBinaryCore = evalBinaryCore;
|
|
12
|
+
exports.evalAssignmentCore = evalAssignmentCore;
|
|
13
|
+
exports.evalPreOrPostCore = evalPreOrPostCore;
|
|
14
|
+
exports.evalArrow = evalArrow;
|
|
15
|
+
exports.obtainClosures = obtainClosures;
|
|
16
|
+
const custom_operations_registry_1 = require("./custom-operations-registry");
|
|
17
|
+
const custom_ui_data_1 = require("./custom-ui-data");
|
|
18
|
+
const eval_tree_async_1 = require("./eval-tree-async");
|
|
19
|
+
const ICustomOperations_1 = require("./ICustomOperations");
|
|
20
|
+
// --- Type guard to check for a Promise
|
|
21
|
+
function isPromise(obj) {
|
|
22
|
+
return obj && typeof obj.then === "function";
|
|
23
|
+
}
|
|
24
|
+
// --- Gets the optional custom operation for the specified operation type
|
|
25
|
+
function getCustomOperations(opType, firstOperand, secondOperand) {
|
|
26
|
+
// --- The first operand must be a useful value or object
|
|
27
|
+
if (firstOperand === null || firstOperand === undefined)
|
|
28
|
+
return null;
|
|
29
|
+
// --- Is the first operand a custom UI type?
|
|
30
|
+
if (!(0, custom_ui_data_1.isCustomUiData)(firstOperand))
|
|
31
|
+
return null;
|
|
32
|
+
// --- Has the custom type registered a custom calculator object?
|
|
33
|
+
const calculator = custom_operations_registry_1.customOperationsRegistry.getOperationsObjectByKey(firstOperand._custom_data_type_);
|
|
34
|
+
if (!calculator)
|
|
35
|
+
return null;
|
|
36
|
+
// --- The calculator defines the requested operation?
|
|
37
|
+
let exists = false;
|
|
38
|
+
switch (opType) {
|
|
39
|
+
case ICustomOperations_1.CustomOperationType.MemberAccess:
|
|
40
|
+
exists = !!calculator.memberAccess;
|
|
41
|
+
break;
|
|
42
|
+
case ICustomOperations_1.CustomOperationType.CalculatedMemberAccess:
|
|
43
|
+
exists = !!calculator.calculatedMemberAccess;
|
|
44
|
+
break;
|
|
45
|
+
case ICustomOperations_1.CustomOperationType.UnaryPlus:
|
|
46
|
+
exists = !!calculator.unaryPlus;
|
|
47
|
+
break;
|
|
48
|
+
case ICustomOperations_1.CustomOperationType.UnaryMinus:
|
|
49
|
+
exists = !!calculator.unaryMinus;
|
|
50
|
+
break;
|
|
51
|
+
case ICustomOperations_1.CustomOperationType.LogicalNot:
|
|
52
|
+
exists = !!calculator.logicalNot;
|
|
53
|
+
break;
|
|
54
|
+
case ICustomOperations_1.CustomOperationType.BitwiseNot:
|
|
55
|
+
exists = !!calculator.bitwiseNot;
|
|
56
|
+
break;
|
|
57
|
+
case ICustomOperations_1.CustomOperationType.Multiply:
|
|
58
|
+
exists = !!calculator.multiply;
|
|
59
|
+
break;
|
|
60
|
+
case ICustomOperations_1.CustomOperationType.Divide:
|
|
61
|
+
exists = !!calculator.divide;
|
|
62
|
+
break;
|
|
63
|
+
case ICustomOperations_1.CustomOperationType.Remainder:
|
|
64
|
+
exists = !!calculator.remainder;
|
|
65
|
+
break;
|
|
66
|
+
case ICustomOperations_1.CustomOperationType.Add:
|
|
67
|
+
exists = !!calculator.add;
|
|
68
|
+
break;
|
|
69
|
+
case ICustomOperations_1.CustomOperationType.Subtract:
|
|
70
|
+
exists = !!calculator.subtract;
|
|
71
|
+
break;
|
|
72
|
+
case ICustomOperations_1.CustomOperationType.SignedRightShift:
|
|
73
|
+
exists = !!calculator.signedRightShift;
|
|
74
|
+
break;
|
|
75
|
+
case ICustomOperations_1.CustomOperationType.UnsignedRightShift:
|
|
76
|
+
exists = !!calculator.unsignedRightShift;
|
|
77
|
+
break;
|
|
78
|
+
case ICustomOperations_1.CustomOperationType.LeftShift:
|
|
79
|
+
exists = !!calculator.leftShift;
|
|
80
|
+
break;
|
|
81
|
+
case ICustomOperations_1.CustomOperationType.LessThan:
|
|
82
|
+
exists = !!calculator.lessThan;
|
|
83
|
+
break;
|
|
84
|
+
case ICustomOperations_1.CustomOperationType.LessThanOrEqual:
|
|
85
|
+
exists = !!calculator.lessThanOrEqual;
|
|
86
|
+
break;
|
|
87
|
+
case ICustomOperations_1.CustomOperationType.GreaterThan:
|
|
88
|
+
exists = !!calculator.greaterThan;
|
|
89
|
+
break;
|
|
90
|
+
case ICustomOperations_1.CustomOperationType.GreaterThanOrEqual:
|
|
91
|
+
exists = !!calculator.greaterThanOrEqual;
|
|
92
|
+
break;
|
|
93
|
+
case ICustomOperations_1.CustomOperationType.Equal:
|
|
94
|
+
exists = !!calculator.equal;
|
|
95
|
+
break;
|
|
96
|
+
case ICustomOperations_1.CustomOperationType.StrictEqual:
|
|
97
|
+
exists = !!calculator.strictEqual;
|
|
98
|
+
break;
|
|
99
|
+
case ICustomOperations_1.CustomOperationType.NotEqual:
|
|
100
|
+
exists = !!calculator.notEqual;
|
|
101
|
+
break;
|
|
102
|
+
case ICustomOperations_1.CustomOperationType.StrictNotEqual:
|
|
103
|
+
exists = !!calculator.strictNotEqual;
|
|
104
|
+
break;
|
|
105
|
+
case ICustomOperations_1.CustomOperationType.BitwiseAnd:
|
|
106
|
+
exists = !!calculator.bitwiseAnd;
|
|
107
|
+
break;
|
|
108
|
+
case ICustomOperations_1.CustomOperationType.BitwiseXor:
|
|
109
|
+
exists = !!calculator.bitwiseXor;
|
|
110
|
+
break;
|
|
111
|
+
case ICustomOperations_1.CustomOperationType.BitwiseOr:
|
|
112
|
+
exists = !!calculator.bitwiseOr;
|
|
113
|
+
break;
|
|
114
|
+
case ICustomOperations_1.CustomOperationType.LogicalAnd:
|
|
115
|
+
exists = !!calculator.logicalAnd;
|
|
116
|
+
break;
|
|
117
|
+
case ICustomOperations_1.CustomOperationType.LogicalOr:
|
|
118
|
+
exists = !!calculator.logicalOr;
|
|
119
|
+
break;
|
|
120
|
+
case ICustomOperations_1.CustomOperationType.NullCoalesce:
|
|
121
|
+
exists = !!calculator.nullCoalesce;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
// --- The calculator object must support the specified operation
|
|
125
|
+
if (!exists)
|
|
126
|
+
return null;
|
|
127
|
+
// --- Does the operation support the provided second operand?
|
|
128
|
+
return secondOperand !== undefined
|
|
129
|
+
? calculator.supportSecondOperand(opType, secondOperand)
|
|
130
|
+
? calculator
|
|
131
|
+
: null
|
|
132
|
+
: calculator;
|
|
133
|
+
}
|
|
134
|
+
// --- Evaluates a literal value (sync & async context)
|
|
135
|
+
function evalLiteral(thisStack, expr) {
|
|
136
|
+
thisStack.push(expr.value);
|
|
137
|
+
return expr.value;
|
|
138
|
+
}
|
|
139
|
+
function getIdentifierScope(expr, evalContext, thread) {
|
|
140
|
+
var _a, _b, _c;
|
|
141
|
+
let type;
|
|
142
|
+
let scope;
|
|
143
|
+
// --- Search for primary value scope
|
|
144
|
+
if (expr.isGlobal) {
|
|
145
|
+
// --- Use the global scope only
|
|
146
|
+
scope = globalThis;
|
|
147
|
+
type = "global";
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// --- Iterate trough threads from the current to the parent
|
|
151
|
+
let currentThread = thread !== null && thread !== void 0 ? thread : evalContext.mainThread;
|
|
152
|
+
while (currentThread && !scope) {
|
|
153
|
+
if (currentThread.blocks) {
|
|
154
|
+
// --- Search the block-scopes
|
|
155
|
+
for (let idx = currentThread.blocks.length - 1; idx >= 0; idx--) {
|
|
156
|
+
const blockContext = (_a = currentThread.blocks[idx]) === null || _a === void 0 ? void 0 : _a.vars;
|
|
157
|
+
if (blockContext && expr.name in blockContext) {
|
|
158
|
+
scope = blockContext;
|
|
159
|
+
type = "block";
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// --- We may have already found the ID
|
|
165
|
+
if (scope)
|
|
166
|
+
break;
|
|
167
|
+
if (currentThread.closures) {
|
|
168
|
+
// --- Search block-scopes of the closure list
|
|
169
|
+
for (let idx = currentThread.closures.length - 1; idx >= 0; idx--) {
|
|
170
|
+
const blockContext = (_b = currentThread.closures[idx]) === null || _b === void 0 ? void 0 : _b.vars;
|
|
171
|
+
if (blockContext && expr.name in blockContext) {
|
|
172
|
+
scope = blockContext;
|
|
173
|
+
type = "block";
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// --- We may have already found the ID
|
|
179
|
+
if (scope)
|
|
180
|
+
break;
|
|
181
|
+
// --- Check the parent thread
|
|
182
|
+
currentThread = currentThread.parent;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// --- If no identifier found so far, check the local context, the app context, and finally, the global context
|
|
186
|
+
if (!scope) {
|
|
187
|
+
if (evalContext.localContext && expr.name in evalContext.localContext) {
|
|
188
|
+
// --- Object in localContext
|
|
189
|
+
scope = evalContext.localContext;
|
|
190
|
+
type = "localContext";
|
|
191
|
+
}
|
|
192
|
+
else if (((_c = evalContext.appContext) === null || _c === void 0 ? void 0 : _c[expr.name]) !== undefined) {
|
|
193
|
+
// --- Object in appContext
|
|
194
|
+
scope = evalContext.appContext;
|
|
195
|
+
type = "app";
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// --- Finally, check the global context
|
|
199
|
+
scope = globalThis;
|
|
200
|
+
type = "global";
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// --- Done
|
|
204
|
+
return { type, scope: scope };
|
|
205
|
+
}
|
|
206
|
+
// --- Evaluates an identifier (sync & async context)
|
|
207
|
+
function evalIdentifier(thisStack, expr, evalContext, thread) {
|
|
208
|
+
const idScope = getIdentifierScope(expr, evalContext, thread);
|
|
209
|
+
const valueScope = idScope.scope;
|
|
210
|
+
let valueIndex = expr.name;
|
|
211
|
+
let idObj;
|
|
212
|
+
// --- Get the variable value
|
|
213
|
+
expr.valueScope = valueScope;
|
|
214
|
+
expr.valueIndex = valueIndex;
|
|
215
|
+
idObj = valueScope[valueIndex];
|
|
216
|
+
// --- Done
|
|
217
|
+
expr.value = idObj;
|
|
218
|
+
thisStack.push(idObj);
|
|
219
|
+
return idObj;
|
|
220
|
+
}
|
|
221
|
+
// --- Evaluates a member access expression (sync & async context)
|
|
222
|
+
function evalMemberAccessCore(parentObj, thisStack, expr, evalContext) {
|
|
223
|
+
var _a;
|
|
224
|
+
// --- At this point we definitely keep the parent object on `thisStack`, as it will be the context object
|
|
225
|
+
// --- of a FunctionInvocationExpression, if that follows the MemberAccess. Other operations would call
|
|
226
|
+
// --- `thisStack.pop()` to remove the result from the previous `evalBindingExpressionTree` call.
|
|
227
|
+
expr.valueScope = parentObj;
|
|
228
|
+
expr.valueIndex = expr.member;
|
|
229
|
+
const memberObj = expr.isOptional || ((_a = evalContext.options) === null || _a === void 0 ? void 0 : _a.defaultToOptionalMemberAccess)
|
|
230
|
+
? parentObj === null || parentObj === void 0 ? void 0 : parentObj[expr.member]
|
|
231
|
+
: parentObj[expr.member];
|
|
232
|
+
thisStack.push(memberObj);
|
|
233
|
+
// --- Done.
|
|
234
|
+
return memberObj;
|
|
235
|
+
}
|
|
236
|
+
// --- Evaluates a calculated member access expression (sync & async context)
|
|
237
|
+
function evalCalculatedMemberAccessCore(parentObj, memberObj, thisStack, expr, evalContext) {
|
|
238
|
+
var _a;
|
|
239
|
+
// --- At this point we definitely keep the parent object on `thisStack`, as it will be the context object
|
|
240
|
+
// --- of a FunctionInvocationExpression, if that follows the MemberAccess. Other operations would call
|
|
241
|
+
// --- `thisStack.pop()` to remove the result from the previous `evalBindingExpressionTree` call.
|
|
242
|
+
expr.valueScope = parentObj;
|
|
243
|
+
expr.valueIndex = memberObj;
|
|
244
|
+
const calcMemberObj = ((_a = evalContext.options) === null || _a === void 0 ? void 0 : _a.defaultToOptionalMemberAccess)
|
|
245
|
+
? parentObj === null || parentObj === void 0 ? void 0 : parentObj[memberObj]
|
|
246
|
+
: parentObj[memberObj];
|
|
247
|
+
thisStack.push(calcMemberObj);
|
|
248
|
+
// --- Done.
|
|
249
|
+
return calcMemberObj;
|
|
250
|
+
}
|
|
251
|
+
// --- Evaluates a unary expression (sync & async context)
|
|
252
|
+
function evalUnaryCore(expr, operand, thisStack, customOp) {
|
|
253
|
+
let unaryObj;
|
|
254
|
+
switch (expr.operator) {
|
|
255
|
+
case "typeof":
|
|
256
|
+
unaryObj = typeof operand;
|
|
257
|
+
break;
|
|
258
|
+
case "delete":
|
|
259
|
+
if (expr.operand.valueScope && expr.operand.valueIndex) {
|
|
260
|
+
return delete expr.operand.valueScope[expr.operand.valueIndex];
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
case "+":
|
|
264
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.UnaryPlus, operand);
|
|
265
|
+
unaryObj = customOp ? customOp.unaryPlus(operand) : operand;
|
|
266
|
+
break;
|
|
267
|
+
case "-":
|
|
268
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.UnaryMinus, operand);
|
|
269
|
+
unaryObj = customOp ? customOp.unaryPlus(operand) : -operand;
|
|
270
|
+
break;
|
|
271
|
+
case "!":
|
|
272
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LogicalNot, operand);
|
|
273
|
+
unaryObj = customOp ? customOp.unaryPlus(operand) : !operand;
|
|
274
|
+
break;
|
|
275
|
+
case "~":
|
|
276
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.BitwiseNot, operand);
|
|
277
|
+
unaryObj = customOp ? customOp.unaryPlus(operand) : ~operand;
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
throw new Error(`Unknown unary operator: ${expr.operator}`);
|
|
281
|
+
}
|
|
282
|
+
thisStack.push(unaryObj);
|
|
283
|
+
return unaryObj;
|
|
284
|
+
}
|
|
285
|
+
// --- Evaluates a binary operation (sync & async context)
|
|
286
|
+
function evalBinaryCore(l, r, thisStack, customOp, opSymbol) {
|
|
287
|
+
let binaryObj;
|
|
288
|
+
switch (opSymbol) {
|
|
289
|
+
case "**":
|
|
290
|
+
binaryObj = Math.pow(l, r);
|
|
291
|
+
break;
|
|
292
|
+
case "*":
|
|
293
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Multiply, l, r);
|
|
294
|
+
binaryObj = customOp ? customOp.multiply(l, r) : l * r;
|
|
295
|
+
break;
|
|
296
|
+
case "/":
|
|
297
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Divide, l, r);
|
|
298
|
+
binaryObj = customOp ? customOp.divide(l, r) : l / r;
|
|
299
|
+
break;
|
|
300
|
+
case "%":
|
|
301
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Remainder, l, r);
|
|
302
|
+
binaryObj = customOp ? customOp.remainder(l, r) : l % r;
|
|
303
|
+
break;
|
|
304
|
+
case "+":
|
|
305
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Add, l, r);
|
|
306
|
+
binaryObj = customOp ? customOp.add(l, r) : l + r;
|
|
307
|
+
break;
|
|
308
|
+
case "-":
|
|
309
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Subtract, l, r);
|
|
310
|
+
binaryObj = customOp ? customOp.subtract(l, r) : l - r;
|
|
311
|
+
break;
|
|
312
|
+
case ">>":
|
|
313
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.SignedRightShift, l, r);
|
|
314
|
+
binaryObj = customOp ? customOp.signedRightShift(l, r) : l >> r;
|
|
315
|
+
break;
|
|
316
|
+
case ">>>":
|
|
317
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.UnsignedRightShift, l, r);
|
|
318
|
+
binaryObj = customOp ? customOp.unsignedRightShift(l, r) : l >>> r;
|
|
319
|
+
break;
|
|
320
|
+
case "<<":
|
|
321
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LeftShift, l, r);
|
|
322
|
+
binaryObj = customOp ? customOp.leftShift(l, r) : l << r;
|
|
323
|
+
break;
|
|
324
|
+
case "<":
|
|
325
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LessThan, l, r);
|
|
326
|
+
binaryObj = customOp ? customOp.lessThan(l, r) : l < r;
|
|
327
|
+
break;
|
|
328
|
+
case "<=":
|
|
329
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LessThanOrEqual, l, r);
|
|
330
|
+
binaryObj = customOp ? customOp.lessThanOrEqual(l, r) : l <= r;
|
|
331
|
+
break;
|
|
332
|
+
case ">":
|
|
333
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.GreaterThan, l, r);
|
|
334
|
+
binaryObj = customOp ? customOp.greaterThan(l, r) : l > r;
|
|
335
|
+
break;
|
|
336
|
+
case ">=":
|
|
337
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.GreaterThanOrEqual, l, r);
|
|
338
|
+
binaryObj = customOp ? customOp.greaterThanOrEqual(l, r) : l >= r;
|
|
339
|
+
break;
|
|
340
|
+
case "in":
|
|
341
|
+
binaryObj = l in r;
|
|
342
|
+
break;
|
|
343
|
+
case "==":
|
|
344
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.Equal, l, r);
|
|
345
|
+
// eslint-disable-next-line eqeqeq
|
|
346
|
+
binaryObj = customOp ? customOp.equal(l, r) : l == r;
|
|
347
|
+
break;
|
|
348
|
+
case "!=":
|
|
349
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.NotEqual, l, r);
|
|
350
|
+
// eslint-disable-next-line eqeqeq
|
|
351
|
+
binaryObj = customOp ? customOp.notEqual(l, r) : l != r;
|
|
352
|
+
break;
|
|
353
|
+
case "===":
|
|
354
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.StrictEqual, l, r);
|
|
355
|
+
binaryObj = customOp ? customOp.strictEqual(l, r) : l === r;
|
|
356
|
+
break;
|
|
357
|
+
case "!==":
|
|
358
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.StrictNotEqual, l, r);
|
|
359
|
+
binaryObj = customOp ? customOp.strictNotEqual(l, r) : l !== r;
|
|
360
|
+
break;
|
|
361
|
+
case "&":
|
|
362
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.BitwiseAnd, l, r);
|
|
363
|
+
binaryObj = customOp ? customOp.bitwiseAnd(l, r) : l & r;
|
|
364
|
+
break;
|
|
365
|
+
case "^":
|
|
366
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.BitwiseXor, l, r);
|
|
367
|
+
binaryObj = customOp ? customOp.bitwiseXor(l, r) : l ^ r;
|
|
368
|
+
break;
|
|
369
|
+
case "|":
|
|
370
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.BitwiseOr, l, r);
|
|
371
|
+
binaryObj = customOp ? customOp.bitwiseOr(l, r) : l | r;
|
|
372
|
+
break;
|
|
373
|
+
case "&&":
|
|
374
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LogicalAnd, l, r);
|
|
375
|
+
binaryObj = customOp ? customOp.logicalAnd(l, r) : l && r;
|
|
376
|
+
break;
|
|
377
|
+
case "||":
|
|
378
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.LogicalOr, l, r);
|
|
379
|
+
binaryObj = customOp ? customOp.logicalOr(l, r) : l || r;
|
|
380
|
+
break;
|
|
381
|
+
case "??":
|
|
382
|
+
customOp = getCustomOperations(ICustomOperations_1.CustomOperationType.NullCoalesce, l, r);
|
|
383
|
+
binaryObj = customOp ? customOp.nullCoalesce(l, r) : l !== null && l !== void 0 ? l : r;
|
|
384
|
+
break;
|
|
385
|
+
default:
|
|
386
|
+
throw new Error(`Unknown binary operator: ${opSymbol}`);
|
|
387
|
+
}
|
|
388
|
+
thisStack.push(binaryObj);
|
|
389
|
+
return binaryObj;
|
|
390
|
+
}
|
|
391
|
+
// --- Evaluates an assignment operation (sync & async context)
|
|
392
|
+
function evalAssignmentCore(leftValue, newValue, thisStack, expr, thread) {
|
|
393
|
+
var _a, _b;
|
|
394
|
+
if (!leftValue.valueScope || leftValue.valueIndex === undefined || leftValue.valueIndex === null) {
|
|
395
|
+
throw new Error(`Evaluation of ${expr.operator} requires a left-hand value., valueScope: ${leftValue.valueScope}, valueIndex: ${leftValue.valueIndex}`);
|
|
396
|
+
}
|
|
397
|
+
const leftScope = leftValue.valueScope;
|
|
398
|
+
const leftIndex = leftValue.valueIndex;
|
|
399
|
+
if (typeof leftScope !== "object" || leftScope === null) {
|
|
400
|
+
throw new Error(`Unknown left-hand value ${leftValue === null || leftValue === void 0 ? void 0 : leftValue.source}, ${expr.source}`);
|
|
401
|
+
}
|
|
402
|
+
// --- Check for const value
|
|
403
|
+
if (expr.leftValue.type === "IdE") {
|
|
404
|
+
if ((0, eval_tree_async_1.isConstVar)(expr.leftValue.name, thread)) {
|
|
405
|
+
throw new Error("A const variable cannot be modified");
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (leftScope === globalThis && !(leftIndex in leftScope)) {
|
|
409
|
+
throw new Error(`Left value variable (${leftIndex}) not found in the scope.`);
|
|
410
|
+
}
|
|
411
|
+
thisStack.pop();
|
|
412
|
+
switch (expr.operator) {
|
|
413
|
+
case "=":
|
|
414
|
+
leftScope[leftIndex] = newValue;
|
|
415
|
+
break;
|
|
416
|
+
case "+=":
|
|
417
|
+
leftScope[leftIndex] += newValue;
|
|
418
|
+
break;
|
|
419
|
+
case "-=":
|
|
420
|
+
leftScope[leftIndex] -= newValue;
|
|
421
|
+
break;
|
|
422
|
+
case "**=":
|
|
423
|
+
(_a = leftScope)[_b = leftIndex] = Math.pow(_a[_b], newValue);
|
|
424
|
+
break;
|
|
425
|
+
case "*=":
|
|
426
|
+
leftScope[leftIndex] *= newValue;
|
|
427
|
+
break;
|
|
428
|
+
case "/=":
|
|
429
|
+
leftScope[leftIndex] /= newValue;
|
|
430
|
+
break;
|
|
431
|
+
case "%=":
|
|
432
|
+
leftScope[leftIndex] %= newValue;
|
|
433
|
+
break;
|
|
434
|
+
case "<<=":
|
|
435
|
+
leftScope[leftIndex] <<= newValue;
|
|
436
|
+
break;
|
|
437
|
+
case ">>=":
|
|
438
|
+
leftScope[leftIndex] >>= newValue;
|
|
439
|
+
break;
|
|
440
|
+
case ">>>=":
|
|
441
|
+
leftScope[leftIndex] >>>= newValue;
|
|
442
|
+
break;
|
|
443
|
+
case "&=":
|
|
444
|
+
leftScope[leftIndex] &= newValue;
|
|
445
|
+
break;
|
|
446
|
+
case "^=":
|
|
447
|
+
leftScope[leftIndex] ^= newValue;
|
|
448
|
+
break;
|
|
449
|
+
case "|=":
|
|
450
|
+
leftScope[leftIndex] |= newValue;
|
|
451
|
+
break;
|
|
452
|
+
case "&&=":
|
|
453
|
+
leftScope[leftIndex] && (leftScope[leftIndex] = newValue);
|
|
454
|
+
break;
|
|
455
|
+
case "||=":
|
|
456
|
+
leftScope[leftIndex] || (leftScope[leftIndex] = newValue);
|
|
457
|
+
break;
|
|
458
|
+
case "??=":
|
|
459
|
+
leftScope[leftIndex] += newValue;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
const value = leftScope[leftIndex];
|
|
463
|
+
thisStack.push(value);
|
|
464
|
+
return value;
|
|
465
|
+
}
|
|
466
|
+
// --- Evaluates a prefix/postfix operator (sync & async context)
|
|
467
|
+
function evalPreOrPostCore(operand, thisStack, expr, evalContext, thread) {
|
|
468
|
+
if (!operand.valueScope || operand.valueIndex === undefined) {
|
|
469
|
+
throw new Error(`Evaluation of ${expr.operator} requires a left-hand value.`);
|
|
470
|
+
}
|
|
471
|
+
// --- Check for const value
|
|
472
|
+
if (expr.operand.type === "IdE") {
|
|
473
|
+
if ((0, eval_tree_async_1.isConstVar)(expr.operand.name, thread)) {
|
|
474
|
+
// --- We cannot modify a const value
|
|
475
|
+
throw new Error("A const variable cannot be modified");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const value = expr.operator === "++"
|
|
479
|
+
? expr.type === "PrefE"
|
|
480
|
+
? ++operand.valueScope[operand.valueIndex]
|
|
481
|
+
: operand.valueScope[operand.valueIndex]++
|
|
482
|
+
: expr.type === "PrefE"
|
|
483
|
+
? --operand.valueScope[operand.valueIndex]
|
|
484
|
+
: operand.valueScope[operand.valueIndex]--;
|
|
485
|
+
thisStack.push(value);
|
|
486
|
+
return value;
|
|
487
|
+
}
|
|
488
|
+
// --- Evaluates an arrow expression (lazy, sync & async context)
|
|
489
|
+
function evalArrow(thisStack, expr, thread) {
|
|
490
|
+
const lazyArrow = Object.assign(Object.assign({}, expr), { _ARROW_EXPR_: true, closureContext: obtainClosures(thread) });
|
|
491
|
+
thisStack.push(lazyArrow);
|
|
492
|
+
return lazyArrow;
|
|
493
|
+
}
|
|
494
|
+
function obtainClosures(thread) {
|
|
495
|
+
var _a, _b;
|
|
496
|
+
const closures = (_b = (_a = thread.blocks) === null || _a === void 0 ? void 0 : _a.slice(0)) !== null && _b !== void 0 ? _b : [];
|
|
497
|
+
return thread.parent ? [...obtainClosures(thread.parent), ...closures] : closures;
|
|
498
|
+
}
|