@eagleoutice/flowr 2.14.1 → 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 +154 -87
- 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 +11 -6
- package/benchmark/calibration.js +19 -8
- package/benchmark/slicer.d.ts +7 -1
- package/benchmark/slicer.js +38 -34
- 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/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/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 +8 -4
- 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 +63 -31
- package/dataflow/environments/built-in-props.d.ts +5 -1
- package/dataflow/environments/built-in-props.js +4 -0
- 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 +112 -7
- package/dataflow/environments/default-builtin-config.js +82 -34
- package/dataflow/environments/environment.d.ts +5 -5
- package/dataflow/environments/environment.js +5 -5
- package/dataflow/environments/identifier.d.ts +11 -1
- package/dataflow/environments/identifier.js +4 -1
- package/dataflow/environments/resolve-by-name.d.ts +7 -0
- package/dataflow/environments/resolve-by-name.js +12 -0
- 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 +9 -6
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +4 -3
- 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 +3 -1
- package/dataflow/fn/strict-function.js +7 -5
- package/dataflow/graph/call-graph.js +2 -2
- package/dataflow/graph/df-helper.d.ts +8 -1
- 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 +4 -3
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/graph/match-args.d.ts +69 -0
- package/dataflow/graph/match-args.js +167 -0
- package/dataflow/info.d.ts +14 -0
- 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 +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -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 +14 -11
- 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/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-dataflow-graph.js +84 -53
- package/documentation/wiki-linter.js +15 -1
- package/documentation/wiki-linting-and-testing.js +1 -16
- package/documentation/wiki-mk/doc-maker.js +6 -4
- package/documentation/wiki-query.js +14 -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 +46 -10
- package/linter/linter-rules.d.ts +40 -9
- package/linter/linter-rules.js +2 -0
- 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 +2 -2
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/unclosed-connection.js +2 -2
- 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 +2 -2
- 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 +0 -7
- package/project/dependency-version-space.js +8 -7
- package/project/flowr-analyzer.d.ts +4 -6
- package/project/flowr-analyzer.js +4 -5
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
- 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/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 +2 -2
- package/project/sigdb/reader.d.ts +48 -13
- package/project/sigdb/reader.js +2 -1
- package/project/sigdb/schema.d.ts +3 -1
- 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/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-format.d.ts +2 -2
- package/queries/catalog/signature-query/signature-query-executor.js +4 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- 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 +3 -2
- 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.js +8 -6
- 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 +9 -0
- package/util/objects.js +12 -0
- package/util/prefix.d.ts +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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type PotentiallyEmptyRArgument, type RFunctionCall } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
|
+
import type { RArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
3
|
+
import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
|
|
4
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
+
import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
6
|
+
import { type DataflowGraph, FunctionArgument } from './graph';
|
|
7
|
+
import type { SigParameter } from '../../project/sigdb/decode';
|
|
8
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
9
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
10
|
+
/**
|
|
11
|
+
* R's argument matching, as {@link matchArgumentsToParameters} implements it. Pick by what you hold:
|
|
12
|
+
*
|
|
13
|
+
* - {@link MatchArgs.toNames|toNames} - AST arguments and the formal names
|
|
14
|
+
* - {@link MatchArgs.toSpec|toSpec} - graph arguments and the formals (a spec or a database signature)
|
|
15
|
+
* - {@link MatchArgs.onCallAndLink|onCallAndLink} - as `toSpec`, and **adds the argument edges to the graph**
|
|
16
|
+
* - {@link MatchArgs.toDefinition|toDefinition} - only the call, the formals are looked up for you
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* MatchArgs.toNames(call.arguments, ['x', 'value']).get('value');
|
|
20
|
+
* MatchArgs.toSpec(args, { file: 'fileId', '...': '...' }).get('fileId');
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const MatchArgs: {
|
|
24
|
+
readonly name: "MatchArgs";
|
|
25
|
+
/**
|
|
26
|
+
* Binds a call's AST `args` to the formal `paramNames`. An empty argument (`f(1, ,3)`) takes its formal but
|
|
27
|
+
* never appears here. Arguments falling to `...` share that key, so only the last survives; use
|
|
28
|
+
* {@link MatchArgs.toSpec} to keep them all.
|
|
29
|
+
* @param args - The arguments as they stand in the normalized AST.
|
|
30
|
+
* @param paramNames - The formals of the called function, in order.
|
|
31
|
+
* @returns Per formal name the argument bound to it.
|
|
32
|
+
*/
|
|
33
|
+
readonly toNames: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string, RArgument<Info>>;
|
|
34
|
+
/**
|
|
35
|
+
* Binds a call's graph `args` against the formals, reading nothing from the graph, so it also serves a
|
|
36
|
+
* function whose parameters are not in the AST at all. Name `'...'` in a specification unless the function
|
|
37
|
+
* really has none, as that is what collects arguments finding no formal of their own.
|
|
38
|
+
* @param args - The arguments as the graph holds them, see {@link convertFnArguments}.
|
|
39
|
+
* @param params - Formal name to the target it stands for, or a signature whose names are the targets.
|
|
40
|
+
* @returns Per target the ids bound to it.
|
|
41
|
+
*/
|
|
42
|
+
readonly toSpec: <Targets extends NodeId = string>(this: void, args: readonly FunctionArgument[], params: Record<string, Targets> | readonly SigParameter[]) => Map<Targets, NodeId[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Binds a call's graph `args` to the `params` of the definition it calls **and mutates `graph`**, adding an
|
|
45
|
+
* {@link EdgeType.DefinesOnCall} and a {@link EdgeType.DefinedByOnCall} edge per bound pair. It is the only
|
|
46
|
+
* member here that writes anything.
|
|
47
|
+
* @param args - The arguments as the graph holds them.
|
|
48
|
+
* @param params - The parameters of the called definition, in order.
|
|
49
|
+
* @param graph - The graph the edges are added to.
|
|
50
|
+
* @returns The argument id to parameter id mapping the edges were drawn for.
|
|
51
|
+
*/
|
|
52
|
+
readonly onCallAndLink: (this: void, args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph) => Map<NodeId, NodeId>;
|
|
53
|
+
/**
|
|
54
|
+
* Binds a call's arguments to the formals of whatever it calls, looking the formals up itself. It takes them
|
|
55
|
+
* from the {@link RFunctionDefinition} the call resolves to in user code, and from the database signature at
|
|
56
|
+
* the version the analysis assumes otherwise (see {@link SignatureDb}). `undefined` when it resolves to
|
|
57
|
+
* neither, so fall back to a hardcoded list then.
|
|
58
|
+
*
|
|
59
|
+
* `graph` is what says which definition a name reaches here, because scoping, shadowing and control flow
|
|
60
|
+
* decide that and a name alone cannot. It therefore needs a finished graph rather than one under
|
|
61
|
+
* construction. Cost is one {@link Dataflow.origin} lookup plus, for a package call, decoding that one
|
|
62
|
+
* function.
|
|
63
|
+
* @param call - The call whose arguments are to be bound.
|
|
64
|
+
* @param graph - The finished graph the call was analyzed into.
|
|
65
|
+
* @param ctx - The analyzer context the database and the assumed versions come from.
|
|
66
|
+
* @returns Per formal name the argument bound to it, `undefined` if the formals could not be found.
|
|
67
|
+
*/
|
|
68
|
+
readonly toDefinition: <Info>(this: void, call: RFunctionCall<Info & ParentInformation>, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext) => ReadonlyMap<string, RArgument<Info & ParentInformation>> | undefined;
|
|
69
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MatchArgs = void 0;
|
|
4
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
5
|
+
const graph_1 = require("./graph");
|
|
6
|
+
const edge_1 = require("./edge");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const arg_matching_1 = require("../../util/arg-matching");
|
|
9
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
10
|
+
const signature_db_1 = require("../../project/sigdb/signature-db");
|
|
11
|
+
const df_helper_1 = require("./df-helper");
|
|
12
|
+
const identifier_1 = require("../environments/identifier");
|
|
13
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
14
|
+
/** the argument names in the shape {@link matchArgumentsToParameters} takes, unnamed arguments as `undefined` */
|
|
15
|
+
function graphArgumentNames(args) {
|
|
16
|
+
return args.map(a => graph_1.FunctionArgument.isNamed(a) ? a.name : undefined);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* R's argument matching, as {@link matchArgumentsToParameters} implements it. Pick by what you hold:
|
|
20
|
+
*
|
|
21
|
+
* - {@link MatchArgs.toNames|toNames} - AST arguments and the formal names
|
|
22
|
+
* - {@link MatchArgs.toSpec|toSpec} - graph arguments and the formals (a spec or a database signature)
|
|
23
|
+
* - {@link MatchArgs.onCallAndLink|onCallAndLink} - as `toSpec`, and **adds the argument edges to the graph**
|
|
24
|
+
* - {@link MatchArgs.toDefinition|toDefinition} - only the call, the formals are looked up for you
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* MatchArgs.toNames(call.arguments, ['x', 'value']).get('value');
|
|
28
|
+
* MatchArgs.toSpec(args, { file: 'fileId', '...': '...' }).get('fileId');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
exports.MatchArgs = {
|
|
32
|
+
name: 'MatchArgs',
|
|
33
|
+
/**
|
|
34
|
+
* Binds a call's AST `args` to the formal `paramNames`. An empty argument (`f(1, ,3)`) takes its formal but
|
|
35
|
+
* never appears here. Arguments falling to `...` share that key, so only the last survives; use
|
|
36
|
+
* {@link MatchArgs.toSpec} to keep them all.
|
|
37
|
+
* @param args - The arguments as they stand in the normalized AST.
|
|
38
|
+
* @param paramNames - The formals of the called function, in order.
|
|
39
|
+
* @returns Per formal name the argument bound to it.
|
|
40
|
+
*/
|
|
41
|
+
toNames(args, paramNames) {
|
|
42
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => a === r_function_call_1.EmptyArgument ? undefined : a.name?.content), paramNames);
|
|
43
|
+
const bound = new Map();
|
|
44
|
+
for (let i = 0; i < args.length; i++) {
|
|
45
|
+
const arg = args[i], param = matched[i];
|
|
46
|
+
if (arg !== r_function_call_1.EmptyArgument && param !== undefined) {
|
|
47
|
+
bound.set(paramNames[param], arg);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return bound;
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Binds a call's graph `args` against the formals, reading nothing from the graph, so it also serves a
|
|
54
|
+
* function whose parameters are not in the AST at all. Name `'...'` in a specification unless the function
|
|
55
|
+
* really has none, as that is what collects arguments finding no formal of their own.
|
|
56
|
+
* @param args - The arguments as the graph holds them, see {@link convertFnArguments}.
|
|
57
|
+
* @param params - Formal name to the target it stands for, or a signature whose names are the targets.
|
|
58
|
+
* @returns Per target the ids bound to it.
|
|
59
|
+
*/
|
|
60
|
+
toSpec(args, params) {
|
|
61
|
+
let spec = params;
|
|
62
|
+
if (Array.isArray(params)) {
|
|
63
|
+
spec = {};
|
|
64
|
+
for (const p of params) {
|
|
65
|
+
spec[p.name] = p.name;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const paramNames = Object.keys(spec);
|
|
69
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(graphArgumentNames(args), paramNames);
|
|
70
|
+
const maps = new Map();
|
|
71
|
+
for (let i = 0; i < args.length; i++) {
|
|
72
|
+
const arg = args[i], param = matched[i];
|
|
73
|
+
if (arg === r_function_call_1.EmptyArgument || param === undefined) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const target = spec[paramNames[param]];
|
|
77
|
+
const known = maps.get(target);
|
|
78
|
+
if (known) {
|
|
79
|
+
known.push(arg.nodeId);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
maps.set(target, [arg.nodeId]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return maps;
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Binds a call's graph `args` to the `params` of the definition it calls **and mutates `graph`**, adding an
|
|
89
|
+
* {@link EdgeType.DefinesOnCall} and a {@link EdgeType.DefinedByOnCall} edge per bound pair. It is the only
|
|
90
|
+
* member here that writes anything.
|
|
91
|
+
* @param args - The arguments as the graph holds them.
|
|
92
|
+
* @param params - The parameters of the called definition, in order.
|
|
93
|
+
* @param graph - The graph the edges are added to.
|
|
94
|
+
* @returns The argument id to parameter id mapping the edges were drawn for.
|
|
95
|
+
*/
|
|
96
|
+
onCallAndLink(args, params, graph) {
|
|
97
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(graphArgumentNames(args), params.map(p => p?.special ? arg_matching_1.DotsParameterName : p?.name?.content));
|
|
98
|
+
const maps = new Map();
|
|
99
|
+
for (let i = 0; i < args.length; i++) {
|
|
100
|
+
const arg = args[i];
|
|
101
|
+
if (arg === r_function_call_1.EmptyArgument) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const param = matched[i];
|
|
105
|
+
const pid = param === undefined ? undefined : params[param].name?.info.id;
|
|
106
|
+
const aid = arg.nodeId;
|
|
107
|
+
if (pid === undefined) {
|
|
108
|
+
logger_1.dataflowLogger.warn(`skipping argument ${i} (id: ${aid}) as there is no corresponding parameter - R should block that`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
|
|
112
|
+
graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
113
|
+
maps.set(aid, pid);
|
|
114
|
+
}
|
|
115
|
+
return maps;
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* Binds a call's arguments to the formals of whatever it calls, looking the formals up itself. It takes them
|
|
119
|
+
* from the {@link RFunctionDefinition} the call resolves to in user code, and from the database signature at
|
|
120
|
+
* the version the analysis assumes otherwise (see {@link SignatureDb}). `undefined` when it resolves to
|
|
121
|
+
* neither, so fall back to a hardcoded list then.
|
|
122
|
+
*
|
|
123
|
+
* `graph` is what says which definition a name reaches here, because scoping, shadowing and control flow
|
|
124
|
+
* decide that and a name alone cannot. It therefore needs a finished graph rather than one under
|
|
125
|
+
* construction. Cost is one {@link Dataflow.origin} lookup plus, for a package call, decoding that one
|
|
126
|
+
* function.
|
|
127
|
+
* @param call - The call whose arguments are to be bound.
|
|
128
|
+
* @param graph - The finished graph the call was analyzed into.
|
|
129
|
+
* @param ctx - The analyzer context the database and the assumed versions come from.
|
|
130
|
+
* @returns Per formal name the argument bound to it, `undefined` if the formals could not be found.
|
|
131
|
+
*/
|
|
132
|
+
toDefinition(call, graph, ctx) {
|
|
133
|
+
const names = formalsOf(call, graph, ctx);
|
|
134
|
+
return names === undefined ? undefined : exports.MatchArgs.toNames(call.arguments, names);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The formals {@link MatchArgs.toDefinition} binds against. User code is tried first because its parameters are
|
|
139
|
+
* already in the AST, so the common case never touches the signature database.
|
|
140
|
+
*/
|
|
141
|
+
function formalsOf(call, graph, ctx) {
|
|
142
|
+
const origins = df_helper_1.Dataflow.origin(graph, call.info.id);
|
|
143
|
+
if (origins === undefined) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
for (const origin of origins) {
|
|
147
|
+
if (origin.type === 2 /* OriginType.FunctionCallOrigin */ && !node_id_1.NodeId.isBuiltIn(origin.id)) {
|
|
148
|
+
const definition = graph.idMap?.get(origin.id);
|
|
149
|
+
if (r_function_definition_1.RFunctionDefinition.is(definition)) {
|
|
150
|
+
return definition.parameters.map(p => p.special ? arg_matching_1.DotsParameterName : p.name.content);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
let db;
|
|
155
|
+
for (const origin of origins) {
|
|
156
|
+
if (origin.type !== 3 /* OriginType.BuiltInFunctionOrigin */) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
db ??= (0, signature_db_1.signatureDbOf)(ctx.deps);
|
|
160
|
+
const found = db.parametersOf(identifier_1.Identifier.toQualified([origin], origin.fn.name) ?? origin.fn.name);
|
|
161
|
+
if (found !== undefined && found.length > 0) {
|
|
162
|
+
return found;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=match-args.js.map
|
package/dataflow/info.d.ts
CHANGED
|
@@ -133,6 +133,20 @@ export type KillReference =
|
|
|
133
133
|
export interface DataflowCfgInformation {
|
|
134
134
|
/** The entry node into the subgraph */
|
|
135
135
|
entryPoint: NodeId;
|
|
136
|
+
/**
|
|
137
|
+
* The node control flow enters this subtree at.
|
|
138
|
+
* Control flow is modeled in post-order (operands are evaluated before the operator that consumes them),
|
|
139
|
+
* so for compound constructs this is not the {@link DataflowCfgInformation#entryPoint|entryPoint}
|
|
140
|
+
* (which names the value-producing node) but the first node that is actually evaluated.
|
|
141
|
+
* Left `undefined` whenever both coincide, which is the case for all leaves.
|
|
142
|
+
*/
|
|
143
|
+
cfgEntry?: NodeId;
|
|
144
|
+
/**
|
|
145
|
+
* The node control flow leaves this subtree at, joining the branches of the construct if it has any.
|
|
146
|
+
* Left `undefined` whenever the {@link DataflowCfgInformation#exitPoints|exitPoints} already name it,
|
|
147
|
+
* which is the case whenever the construct has a single point of exit.
|
|
148
|
+
*/
|
|
149
|
+
cfgExit?: NodeId;
|
|
136
150
|
/**
|
|
137
151
|
* All already identified exit points (active 'return'/'break'/'next'-likes) of the respective structure.
|
|
138
152
|
* This also tracks (local knowledge of) exceptions thrown within the structure.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { DataflowGraph } from '../graph/graph';
|
|
3
|
+
import type { ControlDependency, DataflowCfgInformation } from '../info';
|
|
4
|
+
import { ExitPointType } from '../info';
|
|
5
|
+
/**
|
|
6
|
+
* Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
|
|
7
|
+
* The {@link ControlFlowGraph} is a view on what is recorded here.
|
|
8
|
+
*
|
|
9
|
+
* The control flow is modeled in post-order: everything a construct is made of runs before the construct
|
|
10
|
+
* itself, so its own vertex is where its parts join again and where it is left.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ControlFlow: {
|
|
13
|
+
readonly name: "ControlFlow";
|
|
14
|
+
/**
|
|
15
|
+
* The node control flow enters the given subtree at.
|
|
16
|
+
* @example
|
|
17
|
+
* ```r
|
|
18
|
+
* x + 1 # the `+` is entered at `x`
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
readonly entryOf: (this: void, info: DataflowCfgInformation) => NodeId;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the node runs as a statement of the program instead of as part of a larger expression.
|
|
24
|
+
* Assignments count as statements wherever they stand.
|
|
25
|
+
* @example
|
|
26
|
+
* ```r
|
|
27
|
+
* print(x + 1) # the call is a statement, `x + 1` and `x` are expressions
|
|
28
|
+
* ```
|
|
29
|
+
* @see {@link ControlFlow#isExpression|isExpression()} - for the other kind
|
|
30
|
+
*/
|
|
31
|
+
readonly isStatement: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the node runs as part of a larger expression instead of as a statement of its own.
|
|
34
|
+
* @example
|
|
35
|
+
* ```r
|
|
36
|
+
* print(x + 1) # `x + 1` and `x` are expressions, the call is a statement
|
|
37
|
+
* ```
|
|
38
|
+
* @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
|
|
39
|
+
*/
|
|
40
|
+
readonly isExpression: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the subtree can be left normally instead of always jumping away.
|
|
43
|
+
* @example
|
|
44
|
+
* ```r
|
|
45
|
+
* { 1 } # can complete
|
|
46
|
+
* { break } # cannot
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
readonly canComplete: (this: void, info: DataflowCfgInformation) => boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whatever `from` completes at continues with `next`.
|
|
52
|
+
* @example
|
|
53
|
+
* ```r
|
|
54
|
+
* f(); g() # the call to `g` continues what `f` completes
|
|
55
|
+
* ```
|
|
56
|
+
* @see {@link ControlFlow#branchesTo|branchesTo()} - if it only continues under a condition
|
|
57
|
+
*/
|
|
58
|
+
readonly continuesWith: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, next: NodeId) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Whatever `from` completes at continues with `target`, but only under the given control dependency.
|
|
61
|
+
* Hand over the very dependency the vertices behind the branch carry, so both say the same thing.
|
|
62
|
+
* @example
|
|
63
|
+
* ```r
|
|
64
|
+
* if(u) a else b # `a` is reached when `u` holds, `b` when it does not
|
|
65
|
+
* ```
|
|
66
|
+
* @see {@link ControlFlow#continuesWith|continuesWith()} - if it always continues
|
|
67
|
+
*/
|
|
68
|
+
readonly branchesTo: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, target: NodeId, cd: ControlDependency) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Every jump of the given kind within `from` lands on `target`.
|
|
71
|
+
* @example
|
|
72
|
+
* ```r
|
|
73
|
+
* while(u) { break } # the `break` lands on the loop it leaves
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
readonly jumpsTo: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, kind: ExitPointType, target: NodeId) => void;
|
|
77
|
+
/**
|
|
78
|
+
* The parts run one after the other and the last one continues with `last`, if it is given.
|
|
79
|
+
* Parts that are `undefined` are skipped, which keeps optional arguments cheap to handle.
|
|
80
|
+
* @example
|
|
81
|
+
* ```r
|
|
82
|
+
* f(a, b) # `a`, then `b`, then the call
|
|
83
|
+
* ```
|
|
84
|
+
* @returns the node control flow enters the sequence at, or `last` if there is nothing to enter
|
|
85
|
+
*/
|
|
86
|
+
readonly inSequence: (this: void, graph: DataflowGraph, parts: readonly (DataflowCfgInformation | undefined)[], last?: NodeId) => NodeId | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The parts before `from` run in sequence, the ones after it are alternatives of which at most one runs.
|
|
89
|
+
* Whichever one it is, control joins on `joinsAt`.
|
|
90
|
+
* @example
|
|
91
|
+
* ```r
|
|
92
|
+
* switch(k, a = 1, b = 2) # `k`, then one arm, then the switch
|
|
93
|
+
* ```
|
|
94
|
+
* @param graph - the graph to record in
|
|
95
|
+
* @param parts - the arguments of the call, in the order they run
|
|
96
|
+
* @param from - the index the alternatives start at
|
|
97
|
+
* @param joinsAt - the call the alternatives belong to
|
|
98
|
+
* @param hasDefault - whether one alternative runs when none of the others matched
|
|
99
|
+
* @returns the node control flow enters the call at
|
|
100
|
+
*/
|
|
101
|
+
readonly picksOneOf: (this: void, graph: DataflowGraph, parts: readonly (DataflowCfgInformation | undefined)[], from: number, joinsAt: NodeId, hasDefault: boolean) => NodeId | undefined;
|
|
102
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControlFlow = void 0;
|
|
4
|
+
const edge_1 = require("../graph/edge");
|
|
5
|
+
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
6
|
+
/**
|
|
7
|
+
* Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
|
|
8
|
+
* The {@link ControlFlowGraph} is a view on what is recorded here.
|
|
9
|
+
*
|
|
10
|
+
* The control flow is modeled in post-order: everything a construct is made of runs before the construct
|
|
11
|
+
* itself, so its own vertex is where its parts join again and where it is left.
|
|
12
|
+
*/
|
|
13
|
+
exports.ControlFlow = {
|
|
14
|
+
name: 'ControlFlow',
|
|
15
|
+
/**
|
|
16
|
+
* The node control flow enters the given subtree at.
|
|
17
|
+
* @example
|
|
18
|
+
* ```r
|
|
19
|
+
* x + 1 # the `+` is entered at `x`
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
entryOf(info) {
|
|
23
|
+
return info.cfgEntry ?? info.entryPoint;
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Whether the node runs as a statement of the program instead of as part of a larger expression.
|
|
27
|
+
* Assignments count as statements wherever they stand.
|
|
28
|
+
* @example
|
|
29
|
+
* ```r
|
|
30
|
+
* print(x + 1) # the call is a statement, `x + 1` and `x` are expressions
|
|
31
|
+
* ```
|
|
32
|
+
* @see {@link ControlFlow#isExpression|isExpression()} - for the other kind
|
|
33
|
+
*/
|
|
34
|
+
isStatement(graph, id) {
|
|
35
|
+
const node = graph.idMap?.get(id);
|
|
36
|
+
if (node === undefined) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return node.info.role === "el-c" /* RoleInParent.ExpressionListChild */
|
|
40
|
+
|| (r_binary_op_1.RBinaryOp.is(node) && node.flavor === 'assignment');
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Whether the node runs as part of a larger expression instead of as a statement of its own.
|
|
44
|
+
* @example
|
|
45
|
+
* ```r
|
|
46
|
+
* print(x + 1) # `x + 1` and `x` are expressions, the call is a statement
|
|
47
|
+
* ```
|
|
48
|
+
* @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
|
|
49
|
+
*/
|
|
50
|
+
isExpression(graph, id) {
|
|
51
|
+
return graph.idMap?.get(id) !== undefined && !exports.ControlFlow.isStatement(graph, id);
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Whether the subtree can be left normally instead of always jumping away.
|
|
55
|
+
* @example
|
|
56
|
+
* ```r
|
|
57
|
+
* { 1 } # can complete
|
|
58
|
+
* { break } # cannot
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
canComplete(info) {
|
|
62
|
+
if (info.cfgExit !== undefined) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
for (const exit of info.exitPoints) {
|
|
66
|
+
if (exit.type === 0 /* ExitPointType.Default */) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Whatever `from` completes at continues with `next`.
|
|
74
|
+
* @example
|
|
75
|
+
* ```r
|
|
76
|
+
* f(); g() # the call to `g` continues what `f` completes
|
|
77
|
+
* ```
|
|
78
|
+
* @see {@link ControlFlow#branchesTo|branchesTo()} - if it only continues under a condition
|
|
79
|
+
*/
|
|
80
|
+
continuesWith(graph, from, next) {
|
|
81
|
+
if (from.cfgExit !== undefined) {
|
|
82
|
+
graph.addEdge(from.cfgExit, next, edge_1.EdgeType.FlowEdge);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const exit of from.exitPoints) {
|
|
86
|
+
if (exit.type === 0 /* ExitPointType.Default */) {
|
|
87
|
+
graph.addEdge(exit.nodeId, next, edge_1.EdgeType.FlowEdge);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Whatever `from` completes at continues with `target`, but only under the given control dependency.
|
|
93
|
+
* Hand over the very dependency the vertices behind the branch carry, so both say the same thing.
|
|
94
|
+
* @example
|
|
95
|
+
* ```r
|
|
96
|
+
* if(u) a else b # `a` is reached when `u` holds, `b` when it does not
|
|
97
|
+
* ```
|
|
98
|
+
* @see {@link ControlFlow#continuesWith|continuesWith()} - if it always continues
|
|
99
|
+
*/
|
|
100
|
+
branchesTo(graph, from, target, cd) {
|
|
101
|
+
if (from.cfgExit !== undefined) {
|
|
102
|
+
graph.addEdge(from.cfgExit, target, edge_1.EdgeType.ControlEdge, { cd });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const exit of from.exitPoints) {
|
|
106
|
+
if (exit.type === 0 /* ExitPointType.Default */) {
|
|
107
|
+
graph.addEdge(exit.nodeId, target, edge_1.EdgeType.ControlEdge, { cd });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Every jump of the given kind within `from` lands on `target`.
|
|
113
|
+
* @example
|
|
114
|
+
* ```r
|
|
115
|
+
* while(u) { break } # the `break` lands on the loop it leaves
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
jumpsTo(graph, from, kind, target) {
|
|
119
|
+
for (const exit of from.exitPoints) {
|
|
120
|
+
if (exit.type === kind) {
|
|
121
|
+
graph.addEdge(exit.nodeId, target, edge_1.EdgeType.FlowEdge);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* The parts run one after the other and the last one continues with `last`, if it is given.
|
|
127
|
+
* Parts that are `undefined` are skipped, which keeps optional arguments cheap to handle.
|
|
128
|
+
* @example
|
|
129
|
+
* ```r
|
|
130
|
+
* f(a, b) # `a`, then `b`, then the call
|
|
131
|
+
* ```
|
|
132
|
+
* @returns the node control flow enters the sequence at, or `last` if there is nothing to enter
|
|
133
|
+
*/
|
|
134
|
+
inSequence(graph, parts, last) {
|
|
135
|
+
let entry = undefined;
|
|
136
|
+
let previous = undefined;
|
|
137
|
+
for (const part of parts) {
|
|
138
|
+
if (part === undefined) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (previous === undefined) {
|
|
142
|
+
entry = exports.ControlFlow.entryOf(part);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
exports.ControlFlow.continuesWith(graph, previous, exports.ControlFlow.entryOf(part));
|
|
146
|
+
}
|
|
147
|
+
previous = part;
|
|
148
|
+
}
|
|
149
|
+
if (previous !== undefined && last !== undefined) {
|
|
150
|
+
exports.ControlFlow.continuesWith(graph, previous, last);
|
|
151
|
+
}
|
|
152
|
+
return entry ?? last;
|
|
153
|
+
},
|
|
154
|
+
/**
|
|
155
|
+
* The parts before `from` run in sequence, the ones after it are alternatives of which at most one runs.
|
|
156
|
+
* Whichever one it is, control joins on `joinsAt`.
|
|
157
|
+
* @example
|
|
158
|
+
* ```r
|
|
159
|
+
* switch(k, a = 1, b = 2) # `k`, then one arm, then the switch
|
|
160
|
+
* ```
|
|
161
|
+
* @param graph - the graph to record in
|
|
162
|
+
* @param parts - the arguments of the call, in the order they run
|
|
163
|
+
* @param from - the index the alternatives start at
|
|
164
|
+
* @param joinsAt - the call the alternatives belong to
|
|
165
|
+
* @param hasDefault - whether one alternative runs when none of the others matched
|
|
166
|
+
* @returns the node control flow enters the call at
|
|
167
|
+
*/
|
|
168
|
+
picksOneOf(graph, parts, from, joinsAt, hasDefault) {
|
|
169
|
+
let entry = undefined;
|
|
170
|
+
let selector = undefined;
|
|
171
|
+
for (let i = 0; i < from; i++) {
|
|
172
|
+
const part = parts[i];
|
|
173
|
+
if (part === undefined) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (selector === undefined) {
|
|
177
|
+
entry = exports.ControlFlow.entryOf(part);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
exports.ControlFlow.continuesWith(graph, selector, exports.ControlFlow.entryOf(part));
|
|
181
|
+
}
|
|
182
|
+
selector = part;
|
|
183
|
+
}
|
|
184
|
+
for (let i = from; i < parts.length; i++) {
|
|
185
|
+
const alternative = parts[i];
|
|
186
|
+
if (alternative === undefined) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (selector !== undefined) {
|
|
190
|
+
exports.ControlFlow.branchesTo(graph, selector, exports.ControlFlow.entryOf(alternative), { id: joinsAt, when: true });
|
|
191
|
+
}
|
|
192
|
+
exports.ControlFlow.continuesWith(graph, alternative, joinsAt);
|
|
193
|
+
}
|
|
194
|
+
if (selector !== undefined && !hasDefault) {
|
|
195
|
+
exports.ControlFlow.branchesTo(graph, selector, joinsAt, { id: joinsAt, when: false });
|
|
196
|
+
}
|
|
197
|
+
return entry ?? joinsAt;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=control-flow.js.map
|
|
@@ -2,7 +2,7 @@ import { DefaultMap } from '../../util/collections/defaultmap';
|
|
|
2
2
|
import type { BuiltIn } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import { Identifier, type IdentifierReference } from '../environments/identifier';
|
|
5
|
-
import {
|
|
5
|
+
import type { FunctionArgument, DataflowGraph } from '../graph/graph';
|
|
6
6
|
import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
|
|
7
7
|
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
8
|
import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexInfo } from '../graph/vertex';
|
|
@@ -18,31 +18,15 @@ export declare function findNonLocalReads(graph: DataflowGraph, ignores?: Readon
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
|
|
20
20
|
/**
|
|
21
|
-
* {@link
|
|
21
|
+
* {@link MatchArgs.onCall|Matches} the arguments to the parameters and links them in the graph,
|
|
22
22
|
* returning the resolved map from argument ids to parameter ids.
|
|
23
|
-
*
|
|
23
|
+
* @useInstead {@link MatchArgs.onCallAndLink}
|
|
24
24
|
*/
|
|
25
25
|
export declare function linkArgumentsOnCall(args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph): Map<NodeId, NodeId>;
|
|
26
26
|
/**
|
|
27
|
-
* {@link
|
|
28
|
-
* arguments bound to each target.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const parameterSpec = {
|
|
33
|
-
* 'paramName': 'paramId',
|
|
34
|
-
* 'anotherParamName': 'anotherParamId',
|
|
35
|
-
* // we recommend to always add '...' to your specification
|
|
36
|
-
* // this way you can collect all arguments that could not be matched!
|
|
37
|
-
* '...': '...'
|
|
38
|
-
* } as const;
|
|
39
|
-
*
|
|
40
|
-
* const match = pMatch(convertFnArguments(args), parameterSpec);
|
|
41
|
-
* const addParam = match.get('paramId');
|
|
42
|
-
* ```
|
|
43
|
-
* @note
|
|
44
|
-
* To obtain the arguments from a {@link RFunctionCall}[], either use {@link processAllArguments} (also available via {@link processKnownFunctionCall})
|
|
45
|
-
* or convert them with {@link convertFnArguments}.
|
|
27
|
+
* {@link MatchArgs.toSpec|Matches} the arguments against a parameter specification, returning the
|
|
28
|
+
* arguments bound to each target.
|
|
29
|
+
* @useInstead {@link MatchArgs.toSpec}
|
|
46
30
|
*/
|
|
47
31
|
export declare function pMatch<Targets extends NodeId>(args: readonly FunctionArgument[], params: Record<string, Targets>): Map<Targets, NodeId[]>;
|
|
48
32
|
/**
|
|
@@ -81,15 +65,6 @@ export declare function getAllFunctionCallTargets(call: NodeId, graph: DataflowG
|
|
|
81
65
|
* To know what fdefs the definition of `x` in the first line links to, you can use {@link getAllLinkedFunctionDefinitions|this function}.
|
|
82
66
|
*/
|
|
83
67
|
export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): [Set<Required<DataflowGraphVertexFunctionDefinition>>, Set<BuiltIn>];
|
|
84
|
-
/**
|
|
85
|
-
* This method links a set of read variables to definitions in an environment.
|
|
86
|
-
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
|
|
87
|
-
* @param environmentInformation - The environment information to link against
|
|
88
|
-
* @param givenInputs - The existing list of inputs that might be extended
|
|
89
|
-
* @param graph - The graph to enter the found links
|
|
90
|
-
* @param maybeForRemaining - Each input that can not be linked, will be added to `givenInputs`. If this flag is `true`, it will be marked as `maybe`.
|
|
91
|
-
* @returns the given inputs, possibly extended with the remaining inputs (those of `referencesToLinkAgainstEnvironment` that could not be linked against the environment)
|
|
92
|
-
*/
|
|
93
68
|
/**
|
|
94
69
|
* Links every name in the expression rooted at `expr` against `environment`, as if it were written there, and
|
|
95
70
|
* hands back what stays unresolved. This is how an expression that was captured elsewhere is read here.
|