@eagleoutice/flowr 2.14.0 → 2.14.2
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/README.md +169 -91
- package/abstract-interpretation/absint-visitor.d.ts +91 -25
- package/abstract-interpretation/absint-visitor.js +235 -74
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
- package/abstract-interpretation/data-frame/resolve-args.js +6 -4
- package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
- package/abstract-interpretation/domains/partial-product-domain.js +1 -1
- package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-range-domain.js +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
- package/benchmark/calibration.d.ts +18 -11
- package/benchmark/calibration.js +37 -27
- package/benchmark/slicer.d.ts +9 -2
- package/benchmark/slicer.js +44 -37
- package/benchmark/stats/count-comments.d.ts +16 -0
- package/benchmark/stats/count-comments.js +30 -0
- package/benchmark/stats/print.js +2 -0
- package/benchmark/stats/size-of.d.ts +7 -3
- package/benchmark/stats/size-of.js +7 -3
- package/benchmark/stats/stats.d.ts +7 -0
- package/benchmark/summarizer/first-phase/process.js +2 -19
- package/benchmark/summarizer/second-phase/graph.js +13 -3
- package/benchmark/summarizer/second-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -0
- package/cli/common/options.js +1 -0
- package/cli/common/scripts-info.d.ts +5 -0
- package/cli/repl/commands/repl-dataflow.js +70 -27
- package/cli/repl/core.d.ts +1 -1
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +2 -1
- package/cli/repl/server/connection.d.ts +4 -0
- package/cli/repl/server/connection.js +19 -16
- package/cli/repl/server/messages/message-analysis.d.ts +1 -1
- package/config.d.ts +6 -0
- package/config.js +12 -9
- package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
- package/control-flow/basic-cfg-guided-visitor.js +37 -24
- package/control-flow/cfg-dead-code.js +44 -33
- package/control-flow/cfg-properties.js +2 -2
- package/control-flow/cfg-simplification.js +6 -5
- package/control-flow/cfg-to-basic-blocks.js +11 -13
- package/control-flow/control-flow-graph.d.ts +179 -189
- package/control-flow/control-flow-graph.js +400 -263
- package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
- package/control-flow/dfg-cfg-guided-visitor.js +17 -13
- package/control-flow/diff-cfg.js +6 -14
- package/control-flow/happens-before.js +5 -4
- package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
- package/control-flow/semantic-cfg-guided-visitor.js +6 -26
- package/control-flow/simple-visitor.js +14 -15
- package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
- package/control-flow/useless-loop.js +18 -14
- package/core/steps/all/core/20-dataflow.d.ts +1 -3
- package/core/steps/pipeline/default-pipelines.d.ts +141 -157
- package/dataflow/cluster.js +7 -0
- package/dataflow/environments/apply-kill.d.ts +6 -0
- package/dataflow/environments/apply-kill.js +64 -32
- package/dataflow/environments/built-in-props.d.ts +10 -2
- package/dataflow/environments/built-in-props.js +9 -1
- package/dataflow/environments/built-in.d.ts +6 -3
- package/dataflow/environments/built-in.js +8 -5
- package/dataflow/environments/clone.d.ts +3 -3
- package/dataflow/environments/clone.js +5 -5
- package/dataflow/environments/default-builtin-config.d.ts +188 -8
- package/dataflow/environments/default-builtin-config.js +112 -39
- package/dataflow/environments/environment.d.ts +9 -1
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/identifier.js +4 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +20 -0
- package/dataflow/environments/resolve-by-name.d.ts +7 -0
- package/dataflow/environments/resolve-by-name.js +26 -2
- package/dataflow/environments/resolve-helper.d.ts +3 -1
- package/dataflow/environments/resolve-helper.js +2 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
- package/dataflow/eval/resolve/alias-tracking.js +2 -2
- package/dataflow/eval/resolve/match-arguments.js +7 -5
- package/dataflow/eval/resolve/node-value.d.ts +3 -1
- package/dataflow/eval/resolve/node-value.js +12 -0
- package/dataflow/eval/resolve/resolve-argument.js +5 -4
- package/dataflow/eval/resolve/resolve-operators.js +10 -7
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +5 -5
- package/dataflow/eval/resolve/resolve.js +3 -2
- package/dataflow/eval/values/general.js +8 -5
- package/dataflow/extractor.d.ts +1 -4
- package/dataflow/extractor.js +11 -10
- package/dataflow/fn/exceptions-of-function.d.ts +6 -2
- package/dataflow/fn/exceptions-of-function.js +85 -38
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +339 -0
- package/dataflow/graph/call-graph.js +2 -2
- package/dataflow/graph/df-helper.d.ts +17 -2
- package/dataflow/graph/df-helper.js +19 -3
- package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +19 -2
- package/dataflow/graph/edge.d.ts +38 -2
- package/dataflow/graph/edge.js +32 -2
- package/dataflow/graph/graph.d.ts +32 -5
- package/dataflow/graph/graph.js +65 -4
- package/dataflow/graph/match-args.d.ts +69 -0
- package/dataflow/graph/match-args.js +167 -0
- package/dataflow/info.d.ts +40 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/control-flow.d.ts +102 -0
- package/dataflow/internal/control-flow.js +200 -0
- package/dataflow/internal/linker.d.ts +6 -31
- package/dataflow/internal/linker.js +24 -81
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +97 -33
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
- package/dataflow/internal/process/functions/call/common.js +5 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
- package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
- package/dataflow/internal/process/functions/call/nse.js +6 -1
- package/dataflow/internal/process/functions/call/quoted.js +2 -2
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
- package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/process-argument.js +12 -4
- package/dataflow/internal/process/functions/process-parameter.js +13 -0
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-named-call.js +9 -7
- package/documentation/data/server/doc-data-server-messages.js +4 -4
- package/documentation/doc-readme.js +45 -0
- package/documentation/doc-util/doc-cfg.d.ts +8 -7
- package/documentation/doc-util/doc-cfg.js +10 -10
- package/documentation/doc-util/doc-playground.d.ts +12 -0
- package/documentation/doc-util/doc-playground.js +21 -0
- package/documentation/doc-util/doc-query.d.ts +4 -1
- package/documentation/doc-util/doc-query.js +4 -2
- package/documentation/wiki-absint.d.ts +3 -4
- package/documentation/wiki-absint.js +12 -5
- package/documentation/wiki-analyzer.js +2 -2
- package/documentation/wiki-cfg.js +101 -106
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +85 -53
- package/documentation/wiki-linter.js +16 -1
- package/documentation/wiki-linting-and-testing.js +1 -16
- package/documentation/wiki-mk/doc-maker.js +6 -4
- package/documentation/wiki-query.js +67 -4
- package/documentation/wiki-signature-database.js +28 -2
- package/linter/linter-fix.d.ts +16 -0
- package/linter/linter-fix.js +104 -0
- package/linter/linter-format.d.ts +18 -1
- package/linter/linter-format.js +31 -1
- package/linter/linter-output.js +47 -11
- package/linter/linter-rules.d.ts +64 -9
- package/linter/linter-rules.js +5 -1
- package/linter/rules/absolute-path.js +4 -2
- package/linter/rules/dataframe-access-validation.js +6 -7
- package/linter/rules/deprecated-functions.d.ts +107 -10
- package/linter/rules/deprecated-functions.js +309 -23
- package/linter/rules/file-path-validity.js +5 -4
- package/linter/rules/function-finder-util.d.ts +6 -0
- package/linter/rules/function-finder-util.js +21 -13
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.js +6 -4
- package/linter/rules/undefined-symbol.js +2 -2
- package/linter/rules/unused-definition.js +8 -4
- package/linter/rules/unused-import.d.ts +60 -0
- package/linter/rules/unused-import.js +179 -0
- package/package.json +5 -8
- package/project/attached-packages.js +2 -1
- package/project/cache/flowr-analyzer-cache.d.ts +2 -5
- package/project/cache/flowr-analyzer-cache.js +4 -7
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
- package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
- package/project/cache/flowr-cache.d.ts +9 -0
- package/project/cache/flowr-cache.js +19 -0
- package/project/context/flowr-analyzer-context.d.ts +7 -3
- package/project/context/flowr-analyzer-context.js +15 -9
- package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
- package/project/context/flowr-analyzer-dependencies-context.js +9 -14
- package/project/context/flowr-analyzer-files-context.js +15 -17
- package/project/context/flowr-analyzer-meta-context.js +2 -12
- package/project/dependency-version-space.d.ts +3 -10
- package/project/dependency-version-space.js +10 -9
- package/project/flowr-analyzer.d.ts +4 -6
- package/project/flowr-analyzer.js +4 -5
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +23 -35
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
- package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.d.ts +2 -2
- package/project/sigdb/decode.d.ts +0 -5
- package/project/sigdb/decode.js +0 -8
- package/project/sigdb/index-format.d.ts +4 -4
- package/project/sigdb/manifest.d.ts +5 -3
- package/project/sigdb/manifest.js +50 -9
- package/project/sigdb/reader.d.ts +48 -13
- package/project/sigdb/reader.js +3 -2
- package/project/sigdb/schema.d.ts +5 -3
- package/project/sigdb/schema.js +2 -2
- package/project/sigdb/signature-db.d.ts +69 -0
- package/project/sigdb/signature-db.js +54 -0
- package/project/sigdb/signature-match.d.ts +10 -5
- package/project/sigdb/signature-match.js +13 -8
- package/queries/catalog/absint-query/absint-query-executor.js +1 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
- package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
- package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
- package/queries/catalog/dependencies-query/link-devices.js +2 -8
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/signature-query/signature-query-executor.js +4 -3
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
- package/reconstruct/inline/source-inline-map.js +3 -3
- package/reconstruct/reconstruct.js +6 -4
- package/search/flowr-search-builder.d.ts +8 -8
- package/search/flowr-search-builder.js +4 -4
- package/search/flowr-search-filters.d.ts +2 -2
- package/search/flowr-search-filters.js +4 -15
- package/search/search-executor/search-enrichers.d.ts +6 -4
- package/search/search-executor/search-enrichers.js +44 -5
- package/slicing/criterion/filters/all-variables.js +2 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +10 -8
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/util/arg-matching.d.ts +3 -0
- package/util/arg-matching.js +12 -1
- package/util/collections/arrays.d.ts +0 -4
- package/util/collections/arrays.js +4 -26
- package/util/diff-graph.d.ts +1 -1
- package/util/diff-graph.js +17 -3
- package/util/diff.d.ts +6 -0
- package/util/mermaid/ast.d.ts +1 -1
- package/util/mermaid/ast.js +5 -4
- package/util/mermaid/cfg.js +130 -24
- package/util/mermaid/dfg.js +31 -10
- package/util/mermaid/mermaid.js +2 -0
- package/util/objects.d.ts +21 -0
- package/util/objects.js +60 -0
- package/util/prefix.d.ts +1 -1
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/name-rank.d.ts +1 -1
- package/util/text/name-rank.js +1 -1
- package/util/text/playground-link.d.ts +131 -0
- package/util/text/playground-link.js +214 -0
- package/util/text/strings.js +7 -3
- package/util/version.js +1 -1
- package/control-flow/cfg-builder.d.ts +0 -30
- package/control-flow/cfg-builder.js +0 -79
- package/control-flow/extract-cfg.d.ts +0 -36
- package/control-flow/extract-cfg.js +0 -693
- package/project/cfg-kind.d.ts +0 -21
- package/project/cfg-kind.js +0 -26
package/util/diff-graph.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ interface EdgeIndexedGraph<EdgeMap> {
|
|
|
52
52
|
export declare const GraphDiff: {
|
|
53
53
|
readonly name: "GraphDiff";
|
|
54
54
|
/** Compares all edges of both graphs vertex by vertex, handing each pair to `diffEdges`. */
|
|
55
|
-
readonly outgoingEdges: <EdgeMap, Graph extends EdgeIndexedGraph<EdgeMap>>(this: void, ctx: GraphDiffContext<Graph>, diffEdges: (ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: EdgeMap | undefined, rEdges: EdgeMap | undefined) => void) => void;
|
|
55
|
+
readonly outgoingEdges: <EdgeMap, Graph extends EdgeIndexedGraph<EdgeMap>>(this: void, ctx: GraphDiffContext<Graph>, diffEdges: (ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: EdgeMap | undefined, rEdges: EdgeMap | undefined) => void, project?: (edges: EdgeMap) => EdgeMap | undefined) => void;
|
|
56
56
|
/** Compares the outgoing edges of a single vertex, handing each pair of edges to `diffEdge`. */
|
|
57
57
|
readonly edges: <Edge, Graph>(this: void, ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: ReadonlyMap<NodeId, Edge> | undefined, rEdges: ReadonlyMap<NodeId, Edge> | undefined, diffEdge: (edge: Edge, otherEdge: Edge, ctx: GraphDiffContext<Graph>, id: NodeId, target: NodeId) => void) => void;
|
|
58
58
|
};
|
package/util/diff-graph.js
CHANGED
|
@@ -58,13 +58,27 @@ function initDiffContext(left, right, config) {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Index the edges of a graph, optionally narrowing every entry to the part the comparison cares about.
|
|
63
|
+
* Sources whose edges the projection drops entirely do not take part in the comparison.
|
|
64
|
+
*/
|
|
65
|
+
function collectEdges(graph, project) {
|
|
66
|
+
const result = new Map();
|
|
67
|
+
for (const [id, edges] of graph.edges()) {
|
|
68
|
+
const projected = project ? project(edges) : edges;
|
|
69
|
+
if (projected !== undefined) {
|
|
70
|
+
result.set(id, projected);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
61
75
|
/** The edge-differencing steps shared by the dataflow and the control flow graph diff. */
|
|
62
76
|
exports.GraphDiff = {
|
|
63
77
|
name: 'GraphDiff',
|
|
64
78
|
/** Compares all edges of both graphs vertex by vertex, handing each pair to `diffEdges`. */
|
|
65
|
-
outgoingEdges(ctx, diffEdges) {
|
|
66
|
-
const lEdges =
|
|
67
|
-
const rEdges =
|
|
79
|
+
outgoingEdges(ctx, diffEdges, project) {
|
|
80
|
+
const lEdges = collectEdges(ctx.left, project);
|
|
81
|
+
const rEdges = collectEdges(ctx.right, project);
|
|
68
82
|
if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph || lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
|
|
69
83
|
ctx.report.addComment(`Detected different number of edges! ${ctx.leftname} has ${lEdges.size} (${JSON.stringify(lEdges, json_1.jsonReplacer)}). ${ctx.rightname} has ${rEdges.size} ${JSON.stringify(rEdges, json_1.jsonReplacer)}`);
|
|
70
84
|
}
|
package/util/diff.d.ts
CHANGED
|
@@ -50,6 +50,12 @@ export interface GenericDiffConfiguration {
|
|
|
50
50
|
* Similar to {@link rightIsSubgraph}, but for the left/first graph.
|
|
51
51
|
*/
|
|
52
52
|
readonly leftIsSubgraph?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Compare the control flow a dataflow graph carries as well.
|
|
55
|
+
* Off by default: the control flow is compared through the control flow graph, so a dataflow comparison
|
|
56
|
+
* that included it would only be repeating that check on a less readable representation.
|
|
57
|
+
*/
|
|
58
|
+
readonly compareControlFlow?: boolean;
|
|
53
59
|
}
|
|
54
60
|
/**
|
|
55
61
|
* Computes the difference of two sets and adds human-readable information to the current report
|
package/util/mermaid/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
|
-
import
|
|
2
|
+
import { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
|
|
3
3
|
import type { MermaidGraphPrinterInfo } from './info';
|
|
4
4
|
/**
|
|
5
5
|
* Serialize the normalized AST to mermaid format
|
package/util/mermaid/ast.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizedAstToMermaid = normalizedAstToMermaid;
|
|
4
4
|
exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
|
|
5
|
-
const
|
|
6
|
-
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
+
const r_project_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-project");
|
|
7
6
|
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
8
7
|
const info_1 = require("./info");
|
|
9
8
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
10
9
|
const mermaid_1 = require("./mermaid");
|
|
10
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
11
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
12
|
function identifyMermaidDirection(prefix) {
|
|
12
13
|
const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
|
|
13
14
|
if (directionMatch) {
|
|
@@ -34,7 +35,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
34
35
|
const roleSuffix = context.role === "el-c" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
|
|
35
36
|
output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
|
|
36
37
|
}
|
|
37
|
-
if (
|
|
38
|
+
if (r_expression_list_1.RExpressionList.is(n) && n.grouping !== undefined) {
|
|
38
39
|
output += ` n${n.info.id} -.-|"group-open"| n${n.grouping[0].info.id}\n`;
|
|
39
40
|
output += ` n${n.info.id} -.-|"group-close"| n${n.grouping[1].info.id}\n`;
|
|
40
41
|
}
|
|
@@ -52,7 +53,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
|
|
|
52
53
|
return false;
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
if (
|
|
56
|
+
if (r_project_1.RProject.is(ast)) {
|
|
56
57
|
for (const f of ast.files) {
|
|
57
58
|
// add a subgraph for each file
|
|
58
59
|
if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
|
package/util/mermaid/cfg.js
CHANGED
|
@@ -9,6 +9,8 @@ const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-selec
|
|
|
9
9
|
const info_1 = require("./info");
|
|
10
10
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
11
11
|
const mermaid_1 = require("./mermaid");
|
|
12
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
13
|
+
const convert_values_1 = require("../../r-bridge/lang-4.x/convert-values");
|
|
12
14
|
exports.MermaidEntryPointDefaultMarkStyle = 'stroke:cyan,stroke-width:6.5px;';
|
|
13
15
|
exports.MermaidExitPointDefaultMarkStyle = 'stroke:green,stroke-width:6.5px;';
|
|
14
16
|
function getLexeme(n) {
|
|
@@ -18,28 +20,107 @@ function cfgOfNode(vert, normalizedVertex, id, content, output) {
|
|
|
18
20
|
if (normalizedVertex && content !== undefined) {
|
|
19
21
|
const start = control_flow_graph_1.CfgVertex.isExpression(vert) ? '([' : '[';
|
|
20
22
|
const end = control_flow_graph_1.CfgVertex.isExpression(vert) ? '])' : ']';
|
|
21
|
-
|
|
23
|
+
/* the code is set in bold so it stands out from the type and id above it */
|
|
24
|
+
const code = content ? `\n**${mermaid_1.Mermaid.escape(content.replaceAll(/\s+/gu, ' '))}**` : '';
|
|
25
|
+
const calls = control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : '';
|
|
26
|
+
const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${code}${calls}\`"`;
|
|
22
27
|
output += ` n${id}${start}${name}${end}\n`;
|
|
23
28
|
}
|
|
24
29
|
else {
|
|
25
|
-
output +=
|
|
30
|
+
output += ` n${id}[[${id}]]\n`;
|
|
26
31
|
}
|
|
27
32
|
return output;
|
|
28
33
|
}
|
|
29
34
|
const getDirRegex = /flowchart\s+([A-Za-z]+)/;
|
|
35
|
+
/**
|
|
36
|
+
* The vertices that make up each function body, keyed by the definition that holds it.
|
|
37
|
+
* Nothing flows into such a region, so it is reachable only from the entry the definition points at.
|
|
38
|
+
*/
|
|
39
|
+
function collectBodies(graph) {
|
|
40
|
+
const bodies = new Map();
|
|
41
|
+
for (const [id] of graph.vertices(false)) {
|
|
42
|
+
const children = graph.childrenOf(id);
|
|
43
|
+
if (children === undefined || children.length === 0) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const body = new Set();
|
|
47
|
+
const stack = [...children];
|
|
48
|
+
while (stack.length > 0) {
|
|
49
|
+
const current = stack.pop();
|
|
50
|
+
if (body.has(current)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
body.add(current);
|
|
54
|
+
for (const next of graph.successors(current)) {
|
|
55
|
+
stack.push(next);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
bodies.set(id, [...body]);
|
|
59
|
+
}
|
|
60
|
+
return bodies;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The region a vertex belongs to: the function definition it is part of and whether it sits in its parameter list.
|
|
64
|
+
* A definition itself belongs to the region it is written in, not to the one it opens.
|
|
65
|
+
*/
|
|
66
|
+
function regionOf(id, normalizedAst) {
|
|
67
|
+
let current = normalizedAst.idMap.get(id);
|
|
68
|
+
current = current?.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
|
|
69
|
+
let inParameters = false;
|
|
70
|
+
while (current !== undefined) {
|
|
71
|
+
inParameters ||= current.info.role === "param" /* RoleInParent.FunctionDefinitionParameter */;
|
|
72
|
+
if (r_function_definition_1.RFunctionDefinition.is(current)) {
|
|
73
|
+
return `${current.info.id}-${inParameters ? 'parameters' : 'body'}`;
|
|
74
|
+
}
|
|
75
|
+
current = current.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
|
|
76
|
+
}
|
|
77
|
+
return 'top-level';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The code a simplified basic block stands for.
|
|
81
|
+
* Its elements are reconstructed per region, so the parameters of a function do not end up looking like its body,
|
|
82
|
+
* and a run that reconstructs to nothing but braces is named by its vertices instead.
|
|
83
|
+
*/
|
|
84
|
+
function blockCode(elems, normalizedAst) {
|
|
85
|
+
const runs = [];
|
|
86
|
+
let lastRegion = undefined;
|
|
87
|
+
for (const elem of elems) {
|
|
88
|
+
const region = regionOf(control_flow_graph_1.CfgVertex.getId(elem), normalizedAst);
|
|
89
|
+
if (region !== lastRegion) {
|
|
90
|
+
runs.push([]);
|
|
91
|
+
lastRegion = region;
|
|
92
|
+
}
|
|
93
|
+
runs[runs.length - 1].push(elem);
|
|
94
|
+
}
|
|
95
|
+
return runs.map(run => {
|
|
96
|
+
const code = (0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(run.map(control_flow_graph_1.CfgVertex.getId)) }, auto_select_defaults_1.doNotAutoSelect).code;
|
|
97
|
+
if (/[\p{L}\p{N}]/u.test(code)) {
|
|
98
|
+
return code;
|
|
99
|
+
}
|
|
100
|
+
/* nothing but braces means these vertices are where a structure is over, so we name them as the graph does */
|
|
101
|
+
return run.map(elem => `${normalizedAst.idMap.get(control_flow_graph_1.CfgVertex.getId(elem))?.type} (${control_flow_graph_1.CfgVertex.getId(elem)})`).join('\n');
|
|
102
|
+
}).join('\n');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Name the condition a branch is decided by, which is where the branch starts from.
|
|
106
|
+
* Within a basic block that is its last element, so an edge still tells what triggers it.
|
|
107
|
+
*/
|
|
108
|
+
function conditionName(cfg, normalizedAst, from) {
|
|
109
|
+
const vertex = cfg.graph.getVertex(from);
|
|
110
|
+
const condition = control_flow_graph_1.CfgVertex.isBlock(vertex) ? control_flow_graph_1.CfgVertex.getId(control_flow_graph_1.CfgVertex.getBasicBlockElements(vertex).at(-1)) ?? from : from;
|
|
111
|
+
const lexeme = getLexeme(normalizedAst.idMap.get(condition));
|
|
112
|
+
return lexeme ? `${lexeme} (${condition})` : String(condition);
|
|
113
|
+
}
|
|
30
114
|
function shouldIncludeNode(simplify, v, include) {
|
|
31
115
|
if (simplify) {
|
|
32
116
|
// Only basic blocks are shown, so include the BB, if at least one child is selected
|
|
33
117
|
return control_flow_graph_1.CfgVertex.isBlock(v) && control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
|
|
34
|
-
.filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
|
|
35
118
|
.some(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)));
|
|
36
119
|
}
|
|
37
120
|
else {
|
|
38
121
|
// Basic blocks and vertices are shown, include the BB, if all children are highlighted
|
|
39
122
|
return control_flow_graph_1.CfgVertex.isBlock(v)
|
|
40
|
-
? control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
|
|
41
|
-
.filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
|
|
42
|
-
.every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
|
|
123
|
+
? control_flow_graph_1.CfgVertex.getBasicBlockElements(v).every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
|
|
43
124
|
: include.has(control_flow_graph_1.CfgVertex.getId(v));
|
|
44
125
|
}
|
|
45
126
|
}
|
|
@@ -47,7 +128,7 @@ function shouldIncludeNode(simplify, v, include) {
|
|
|
47
128
|
* Convert the control flow graph to a mermaid string.
|
|
48
129
|
* @see {@link MermaidCfgGraphPrinterInfo} for additional options.
|
|
49
130
|
*/
|
|
50
|
-
function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart
|
|
131
|
+
function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart TD\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
|
|
51
132
|
const hasBbandSimplify = simplify && cfg.graph.mayHaveBasicBlocks();
|
|
52
133
|
let output = prefix;
|
|
53
134
|
if (includeOnlyIds) {
|
|
@@ -62,16 +143,33 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
62
143
|
completed.add(childId);
|
|
63
144
|
}
|
|
64
145
|
}
|
|
65
|
-
// if we have a filter, we automatically add all vertices in the cfg that are *markers* for these ids and
|
|
66
|
-
for (const [id, v] of cfg.graph.vertices()) {
|
|
67
|
-
if (control_flow_graph_1.CfgVertex.isMarker(v) && completed.has(control_flow_graph_1.CfgVertex.unpackRootId(v))) {
|
|
68
|
-
completed.add(id);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
146
|
includeOnlyIds = completed;
|
|
72
147
|
}
|
|
73
148
|
const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
|
|
74
149
|
const diagramIncludedIds = new Set();
|
|
150
|
+
/* a function body runs when the function is called, so it is drawn as a region of its own instead of floating free */
|
|
151
|
+
const bodies = cfg.graph.mayHaveBasicBlocks() ? new Map() : collectBodies(cfg.graph);
|
|
152
|
+
const partOfBody = new Set(bodies.values().flatMap(body => body));
|
|
153
|
+
const emitBody = (defId) => {
|
|
154
|
+
const body = bodies.get(defId)?.filter(v => !includeOnlyIds || includeOnlyIds.has(v));
|
|
155
|
+
if (body === undefined || body.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const definition = normalizedAst.idMap.get(defId);
|
|
159
|
+
output += ` subgraph n${defId}-body ["body of ${mermaid_1.Mermaid.escape(limitTo(getLexeme(definition) ?? String(defId), 40))}"]\n`;
|
|
160
|
+
output += ` direction ${dirIs}\n`;
|
|
161
|
+
for (const vertexId of body) {
|
|
162
|
+
const vertex = cfg.graph.getVertex(vertexId);
|
|
163
|
+
if (vertex === undefined || control_flow_graph_1.CfgVertex.isBlock(vertex)) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const node = normalizedAst.idMap.get(vertexId);
|
|
167
|
+
output = cfgOfNode(vertex, node, vertexId, getLexeme(node), output);
|
|
168
|
+
diagramIncludedIds.add(vertexId);
|
|
169
|
+
emitBody(vertexId);
|
|
170
|
+
}
|
|
171
|
+
output += ' end\n';
|
|
172
|
+
};
|
|
75
173
|
for (const [id, vertex] of cfg.graph.vertices(false)) {
|
|
76
174
|
const normalizedVertex = normalizedAst?.idMap.get(id);
|
|
77
175
|
const content = getLexeme(normalizedVertex);
|
|
@@ -81,9 +179,8 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
81
179
|
if (includeOnlyIds && !elems.some(elem => includeOnlyIds.has(control_flow_graph_1.CfgVertex.getId(elem)))) {
|
|
82
180
|
continue;
|
|
83
181
|
}
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(reconstruct)}\`"`;
|
|
182
|
+
const code = limitTo(blockCode(elems, normalizedAst), basicBlockCharacterLimit);
|
|
183
|
+
const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(code)}\`"`;
|
|
87
184
|
output += ` n${id}[[${name}]]\n`;
|
|
88
185
|
diagramIncludedIds.add(control_flow_graph_1.CfgVertex.getId(vertex));
|
|
89
186
|
}
|
|
@@ -103,20 +200,21 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
103
200
|
const eid = control_flow_graph_1.CfgVertex.getId(element);
|
|
104
201
|
const childNormalizedVertex = normalizedAst?.idMap.get(eid);
|
|
105
202
|
const childContent = getLexeme(childNormalizedVertex);
|
|
106
|
-
output = cfgOfNode(
|
|
203
|
+
output = cfgOfNode(element, childNormalizedVertex, eid, childContent, output);
|
|
107
204
|
diagramIncludedIds.add(eid);
|
|
108
|
-
|
|
205
|
+
/* everything in a block runs one after the other, which is what these arrows show */
|
|
109
206
|
if (last) {
|
|
110
|
-
output += ` ${last}
|
|
207
|
+
output += ` ${last} --> n${eid}\n`;
|
|
111
208
|
}
|
|
112
209
|
last = `n${eid}`;
|
|
113
210
|
}
|
|
114
211
|
output += ' end\n';
|
|
115
212
|
}
|
|
116
213
|
}
|
|
117
|
-
else if (!includeOnlyIds || includeOnlyIds.has(id)) {
|
|
214
|
+
else if ((!includeOnlyIds || includeOnlyIds.has(id)) && !partOfBody.has(id)) {
|
|
118
215
|
output = cfgOfNode(vertex, normalizedVertex, id, content, output);
|
|
119
216
|
diagramIncludedIds.add(id);
|
|
217
|
+
emitBody(id);
|
|
120
218
|
}
|
|
121
219
|
}
|
|
122
220
|
for (const [from, targets] of cfg.graph.edges()) {
|
|
@@ -127,10 +225,18 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
|
|
|
127
225
|
if (!diagramIncludedIds.has(to)) {
|
|
128
226
|
continue;
|
|
129
227
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
228
|
+
/* a branch is drawn dashed, so what always runs stands out from what only runs under a condition */
|
|
229
|
+
const isBranch = control_flow_graph_1.CfgEdge.isControlDependency(edge);
|
|
230
|
+
const arrow = isBranch ? '-.->' : '-->';
|
|
231
|
+
const label = isBranch ? `branch on ${conditionName(cfg, normalizedAst, from)} if ${control_flow_graph_1.CfgEdge.unpackWhen(edge) === convert_values_1.RTrue ? 'T' : 'F'}` : control_flow_graph_1.CfgEdge.typeToString(edge);
|
|
232
|
+
output += ` n${from} ${arrow}|"${mermaid_1.Mermaid.escape(label)}"| n${to}\n`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
for (const [defId] of bodies) {
|
|
236
|
+
const entry = cfg.graph.childrenOf(defId)?.[0];
|
|
237
|
+
/* no arrow head: the definition does not run its body, it only holds it */
|
|
238
|
+
if (entry !== undefined && diagramIncludedIds.has(defId) && diagramIncludedIds.has(entry)) {
|
|
239
|
+
output += ` n${defId} -. holds .- n${entry}\n`;
|
|
134
240
|
}
|
|
135
241
|
}
|
|
136
242
|
for (const entryPoint of cfg.entryPoints) {
|
package/util/mermaid/dfg.js
CHANGED
|
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
12
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
13
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
14
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
15
|
-
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
15
|
const info_1 = require("./info");
|
|
17
16
|
const range_1 = require("../range");
|
|
18
17
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
19
18
|
const info_2 = require("../../dataflow/info");
|
|
20
19
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
20
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
21
21
|
function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
|
|
22
22
|
if (subflow === undefined) {
|
|
23
23
|
return;
|
|
@@ -181,7 +181,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
const node = mermaid.rootGraph.idMap?.get(info.id);
|
|
184
|
-
const lexeme = node?.lexeme ?? (
|
|
184
|
+
const lexeme = node?.lexeme ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0]?.lexeme : '') ?? '??';
|
|
185
185
|
let display = lexeme;
|
|
186
186
|
if (fCall && vertex_1.FunctionCallVertex.is(info)) {
|
|
187
187
|
const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
|
|
@@ -201,7 +201,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
201
201
|
const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
|
|
202
202
|
const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
|
|
203
203
|
const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
|
|
204
|
-
const n = node?.info.fullRange ?? node?.location ?? (
|
|
204
|
+
const n = node?.info.fullRange ?? node?.location ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0].location : undefined);
|
|
205
205
|
mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
|
|
206
206
|
}
|
|
207
207
|
if (mark?.has(id)) {
|
|
@@ -218,25 +218,35 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
218
218
|
mermaid.nodeLines.push(' %% No edges found for ' + id);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']), file: x.file }]);
|
|
222
221
|
// eslint-disable-next-line prefer-const
|
|
223
|
-
for (let [target, edge] of
|
|
222
|
+
for (let [target, edge] of edges) {
|
|
224
223
|
if (includeOnlyIds && !includeOnlyIds.has(target)) {
|
|
225
224
|
continue;
|
|
226
225
|
}
|
|
227
226
|
const originalTarget = target;
|
|
228
227
|
target = mermaid_1.Mermaid.escapeId(target);
|
|
229
228
|
const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
|
|
229
|
+
const carriesControlFlow = edgeTypes.has(edge_1.EdgeType.FlowEdge) || edgeTypes.has(edge_1.EdgeType.ControlEdge);
|
|
230
|
+
/* an edge that carries dataflow as well stays a dataflow edge, it just says the control flow goes there too */
|
|
231
|
+
const onlyControlFlow = carriesControlFlow && ![...edgeTypes].some(t => typeof t === 'number' && (t & ~edge_1.ControlFlowEdgeTypes) !== 0);
|
|
232
|
+
if (mermaid.simplified && onlyControlFlow) {
|
|
233
|
+
/* a simplified view is about the dataflow, and the control flow is a graph of its own */
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
230
236
|
const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
|
|
231
237
|
if (!mermaid.presentEdges.has(edgeId)) {
|
|
232
238
|
mermaid.presentEdges.add(edgeId);
|
|
233
|
-
const style = node_id_1.NodeId.isBuiltIn(target) ? '-.->' : '-->';
|
|
234
|
-
|
|
239
|
+
const style = node_id_1.NodeId.isBuiltIn(target) || onlyControlFlow ? '-.->' : '-->';
|
|
240
|
+
const names = [...edgeTypes].map(e => typeof e === 'number' ? edgeName(e) : e).join(', ');
|
|
241
|
+
const cd = edgeTypes.has(edge_1.EdgeType.ControlEdge) ? edge.cd : undefined;
|
|
242
|
+
const when = cd === undefined ? '' : ` (when: ${cd.when ?? 'any'})`;
|
|
243
|
+
const assumedFile = cd?.file ? `, from: ${mermaid_1.Mermaid.escape(cd.file)}` : '';
|
|
244
|
+
mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${names}${when}${assumedFile}"| ${idPrefix}${target}`);
|
|
235
245
|
if (mermaid.mark?.has(id + '->' + target)) {
|
|
236
246
|
// who invented this syntax?!
|
|
237
247
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
|
|
238
248
|
}
|
|
239
|
-
if (
|
|
249
|
+
if (onlyControlFlow) {
|
|
240
250
|
mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray,color:gray;`);
|
|
241
251
|
}
|
|
242
252
|
if (node_id_1.NodeId.isBuiltIn(target)) {
|
|
@@ -250,8 +260,19 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
|
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
262
|
}
|
|
263
|
+
/** control flow edges are drawn all over the graph, so they get a short name to save space */
|
|
264
|
+
function edgeName(type) {
|
|
265
|
+
switch (type) {
|
|
266
|
+
case edge_1.EdgeType.FlowEdge:
|
|
267
|
+
return 'flow';
|
|
268
|
+
case edge_1.EdgeType.ControlEdge:
|
|
269
|
+
return 'branch';
|
|
270
|
+
default:
|
|
271
|
+
return edge_1.DfEdge.typeToName(type);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
253
274
|
// make the passing of root ids more performant again
|
|
254
|
-
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart
|
|
275
|
+
function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
|
|
255
276
|
const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
|
|
256
277
|
for (const [id, info] of graph.vertices(true)) {
|
|
257
278
|
if (rootIds.has(id)) {
|
|
@@ -265,7 +286,7 @@ function diffGraphsToMermaid(left, right, prefix) {
|
|
|
265
286
|
// we add the prefix ourselves
|
|
266
287
|
const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
|
|
267
288
|
const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
|
|
268
|
-
return `${prefix}flowchart
|
|
289
|
+
return `${prefix}flowchart TD\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
|
|
269
290
|
}
|
|
270
291
|
/**
|
|
271
292
|
* Converts two dataflow graphs to a mermaid url that visualizes their differences.
|
package/util/mermaid/mermaid.js
CHANGED
|
@@ -68,6 +68,8 @@ exports.Mermaid = {
|
|
|
68
68
|
*/
|
|
69
69
|
escapeId(text) {
|
|
70
70
|
text = String(text).replace(/[^a-zA-Z0-9:\-./]/g, '_');
|
|
71
|
+
/* a dash before a dash or a dot reads as the start of a link, e.g. the id of `$<-.grouped_df` would cut the line in two */
|
|
72
|
+
text = text.replace(/-(?=[-.])/g, '_');
|
|
71
73
|
return text.replace(/(^|[:\-./])([a-zA-Z0-9_]+)/g, (_m, sep, tok) => sep + (exports.Mermaid.reservedIds.has(tok) ? tok + '_' : tok));
|
|
72
74
|
},
|
|
73
75
|
/**
|
package/util/objects.d.ts
CHANGED
|
@@ -58,4 +58,25 @@ export declare function deepClonePreserveUnclonable<T>(obj: T): T;
|
|
|
58
58
|
* @param logger - The logger to use for trace debugging.
|
|
59
59
|
*/
|
|
60
60
|
export declare function looselyCompareObjects(obj: Record<string, unknown>, expected: Record<string, unknown>, arrayMatch?: 'some' | 'every', logger?: Logger<ILogObj>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
|
|
63
|
+
* or `undefined` if any segment along the way is missing.
|
|
64
|
+
* @see {@link setOnPath} for the counterpart that writes such a path
|
|
65
|
+
*/
|
|
66
|
+
export declare function getOnPath(obj: unknown, path: string): unknown;
|
|
67
|
+
/**
|
|
68
|
+
* Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
|
|
69
|
+
* An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
|
|
70
|
+
* @see {@link getOnPath} for the counterpart that reads such a path
|
|
71
|
+
*/
|
|
72
|
+
export declare function setOnPath(obj: object, path: string, value: unknown): void;
|
|
73
|
+
/**
|
|
74
|
+
* The members of an enum as name-value pairs.
|
|
75
|
+
* A numeric enum maps its values back to their names as well, which this leaves out.
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function enumMembers<T extends object>(enumObject: T): [name: string, value: T[keyof T]][];
|
|
61
82
|
export {};
|
package/util/objects.js
CHANGED
|
@@ -7,6 +7,10 @@ exports.deepMergeObjectInPlace = deepMergeObjectInPlace;
|
|
|
7
7
|
exports.compactRecord = compactRecord;
|
|
8
8
|
exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
|
|
9
9
|
exports.looselyCompareObjects = looselyCompareObjects;
|
|
10
|
+
exports.getOnPath = getOnPath;
|
|
11
|
+
exports.setOnPath = setOnPath;
|
|
12
|
+
exports.enumMembers = enumMembers;
|
|
13
|
+
const assert_1 = require("./assert");
|
|
10
14
|
const json_1 = require("./json");
|
|
11
15
|
const log_1 = require("./log");
|
|
12
16
|
/**
|
|
@@ -194,4 +198,60 @@ function looselyCompareObjects(obj, expected, arrayMatch, logger) {
|
|
|
194
198
|
(0, log_1.expensiveTrace)(logger, () => `Object ${JSON.stringify(obj)} matches ${JSON.stringify(expected)}`);
|
|
195
199
|
return true;
|
|
196
200
|
}
|
|
201
|
+
/** Segments that would let a dotted path reach into the prototype chain. */
|
|
202
|
+
const magicPathSegments = new Set(['__proto__', 'prototype', 'constructor']);
|
|
203
|
+
/**
|
|
204
|
+
* Splits a dot-separated path into its segments, turning integral segments into numbers
|
|
205
|
+
* so that `a.0.b` indexes an array rather than an object with the key `'0'`.
|
|
206
|
+
*/
|
|
207
|
+
function pathSegments(path) {
|
|
208
|
+
return path.split('.').map(segment => {
|
|
209
|
+
(0, assert_1.guard)(!magicPathSegments.has(segment), () => `refusing to walk the magic property '${segment}' in path '${path}'`);
|
|
210
|
+
const asInt = parseInt(segment);
|
|
211
|
+
return String(asInt) === segment ? asInt : segment;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
|
|
216
|
+
* or `undefined` if any segment along the way is missing.
|
|
217
|
+
* @see {@link setOnPath} for the counterpart that writes such a path
|
|
218
|
+
*/
|
|
219
|
+
function getOnPath(obj, path) {
|
|
220
|
+
let at = obj;
|
|
221
|
+
for (const segment of pathSegments(path)) {
|
|
222
|
+
if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, segment)) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
at = at[segment];
|
|
226
|
+
}
|
|
227
|
+
return at;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
|
|
231
|
+
* An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
|
|
232
|
+
* @see {@link getOnPath} for the counterpart that reads such a path
|
|
233
|
+
*/
|
|
234
|
+
function setOnPath(obj, path, value) {
|
|
235
|
+
const segments = pathSegments(path);
|
|
236
|
+
let at = obj;
|
|
237
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
238
|
+
const segment = segments[i];
|
|
239
|
+
if (at[segment] === undefined) {
|
|
240
|
+
at[segment] = typeof segments[i + 1] === 'number' ? [] : {};
|
|
241
|
+
}
|
|
242
|
+
at = at[segment];
|
|
243
|
+
}
|
|
244
|
+
at[segments[segments.length - 1]] = value;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The members of an enum as name-value pairs.
|
|
248
|
+
* A numeric enum maps its values back to their names as well, which this leaves out.
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
function enumMembers(enumObject) {
|
|
255
|
+
return Object.entries(enumObject).filter(([name]) => Number.isNaN(Number(name)));
|
|
256
|
+
}
|
|
197
257
|
//# sourceMappingURL=objects.js.map
|
package/util/prefix.d.ts
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export declare function findByPrefixIfUnique(prefix: string, keys:
|
|
16
|
+
export declare function findByPrefixIfUnique(prefix: string, keys: Iterable<string>): string | undefined;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dfgToAscii = dfgToAscii;
|
|
4
|
-
const dagre_1 = require("dagre");
|
|
5
4
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
6
5
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
7
6
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
7
|
+
let dagreModule;
|
|
8
|
+
/* type-only import above, `dagre` is optional: the ascii layout is a side feature, so the package is resolved at call time */
|
|
9
|
+
function dagre() {
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- loaded on demand, see above
|
|
12
|
+
return dagreModule ??= require('dagre');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('the optional dependency `dagre` is required to render a dataflow graph as ascii, install it with `npm i dagre`');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
function combineAscii(has, add) {
|
|
9
19
|
if (has === ' ' || has === add) {
|
|
10
20
|
return add;
|
|
@@ -72,7 +82,8 @@ class AsciiCanvas {
|
|
|
72
82
|
* Converts the given dataflow graph to an ASCII representation.
|
|
73
83
|
*/
|
|
74
84
|
function dfgToAscii(dfg) {
|
|
75
|
-
const
|
|
85
|
+
const { graphlib: dagreGraphlib, layout } = dagre();
|
|
86
|
+
const g = new dagreGraphlib.Graph();
|
|
76
87
|
const verts = Array.from(dfg.vertices(true));
|
|
77
88
|
g.setGraph({
|
|
78
89
|
nodesep: 1,
|
|
@@ -106,7 +117,7 @@ function dfgToAscii(dfg) {
|
|
|
106
117
|
edgesDone.add(`${from}-${to}`);
|
|
107
118
|
}
|
|
108
119
|
}
|
|
109
|
-
|
|
120
|
+
layout(g, {
|
|
110
121
|
minlen: 2
|
|
111
122
|
});
|
|
112
123
|
const canvas = new AsciiCanvas();
|
package/util/text/name-rank.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a reader most likely meant when typing a name: a well-used package first, base R ahead of CRAN, and
|
|
3
|
-
* the things one rarely reaches for last, which are S3 methods, `%operators
|
|
3
|
+
* the things one rarely reaches for last, which are S3 methods, `%operators%`, and names starting with a dot.
|
|
4
4
|
*
|
|
5
5
|
* The signature browser and the playground's completion both offer names out of the same database, so they
|
|
6
6
|
* order them with the same {@link rankName}, and what one of them learns the other one knows.
|
package/util/text/name-rank.js
CHANGED
|
@@ -22,7 +22,7 @@ const Adjustments = [
|
|
|
22
22
|
offer `ggplot` before `plotH`, because one of them is a function people actually call */
|
|
23
23
|
[500, ({ known }) => known === true],
|
|
24
24
|
[-30, ({ s3 }) => s3 === true],
|
|
25
|
-
/* operators, punctuation and SHOUTING names are rarely what someone is looking for */
|
|
25
|
+
/* operators, punctuation, and SHOUTING names are rarely what someone is looking for */
|
|
26
26
|
[-60, ({ name }) => /^%.*%$/.test(name) || /^[^\w.]/.test(name)],
|
|
27
27
|
[-30, ({ name, needle }) => name === name.toUpperCase() && /[A-Z]/.test(name) && name !== needle],
|
|
28
28
|
[-400, ({ name }) => name.startsWith('.')]
|