@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
|
@@ -1,22 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SemanticCfgGuidedVisitor, type SemanticCfgGuidedVisitorConfiguration } from '../control-flow/semantic-cfg-guided-visitor';
|
|
1
|
+
import { CfgVertex, type ControlFlowInformation } from '../control-flow/control-flow-graph';
|
|
2
|
+
import { SemanticCfgGuidedVisitor, type SemanticCfgGuidedVisitorConfiguration, type OnCall } from '../control-flow/semantic-cfg-guided-visitor';
|
|
3
3
|
import { BuiltInProcName } from '../dataflow/environments/built-in-proc-name';
|
|
4
|
-
import type
|
|
4
|
+
import { type DataflowGraph } from '../dataflow/graph/graph';
|
|
5
5
|
import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexVariableDefinition } from '../dataflow/graph/vertex';
|
|
6
|
-
import {
|
|
6
|
+
import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
|
|
7
7
|
import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
8
|
-
import
|
|
8
|
+
import { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
9
|
+
import type { ControlDependency } from '../dataflow/info';
|
|
9
10
|
import type { AnyStateDomain, ValueDomain } from './domains/state-domain-like';
|
|
10
11
|
export type DomainOfVisitor<AbsintVisitor extends AbstractInterpretationVisitor<AnyStateDomain>> = AbsintVisitor extends AbstractInterpretationVisitor<infer StateDomain> ? StateDomain : never;
|
|
11
|
-
export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfiguration<NoInfo, ControlFlowInformation, NormalizedAst>, 'defaultVisitingOrder'
|
|
12
|
+
export type AbsintVisitorConfiguration = Omit<SemanticCfgGuidedVisitorConfiguration<NoInfo, ControlFlowInformation, NormalizedAst>, 'defaultVisitingOrder'>;
|
|
13
|
+
/**
|
|
14
|
+
* Where an abstract state arrives from, and which way the branch went if the step was one.
|
|
15
|
+
*
|
|
16
|
+
* For `if(u) a else b` the step onto `a` carries `{ id: <u>, branch: { id: <the if>, when: true } }`,
|
|
17
|
+
* so the predecessor is the condition and `when` is the outcome it had.
|
|
18
|
+
*/
|
|
19
|
+
export interface AbsintPredecessor {
|
|
20
|
+
/** the vertex the abstract state comes from */
|
|
21
|
+
readonly id: NodeId;
|
|
22
|
+
/** the branch taken to get here, `undefined` if control simply flows on */
|
|
23
|
+
readonly branch?: ControlDependency;
|
|
24
|
+
}
|
|
12
25
|
/**
|
|
13
26
|
* A control flow graph visitor to perform abstract interpretation.
|
|
14
27
|
*
|
|
15
|
-
*
|
|
28
|
+
* The worklist below stays within the function it starts in: a function definition produces a closure and its
|
|
29
|
+
* body is a region of its own, which nothing flows into.
|
|
30
|
+
*
|
|
31
|
+
* Calls are not followed by default: flip {@link AbstractInterpretationVisitor#shouldEnterCall|shouldEnterCall()} to
|
|
32
|
+
* step into what a call dispatches to and continue with the state at the function's exit points.
|
|
33
|
+
* Condition semantics are not applied by default either, but everything needed for them is there:
|
|
34
|
+
* {@link AbstractInterpretationVisitor#getPredecessorState|getPredecessorState()} is handed the branch that was
|
|
35
|
+
* taken, and {@link BasicCfgGuidedVisitor#getDecidedConstructs|getDecidedConstructs()} names the construct a
|
|
36
|
+
* condition belongs to.
|
|
16
37
|
*/
|
|
17
38
|
export declare abstract class AbstractInterpretationVisitor<StateDomain extends AnyStateDomain, Config extends AbsintVisitorConfiguration = AbsintVisitorConfiguration> extends SemanticCfgGuidedVisitor<NoInfo, ControlFlowInformation, NormalizedAst, DataflowGraph, Config & {
|
|
18
39
|
defaultVisitingOrder: 'forward';
|
|
19
|
-
defaultVisitingType: 'exit';
|
|
20
40
|
}> {
|
|
21
41
|
/**
|
|
22
42
|
* The abstract trace of the abstract interpretation visitor mapping node IDs to the abstract state at the respective node.
|
|
@@ -31,13 +51,18 @@ export declare abstract class AbstractInterpretationVisitor<StateDomain extends
|
|
|
31
51
|
*/
|
|
32
52
|
private stack;
|
|
33
53
|
/**
|
|
34
|
-
*
|
|
54
|
+
* The nodes a back edge of the control flow graph leads to, computed on demand.
|
|
55
|
+
* @see {@link AbstractInterpretationVisitor#isWideningPoint|isWideningPoint()}
|
|
35
56
|
*/
|
|
36
|
-
private
|
|
57
|
+
private wideningPoints;
|
|
37
58
|
/**
|
|
38
|
-
* A
|
|
59
|
+
* A set of nodes representing variable definitions that have already been visited but whose assignment has not yet been processed.
|
|
39
60
|
*/
|
|
40
|
-
private readonly
|
|
61
|
+
private readonly unassigned;
|
|
62
|
+
/** The call a function body is currently being interpreted for, mapping the body's entry to it. */
|
|
63
|
+
private readonly enteredFrom;
|
|
64
|
+
/** The function definitions currently being interpreted, which is what stops a recursive call from running forever. */
|
|
65
|
+
private readonly running;
|
|
41
66
|
constructor(config: Config, stateDomain: StateDomain);
|
|
42
67
|
/**
|
|
43
68
|
* Resolves the inferred abstract value of an AST node.
|
|
@@ -68,18 +93,15 @@ export declare abstract class AbstractInterpretationVisitor<StateDomain extends
|
|
|
68
93
|
start(): void;
|
|
69
94
|
protected startVisitor(start: readonly NodeId[]): void;
|
|
70
95
|
protected visitNode(vertexId: NodeId): boolean;
|
|
71
|
-
protected visitUnknown(vertex: CfgStatementVertex | CfgExpressionVertex): void;
|
|
72
96
|
protected onDispatchFunctionCallOrigin(call: DataflowGraphVertexFunctionCall, origin: BuiltInProcName): void;
|
|
73
97
|
protected onVariableDefinition({ vertex }: {
|
|
74
98
|
vertex: DataflowGraphVertexVariableDefinition;
|
|
75
99
|
}): void;
|
|
76
|
-
protected onAssignmentCall({ target, source }: {
|
|
77
|
-
call: DataflowGraphVertexFunctionCall;
|
|
100
|
+
protected onAssignmentCall({ target, source }: OnCall & {
|
|
78
101
|
target?: NodeId;
|
|
79
102
|
source?: NodeId;
|
|
80
103
|
}): void;
|
|
81
|
-
protected onReplacementCall({ target }: {
|
|
82
|
-
call: DataflowGraphVertexFunctionCall;
|
|
104
|
+
protected onReplacementCall({ target }: OnCall & {
|
|
83
105
|
target?: NodeId;
|
|
84
106
|
source?: NodeId;
|
|
85
107
|
}): void;
|
|
@@ -92,22 +114,66 @@ export declare abstract class AbstractInterpretationVisitor<StateDomain extends
|
|
|
92
114
|
* This bundles all function calls that are no conditions, loops, assignments, replacement calls, and access operations.
|
|
93
115
|
* @protected
|
|
94
116
|
*/
|
|
95
|
-
protected onFunctionCall(_data:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
protected onFunctionCall(_data: OnCall): void;
|
|
118
|
+
/**
|
|
119
|
+
* Everything the control flow may come from to reach this vertex, together with the branch it took to get here.
|
|
120
|
+
* Skipped vertices hold no state of their own, so what led into them is reported instead.
|
|
121
|
+
*/
|
|
122
|
+
protected getPredecessors(vertexId: NodeId): readonly AbsintPredecessor[];
|
|
123
|
+
/**
|
|
124
|
+
* The abstract state one predecessor contributes, joined into the state at the current vertex.
|
|
125
|
+
*
|
|
126
|
+
* By default, this is the state as the predecessor left it. Override it to apply condition semantics:
|
|
127
|
+
* on the then-branch of `if(u) a else b` the predecessor is `u` and `branch.when` is `true`, so `u` held.
|
|
128
|
+
*/
|
|
129
|
+
protected getPredecessorState({ id }: AbsintPredecessor): StateDomain | undefined;
|
|
130
|
+
protected visitFunctionCall(call: DataflowGraphVertexFunctionCall): void;
|
|
131
|
+
/**
|
|
132
|
+
* Whether the traversal should step into what the given call dispatches to.
|
|
133
|
+
* Returning `true` runs the bodies and continues with the state at their exit points.
|
|
134
|
+
*/
|
|
135
|
+
protected shouldEnterCall(_call: DataflowGraphVertexFunctionCall): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* The function definitions the given call may dispatch to.
|
|
138
|
+
* Built-in functions have no definition in the source, so they are not part of this.
|
|
139
|
+
*/
|
|
140
|
+
protected getCallTargets(callId: NodeId): readonly NodeId[];
|
|
141
|
+
/** Where a function definition starts, i.e. the first thing that runs when it is called. */
|
|
142
|
+
protected getFunctionEntry(defId: NodeId): NodeId | undefined;
|
|
143
|
+
/** Where a function definition is left, i.e. its last expressions and `return` calls. */
|
|
144
|
+
protected getFunctionExits(defId: NodeId): readonly NodeId[];
|
|
145
|
+
/**
|
|
146
|
+
* Runs the bodies the given call dispatches to, starting from the state at the call, and returns the state
|
|
147
|
+
* control comes back with: the states at their exit points joined.
|
|
148
|
+
* A call already being interpreted is not entered again, so recursion stops at the second entry.
|
|
149
|
+
* @returns the state at the exit points, or `undefined` if the call reaches nothing to step into
|
|
150
|
+
*/
|
|
151
|
+
protected enterCall(callId: NodeId): StateDomain | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Hand the arguments of the call to the parameters of the function it enters, so the body can read them.
|
|
154
|
+
* Only the arguments of this very call are used, whichever other calls the function has.
|
|
155
|
+
*/
|
|
156
|
+
protected bindParameters(callId: NodeId, defId: NodeId): void;
|
|
100
157
|
/** Gets each variable origin that has already been visited and whose assignment has already been processed */
|
|
101
158
|
protected getVariableOrigins(nodeId: NodeId): NodeId[];
|
|
102
159
|
/** Checks whether a node represents a unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...) */
|
|
103
160
|
protected isUnsupportedFunctionCall(nodeId: NodeId): boolean;
|
|
104
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* We widen wherever the control flow comes back around, i.e. at the node a back edge leads to.
|
|
163
|
+
* That is what makes the iteration terminate, and it is the loop head whichever loop the code used:
|
|
164
|
+
* the condition of a `while`, the binding of a `for`, or the first statement of a `repeat`.
|
|
165
|
+
*/
|
|
105
166
|
protected isWideningPoint(nodeId: NodeId): boolean;
|
|
167
|
+
/** The targets of the back edges of the control flow graph, found with one depth-first search. */
|
|
168
|
+
private findWideningPoints;
|
|
169
|
+
/** Everywhere the control flow may start: the program itself, and every function body, as nothing flows into one. */
|
|
170
|
+
private startingPoints;
|
|
106
171
|
/**
|
|
107
172
|
* Checks whether a control flow graph vertex should be skipped during visitation.
|
|
108
|
-
*
|
|
173
|
+
* Every node has exactly one vertex, reached once its operands are evaluated, so nothing is skipped
|
|
174
|
+
* by default; overriding this lets an analysis ignore parts of the program.
|
|
109
175
|
*/
|
|
110
|
-
protected shouldSkipVertex(
|
|
176
|
+
protected shouldSkipVertex(_vertex: CfgVertex): boolean;
|
|
111
177
|
/**
|
|
112
178
|
* Whether widening should be performed at a widening point.
|
|
113
179
|
* By default, we perform widening when the number of visits of the widening point reaches the widening threshold of the config.
|
|
@@ -5,17 +5,35 @@ const control_flow_graph_1 = require("../control-flow/control-flow-graph");
|
|
|
5
5
|
const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
|
|
6
6
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
7
7
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
8
|
+
const graph_1 = require("../dataflow/graph/graph");
|
|
9
|
+
const edge_1 = require("../dataflow/graph/edge");
|
|
8
10
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
9
|
-
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
10
11
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
|
-
const
|
|
12
|
+
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
13
|
const assert_1 = require("../util/assert");
|
|
13
14
|
const abstract_domain_1 = require("./domains/abstract-domain");
|
|
14
15
|
const unsupported_functions_1 = require("./unsupported-functions");
|
|
16
|
+
const r_argument_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
17
|
+
const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
18
|
+
const r_expression_list_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
19
|
+
const r_if_then_else_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
|
|
20
|
+
const r_pipe_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
|
|
21
|
+
const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
22
|
+
function stepFrom(graph, node) {
|
|
23
|
+
return { node, successors: [...graph.successors(node)], at: 0 };
|
|
24
|
+
}
|
|
15
25
|
/**
|
|
16
26
|
* A control flow graph visitor to perform abstract interpretation.
|
|
17
27
|
*
|
|
18
|
-
*
|
|
28
|
+
* The worklist below stays within the function it starts in: a function definition produces a closure and its
|
|
29
|
+
* body is a region of its own, which nothing flows into.
|
|
30
|
+
*
|
|
31
|
+
* Calls are not followed by default: flip {@link AbstractInterpretationVisitor#shouldEnterCall|shouldEnterCall()} to
|
|
32
|
+
* step into what a call dispatches to and continue with the state at the function's exit points.
|
|
33
|
+
* Condition semantics are not applied by default either, but everything needed for them is there:
|
|
34
|
+
* {@link AbstractInterpretationVisitor#getPredecessorState|getPredecessorState()} is handed the branch that was
|
|
35
|
+
* taken, and {@link BasicCfgGuidedVisitor#getDecidedConstructs|getDecidedConstructs()} names the construct a
|
|
36
|
+
* condition belongs to.
|
|
19
37
|
*/
|
|
20
38
|
class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
|
|
21
39
|
/**
|
|
@@ -31,15 +49,20 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
31
49
|
*/
|
|
32
50
|
stack = [];
|
|
33
51
|
/**
|
|
34
|
-
*
|
|
52
|
+
* The nodes a back edge of the control flow graph leads to, computed on demand.
|
|
53
|
+
* @see {@link AbstractInterpretationVisitor#isWideningPoint|isWideningPoint()}
|
|
35
54
|
*/
|
|
36
|
-
|
|
55
|
+
wideningPoints;
|
|
37
56
|
/**
|
|
38
|
-
* A
|
|
57
|
+
* A set of nodes representing variable definitions that have already been visited but whose assignment has not yet been processed.
|
|
39
58
|
*/
|
|
40
|
-
|
|
59
|
+
unassigned = new Set();
|
|
60
|
+
/** The call a function body is currently being interpreted for, mapping the body's entry to it. */
|
|
61
|
+
enteredFrom = new Map();
|
|
62
|
+
/** The function definitions currently being interpreted, which is what stops a recursive call from running forever. */
|
|
63
|
+
running = new Set();
|
|
41
64
|
constructor(config, stateDomain) {
|
|
42
|
-
super({ ...config, defaultVisitingOrder: 'forward'
|
|
65
|
+
super({ ...config, defaultVisitingOrder: 'forward' });
|
|
43
66
|
this.currentState = stateDomain.top();
|
|
44
67
|
}
|
|
45
68
|
/**
|
|
@@ -64,21 +87,21 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
64
87
|
const vertex = this.getDataflowGraph(node.info.id);
|
|
65
88
|
const call = vertex_1.FunctionCallVertex.is(vertex) ? vertex : undefined;
|
|
66
89
|
const origins = Array.isArray(call?.origin) ? call.origin : [];
|
|
67
|
-
if (
|
|
90
|
+
if (r_symbol_1.RSymbol.is(node)) {
|
|
68
91
|
const values = this.getVariableOrigins(node.info.id)
|
|
69
92
|
.map(origin => (this.getAbstractState(origin)?.isBottom() ? this.currentState.domain.bottom() : state?.get(origin)));
|
|
70
93
|
if (values.length > 0 && values.every(assert_1.isNotUndefined)) {
|
|
71
94
|
return abstract_domain_1.AbstractDomain.joinAll(values);
|
|
72
95
|
}
|
|
73
96
|
}
|
|
74
|
-
else if (
|
|
97
|
+
else if (r_argument_1.RArgument.isWithValue(node)) {
|
|
75
98
|
return this.getAbstractValue(node.value, state);
|
|
76
99
|
}
|
|
77
|
-
else if (
|
|
100
|
+
else if (r_expression_list_1.RExpressionList.is(node) && node.children.length > 0) {
|
|
78
101
|
return this.getAbstractValue(node.children.at(-1), state);
|
|
79
102
|
}
|
|
80
103
|
else if (origins.includes(built_in_proc_name_1.BuiltInProcName.Pipe)) {
|
|
81
|
-
if (
|
|
104
|
+
if (r_pipe_1.RPipe.is(node) || r_binary_op_1.RBinaryOp.is(node)) {
|
|
82
105
|
return this.getAbstractValue(node.rhs, state);
|
|
83
106
|
}
|
|
84
107
|
else if (call?.args.length === 2 && call?.args[1] !== r_function_call_1.EmptyArgument) {
|
|
@@ -87,7 +110,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
87
110
|
}
|
|
88
111
|
else if (origins.includes(built_in_proc_name_1.BuiltInProcName.IfThenElse)) {
|
|
89
112
|
let values = [];
|
|
90
|
-
if (
|
|
113
|
+
if (r_if_then_else_1.RIfThenElse.is(node) && node.otherwise !== undefined) {
|
|
91
114
|
values = [node.then, node.otherwise].map(entry => this.getAbstractValue(entry, state));
|
|
92
115
|
}
|
|
93
116
|
else if (call?.args.every(arg => arg !== r_function_call_1.EmptyArgument) && call.args.length === 3) {
|
|
@@ -113,9 +136,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
113
136
|
* @returns The inferred abstract state at the end of the program
|
|
114
137
|
*/
|
|
115
138
|
getEndState() {
|
|
116
|
-
const
|
|
117
|
-
const exitNodes = exitPoints.map(control_flow_graph_1.CfgVertex.getRootId).filter(assert_1.isNotUndefined);
|
|
118
|
-
const states = exitNodes.map(node => this.trace.get(node)).filter(assert_1.isNotUndefined);
|
|
139
|
+
const states = this.config.controlFlow.exitPoints.map(node => this.trace.get(node)).filter(assert_1.isNotUndefined);
|
|
119
140
|
return abstract_domain_1.AbstractDomain.joinAll(states, this.currentState.bottom());
|
|
120
141
|
}
|
|
121
142
|
/**
|
|
@@ -137,7 +158,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
137
158
|
if (!this.visitNode(current)) {
|
|
138
159
|
continue;
|
|
139
160
|
}
|
|
140
|
-
const successors = this.config.controlFlow.graph.
|
|
161
|
+
const successors = [...this.config.controlFlow.graph.successors(current)].reverse();
|
|
141
162
|
for (const next of successors) {
|
|
142
163
|
if (!this.stack.includes(next)) { // prevent double entries in working list
|
|
143
164
|
this.stack.push(next);
|
|
@@ -147,15 +168,14 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
147
168
|
}
|
|
148
169
|
visitNode(vertexId) {
|
|
149
170
|
const vertex = this.getCfgVertex(vertexId);
|
|
150
|
-
// skip exit vertices of widening points and entry vertices of complex nodes
|
|
151
171
|
if (vertex === undefined || this.shouldSkipVertex(vertex)) {
|
|
152
172
|
return true;
|
|
153
173
|
}
|
|
154
174
|
// retrieve new abstract state by joining states of predecessor nodes
|
|
155
|
-
const
|
|
156
|
-
const
|
|
175
|
+
const nodeId = control_flow_graph_1.CfgVertex.getId(vertex);
|
|
176
|
+
const predecessors = this.getPredecessors(nodeId);
|
|
177
|
+
const predecessorStates = predecessors.map(pred => this.getPredecessorState(pred)).filter(assert_1.isNotUndefined);
|
|
157
178
|
this.currentState = abstract_domain_1.AbstractDomain.joinAll(predecessorStates, this.currentState.top());
|
|
158
|
-
const nodeId = control_flow_graph_1.CfgVertex.getRootId(vertex);
|
|
159
179
|
// differentiate between widening points and other vertices
|
|
160
180
|
if (this.isWideningPoint(nodeId)) {
|
|
161
181
|
const oldState = this.trace.get(nodeId);
|
|
@@ -175,37 +195,21 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
175
195
|
this.currentState = this.currentState.top();
|
|
176
196
|
}
|
|
177
197
|
this.trace.set(nodeId, this.currentState);
|
|
178
|
-
const predecessorVisits = predecessors.map(pred => this.visited.get(pred) ?? 0);
|
|
198
|
+
const predecessorVisits = predecessors.map(pred => this.visited.get(pred.id) ?? 0);
|
|
179
199
|
const visitedCount = this.visited.get(nodeId) ?? 0;
|
|
180
200
|
this.visited.set(nodeId, visitedCount + 1);
|
|
181
201
|
// continue visiting if vertex is not a join vertex or number of visits of predecessors is the same
|
|
182
202
|
return predecessors.length <= 1 || this.stack.length === 0 || predecessorVisits.every(visits => visits === predecessorVisits[0]);
|
|
183
203
|
}
|
|
184
204
|
}
|
|
185
|
-
visitUnknown(vertex) {
|
|
186
|
-
const nodeId = control_flow_graph_1.CfgVertex.getRootId(vertex);
|
|
187
|
-
const replacements = this.replacements.get(nodeId);
|
|
188
|
-
if (replacements !== undefined) {
|
|
189
|
-
this.replacements.delete(nodeId);
|
|
190
|
-
for (const replacement of replacements) {
|
|
191
|
-
const call = this.getDataflowGraph(replacement);
|
|
192
|
-
if (vertex_1.FunctionCallVertex.is(call)) {
|
|
193
|
-
this.onReplacementCall({ call, ...this.getSourceAndTarget(call) });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
205
|
onDispatchFunctionCallOrigin(call, origin) {
|
|
199
206
|
if (origin === built_in_proc_name_1.BuiltInProcName.Replacement) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.replacements.set(assignment.info.id, replacements);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
207
|
+
/*
|
|
208
|
+
* A replacement is the last thing its statement does (the target and the value are evaluated first),
|
|
209
|
+
* so it is handled where it is visited; the `<-` it was rewritten from has no vertex to defer to.
|
|
210
|
+
*/
|
|
211
|
+
this.onReplacementCall({ call, ...this.getSourceAndTarget(call) });
|
|
212
|
+
return;
|
|
209
213
|
}
|
|
210
214
|
super.onDispatchFunctionCallOrigin(call, origin);
|
|
211
215
|
switch (origin) {
|
|
@@ -218,7 +222,6 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
218
222
|
case built_in_proc_name_1.BuiltInProcName.Assignment:
|
|
219
223
|
case built_in_proc_name_1.BuiltInProcName.AssignmentLike:
|
|
220
224
|
case built_in_proc_name_1.BuiltInProcName.TableAssignment:
|
|
221
|
-
case built_in_proc_name_1.BuiltInProcName.Replacement:
|
|
222
225
|
case built_in_proc_name_1.BuiltInProcName.Access:
|
|
223
226
|
case built_in_proc_name_1.BuiltInProcName.Pipe:
|
|
224
227
|
case built_in_proc_name_1.BuiltInProcName.Break:
|
|
@@ -262,22 +265,148 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
262
265
|
* @protected
|
|
263
266
|
*/
|
|
264
267
|
onFunctionCall(_data) { }
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Everything the control flow may come from to reach this vertex, together with the branch it took to get here.
|
|
270
|
+
* Skipped vertices hold no state of their own, so what led into them is reported instead.
|
|
271
|
+
*/
|
|
272
|
+
getPredecessors(vertexId) {
|
|
273
|
+
const result = [];
|
|
274
|
+
for (const [id, edge] of this.config.controlFlow.graph.ingoingEdges(vertexId) ?? graph_1.NoEdges) {
|
|
275
|
+
const branch = control_flow_graph_1.CfgEdge.isControlDependency(edge) ? edge : undefined;
|
|
276
|
+
const vertex = this.getCfgVertex(id);
|
|
270
277
|
if (vertex === undefined) {
|
|
271
|
-
|
|
278
|
+
continue;
|
|
272
279
|
}
|
|
273
280
|
else if (this.shouldSkipVertex(vertex)) {
|
|
274
|
-
|
|
281
|
+
/* the branch closest to us is the one that decided we get here at all, so it wins */
|
|
282
|
+
result.push(...this.getPredecessors(id).map(pred => branch ? { ...pred, branch } : pred));
|
|
275
283
|
}
|
|
276
284
|
else {
|
|
277
|
-
|
|
285
|
+
result.push({ id, branch });
|
|
278
286
|
}
|
|
279
|
-
}
|
|
280
|
-
|
|
287
|
+
}
|
|
288
|
+
/* a body has no predecessor of its own, so what runs before it is the call we stepped in from */
|
|
289
|
+
const enteredFrom = this.enteredFrom.get(vertexId);
|
|
290
|
+
if (enteredFrom !== undefined) {
|
|
291
|
+
result.push({ id: enteredFrom });
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The abstract state one predecessor contributes, joined into the state at the current vertex.
|
|
297
|
+
*
|
|
298
|
+
* By default, this is the state as the predecessor left it. Override it to apply condition semantics:
|
|
299
|
+
* on the then-branch of `if(u) a else b` the predecessor is `u` and `branch.when` is `true`, so `u` held.
|
|
300
|
+
*/
|
|
301
|
+
getPredecessorState({ id }) {
|
|
302
|
+
return this.trace.get(id);
|
|
303
|
+
}
|
|
304
|
+
visitFunctionCall(call) {
|
|
305
|
+
super.visitFunctionCall(call);
|
|
306
|
+
if (this.shouldEnterCall(call)) {
|
|
307
|
+
this.currentState = this.enterCall(call.id) ?? this.currentState;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Whether the traversal should step into what the given call dispatches to.
|
|
312
|
+
* Returning `true` runs the bodies and continues with the state at their exit points.
|
|
313
|
+
*/
|
|
314
|
+
shouldEnterCall(_call) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The function definitions the given call may dispatch to.
|
|
319
|
+
* Built-in functions have no definition in the source, so they are not part of this.
|
|
320
|
+
*/
|
|
321
|
+
getCallTargets(callId) {
|
|
322
|
+
const targets = control_flow_graph_1.CfgVertex.getCallTargets(this.getCfgVertex(callId));
|
|
323
|
+
return targets === undefined ? control_flow_graph_1.NoNeighbors : [...targets];
|
|
324
|
+
}
|
|
325
|
+
/** Where a function definition starts, i.e. the first thing that runs when it is called. */
|
|
326
|
+
getFunctionEntry(defId) {
|
|
327
|
+
const def = this.getDataflowGraph(defId);
|
|
328
|
+
return vertex_1.FunctionDefinitionVertex.is(def) ? def.subflow.cfgEntry ?? def.subflow.entryPoint : undefined;
|
|
329
|
+
}
|
|
330
|
+
/** Where a function definition is left, i.e. its last expressions and `return` calls. */
|
|
331
|
+
getFunctionExits(defId) {
|
|
332
|
+
const def = this.getDataflowGraph(defId);
|
|
333
|
+
return vertex_1.FunctionDefinitionVertex.is(def) ? def.exitPoints.map(exit => exit.nodeId) : control_flow_graph_1.NoNeighbors;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Runs the bodies the given call dispatches to, starting from the state at the call, and returns the state
|
|
337
|
+
* control comes back with: the states at their exit points joined.
|
|
338
|
+
* A call already being interpreted is not entered again, so recursion stops at the second entry.
|
|
339
|
+
* @returns the state at the exit points, or `undefined` if the call reaches nothing to step into
|
|
340
|
+
*/
|
|
341
|
+
enterCall(callId) {
|
|
342
|
+
const states = [];
|
|
343
|
+
const values = [];
|
|
344
|
+
const outerState = this.currentState;
|
|
345
|
+
for (const def of this.getCallTargets(callId)) {
|
|
346
|
+
const entry = this.getFunctionEntry(def);
|
|
347
|
+
if (entry === undefined || this.running.has(def)) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
this.running.add(def);
|
|
351
|
+
this.bindParameters(callId, def);
|
|
352
|
+
/* the entry picks its state up from the call, which is what makes the arguments visible in the body */
|
|
353
|
+
this.trace.set(callId, outerState);
|
|
354
|
+
this.enteredFrom.set(entry, callId);
|
|
355
|
+
const outerStack = this.stack;
|
|
356
|
+
this.startVisitor([entry]);
|
|
357
|
+
this.stack = outerStack;
|
|
358
|
+
this.enteredFrom.delete(entry);
|
|
359
|
+
this.running.delete(def);
|
|
360
|
+
for (const exit of this.getFunctionExits(def)) {
|
|
361
|
+
const state = this.trace.get(exit);
|
|
362
|
+
if (state === undefined) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
states.push(state);
|
|
366
|
+
const value = this.getAbstractValue(exit, state);
|
|
367
|
+
if (value !== undefined) {
|
|
368
|
+
values.push(value);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
this.currentState = outerState;
|
|
373
|
+
if (states.length === 0) {
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
376
|
+
const returned = abstract_domain_1.AbstractDomain.joinAll(states);
|
|
377
|
+
if (values.length > 0) {
|
|
378
|
+
/* what the call is worth is what its function leaves behind at its exits */
|
|
379
|
+
returned.set(callId, abstract_domain_1.AbstractDomain.joinAll(values));
|
|
380
|
+
}
|
|
381
|
+
return returned;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Hand the arguments of the call to the parameters of the function it enters, so the body can read them.
|
|
385
|
+
* Only the arguments of this very call are used, whichever other calls the function has.
|
|
386
|
+
*/
|
|
387
|
+
bindParameters(callId, defId) {
|
|
388
|
+
const call = this.getDataflowGraph(callId);
|
|
389
|
+
const definition = this.getDataflowGraph(defId);
|
|
390
|
+
if (!vertex_1.FunctionCallVertex.is(call) || !vertex_1.FunctionDefinitionVertex.is(definition)) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const args = new Set(call.args.filter(graph_1.FunctionArgument.isNotEmpty).map(arg => arg.nodeId));
|
|
394
|
+
for (const key of Object.keys(definition.params)) {
|
|
395
|
+
/* object keys are strings, the graph keys its vertices by the id itself */
|
|
396
|
+
const parameter = node_id_1.NodeId.normalize(key);
|
|
397
|
+
for (const [target, edge] of this.config.dfg.outgoingEdges(parameter) ?? graph_1.NoEdges) {
|
|
398
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedByOnCall) || !args.has(target)) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const value = this.getAbstractValue(target, this.currentState);
|
|
402
|
+
if (value !== undefined) {
|
|
403
|
+
this.currentState.set(parameter, value);
|
|
404
|
+
/* the parameter is a definition like any other, so the body only reads it once it counts as assigned */
|
|
405
|
+
this.trace.set(parameter, this.currentState);
|
|
406
|
+
this.unassigned.delete(parameter);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
281
410
|
}
|
|
282
411
|
/** Gets each variable origin that has already been visited and whose assignment has already been processed */
|
|
283
412
|
getVariableOrigins(nodeId) {
|
|
@@ -290,32 +419,64 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
290
419
|
isUnsupportedFunctionCall(nodeId) {
|
|
291
420
|
return unsupported_functions_1.UnsupportedFunctions.isUnsupportedCall(this.getDataflowGraph(nodeId), this.config.dfg);
|
|
292
421
|
}
|
|
293
|
-
/**
|
|
422
|
+
/**
|
|
423
|
+
* We widen wherever the control flow comes back around, i.e. at the node a back edge leads to.
|
|
424
|
+
* That is what makes the iteration terminate, and it is the loop head whichever loop the code used:
|
|
425
|
+
* the condition of a `while`, the binding of a `for`, or the first statement of a `repeat`.
|
|
426
|
+
*/
|
|
294
427
|
isWideningPoint(nodeId) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
428
|
+
this.wideningPoints ??= this.findWideningPoints();
|
|
429
|
+
return this.wideningPoints.has(nodeId);
|
|
430
|
+
}
|
|
431
|
+
/** The targets of the back edges of the control flow graph, found with one depth-first search. */
|
|
432
|
+
findWideningPoints() {
|
|
433
|
+
const graph = this.config.controlFlow.graph;
|
|
434
|
+
const heads = new Set();
|
|
435
|
+
const onPath = new Set();
|
|
436
|
+
const done = new Set();
|
|
437
|
+
for (const start of this.startingPoints()) {
|
|
438
|
+
if (done.has(start)) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const stack = [stepFrom(graph, start)];
|
|
442
|
+
onPath.add(start);
|
|
443
|
+
while (stack.length > 0) {
|
|
444
|
+
const step = stack[stack.length - 1];
|
|
445
|
+
if (step.at >= step.successors.length) {
|
|
446
|
+
onPath.delete(step.node);
|
|
447
|
+
done.add(step.node);
|
|
448
|
+
stack.pop();
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
const next = step.successors[step.at++];
|
|
452
|
+
if (onPath.has(next)) {
|
|
453
|
+
/* the path leads back to a node it already runs through, so this is where the loop closes */
|
|
454
|
+
heads.add(next);
|
|
455
|
+
}
|
|
456
|
+
else if (!done.has(next)) {
|
|
457
|
+
onPath.add(next);
|
|
458
|
+
stack.push(stepFrom(graph, next));
|
|
459
|
+
}
|
|
460
|
+
}
|
|
301
461
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
462
|
+
return heads;
|
|
463
|
+
}
|
|
464
|
+
/** Everywhere the control flow may start: the program itself, and every function body, as nothing flows into one. */
|
|
465
|
+
startingPoints() {
|
|
466
|
+
const graph = this.config.controlFlow.graph;
|
|
467
|
+
const starts = [...this.config.controlFlow.entryPoints];
|
|
468
|
+
for (const [id] of graph.vertices(false)) {
|
|
469
|
+
starts.push(...graph.childrenOf(id) ?? control_flow_graph_1.NoNeighbors);
|
|
305
470
|
}
|
|
306
|
-
|
|
307
|
-
return origin.includes(built_in_proc_name_1.BuiltInProcName.ForLoop) || origin.includes(built_in_proc_name_1.BuiltInProcName.WhileLoop) || origin.includes(built_in_proc_name_1.BuiltInProcName.RepeatLoop);
|
|
471
|
+
return starts;
|
|
308
472
|
}
|
|
309
473
|
/**
|
|
310
474
|
* Checks whether a control flow graph vertex should be skipped during visitation.
|
|
311
|
-
*
|
|
475
|
+
* Every node has exactly one vertex, reached once its operands are evaluated, so nothing is skipped
|
|
476
|
+
* by default; overriding this lets an analysis ignore parts of the program.
|
|
312
477
|
*/
|
|
313
|
-
shouldSkipVertex(
|
|
314
|
-
|
|
315
|
-
// skip exit vertices of widening points
|
|
316
|
-
return control_flow_graph_1.CfgVertex.isMarker(vertex);
|
|
317
|
-
}
|
|
318
|
-
return !control_flow_graph_1.CfgVertex.isMarker(vertex) && !control_flow_graph_1.CfgVertex.isBlock(vertex) && control_flow_graph_1.CfgVertex.getEnd(vertex) !== undefined;
|
|
478
|
+
shouldSkipVertex(_vertex) {
|
|
479
|
+
return false;
|
|
319
480
|
}
|
|
320
481
|
/**
|
|
321
482
|
* Whether widening should be performed at a widening point.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataflowGraph } from '../../../dataflow/graph/graph';
|
|
2
2
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
3
3
|
import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
4
|
-
import
|
|
4
|
+
import { RAccess, type RNamedAccess } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-access';
|
|
5
5
|
import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
6
6
|
import type { DataFrameOperations, DataFrameShapeInferenceVisitor } from '../shape-inference';
|
|
7
7
|
/**
|