@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
|
@@ -5,26 +5,32 @@ import type { ControlDependency } from '../info';
|
|
|
5
5
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
/** A single entry/scope within an {@link REnvironmentInformation} */
|
|
7
7
|
export interface IEnvironment {
|
|
8
|
-
/** Unique
|
|
8
|
+
/** Unique internally generated identifier, used for debugging not comparison */
|
|
9
9
|
readonly id: number;
|
|
10
10
|
/** Lexical parent of the environment, if any (can be manipulated by R code) */
|
|
11
11
|
parent: IEnvironment;
|
|
12
12
|
/** Maps to exactly one definition of an identifier if the source is known, otherwise to a list of all possible definitions */
|
|
13
13
|
memory: BuiltInMemory;
|
|
14
|
-
/**
|
|
15
|
-
* Is this a built-in environment that is not allowed to change? Please use this carefully and only for the top-most envs!
|
|
16
|
-
*/
|
|
14
|
+
/** Built-in environment that must not change; only for the top-most envs. */
|
|
17
15
|
builtInEnv?: true | undefined;
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
export declare enum EnvType {
|
|
18
|
+
Namespace = "ns",
|
|
19
|
+
Imports = "imp",
|
|
20
|
+
/** `requireNamespace("pkg")`: `pkg::fn` resolves, bare `fn` does not */
|
|
21
|
+
LoadedNamespace = "lns"
|
|
22
|
+
}
|
|
23
|
+
interface Jsonified {
|
|
20
24
|
id: NodeId;
|
|
21
25
|
parent: Jsonified | undefined;
|
|
22
26
|
builtInEnv?: true;
|
|
23
27
|
memory: BuiltInMemory;
|
|
24
|
-
|
|
28
|
+
n?: string;
|
|
29
|
+
t?: EnvType;
|
|
30
|
+
globalEnv?: true;
|
|
31
|
+
}
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
27
|
-
* Otherwise, rely on {@link IEnvironment#builtInEnv}
|
|
33
|
+
* Use only if you do not know the object type; otherwise rely on {@link IEnvironment#builtInEnv}.
|
|
28
34
|
*/
|
|
29
35
|
export declare function isDefaultBuiltInEnvironment(obj: unknown): boolean;
|
|
30
36
|
/** @see REnvironmentInformation */
|
|
@@ -32,22 +38,27 @@ export declare class Environment implements IEnvironment {
|
|
|
32
38
|
readonly id: number;
|
|
33
39
|
/** Optional name for namespaced/non-anonymous environments, please only set if you know what you are doing */
|
|
34
40
|
n?: string;
|
|
41
|
+
/** which search-path layer this env is (package/namespace/imports), if any */
|
|
42
|
+
t?: EnvType;
|
|
35
43
|
/** if created by a closure, the node id of that closure */
|
|
36
44
|
private c?;
|
|
37
45
|
parent: Environment;
|
|
38
46
|
memory: BuiltInMemory;
|
|
39
47
|
cache?: Map<Identifier, IdentifierDefinition[]>;
|
|
40
48
|
builtInEnv?: true;
|
|
49
|
+
/** marks the global environment (`.GlobalEnv`); attached packages (see {@link EnvType}) live below it */
|
|
50
|
+
globalEnv?: true;
|
|
41
51
|
constructor(parent: Environment, isBuiltInDefault?: true | undefined);
|
|
52
|
+
/** Marks this as an attached-package layer (see {@link EnvType}) for package `name`. */
|
|
53
|
+
asLibrary(name: string, type: EnvType): this;
|
|
54
|
+
/** Marks this as the global environment (`.GlobalEnv`); see {@link globalEnv}. */
|
|
55
|
+
asGlobal(): this;
|
|
42
56
|
/** please only use if you know what you are doing */
|
|
43
57
|
setClosureNodeId(nodeId: NodeId): void;
|
|
44
|
-
/**
|
|
45
|
-
* Provides the closure linked to this environment.
|
|
46
|
-
* This is of importance if, for example, if you want to know the function definition associated with this environment.
|
|
47
|
-
*/
|
|
58
|
+
/** Provides the closure linked to this environment. */
|
|
48
59
|
get closure(): NodeId | undefined;
|
|
49
60
|
/**
|
|
50
|
-
* Create a
|
|
61
|
+
* Create a clone of this environment.
|
|
51
62
|
* @param recurseParents - Whether to also clone parent environments
|
|
52
63
|
*/
|
|
53
64
|
clone(recurseParents: boolean): Environment;
|
|
@@ -63,34 +74,43 @@ export declare class Environment implements IEnvironment {
|
|
|
63
74
|
name: Identifier;
|
|
64
75
|
}): Environment;
|
|
65
76
|
/**
|
|
66
|
-
*
|
|
67
|
-
* <b>But</b> if all definitions within other are maybe, then they are appended to the current definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
|
|
68
|
-
* This always recurses parents.
|
|
77
|
+
* Definitions within `other` replace those here by name; if all of `other`'s are maybe, they are appended instead (turning existing ones maybe too), like {@link appendEnvironment}. Always recurses parents.
|
|
69
78
|
*/
|
|
70
79
|
overwrite(other: Environment | undefined, applyCds?: readonly ControlDependency[]): Environment;
|
|
71
80
|
/**
|
|
72
|
-
* Adds all writes of `other` to this environment (
|
|
73
|
-
* This always recurses parents.
|
|
81
|
+
* Adds all writes of `other` to this environment (`other`'s operations *might* happen). Always recurses parents.
|
|
74
82
|
*/
|
|
75
83
|
append(other: Environment | undefined): Environment;
|
|
84
|
+
/**
|
|
85
|
+
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
86
|
+
*/
|
|
87
|
+
private mergePackageBlocks;
|
|
76
88
|
remove(id: Identifier): this;
|
|
77
89
|
removeAll(names: readonly {
|
|
78
90
|
name: Identifier;
|
|
79
91
|
}[]): Environment;
|
|
80
92
|
toJSON(): Jsonified;
|
|
81
93
|
}
|
|
94
|
+
/** Walks up to the global environment (see {@link Environment#globalEnv}), falling back to the last non-builtin env. */
|
|
95
|
+
declare function findGlobalEnvironment(this: void, env: Environment): Environment;
|
|
96
|
+
/**
|
|
97
|
+
* Splices a package block (`blockTop`..`blockBottom`) directly below the global environment. Returns a fresh `current`, cloning only the path down to global.
|
|
98
|
+
*/
|
|
99
|
+
declare function attachPackageBelowGlobal(this: void, current: Environment, blockTop: Environment, blockBottom: Environment): Environment;
|
|
100
|
+
/**
|
|
101
|
+
* Helpers for navigating and manipulating {@link REnvironmentInformation|environments} around the global environment and attached-package search path.
|
|
102
|
+
*/
|
|
103
|
+
export declare const REnvironment: {
|
|
104
|
+
readonly name: "REnvironment";
|
|
105
|
+
/** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
|
|
106
|
+
readonly findGlobal: typeof findGlobalEnvironment;
|
|
107
|
+
/** Attaches a package block below the global environment; see {@link attachPackageBelowGlobal}. */
|
|
108
|
+
readonly attachBelowGlobal: typeof attachPackageBelowGlobal;
|
|
109
|
+
};
|
|
82
110
|
/**
|
|
83
111
|
* An environment describes a ({@link IEnvironment#parent|scoped}) mapping of names to their definitions ({@link BuiltIns}).
|
|
84
112
|
*
|
|
85
|
-
*
|
|
86
|
-
* the `baseenv`, the `emptyenv`, and other default environments (see https://adv-r.hadley.nz/environments.html).
|
|
87
|
-
* Yet, during the dataflow analysis, we want sometimes to know more (static {@link IdentifierDefinition|reference information})
|
|
88
|
-
* and sometimes know less (to be honest, we do not want that,
|
|
89
|
-
* but statically determining all attached environments is theoretically impossible --- consider attachments by user input).
|
|
90
|
-
*
|
|
91
|
-
* One important environment is the {@link BuiltIns|BuiltInEnvironment} which contains the default definitions for R's built-in functions and constants.
|
|
92
|
-
* This environment is created and provided by the {@link FlowrAnalyzerEnvironmentContext}.
|
|
93
|
-
* During serialization, you may want to rely on the {@link builtInEnvJsonReplacer} to avoid the huge built-in environment.
|
|
113
|
+
* The {@link BuiltIns|BuiltInEnvironment} holds R's built-in functions and constants; during serialization use {@link builtInEnvJsonReplacer} to avoid inlining it.
|
|
94
114
|
* @see {@link define} - to define a new {@link IdentifierDefinition|identifier definition} within an environment
|
|
95
115
|
* @see {@link resolveByName} - to resolve an {@link Identifier|identifier/name} to its {@link IdentifierDefinition|definitions} within an environment
|
|
96
116
|
* @see {@link makeReferenceMaybe} - to attach control dependencies to a reference
|
|
@@ -100,13 +120,11 @@ export declare class Environment implements IEnvironment {
|
|
|
100
120
|
* @see {@link overwriteEnvironment} - to overwrite the definitions in the current environment with those of another one
|
|
101
121
|
*/
|
|
102
122
|
export interface REnvironmentInformation {
|
|
103
|
-
/**
|
|
123
|
+
/** The currently active environment (the stack is represented by the {@link IEnvironment#parent} chain). */
|
|
104
124
|
readonly current: Environment;
|
|
105
125
|
/** nesting level of the environment, will be `0` for the global/root environment */
|
|
106
126
|
readonly level: number;
|
|
107
127
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Helps to serialize an environment, but replaces the built-in environment with a placeholder.
|
|
110
|
-
*/
|
|
128
|
+
/** Serializes an environment, replacing the built-in environment with a placeholder. */
|
|
111
129
|
export declare function builtInEnvJsonReplacer(k: unknown, v: unknown): unknown;
|
|
112
130
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Environment = void 0;
|
|
3
|
+
exports.REnvironment = exports.Environment = exports.EnvType = void 0;
|
|
4
4
|
exports.isDefaultBuiltInEnvironment = isDefaultBuiltInEnvironment;
|
|
5
5
|
exports.builtInEnvJsonReplacer = builtInEnvJsonReplacer;
|
|
6
6
|
/**
|
|
7
7
|
* Provides an environment structure similar to R.
|
|
8
|
-
* This allows the dataflow to hold current definition locations for variables, based on the current scope.
|
|
9
8
|
* @module
|
|
10
9
|
*/
|
|
11
10
|
const json_1 = require("../../util/json");
|
|
@@ -14,9 +13,15 @@ const assert_1 = require("../../util/assert");
|
|
|
14
13
|
const info_1 = require("../info");
|
|
15
14
|
const append_1 = require("./append");
|
|
16
15
|
const log_1 = require("../../util/log");
|
|
16
|
+
var EnvType;
|
|
17
|
+
(function (EnvType) {
|
|
18
|
+
EnvType["Namespace"] = "ns";
|
|
19
|
+
EnvType["Imports"] = "imp";
|
|
20
|
+
/** `requireNamespace("pkg")`: `pkg::fn` resolves, bare `fn` does not */
|
|
21
|
+
EnvType["LoadedNamespace"] = "lns";
|
|
22
|
+
})(EnvType || (exports.EnvType = EnvType = {}));
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
19
|
-
* Otherwise, rely on {@link IEnvironment#builtInEnv}
|
|
24
|
+
* Use only if you do not know the object type; otherwise rely on {@link IEnvironment#builtInEnv}.
|
|
20
25
|
*/
|
|
21
26
|
function isDefaultBuiltInEnvironment(obj) {
|
|
22
27
|
return typeof obj === 'object' && obj !== null && (obj.builtInEnv === true);
|
|
@@ -27,12 +32,16 @@ class Environment {
|
|
|
27
32
|
id;
|
|
28
33
|
/** Optional name for namespaced/non-anonymous environments, please only set if you know what you are doing */
|
|
29
34
|
n;
|
|
35
|
+
/** which search-path layer this env is (package/namespace/imports), if any */
|
|
36
|
+
t;
|
|
30
37
|
/** if created by a closure, the node id of that closure */
|
|
31
38
|
c;
|
|
32
39
|
parent;
|
|
33
40
|
memory;
|
|
34
41
|
cache;
|
|
35
42
|
builtInEnv;
|
|
43
|
+
/** marks the global environment (`.GlobalEnv`); attached packages (see {@link EnvType}) live below it */
|
|
44
|
+
globalEnv;
|
|
36
45
|
constructor(parent, isBuiltInDefault = undefined) {
|
|
37
46
|
this.id = isBuiltInDefault ? 0 : environmentIdCounter++;
|
|
38
47
|
this.parent = parent;
|
|
@@ -42,19 +51,27 @@ class Environment {
|
|
|
42
51
|
this.builtInEnv = isBuiltInDefault;
|
|
43
52
|
}
|
|
44
53
|
}
|
|
54
|
+
/** Marks this as an attached-package layer (see {@link EnvType}) for package `name`. */
|
|
55
|
+
asLibrary(name, type) {
|
|
56
|
+
this.n = name;
|
|
57
|
+
this.t = type;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/** Marks this as the global environment (`.GlobalEnv`); see {@link globalEnv}. */
|
|
61
|
+
asGlobal() {
|
|
62
|
+
this.globalEnv = true;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
45
65
|
/** please only use if you know what you are doing */
|
|
46
66
|
setClosureNodeId(nodeId) {
|
|
47
67
|
this.c = nodeId;
|
|
48
68
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Provides the closure linked to this environment.
|
|
51
|
-
* This is of importance if, for example, if you want to know the function definition associated with this environment.
|
|
52
|
-
*/
|
|
69
|
+
/** Provides the closure linked to this environment. */
|
|
53
70
|
get closure() {
|
|
54
71
|
return this.c;
|
|
55
72
|
}
|
|
56
73
|
/**
|
|
57
|
-
* Create a
|
|
74
|
+
* Create a clone of this environment.
|
|
58
75
|
* @param recurseParents - Whether to also clone parent environments
|
|
59
76
|
*/
|
|
60
77
|
clone(recurseParents) {
|
|
@@ -65,13 +82,9 @@ class Environment {
|
|
|
65
82
|
const clone = new Environment(parent, this.builtInEnv);
|
|
66
83
|
clone.c = this.c;
|
|
67
84
|
clone.n = this.n;
|
|
68
|
-
clone.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
...s,
|
|
72
|
-
cds: s.cds?.slice()
|
|
73
|
-
}))
|
|
74
|
-
]));
|
|
85
|
+
clone.t = this.t;
|
|
86
|
+
clone.globalEnv = this.globalEnv;
|
|
87
|
+
clone.memory = new Map(this.memory);
|
|
75
88
|
return clone;
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
@@ -83,6 +96,10 @@ class Environment {
|
|
|
83
96
|
if (ns !== undefined && this.n !== ns) {
|
|
84
97
|
return this.defineInNamespace(definition, ns);
|
|
85
98
|
}
|
|
99
|
+
/* isolate the cds from the originating reference, which may still be updated in place */
|
|
100
|
+
if (definition.cds !== undefined) {
|
|
101
|
+
definition = { ...definition, cds: definition.cds.slice() };
|
|
102
|
+
}
|
|
86
103
|
const newEnvironment = this.clone(false);
|
|
87
104
|
// When there are defined indices, merge the definitions
|
|
88
105
|
if (definition.cds === undefined) {
|
|
@@ -99,7 +116,8 @@ class Environment {
|
|
|
99
116
|
newEnvironment.memory.set(name, [definition]);
|
|
100
117
|
}
|
|
101
118
|
else {
|
|
102
|
-
|
|
119
|
+
/* the array may be shared with clones, so replace instead of push */
|
|
120
|
+
newEnvironment.memory.set(name, [...existing, definition]);
|
|
103
121
|
}
|
|
104
122
|
}
|
|
105
123
|
return newEnvironment;
|
|
@@ -134,6 +152,10 @@ class Environment {
|
|
|
134
152
|
}
|
|
135
153
|
defineSuper(definition) {
|
|
136
154
|
const [name, ns] = identifier_1.Identifier.toArray(definition.name);
|
|
155
|
+
/* isolate the cds from the originating reference, see {@link define} */
|
|
156
|
+
if (definition.cds !== undefined) {
|
|
157
|
+
definition = { ...definition, cds: definition.cds.slice() };
|
|
158
|
+
}
|
|
137
159
|
const newEnvironment = this.clone(false);
|
|
138
160
|
if (ns !== undefined && this.n !== ns) {
|
|
139
161
|
newEnvironment.parent = newEnvironment.parent.defineInNamespace(definition, ns);
|
|
@@ -148,6 +170,12 @@ class Environment {
|
|
|
148
170
|
found = true;
|
|
149
171
|
break;
|
|
150
172
|
}
|
|
173
|
+
// `<<-` falls back to the global env, never an attached package below it
|
|
174
|
+
if (current.globalEnv) {
|
|
175
|
+
current.memory.set(name, [definition]);
|
|
176
|
+
found = true;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
151
179
|
last = current;
|
|
152
180
|
current.parent = current.parent.clone(false);
|
|
153
181
|
current = current.parent;
|
|
@@ -159,12 +187,17 @@ class Environment {
|
|
|
159
187
|
return newEnvironment;
|
|
160
188
|
}
|
|
161
189
|
/**
|
|
162
|
-
*
|
|
163
|
-
* <b>But</b> if all definitions within other are maybe, then they are appended to the current definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
|
|
164
|
-
* This always recurses parents.
|
|
190
|
+
* Definitions within `other` replace those here by name; if all of `other`'s are maybe, they are appended instead (turning existing ones maybe too), like {@link appendEnvironment}. Always recurses parents.
|
|
165
191
|
*/
|
|
166
192
|
overwrite(other, applyCds) {
|
|
167
|
-
if (
|
|
193
|
+
if (!other || this === other) {
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
// package blocks are unioned, never overwritten (see mergePackageBlocks)
|
|
197
|
+
if (this.t !== undefined || other.t !== undefined) {
|
|
198
|
+
return this.mergePackageBlocks(other);
|
|
199
|
+
}
|
|
200
|
+
if (this.builtInEnv || this.n !== other.n) {
|
|
168
201
|
return this;
|
|
169
202
|
}
|
|
170
203
|
const map = new Map(this.memory);
|
|
@@ -203,15 +236,23 @@ class Environment {
|
|
|
203
236
|
const out = new Environment(this.parent.overwrite(other.parent, applyCds));
|
|
204
237
|
out.c = this.c;
|
|
205
238
|
out.n = this.n;
|
|
239
|
+
out.t = this.t;
|
|
240
|
+
out.globalEnv = this.globalEnv;
|
|
206
241
|
out.memory = map;
|
|
207
242
|
return out;
|
|
208
243
|
}
|
|
209
244
|
/**
|
|
210
|
-
* Adds all writes of `other` to this environment (
|
|
211
|
-
* This always recurses parents.
|
|
245
|
+
* Adds all writes of `other` to this environment (`other`'s operations *might* happen). Always recurses parents.
|
|
212
246
|
*/
|
|
213
247
|
append(other) {
|
|
214
|
-
if (!other || this
|
|
248
|
+
if (!other || this === other) {
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
// package blocks may diverge between branches; union them before the built-in guard
|
|
252
|
+
if (this.t !== undefined || other.t !== undefined) {
|
|
253
|
+
return this.mergePackageBlocks(other);
|
|
254
|
+
}
|
|
255
|
+
if (this.builtInEnv || this.n !== other.n) {
|
|
215
256
|
return this;
|
|
216
257
|
}
|
|
217
258
|
const map = new Map(this.memory);
|
|
@@ -225,9 +266,43 @@ class Environment {
|
|
|
225
266
|
}
|
|
226
267
|
}
|
|
227
268
|
const out = new Environment(this.parent.append(other.parent));
|
|
269
|
+
out.n = this.n;
|
|
270
|
+
out.t = this.t;
|
|
271
|
+
out.globalEnv = this.globalEnv;
|
|
228
272
|
out.memory = map;
|
|
229
273
|
return out;
|
|
230
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
|
|
277
|
+
*/
|
|
278
|
+
mergePackageBlocks(other) {
|
|
279
|
+
const [thisLayers, thisBase] = splitLibraryLayers(this);
|
|
280
|
+
const [otherLayers, otherBase] = splitLibraryLayers(other);
|
|
281
|
+
// `other` first so its packages end up nearest global (most recently attached is nearest, cf. R `search()`)
|
|
282
|
+
const merged = new Map();
|
|
283
|
+
for (const layers of [otherLayers, thisLayers]) {
|
|
284
|
+
for (const layer of layers) {
|
|
285
|
+
const key = `${layer.t}:${layer.n}`;
|
|
286
|
+
const existing = merged.get(key);
|
|
287
|
+
if (existing === undefined) {
|
|
288
|
+
merged.set(key, layer.clone(false));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
for (const [name, value] of layer.memory) {
|
|
292
|
+
const old = existing.memory.get(name);
|
|
293
|
+
existing.memory.set(name, old ? (0, append_1.uniqueMergeValuesInDefinitions)(old, value) : value);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const uniqueLayers = Array.from(merged.values());
|
|
299
|
+
let current = thisBase.append(otherBase);
|
|
300
|
+
for (let i = uniqueLayers.length - 1; i >= 0; i--) {
|
|
301
|
+
uniqueLayers[i].parent = current;
|
|
302
|
+
current = uniqueLayers[i];
|
|
303
|
+
}
|
|
304
|
+
return current;
|
|
305
|
+
}
|
|
231
306
|
remove(id) {
|
|
232
307
|
if (this.builtInEnv) {
|
|
233
308
|
return this;
|
|
@@ -270,13 +345,57 @@ class Environment {
|
|
|
270
345
|
id: this.id,
|
|
271
346
|
parent: this.parent,
|
|
272
347
|
memory: this.memory,
|
|
348
|
+
// markers needed to rebuild the search path after a round-trip (undefined values are dropped by JSON.stringify)
|
|
349
|
+
n: this.n,
|
|
350
|
+
t: this.t,
|
|
351
|
+
globalEnv: this.globalEnv,
|
|
273
352
|
};
|
|
274
353
|
}
|
|
275
354
|
}
|
|
276
355
|
exports.Environment = Environment;
|
|
356
|
+
/** Walks up to the global environment (see {@link Environment#globalEnv}), falling back to the last non-builtin env. */
|
|
357
|
+
function findGlobalEnvironment(env) {
|
|
358
|
+
let current = env;
|
|
359
|
+
while (!current.globalEnv && !current.parent.builtInEnv) {
|
|
360
|
+
current = current.parent;
|
|
361
|
+
}
|
|
362
|
+
return current;
|
|
363
|
+
}
|
|
277
364
|
/**
|
|
278
|
-
*
|
|
365
|
+
* Splices a package block (`blockTop`..`blockBottom`) directly below the global environment. Returns a fresh `current`, cloning only the path down to global.
|
|
279
366
|
*/
|
|
367
|
+
function attachPackageBelowGlobal(current, blockTop, blockBottom) {
|
|
368
|
+
const clonedCurrent = current.clone(false);
|
|
369
|
+
let global = clonedCurrent;
|
|
370
|
+
while (!global.globalEnv && !global.parent.builtInEnv) {
|
|
371
|
+
global.parent = global.parent.clone(false);
|
|
372
|
+
global = global.parent;
|
|
373
|
+
}
|
|
374
|
+
blockBottom.parent = global.parent; // the built-in env, or the previously attached packages
|
|
375
|
+
global.parent = blockTop;
|
|
376
|
+
return clonedCurrent;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Helpers for navigating and manipulating {@link REnvironmentInformation|environments} around the global environment and attached-package search path.
|
|
380
|
+
*/
|
|
381
|
+
exports.REnvironment = {
|
|
382
|
+
name: 'REnvironment',
|
|
383
|
+
/** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
|
|
384
|
+
findGlobal: findGlobalEnvironment,
|
|
385
|
+
/** Attaches a package block below the global environment; see {@link attachPackageBelowGlobal}. */
|
|
386
|
+
attachBelowGlobal: attachPackageBelowGlobal,
|
|
387
|
+
};
|
|
388
|
+
/** Splits a package block (a contiguous run of attached-package layers, see {@link EnvType}) into its layers and the env below them. */
|
|
389
|
+
function splitLibraryLayers(env) {
|
|
390
|
+
const layers = [];
|
|
391
|
+
let current = env;
|
|
392
|
+
while (current.t !== undefined && !current.builtInEnv) {
|
|
393
|
+
layers.push(current);
|
|
394
|
+
current = current.parent;
|
|
395
|
+
}
|
|
396
|
+
return [layers, current];
|
|
397
|
+
}
|
|
398
|
+
/** Serializes an environment, replacing the built-in environment with a placeholder. */
|
|
280
399
|
function builtInEnvJsonReplacer(k, v) {
|
|
281
400
|
if (isDefaultBuiltInEnvironment(v)) {
|
|
282
401
|
return '<BuiltInEnvironment>';
|
|
@@ -2,6 +2,7 @@ import type { BuiltInIdentifierConstant, BuiltInIdentifierDefinition } from './b
|
|
|
2
2
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { ControlDependency } from '../info';
|
|
4
4
|
import type { REnvironmentInformation } from './environment';
|
|
5
|
+
import type { Origin } from '../origin/dfg-get-origin';
|
|
5
6
|
/** this is just a safe-guard type to prevent mixing up branded identifiers with normal strings */
|
|
6
7
|
export type BrandedIdentifier = string & {
|
|
7
8
|
__brand?: 'identifier';
|
|
@@ -36,10 +37,20 @@ export type Identifier = BrandedIdentifier | [id: BrandedIdentifier, namespace:
|
|
|
36
37
|
export declare const Identifier: {
|
|
37
38
|
readonly name: "Identifier";
|
|
38
39
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* Creates an identifier. Strips surrounding backticks from the name.
|
|
41
|
+
* Prefer {@link Identifier.from} for static config entries where namespace is always present and name has no backticks.
|
|
41
42
|
*/
|
|
42
43
|
readonly make: (this: void, name: BrandedIdentifier, namespace?: BrandedNamespace, internal?: boolean) => Identifier;
|
|
44
|
+
/**
|
|
45
|
+
* Fast-path factory: returns the tuple as-is with no allocation or runtime checks.
|
|
46
|
+
* Use for static built-in config entries where name is a compile-time constant with no backticks.
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* Identifier.from(['map', 'purrr']) // ['map', 'purrr']
|
|
50
|
+
* Identifier.from(['map', 'purrr', true]) // ['map', 'purrr', true]
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
readonly from: (this: void, arr: [BrandedIdentifier, BrandedNamespace] | [BrandedIdentifier, BrandedNamespace, boolean]) => Identifier;
|
|
43
54
|
/**
|
|
44
55
|
* Verify whether an unknown element has a valid identifier shape!
|
|
45
56
|
*/
|
|
@@ -100,7 +111,59 @@ export declare const Identifier: {
|
|
|
100
111
|
* Convert the identifier to its array representation
|
|
101
112
|
*/
|
|
102
113
|
readonly toArray: (this: void, id: Identifier) => [BrandedIdentifier, BrandedNamespace | undefined, boolean | undefined];
|
|
114
|
+
/**
|
|
115
|
+
* The qualified identifier of a call from its dataflow {@link Origin}s (via `getOriginInDfg`), if it
|
|
116
|
+
* resolves to an export of a loaded package (the `flowr-pkgdb` info attached by `library()`/`use()`);
|
|
117
|
+
* `undefined` otherwise. With `purrr` loaded, `map()` yields `Identifier.make('map', 'purrr')`.
|
|
118
|
+
*/
|
|
119
|
+
readonly toQualified: (this: void, origins: readonly Origin[] | undefined) => Identifier | undefined;
|
|
120
|
+
/** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
|
|
121
|
+
readonly toQualifiedName: (this: void, origins: readonly Origin[] | undefined) => string | undefined;
|
|
103
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Well-known R package names used in {@link DefaultBuiltinConfig}.
|
|
125
|
+
* Using a const enum keeps the string values inlined at compile time.
|
|
126
|
+
*/
|
|
127
|
+
export declare const enum PkgName {
|
|
128
|
+
Base = "base",
|
|
129
|
+
Compiler = "compiler",
|
|
130
|
+
Graphics = "graphics",
|
|
131
|
+
GrDevices = "grDevices",
|
|
132
|
+
Methods = "methods",
|
|
133
|
+
Stats = "stats",
|
|
134
|
+
Utils = "utils",
|
|
135
|
+
AssertThat = "assertthat",
|
|
136
|
+
Box = "box",
|
|
137
|
+
Cli = "cli",
|
|
138
|
+
DataTable = "data.table",
|
|
139
|
+
Devtools = "devtools",
|
|
140
|
+
Dplyr = "dplyr",
|
|
141
|
+
Fs = "fs",
|
|
142
|
+
Functools = "functools",
|
|
143
|
+
GgPlot2 = "ggplot2",
|
|
144
|
+
Import = "import",
|
|
145
|
+
Inferference = "inferference",
|
|
146
|
+
Janitor = "janitor",
|
|
147
|
+
Lattice = "lattice",
|
|
148
|
+
Magick = "magick",
|
|
149
|
+
Magrittr = "magrittr",
|
|
150
|
+
Msgr = "msgr",
|
|
151
|
+
PkgLoad = "pkgload",
|
|
152
|
+
Plyr = "plyr",
|
|
153
|
+
Purrr = "purrr",
|
|
154
|
+
Ragg = "ragg",
|
|
155
|
+
RasterPdf = "rasterpdf",
|
|
156
|
+
Remotes = "remotes",
|
|
157
|
+
Rlang = "rlang",
|
|
158
|
+
RmethodsS3 = "R.methodsS3",
|
|
159
|
+
Roo = "R.oo",
|
|
160
|
+
Rutils = "R.utils",
|
|
161
|
+
S7 = "S7",
|
|
162
|
+
Soda = "SoDA",
|
|
163
|
+
Testthat = "testthat",
|
|
164
|
+
TinyPlot = "tinyplot",
|
|
165
|
+
TryCatchLog = "tryCatchLog"
|
|
166
|
+
}
|
|
104
167
|
/**
|
|
105
168
|
* Each reference has exactly one reference type, stored as the respective number.
|
|
106
169
|
* However, when checking, we may want to allow for one of several types,
|
|
@@ -19,8 +19,8 @@ const dotDotDotAccess = /^\.\.\d+$/;
|
|
|
19
19
|
exports.Identifier = {
|
|
20
20
|
name: 'Identifier',
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Creates an identifier. Strips surrounding backticks from the name.
|
|
23
|
+
* Prefer {@link Identifier.from} for static config entries where namespace is always present and name has no backticks.
|
|
24
24
|
*/
|
|
25
25
|
make(name, namespace, internal = false) {
|
|
26
26
|
if ((0, strings_1.startAndEndsWith)(name, '`')) {
|
|
@@ -33,6 +33,18 @@ exports.Identifier = {
|
|
|
33
33
|
return name;
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* Fast-path factory: returns the tuple as-is with no allocation or runtime checks.
|
|
38
|
+
* Use for static built-in config entries where name is a compile-time constant with no backticks.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* Identifier.from(['map', 'purrr']) // ['map', 'purrr']
|
|
42
|
+
* Identifier.from(['map', 'purrr', true]) // ['map', 'purrr', true]
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
from(arr) {
|
|
46
|
+
return arr;
|
|
47
|
+
},
|
|
36
48
|
/**
|
|
37
49
|
* Verify whether an unknown element has a valid identifier shape!
|
|
38
50
|
*/
|
|
@@ -176,6 +188,29 @@ exports.Identifier = {
|
|
|
176
188
|
else {
|
|
177
189
|
return [id, undefined, undefined];
|
|
178
190
|
}
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* The qualified identifier of a call from its dataflow {@link Origin}s (via `getOriginInDfg`), if it
|
|
194
|
+
* resolves to an export of a loaded package (the `flowr-pkgdb` info attached by `library()`/`use()`);
|
|
195
|
+
* `undefined` otherwise. With `purrr` loaded, `map()` yields `Identifier.make('map', 'purrr')`.
|
|
196
|
+
*/
|
|
197
|
+
toQualified(origins) {
|
|
198
|
+
for (const origin of origins ?? []) {
|
|
199
|
+
// a package-export origin carries the target builtin id `built-in:pkg:func` in `proc`
|
|
200
|
+
if ('proc' in origin && origin.proc.startsWith('built-in:')) {
|
|
201
|
+
const rest = origin.proc.slice('built-in:'.length);
|
|
202
|
+
const sep = rest.indexOf(':'); // base builtins (`built-in:print`) have no separator
|
|
203
|
+
if (sep > 0) {
|
|
204
|
+
return exports.Identifier.make(rest.slice(sep + 1), rest.slice(0, sep));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return undefined;
|
|
209
|
+
},
|
|
210
|
+
/** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
|
|
211
|
+
toQualifiedName(origins) {
|
|
212
|
+
const qualified = exports.Identifier.toQualified(origins);
|
|
213
|
+
return qualified === undefined ? undefined : exports.Identifier.toString(qualified);
|
|
179
214
|
}
|
|
180
215
|
};
|
|
181
216
|
/**
|
|
@@ -3,22 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.overwriteEnvironment = overwriteEnvironment;
|
|
4
4
|
const scoping_1 = require("./scoping");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* <b>But</b> if all definitions within next are maybe, then they are appended to the base definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
|
|
6
|
+
* Definitions within `next` replace those in `base` by name; if all of `next`'s are maybe, they are appended instead (turning existing ones maybe too), like {@link appendEnvironment}.
|
|
8
7
|
* @see {@link Environment.overwrite} - for details on how definitions are handled.
|
|
9
8
|
*/
|
|
10
9
|
function overwriteEnvironment(base, next, applyCds) {
|
|
11
10
|
if (base === undefined || next === undefined) {
|
|
12
11
|
return next ?? base;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
while (next.level < base.level) {
|
|
16
|
-
next = (0, scoping_1.pushLocalEnvironment)(next);
|
|
17
|
-
}
|
|
18
|
-
while (next.level > base.level) {
|
|
19
|
-
base = (0, scoping_1.pushLocalEnvironment)(base);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
13
|
+
({ base, next } = (0, scoping_1.padToCommonScope)(base, next));
|
|
22
14
|
return {
|
|
23
15
|
current: base.current.overwrite(next.current, applyCds),
|
|
24
16
|
level: base.level
|
|
@@ -4,6 +4,8 @@ import type { ControlDependency } from '../info';
|
|
|
4
4
|
import type { REnvironmentInformation } from './environment';
|
|
5
5
|
/**
|
|
6
6
|
* Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
|
|
7
|
+
* With `includeDefs`, the cds are also attached (copy-on-write) to the definitions the reference
|
|
8
|
+
* resolves to, see {@link applyCdsToDefinitions}.
|
|
7
9
|
*/
|
|
8
10
|
export declare function makeReferenceMaybe(ref: IdentifierReference, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency[] | undefined): IdentifierReference;
|
|
9
11
|
/**
|