@eagleoutice/flowr 2.14.0 → 2.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -91
- package/abstract-interpretation/absint-visitor.d.ts +91 -25
- package/abstract-interpretation/absint-visitor.js +235 -74
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
- package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
- package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
- package/abstract-interpretation/data-frame/resolve-args.js +6 -4
- package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
- package/abstract-interpretation/domains/partial-product-domain.js +1 -1
- package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-range-domain.js +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
- package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
- package/benchmark/calibration.d.ts +18 -11
- package/benchmark/calibration.js +37 -27
- package/benchmark/slicer.d.ts +9 -2
- package/benchmark/slicer.js +44 -37
- package/benchmark/stats/count-comments.d.ts +16 -0
- package/benchmark/stats/count-comments.js +30 -0
- package/benchmark/stats/print.js +2 -0
- package/benchmark/stats/size-of.d.ts +7 -3
- package/benchmark/stats/size-of.js +7 -3
- package/benchmark/stats/stats.d.ts +7 -0
- package/benchmark/summarizer/first-phase/process.js +2 -19
- package/benchmark/summarizer/second-phase/graph.js +13 -3
- package/benchmark/summarizer/second-phase/process.js +2 -0
- package/cli/benchmark-app.js +4 -1
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +2 -2
- package/cli/common/options.d.ts +5 -0
- package/cli/common/options.js +1 -0
- package/cli/common/scripts-info.d.ts +5 -0
- package/cli/repl/commands/repl-dataflow.js +70 -27
- package/cli/repl/core.d.ts +1 -1
- package/cli/repl/core.js +1 -1
- package/cli/repl/execute.d.ts +2 -2
- package/cli/repl/execute.js +2 -2
- package/cli/repl/parser/slice-query-parser.js +2 -1
- package/cli/repl/server/connection.d.ts +4 -0
- package/cli/repl/server/connection.js +19 -16
- package/cli/repl/server/messages/message-analysis.d.ts +1 -1
- package/config.d.ts +6 -0
- package/config.js +12 -9
- package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
- package/control-flow/basic-cfg-guided-visitor.js +37 -24
- package/control-flow/cfg-dead-code.js +44 -33
- package/control-flow/cfg-properties.js +2 -2
- package/control-flow/cfg-simplification.js +6 -5
- package/control-flow/cfg-to-basic-blocks.js +11 -13
- package/control-flow/control-flow-graph.d.ts +179 -189
- package/control-flow/control-flow-graph.js +400 -263
- package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
- package/control-flow/dfg-cfg-guided-visitor.js +17 -13
- package/control-flow/diff-cfg.js +6 -14
- package/control-flow/happens-before.js +5 -4
- package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
- package/control-flow/semantic-cfg-guided-visitor.js +6 -26
- package/control-flow/simple-visitor.js +14 -15
- package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
- package/control-flow/useless-loop.js +18 -14
- package/core/steps/all/core/20-dataflow.d.ts +1 -3
- package/core/steps/pipeline/default-pipelines.d.ts +141 -157
- package/dataflow/cluster.js +7 -0
- package/dataflow/environments/apply-kill.d.ts +6 -0
- package/dataflow/environments/apply-kill.js +64 -32
- package/dataflow/environments/built-in-props.d.ts +10 -2
- package/dataflow/environments/built-in-props.js +9 -1
- package/dataflow/environments/built-in.d.ts +6 -3
- package/dataflow/environments/built-in.js +8 -5
- package/dataflow/environments/clone.d.ts +3 -3
- package/dataflow/environments/clone.js +5 -5
- package/dataflow/environments/default-builtin-config.d.ts +188 -8
- package/dataflow/environments/default-builtin-config.js +112 -39
- package/dataflow/environments/environment.d.ts +9 -1
- package/dataflow/environments/environment.js +25 -7
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/identifier.js +4 -1
- package/dataflow/environments/query-fn-props.d.ts +6 -0
- package/dataflow/environments/query-fn-props.js +20 -0
- package/dataflow/environments/resolve-by-name.d.ts +7 -0
- package/dataflow/environments/resolve-by-name.js +26 -2
- package/dataflow/environments/resolve-helper.d.ts +3 -1
- package/dataflow/environments/resolve-helper.js +2 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
- package/dataflow/eval/resolve/alias-tracking.js +2 -2
- package/dataflow/eval/resolve/match-arguments.js +7 -5
- package/dataflow/eval/resolve/node-value.d.ts +3 -1
- package/dataflow/eval/resolve/node-value.js +12 -0
- package/dataflow/eval/resolve/resolve-argument.js +5 -4
- package/dataflow/eval/resolve/resolve-operators.js +10 -7
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +5 -5
- package/dataflow/eval/resolve/resolve.js +3 -2
- package/dataflow/eval/values/general.js +8 -5
- package/dataflow/extractor.d.ts +1 -4
- package/dataflow/extractor.js +11 -10
- package/dataflow/fn/exceptions-of-function.d.ts +6 -2
- package/dataflow/fn/exceptions-of-function.js +85 -38
- package/dataflow/fn/strict-function.d.ts +40 -0
- package/dataflow/fn/strict-function.js +339 -0
- package/dataflow/graph/call-graph.js +2 -2
- package/dataflow/graph/df-helper.d.ts +17 -2
- package/dataflow/graph/df-helper.js +19 -3
- package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +19 -2
- package/dataflow/graph/edge.d.ts +38 -2
- package/dataflow/graph/edge.js +32 -2
- package/dataflow/graph/graph.d.ts +32 -5
- package/dataflow/graph/graph.js +65 -4
- package/dataflow/graph/match-args.d.ts +69 -0
- package/dataflow/graph/match-args.js +167 -0
- package/dataflow/info.d.ts +40 -0
- package/dataflow/info.js +28 -1
- package/dataflow/internal/control-flow.d.ts +102 -0
- package/dataflow/internal/control-flow.js +200 -0
- package/dataflow/internal/linker.d.ts +6 -31
- package/dataflow/internal/linker.js +24 -81
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +97 -33
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
- package/dataflow/internal/process/functions/call/common.js +5 -6
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
- package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
- package/dataflow/internal/process/functions/call/nse.js +6 -1
- package/dataflow/internal/process/functions/call/quoted.js +2 -2
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
- package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/process-argument.js +12 -4
- package/dataflow/internal/process/functions/process-parameter.js +13 -0
- package/dataflow/internal/process/process-named-call.d.ts +2 -2
- package/dataflow/internal/process/process-named-call.js +9 -7
- package/documentation/data/server/doc-data-server-messages.js +4 -4
- package/documentation/doc-readme.js +45 -0
- package/documentation/doc-util/doc-cfg.d.ts +8 -7
- package/documentation/doc-util/doc-cfg.js +10 -10
- package/documentation/doc-util/doc-playground.d.ts +12 -0
- package/documentation/doc-util/doc-playground.js +21 -0
- package/documentation/doc-util/doc-query.d.ts +4 -1
- package/documentation/doc-util/doc-query.js +4 -2
- package/documentation/wiki-absint.d.ts +3 -4
- package/documentation/wiki-absint.js +12 -5
- package/documentation/wiki-analyzer.js +2 -2
- package/documentation/wiki-cfg.js +101 -106
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +85 -53
- package/documentation/wiki-linter.js +16 -1
- package/documentation/wiki-linting-and-testing.js +1 -16
- package/documentation/wiki-mk/doc-maker.js +6 -4
- package/documentation/wiki-query.js +67 -4
- package/documentation/wiki-signature-database.js +28 -2
- package/linter/linter-fix.d.ts +16 -0
- package/linter/linter-fix.js +104 -0
- package/linter/linter-format.d.ts +18 -1
- package/linter/linter-format.js +31 -1
- package/linter/linter-output.js +47 -11
- package/linter/linter-rules.d.ts +64 -9
- package/linter/linter-rules.js +5 -1
- package/linter/rules/absolute-path.js +4 -2
- package/linter/rules/dataframe-access-validation.js +6 -7
- package/linter/rules/deprecated-functions.d.ts +107 -10
- package/linter/rules/deprecated-functions.js +309 -23
- package/linter/rules/file-path-validity.js +5 -4
- package/linter/rules/function-finder-util.d.ts +6 -0
- package/linter/rules/function-finder-util.js +21 -13
- package/linter/rules/naming-convention.js +1 -1
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/stop-with-call-arg.js +2 -2
- package/linter/rules/unclosed-connection.d.ts +44 -0
- package/linter/rules/unclosed-connection.js +200 -0
- package/linter/rules/undefined-symbol-util.js +6 -4
- package/linter/rules/undefined-symbol.js +2 -2
- package/linter/rules/unused-definition.js +8 -4
- package/linter/rules/unused-import.d.ts +60 -0
- package/linter/rules/unused-import.js +179 -0
- package/package.json +5 -8
- package/project/attached-packages.js +2 -1
- package/project/cache/flowr-analyzer-cache.d.ts +2 -5
- package/project/cache/flowr-analyzer-cache.js +4 -7
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
- package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
- package/project/cache/flowr-cache.d.ts +9 -0
- package/project/cache/flowr-cache.js +19 -0
- package/project/context/flowr-analyzer-context.d.ts +7 -3
- package/project/context/flowr-analyzer-context.js +15 -9
- package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
- package/project/context/flowr-analyzer-dependencies-context.js +9 -14
- package/project/context/flowr-analyzer-files-context.js +15 -17
- package/project/context/flowr-analyzer-meta-context.js +2 -12
- package/project/dependency-version-space.d.ts +3 -10
- package/project/dependency-version-space.js +10 -9
- package/project/flowr-analyzer.d.ts +4 -6
- package/project/flowr-analyzer.js +4 -5
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +23 -35
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
- package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
- package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
- package/project/sigdb/build.d.ts +2 -2
- package/project/sigdb/decode.d.ts +0 -5
- package/project/sigdb/decode.js +0 -8
- package/project/sigdb/index-format.d.ts +4 -4
- package/project/sigdb/manifest.d.ts +5 -3
- package/project/sigdb/manifest.js +50 -9
- package/project/sigdb/reader.d.ts +48 -13
- package/project/sigdb/reader.js +3 -2
- package/project/sigdb/schema.d.ts +5 -3
- package/project/sigdb/schema.js +2 -2
- package/project/sigdb/signature-db.d.ts +69 -0
- package/project/sigdb/signature-db.js +54 -0
- package/project/sigdb/signature-match.d.ts +10 -5
- package/project/sigdb/signature-match.js +13 -8
- package/queries/catalog/absint-query/absint-query-executor.js +1 -2
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
- package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
- package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
- package/queries/catalog/dependencies-query/link-devices.js +2 -8
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
- package/queries/catalog/signature-query/signature-query-executor.js +4 -3
- package/queries/catalog/slice-query-options.d.ts +1 -1
- package/queries/catalog/slice-query-options.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/query-function-filter.d.ts +8 -2
- package/queries/query-function-filter.js +11 -1
- package/queries/query.d.ts +11 -1
- package/queries/query.js +2 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
- package/r-bridge/lang-4.x/ast/model/model.js +4 -4
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
- package/reconstruct/inline/source-inline-map.js +3 -3
- package/reconstruct/reconstruct.js +6 -4
- package/search/flowr-search-builder.d.ts +8 -8
- package/search/flowr-search-builder.js +4 -4
- package/search/flowr-search-filters.d.ts +2 -2
- package/search/flowr-search-filters.js +4 -15
- package/search/search-executor/search-enrichers.d.ts +6 -4
- package/search/search-executor/search-enrichers.js +44 -5
- package/slicing/criterion/filters/all-variables.js +2 -1
- package/slicing/criterion/parse.d.ts +2 -2
- package/slicing/criterion/parse.js +10 -8
- package/slicing/static/fingerprint.js +1 -1
- package/slicing/static/slice-call.js +2 -2
- package/util/arg-matching.d.ts +3 -0
- package/util/arg-matching.js +12 -1
- package/util/collections/arrays.d.ts +0 -4
- package/util/collections/arrays.js +4 -26
- package/util/diff-graph.d.ts +1 -1
- package/util/diff-graph.js +17 -3
- package/util/diff.d.ts +6 -0
- package/util/mermaid/ast.d.ts +1 -1
- package/util/mermaid/ast.js +5 -4
- package/util/mermaid/cfg.js +130 -24
- package/util/mermaid/dfg.js +31 -10
- package/util/mermaid/mermaid.js +2 -0
- package/util/objects.d.ts +21 -0
- package/util/objects.js +60 -0
- package/util/prefix.d.ts +1 -1
- package/util/simple-df/dfg-ascii.js +14 -3
- package/util/text/name-rank.d.ts +1 -1
- package/util/text/name-rank.js +1 -1
- package/util/text/playground-link.d.ts +131 -0
- package/util/text/playground-link.js +214 -0
- package/util/text/strings.js +7 -3
- package/util/version.js +1 -1
- package/control-flow/cfg-builder.d.ts +0 -30
- package/control-flow/cfg-builder.js +0 -79
- package/control-flow/extract-cfg.d.ts +0 -36
- package/control-flow/extract-cfg.js +0 -693
- package/project/cfg-kind.d.ts +0 -21
- package/project/cfg-kind.js +0 -26
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { DataflowGraph } from '../graph/graph';
|
|
3
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
4
|
+
import { Ternary } from '../../util/logic';
|
|
5
|
+
/**
|
|
6
|
+
* How a function treats its parameters: R hands arguments over as promises, so a parameter is strict when
|
|
7
|
+
* calling the function is enough to force it.
|
|
8
|
+
*/
|
|
9
|
+
export interface FunctionStrictness {
|
|
10
|
+
/** whether every parameter is forced */
|
|
11
|
+
readonly strict: Ternary;
|
|
12
|
+
/** the same per parameter, keyed by the id of the parameter's name */
|
|
13
|
+
readonly parameters: Record<NodeId, Ternary>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Determines whether the function with the given id is strict, i.e., whether calling it forces its arguments.
|
|
17
|
+
* {@link Ternary#Always} says every call forces every parameter, {@link Ternary#Never} that no call forces
|
|
18
|
+
* all of them, and {@link Ternary#Maybe} that it depends on the path taken, on the caller, or on a function
|
|
19
|
+
* flowR could not resolve. A definition without parameters has nothing to leave unforced and is strict.
|
|
20
|
+
*
|
|
21
|
+
* The analysis follows an argument that is handed on into the function receiving it, and treats a read in a
|
|
22
|
+
* default, in a loop, in a branch, or in a nested definition as one that may not happen. What a built-in
|
|
23
|
+
* does with an argument is not guessed from its name: an argument stated {@link ArgProp.Nse} or
|
|
24
|
+
* {@link ArgProp.Presence} is never evaluated, one stated {@link ArgProp.Forced} always is, and the calls
|
|
25
|
+
* reaching an argument only on the way the run takes are the ones flowR hands to the processor that says so
|
|
26
|
+
* (`switch` picking a branch, `try` reaching a handler, a hook running at exit).
|
|
27
|
+
* For a generic, the methods reached by S3 dispatch decide: they agree on a parameter or it is left open,
|
|
28
|
+
* while the object the dispatch is on is forced by the dispatch itself. A `NextMethod` carries the same
|
|
29
|
+
* question on to the methods it reaches, matched by the position the parameter is written in.
|
|
30
|
+
* An argument in `...` is followed to the parameter it binds to, whereas the method of an object flowR
|
|
31
|
+
* cannot resolve (`obj$m(x)`) is one more thing it cannot claim anything about.
|
|
32
|
+
* Cyclic dependencies between functions and calls flowR cannot resolve answer {@link Ternary#Maybe}, so this
|
|
33
|
+
* only claims certainty where the code gives it.
|
|
34
|
+
* What a built-in does with an argument comes from the {@link ArgProp} bits its signature states, so a
|
|
35
|
+
* configured or overwritten built-in is the one that answers when the analyzer context is handed along.
|
|
36
|
+
* @see {@link strictnessOfFunctions} - to ask about several definitions at once, sharing the work
|
|
37
|
+
*/
|
|
38
|
+
export declare function strictnessOfFunction(id: NodeId, graph: DataflowGraph, ctx?: ReadOnlyFlowrAnalyzerContext): FunctionStrictness;
|
|
39
|
+
/** The {@link strictnessOfFunction|strictness} of several definitions, sharing the work between them. */
|
|
40
|
+
export declare function strictnessOfFunctions(ids: Iterable<NodeId>, graph: DataflowGraph, ctx?: ReadOnlyFlowrAnalyzerContext): Record<NodeId, FunctionStrictness>;
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strictnessOfFunction = strictnessOfFunction;
|
|
4
|
+
exports.strictnessOfFunctions = strictnessOfFunctions;
|
|
5
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
6
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
|
+
const graph_1 = require("../graph/graph");
|
|
8
|
+
const edge_1 = require("../graph/edge");
|
|
9
|
+
const vertex_1 = require("../graph/vertex");
|
|
10
|
+
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
11
|
+
const built_in_props_1 = require("../environments/built-in-props");
|
|
12
|
+
const query_fn_props_1 = require("../environments/query-fn-props");
|
|
13
|
+
const identifier_1 = require("../environments/identifier");
|
|
14
|
+
const logic_1 = require("../../util/logic");
|
|
15
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
17
|
+
const r_parameter_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
|
|
18
|
+
/**
|
|
19
|
+
* What an argument is used for when the call never evaluates it: quoted or read in another frame
|
|
20
|
+
* ({@link ArgProp.Nse}), or looked at only for having been supplied ({@link ArgProp.Presence}).
|
|
21
|
+
*/
|
|
22
|
+
const NotEvaluated = built_in_props_1.ArgProp.Nse | built_in_props_1.ArgProp.Presence;
|
|
23
|
+
/**
|
|
24
|
+
* The processors whose calls reach their first argument and the rest only on the way the run happens to
|
|
25
|
+
* take: `switch` picks one of its branches, and `try`/`tryCatch` reach a handler only when one is needed.
|
|
26
|
+
*/
|
|
27
|
+
const LazyAfterFirst = [built_in_proc_name_1.BuiltInProcName.Switch, built_in_proc_name_1.BuiltInProcName.Try];
|
|
28
|
+
/**
|
|
29
|
+
* The processors putting off what they are given until a moment that may never come: a hook runs when the
|
|
30
|
+
* function exits, and `Recall` starts the same function over rather than reading anything itself.
|
|
31
|
+
*/
|
|
32
|
+
const LazyThroughout = [built_in_proc_name_1.BuiltInProcName.RegisterHook, built_in_proc_name_1.BuiltInProcName.Recall];
|
|
33
|
+
/** The processors dispatching to a method chosen at run time. */
|
|
34
|
+
const DispatchProcessors = [
|
|
35
|
+
built_in_proc_name_1.BuiltInProcName.S3Dispatch, built_in_proc_name_1.BuiltInProcName.S3DispatchNext, built_in_proc_name_1.BuiltInProcName.S7Dispatch
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Whether the call hands the work to a method chosen at run time: flowR's own dispatch processors say so for
|
|
39
|
+
* `UseMethod` and `NextMethod`, and {@link DispatchCallees} covers the ones it has no processor for.
|
|
40
|
+
*/
|
|
41
|
+
function isDispatch(vertex) {
|
|
42
|
+
return hasProcessor(vertex, DispatchProcessors) || built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name));
|
|
43
|
+
}
|
|
44
|
+
/** Whether the call belongs to one of the given processors. */
|
|
45
|
+
function hasProcessor(vertex, of) {
|
|
46
|
+
return vertex.origin !== 'unnamed' && of.some(p => vertex.origin.includes(p));
|
|
47
|
+
}
|
|
48
|
+
/** The definition a node sits in. */
|
|
49
|
+
function enclosingDefinition(id, idMap, graph) {
|
|
50
|
+
let node = idMap.get(id);
|
|
51
|
+
while (node !== undefined) {
|
|
52
|
+
if (vertex_1.FunctionDefinitionVertex.is(graph.getVertex(node.info.id))) {
|
|
53
|
+
return node.info.id;
|
|
54
|
+
}
|
|
55
|
+
node = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
function makeState(graph, ctx) {
|
|
60
|
+
const idMap = graph.idMap;
|
|
61
|
+
const owner = new Map();
|
|
62
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
63
|
+
for (const param of Object.keys(vertex.params)) {
|
|
64
|
+
owner.set(node_id_1.NodeId.normalize(param), id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const dispatch = new Map();
|
|
68
|
+
if (idMap !== undefined) {
|
|
69
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
70
|
+
if (!isDispatch(vertex) || typeof node_id_1.NodeId.normalize(id) !== 'number') {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const within = enclosingDefinition(id, idMap, graph);
|
|
74
|
+
if (within === undefined) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const node = idMap.get(id);
|
|
78
|
+
const known = dispatch.get(within);
|
|
79
|
+
const named = (r_function_call_1.RFunctionCall.is(node) && (node.arguments?.length ?? 0) > 1) || (known?.named ?? false);
|
|
80
|
+
const certain = !underCondition(vertex.cds, graph.getVertex(within)?.cds) || (known?.certain ?? false);
|
|
81
|
+
const next = [...known?.next ?? []];
|
|
82
|
+
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
83
|
+
if (target !== within && edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.FunctionDefinitionVertex.is(graph.getVertex(target))) {
|
|
84
|
+
next.push(target);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
dispatch.set(within, { named, certain, next });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const environment = ctx?.env.makeCleanEnv();
|
|
91
|
+
const props = environment === undefined
|
|
92
|
+
? (name) => query_fn_props_1.BuiltInIndex.default().get(name)?.sig
|
|
93
|
+
: (name) => (0, query_fn_props_1.queryFnProps)(name, { environment })?.sig;
|
|
94
|
+
return { graph, idMap, owner, dispatch, sigs: new Map(), props, known: new Map(), asking: new Set(), assumed: false };
|
|
95
|
+
}
|
|
96
|
+
/** What is certain becomes a possibility once something may intervene. */
|
|
97
|
+
function weaken(value) {
|
|
98
|
+
return value === logic_1.Ternary.Always ? logic_1.Ternary.Maybe : value;
|
|
99
|
+
}
|
|
100
|
+
/** What several answers amount to when only one applies and nothing says which. */
|
|
101
|
+
function agree(values) {
|
|
102
|
+
if (values.length === 0) {
|
|
103
|
+
return logic_1.Ternary.Never;
|
|
104
|
+
}
|
|
105
|
+
return values.every(v => v === values[0]) ? values[0] : logic_1.Ternary.Maybe;
|
|
106
|
+
}
|
|
107
|
+
/** Whether the control dependencies exceed the ones the definition itself stands under. */
|
|
108
|
+
function underCondition(cds, definition) {
|
|
109
|
+
return cds?.some(c => !definition?.some(d => d.id === c.id && d.when === c.when)) ?? false;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Built-ins force what they are given, and the ones that do not (`quote` and its relatives) leave no read of
|
|
113
|
+
* the argument in the graph in the first place, so there is nothing to hold back here. A call of something
|
|
114
|
+
* the code worked out for itself (`obj$method(...)`) is none of them, whichever way it was written.
|
|
115
|
+
*/
|
|
116
|
+
function isBuiltInCall(vertex) {
|
|
117
|
+
return vertex.origin !== 'unnamed'
|
|
118
|
+
&& !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Function)
|
|
119
|
+
&& !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Unnamed);
|
|
120
|
+
}
|
|
121
|
+
/** The node whose value an argument stands for, carrying the link to the parameter it binds to. */
|
|
122
|
+
function argumentValue(id, idMap) {
|
|
123
|
+
const node = idMap.get(id);
|
|
124
|
+
return r_argument_1.RArgument.is(node) ? node.value?.info.id ?? id : id;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Where the given node stands in the call's arguments. The graph names an argument by the value it wraps,
|
|
128
|
+
* while the walk arrives at the argument itself, so both count as a hit; `-1` when neither does, which a
|
|
129
|
+
* call whose arguments flowR rewrote (`on.exit` and the other deferred ones) is enough to bring about.
|
|
130
|
+
*/
|
|
131
|
+
function argumentIndex(call, child, idMap) {
|
|
132
|
+
const value = argumentValue(child, idMap);
|
|
133
|
+
return call.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && (arg.nodeId === child || arg.nodeId === value));
|
|
134
|
+
}
|
|
135
|
+
/** Whether the node is the function a call is of rather than something handed to it. */
|
|
136
|
+
function isCallee(call, child, idMap) {
|
|
137
|
+
const node = idMap.get(call);
|
|
138
|
+
if (!r_function_call_1.RFunctionCall.is(node)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return (r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.info.id : node.calledFunction.info.id) === child;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* What flowR states the argument at `index` of the call is used for. A `...` covers every position from
|
|
145
|
+
* where it is declared, which {@link FnSig.propAt} takes care of.
|
|
146
|
+
*/
|
|
147
|
+
function argProps(vertex, index, state) {
|
|
148
|
+
const name = identifier_1.Identifier.getName(vertex.name);
|
|
149
|
+
let sig = state.sigs.get(name);
|
|
150
|
+
if (sig === undefined && !state.sigs.has(name)) {
|
|
151
|
+
state.sigs.set(name, sig = state.props(vertex.name));
|
|
152
|
+
}
|
|
153
|
+
return sig === undefined || index < 0 ? 0 : built_in_props_1.FnSig.propAt(built_in_props_1.FnSig.layout(sig), index);
|
|
154
|
+
}
|
|
155
|
+
/** The verdict a callee's parameter carries over to what is handed to it. */
|
|
156
|
+
function handedTo(param, state) {
|
|
157
|
+
const owner = state.owner.get(param);
|
|
158
|
+
return owner === undefined ? logic_1.Ternary.Maybe : strictnessOf(owner, state).parameters[param] ?? logic_1.Ternary.Maybe;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether handing `argument` to `call` forces it. An argument the call passes on is forced exactly as the
|
|
162
|
+
* function receiving it forces the parameter it binds to; a call flowR cannot resolve, and one whose argument
|
|
163
|
+
* it cannot match to a parameter, leave the question open.
|
|
164
|
+
*/
|
|
165
|
+
function forcedByCallee(call, argument, idMap, state) {
|
|
166
|
+
const resolved = [...state.graph.outgoingEdges(call.id) ?? graph_1.NoEdges]
|
|
167
|
+
.some(([target, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.FunctionDefinitionVertex.is(state.graph.getVertex(target)));
|
|
168
|
+
if (!resolved) {
|
|
169
|
+
return logic_1.Ternary.Maybe;
|
|
170
|
+
}
|
|
171
|
+
const bound = [];
|
|
172
|
+
for (const from of new Set([argument, argumentValue(argument, idMap)])) {
|
|
173
|
+
for (const [target, edge] of state.graph.outgoingEdges(from) ?? graph_1.NoEdges) {
|
|
174
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinesOnCall)) {
|
|
175
|
+
bound.push(handedTo(target, state));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return bound.length === 0 ? logic_1.Ternary.Maybe : agree(bound);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* How far the given read of a parameter is unavoidable: it has to stand under no condition the definition
|
|
183
|
+
* does not already stand under, must not sit in a function or a default of its own that may never be
|
|
184
|
+
* reached, and must not merely be handed to something that leaves it alone.
|
|
185
|
+
*/
|
|
186
|
+
function forces(read, definition, state) {
|
|
187
|
+
const idMap = state.idMap;
|
|
188
|
+
if (idMap === undefined) {
|
|
189
|
+
return logic_1.Ternary.Maybe;
|
|
190
|
+
}
|
|
191
|
+
let certain = true;
|
|
192
|
+
let child = read;
|
|
193
|
+
let node = idMap.get(read);
|
|
194
|
+
while (node !== undefined && node.info.id !== definition.id) {
|
|
195
|
+
const vertex = state.graph.getVertex(node.info.id);
|
|
196
|
+
if (underCondition(vertex?.cds, definition.cds)) {
|
|
197
|
+
certain = false;
|
|
198
|
+
}
|
|
199
|
+
if (node.info.id !== read) {
|
|
200
|
+
if (vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
201
|
+
/* nothing says the nested definition is ever called */
|
|
202
|
+
certain = false;
|
|
203
|
+
}
|
|
204
|
+
else if (r_parameter_1.RParameter.is(node)) {
|
|
205
|
+
/* a default is evaluated only when the argument is left out */
|
|
206
|
+
certain = false;
|
|
207
|
+
}
|
|
208
|
+
else if (vertex_1.FunctionCallVertex.is(vertex) && !isDispatch(vertex) && !isCallee(node.info.id, child, idMap)) {
|
|
209
|
+
if (!isBuiltInCall(vertex)) {
|
|
210
|
+
const handed = forcedByCallee(vertex, child, idMap, state);
|
|
211
|
+
return certain ? handed : weaken(handed);
|
|
212
|
+
}
|
|
213
|
+
const index = argumentIndex(vertex, child, idMap);
|
|
214
|
+
const props = argProps(vertex, index, state);
|
|
215
|
+
if ((props & NotEvaluated) !== 0) {
|
|
216
|
+
return logic_1.Ternary.Never;
|
|
217
|
+
}
|
|
218
|
+
else if ((props & built_in_props_1.ArgProp.Forced) === 0
|
|
219
|
+
&& (hasProcessor(vertex, LazyThroughout) || (index !== 0 && hasProcessor(vertex, LazyAfterFirst)))) {
|
|
220
|
+
certain = false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
child = node.info.id;
|
|
225
|
+
node = node.info.parent === undefined ? undefined : idMap.get(node.info.parent);
|
|
226
|
+
}
|
|
227
|
+
if (node === undefined) {
|
|
228
|
+
return logic_1.Ternary.Never;
|
|
229
|
+
}
|
|
230
|
+
return certain ? logic_1.Ternary.Always : logic_1.Ternary.Maybe;
|
|
231
|
+
}
|
|
232
|
+
function strictnessOfParameter(param, definition, state) {
|
|
233
|
+
const reads = [];
|
|
234
|
+
for (const [read, edge] of state.graph.ingoingEdges(param) ?? graph_1.NoEdges) {
|
|
235
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
|
|
236
|
+
reads.push(forces(read, definition, state));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const dispatch = state.dispatch.get(definition.id);
|
|
240
|
+
if (dispatch !== undefined) {
|
|
241
|
+
const methods = [];
|
|
242
|
+
for (const [target, edge] of state.graph.outgoingEdges(param) ?? graph_1.NoEdges) {
|
|
243
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinesOnCall)) {
|
|
244
|
+
methods.push(handedTo(target, state));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
reads.push(dispatch.certain ? agree(methods) : weaken(agree(methods)));
|
|
248
|
+
if (dispatch.next.length > 0) {
|
|
249
|
+
const at = parameterIds(definition.id, state.idMap).indexOf(param);
|
|
250
|
+
const along = at < 0 ? [] : dispatch.next.map(method => {
|
|
251
|
+
const same = parameterIds(method, state.idMap)[at];
|
|
252
|
+
return same === undefined ? logic_1.Ternary.Maybe : strictnessOf(method, state).parameters[same] ?? logic_1.Ternary.Maybe;
|
|
253
|
+
});
|
|
254
|
+
reads.push(dispatch.certain ? agree(along) : weaken(agree(along)));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return logic_1.TernaryLogic.or(...reads);
|
|
258
|
+
}
|
|
259
|
+
/** The parameters of a definition in the order they are written. */
|
|
260
|
+
function parameterIds(definition, idMap) {
|
|
261
|
+
const node = idMap?.get(definition);
|
|
262
|
+
return r_function_definition_1.RFunctionDefinition.is(node) ? node.parameters.map(p => p.name.info.id) : [];
|
|
263
|
+
}
|
|
264
|
+
function strictnessOf(id, state) {
|
|
265
|
+
const known = state.known.get(id);
|
|
266
|
+
if (known !== undefined) {
|
|
267
|
+
return known;
|
|
268
|
+
}
|
|
269
|
+
const vertex = state.graph.getVertex(id);
|
|
270
|
+
if (!vertex_1.FunctionDefinitionVertex.is(vertex)) {
|
|
271
|
+
return { strict: logic_1.Ternary.Never, parameters: {} };
|
|
272
|
+
}
|
|
273
|
+
const params = Object.keys(vertex.params);
|
|
274
|
+
if (state.asking.has(id)) {
|
|
275
|
+
/* the answer is the one still being worked out */
|
|
276
|
+
state.assumed = true;
|
|
277
|
+
return { strict: logic_1.Ternary.Maybe, parameters: Object.fromEntries(params.map(param => [param, logic_1.Ternary.Maybe])) };
|
|
278
|
+
}
|
|
279
|
+
state.asking.add(id);
|
|
280
|
+
const parameters = {};
|
|
281
|
+
for (const param of params) {
|
|
282
|
+
parameters[param] = strictnessOfParameter(node_id_1.NodeId.normalize(param), vertex, state);
|
|
283
|
+
}
|
|
284
|
+
const dispatch = state.dispatch.get(id);
|
|
285
|
+
if (dispatch !== undefined) {
|
|
286
|
+
for (const param of params) {
|
|
287
|
+
parameters[param] = logic_1.TernaryLogic.or(parameters[param], logic_1.Ternary.Maybe);
|
|
288
|
+
}
|
|
289
|
+
const object = dispatch.named ? undefined : parameterIds(id, state.idMap)[0];
|
|
290
|
+
if (object !== undefined && parameters[object] !== undefined) {
|
|
291
|
+
parameters[object] = dispatch.certain ? logic_1.Ternary.Always : logic_1.TernaryLogic.or(parameters[object], logic_1.Ternary.Maybe);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
state.asking.delete(id);
|
|
295
|
+
const result = { strict: logic_1.TernaryLogic.and(...Object.values(parameters)), parameters };
|
|
296
|
+
if (!state.assumed) {
|
|
297
|
+
state.known.set(id, result);
|
|
298
|
+
}
|
|
299
|
+
else if (state.asking.size === 0) {
|
|
300
|
+
state.assumed = false;
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Determines whether the function with the given id is strict, i.e., whether calling it forces its arguments.
|
|
306
|
+
* {@link Ternary#Always} says every call forces every parameter, {@link Ternary#Never} that no call forces
|
|
307
|
+
* all of them, and {@link Ternary#Maybe} that it depends on the path taken, on the caller, or on a function
|
|
308
|
+
* flowR could not resolve. A definition without parameters has nothing to leave unforced and is strict.
|
|
309
|
+
*
|
|
310
|
+
* The analysis follows an argument that is handed on into the function receiving it, and treats a read in a
|
|
311
|
+
* default, in a loop, in a branch, or in a nested definition as one that may not happen. What a built-in
|
|
312
|
+
* does with an argument is not guessed from its name: an argument stated {@link ArgProp.Nse} or
|
|
313
|
+
* {@link ArgProp.Presence} is never evaluated, one stated {@link ArgProp.Forced} always is, and the calls
|
|
314
|
+
* reaching an argument only on the way the run takes are the ones flowR hands to the processor that says so
|
|
315
|
+
* (`switch` picking a branch, `try` reaching a handler, a hook running at exit).
|
|
316
|
+
* For a generic, the methods reached by S3 dispatch decide: they agree on a parameter or it is left open,
|
|
317
|
+
* while the object the dispatch is on is forced by the dispatch itself. A `NextMethod` carries the same
|
|
318
|
+
* question on to the methods it reaches, matched by the position the parameter is written in.
|
|
319
|
+
* An argument in `...` is followed to the parameter it binds to, whereas the method of an object flowR
|
|
320
|
+
* cannot resolve (`obj$m(x)`) is one more thing it cannot claim anything about.
|
|
321
|
+
* Cyclic dependencies between functions and calls flowR cannot resolve answer {@link Ternary#Maybe}, so this
|
|
322
|
+
* only claims certainty where the code gives it.
|
|
323
|
+
* What a built-in does with an argument comes from the {@link ArgProp} bits its signature states, so a
|
|
324
|
+
* configured or overwritten built-in is the one that answers when the analyzer context is handed along.
|
|
325
|
+
* @see {@link strictnessOfFunctions} - to ask about several definitions at once, sharing the work
|
|
326
|
+
*/
|
|
327
|
+
function strictnessOfFunction(id, graph, ctx) {
|
|
328
|
+
return strictnessOf(id, makeState(graph, ctx));
|
|
329
|
+
}
|
|
330
|
+
/** The {@link strictnessOfFunction|strictness} of several definitions, sharing the work between them. */
|
|
331
|
+
function strictnessOfFunctions(ids, graph, ctx) {
|
|
332
|
+
const state = makeState(graph, ctx);
|
|
333
|
+
const result = {};
|
|
334
|
+
for (const id of ids) {
|
|
335
|
+
result[id] = strictnessOf(id, state);
|
|
336
|
+
}
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=strict-function.js.map
|
|
@@ -12,8 +12,8 @@ const graph_helper_1 = require("./graph-helper");
|
|
|
12
12
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
13
13
|
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
14
14
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
15
|
-
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
15
|
const identifier_1 = require("../environments/identifier");
|
|
16
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
17
17
|
function processCds(vtx, graph, result, state) {
|
|
18
18
|
for (const tar of vtx.cds ?? []) {
|
|
19
19
|
const targetVtx = graph.getVertex(tar.id);
|
|
@@ -215,7 +215,7 @@ function mayRunAnyway(graph, reached) {
|
|
|
215
215
|
continue;
|
|
216
216
|
}
|
|
217
217
|
const parent = model_1.RNode.directParent(node, idMap);
|
|
218
|
-
if (
|
|
218
|
+
if (r_argument_1.RArgument.is(parent)) {
|
|
219
219
|
seeds.push(id);
|
|
220
220
|
continue;
|
|
221
221
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataflowGraph } from './graph';
|
|
2
|
-
import { EdgeType } from './edge';
|
|
2
|
+
import { DfEdge, EdgeType } from './edge';
|
|
3
3
|
import { emptyGraph } from './dataflowgraph-builder';
|
|
4
4
|
import { getOriginInDfg } from '../origin/dfg-get-origin';
|
|
5
5
|
import { CallGraph } from './call-graph';
|
|
@@ -14,7 +14,8 @@ import { Identifier } from '../environments/identifier';
|
|
|
14
14
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
15
15
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
16
16
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
17
|
-
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call
|
|
17
|
+
* - {@link Dataflow.qualify}/{@link Dataflow.qualifyAll} - for the package-qualified `pkg::fn` identifier of a call
|
|
18
|
+
* from its id and graph, or of every call of a graph at once,
|
|
18
19
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
19
20
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
20
21
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
@@ -54,6 +55,12 @@ export declare const Dataflow: {
|
|
|
54
55
|
readonly isOnlyType: (this: void, { types }: {
|
|
55
56
|
types: number;
|
|
56
57
|
}, only: EdgeType) => boolean;
|
|
58
|
+
readonly isOnlyControlFlow: (this: void, { types }: {
|
|
59
|
+
types: number;
|
|
60
|
+
}) => boolean;
|
|
61
|
+
readonly without: (this: void, { types }: {
|
|
62
|
+
types: number;
|
|
63
|
+
}, drop: import("./edge").EdgeTypeBits) => DfEdge;
|
|
57
64
|
};
|
|
58
65
|
/**
|
|
59
66
|
* Dispatches to helper objects that relate to (sub-) views of the dataflow graph, e.g. the call graph.
|
|
@@ -113,6 +120,7 @@ export declare const Dataflow: {
|
|
|
113
120
|
readonly byName: typeof import("../environments/resolve-by-name").resolveByNameAnyType;
|
|
114
121
|
readonly byNameAndType: typeof import("../environments/resolve-by-name").resolveByName;
|
|
115
122
|
readonly toBuiltIn: typeof import("../environments/resolve-by-name").resolvesToBuiltInConstant;
|
|
123
|
+
readonly isBuiltIn: typeof import("../environments/resolve-by-name").resolvesToBuiltIn;
|
|
116
124
|
readonly toConstants: typeof import("../eval/resolve/alias-tracking").resolveToConstants;
|
|
117
125
|
readonly toValue: typeof import("../eval/resolve/alias-tracking").resolveIdToValue;
|
|
118
126
|
readonly toSingleString: typeof import("../eval/resolve/alias-tracking").resolveIdToSingleString;
|
|
@@ -139,6 +147,13 @@ export declare const Dataflow: {
|
|
|
139
147
|
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
140
148
|
*/
|
|
141
149
|
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* The qualified name of every call of the graph, `undefined` for the calls that do not qualify.
|
|
152
|
+
* Prefer this over asking call by call: it resolves each call once for both `qualifyBaseR` variants.
|
|
153
|
+
* @param graph - The graph to qualify
|
|
154
|
+
* @param qualifyBaseR - Which of the two results to return, see {@link Dataflow.qualify}
|
|
155
|
+
*/
|
|
156
|
+
readonly qualifyAll: (this: void, graph: DataflowGraph, qualifyBaseR?: boolean) => ReadonlyMap<NodeId, Identifier | undefined>;
|
|
142
157
|
/**
|
|
143
158
|
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
144
159
|
* This is what a selection needs, which is not what the program loads: a `library()` whose exports the
|
|
@@ -20,7 +20,8 @@ const r_base_packages_1 = require("../../util/r-base-packages");
|
|
|
20
20
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
21
21
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
22
22
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
23
|
-
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call
|
|
23
|
+
* - {@link Dataflow.qualify}/{@link Dataflow.qualifyAll} - for the package-qualified `pkg::fn` identifier of a call
|
|
24
|
+
* from its id and graph, or of every call of a graph at once,
|
|
24
25
|
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
25
26
|
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
26
27
|
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
@@ -86,8 +87,16 @@ exports.Dataflow = {
|
|
|
86
87
|
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
87
88
|
*/
|
|
88
89
|
qualify(id, graph, qualifyBaseR = true) {
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
return graph.qualify(id, qualifyBaseR, resolveQualification);
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* The qualified name of every call of the graph, `undefined` for the calls that do not qualify.
|
|
94
|
+
* Prefer this over asking call by call: it resolves each call once for both `qualifyBaseR` variants.
|
|
95
|
+
* @param graph - The graph to qualify
|
|
96
|
+
* @param qualifyBaseR - Which of the two results to return, see {@link Dataflow.qualify}
|
|
97
|
+
*/
|
|
98
|
+
qualifyAll(graph, qualifyBaseR = true) {
|
|
99
|
+
return graph.qualifyAll(qualifyBaseR, resolveQualification);
|
|
91
100
|
},
|
|
92
101
|
/**
|
|
93
102
|
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
@@ -312,4 +321,11 @@ exports.Dataflow = {
|
|
|
312
321
|
return exports.Dataflow.reduceGraph(graph, exports.Dataflow.provenance(id, graph, consider));
|
|
313
322
|
}
|
|
314
323
|
};
|
|
324
|
+
/** both qualifications of a call from a single origin resolution, as the base-R step only adds to what the origins gave */
|
|
325
|
+
const resolveQualification = (graph, id, vertex) => {
|
|
326
|
+
const origins = (0, dfg_get_origin_1.getOriginInDfg)(graph, id);
|
|
327
|
+
const name = vertex_1.FunctionCallVertex.is(vertex) ? vertex.name : undefined;
|
|
328
|
+
const bare = identifier_1.Identifier.toQualified(origins, name, false);
|
|
329
|
+
return [bare, bare ?? identifier_1.Identifier.toQualified(origins, name, true)];
|
|
330
|
+
};
|
|
315
331
|
//# sourceMappingURL=df-helper.js.map
|
|
@@ -4,7 +4,7 @@ import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
|
|
|
4
4
|
import type { GraphDifferenceReport, GraphDiffContext } from '../../util/diff-graph';
|
|
5
5
|
/**
|
|
6
6
|
* This is the underlying function to calculate the difference based on a given context.
|
|
7
|
-
* Use {@link Dataflow.
|
|
7
|
+
* Use {@link Dataflow.diffGraphs} to calculate the diff of two graphs.
|
|
8
8
|
*/
|
|
9
9
|
export declare function diffDataflowGraph(ctx: GraphDiffContext): void;
|
|
10
10
|
/**
|
|
@@ -18,12 +18,29 @@ const diff_graph_1 = require("../../util/diff-graph");
|
|
|
18
18
|
const vertex_1 = require("./vertex");
|
|
19
19
|
/**
|
|
20
20
|
* This is the underlying function to calculate the difference based on a given context.
|
|
21
|
-
* Use {@link Dataflow.
|
|
21
|
+
* Use {@link Dataflow.diffGraphs} to calculate the diff of two graphs.
|
|
22
22
|
*/
|
|
23
23
|
function diffDataflowGraph(ctx) {
|
|
24
24
|
diffRootVertices(ctx);
|
|
25
25
|
diffVertices(ctx);
|
|
26
|
-
diff_graph_1.GraphDiff.outgoingEdges(ctx, diffEdges);
|
|
26
|
+
diff_graph_1.GraphDiff.outgoingEdges(ctx, diffEdges, ctx.config.compareControlFlow ? undefined : withoutControlFlow);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Narrow a vertex' outgoing edges to their dataflow part, dropping the control flow the
|
|
30
|
+
* {@link ControlFlowGraph} projects out of the very same graph.
|
|
31
|
+
* Comparing control flow is the job of the control flow diff, so a dataflow comparison would only be
|
|
32
|
+
* duplicating it (and would force every expected graph to spell the control flow out again).
|
|
33
|
+
*/
|
|
34
|
+
function withoutControlFlow(edges) {
|
|
35
|
+
let result = undefined;
|
|
36
|
+
for (const [target, edge] of edges) {
|
|
37
|
+
if (edge_1.DfEdge.isOnlyControlFlow(edge)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
result ??= new Map();
|
|
41
|
+
result.set(target, edge_1.DfEdge.includesType(edge, edge_1.ControlFlowEdgeTypes) ? edge_1.DfEdge.without(edge, edge_1.ControlFlowEdgeTypes) : edge);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
27
44
|
}
|
|
28
45
|
function diffRootVertices(ctx) {
|
|
29
46
|
(0, diff_1.setDifference)(ctx.left.rootIds(), ctx.right.rootIds(), { ...ctx, position: `${ctx.position}Root vertices differ in graphs. ` });
|
package/dataflow/graph/edge.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ControlDependency } from '../info';
|
|
1
2
|
/**
|
|
2
3
|
* An edge consist of only of the type (source and target are encoded with the Dataflow Graph).
|
|
3
4
|
* Multiple edges are encoded by joining the respective type bits.
|
|
@@ -7,6 +8,15 @@
|
|
|
7
8
|
export interface DfEdge {
|
|
8
9
|
types: EdgeTypeBits;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* A {@link EdgeType.ControlEdge} additionally carries what decides whether its target runs.
|
|
13
|
+
* This is the very {@link ControlDependency} the vertices behind the edge carry in their `cds`, so the two
|
|
14
|
+
* never say different things about the same branch.
|
|
15
|
+
*/
|
|
16
|
+
export interface DFControlFlowEdge extends DfEdge {
|
|
17
|
+
types: EdgeType.ControlEdge;
|
|
18
|
+
cd: ControlDependency;
|
|
19
|
+
}
|
|
10
20
|
/**
|
|
11
21
|
* Represents the relationship between the source and the target vertex in the dataflow graph.
|
|
12
22
|
* The actual value is represented as a bitmask, so please refer to {@link DfEdge} for helpful functions.
|
|
@@ -35,7 +45,17 @@ export declare enum EdgeType {
|
|
|
35
45
|
/** The edge determines that the source is a side effect that happens when the target is called */
|
|
36
46
|
SideEffectOnCall = 128,
|
|
37
47
|
/** The Edge determines that the reference is affected by a non-standard evaluation (e.g., a for-loop body or a quotation) */
|
|
38
|
-
NonStandardEvaluation = 256
|
|
48
|
+
NonStandardEvaluation = 256,
|
|
49
|
+
/**
|
|
50
|
+
* The edge points the way execution goes: the target is evaluated after the source.
|
|
51
|
+
* @see {@link ControlFlowGraph} - the view these edges carry
|
|
52
|
+
*/
|
|
53
|
+
FlowEdge = 4096,
|
|
54
|
+
/**
|
|
55
|
+
* Like {@link EdgeType.FlowEdge}, pointing the way execution goes, but only taken when the condition the
|
|
56
|
+
* edge names evaluates to the value it names (e.g. one branch of an if-else).
|
|
57
|
+
*/
|
|
58
|
+
ControlEdge = 8192
|
|
39
59
|
}
|
|
40
60
|
/**
|
|
41
61
|
* See {@link EdgeType} for the basis.
|
|
@@ -49,9 +69,17 @@ export declare const enum EdgeTypeName {
|
|
|
49
69
|
DefinedByOnCall = "def-by-on-call",
|
|
50
70
|
Argument = "arg",
|
|
51
71
|
SideEffectOnCall = "side-effect-on-call",
|
|
52
|
-
NonStandardEvaluation = "non-standard-evaluation"
|
|
72
|
+
NonStandardEvaluation = "non-standard-evaluation",
|
|
73
|
+
FlowEdge = "flows-to",
|
|
74
|
+
ControlEdge = "branches-to"
|
|
53
75
|
}
|
|
54
76
|
export type EdgeTypeBits = number;
|
|
77
|
+
/**
|
|
78
|
+
* The edge types that carry the control flow of the program, all of them pointing the way execution goes.
|
|
79
|
+
* The {@link ControlFlowGraph} is a view on them.
|
|
80
|
+
* @see {@link EdgeType.FlowEdge}, {@link EdgeType.ControlEdge}
|
|
81
|
+
*/
|
|
82
|
+
export declare const ControlFlowEdgeTypes: EdgeTypeBits;
|
|
55
83
|
type DfEdgeLike = {
|
|
56
84
|
types: number;
|
|
57
85
|
};
|
|
@@ -123,6 +151,14 @@ export declare const DfEdge: {
|
|
|
123
151
|
* ```
|
|
124
152
|
*/
|
|
125
153
|
readonly isOnlyType: (this: void, { types }: DfEdgeLike, only: EdgeType) => boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Whether the edge carries nothing but control flow, i.e. it exists only because the
|
|
156
|
+
* {@link ControlFlowGraph} is a view on the dataflow graph.
|
|
157
|
+
* @see {@link ControlFlowEdgeTypes}
|
|
158
|
+
*/
|
|
159
|
+
readonly isOnlyControlFlow: (this: void, { types }: DfEdgeLike) => boolean;
|
|
160
|
+
/** The same edge without the given types, e.g. to look at the dataflow part of an edge on its own. */
|
|
161
|
+
readonly without: (this: void, { types }: DfEdgeLike, drop: EdgeTypeBits) => DfEdge;
|
|
126
162
|
};
|
|
127
163
|
export declare const enum TraverseEdge {
|
|
128
164
|
/** Do not traverse this edge */
|