@eagleoutice/flowr 2.14.1 → 2.14.3
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 +142 -87
- package/abstract-interpretation/absint-visitor.d.ts +132 -25
- package/abstract-interpretation/absint-visitor.js +459 -99
- 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 +21 -8
- package/config.js +12 -5
- 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 -3
- 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 +114 -3
- package/dataflow/environments/default-builtin-config.js +137 -35
- 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 +3 -3
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- 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 +15 -6
- package/dataflow/info.js +0 -17
- package/dataflow/internal/control-flow.d.ts +114 -0
- package/dataflow/internal/control-flow.js +224 -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 +18 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +12 -1
- 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 +38 -30
- 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 +36 -8
- 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 +9 -4
- 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.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +11 -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 +13 -14
- 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 +50 -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 +20 -4
- 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 +41 -15
- 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 +33 -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 +17 -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-interface.js +1 -0
- 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 +311 -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 +1 -7
- package/project/dependency-version-space.js +9 -8
- package/project/flowr-analyzer-builder.d.ts +4 -4
- 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 +54 -13
- package/project/sigdb/reader.js +4 -3
- 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 +8 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +8 -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/node-id.d.ts +5 -1
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
- 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 -0
- 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 +24 -4
- 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
|
@@ -2,20 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractInterpretationVisitor = void 0;
|
|
4
4
|
const control_flow_graph_1 = require("../control-flow/control-flow-graph");
|
|
5
|
+
const simple_visitor_1 = require("../control-flow/simple-visitor");
|
|
5
6
|
const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
|
|
6
7
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
7
8
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
9
|
+
const graph_1 = require("../dataflow/graph/graph");
|
|
10
|
+
const edge_1 = require("../dataflow/graph/edge");
|
|
8
11
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
9
|
-
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
10
12
|
const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
|
-
const
|
|
13
|
+
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
14
|
const assert_1 = require("../util/assert");
|
|
13
15
|
const abstract_domain_1 = require("./domains/abstract-domain");
|
|
14
16
|
const unsupported_functions_1 = require("./unsupported-functions");
|
|
17
|
+
const r_argument_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
18
|
+
const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
19
|
+
const r_expression_list_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
20
|
+
const r_if_then_else_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
|
|
21
|
+
const r_pipe_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
|
|
22
|
+
const r_parameter_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
|
|
23
|
+
const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
24
|
+
function stepFrom(graph, node) {
|
|
25
|
+
return { node, successors: [...graph.successors(node)], at: 0 };
|
|
26
|
+
}
|
|
27
|
+
/** Whether two rounds of a fixpoint bound the same values, `undefined` standing for nothing known yet. */
|
|
28
|
+
function sameValues(a, b) {
|
|
29
|
+
return b !== undefined && a.length === b.length
|
|
30
|
+
&& a.every((value, at) => value === undefined ? b[at] === undefined : b[at] !== undefined && value.equals(b[at]));
|
|
31
|
+
}
|
|
15
32
|
/**
|
|
16
33
|
* A control flow graph visitor to perform abstract interpretation.
|
|
17
34
|
*
|
|
18
|
-
*
|
|
35
|
+
* The worklist below stays within the function it starts in: a function definition produces a closure and its
|
|
36
|
+
* body is a region of its own, which nothing flows into.
|
|
37
|
+
*
|
|
38
|
+
* Calls are not followed by default: flip {@link AbstractInterpretationVisitor#shouldEnterCall|shouldEnterCall()} to
|
|
39
|
+
* step into what a call dispatches to and continue with the state at the function's exit points.
|
|
40
|
+
* Condition semantics are not applied by default either, but everything needed for them is there:
|
|
41
|
+
* {@link AbstractInterpretationVisitor#getPredecessorState|getPredecessorState()} is handed the branch that was
|
|
42
|
+
* taken, and {@link BasicCfgGuidedVisitor#getDecidedConstructs|getDecidedConstructs()} names the construct a
|
|
43
|
+
* condition belongs to.
|
|
19
44
|
*/
|
|
20
45
|
class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
|
|
21
46
|
/**
|
|
@@ -31,15 +56,39 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
31
56
|
*/
|
|
32
57
|
stack = [];
|
|
33
58
|
/**
|
|
34
|
-
*
|
|
59
|
+
* The nodes a back edge of the control flow graph leads to, computed on demand.
|
|
60
|
+
* @see {@link AbstractInterpretationVisitor#isWideningPoint|isWideningPoint()}
|
|
35
61
|
*/
|
|
36
|
-
|
|
62
|
+
wideningPoints;
|
|
63
|
+
/**
|
|
64
|
+
* What leads to a vertex, without the call a body was entered from.
|
|
65
|
+
* {@link AbstractInterpretationVisitor#shouldSkipVertex|shouldSkipVertex()} is asked once per vertex, so
|
|
66
|
+
* an override of it has to say the same thing every time.
|
|
67
|
+
*/
|
|
68
|
+
predecessorsOf = new Map();
|
|
69
|
+
/** What the control flow may reach from a vertex, asked only by a read with several definitions. */
|
|
70
|
+
reachableFrom = new Map();
|
|
37
71
|
/**
|
|
38
|
-
*
|
|
72
|
+
* The state each vertex was left in when it was last visited, so a re-visit can tell whether anything moved.
|
|
73
|
+
* The trace cannot say that: entering a call seeds it before the parameters and the call are visited.
|
|
39
74
|
*/
|
|
40
|
-
|
|
75
|
+
lastState = new Map();
|
|
76
|
+
/**
|
|
77
|
+
* A set of nodes representing variable definitions that have already been visited but whose assignment has not yet been processed.
|
|
78
|
+
*/
|
|
79
|
+
unassigned = new Set();
|
|
80
|
+
/** The call a function body is currently being interpreted for, mapping the body's entry to it. */
|
|
81
|
+
enteredFrom = new Map();
|
|
82
|
+
/** The function definitions currently being interpreted, which is what makes a call back into one recursive. */
|
|
83
|
+
running = new Set();
|
|
84
|
+
/** The definitions that turned out to call themselves, which are the ones run more than once. */
|
|
85
|
+
recursive = new Set();
|
|
86
|
+
/** What a definition being interpreted was last seen to leave behind, which is what its own calls are worth. */
|
|
87
|
+
returns = new Map();
|
|
88
|
+
/** The calls that lead back into a definition still being interpreted, and the definition they reach. */
|
|
89
|
+
recursiveCalls = new Map();
|
|
41
90
|
constructor(config, stateDomain) {
|
|
42
|
-
super({ ...config, defaultVisitingOrder: 'forward'
|
|
91
|
+
super({ ...config, defaultVisitingOrder: 'forward' });
|
|
43
92
|
this.currentState = stateDomain.top();
|
|
44
93
|
}
|
|
45
94
|
/**
|
|
@@ -58,27 +107,38 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
58
107
|
else if (node === undefined) {
|
|
59
108
|
return;
|
|
60
109
|
}
|
|
61
|
-
|
|
110
|
+
const reached = this.recursiveCalls.get(node.info.id);
|
|
111
|
+
if (reached !== undefined) {
|
|
112
|
+
/* it is worth what the definition it reaches was last seen to leave behind, nothing in round one */
|
|
113
|
+
return this.returns.get(reached) ?? this.currentState.domain.bottom();
|
|
114
|
+
}
|
|
115
|
+
if (state?.has(node.info.id)) {
|
|
62
116
|
return state.get(node.info.id);
|
|
63
117
|
}
|
|
64
118
|
const vertex = this.getDataflowGraph(node.info.id);
|
|
65
119
|
const call = vertex_1.FunctionCallVertex.is(vertex) ? vertex : undefined;
|
|
66
120
|
const origins = Array.isArray(call?.origin) ? call.origin : [];
|
|
67
|
-
if (
|
|
121
|
+
if (r_symbol_1.RSymbol.is(node)) {
|
|
68
122
|
const values = this.getVariableOrigins(node.info.id)
|
|
69
123
|
.map(origin => (this.getAbstractState(origin)?.isBottom() ? this.currentState.domain.bottom() : state?.get(origin)));
|
|
70
124
|
if (values.length > 0 && values.every(assert_1.isNotUndefined)) {
|
|
71
125
|
return abstract_domain_1.AbstractDomain.joinAll(values);
|
|
72
126
|
}
|
|
73
127
|
}
|
|
74
|
-
else if (
|
|
128
|
+
else if (r_argument_1.RArgument.isWithValue(node)) {
|
|
75
129
|
return this.getAbstractValue(node.value, state);
|
|
76
130
|
}
|
|
77
|
-
else if (
|
|
131
|
+
else if (r_expression_list_1.RExpressionList.is(node) && node.children.length > 0) {
|
|
78
132
|
return this.getAbstractValue(node.children.at(-1), state);
|
|
79
133
|
}
|
|
134
|
+
else if (origins.includes(built_in_proc_name_1.BuiltInProcName.Return)) {
|
|
135
|
+
/* leaving with `return(x)` is worth what `x` is worth, which is what a function that does it exits with */
|
|
136
|
+
if (call?.args.length === 1 && call.args[0] !== r_function_call_1.EmptyArgument) {
|
|
137
|
+
return this.getAbstractValue(call.args[0].nodeId, state);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
80
140
|
else if (origins.includes(built_in_proc_name_1.BuiltInProcName.Pipe)) {
|
|
81
|
-
if (
|
|
141
|
+
if (r_pipe_1.RPipe.is(node) || r_binary_op_1.RBinaryOp.is(node)) {
|
|
82
142
|
return this.getAbstractValue(node.rhs, state);
|
|
83
143
|
}
|
|
84
144
|
else if (call?.args.length === 2 && call?.args[1] !== r_function_call_1.EmptyArgument) {
|
|
@@ -87,7 +147,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
87
147
|
}
|
|
88
148
|
else if (origins.includes(built_in_proc_name_1.BuiltInProcName.IfThenElse)) {
|
|
89
149
|
let values = [];
|
|
90
|
-
if (
|
|
150
|
+
if (r_if_then_else_1.RIfThenElse.is(node) && node.otherwise !== undefined) {
|
|
91
151
|
values = [node.then, node.otherwise].map(entry => this.getAbstractValue(entry, state));
|
|
92
152
|
}
|
|
93
153
|
else if (call?.args.every(arg => arg !== r_function_call_1.EmptyArgument) && call.args.length === 3) {
|
|
@@ -113,9 +173,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
113
173
|
* @returns The inferred abstract state at the end of the program
|
|
114
174
|
*/
|
|
115
175
|
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);
|
|
176
|
+
const states = this.config.controlFlow.exitPoints.map(node => this.trace.get(node)).filter(assert_1.isNotUndefined);
|
|
119
177
|
return abstract_domain_1.AbstractDomain.joinAll(states, this.currentState.bottom());
|
|
120
178
|
}
|
|
121
179
|
/**
|
|
@@ -129,17 +187,21 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
129
187
|
(0, assert_1.guard)(this.trace.size === 0, 'Abstract interpretation visitor has already been started');
|
|
130
188
|
super.start();
|
|
131
189
|
this.unassigned.clear();
|
|
190
|
+
this.lastState.clear();
|
|
132
191
|
}
|
|
133
192
|
startVisitor(start) {
|
|
134
193
|
this.stack = Array.from(start);
|
|
194
|
+
const queued = new Set(this.stack);
|
|
135
195
|
while (this.stack.length > 0) {
|
|
136
196
|
const current = this.stack.pop();
|
|
197
|
+
queued.delete(current);
|
|
137
198
|
if (!this.visitNode(current)) {
|
|
138
199
|
continue;
|
|
139
200
|
}
|
|
140
|
-
const successors = this.config.controlFlow.graph.
|
|
201
|
+
const successors = [...this.config.controlFlow.graph.successors(current)].reverse();
|
|
141
202
|
for (const next of successors) {
|
|
142
|
-
if (!
|
|
203
|
+
if (!queued.has(next)) { // prevent double entries in working list
|
|
204
|
+
queued.add(next);
|
|
143
205
|
this.stack.push(next);
|
|
144
206
|
}
|
|
145
207
|
}
|
|
@@ -147,65 +209,45 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
147
209
|
}
|
|
148
210
|
visitNode(vertexId) {
|
|
149
211
|
const vertex = this.getCfgVertex(vertexId);
|
|
150
|
-
// skip exit vertices of widening points and entry vertices of complex nodes
|
|
151
212
|
if (vertex === undefined || this.shouldSkipVertex(vertex)) {
|
|
152
213
|
return true;
|
|
153
214
|
}
|
|
154
215
|
// retrieve new abstract state by joining states of predecessor nodes
|
|
155
|
-
const
|
|
156
|
-
const
|
|
216
|
+
const nodeId = control_flow_graph_1.CfgVertex.getId(vertex);
|
|
217
|
+
const predecessors = this.getPredecessors(nodeId);
|
|
218
|
+
const predecessorStates = predecessors.map(pred => this.getPredecessorState(pred)).filter(assert_1.isNotUndefined);
|
|
157
219
|
this.currentState = abstract_domain_1.AbstractDomain.joinAll(predecessorStates, this.currentState.top());
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.trace.set(nodeId, this.currentState);
|
|
166
|
-
const visitedCount = this.visited.get(nodeId) ?? 0;
|
|
167
|
-
this.visited.set(nodeId, visitedCount + 1);
|
|
168
|
-
// continue visiting after widening point if visited for the first time or the state changed
|
|
169
|
-
return visitedCount === 0 || !oldState?.equals(this.currentState);
|
|
220
|
+
const oldState = this.lastState.get(nodeId);
|
|
221
|
+
/*
|
|
222
|
+
* A widening point is a node of the program like any other: the head of a `while` is its condition, of a
|
|
223
|
+
* `repeat` its first statement. The iteration is bounded here, the node still says what it says.
|
|
224
|
+
*/
|
|
225
|
+
if (oldState !== undefined && this.isWideningPoint(nodeId) && this.shouldWiden(vertex)) {
|
|
226
|
+
this.currentState = oldState.widen(this.currentState);
|
|
170
227
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.currentState = this.currentState.top();
|
|
176
|
-
}
|
|
177
|
-
this.trace.set(nodeId, this.currentState);
|
|
178
|
-
const predecessorVisits = predecessors.map(pred => this.visited.get(pred) ?? 0);
|
|
179
|
-
const visitedCount = this.visited.get(nodeId) ?? 0;
|
|
180
|
-
this.visited.set(nodeId, visitedCount + 1);
|
|
181
|
-
// continue visiting if vertex is not a join vertex or number of visits of predecessors is the same
|
|
182
|
-
return predecessors.length <= 1 || this.stack.length === 0 || predecessorVisits.every(visits => visits === predecessorVisits[0]);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
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
|
-
}
|
|
228
|
+
this.onVisitNode(vertexId);
|
|
229
|
+
// discard the inferred abstract state when encountering unsupported function calls
|
|
230
|
+
if (this.isUnsupportedFunctionCall(nodeId)) {
|
|
231
|
+
this.currentState = this.currentState.top();
|
|
196
232
|
}
|
|
233
|
+
this.trace.set(nodeId, this.currentState);
|
|
234
|
+
this.lastState.set(nodeId, this.currentState);
|
|
235
|
+
const visitedCount = this.visited.get(nodeId) ?? 0;
|
|
236
|
+
this.visited.set(nodeId, visitedCount + 1);
|
|
237
|
+
/*
|
|
238
|
+
* Carry on wherever the vertex is new or its state moved. Waiting for the branches of a join to arrive
|
|
239
|
+
* in step instead drops the rest of the program whenever they do not, three arms in a loop say.
|
|
240
|
+
*/
|
|
241
|
+
return visitedCount === 0 || !oldState?.equals(this.currentState);
|
|
197
242
|
}
|
|
198
243
|
onDispatchFunctionCallOrigin(call, origin) {
|
|
199
244
|
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
|
-
}
|
|
245
|
+
/*
|
|
246
|
+
* A replacement is the last thing its statement does (the target and the value are evaluated first),
|
|
247
|
+
* so it is handled where it is visited; the `<-` it was rewritten from has no vertex to defer to.
|
|
248
|
+
*/
|
|
249
|
+
this.onReplacementCall({ call, ...this.getSourceAndTarget(call) });
|
|
250
|
+
return;
|
|
209
251
|
}
|
|
210
252
|
super.onDispatchFunctionCallOrigin(call, origin);
|
|
211
253
|
switch (origin) {
|
|
@@ -218,7 +260,6 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
218
260
|
case built_in_proc_name_1.BuiltInProcName.Assignment:
|
|
219
261
|
case built_in_proc_name_1.BuiltInProcName.AssignmentLike:
|
|
220
262
|
case built_in_proc_name_1.BuiltInProcName.TableAssignment:
|
|
221
|
-
case built_in_proc_name_1.BuiltInProcName.Replacement:
|
|
222
263
|
case built_in_proc_name_1.BuiltInProcName.Access:
|
|
223
264
|
case built_in_proc_name_1.BuiltInProcName.Pipe:
|
|
224
265
|
case built_in_proc_name_1.BuiltInProcName.Break:
|
|
@@ -232,6 +273,23 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
232
273
|
if (!this.trace.has(vertex.id)) {
|
|
233
274
|
this.unassigned.add(vertex.id);
|
|
234
275
|
}
|
|
276
|
+
/*
|
|
277
|
+
* `bindParameters` hands the arguments over before the function is entered, so a parameter still without
|
|
278
|
+
* a value is one the call passed nothing for and is worth the default it names. That default runs before
|
|
279
|
+
* the body, so standing on the parameter is the moment to read it.
|
|
280
|
+
*/
|
|
281
|
+
if (this.currentState.has(vertex.id)) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const declaration = this.getNormalizedAst(this.getNormalizedAst(vertex.id)?.info.parent);
|
|
285
|
+
if (!r_parameter_1.RParameter.isWithDefault(declaration)) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const value = this.getAbstractValue(declaration.defaultValue, this.currentState);
|
|
289
|
+
if (value !== undefined) {
|
|
290
|
+
this.currentState.set(vertex.id, value);
|
|
291
|
+
this.unassigned.delete(vertex.id);
|
|
292
|
+
}
|
|
235
293
|
}
|
|
236
294
|
onAssignmentCall({ target, source }) {
|
|
237
295
|
if (target === undefined || source === undefined) {
|
|
@@ -262,60 +320,362 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
|
|
|
262
320
|
* @protected
|
|
263
321
|
*/
|
|
264
322
|
onFunctionCall(_data) { }
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Everything the control flow may come from to reach this vertex, together with the branch it took to get here.
|
|
325
|
+
* Skipped vertices hold no state of their own, so what led into them is reported instead.
|
|
326
|
+
*/
|
|
327
|
+
getPredecessors(vertexId) {
|
|
328
|
+
let result = this.predecessorsOf.get(vertexId);
|
|
329
|
+
if (result === undefined) {
|
|
330
|
+
result = this.collectPredecessors(vertexId);
|
|
331
|
+
this.predecessorsOf.set(vertexId, result);
|
|
332
|
+
}
|
|
333
|
+
/* a body has no predecessor of its own, so what runs before it is the call we stepped in from */
|
|
334
|
+
const enteredFrom = this.enteredFrom.get(vertexId);
|
|
335
|
+
return enteredFrom === undefined ? result : [...result, { id: enteredFrom }];
|
|
336
|
+
}
|
|
337
|
+
/** What the control flow graph itself says leads here, which is the same however often it is asked. */
|
|
338
|
+
collectPredecessors(vertexId) {
|
|
339
|
+
const result = [];
|
|
340
|
+
for (const [id, edge] of this.config.controlFlow.graph.ingoingEdges(vertexId) ?? graph_1.NoEdges) {
|
|
341
|
+
const branch = control_flow_graph_1.CfgEdge.isControlDependency(edge) ? edge : undefined;
|
|
342
|
+
const vertex = this.getCfgVertex(id);
|
|
270
343
|
if (vertex === undefined) {
|
|
271
|
-
|
|
344
|
+
continue;
|
|
272
345
|
}
|
|
273
346
|
else if (this.shouldSkipVertex(vertex)) {
|
|
274
|
-
|
|
347
|
+
/* the branch closest to us is the one that decided we get here at all, so it wins */
|
|
348
|
+
result.push(...this.collectPredecessors(id).map(pred => branch ? { ...pred, branch } : pred));
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
result.push({ id, branch });
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* The abstract state one predecessor contributes, joined into the state at the current vertex.
|
|
358
|
+
*
|
|
359
|
+
* By default, this is the state as the predecessor left it. Override it to apply condition semantics:
|
|
360
|
+
* on the then-branch of `if(u) a else b` the predecessor is `u` and `branch.when` is `true`, so `u` held.
|
|
361
|
+
*/
|
|
362
|
+
getPredecessorState({ id }) {
|
|
363
|
+
return this.trace.get(id);
|
|
364
|
+
}
|
|
365
|
+
visitFunctionCall(call) {
|
|
366
|
+
super.visitFunctionCall(call);
|
|
367
|
+
if (this.shouldEnterCall(call)) {
|
|
368
|
+
this.currentState = this.enterCall(call.id) ?? this.currentState;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Whether to step into what the given call dispatches to, which is what makes the analysis interprocedural.
|
|
373
|
+
* Defaults to `abstractInterpretation.followCalls`; override it to decide per call. A call that reaches no
|
|
374
|
+
* definition is left alone either way.
|
|
375
|
+
*/
|
|
376
|
+
shouldEnterCall(_call) {
|
|
377
|
+
return this.config.ctx.config.abstractInterpretation.followCalls;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The function definitions the given call may dispatch to.
|
|
381
|
+
* Built-in functions have no definition in the source, so they are not part of this.
|
|
382
|
+
*/
|
|
383
|
+
getCallTargets(callId) {
|
|
384
|
+
const targets = control_flow_graph_1.CfgVertex.getCallTargets(this.getCfgVertex(callId));
|
|
385
|
+
return targets === undefined ? control_flow_graph_1.NoNeighbors : [...targets];
|
|
386
|
+
}
|
|
387
|
+
/** Where a function definition starts, i.e. the first thing that runs when it is called. */
|
|
388
|
+
getFunctionEntry(defId) {
|
|
389
|
+
const def = this.getDataflowGraph(defId);
|
|
390
|
+
return vertex_1.FunctionDefinitionVertex.is(def) ? def.subflow.cfgEntry ?? def.subflow.entryPoint : undefined;
|
|
391
|
+
}
|
|
392
|
+
/** Where a function definition is left, i.e. its last expressions and `return` calls. */
|
|
393
|
+
getFunctionExits(defId) {
|
|
394
|
+
const def = this.getDataflowGraph(defId);
|
|
395
|
+
return vertex_1.FunctionDefinitionVertex.is(def) ? def.exitPoints.map(exit => exit.nodeId) : control_flow_graph_1.NoNeighbors;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Runs the bodies the given call dispatches to, starting from the state at the call, and returns the state
|
|
399
|
+
* control comes back with: the states at their exit points joined.
|
|
400
|
+
* A call already being interpreted is not entered again, so recursion stops at the second entry.
|
|
401
|
+
* @returns the state at the exit points, or `undefined` if the call reaches nothing to step into
|
|
402
|
+
*/
|
|
403
|
+
enterCall(callId) {
|
|
404
|
+
const states = [];
|
|
405
|
+
const values = [];
|
|
406
|
+
const outerState = this.currentState;
|
|
407
|
+
/* the entry picks its state up from the call, which is what makes the arguments visible in the body */
|
|
408
|
+
this.trace.set(callId, outerState);
|
|
409
|
+
/*
|
|
410
|
+
* The call is worth something only if every way out of every function it reaches is: one that leaves a
|
|
411
|
+
* frame on one path and something else on another says as little as `if(u) df else 42` does.
|
|
412
|
+
*/
|
|
413
|
+
let known = true;
|
|
414
|
+
for (const def of this.getCallTargets(callId)) {
|
|
415
|
+
const entry = this.getFunctionEntry(def);
|
|
416
|
+
if (entry === undefined) {
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
else if (this.running.has(def)) {
|
|
420
|
+
/* it is worth what it leaves behind, which is only known once it is done; see `getAbstractValue` */
|
|
421
|
+
this.recursive.add(def);
|
|
422
|
+
this.recursiveCalls.set(callId, def);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
this.running.add(def);
|
|
426
|
+
const left = this.runFunction(callId, def, entry, outerState);
|
|
427
|
+
this.running.delete(def);
|
|
428
|
+
this.recursive.delete(def);
|
|
429
|
+
this.returns.delete(def);
|
|
430
|
+
states.push(...left.states);
|
|
431
|
+
if (left.value === undefined) {
|
|
432
|
+
known = false;
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
values.push(left.value);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
this.currentState = outerState;
|
|
439
|
+
if (states.length === 0) {
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
const returned = abstract_domain_1.AbstractDomain.joinAll(states);
|
|
443
|
+
if (known && values.length > 0) {
|
|
444
|
+
/* what the call is worth is what its function leaves behind at its exits */
|
|
445
|
+
returned.set(callId, abstract_domain_1.AbstractDomain.joinAll(values));
|
|
446
|
+
}
|
|
447
|
+
return returned;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Runs one definition for one call until what it leaves behind stops moving.
|
|
451
|
+
*
|
|
452
|
+
* One that does not call itself is run once. One that does is a fixpoint in two halves: what it leaves
|
|
453
|
+
* behind, which its own calls read, and what its parameters are worth, which those calls decide, since
|
|
454
|
+
* `shrink(head(x, nrow(x) - 1))` hands over fewer rows than it was given. Both are widened so they stop.
|
|
455
|
+
* @returns the states at the exit points, and what the definition leaves behind if every way out says
|
|
456
|
+
*/
|
|
457
|
+
runFunction(callId, def, entry, outerState) {
|
|
458
|
+
const threshold = this.config.ctx.config.abstractInterpretation.wideningThreshold;
|
|
459
|
+
/* the counts drive the widening within the body, and belong to this call rather than to the program */
|
|
460
|
+
const counts = this.regionVisits(entry);
|
|
461
|
+
let settled = undefined;
|
|
462
|
+
let bound = undefined;
|
|
463
|
+
for (let round = 0;; round++) {
|
|
464
|
+
/* the parameters are the definition's own, so they are bound in a state of its own */
|
|
465
|
+
const inner = outerState.create(outerState.value);
|
|
466
|
+
this.currentState = inner;
|
|
467
|
+
this.bindParameters(callId, def);
|
|
468
|
+
/*
|
|
469
|
+
* The calls a definition makes to itself enter it too, so its parameters are worth what either they
|
|
470
|
+
* or the outer call say. Widening them is what stops the rounds: a recursion that keeps adding to
|
|
471
|
+
* what it is handed would otherwise be described by the first step it takes.
|
|
472
|
+
*/
|
|
473
|
+
for (const [call, reached] of this.recursiveCalls) {
|
|
474
|
+
if (reached === def) {
|
|
475
|
+
this.bindParameters(call, def, round > 0 ? 'widen' : 'join');
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const handed = this.parameterValues(def);
|
|
479
|
+
this.trace.set(callId, inner);
|
|
480
|
+
this.enteredFrom.set(entry, callId);
|
|
481
|
+
/* what a recursive call is worth is no part of the state, so the traversal has to be made to re-read */
|
|
482
|
+
if (round > 0) {
|
|
483
|
+
for (const id of this.reachableSet(entry)) {
|
|
484
|
+
this.lastState.delete(id);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const outerStack = this.stack;
|
|
488
|
+
this.startVisitor([entry]);
|
|
489
|
+
this.stack = outerStack;
|
|
490
|
+
this.enteredFrom.delete(entry);
|
|
491
|
+
const states = [];
|
|
492
|
+
const exits = [];
|
|
493
|
+
let complete = true;
|
|
494
|
+
for (const exit of this.getFunctionExits(def)) {
|
|
495
|
+
const state = this.trace.get(exit);
|
|
496
|
+
if (state === undefined) {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
states.push(state);
|
|
500
|
+
const value = this.getAbstractValue(exit, state);
|
|
501
|
+
if (value === undefined) {
|
|
502
|
+
complete = false;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
exits.push(value);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const left = complete && exits.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(exits) : undefined;
|
|
509
|
+
if (!this.recursive.has(def)) {
|
|
510
|
+
this.restoreVisits(counts);
|
|
511
|
+
return { states, value: left };
|
|
512
|
+
}
|
|
513
|
+
else if (left === undefined) {
|
|
514
|
+
/* one way out of the recursion says nothing, so neither does the recursion */
|
|
515
|
+
this.restoreVisits(counts);
|
|
516
|
+
return { states, value: undefined };
|
|
517
|
+
}
|
|
518
|
+
/* widening bounds the rounds, the same way it bounds the rounds of a loop */
|
|
519
|
+
const next = settled !== undefined && round >= threshold ? settled.widen(left) : left;
|
|
520
|
+
const moved = settled === undefined || !next.equals(settled) || !sameValues(handed, bound);
|
|
521
|
+
settled = next;
|
|
522
|
+
bound = handed;
|
|
523
|
+
this.returns.set(def, next);
|
|
524
|
+
if (!moved) {
|
|
525
|
+
this.restoreVisits(counts);
|
|
526
|
+
return { states, value: settled };
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
/** What the parameters of a definition are worth in the state they were just bound in. */
|
|
531
|
+
parameterValues(defId) {
|
|
532
|
+
const definition = this.getDataflowGraph(defId);
|
|
533
|
+
if (!vertex_1.FunctionDefinitionVertex.is(definition)) {
|
|
534
|
+
return [];
|
|
535
|
+
}
|
|
536
|
+
return Object.keys(definition.params).map(key => this.currentState.get(node_id_1.NodeId.normalize(key)));
|
|
537
|
+
}
|
|
538
|
+
/** How often each vertex of a function has been visited, so one call does not widen the next one early. */
|
|
539
|
+
regionVisits(entry) {
|
|
540
|
+
const counts = new Map();
|
|
541
|
+
for (const id of this.reachableSet(entry)) {
|
|
542
|
+
counts.set(id, this.visited.get(id));
|
|
543
|
+
}
|
|
544
|
+
return counts;
|
|
545
|
+
}
|
|
546
|
+
/** Puts the visit counts back as they were before a function was run for one call. */
|
|
547
|
+
restoreVisits(counts) {
|
|
548
|
+
for (const [id, count] of counts) {
|
|
549
|
+
if (count === undefined) {
|
|
550
|
+
this.visited.delete(id);
|
|
275
551
|
}
|
|
276
552
|
else {
|
|
277
|
-
|
|
553
|
+
this.visited.set(id, count);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Hand the arguments of the call to the parameters of the function it enters, so the body can read them.
|
|
559
|
+
* Only the arguments of this very call are used, whichever other calls the function has.
|
|
560
|
+
*/
|
|
561
|
+
bindParameters(callId, defId, add) {
|
|
562
|
+
const call = this.getDataflowGraph(callId);
|
|
563
|
+
const definition = this.getDataflowGraph(defId);
|
|
564
|
+
if (!vertex_1.FunctionCallVertex.is(call) || !vertex_1.FunctionDefinitionVertex.is(definition)) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const args = new Set(call.args.filter(graph_1.FunctionArgument.isNotEmpty).map(arg => arg.nodeId));
|
|
568
|
+
for (const key of Object.keys(definition.params)) {
|
|
569
|
+
/* object keys are strings, the graph keys its vertices by the id itself */
|
|
570
|
+
const parameter = node_id_1.NodeId.normalize(key);
|
|
571
|
+
for (const [target, edge] of this.config.dfg.outgoingEdges(parameter) ?? graph_1.NoEdges) {
|
|
572
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedByOnCall) || !args.has(target)) {
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
/* a call that is not the one being entered is read where it stands, not from the state here */
|
|
576
|
+
let value = add === undefined ? this.getAbstractValue(target, this.currentState) : this.getAbstractValue(target);
|
|
577
|
+
const previous = add === undefined ? undefined : this.currentState.get(parameter);
|
|
578
|
+
if (value !== undefined && previous !== undefined) {
|
|
579
|
+
value = (add === 'widen' ? previous.widen(value) : previous.join(value));
|
|
580
|
+
}
|
|
581
|
+
if (value !== undefined) {
|
|
582
|
+
this.currentState.set(parameter, value);
|
|
583
|
+
/* the parameter is a definition like any other, so the body only reads it once it counts as assigned */
|
|
584
|
+
this.trace.set(parameter, this.currentState);
|
|
585
|
+
this.unassigned.delete(parameter);
|
|
586
|
+
}
|
|
278
587
|
}
|
|
279
|
-
}
|
|
280
|
-
.toArray() ?? [];
|
|
588
|
+
}
|
|
281
589
|
}
|
|
282
590
|
/** Gets each variable origin that has already been visited and whose assignment has already been processed */
|
|
283
591
|
getVariableOrigins(nodeId) {
|
|
284
|
-
|
|
592
|
+
const origins = df_helper_1.Dataflow.origin(this.config.dfg, nodeId)
|
|
285
593
|
?.filter(origin => origin.type === 0 /* OriginType.ReadVariableOrigin */)
|
|
286
594
|
.map(origin => origin.id)
|
|
287
595
|
.filter(origin => this.trace.has(origin) && !this.unassigned.has(origin)) ?? [];
|
|
596
|
+
/*
|
|
597
|
+
* A read with a single definition takes it whatever the control flow does. One with several only sees
|
|
598
|
+
* those that can reach it: `x` within `for(i in 1:nrow(x)) x$a[i] <- 1` is a definition of the `x` in
|
|
599
|
+
* the head of the loop, but the head runs before the body ever does.
|
|
600
|
+
*/
|
|
601
|
+
return origins.length > 1 ? origins.filter(origin => this.reaches(origin, nodeId)) : origins;
|
|
602
|
+
}
|
|
603
|
+
/** Whether the control flow may get from one vertex to another, answered from one traversal per source. */
|
|
604
|
+
reaches(from, to) {
|
|
605
|
+
return this.reachableSet(from).has(to);
|
|
606
|
+
}
|
|
607
|
+
/** Everything the control flow may reach from a vertex, walked once per source and kept. */
|
|
608
|
+
reachableSet(from) {
|
|
609
|
+
let reachable = this.reachableFrom.get(from);
|
|
610
|
+
if (reachable === undefined) {
|
|
611
|
+
reachable = (0, simple_visitor_1.visitCfgInOrder)(this.config.controlFlow.graph, [from], () => { });
|
|
612
|
+
this.reachableFrom.set(from, reachable);
|
|
613
|
+
}
|
|
614
|
+
return reachable;
|
|
288
615
|
}
|
|
289
616
|
/** Checks whether a node represents a unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...) */
|
|
290
617
|
isUnsupportedFunctionCall(nodeId) {
|
|
291
618
|
return unsupported_functions_1.UnsupportedFunctions.isUnsupportedCall(this.getDataflowGraph(nodeId), this.config.dfg);
|
|
292
619
|
}
|
|
293
|
-
/**
|
|
620
|
+
/**
|
|
621
|
+
* We widen wherever the control flow comes back around, i.e. at the node a back edge leads to.
|
|
622
|
+
* That is what makes the iteration terminate, and it is the loop head whichever loop the code used:
|
|
623
|
+
* the condition of a `while`, the binding of a `for`, or the first statement of a `repeat`.
|
|
624
|
+
*/
|
|
294
625
|
isWideningPoint(nodeId) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
626
|
+
this.wideningPoints ??= this.findWideningPoints();
|
|
627
|
+
return this.wideningPoints.has(nodeId);
|
|
628
|
+
}
|
|
629
|
+
/** The targets of the back edges of the control flow graph, found with one depth-first search. */
|
|
630
|
+
findWideningPoints() {
|
|
631
|
+
const graph = this.config.controlFlow.graph;
|
|
632
|
+
const heads = new Set();
|
|
633
|
+
const onPath = new Set();
|
|
634
|
+
const done = new Set();
|
|
635
|
+
for (const start of this.startingPoints()) {
|
|
636
|
+
if (done.has(start)) {
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
const stack = [stepFrom(graph, start)];
|
|
640
|
+
onPath.add(start);
|
|
641
|
+
while (stack.length > 0) {
|
|
642
|
+
const step = stack[stack.length - 1];
|
|
643
|
+
if (step.at >= step.successors.length) {
|
|
644
|
+
onPath.delete(step.node);
|
|
645
|
+
done.add(step.node);
|
|
646
|
+
stack.pop();
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
const next = step.successors[step.at++];
|
|
650
|
+
if (onPath.has(next)) {
|
|
651
|
+
/* the path leads back to a node it already runs through, so this is where the loop closes */
|
|
652
|
+
heads.add(next);
|
|
653
|
+
}
|
|
654
|
+
else if (!done.has(next)) {
|
|
655
|
+
onPath.add(next);
|
|
656
|
+
stack.push(stepFrom(graph, next));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
301
659
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
660
|
+
return heads;
|
|
661
|
+
}
|
|
662
|
+
/** Everywhere the control flow may start: the program itself, and every function body, as nothing flows into one. */
|
|
663
|
+
startingPoints() {
|
|
664
|
+
const graph = this.config.controlFlow.graph;
|
|
665
|
+
const starts = [...this.config.controlFlow.entryPoints];
|
|
666
|
+
/* asking the control flow for all of its vertices copies it out of the dataflow graph, which already has them */
|
|
667
|
+
for (const [id] of this.config.dfg.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
668
|
+
starts.push(...graph.childrenOf(id) ?? control_flow_graph_1.NoNeighbors);
|
|
305
669
|
}
|
|
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);
|
|
670
|
+
return starts;
|
|
308
671
|
}
|
|
309
672
|
/**
|
|
310
673
|
* Checks whether a control flow graph vertex should be skipped during visitation.
|
|
311
|
-
*
|
|
674
|
+
* Every node has exactly one vertex, reached once its operands are evaluated, so nothing is skipped
|
|
675
|
+
* by default; overriding this lets an analysis ignore parts of the program.
|
|
312
676
|
*/
|
|
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;
|
|
677
|
+
shouldSkipVertex(_vertex) {
|
|
678
|
+
return false;
|
|
319
679
|
}
|
|
320
680
|
/**
|
|
321
681
|
* Whether widening should be performed at a widening point.
|