@eagleoutice/flowr 2.12.3 → 2.13.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 +38 -91
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +3 -3
- package/abstract-interpretation/data-frame/dataframe-domain.js +14 -6
- package/abstract-interpretation/data-frame/semantics.js +12 -16
- package/abstract-interpretation/domains/abstract-domain.d.ts +46 -44
- package/abstract-interpretation/domains/abstract-domain.js +146 -6
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +16 -25
- package/abstract-interpretation/domains/bounded-set-domain.js +22 -69
- package/abstract-interpretation/domains/interval-domain.d.ts +27 -36
- package/abstract-interpretation/domains/interval-domain.js +111 -146
- package/abstract-interpretation/domains/lattice.d.ts +3 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +3 -3
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -19
- package/abstract-interpretation/domains/partial-product-domain.js +21 -54
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +8 -12
- package/abstract-interpretation/domains/positive-interval-domain.js +21 -50
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/product-domain.js +4 -4
- package/abstract-interpretation/domains/set-range-domain.d.ts +60 -56
- package/abstract-interpretation/domains/set-range-domain.js +141 -200
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +17 -23
- package/abstract-interpretation/domains/set-upper-bound-domain.js +59 -103
- package/abstract-interpretation/domains/singleton-domain.d.ts +15 -18
- package/abstract-interpretation/domains/singleton-domain.js +33 -72
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +12 -16
- package/abstract-interpretation/domains/state-abstract-domain.js +36 -126
- package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
- package/abstract-interpretation/domains/value-abstract-domain.d.ts +120 -0
- package/abstract-interpretation/domains/{satisfiable-domain.js → value-abstract-domain.js} +14 -2
- package/benchmark/slicer.d.ts +2 -2
- package/benchmark/slicer.js +6 -5
- package/cli/common/options.d.ts +10 -0
- package/cli/common/options.js +2 -0
- package/cli/common/scripts-info.d.ts +10 -0
- package/cli/flowr-main-options.d.ts +4 -0
- package/cli/flowr-main-options.js +5 -0
- package/cli/flowr.d.ts +5 -0
- package/cli/flowr.js +15 -7
- package/cli/repl/commands/repl-query.js +42 -20
- package/cli/repl/commands/repl-signature.js +2 -2
- package/cli/repl/core.d.ts +14 -5
- package/cli/repl/core.js +32 -17
- package/cli/repl/parser/slice-query-parser.d.ts +69 -8
- package/cli/repl/parser/slice-query-parser.js +82 -13
- package/cli/repl/path-input.d.ts +6 -0
- package/cli/repl/path-input.js +41 -0
- package/cli/repl/print-version.js +3 -5
- package/cli/slicer-app.d.ts +2 -0
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +54 -6
- package/config.js +133 -12
- package/control-flow/control-flow-graph.d.ts +3 -2
- package/control-flow/control-flow-graph.js +34 -14
- package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -0
- package/control-flow/semantic-cfg-guided-visitor.js +3 -0
- package/core/steps/all/static-slicing/10-reconstruct.d.ts +6 -0
- package/core/steps/all/static-slicing/10-reconstruct.js +3 -1
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/data/sigdb/sigdb.remote.json +53 -53
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +3 -5
- package/dataflow/environments/default-builtin-config.js +2 -2
- package/dataflow/environments/environment.d.ts +9 -0
- package/dataflow/environments/environment.js +28 -7
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +1 -5
- package/dataflow/extractor.js +1 -2
- package/dataflow/graph/dataflowgraph-builder.js +42 -3
- package/dataflow/graph/df-helper.d.ts +15 -0
- package/dataflow/graph/df-helper.js +20 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +57 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +12 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +233 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -3
- package/documentation/data/faq/faqs.js +12 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +2 -2
- package/documentation/doc-util/doc-files.js +4 -7
- package/documentation/doc-util/doc-query.d.ts +12 -9
- package/documentation/doc-util/doc-query.js +63 -28
- package/documentation/wiki-absint.js +1 -4
- package/documentation/wiki-analyzer.js +8 -3
- package/documentation/wiki-cfg.js +3 -2
- package/documentation/wiki-dataflow-graph.js +14 -4
- package/documentation/wiki-interface.js +29 -16
- package/documentation/wiki-mk/doc-maker.js +1 -1
- package/documentation/wiki-query.js +189 -30
- package/documentation/wiki-signature-database.d.ts +1 -1
- package/documentation/wiki-signature-database.js +53 -27
- package/linter/linter-output.d.ts +24 -0
- package/linter/linter-output.js +117 -0
- package/linter/linter-rules.d.ts +2 -4
- package/linter/rules/dataframe-access-validation.js +4 -4
- package/linter/rules/deprecated-functions.d.ts +2 -4
- package/linter/rules/deprecated-functions.js +58 -3
- package/linter/rules/undefined-symbol.js +18 -10
- package/linter/rules/unused-definition.js +24 -0
- package/package.json +5 -2
- package/project/context/flowr-analyzer-context.d.ts +59 -1
- package/project/context/flowr-analyzer-context.js +118 -3
- package/project/context/flowr-analyzer-dependencies-context.d.ts +32 -7
- package/project/context/flowr-analyzer-dependencies-context.js +33 -3
- package/project/context/flowr-analyzer-files-context.d.ts +32 -0
- package/project/context/flowr-analyzer-files-context.js +132 -14
- package/project/context/flowr-analyzer-loading-order-context.d.ts +6 -0
- package/project/context/flowr-analyzer-loading-order-context.js +20 -0
- package/project/context/flowr-analyzer-meta-context.d.ts +92 -10
- package/project/context/flowr-analyzer-meta-context.js +64 -23
- package/project/context/flowr-file.d.ts +7 -0
- package/project/context/flowr-file.js +7 -0
- package/project/context/project-kind.d.ts +22 -0
- package/project/context/project-kind.js +27 -0
- package/project/dependency-version-space.d.ts +166 -0
- package/project/dependency-version-space.js +564 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/flowr-analyzer.d.ts +4 -0
- package/project/flowr-analyzer.js +5 -0
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
- package/project/plugins/file-plugins/files/flowr-description-file.js +7 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +5 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +739 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.js +2407 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.d.ts +31 -0
- package/project/plugins/file-plugins/files/flowr-rproject-file.js +66 -0
- package/project/plugins/file-plugins/files/r-fun-tab.d.ts +828 -0
- package/project/plugins/file-plugins/files/r-fun-tab.js +1039 -0
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +26 -0
- package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +38 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +17 -0
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +30 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.d.ts +22 -0
- package/project/plugins/file-plugins/flowr-analyzer-rproject-file-plugin.js +36 -0
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +3 -4
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +5 -6
- package/project/plugins/flowr-analyzer-plugin.js +5 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.d.ts +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.d.ts +14 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin.js +53 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-plugin.js +1 -1
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.d.ts +15 -0
- package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +18 -13
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.d.ts +13 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-rproject-file-plugin.js +32 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +8 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +70 -7
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.d.ts +18 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +62 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +5 -13
- package/project/plugins/package-version-plugins/package.d.ts +4 -1
- package/project/plugins/package-version-plugins/package.js +8 -5
- package/project/plugins/plugin-registry.d.ts +11 -3
- package/project/plugins/plugin-registry.js +24 -5
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +51 -0
- package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.js +101 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +10 -5
- package/project/sigdb/build.js +12 -2
- package/project/sigdb/decode.d.ts +7 -0
- package/project/sigdb/decode.js +35 -4
- package/project/sigdb/decompress.d.ts +2 -0
- package/project/sigdb/decompress.js +5 -0
- package/project/sigdb/manifest.d.ts +5 -0
- package/project/sigdb/manifest.js +37 -6
- package/project/sigdb/reader.d.ts +82 -2
- package/project/sigdb/reader.js +226 -14
- package/project/sigdb/schema.d.ts +31 -5
- package/project/sigdb/schema.js +7 -3
- package/project/sigdb/{version.d.ts → sigdb-version.d.ts} +21 -1
- package/project/sigdb/sigdb-version.js +119 -0
- package/queries/catalog/absint-query/absint-query-format.d.ts +2 -0
- package/queries/catalog/absint-query/absint-query-format.js +2 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +30 -3
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +6 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -0
- package/queries/catalog/call-graph-query/expand-library-internals.d.ts +19 -0
- package/queries/catalog/call-graph-query/expand-library-internals.js +59 -0
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -0
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -0
- package/queries/catalog/config-query/config-query-executor.js +15 -6
- package/queries/catalog/config-query/config-query-format.d.ts +18 -4
- package/queries/catalog/config-query/config-query-format.js +246 -96
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -0
- package/queries/catalog/control-flow-query/control-flow-query-format.js +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +1 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +13 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +117 -17
- package/queries/catalog/dice-query/dice-query-executor.js +6 -9
- package/queries/catalog/dice-query/dice-query-format.d.ts +4 -5
- package/queries/catalog/dice-query/dice-query-format.js +10 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +15 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +8 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +4 -1
- package/queries/catalog/files-query/files-query-format.d.ts +2 -0
- package/queries/catalog/files-query/files-query-format.js +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +6 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +277 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +119 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +331 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -0
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -0
- 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 +2 -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 +2 -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 +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -0
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -0
- package/queries/catalog/linter-query/linter-query-executor.js +11 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +9 -4
- package/queries/catalog/linter-query/linter-query-format.js +44 -21
- 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 +2 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -0
- package/queries/catalog/normalized-ast-query/normalized-ast-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 +2 -0
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -15
- package/queries/catalog/project-query/project-query-executor.js +19 -62
- package/queries/catalog/project-query/project-query-format.d.ts +7 -18
- package/queries/catalog/project-query/project-query-format.js +3 -18
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -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 +2 -0
- package/queries/catalog/search-query/search-query-format.d.ts +1 -0
- package/queries/catalog/search-query/search-query-format.js +1 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +5 -0
- package/queries/catalog/signature-query/signature-query-executor.js +267 -57
- package/queries/catalog/signature-query/signature-query-format.d.ts +37 -6
- package/queries/catalog/signature-query/signature-query-format.js +41 -5
- package/queries/catalog/signature-query/signature-query-render.js +48 -6
- package/queries/catalog/slice-query-options.d.ts +49 -0
- package/queries/catalog/slice-query-options.js +50 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -12
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -15
- package/queries/catalog/static-slice-query/static-slice-query-format.js +9 -10
- package/queries/query-print.js +3 -1
- package/queries/query.d.ts +63 -3
- package/queries/query.js +9 -2
- package/r-bridge/data/data.d.ts +16 -0
- package/r-bridge/data/data.js +20 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -16
- package/reconstruct/reconstruct.d.ts +18 -1
- package/reconstruct/reconstruct.js +42 -19
- package/slicing/criterion/parse.d.ts +4 -0
- package/slicing/criterion/parse.js +4 -0
- package/slicing/static/slice-call.js +17 -9
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +5 -4
- package/util/files.d.ts +19 -1
- package/util/files.js +45 -3
- package/util/glob.d.ts +19 -0
- package/util/glob.js +67 -0
- package/util/log.d.ts +12 -0
- package/util/log.js +17 -1
- package/util/logic.d.ts +6 -0
- package/util/logic.js +31 -1
- package/util/mermaid/dfg.js +17 -12
- package/util/mermaid/mermaid.js +2 -2
- package/util/objects.d.ts +5 -0
- package/util/objects.js +8 -0
- package/util/r-version.d.ts +9 -1
- package/util/r-version.js +27 -2
- package/util/schema.d.ts +16 -0
- package/util/schema.js +89 -4
- package/util/text/ansi.d.ts +4 -0
- package/util/text/ansi.js +27 -3
- package/util/text/strings.d.ts +9 -0
- package/util/text/strings.js +29 -0
- package/util/version.js +79 -6
- package/abstract-interpretation/domains/satisfiable-domain.d.ts +0 -29
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +0 -22
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +0 -52
- package/project/sigdb/version.js +0 -55
|
@@ -69,6 +69,15 @@ export declare class Environment implements IEnvironment {
|
|
|
69
69
|
define(definition: IdentifierDefinition & {
|
|
70
70
|
name: Identifier;
|
|
71
71
|
}): Environment;
|
|
72
|
+
/**
|
|
73
|
+
* Define several identifiers at once in a more performant fashion.
|
|
74
|
+
* @param definitions - The definitions to add.
|
|
75
|
+
*/
|
|
76
|
+
defineAll(definitions: Iterable<IdentifierDefinition & {
|
|
77
|
+
name: Identifier;
|
|
78
|
+
}>): Environment;
|
|
79
|
+
/** Only sound on an environment nobody else holds yet. */
|
|
80
|
+
private apply;
|
|
72
81
|
private defineInNamespace;
|
|
73
82
|
defineSuper(definition: IdentifierDefinition & {
|
|
74
83
|
name: Identifier;
|
|
@@ -96,31 +96,52 @@ class Environment {
|
|
|
96
96
|
if (ns !== undefined && this.n !== ns) {
|
|
97
97
|
return this.defineInNamespace(definition, ns);
|
|
98
98
|
}
|
|
99
|
+
const newEnvironment = this.clone(false);
|
|
100
|
+
newEnvironment.apply(name, definition);
|
|
101
|
+
return newEnvironment;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Define several identifiers at once in a more performant fashion.
|
|
105
|
+
* @param definitions - The definitions to add.
|
|
106
|
+
*/
|
|
107
|
+
defineAll(definitions) {
|
|
108
|
+
let env = this.clone(false);
|
|
109
|
+
for (const definition of definitions) {
|
|
110
|
+
const [name, ns] = identifier_1.Identifier.toArray(definition.name);
|
|
111
|
+
if (ns !== undefined && env.n !== ns) {
|
|
112
|
+
env = env.defineInNamespace(definition, ns);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
env.apply(name, definition);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return env;
|
|
119
|
+
}
|
|
120
|
+
/** Only sound on an environment nobody else holds yet. */
|
|
121
|
+
apply(name, definition) {
|
|
99
122
|
/* isolate the cds from the originating reference, which may still be updated in place */
|
|
100
123
|
if (definition.cds !== undefined) {
|
|
101
124
|
definition = { ...definition, cds: definition.cds.slice() };
|
|
102
125
|
}
|
|
103
|
-
const newEnvironment = this.clone(false);
|
|
104
126
|
// When there are defined indices, merge the definitions
|
|
105
127
|
if (definition.cds === undefined) {
|
|
106
|
-
|
|
128
|
+
this.memory.set(name, [definition]);
|
|
107
129
|
}
|
|
108
130
|
else {
|
|
109
|
-
const existing =
|
|
131
|
+
const existing = this.memory.get(name);
|
|
110
132
|
const inGraphDefinition = definition;
|
|
111
133
|
if (existing !== undefined &&
|
|
112
134
|
inGraphDefinition.cds === undefined) {
|
|
113
|
-
|
|
135
|
+
this.memory.set(name, [inGraphDefinition]);
|
|
114
136
|
}
|
|
115
137
|
else if (existing === undefined || definition.cds === undefined) {
|
|
116
|
-
|
|
138
|
+
this.memory.set(name, [definition]);
|
|
117
139
|
}
|
|
118
140
|
else {
|
|
119
141
|
/* the array may be shared with clones, so replace instead of push */
|
|
120
|
-
|
|
142
|
+
this.memory.set(name, [...existing, definition]);
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
|
-
return newEnvironment;
|
|
124
145
|
}
|
|
125
146
|
defineInNamespace(definition, ns) {
|
|
126
147
|
if (this.n === ns) {
|
|
@@ -120,10 +120,9 @@ export declare const Identifier: {
|
|
|
120
120
|
* from the base package that exports it (`sd` yields `stats::sd`, `plot` yields `base::plot`) via the
|
|
121
121
|
* precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
|
|
122
122
|
* the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
|
|
123
|
+
* @see {@link Dataflow.qualify} - the compact form, if you have the call's id and its graph
|
|
123
124
|
*/
|
|
124
125
|
readonly toQualified: (this: void, origins: readonly Origin[] | undefined, name?: Identifier) => Identifier | undefined;
|
|
125
|
-
/** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
|
|
126
|
-
readonly toQualifiedName: (this: void, origins: readonly Origin[] | undefined, name?: Identifier) => string | undefined;
|
|
127
126
|
};
|
|
128
127
|
/**
|
|
129
128
|
* Well-known R package names used in {@link DefaultBuiltinConfig}.
|
|
@@ -200,6 +200,7 @@ exports.Identifier = {
|
|
|
200
200
|
* from the base package that exports it (`sd` yields `stats::sd`, `plot` yields `base::plot`) via the
|
|
201
201
|
* precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
|
|
202
202
|
* the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
|
|
203
|
+
* @see {@link Dataflow.qualify} - the compact form, if you have the call's id and its graph
|
|
203
204
|
*/
|
|
204
205
|
toQualified(origins, name) {
|
|
205
206
|
let sawUserDefinition = false;
|
|
@@ -224,11 +225,6 @@ exports.Identifier = {
|
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
227
|
return undefined;
|
|
227
|
-
},
|
|
228
|
-
/** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
|
|
229
|
-
toQualifiedName(origins, name) {
|
|
230
|
-
const qualified = exports.Identifier.toQualified(origins, name);
|
|
231
|
-
return qualified === undefined ? undefined : exports.Identifier.toString(qualified);
|
|
232
228
|
}
|
|
233
229
|
};
|
|
234
230
|
/**
|
package/dataflow/extractor.js
CHANGED
|
@@ -126,8 +126,7 @@ function produceDataFlowGraph(parser, completeAst, ctx) {
|
|
|
126
126
|
ctx.files.addConsideredFile(files[0].filePath ? files[0].filePath : flowr_file_1.FlowrFile.INLINE_PATH);
|
|
127
127
|
const env = ctx.env.makeCleanEnv();
|
|
128
128
|
env.current.n = ctx.meta.getNamespace();
|
|
129
|
-
|
|
130
|
-
const environment = (0, built_in_library_1.attachDeclaredDependencies)((0, built_in_library_1.attachBaseRNamespaces)(env, ctx), ctx);
|
|
129
|
+
const environment = (0, built_in_library_1.attachProject)(env, ctx);
|
|
131
130
|
const dfData = {
|
|
132
131
|
parser,
|
|
133
132
|
completeAst,
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.DataflowGraphBuilder = void 0;
|
|
4
37
|
exports.emptyGraph = emptyGraph;
|
|
@@ -10,7 +43,6 @@ const vertex_1 = require("./vertex");
|
|
|
10
43
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
44
|
const edge_1 = require("./edge");
|
|
12
45
|
const default_builtin_config_1 = require("../environments/default-builtin-config");
|
|
13
|
-
const flowr_search_executor_1 = require("../../search/flowr-search-executor");
|
|
14
46
|
const assert_1 = require("../../util/assert");
|
|
15
47
|
const flowr_analyzer_context_1 = require("../../project/context/flowr-analyzer-context");
|
|
16
48
|
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
@@ -189,12 +221,19 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
189
221
|
return this.addEdge(node_id_1.NodeId.normalize(from), node_id_1.NodeId.normalize(to), type);
|
|
190
222
|
}
|
|
191
223
|
async queryHelper(from, to, data, type) {
|
|
224
|
+
/*
|
|
225
|
+
* the search executor reaches back into the dataflow graph (via the queries and the linter), so importing it
|
|
226
|
+
* up here would make this cycle load-bearing: whoever is loaded first sees the other half-initialized, which
|
|
227
|
+
* breaks at module-evaluation time (a subclass extending an `undefined` base). We only need it once a query
|
|
228
|
+
* is actually run, which is long after every module is up.
|
|
229
|
+
*/
|
|
230
|
+
const { runSearch } = await Promise.resolve().then(() => __importStar(require('../../search/flowr-search-executor')));
|
|
192
231
|
let fromId;
|
|
193
232
|
if ('nodeId' in from) {
|
|
194
233
|
fromId = from.nodeId;
|
|
195
234
|
}
|
|
196
235
|
else {
|
|
197
|
-
const result = (await
|
|
236
|
+
const result = (await runSearch(from.query, data)).getElements();
|
|
198
237
|
(0, assert_1.guard)(result.length === 1, `from query result should yield exactly one node, but yielded ${result.length}`);
|
|
199
238
|
fromId = result[0].node.info.id;
|
|
200
239
|
}
|
|
@@ -203,7 +242,7 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
|
|
|
203
242
|
toIds = to.target;
|
|
204
243
|
}
|
|
205
244
|
else {
|
|
206
|
-
const result = (await
|
|
245
|
+
const result = (await runSearch(to.query, data)).getElements();
|
|
207
246
|
toIds = result.map(r => r.node.info.id);
|
|
208
247
|
}
|
|
209
248
|
return this.edgeHelper(fromId, toIds, type);
|
|
@@ -7,12 +7,14 @@ import { computeCallGraphSummaries, propagateTransitiveSideEffects } from '../in
|
|
|
7
7
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import type { REnvironmentInformation } from '../environments/environment';
|
|
9
9
|
import type { DataflowGraphVertexInfo } from './vertex';
|
|
10
|
+
import { Identifier } from '../environments/identifier';
|
|
10
11
|
/**
|
|
11
12
|
* This is the root helper object to work with the {@link DataflowGraph}.
|
|
12
13
|
*
|
|
13
14
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
14
15
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
15
16
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
17
|
+
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call from its id and graph,
|
|
16
18
|
*/
|
|
17
19
|
export declare const Dataflow: {
|
|
18
20
|
/**
|
|
@@ -81,6 +83,19 @@ export declare const Dataflow: {
|
|
|
81
83
|
* @see {@link getOriginInDfg} - for the underlying function
|
|
82
84
|
*/
|
|
83
85
|
readonly origin: typeof getOriginInDfg;
|
|
86
|
+
/**
|
|
87
|
+
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
88
|
+
* export (with `purrr` loaded, a `map()` call yields `Identifier.make('map', 'purrr')`).
|
|
89
|
+
*
|
|
90
|
+
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
91
|
+
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
92
|
+
* @param id - The id of the call to qualify
|
|
93
|
+
* @param graph - The graph the call is part of
|
|
94
|
+
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
95
|
+
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
96
|
+
* Set this to `false` to only qualify what the origins resolve to.
|
|
97
|
+
*/
|
|
98
|
+
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
84
99
|
/**
|
|
85
100
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
86
101
|
*/
|
|
@@ -8,12 +8,15 @@ const dfg_get_origin_1 = require("../origin/dfg-get-origin");
|
|
|
8
8
|
const graph_helper_1 = require("./graph-helper");
|
|
9
9
|
const call_graph_1 = require("./call-graph");
|
|
10
10
|
const transitive_side_effects_1 = require("../internal/process/functions/call/built-in/transitive-side-effects");
|
|
11
|
+
const vertex_1 = require("./vertex");
|
|
12
|
+
const identifier_1 = require("../environments/identifier");
|
|
11
13
|
/**
|
|
12
14
|
* This is the root helper object to work with the {@link DataflowGraph}.
|
|
13
15
|
*
|
|
14
16
|
* - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph),
|
|
15
17
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
16
18
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
19
|
+
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call from its id and graph,
|
|
17
20
|
*/
|
|
18
21
|
exports.Dataflow = {
|
|
19
22
|
name: 'Dataflow',
|
|
@@ -51,6 +54,23 @@ exports.Dataflow = {
|
|
|
51
54
|
* @see {@link getOriginInDfg} - for the underlying function
|
|
52
55
|
*/
|
|
53
56
|
origin: dfg_get_origin_1.getOriginInDfg,
|
|
57
|
+
/**
|
|
58
|
+
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
59
|
+
* export (with `purrr` loaded, a `map()` call yields `Identifier.make('map', 'purrr')`).
|
|
60
|
+
*
|
|
61
|
+
* This is the compact form of {@link Identifier.toQualified}, reconstructing both the
|
|
62
|
+
* {@link Dataflow.origin|origins} and the call's name from the graph.
|
|
63
|
+
* @param id - The id of the call to qualify
|
|
64
|
+
* @param graph - The graph the call is part of
|
|
65
|
+
* @param qualifyBaseR - Whether to also qualify a bare base-R call from the package exporting it
|
|
66
|
+
* (`sd` yields `stats::sd`), which needs neither a loaded database nor graph edges.
|
|
67
|
+
* Set this to `false` to only qualify what the origins resolve to.
|
|
68
|
+
*/
|
|
69
|
+
qualify(id, graph, qualifyBaseR = true) {
|
|
70
|
+
// only look the vertex up when its name is actually needed (base-R qualification)
|
|
71
|
+
const vertex = qualifyBaseR ? graph.getVertex(id) : undefined;
|
|
72
|
+
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), (0, vertex_1.isFunctionCallVertex)(vertex) ? vertex.name : undefined);
|
|
73
|
+
},
|
|
54
74
|
/**
|
|
55
75
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
56
76
|
*/
|
|
@@ -26,19 +26,19 @@ function processAttach(name, args, rootId, data) {
|
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
28
|
/* build the attached layer with the env's known bindings */
|
|
29
|
-
|
|
29
|
+
const injected = [];
|
|
30
30
|
for (const [varName, varDefs] of envirResolution.envDef.envState.current.memory) {
|
|
31
31
|
for (const varDef of varDefs) {
|
|
32
32
|
const inDef = varDef;
|
|
33
|
-
|
|
33
|
+
injected.push({
|
|
34
34
|
...inDef,
|
|
35
35
|
name: varName,
|
|
36
36
|
type: identifier_1.ReferenceType.Variable,
|
|
37
|
-
};
|
|
38
|
-
attachedLayer = attachedLayer.define(injected);
|
|
37
|
+
});
|
|
39
38
|
result.graph.addEdge(inDef.nodeId, rootId, edge_1.EdgeType.Reads);
|
|
40
39
|
}
|
|
41
40
|
}
|
|
41
|
+
const attachedLayer = new environment_1.Environment(result.environment.current).defineAll(injected);
|
|
42
42
|
/* R attaches below `.GlobalEnv`, so existing global bindings shadow the attached ones */
|
|
43
43
|
return { ...result, environment: {
|
|
44
44
|
current: environment_1.REnvironment.attachBelowGlobal(result.environment.current, attachedLayer, attachedLayer),
|
|
@@ -25,6 +25,13 @@ export interface EnvirResolution<OtherInfo> {
|
|
|
25
25
|
* Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
|
|
26
26
|
*/
|
|
27
27
|
export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
|
|
28
|
+
/**
|
|
29
|
+
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
30
|
+
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
31
|
+
* built-in argument matcher use R's real signature (via {@link ReadOnlyFlowrAnalyzerDependenciesContext#signatureOf})
|
|
32
|
+
* instead of a hardcoded formal list, while staying correct -- and graph-invariant -- when no signature is available.
|
|
33
|
+
*/
|
|
34
|
+
export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorInformation<OtherInfo & ParentInformation>, id: Identifier, fallback: readonly string[]): readonly string[];
|
|
28
35
|
/** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
29
36
|
export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
|
|
30
37
|
/** Resolves the `argName` argument (default `'envir'`, pmatch against `allParamNames`), falling back to `positionalFallbackIndex`, to an {@link EnvirResolution}. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bindArgs = bindArgs;
|
|
4
|
+
exports.signatureParamNames = signatureParamNames;
|
|
4
5
|
exports.resolveArgToEnvir = resolveArgToEnvir;
|
|
5
6
|
exports.resolveEnvirArg = resolveEnvirArg;
|
|
6
7
|
exports.resolveSymbolToEnvir = resolveSymbolToEnvir;
|
|
@@ -8,6 +9,7 @@ exports.routeWrittenToCustomEnv = routeWrittenToCustomEnv;
|
|
|
8
9
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
10
|
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
10
11
|
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
12
|
+
const decode_1 = require("../../../../../../project/sigdb/decode");
|
|
11
13
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
12
14
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
13
15
|
const define_1 = require("../../../../../environments/define");
|
|
@@ -59,6 +61,17 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
|
|
|
59
61
|
function bindArgs(args, paramNames) {
|
|
60
62
|
return r_function_call_1.RFunctionCall.matchArgsToParams(args, paramNames);
|
|
61
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
66
|
+
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
67
|
+
* built-in argument matcher use R's real signature (via {@link ReadOnlyFlowrAnalyzerDependenciesContext#signatureOf})
|
|
68
|
+
* instead of a hardcoded formal list, while staying correct -- and graph-invariant -- when no signature is available.
|
|
69
|
+
*/
|
|
70
|
+
function signatureParamNames(data, id, fallback) {
|
|
71
|
+
const sig = data.ctx.deps.signatureOf(id)?.signature;
|
|
72
|
+
const names = sig ? (0, decode_1.signatureParameterNames)(sig) : [];
|
|
73
|
+
return names.length > 0 ? names : fallback;
|
|
74
|
+
}
|
|
62
75
|
/** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
63
76
|
function resolveArgToEnvir(arg, data) {
|
|
64
77
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
@@ -60,4 +60,8 @@ export declare function attachBaseRNamespaces(env: REnvironmentInformation, ctx:
|
|
|
60
60
|
* no-op via the {@link isAttached} guard inside {@link attachDependencyToEnvironment}.
|
|
61
61
|
*/
|
|
62
62
|
export declare function attachDeclaredDependencies(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
|
|
63
|
+
/** attach the analyzed package's own `NAMESPACE importFrom(...)` symbols (by their bare name) below the global, so a bare imported call resolves to its source package */
|
|
64
|
+
export declare function attachProjectImports(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
|
|
65
|
+
/** attach every project-level environment layer in order: base R namespaces, the project's own `importFrom` symbols, then its declared dependencies */
|
|
66
|
+
export declare function attachProject(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
|
|
63
67
|
export {};
|
|
@@ -6,6 +6,8 @@ exports.loadNodesForNamespace = loadNodesForNamespace;
|
|
|
6
6
|
exports.attachDependencyToEnvironment = attachDependencyToEnvironment;
|
|
7
7
|
exports.attachBaseRNamespaces = attachBaseRNamespaces;
|
|
8
8
|
exports.attachDeclaredDependencies = attachDeclaredDependencies;
|
|
9
|
+
exports.attachProjectImports = attachProjectImports;
|
|
10
|
+
exports.attachProject = attachProject;
|
|
9
11
|
const known_call_handling_1 = require("../known-call-handling");
|
|
10
12
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
13
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
@@ -392,19 +394,15 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
|
|
|
392
394
|
const exports = selectExports((0, flowr_namespace_file_1.getCallables)(dependency.namespaceInfo), spec);
|
|
393
395
|
if (spec.namespaceOnly || isSubsetAttach(spec)) {
|
|
394
396
|
const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
layer = layer.define(exportDefinition(pack, exp, definedAt));
|
|
398
|
-
}
|
|
397
|
+
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType)
|
|
398
|
+
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
399
399
|
return { level: envInfo.level, current: environment_1.REnvironment.attachBelowGlobal(envInfo.current, layer, layer) };
|
|
400
400
|
}
|
|
401
401
|
// full attach: imports layer at the bottom, namespace (exports) layer on top
|
|
402
402
|
let importsEnv = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.Imports);
|
|
403
403
|
importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
namespaceEnv = namespaceEnv.define(exportDefinition(pack, exp, definedAt));
|
|
407
|
-
}
|
|
404
|
+
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
|
|
405
|
+
.defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
|
|
408
406
|
return { level: envInfo.level, current: environment_1.REnvironment.attachBelowGlobal(envInfo.current, namespaceEnv, importsEnv) };
|
|
409
407
|
}
|
|
410
408
|
/** A namespace-only load is subsumed by any layer for `pack`; a full attach ignores a mere {@link EnvType.LoadedNamespace}. */
|
|
@@ -481,6 +479,46 @@ function attachDeclaredDependencies(env, ctx) {
|
|
|
481
479
|
}
|
|
482
480
|
return built;
|
|
483
481
|
}
|
|
482
|
+
/** attach the analyzed package's own `NAMESPACE importFrom(...)` symbols (by their bare name) below the global, so a bare imported call resolves to its source package */
|
|
483
|
+
function attachProjectImports(env, ctx) {
|
|
484
|
+
const own = ctx.deps.getDependency('current')?.namespaceInfo;
|
|
485
|
+
if (own === undefined || own.importedPackages.size === 0) {
|
|
486
|
+
return env;
|
|
487
|
+
}
|
|
488
|
+
const layerNamespace = 'current';
|
|
489
|
+
const toDefine = [];
|
|
490
|
+
for (const [pkg, funcs] of own.importedPackages) {
|
|
491
|
+
// an explicit `importFrom(pkg, a, b)` names the symbols directly; `import(pkg)` needs the package's own export list
|
|
492
|
+
let names;
|
|
493
|
+
if (funcs === 'all') {
|
|
494
|
+
const imported = ctx.deps.getDependency(pkg)?.namespaceInfo;
|
|
495
|
+
if (imported === undefined) {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
names = (0, flowr_namespace_file_1.getCallables)(imported);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
names = funcs;
|
|
502
|
+
}
|
|
503
|
+
for (const fn of names) {
|
|
504
|
+
toDefine.push({
|
|
505
|
+
name: identifier_1.Identifier.make(fn, layerNamespace),
|
|
506
|
+
type: identifier_1.ReferenceType.Function,
|
|
507
|
+
nodeId: node_id_1.NodeId.fromPkgFn(pkg, fn),
|
|
508
|
+
definedAt: node_id_1.NodeId.toBuiltIn(pkg)
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (toDefine.length === 0) {
|
|
513
|
+
return env;
|
|
514
|
+
}
|
|
515
|
+
const layer = new environment_1.Environment(env.current).asLibrary(layerNamespace, environment_1.EnvType.Imports).defineAll(toDefine);
|
|
516
|
+
return { level: env.level, current: environment_1.REnvironment.attachBelowGlobal(env.current, layer, layer) };
|
|
517
|
+
}
|
|
518
|
+
/** attach every project-level environment layer in order: base R namespaces, the project's own `importFrom` symbols, then its declared dependencies */
|
|
519
|
+
function attachProject(env, ctx) {
|
|
520
|
+
return attachDeclaredDependencies(attachProjectImports(attachBaseRNamespaces(env, ctx), ctx), ctx);
|
|
521
|
+
}
|
|
484
522
|
function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
|
|
485
523
|
for (const imp of namespaceInfo.importedPackages) {
|
|
486
524
|
const importedDependency = ctx.deps.getDependency(imp[0]);
|
|
@@ -496,17 +534,25 @@ function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
|
|
|
496
534
|
if (alreadyImportedAll.has(importedDependency.name)) {
|
|
497
535
|
continue;
|
|
498
536
|
}
|
|
537
|
+
/* collect first and define in one go, as defining one by one copies the (growing) memory every time */
|
|
538
|
+
const toDefine = [];
|
|
539
|
+
const queued = new Set();
|
|
499
540
|
for (const func of funcToImport) {
|
|
500
|
-
|
|
541
|
+
const identifier = package_1.Package.functionIdentifier(importedDependency.name, func);
|
|
542
|
+
if (importsEnv.memory.has(identifier) || queued.has(identifier)) {
|
|
501
543
|
continue;
|
|
502
544
|
}
|
|
503
|
-
|
|
504
|
-
|
|
545
|
+
queued.add(identifier);
|
|
546
|
+
toDefine.push({
|
|
547
|
+
name: identifier_1.Identifier.make(identifier, importsEnv.n),
|
|
505
548
|
type: identifier_1.ReferenceType.Function,
|
|
506
549
|
nodeId: node_id_1.NodeId.fromPkgFn(importedDependency.name, func),
|
|
507
550
|
definedAt: node_id_1.NodeId.toBuiltIn(importedDependency.name)
|
|
508
551
|
});
|
|
509
552
|
}
|
|
553
|
+
if (toDefine.length > 0) {
|
|
554
|
+
importsEnv = importsEnv.defineAll(toDefine);
|
|
555
|
+
}
|
|
510
556
|
if (imp[1] === 'all') {
|
|
511
557
|
alreadyImportedAll.add(importedDependency.name);
|
|
512
558
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
2
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
5
|
+
import type { DataflowInformation } from '../../../../../info';
|
|
6
|
+
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
|
+
/**
|
|
8
|
+
* Processes a built-in 'load' function call by retrieving the names of the variables loaded by the given file.
|
|
9
|
+
* Example: `load(test.rda)` with two variables 'x' and 'y'. processLoadCall adds 'x' and 'y' to the dataflow graph and
|
|
10
|
+
* adds control dependencies between the variables and the loaded file.
|
|
11
|
+
*/
|
|
12
|
+
export declare function processLoadCall<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|