@eagleoutice/flowr 2.10.9 → 2.11.0
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 +116 -38
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/options.d.ts +2 -108
- package/cli/common/options.js +3 -27
- package/cli/common/script.js +3 -2
- package/cli/common/scripts-info.d.ts +2 -123
- package/cli/common/scripts-info.js +0 -17
- package/cli/flowr-main-options.d.ts +5 -0
- package/cli/flowr-main-options.js +10 -0
- package/cli/flowr.js +48 -11
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/print-version.d.ts +3 -1
- package/cli/repl/print-version.js +21 -2
- package/cli/repl/server/connection.d.ts +3 -0
- package/cli/repl/server/connection.js +65 -31
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/summarizer-core.js +13 -32
- package/cli/wiki.d.ts +3 -1
- package/cli/wiki.js +6 -1
- package/config.d.ts +22 -10
- package/config.js +33 -7
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +2 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/data/pkgdb/pkgdb-latest.json.br +0 -0
- package/data/pkgdb/pkgdb-tiny.json.br +0 -0
- package/dataflow/environments/append.d.ts +2 -2
- package/dataflow/environments/append.js +4 -10
- package/dataflow/environments/apply-kill.d.ts +21 -0
- package/dataflow/environments/apply-kill.js +155 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in.d.ts +4 -0
- package/dataflow/environments/built-in.js +4 -0
- package/dataflow/environments/default-builtin-config.d.ts +183 -67
- package/dataflow/environments/default-builtin-config.js +358 -147
- package/dataflow/environments/environment.d.ts +49 -31
- package/dataflow/environments/environment.js +144 -25
- package/dataflow/environments/identifier.d.ts +65 -2
- package/dataflow/environments/identifier.js +37 -2
- package/dataflow/environments/overwrite.js +2 -10
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.d.ts +1 -1
- package/dataflow/environments/resolve-by-name.js +23 -9
- package/dataflow/environments/scoping.d.ts +9 -2
- package/dataflow/environments/scoping.js +15 -2
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +35 -4
- package/dataflow/graph/df-helper.d.ts +14 -0
- package/dataflow/graph/df-helper.js +41 -0
- package/dataflow/graph/graph.d.ts +4 -1
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/info.d.ts +27 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +7 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +61 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- 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 +132 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +11 -4
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +23 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +78 -57
- package/documentation/data/interface/doc-writing-code.js +4 -80
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-structure.js +1 -2
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +121 -32
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +112 -77
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +22 -8
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +16 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +4 -17
- package/documentation/wiki-package-database.d.ts +9 -0
- package/documentation/wiki-package-database.js +63 -0
- package/documentation/wiki-query.js +86 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +111 -86
- package/linter/linter-rules.js +9 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +8 -5
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/undefined-symbol.d.ts +39 -0
- package/linter/rules/undefined-symbol.js +80 -0
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +5 -5
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +9 -1
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
- package/project/context/flowr-analyzer-dependencies-context.js +36 -4
- package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
- package/project/context/flowr-analyzer-environment-context.js +3 -4
- package/project/context/flowr-analyzer-files-context.d.ts +13 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/context/flowr-file.d.ts +2 -0
- package/project/context/flowr-file.js +2 -0
- package/project/flowr-analyzer-builder.js +3 -0
- package/project/flowr-analyzer.d.ts +2 -1
- package/project/flowr-analyzer.js +3 -1
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
- package/project/plugins/package-version-plugins/package.d.ts +3 -0
- package/project/plugins/package-version-plugins/package.js +12 -0
- package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
- package/project/plugins/package-version-plugins/pkgdb.js +370 -0
- package/project/plugins/plugin-registry.d.ts +5 -1
- package/project/plugins/plugin-registry.js +10 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +62 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -2
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +8 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +7 -2
- package/r-bridge/data/data.js +8 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +601 -1
- package/search/search-executor/search-enrichers.js +30 -6
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/mermaid/mermaid.d.ts +4 -0
- package/util/mermaid/mermaid.js +8 -1
- package/util/objects.d.ts +9 -0
- package/util/objects.js +54 -0
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +10 -2
- package/cli/common/features.d.ts +0 -9
- package/cli/common/features.js +0 -35
- package/cli/script-core/statistics-core.d.ts +0 -6
- package/cli/script-core/statistics-core.js +0 -103
- package/cli/script-core/statistics-helper-core.d.ts +0 -6
- package/cli/script-core/statistics-helper-core.js +0 -85
- package/cli/statistics-app.d.ts +0 -11
- package/cli/statistics-app.js +0 -16
- package/cli/statistics-helper-app.d.ts +0 -11
- package/cli/statistics-helper-app.js +0 -14
- package/statistics/features/common-syntax-probability.d.ts +0 -38
- package/statistics/features/common-syntax-probability.js +0 -169
- package/statistics/features/feature.d.ts +0 -179
- package/statistics/features/feature.js +0 -38
- package/statistics/features/post-processing.d.ts +0 -18
- package/statistics/features/post-processing.js +0 -26
- package/statistics/features/supported/assignments/assignments.d.ts +0 -12
- package/statistics/features/supported/assignments/assignments.js +0 -56
- package/statistics/features/supported/assignments/post-process.d.ts +0 -6
- package/statistics/features/supported/assignments/post-process.js +0 -126
- package/statistics/features/supported/comments/comments.d.ts +0 -18
- package/statistics/features/supported/comments/comments.js +0 -143
- package/statistics/features/supported/comments/post-process.d.ts +0 -6
- package/statistics/features/supported/comments/post-process.js +0 -51
- package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
- package/statistics/features/supported/control-flow/control-flow.js +0 -69
- package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
- package/statistics/features/supported/control-flow/post-process.js +0 -66
- package/statistics/features/supported/data-access/data-access.d.ts +0 -15
- package/statistics/features/supported/data-access/data-access.js +0 -122
- package/statistics/features/supported/data-access/post-process.d.ts +0 -6
- package/statistics/features/supported/data-access/post-process.js +0 -108
- package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
- package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
- package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/defined-functions/post-process.js +0 -168
- package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
- package/statistics/features/supported/expression-list/post-process.js +0 -45
- package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
- package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
- package/statistics/features/supported/loops/loops.d.ts +0 -20
- package/statistics/features/supported/loops/loops.js +0 -81
- package/statistics/features/supported/loops/post-process.d.ts +0 -6
- package/statistics/features/supported/loops/post-process.js +0 -73
- package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
- package/statistics/features/supported/used-functions/post-process.js +0 -176
- package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
- package/statistics/features/supported/used-functions/used-functions.js +0 -99
- package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
- package/statistics/features/supported/used-packages/post-process.js +0 -122
- package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
- package/statistics/features/supported/used-packages/used-packages.js +0 -140
- package/statistics/features/supported/values/post-process.d.ts +0 -6
- package/statistics/features/supported/values/post-process.js +0 -73
- package/statistics/features/supported/values/values.d.ts +0 -14
- package/statistics/features/supported/values/values.js +0 -111
- package/statistics/features/supported/variables/post-process.d.ts +0 -15
- package/statistics/features/supported/variables/post-process.js +0 -126
- package/statistics/features/supported/variables/variables.d.ts +0 -15
- package/statistics/features/supported/variables/variables.js +0 -62
- package/statistics/meta-statistics.d.ts +0 -32
- package/statistics/meta-statistics.js +0 -16
- package/statistics/output/file-provider.d.ts +0 -36
- package/statistics/output/file-provider.js +0 -96
- package/statistics/output/print-stats.d.ts +0 -29
- package/statistics/output/print-stats.js +0 -81
- package/statistics/output/statistics-file.d.ts +0 -36
- package/statistics/output/statistics-file.js +0 -68
- package/statistics/statistics.d.ts +0 -29
- package/statistics/statistics.js +0 -108
- package/statistics/summarizer/auto-detect.d.ts +0 -5
- package/statistics/summarizer/auto-detect.js +0 -34
- package/statistics/summarizer/first-phase/process.d.ts +0 -6
- package/statistics/summarizer/first-phase/process.js +0 -81
- package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
- package/statistics/summarizer/post-process/clusterer.js +0 -40
- package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
- package/statistics/summarizer/post-process/file-based-count.js +0 -47
- package/statistics/summarizer/post-process/histogram.d.ts +0 -57
- package/statistics/summarizer/post-process/histogram.js +0 -126
- package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
- package/statistics/summarizer/post-process/post-process-output.js +0 -102
- package/statistics/summarizer/second-phase/process.d.ts +0 -15
- package/statistics/summarizer/second-phase/process.js +0 -118
- package/statistics/summarizer/summarizer.d.ts +0 -34
- package/statistics/summarizer/summarizer.js +0 -141
|
@@ -27,6 +27,7 @@ const resolve_by_name_1 = require("../dataflow/environments/resolve-by-name");
|
|
|
27
27
|
const default_pipelines_1 = require("../core/steps/pipeline/default-pipelines");
|
|
28
28
|
const text_1 = require("../util/text/text");
|
|
29
29
|
const linker_1 = require("../dataflow/internal/linker");
|
|
30
|
+
const apply_kill_1 = require("../dataflow/environments/apply-kill");
|
|
30
31
|
const doc_normalized_ast_1 = require("./doc-util/doc-normalized-ast");
|
|
31
32
|
const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
|
|
32
33
|
const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
|
|
@@ -44,7 +45,7 @@ const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
|
44
45
|
const range_1 = require("../util/range");
|
|
45
46
|
const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
46
47
|
const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
|
|
47
|
-
async function subExplanation(parser, { description, code, expectedSubgraph }) {
|
|
48
|
+
async function subExplanation(parser, ctx, { description, code, expectedSubgraph }) {
|
|
48
49
|
expectedSubgraph = await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
49
50
|
const marks = [];
|
|
50
51
|
for (const [id] of expectedSubgraph.vertices(true)) {
|
|
@@ -56,11 +57,11 @@ async function subExplanation(parser, { description, code, expectedSubgraph }) {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
return `
|
|
59
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set(marks) })}
|
|
60
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set(marks), ctx })}
|
|
60
61
|
|
|
61
62
|
${description}`;
|
|
62
63
|
}
|
|
63
|
-
async function printAllSubExplanations(parser, expls) {
|
|
64
|
+
async function printAllSubExplanations(parser, ctx, expls) {
|
|
64
65
|
let result = `
|
|
65
66
|
<details>
|
|
66
67
|
|
|
@@ -69,11 +70,11 @@ async function printAllSubExplanations(parser, expls) {
|
|
|
69
70
|
`;
|
|
70
71
|
for (const sub of expls) {
|
|
71
72
|
result += `#### ${sub.name}\n`;
|
|
72
|
-
result += await subExplanation(parser, sub) + '\n';
|
|
73
|
+
result += await subExplanation(parser, ctx, sub) + '\n';
|
|
73
74
|
}
|
|
74
75
|
return result + '\n\n</details>';
|
|
75
76
|
}
|
|
76
|
-
async function explanation({ name, type, description, code, expectedSubgraph }, parser, index, ...subExplanations) {
|
|
77
|
+
async function explanation({ name, type, description, code, expectedSubgraph }, parser, ctx, index, ...subExplanations) {
|
|
77
78
|
await (0, doc_dfg_1.verifyExpectedSubgraph)(parser, code, expectedSubgraph);
|
|
78
79
|
return `
|
|
79
80
|
<a id='${name.toLowerCase().replaceAll(' ', '-')}'> </a>
|
|
@@ -82,9 +83,9 @@ async function explanation({ name, type, description, code, expectedSubgraph },
|
|
|
82
83
|
|
|
83
84
|
Type: \`${type}\` (this is the bit-flag value, e.g., when looking at the serialization)
|
|
84
85
|
|
|
85
|
-
${await subExplanation(parser, { name, description, code, expectedSubgraph })}
|
|
86
|
+
${await subExplanation(parser, ctx, { name, description, code, expectedSubgraph })}
|
|
86
87
|
|
|
87
|
-
${subExplanations.length > 0 ? await printAllSubExplanations(parser, subExplanations) : ''}
|
|
88
|
+
${subExplanations.length > 0 ? await printAllSubExplanations(parser, ctx, subExplanations) : ''}
|
|
88
89
|
`;
|
|
89
90
|
}
|
|
90
91
|
function edgeTypeToId(edgeType) {
|
|
@@ -109,7 +110,7 @@ ${(0, doc_structure_1.block)({
|
|
|
109
110
|
type: 'NOTE',
|
|
110
111
|
content: `
|
|
111
112
|
The value is not stored in the vertex itself, but in the normalized AST.
|
|
112
|
-
To access the value, you can use the \`id\` of the vertex to access the respective node in the
|
|
113
|
+
To access the value, you can use the \`id\` of the vertex to access the respective node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}
|
|
113
114
|
and ask for the value associated with it.
|
|
114
115
|
`
|
|
115
116
|
})}
|
|
@@ -117,8 +118,8 @@ and ask for the value associated with it.
|
|
|
117
118
|
Please be aware that such nodes may be the result from language semantics as well, and not just from constants directly in the source.
|
|
118
119
|
For example, an access operation like \`df$column\` will treat the column name as a constant value.
|
|
119
120
|
|
|
120
|
-
${(0, doc_structure_1.details)('Example: Semantics Create a Value', `In the following graph, the original type printed by mermaid is still \`RSymbol\` (from the
|
|
121
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'df$column', { mark: new Set([1]) }))}
|
|
121
|
+
${(0, doc_structure_1.details)('Example: Semantics Create a Value', `In the following graph, the original type printed by mermaid is still \`RSymbol\` (from the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}), however, the shape of the vertex signals to you that the symbol is in-fact treated as a constant! If you do not know what \`df$column\` even means, please refer to the [R topic](https://rdrr.io/r/base/Extract.html).\n` +
|
|
122
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'df$column', { mark: new Set([1]), ctx }))}
|
|
122
123
|
`,
|
|
123
124
|
code: '42',
|
|
124
125
|
expectedSubgraph: (0, dataflowgraph_builder_1.emptyGraph)().constant('0')
|
|
@@ -149,29 +150,29 @@ Most often, you will see the _use_ vertex whenever a variable is read.
|
|
|
149
150
|
However, similar to the [value vertex](#value-vertex), the _use_ vertex can also be the result of language semantics.
|
|
150
151
|
Consider a case, in which we refer to a variable with a string, as in \`get("x")\`.
|
|
151
152
|
|
|
152
|
-
${(0, doc_structure_1.details)('Example: Semantics Create a Symbol', `In the following graph, the original type printed by mermaid is still \`RString\` (from the
|
|
153
|
+
${(0, doc_structure_1.details)('Example: Semantics Create a Symbol', `In the following graph, the original type printed by mermaid is still \`RString\` (from the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}), however, the shape of the vertex signals to you that the symbol is in-fact treated as a variable use! ` +
|
|
153
154
|
'If you are unsure what `get` does, refer to the [documentation](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/get). ' +
|
|
154
155
|
'Please note, that the lexeme being printed as `"x"` may be misleading (after all it is recovered from the AST), the quotes are not part of the reference.\n' +
|
|
155
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'get("x")', { mark: new Set([1]) }))}
|
|
156
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'get("x")', { mark: new Set([1]), ctx }))}
|
|
156
157
|
|
|
157
158
|
But now to the interesting stuff: how do we actually know which values are read by the respective variable use?
|
|
158
159
|
This usually involves a [variable definition](#variable-definition-vertex) and a [reads edge](#reads-edge) linking the two.
|
|
159
160
|
|
|
160
161
|
${(0, doc_structure_1.details)('Example: Reads Edge Identifying a Single Definition', 'In the following graph, the `x` is read from the definition `x <- 1`.\n' +
|
|
161
|
-
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nprint(x)', { mark: new Set([3, '0->3']), codeOpen: true }))}
|
|
162
|
+
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nprint(x)', { mark: new Set([3, '0->3']), codeOpen: true, ctx }))}
|
|
162
163
|
|
|
163
164
|
In general, there may be many such edges, identifying every possible definition of the variable.
|
|
164
165
|
|
|
165
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (conditional)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nif(u) x <- 2\nprint(x)', { mark: new Set([10, '10->0', '10->4']), codeOpen: true }))}
|
|
166
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (loop)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nfor(i in v) x <- 2\nprint(x)', { mark: new Set([11, '11->0', '11->5']), codeOpen: true }))}
|
|
167
|
-
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (side-effect)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 2\nx <- 2\nif(u) f()\nprint(x)', { mark: new Set([16, '16->1', '16->7']), codeOpen: true }))}
|
|
166
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (conditional)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nif(u) x <- 2\nprint(x)', { mark: new Set([10, '10->0', '10->4']), codeOpen: true, ctx }))}
|
|
167
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (loop)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 1\nfor(i in v) x <- 2\nprint(x)', { mark: new Set([11, '11->0', '11->5']), codeOpen: true, ctx }))}
|
|
168
|
+
${(0, doc_structure_1.details)('Example: Reads Edge Identifying Multiple Definitions (side-effect)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 2\nx <- 2\nif(u) f()\nprint(x)', { mark: new Set([16, '16->1', '16->7']), codeOpen: true, ctx }))}
|
|
168
169
|
|
|
169
170
|
${(0, doc_structure_1.block)({
|
|
170
171
|
type: 'IMPORTANT',
|
|
171
172
|
content: `
|
|
172
173
|
If you want to obtain the locations where a variable is defined, or read, or re-defined, refrain from tracking these details manually in the dataflow graph
|
|
173
174
|
as there are some edge-cases that require special attention.
|
|
174
|
-
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (which is also available as ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function explained below in
|
|
175
|
+
In general, the ${ctx.link(dfg_get_origin_1.getOriginInDfg)} (which is also available as ${ctx.linkO(df_helper_1.Dataflow, 'origin')}) function explained below in ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')} will help you to get the information you need.
|
|
175
176
|
`
|
|
176
177
|
})}
|
|
177
178
|
|
|
@@ -202,7 +203,7 @@ However, in general, flowR may use any fitting handler as an origin (see the ${c
|
|
|
202
203
|
|
|
203
204
|
${(0, doc_structure_1.details)('Example: Simple Function Call (unresolved)', await (async () => {
|
|
204
205
|
const code = 'foo(x,3,y=3,)';
|
|
205
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([8]), exposeResult: true });
|
|
206
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([8]), exposeResult: true, ctx });
|
|
206
207
|
const callInfo = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionCall && identifier_1.Identifier.getName(vertex.name) === 'foo');
|
|
207
208
|
(0, assert_1.guard)(callInfo !== undefined, () => `Could not find call vertex for ${code}`);
|
|
208
209
|
const [callId, callVert] = callInfo;
|
|
@@ -246,14 +247,14 @@ ${(0, doc_structure_1.block)({
|
|
|
246
247
|
content: `
|
|
247
248
|
But how do you know which definitions are actually called by the function?
|
|
248
249
|
|
|
249
|
-
So first of all, some frontends of _flowR_ (like the ${(0, doc_cli_option_1.getReplCommand)('slicer')} and ${(0, doc_cli_option_1.getReplCommand)('query')} with the
|
|
250
|
+
So first of all, some frontends of _flowR_ (like the ${(0, doc_cli_option_1.getReplCommand)('slicer')} and ${(0, doc_cli_option_1.getReplCommand)('query')} with the ${ctx.linkPage('wiki/Query API', 'Query API')}) already provide you with this information.
|
|
250
251
|
In general there are three scenarios you may be interested in:
|
|
251
252
|
|
|
252
253
|
${(0, doc_structure_1.details)('1) the function resolves only to builtin definitions (like <code><-</code>)', `
|
|
253
254
|
|
|
254
255
|
Let's have a look at a simple assignment:
|
|
255
256
|
|
|
256
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2')}
|
|
257
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2', { ctx })}
|
|
257
258
|
|
|
258
259
|
In this case, the call does not have a single ${linkEdgeName(edge_1.EdgeType.Calls)} edge, which in general means (i.e., if the analysis is done and you are not looking at an intermediate result) it is bound to anything
|
|
259
260
|
global beyond the scope of the given script. _flowR_ generally (theoretically at least) does not know if the call really refers to a built-in variable or function,
|
|
@@ -268,7 +269,7 @@ Let's have a look at a call to a function named \`foo\` which is defined in the
|
|
|
268
269
|
|
|
269
270
|
${await (async () => {
|
|
270
271
|
const code = 'foo <- function() 3\nfoo()';
|
|
271
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { exposeResult: true, mark: new Set([6, '6->0', '6->1', '6->3']) });
|
|
272
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { exposeResult: true, mark: new Set([6, '6->0', '6->1', '6->3']), ctx });
|
|
272
273
|
const numberOfEdges = [...info.dataflow.graph.edges()].flatMap(e => [...e[1].keys()]).length;
|
|
273
274
|
const callVertex = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionCall && identifier_1.Identifier.getName(vertex.name) === 'foo');
|
|
274
275
|
(0, assert_1.guard)(callVertex !== undefined, () => `Could not find call vertex for ${code}`);
|
|
@@ -283,7 +284,7 @@ While it seems to be somewhat redundant given the ${linkEdgeName(edge_1.EdgeType
|
|
|
283
284
|
you have to consider cases in which aliases are involved in the call resolution (e.g., with higher order functions).
|
|
284
285
|
|
|
285
286
|
${(0, doc_structure_1.details)('Example: Alias in Call Resolution', `In the following example, \`g\` ${linkEdgeName(edge_1.EdgeType.Reads)} the previous definition, but ${linkEdgeName(edge_1.EdgeType.Calls)} the function assigned to \`f\`.\n`
|
|
286
|
-
+ await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() 3\ng <- f\ng()', { mark: new Set(['9', '9->5', '9->3']) }))}
|
|
287
|
+
+ await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() 3\ng <- f\ng()', { mark: new Set(['9', '9->5', '9->3']), ctx }))}
|
|
287
288
|
|
|
288
289
|
Lastly, the ${linkEdgeName(edge_1.EdgeType.Returns)} edge links the call to the return vertices(s) of the function.
|
|
289
290
|
Please be aware, that these multiple exit points may be counter intuitive as they often appear with a nested call (usually a call to the built-in \`{\` function).
|
|
@@ -294,7 +295,7 @@ f <- function() {
|
|
|
294
295
|
if(v) return(2)
|
|
295
296
|
1
|
|
296
297
|
}
|
|
297
|
-
f()`.trim(), { mark: new Set([22, '22->18']) }) +
|
|
298
|
+
f()`.trim(), { mark: new Set([22, '22->18']), ctx }) +
|
|
298
299
|
`
|
|
299
300
|
In this case the call of \`f\` still only has one ${linkEdgeName(edge_1.EdgeType.Returns)} edge, although the function _looks_ as if it would have multiple exit points!
|
|
300
301
|
But you have to beware that \`{\` is a function call as well (see below) and it may be redefined, or at least affect the actual returns of the function.
|
|
@@ -315,7 +316,7 @@ Users may write… interesting pieces of code - for reasons we should not be int
|
|
|
315
316
|
Consider a case in which you have a built-in function (like the assignment operator \`<-\`) and a user that wants to redefine the meaning of the function call _sometimes_:
|
|
316
317
|
|
|
317
318
|
${await (async () => {
|
|
318
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2\nif(u) `<-` <- `*`\nx <- 3', { switchCodeAndGraph: true, mark: new Set([9, '9->0', '9->10']), exposeResult: true });
|
|
319
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 2\nif(u) `<-` <- `*`\nx <- 3', { switchCodeAndGraph: true, mark: new Set([9, '9->0', '9->10']), exposeResult: true, ctx });
|
|
319
320
|
const interestingUseOfAssignment = info.dataflow.graph.vertices(true).find(([, vertex]) => vertex.id === 11);
|
|
320
321
|
(0, assert_1.guard)(interestingUseOfAssignment !== undefined, () => 'Could not find interesting assignment vertex for the code');
|
|
321
322
|
const [id, interestingVertex] = interestingUseOfAssignment;
|
|
@@ -350,18 +351,18 @@ Similarly, trying to resolve the name with ${ctx.link(resolve_by_name_1.resolveB
|
|
|
350
351
|
|
|
351
352
|
|
|
352
353
|
Similar to finding the definitions read by a variable use, please use the ${ctx.link(linker_1.getAllFunctionCallTargets)} function to find all possible definitions of a function call,
|
|
353
|
-
as explained in the
|
|
354
|
+
as explained in the ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')} section.`
|
|
354
355
|
})}
|
|
355
356
|
|
|
356
357
|
Function calls are the most complicated mechanism in R as essentially everything is a function call.
|
|
357
358
|
Even **control structures** like \`if(p) a else b\` are desugared into function calls (e.g., as \`\` \`if\`(p, a, b) \`\`).
|
|
358
|
-
${(0, doc_structure_1.details)('Example: <code>if</code> as a Function Call', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'if(p) a else b'))}
|
|
359
|
+
${(0, doc_structure_1.details)('Example: <code>if</code> as a Function Call', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'if(p) a else b', { ctx }))}
|
|
359
360
|
|
|
360
361
|
Similarly, you should be aware of calls to **anonymous functions**, which may appear given directly (e.g. as \`(function() 1)()\`) or indirectly, with code
|
|
361
362
|
directly calling the return of another function call: \`foo()()\`.
|
|
362
|
-
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given directly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, '(function() 1)()', { mark: new Set([6, '6->4']) }))}
|
|
363
|
+
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given directly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, '(function() 1)()', { mark: new Set([6, '6->4']), ctx }))}
|
|
363
364
|
|
|
364
|
-
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given indirectly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'foo <- function() return(function() 3)\nfoo()()', { mark: new Set([12, '12->4']) }))}
|
|
365
|
+
${(0, doc_structure_1.details)('Example: Anonymous Function Call (given indirectly)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'foo <- function() return(function() 3)\nfoo()()', { mark: new Set([12, '12->4']), ctx }))}
|
|
365
366
|
|
|
366
367
|
${(0, doc_structure_1.block)({
|
|
367
368
|
type: 'NOTE',
|
|
@@ -372,7 +373,7 @@ But in short: the \`origin\` attribute of the ${ctx.link('DataflowGraphVertexFun
|
|
|
372
373
|
Please be aware that unnamed functions still have a \`name\` property to give it a unique identifier that can be used for debugging and reference.
|
|
373
374
|
This name _always_ starts with \`${unnamed_call_handling_1.UnnamedFunctionCallPrefix}\`.
|
|
374
375
|
|
|
375
|
-
To identify these calls please do not rely on the
|
|
376
|
+
To identify these calls please do not rely on the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}. An expression like \`1 + 1\` will be correctly
|
|
376
377
|
identified as a syntactical binary operation. Yet, from a dataflow/semantic perspective this is equivalent to \`\` \`+\`(1, 1) \`\` (which is a named function call and marked as such in the dataflow graph).
|
|
377
378
|
To know which function is called, please rely on the ${linkEdgeName(edge_1.EdgeType.Calls)} edge.
|
|
378
379
|
`
|
|
@@ -380,7 +381,7 @@ To know which function is called, please rely on the ${linkEdgeName(edge_1.EdgeT
|
|
|
380
381
|
|
|
381
382
|
Another interesting case is a function with **side effects**, most prominently with the super-assignment \`<<-\`.
|
|
382
383
|
In this case, you may encounter the ${linkEdgeName(edge_1.EdgeType.SideEffectOnCall)} as exemplified below.
|
|
383
|
-
${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 3\n f()', { mark: new Set([8, '1->8']) }))}
|
|
384
|
+
${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() x <<- 3\n f()', { mark: new Set([8, '1->8']), ctx }))}
|
|
384
385
|
|
|
385
386
|
`,
|
|
386
387
|
code: 'foo()',
|
|
@@ -392,7 +393,7 @@ ${(0, doc_structure_1.details)('Example: Function Call with a Side-Effect', awai
|
|
|
392
393
|
description: `
|
|
393
394
|
Defined variables most commonly occur in the context of an assignment, for example, with the \`<-\` operator as shown above.
|
|
394
395
|
|
|
395
|
-
${(0, doc_structure_1.details)('Example: Super Definition (<code><<-</code>)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <<- 1', { mark: new Set([0]) }))}
|
|
396
|
+
${(0, doc_structure_1.details)('Example: Super Definition (<code><<-</code>)', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <<- 1', { mark: new Set([0]), ctx }))}
|
|
396
397
|
|
|
397
398
|
The implementation is relatively sparse and similar to the other marker vertices:
|
|
398
399
|
|
|
@@ -401,18 +402,18 @@ Of only interest is \`par\`, which signals that the definitions is partial (e.g.
|
|
|
401
402
|
|
|
402
403
|
Of course, there are not just operators that define variables, but also functions, like \`assign\`.
|
|
403
404
|
|
|
404
|
-
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]) })
|
|
405
|
+
${(0, doc_structure_1.details)('Example: Using <code>assign</code>', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'assign("x", 1)\nx', { mark: new Set([1]), ctx })
|
|
405
406
|
+ `\nThe example may be misleading as the visualization uses \`${node_id_1.recoverName.name}\` to print the lexeme of the variable. However, this actually defines the variable \`x\` (without the quotes) as you can see with the ${linkEdgeName(edge_1.EdgeType.Reads)} edge.`)}
|
|
406
407
|
|
|
407
408
|
Please be aware, that the name of the symbol defined may differ from what you read in the program as R allows the assignments to strings, escaped names, and more:
|
|
408
409
|
|
|
409
|
-
${(0, doc_structure_1.details)('Example: Assigning with an Escaped Name', await (0, doc_dfg_1.printDfGraphForCode)(parser, '`x` <- 1\nx', { mark: new Set([0]) }))}
|
|
410
|
-
${(0, doc_structure_1.details)('Example: Assigning with a String', await (0, doc_dfg_1.printDfGraphForCode)(parser, '"x" <- 1\nx', { mark: new Set([0]) }))}
|
|
410
|
+
${(0, doc_structure_1.details)('Example: Assigning with an Escaped Name', await (0, doc_dfg_1.printDfGraphForCode)(parser, '`x` <- 1\nx', { mark: new Set([0]), ctx }))}
|
|
411
|
+
${(0, doc_structure_1.details)('Example: Assigning with a String', await (0, doc_dfg_1.printDfGraphForCode)(parser, '"x" <- 1\nx', { mark: new Set([0]), ctx }))}
|
|
411
412
|
|
|
412
413
|
Definitions may be constrained by conditionals (_flowR_ takes care of calculating the dominating front for you).
|
|
413
414
|
|
|
414
415
|
${(0, doc_structure_1.details)('Conditional Assignments', await (async () => {
|
|
415
|
-
const constrainedDefinitions = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 0\nif(u) x <- 1 else x <- 2\nx', { exposeResult: true });
|
|
416
|
+
const constrainedDefinitions = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 0\nif(u) x <- 1 else x <- 2\nx', { exposeResult: true, ctx });
|
|
416
417
|
const [text, info] = constrainedDefinitions;
|
|
417
418
|
const finalEnvironment = (0, doc_env_1.printEnvironmentToMarkdown)(info.dataflow.environment.current);
|
|
418
419
|
return `
|
|
@@ -456,7 +457,7 @@ the actual dataflow graph is flat, and you can query all root vertices (i.e., th
|
|
|
456
457
|
vertices of function definitions or not (e.g., \`${new graph_1.DataflowGraph(undefined).vertices.name}\`)
|
|
457
458
|
|
|
458
459
|
${(0, doc_structure_1.details)('Example: Nested Function Definitions', await (async () => {
|
|
459
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { g <- function() 3 }', { mark: new Set([9, 6]), exposeResult: true });
|
|
460
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { g <- function() 3 }', { mark: new Set([9, 6]), exposeResult: true, ctx });
|
|
460
461
|
const definitions = info.dataflow.graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
461
462
|
.map(([id, vertex]) => `| \`${id}\` | { \`${[...vertex.subflow.graph].join('`, `')}\` } |`)
|
|
462
463
|
.toArray();
|
|
@@ -474,12 +475,12 @@ ${definitions.join('\n')}
|
|
|
474
475
|
|
|
475
476
|
But now there is still an open question: how do you know which vertices are the parameters?
|
|
476
477
|
In short: there is no direct way to infer this from the dataflow graph (as parameters are handled as open references which are promises).
|
|
477
|
-
However, you can use the
|
|
478
|
+
However, you can use the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} to get the parameters used.
|
|
478
479
|
|
|
479
480
|
${(0, doc_structure_1.details)('Example: Parameters of a Function', await (async () => {
|
|
480
481
|
const code = 'f <- function(x, y = 3) x + y';
|
|
481
|
-
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([10, 1, 3]), exposeResult: true });
|
|
482
|
-
const ast = await (0, doc_normalized_ast_1.printNormalizedAstForCode)(parser, code, { prefix: 'flowchart LR\n', showCode: false });
|
|
482
|
+
const [text, info] = await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { mark: new Set([10, 1, 3]), exposeResult: true, ctx });
|
|
483
|
+
const ast = await (0, doc_normalized_ast_1.printNormalizedAstForCode)(parser, code, { prefix: 'flowchart LR\n', showCode: false, ctx });
|
|
483
484
|
const functionDefinition = [...info.dataflow.graph.vertices(true)].find(([, vertex]) => vertex.tag === vertex_1.VertexType.FunctionDefinition);
|
|
484
485
|
(0, assert_1.guard)(functionDefinition !== undefined, () => `Could not find function definition for ${code}`);
|
|
485
486
|
const [id] = functionDefinition;
|
|
@@ -489,7 +490,7 @@ Let's first consider the following dataflow graph (of \`${code}\`):
|
|
|
489
490
|
|
|
490
491
|
${text}
|
|
491
492
|
|
|
492
|
-
The function definition we are interested in has the id \`${id}\`. Looking at the
|
|
493
|
+
The function definition we are interested in has the id \`${id}\`. Looking at the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} of the code,
|
|
493
494
|
we can get the parameters simply be requesting the \`parameters\` property of the function definition (yielding the names: [${normalized.parameters.map(p => `\`${p.name.content}\``).join(', ')}]):
|
|
494
495
|
|
|
495
496
|
${ast}
|
|
@@ -500,7 +501,7 @@ ${ast}
|
|
|
500
501
|
|
|
501
502
|
Last but not least, please keep in mind that R offers another way of writing anonymous functions (using the backslash):
|
|
502
503
|
|
|
503
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(parser, '\\(x) x + 1', { switchCodeAndGraph: true })}
|
|
504
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(parser, '\\(x) x + 1', { switchCodeAndGraph: true, ctx })}
|
|
504
505
|
|
|
505
506
|
Besides this being a theoretically "shorter" way of defining a function, this behaves similarly to the use of \`function\`.
|
|
506
507
|
|
|
@@ -514,7 +515,7 @@ Besides this being a theoretically "shorter" way of defining a function, this be
|
|
|
514
515
|
const get = vertexExplanations.get(vertex);
|
|
515
516
|
(0, assert_1.guard)(get !== undefined, () => `No explanation for vertex type ${vertex}`);
|
|
516
517
|
const [expl, subExplanations] = get;
|
|
517
|
-
results.push(await explanation(expl, parser, ++i, ...subExplanations));
|
|
518
|
+
results.push(await explanation(expl, parser, ctx, ++i, ...subExplanations));
|
|
518
519
|
}
|
|
519
520
|
return results.join('\n');
|
|
520
521
|
}
|
|
@@ -533,13 +534,13 @@ A ${linkEdgeName(edge_1.EdgeType.Reads)} edge is not a transitive closure and on
|
|
|
533
534
|
Our abstract domains resolving transitive ${linkEdgeName(edge_1.EdgeType.Reads)} edges (and for that matter, following ${linkEdgeName(edge_1.EdgeType.Returns)} as well)
|
|
534
535
|
are currently tailored to what we need in _flowR_. Hence, we offer a function like ${ctx.link(linker_1.getAllFunctionCallTargets)},
|
|
535
536
|
as well as ${ctx.link(resolve_by_name_1.resolvesToBuiltInConstant)} which do this for specific cases.
|
|
536
|
-
Refer to ${ctx.link(dfg_get_origin_1.getOriginInDfg)} for a more general solution, as explained in
|
|
537
|
+
Refer to ${ctx.link(dfg_get_origin_1.getOriginInDfg)} for a more general solution, as explained in ${ctx.linkPage('wiki/Dataflow Graph', 'working with the dataflow graph', 'dfg-working')}.
|
|
537
538
|
|
|
538
|
-
${(0, doc_structure_1.details)('Example: Multi-Level Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 3\ny <- x\nprint(y)', { mark: new Set(['9->7', '7->3', '4->0']) }))}
|
|
539
|
+
${(0, doc_structure_1.details)('Example: Multi-Level Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'x <- 3\ny <- x\nprint(y)', { mark: new Set(['9->7', '7->3', '4->0']), ctx }))}
|
|
539
540
|
|
|
540
541
|
Similarly, ${linkEdgeName(edge_1.EdgeType.Reads)} can be cyclic, for example in the context of loops:
|
|
541
542
|
|
|
542
|
-
${(0, doc_structure_1.details)('Example: Cyclic Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) x <- x + 1', { mark: new Set(['3->2']) }))}
|
|
543
|
+
${(0, doc_structure_1.details)('Example: Cyclic Reads', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) x <- x + 1', { mark: new Set(['3->2']), ctx }))}
|
|
543
544
|
`
|
|
544
545
|
})}
|
|
545
546
|
|
|
@@ -567,7 +568,7 @@ Please refer to the explanation of the respective vertices for more information.
|
|
|
567
568
|
type: edge_1.EdgeType.DefinedBy,
|
|
568
569
|
description: `
|
|
569
570
|
The source vertex is usually a [\`variable definition\`](#variable-definition-vertex) linking the defined symbol to the entry point of the resulting side.
|
|
570
|
-
${(0, doc_structure_1.details)('In general, this does not have to be the right hand side of the operator.', await (0, doc_dfg_1.printDfGraphForCode)(parser, '3 -> x', { mark: new Set([0]) }))}
|
|
571
|
+
${(0, doc_structure_1.details)('In general, this does not have to be the right hand side of the operator.', await (0, doc_dfg_1.printDfGraphForCode)(parser, '3 -> x', { mark: new Set([0]), ctx }))}
|
|
571
572
|
|
|
572
573
|
However, nested definitions can carry it (in the nested case, \`x\` is defined by the return value of <code>\\\`<-\\\`(y, z)</code>). Additionally, we link the assignment function.
|
|
573
574
|
|
|
@@ -603,7 +604,7 @@ As you can see in the example, this happens for user-defined functions (like \`f
|
|
|
603
604
|
However, these edges are specific to scenarios in which flowR knows that a specific element is returned.
|
|
604
605
|
For contrast, compare this to a use of, for example, \`+\`:
|
|
605
606
|
|
|
606
|
-
${(0, doc_structure_1.details)('Example: No returns edge for +', await (0, doc_dfg_1.printDfGraphForCode)(parser, '1 + 1'))}
|
|
607
|
+
${(0, doc_structure_1.details)('Example: No returns edge for +', await (0, doc_dfg_1.printDfGraphForCode)(parser, '1 + 1', { ctx }))}
|
|
607
608
|
|
|
608
609
|
Here, we do not get a ${linkEdgeName(edge_1.EdgeType.Returns)} edge as this function call creates a new value based on its arguments.
|
|
609
610
|
In these scenarios you should rely on the \`args\` property of the ${ctx.link('DataflowGraphVertexFunctionCall')}
|
|
@@ -615,7 +616,8 @@ In general, the ${linkEdgeName(edge_1.EdgeType.Returns)} edge already does most
|
|
|
615
616
|
${(0, doc_structure_1.details)('Example: Tricky Returns', `We show the _simplified_ DFG for simplicity and highlight all ${linkEdgeName(edge_1.EdgeType.Returns)} edges involved in tracking the return of a call to \`f\` (as ${linkEdgeName(edge_1.EdgeType.Returns)} are never transitive and must hence be followed):\n` +
|
|
616
617
|
await (0, doc_dfg_1.printDfGraphForCode)(parser, 'f <- function() { if(u) { return(3); 2 } else 42 }\nf()', {
|
|
617
618
|
simplified: true,
|
|
618
|
-
mark: new Set(['19->15', '15->14', '14->12', '14->11', '11->9', '9->7'])
|
|
619
|
+
mark: new Set(['19->15', '15->14', '14->12', '14->11', '11->9', '9->7']),
|
|
620
|
+
ctx
|
|
619
621
|
})
|
|
620
622
|
+ '\n\n Note, that the `2` should be completely absent of the dataflow graph (recognized as dead code).')}
|
|
621
623
|
<br/>
|
|
@@ -625,7 +627,7 @@ ${(0, doc_structure_1.block)({
|
|
|
625
627
|
content: `You might find it an inconvenience that there is no ${linkEdgeName(edge_1.EdgeType.Returns)} edge for _every_ function call.
|
|
626
628
|
If there is particular function for which you think flowR should be able to detect the return, please open a [new issue](${doc_issue_1.NewIssueUrl}).
|
|
627
629
|
Yet the problem of flowR not tracking returns for functions that create new/transform existing values is a fundamental design decision — if this irritates you ~~you may be eligible for compensation~~, you may be interested in an
|
|
628
|
-
alternative with the
|
|
630
|
+
alternative with the ${ctx.linkPage('wiki/Control Flow Graph', 'Control Flow Graph', 'cfg-exit-points')} which not just tracks all possible execution orders of the program,
|
|
629
631
|
but also the exit points of _all_ function calls.
|
|
630
632
|
`
|
|
631
633
|
})}
|
|
@@ -638,7 +640,7 @@ f <- function() x
|
|
|
638
640
|
x <- 3
|
|
639
641
|
f()
|
|
640
642
|
`.trim();
|
|
641
|
-
const dfInfo = await (0, doc_dfg_1.printDfGraphForCode)(parser, lateBindingExample, { switchCodeAndGraph: true, codeOpen: true, mark: new Set([1, '1->5', '9->5']) });
|
|
643
|
+
const dfInfo = await (0, doc_dfg_1.printDfGraphForCode)(parser, lateBindingExample, { switchCodeAndGraph: true, codeOpen: true, mark: new Set([1, '1->5', '9->5']), ctx });
|
|
642
644
|
edgeExplanations.set(edge_1.EdgeType.DefinesOnCall, [{
|
|
643
645
|
name: 'DefinesOnCall Edge',
|
|
644
646
|
type: edge_1.EdgeType.DefinesOnCall,
|
|
@@ -705,8 +707,8 @@ Yet, you may choose to follow these references for other queries. For now, _flow
|
|
|
705
707
|
Besides the obvious quotation there are other cases in which _flowR_ may choose to create a ${linkEdgeName(edge_1.EdgeType.NonStandardEvaluation)} edge, there are
|
|
706
708
|
some that may appear to be counter-intuitive. For example, a for-loop body, as in the following example.
|
|
707
709
|
|
|
708
|
-
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) b', { mark: new Set([2, '4->2']) }))}
|
|
709
|
-
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'while(TRUE) b', { mark: new Set([1, '3->1']) }))}
|
|
710
|
+
${(0, doc_structure_1.details)('Example: For-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'for(i in v) b', { mark: new Set([2, '4->2']), ctx }))}
|
|
711
|
+
${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.printDfGraphForCode)(parser, 'while(TRUE) b', { mark: new Set([1, '3->1']), ctx }))}
|
|
710
712
|
`
|
|
711
713
|
})}
|
|
712
714
|
`,
|
|
@@ -727,7 +729,7 @@ ${(0, doc_structure_1.details)('Example: While-Loop Body', await (0, doc_dfg_1.p
|
|
|
727
729
|
const get = edgeExplanations.get(edge);
|
|
728
730
|
(0, assert_1.guard)(get !== undefined, () => `No explanation for edge type ${edge}`);
|
|
729
731
|
const [expl, subExplanations] = get;
|
|
730
|
-
results.push(`<a id='${edgeTypeToId(edge)}'></a>` + await explanation(expl, parser, ++i, ...subExplanations));
|
|
732
|
+
results.push(`<a id='${edgeTypeToId(edge)}'></a>` + await explanation(expl, parser, ctx, ++i, ...subExplanations));
|
|
731
733
|
}
|
|
732
734
|
return results.join('\n');
|
|
733
735
|
}
|
|
@@ -774,7 +776,7 @@ Additionally, you may be interested in the [Unknown Side Effects](#unknown-side-
|
|
|
774
776
|
> There is also a simplified version available with ${ctx.replCmd('dataflowsimple*')} that does not show everything but is easier to read.
|
|
775
777
|
> For small graphs, you can also use ${ctx.replCmd('dataflowascii')} to print the graph as ASCII art.
|
|
776
778
|
>
|
|
777
|
-
> If you receive a dataflow graph in its serialized form (e.g., by talking to a
|
|
779
|
+
> If you receive a dataflow graph in its serialized form (e.g., by talking to a ${ctx.linkPage('wiki/Interface', '_flowR_ server')}), you can use ${ctx.linkM(graph_1.DataflowGraph, 'fromJson', { realNameWrapper: 'i', codeFont: true })} to recover the graph object.
|
|
778
780
|
>
|
|
779
781
|
> Also, check out the [${doc_files_1.FlowrGithubGroupName}/sample-analyzer-df-diff](${doc_files_1.FlowrGithubBaseRef}/sample-analyzer-df-diff) repository for a complete example project creating and comparing dataflow graphs.
|
|
780
782
|
|
|
@@ -783,7 +785,7 @@ ${(0, doc_code_1.codeBlock)('r', introExampleCode)}
|
|
|
783
785
|
|
|
784
786
|
With this code, the corresponding dataflow graph looks like this:
|
|
785
787
|
|
|
786
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, introExampleCode, { showCode: false })}
|
|
788
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, introExampleCode, { showCode: false, ctx })}
|
|
787
789
|
|
|
788
790
|
The above dataflow graph showcases the general gist. We define a dataflow graph as a directed graph G = (V, E),
|
|
789
791
|
differentiating between ${(0, doc_data_dfg_util_1.getAllVertices)().length} types of vertices V and
|
|
@@ -791,7 +793,7 @@ ${(0, doc_data_dfg_util_1.getAllEdges)().length} types of edges E allowing
|
|
|
791
793
|
Additionally, every node may have links to its [control dependencies](#control-dependencies) (which you may view as a ${(0, text_1.nth)((0, doc_data_dfg_util_1.getAllEdges)().length + 1)} edge type,
|
|
792
794
|
although they are explicitly no data dependency and relate to the ${ctx.linkPage('wiki/Control Flow Graph')}.
|
|
793
795
|
|
|
794
|
-
${(0, doc_structure_1.details)('Simplified Version of the graph', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'x <- 3\ny <- x + 1\ny', { simplified: true, showCode: false }))}
|
|
796
|
+
${(0, doc_structure_1.details)('Simplified Version of the graph', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'x <- 3\ny <- x + 1\ny', { simplified: true, showCode: false, ctx }))}
|
|
795
797
|
|
|
796
798
|
The following vertices types exist:
|
|
797
799
|
|
|
@@ -812,16 +814,16 @@ From an implementation perspective all of these types are represented by respect
|
|
|
812
814
|
The following sections present details on the different types of vertices and edges, including examples and explanations.
|
|
813
815
|
|
|
814
816
|
> [!NOTE]
|
|
815
|
-
> Every dataflow vertex holds an \`id\` which links it to the respective node in the
|
|
817
|
+
> Every dataflow vertex holds an \`id\` which links it to the respective node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')}.
|
|
816
818
|
> So if you want more information about the respective vertex, you can usually access more information
|
|
817
819
|
> using the <code>${ctx.link(`${graph_1.DataflowGraph.name}`, { codeFont: false, realNameWrapper: 'i' })}::idMap</code> linked to the dataflow graph:
|
|
818
820
|
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', 'const node = graph.idMap.get(id);'), '> ')}
|
|
819
821
|
> In case you just need the name (\`lexeme\`) of the respective vertex, ${ctx.link(node_id_1.recoverName)} can help you out:
|
|
820
822
|
${(0, doc_general_1.prefixLines)((0, doc_code_1.codeBlock)('ts', `const name = ${node_id_1.recoverName.name}(id, graph.idMap);`), '> ')}
|
|
821
823
|
>
|
|
822
|
-
> Please note, that not every node in the
|
|
824
|
+
> Please note, that not every node in the ${ctx.linkPage('wiki/Normalized AST', 'normalized AST')} is represented in the dataflow graph.
|
|
823
825
|
> For example, if the node is unreachable in a way that can be detected during the analysis and flowR
|
|
824
|
-
> is configured to ignore dead code (there are more powerful dead code capabilities with the
|
|
826
|
+
> is configured to ignore dead code (there are more powerful dead code capabilities with the ${ctx.linkPage('wiki/Control Flow Graph', 'CFG')}). Likewise, empty argument wrappers do not have a corresponding
|
|
825
827
|
> dataflow graph vertex (as they are not relevant for the dataflow graph). It depends on the scenario what to do in such a case.
|
|
826
828
|
> For argument wrappers you can access the dataflow information for their value. For dead code, however, flowR currently contains
|
|
827
829
|
> some core heuristics that remove it which cannot be reversed easily. So please open [an issue](${doc_issue_1.NewIssueUrl}) if you encounter such a case and require the node to be present in the dataflow graph.
|
|
@@ -831,7 +833,7 @@ ${(0, doc_structure_1.section)('Reading the Visualizations', 2, 'reading-the-vis
|
|
|
831
833
|
Before we dive into the details of the different vertices and edges, let's briefly talk about how to read the visualizations.
|
|
832
834
|
For this, let's have a look at a very simple graph, created for the number \`42\`:
|
|
833
835
|
|
|
834
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, '42', { showCode: false })}
|
|
836
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, '42', { showCode: false, ctx })}
|
|
835
837
|
|
|
836
838
|
${(0, doc_structure_1.section)('Vertex Shape', 3, 'vtx-shape')}
|
|
837
839
|
|
|
@@ -867,7 +869,7 @@ In the second line, you will usually find the id (in the form of a ${ctx.link(no
|
|
|
867
869
|
alongside its [control dependencies](#control-dependencies) if it has any. This id links the vertex to the respective node in the ${ctx.linkPage('wiki/Normalized AST')} (and all other perspectives created by flowR).
|
|
868
870
|
To give you an example, have a look at the following graph:
|
|
869
871
|
|
|
870
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(u) a', { showCode: false, mark: new Set(['1']) })}
|
|
872
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(u) a', { showCode: false, mark: new Set(['1']), ctx })}
|
|
871
873
|
With the _may_ prefix you can see that \`a\` has a [control dependency](#control-dependencies)
|
|
872
874
|
on the \`if\`, which only triggers when the condition is \`true\` (as indicated by the \`+\` suffix).
|
|
873
875
|
|
|
@@ -904,21 +906,21 @@ and a boolean flag \`when\` to indicate if the control dependency is active when
|
|
|
904
906
|
|
|
905
907
|
As an example, consider the following dataflow graph:
|
|
906
908
|
|
|
907
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a else b')}
|
|
909
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a else b', { ctx })}
|
|
908
910
|
|
|
909
911
|
Whenever we visualize a graph, we represent the control dependencies as grayed out edges with a \`CD\` prefix, followed
|
|
910
912
|
by the \`when\` flag.
|
|
911
913
|
In the above example, both \`a\` and \`b\` depend on the \`if\`. Please note that they are _not_ linked to the result of
|
|
912
914
|
the condition itself as this is the more general linkage point (and harmonizes with other control structures, especially those which are user-defined).
|
|
913
915
|
|
|
914
|
-
${(0, doc_structure_1.details)('Example: Multiple Vertices (Assignment)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a <- 1'))}
|
|
915
|
-
${(0, doc_structure_1.details)('Example: Multiple Vertices (Arithmetic Expression)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) 3 + 2'))}
|
|
916
|
-
${(0, doc_structure_1.details)('Example: Nested Conditionals', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(x) { if(y) a else b } else c'))}
|
|
916
|
+
${(0, doc_structure_1.details)('Example: Multiple Vertices (Assignment)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) a <- 1', { ctx }))}
|
|
917
|
+
${(0, doc_structure_1.details)('Example: Multiple Vertices (Arithmetic Expression)', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(p) 3 + 2', { ctx }))}
|
|
918
|
+
${(0, doc_structure_1.details)('Example: Nested Conditionals', await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'if(x) { if(y) a else b } else c', { ctx }))}
|
|
917
919
|
|
|
918
920
|
|
|
919
921
|
${(0, doc_structure_1.section)('Dataflow Information', 2, 'dataflow-information')}
|
|
920
922
|
|
|
921
|
-
Using _flowR's_ code interface (see the
|
|
923
|
+
Using _flowR's_ code interface (see the ${ctx.linkPage('wiki/Interface', 'Interface', 'creating-flowr-analyses')} wiki page for more), you can generate the dataflow information
|
|
922
924
|
for a given piece of R code (in this case \`x <- 1; x + 1\`) as follows:
|
|
923
925
|
|
|
924
926
|
${(0, doc_code_1.codeBlock)('ts', `
|
|
@@ -964,7 +966,7 @@ Let's start by looking at the properties of the dataflow information object: ${O
|
|
|
964
966
|
|
|
965
967
|
${(() => {
|
|
966
968
|
/* this includes the meta field for timing and the quick CFG in order to enable re-use and improve performance */
|
|
967
|
-
(0, assert_1.guard)(Object.keys(result).length ===
|
|
969
|
+
(0, assert_1.guard)(Object.keys(result).length === 11, () => 'Update Dataflow Documentation! (Keys: ' + Object.keys(result).join(', ') + ')');
|
|
968
970
|
return '';
|
|
969
971
|
})()}
|
|
970
972
|
|
|
@@ -984,18 +986,51 @@ ${(0, doc_env_1.printEnvironmentToMarkdown)(result.environment.current)}
|
|
|
984
986
|
This shows us that the local environment contains a single definition for \`x\` (with id 0) and that the parent environment is the built-in environment.
|
|
985
987
|
Additionally, we get the information that the node with the id 2 was responsible for the definition of \`x\`.
|
|
986
988
|
|
|
989
|
+
#### Attached Packages and the Search Path
|
|
990
|
+
|
|
991
|
+
Calling \`library(pkg)\` (or \`require\`) attaches a package to the search path.
|
|
992
|
+
Mirroring R's \`search()\`, _flowR_ inserts the package's namespace and imports environments *below* the global environment (\`.GlobalEnv\`), so resolution walks **current scope -> enclosing scopes -> global -> attached packages -> built-ins**.
|
|
993
|
+
|
|
994
|
+
**A global binding shadows a package export** of the same name, exactly as in R:
|
|
995
|
+
|
|
996
|
+
\`\`\`r
|
|
997
|
+
filter <- function(x) x # your global definition
|
|
998
|
+
library(stats) # stats also exports filter()
|
|
999
|
+
filter(1) # -> resolves to YOUR filter, not stats::filter
|
|
1000
|
+
\`\`\`
|
|
1001
|
+
|
|
1002
|
+
**Most recently attached is nearest, and re-attaching is a no-op:**
|
|
1003
|
+
|
|
1004
|
+
\`\`\`r
|
|
1005
|
+
library(A) # search path (top-down): A
|
|
1006
|
+
library(B) # B, A
|
|
1007
|
+
library(A) # no-op B, A (A is not moved or duplicated)
|
|
1008
|
+
\`\`\`
|
|
1009
|
+
|
|
1010
|
+
**Attaching inside a function propagates to the caller** (R attaches globally), and across branches every possibly-attached package is kept (a sound over-approximation of R's single runtime path):
|
|
1011
|
+
|
|
1012
|
+
\`\`\`r
|
|
1013
|
+
f <- function() library(A) # attaches A when called
|
|
1014
|
+
f()
|
|
1015
|
+
someExportOfA() # -> resolves against A
|
|
1016
|
+
if (cond) library(B) # B is kept (may be attached)
|
|
1017
|
+
\`\`\`
|
|
1018
|
+
|
|
987
1019
|
Last but not least, the information contains the single **entry point** (${JSON.stringify(result.entryPoint)}) and a set of **exit points** (${JSON.stringify(result.exitPoints.map(e => e.nodeId))}).
|
|
988
1020
|
Besides marking potential exits, the exit points also provide information about why the exit occurs and which control dependencies affect the exit.
|
|
989
1021
|
|
|
1022
|
+
Finally, the **kill** property (${ctx.link('KillReference', undefined, { type: 'type' })}) tracks references that are removed from scope within the current subtree (e.g., via \`rm(x)\`).
|
|
1023
|
+
It is \`undefined\` unless such a removal occurred and, like the outgoing references, bubbles up so that the enclosing scope can apply the removal (see ${ctx.link(apply_kill_1.applyKills)}) at the right location.
|
|
1024
|
+
|
|
990
1025
|
### Unknown Side Effects
|
|
991
1026
|
|
|
992
1027
|
In case _flowR_ encounters a function call that it cannot handle, it marks the call as an unknown side effect.
|
|
993
1028
|
You can find these as part of the dataflow graph, specifically as \`unknownSideEffects\` (with a leading underscore if sesrialized as JSON).
|
|
994
1029
|
In the following graph, _flowR_ realizes that it is unable to correctly handle the impacts of the \`load\` call and therefore marks it as such (marked in bright red):
|
|
995
1030
|
|
|
996
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'load("file")\nprint(x + y)')}
|
|
1031
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'load("file")\nprint(x + y)', { ctx })}
|
|
997
1032
|
|
|
998
|
-
In general, as we cannot handle these correctly, we leave it up to other analyses (and
|
|
1033
|
+
In general, as we cannot handle these correctly, we leave it up to other analyses (and ${ctx.linkPage('wiki/Query API', 'queries')}) to handle these cases
|
|
999
1034
|
as they see fit.
|
|
1000
1035
|
|
|
1001
1036
|
#### Linked Unknown Side Effects
|
|
@@ -1005,7 +1040,7 @@ Consider R's basic [\`graphics\`](https://www.rdocumentation.org/packages/graphi
|
|
|
1005
1040
|
implicitly draws on the current device and does not explicitly link a function like \`points\` to the last call opening a new graphic device. In such a scenario, we use a linked side effect to mark the relation:
|
|
1006
1041
|
|
|
1007
1042
|
${await (async () => {
|
|
1008
|
-
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'plot(data)\npoints(data2)', { exposeResult: true });
|
|
1043
|
+
const [result, df] = await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'plot(data)\npoints(data2)', { exposeResult: true, ctx });
|
|
1009
1044
|
return `
|
|
1010
1045
|
${result}
|
|
1011
1046
|
|
|
@@ -1033,7 +1068,7 @@ ${(0, doc_code_1.codeBlock)('r', 'f <- function() f()')}
|
|
|
1033
1068
|
|
|
1034
1069
|
The resulting call graph looks like this:
|
|
1035
1070
|
|
|
1036
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'f <- function() f()', { callGraph: true })}
|
|
1071
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'f <- function() f()', { callGraph: true, ctx })}
|
|
1037
1072
|
|
|
1038
1073
|
Please note, that, due to the over-approximative nature of call-graphs, the call-graph may label some function calls that are *not*
|
|
1039
1074
|
marked as such in the full dataflow graph (which may have more precise information).
|
|
@@ -1043,11 +1078,11 @@ ${(0, doc_code_1.codeBlock)('r', 'alias <- unknown\nalias(print)')}
|
|
|
1043
1078
|
|
|
1044
1079
|
The resulting call graph looks like this:
|
|
1045
1080
|
|
|
1046
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: true })}
|
|
1081
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: true, ctx })}
|
|
1047
1082
|
|
|
1048
1083
|
Here, \`unknown\` is a function call, while it is a symbol in the full dataflow graph (as we cannot resolve it):
|
|
1049
1084
|
|
|
1050
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: false })}
|
|
1085
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'alias <- unknown\nalias()', { callGraph: false, ctx })}
|
|
1051
1086
|
|
|
1052
1087
|
|
|
1053
1088
|
${(0, doc_structure_1.section)('Working with the Dataflow Graph', 2, 'dfg-working')}
|
|
@@ -1075,13 +1110,13 @@ If you are interested in which features we support and which features are still
|
|
|
1075
1110
|
|
|
1076
1111
|
${(0, doc_structure_1.section)('Resolving Values', 3, 'dfg-resolving-values')}
|
|
1077
1112
|
|
|
1078
|
-
FlowR supports a
|
|
1079
|
-
These capabilities are exposed by the
|
|
1113
|
+
FlowR supports a ${ctx.linkPage('wiki/Interface', 'configurable', 'configuring-flowr')} level of value tracking—all with the goal of knowing the static value domain of a variable.
|
|
1114
|
+
These capabilities are exposed by the ${ctx.linkPage('wiki/Query API', 'resolve value Query', 'resolve-value-query')} and backed by two important functions:
|
|
1080
1115
|
|
|
1081
1116
|
${ctx.link(alias_tracking_1.resolveIdToValue)} provides an environment-sensitive (see ${ctx.link('REnvironmentInformation')})
|
|
1082
1117
|
value resolution depending on if the environment is provided.
|
|
1083
1118
|
The idea of ${ctx.link(alias_tracking_1.resolveIdToValue)} is to provide a compromise between precision and performance, to
|
|
1084
|
-
be used _during_ and _after_ the core analysis. After the dataflow analysis completes, there are much more expensive queries possible (such as the resolution of the data frame shape, see the
|
|
1119
|
+
be used _during_ and _after_ the core analysis. After the dataflow analysis completes, there are much more expensive queries possible (such as the resolution of the data frame shape, see the ${ctx.linkPage('wiki/Query API', 'Query API')}).
|
|
1085
1120
|
|
|
1086
1121
|
Additionally, to ${ctx.link(alias_tracking_1.resolveIdToValue)}, we offer the aforementioned ${ctx.link(identify_link_to_last_call_relation_1.getValueOfArgument)} to retrieve the value of an argument in a function call.
|
|
1087
1122
|
Be aware, that this function is currently not optimized for speed, so if you frequently require the values of multiple arguments of the same function call, you may want to open [an issue](${doc_issue_1.NewIssueUrl}) to request support for resolving
|
|
@@ -1093,7 +1128,7 @@ The [edges](#edges) of the dataflow graph use bitmasks to represent an edge with
|
|
|
1093
1128
|
difficult to check whether a given edge is a read edge.
|
|
1094
1129
|
Consider the following example:
|
|
1095
1130
|
|
|
1096
|
-
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'print(x)', { mark: new Set(['3->1']) })}
|
|
1131
|
+
${await (0, doc_dfg_1.printDfGraphForCode)(treeSitter, 'print(x)', { mark: new Set(['3->1']), ctx })}
|
|
1097
1132
|
|
|
1098
1133
|
Retrieving the _types_ of the edge from the print call to its argument returns:
|
|
1099
1134
|
${await (async () => {
|