@eagleoutice/flowr 2.16.1 → 2.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/abstract-interpretation/data-frame/arguments.js +4 -3
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
- package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
- package/abstract-interpretation/data-frame/semantics.js +2 -6
- package/benchmark/slicer.js +1 -3
- package/benchmark/summarizer/first-phase/input.js +1 -12
- package/benchmark/summarizer/second-phase/process.d.ts +7 -0
- package/benchmark/summarizer/second-phase/process.js +15 -12
- package/cli/repl/commands/repl-cfg.js +18 -49
- package/cli/repl/commands/repl-clipboard.d.ts +2 -0
- package/cli/repl/commands/repl-clipboard.js +5 -0
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/commands/repl-dataflow.js +21 -55
- package/cli/repl/commands/repl-normalize.js +15 -28
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +10 -10
- package/cli/repl/commands/repl-signature.js +4 -4
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +8 -30
- package/cli/repl/server/messages/message-analysis.js +1 -1
- package/config.d.ts +6 -0
- package/config.js +7 -4
- package/control-flow/cfg-dead-code.js +5 -14
- package/control-flow/cfg-to-basic-blocks.js +1 -6
- package/control-flow/control-flow-graph.d.ts +2 -16
- package/control-flow/control-flow-graph.js +8 -66
- package/control-flow/diff-cfg.js +10 -23
- package/control-flow/semantic-cfg-guided-visitor.js +5 -11
- package/control-flow/simple-visitor.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +138 -138
- package/data/r-base-packages.generated.js +0 -1
- package/data/r-base-primitives.generated.js +0 -1
- package/data/r-s3-generics.generated.d.ts +5 -0
- package/data/r-s3-generics.generated.js +103 -0
- package/dataflow/cluster.js +2 -1
- package/dataflow/environments/append.d.ts +1 -0
- package/dataflow/environments/built-in-props.d.ts +15 -2
- package/dataflow/environments/built-in-props.js +31 -4
- package/dataflow/environments/built-in.js +15 -9
- package/dataflow/environments/clone.d.ts +1 -0
- package/dataflow/environments/clone.js +1 -0
- package/dataflow/environments/default-builtin-config.d.ts +385 -25
- package/dataflow/environments/default-builtin-config.js +186 -106
- package/dataflow/environments/define.d.ts +1 -0
- package/dataflow/environments/define.js +1 -0
- package/dataflow/environments/environment.d.ts +27 -0
- package/dataflow/environments/environment.js +37 -16
- package/dataflow/environments/frame-memory.d.ts +9 -1
- package/dataflow/environments/frame-memory.js +12 -1
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -0
- package/dataflow/environments/query-fn-props.js +7 -0
- package/dataflow/environments/resolve-by-name.js +11 -4
- package/dataflow/environments/scoping.d.ts +3 -0
- package/dataflow/environments/scoping.js +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
- package/dataflow/eval/resolve/resolve-argument.js +21 -12
- package/dataflow/eval/resolve/resolve-numbers.js +5 -2
- package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
- package/dataflow/eval/resolve/resolve.js +1 -2
- package/dataflow/eval/values/intervals/interval-constants.js +1 -6
- package/dataflow/eval/values/r-value.js +1 -6
- package/dataflow/extractor.js +17 -17
- package/dataflow/fn/argument-roles.js +15 -15
- package/dataflow/fn/class-declaration.js +7 -7
- package/dataflow/fn/frame-reflection.d.ts +1 -23
- package/dataflow/fn/frame-reflection.js +8 -95
- package/dataflow/fn/function-props.d.ts +0 -3
- package/dataflow/fn/function-props.js +9 -11
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/fn/strict-function.js +15 -14
- package/dataflow/graph/call-graph.d.ts +8 -0
- package/dataflow/graph/call-graph.js +40 -25
- package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
- package/dataflow/graph/dataflowgraph-builder.js +15 -135
- package/dataflow/graph/df-helper.d.ts +56 -4
- package/dataflow/graph/df-helper.js +116 -1
- package/dataflow/graph/diff-dataflow-graph.js +13 -15
- package/dataflow/graph/graph-helper.d.ts +20 -0
- package/dataflow/graph/graph-helper.js +18 -0
- package/dataflow/graph/graph.js +15 -8
- package/dataflow/graph/match-args.d.ts +1 -1
- package/dataflow/graph/match-args.js +3 -3
- package/dataflow/internal/linker.d.ts +4 -10
- package/dataflow/internal/linker.js +21 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +14 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +6 -7
- package/dataflow/internal/process/functions/call/deferred.js +8 -8
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
- package/dataflow/internal/process/functions/call/named-call-handling.js +64 -11
- package/dataflow/internal/process/functions/call/nse.js +4 -4
- package/dataflow/internal/process/functions/call/quoted.js +16 -14
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/internal/process/process-named-call.js +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
- package/documentation/data/faq/wiki-faq-store.js +2 -2
- package/documentation/doc-capabilities.js +2 -1
- package/documentation/doc-util/doc-functions.js +2 -2
- package/documentation/doc-util/doc-repl.js +4 -4
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-cfg.js +2 -1
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-dataflow-graph.js +6 -6
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +54 -4
- package/documentation/wiki-mk/doc-maker.js +1 -2
- package/documentation/wiki-query.js +25 -0
- package/documentation/wiki-search.js +2 -1
- package/documentation/wiki-signature-database.js +0 -2
- package/linter/linter-executor.js +4 -0
- package/linter/linter-rules.d.ts +526 -4
- package/linter/linter-rules.js +39 -1
- package/linter/linter-tags.d.ts +6 -0
- package/linter/linter-tags.js +6 -0
- package/linter/rules/absolute-path.js +4 -3
- package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
- package/linter/rules/cmd-check/bogus-return.js +63 -0
- package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
- package/linter/rules/cmd-check/call-arguments.js +211 -0
- package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
- package/linter/rules/cmd-check/class-string-comparison.js +135 -0
- package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
- package/linter/rules/cmd-check/cmd-check-util.js +169 -0
- package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
- package/linter/rules/cmd-check/compiled-code.js +350 -0
- package/linter/rules/cmd-check/conformance.d.ts +47 -0
- package/linter/rules/cmd-check/conformance.js +166 -0
- package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
- package/linter/rules/cmd-check/dependency-declaration.js +299 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
- package/linter/rules/cmd-check/description-metadata.js +393 -0
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +54 -0
- package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
- package/linter/rules/cmd-check/file-checks.d.ts +29 -0
- package/linter/rules/cmd-check/file-checks.js +34 -0
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
- package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
- package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
- package/linter/rules/cmd-check/global-environment-modification.js +237 -0
- package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
- package/linter/rules/cmd-check/namespace-tampering.js +162 -0
- package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
- package/linter/rules/cmd-check/non-ascii-code.js +112 -0
- package/linter/rules/cmd-check/package-code.d.ts +30 -0
- package/linter/rules/cmd-check/package-code.js +141 -0
- package/linter/rules/cmd-check/package-data.d.ts +49 -0
- package/linter/rules/cmd-check/package-data.js +181 -0
- package/linter/rules/cmd-check/package-files.d.ts +41 -0
- package/linter/rules/cmd-check/package-files.js +157 -0
- package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
- package/linter/rules/cmd-check/package-hooks.js +165 -0
- package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
- package/linter/rules/cmd-check/package-metafiles.js +292 -0
- package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
- package/linter/rules/cmd-check/package-runtime.js +284 -0
- package/linter/rules/cmd-check/package-structure.d.ts +85 -0
- package/linter/rules/cmd-check/package-structure.js +320 -0
- package/linter/rules/cmd-check/rd-files.d.ts +67 -0
- package/linter/rules/cmd-check/rd-files.js +621 -0
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
- package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
- package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
- package/linter/rules/deprecated-functions.js +4 -4
- package/linter/rules/function-finder-util.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -3
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -14
- package/linter/rules/network-functions.d.ts +4 -3
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +8 -3
- package/linter/rules/no-leaked-credentials.js +134 -36
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +21 -14
- package/linter/rules/seeded-randomness.js +5 -5
- package/linter/rules/software-has-license.d.ts +1 -1
- package/linter/rules/software-has-license.js +1 -1
- package/linter/rules/unclosed-connection.js +3 -3
- package/linter/rules/undefined-symbol-util.js +16 -32
- package/linter/rules/undefined-symbol.d.ts +2 -0
- package/linter/rules/undefined-symbol.js +33 -3
- package/linter/rules/unescaped-arguments.d.ts +13 -2
- package/linter/rules/unescaped-arguments.js +104 -15
- package/linter/rules/unused-definition.js +13 -19
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/context/flowr-analyzer-context.js +1 -1
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
- package/project/context/flowr-analyzer-files-context.d.ts +6 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
- package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
- package/project/context/flowr-file.d.ts +4 -0
- package/project/context/flowr-file.js +4 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
- package/project/sigdb/build.js +16 -30
- package/project/sigdb/dict.d.ts +4 -6
- package/project/sigdb/dict.js +125 -31
- package/project/sigdb/reader.js +2 -18
- package/project/sigdb/sigdb-download.js +14 -23
- package/queries/base-query-format.d.ts +2 -0
- package/queries/base-query-format.js +10 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/absint-query/absint-query-format.js +5 -7
- package/queries/catalog/call-context-query/call-context-query-executor.js +26 -33
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
- package/queries/catalog/config-query/config-query-format.js +3 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
- package/queries/catalog/dependencies-query/data-flow.d.ts +43 -0
- package/queries/catalog/dependencies-query/data-flow.js +173 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
- package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
- package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
- package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
- package/queries/catalog/dependencies-query/implicit-echo.js +33 -34
- package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
- package/queries/catalog/dependencies-query/link-devices.js +9 -6
- package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
- package/queries/catalog/dependencies-query/plot-description.js +119 -0
- package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
- package/queries/catalog/dependencies-query/plot-objects.js +61 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
- package/queries/catalog/dice-query/dice-query-format.js +3 -40
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +6 -4
- package/queries/catalog/input-sources-query/input-source-functions.js +11 -6
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -3
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -5
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +12 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +237 -40
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-executor.js +10 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
- package/queries/catalog/linter-query/linter-query-format.js +32 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +4 -5
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
- package/queries/catalog/search-query/search-query-format.js +1 -3
- package/queries/catalog/signature-query/signature-query-executor.js +3 -3
- package/queries/catalog/signature-query/signature-query-format.js +2 -2
- package/queries/catalog/slice-query-options.d.ts +16 -0
- package/queries/catalog/slice-query-options.js +28 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
- package/queries/query-print.d.ts +4 -0
- package/queries/query-print.js +17 -1
- package/queries/query.d.ts +3 -3
- package/queries/query.js +3 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
- package/r-bridge/lang-4.x/ast/model/model.js +28 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
- package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
- package/r-bridge/retriever.d.ts +0 -4
- package/r-bridge/retriever.js +0 -13
- package/r-bridge/roxygen2/documentation-provider.js +3 -7
- package/r-bridge/shell.js +3 -8
- package/reconstruct/auto-select/magic-comments.js +8 -7
- package/reconstruct/inline/source-inline-map.d.ts +3 -0
- package/reconstruct/inline/source-inline-map.js +8 -7
- package/reconstruct/reconstruct.d.ts +1 -1
- package/reconstruct/reconstruct.js +33 -109
- package/search/flowr-search-printer.js +4 -15
- package/search/search-executor/search-enrichers.js +5 -3
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/filters/all-variables.js +1 -2
- package/slicing/static/fingerprint.js +11 -2
- package/slicing/static/slice-call.d.ts +2 -8
- package/slicing/static/slice-call.js +8 -18
- package/slicing/static/static-slicer.js +81 -6
- package/util/collections/arrays.js +1 -1
- package/util/collections/set.js +1 -1
- package/util/diff-graph.d.ts +4 -0
- package/util/diff-graph.js +12 -0
- package/util/files.js +2 -6
- package/util/json.js +1 -15
- package/util/mermaid/cfg.js +10 -17
- package/util/mermaid/dfg.js +6 -8
- package/util/objects.d.ts +1 -1
- package/util/quads.js +4 -13
- package/util/r-author.js +5 -5
- package/util/range.d.ts +9 -0
- package/util/range.js +11 -0
- package/util/schema.js +3 -3
- package/util/simple-df/dfg-view.js +2 -1
- package/util/text/ansi.js +1 -2
- package/util/text/playground-link.js +2 -1
- package/util/text/r-highlight.js +2 -1
- package/util/text/strings.d.ts +2 -0
- package/util/text/strings.js +5 -0
- package/util/text/time.js +1 -2
- package/util/version.js +4 -3
- package/dataflow/fn/recursive-function.d.ts +0 -6
- package/dataflow/fn/recursive-function.js +0 -32
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ClosureRefs = void 0;
|
|
4
4
|
exports.findNonLocalReads = findNonLocalReads;
|
|
5
5
|
exports.produceNameSharedIdMap = produceNameSharedIdMap;
|
|
6
|
-
exports.linkArgumentsOnCall = linkArgumentsOnCall;
|
|
7
6
|
exports.linkFunctionCallWithSingleTarget = linkFunctionCallWithSingleTarget;
|
|
8
7
|
exports.linkFunctionCalls = linkFunctionCalls;
|
|
9
8
|
exports.getAllFunctionCallTargets = getAllFunctionCallTargets;
|
|
@@ -17,6 +16,7 @@ exports.accessedFieldName = accessedFieldName;
|
|
|
17
16
|
exports.linkFieldReads = linkFieldReads;
|
|
18
17
|
exports.bindAccessedField = bindAccessedField;
|
|
19
18
|
exports.separateClosureInstances = separateClosureInstances;
|
|
19
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
20
20
|
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
21
21
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
22
22
|
const function_semantics_1 = require("../fn/function-semantics");
|
|
@@ -30,7 +30,6 @@ const edge_1 = require("../graph/edge");
|
|
|
30
30
|
const vertex_1 = require("../graph/vertex");
|
|
31
31
|
const info_1 = require("../info");
|
|
32
32
|
const r_access_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
33
|
-
const unpack_argument_1 = require("./process/functions/call/argument/unpack-argument");
|
|
34
33
|
const r_number_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
35
34
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
36
35
|
const unnamed_call_handling_1 = require("./process/functions/call/unnamed-call-handling");
|
|
@@ -40,7 +39,7 @@ const resolve_helper_1 = require("../environments/resolve-helper");
|
|
|
40
39
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
41
40
|
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
42
41
|
const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
43
|
-
const
|
|
42
|
+
const df_helper_1 = require("../graph/df-helper");
|
|
44
43
|
const ValueFlowBits = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
45
44
|
const FCallLinkReadBits = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls | edge_1.EdgeType.DefinedByOnCall;
|
|
46
45
|
/**
|
|
@@ -92,14 +91,6 @@ function produceNameSharedIdMap(references) {
|
|
|
92
91
|
}
|
|
93
92
|
return nameIdShares;
|
|
94
93
|
}
|
|
95
|
-
/**
|
|
96
|
-
* {@link FunctionSemantics.call.match.onCall|Matches} the arguments to the parameters and links them in the graph,
|
|
97
|
-
* returning the resolved map from argument ids to parameter ids.
|
|
98
|
-
* @useInstead {@link FunctionSemantics.call.match.onCallAndLink}
|
|
99
|
-
*/
|
|
100
|
-
function linkArgumentsOnCall(args, params, graph) {
|
|
101
|
-
return function_semantics_1.FunctionSemantics.call.match.onCallAndLink(args, params, graph);
|
|
102
|
-
}
|
|
103
94
|
function environmentsOfCallee(info, environment) {
|
|
104
95
|
if (info.name === undefined) {
|
|
105
96
|
return [];
|
|
@@ -153,7 +144,7 @@ function linkFunctionCallWithSingleTarget(graph, { subflow: fnSubflow, exitPoint
|
|
|
153
144
|
if (!vertex_2.DfgVertex.isVariableDefinition(graph.getVertex(node)) || fieldAssignmentOf(node, idMap) === undefined) {
|
|
154
145
|
continue;
|
|
155
146
|
}
|
|
156
|
-
for (const captured of
|
|
147
|
+
for (const captured of df_helper_1.Dataflow.targetsOf(graph, node, edge_1.EdgeType.Reads)) {
|
|
157
148
|
const frame = fnSubflow.graph.has(captured) ? undefined : model_1.RNode.findEnclosing(captured, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
158
149
|
const owner = frame === undefined ? undefined : graph.getVertex(frame);
|
|
159
150
|
const name = node_id_1.NodeId.recoverName(captured, idMap);
|
|
@@ -170,7 +161,7 @@ function linkFunctionCallWithSingleTarget(graph, { subflow: fnSubflow, exitPoint
|
|
|
170
161
|
graph.addEdge(id, fnId, edge_1.EdgeType.Calls);
|
|
171
162
|
const fn = idMap.get(fnId);
|
|
172
163
|
if (r_function_definition_1.RFunctionDefinition.is(fn)) {
|
|
173
|
-
applyForForcedArgs(graph, id, params,
|
|
164
|
+
applyForForcedArgs(graph, id, params, function_semantics_1.FunctionSemantics.call.match.onCallAndLink(info.args, fn.parameters, graph));
|
|
174
165
|
}
|
|
175
166
|
return exitPoints.filter(e => (0, info_1.doesExitPointPropagateCalls)(e.type));
|
|
176
167
|
}
|
|
@@ -190,7 +181,7 @@ function applyForForcedArgs(graph, callId, readParams, argToParam) {
|
|
|
190
181
|
function linkFieldWritesOnCall(graph, id, fnId, start, binding, envState, idMap) {
|
|
191
182
|
const aliases = new Set([start]);
|
|
192
183
|
for (const alias of aliases) {
|
|
193
|
-
for (const from of
|
|
184
|
+
for (const from of df_helper_1.Dataflow.sourcesOf(graph, alias, ValueFlowBits)) {
|
|
194
185
|
aliases.add(from);
|
|
195
186
|
}
|
|
196
187
|
}
|
|
@@ -202,7 +193,7 @@ function linkFieldWritesOnCall(graph, id, fnId, start, binding, envState, idMap)
|
|
|
202
193
|
graph.addEdge(binding, id, edge_1.EdgeType.SideEffectOnCall);
|
|
203
194
|
/* a write in a nested function only runs when that function is called */
|
|
204
195
|
const within = model_1.RNode.findEnclosing(write, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
205
|
-
for (const caller of within === undefined || within === fnId ? [] :
|
|
196
|
+
for (const caller of within === undefined || within === fnId ? [] : df_helper_1.Dataflow.sourcesOf(graph, within, edge_1.EdgeType.Calls)) {
|
|
206
197
|
graph.addEdge(write, caller, edge_1.EdgeType.Reads);
|
|
207
198
|
}
|
|
208
199
|
}
|
|
@@ -219,7 +210,7 @@ function linkFunctionCall(graph, id, info, idMap, isRoot) {
|
|
|
219
210
|
const propagateExitPoints = [];
|
|
220
211
|
for (const def of functionDefs) {
|
|
221
212
|
/* we can skip this if we already linked it */
|
|
222
|
-
if (!
|
|
213
|
+
if (!df_helper_1.Dataflow.hasEdge(graph, id, def.id, edge_1.EdgeType.Calls)) {
|
|
223
214
|
propagateExitPoints.push(...linkFunctionCallWithSingleTarget(graph, def, info, idMap));
|
|
224
215
|
}
|
|
225
216
|
}
|
|
@@ -253,6 +244,7 @@ alsoCalls = []) {
|
|
|
253
244
|
}
|
|
254
245
|
/**
|
|
255
246
|
* convenience function returning all known call targets, as well as the name source which defines them
|
|
247
|
+
* @useInstead {@link Dataflow.callTargetsOf}
|
|
256
248
|
*/
|
|
257
249
|
function getAllFunctionCallTargets(call, graph, environment) {
|
|
258
250
|
const info = graph.getVertex(call);
|
|
@@ -260,13 +252,13 @@ function getAllFunctionCallTargets(call, graph, environment) {
|
|
|
260
252
|
return [];
|
|
261
253
|
}
|
|
262
254
|
const known = environment ?? info.environment;
|
|
263
|
-
const refType =
|
|
264
|
-
|
|
255
|
+
const refType = vertex_2.DfgVertex.hasOrigin(info, built_in_proc_name_1.BuiltInProcName.S3Dispatch) ? identifier_1.ReferenceType.S3MethodPrefix :
|
|
256
|
+
vertex_2.DfgVertex.hasOrigin(info, built_in_proc_name_1.BuiltInProcName.S7Dispatch) ? identifier_1.ReferenceType.S7MethodPrefix : identifier_1.ReferenceType.Function;
|
|
265
257
|
let functionCallDefs = [];
|
|
266
258
|
if (known !== undefined && info.name !== undefined && !identifier_1.Identifier.getName(info.name).startsWith(unnamed_call_handling_1.UnnamedFunctionCallPrefix)) {
|
|
267
259
|
functionCallDefs = resolve_helper_1.Resolve.byNameAndType(info.name, known, refType)?.map(d => d.nodeId) ?? [];
|
|
268
260
|
}
|
|
269
|
-
const followBits =
|
|
261
|
+
const followBits = vertex_2.DfgVertex.hasOrigin(info, built_in_proc_name_1.BuiltInProcName.Unnamed) || functionCallDefs.length === 0 ? FCallLinkReadBits : edge_1.EdgeType.Calls;
|
|
270
262
|
for (const [target, edge] of graph.edgesFrom(call)) {
|
|
271
263
|
if (edge_1.DfEdge.includesType(edge, followBits) && edge_1.DfEdge.doesNotIncludeType(edge, edge_1.EdgeType.Argument) && (known !== undefined || !node_id_1.NodeId.isBuiltIn(target))) {
|
|
272
264
|
functionCallDefs.push(target);
|
|
@@ -280,7 +272,7 @@ function getAllFunctionCallTargets(call, graph, environment) {
|
|
|
280
272
|
}
|
|
281
273
|
/**
|
|
282
274
|
* Finds all linked function definitions starting from the given read ids; expects the caller to already have resolved
|
|
283
|
-
* the accessed objects (first layer of reads/returns/calls/...). For call targets, use {@link
|
|
275
|
+
* the accessed objects (first layer of reads/returns/calls/...). For call targets, use {@link Dataflow.callTargetsOf} instead.
|
|
284
276
|
*/
|
|
285
277
|
function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGraph) {
|
|
286
278
|
const result = new Set();
|
|
@@ -370,7 +362,7 @@ function linkCallToDefinitions(graph, callId, definitions, idMap) {
|
|
|
370
362
|
return;
|
|
371
363
|
}
|
|
372
364
|
for (const fn of getAllLinkedFunctionDefinitions(new Set(definitions), graph)[0]) {
|
|
373
|
-
if (!
|
|
365
|
+
if (!df_helper_1.Dataflow.hasEdge(graph, callId, fn.id, edge_1.EdgeType.Calls)) {
|
|
374
366
|
linkFunctionCallWithSingleTarget(graph, fn, call, idMap);
|
|
375
367
|
}
|
|
376
368
|
}
|
|
@@ -511,7 +503,7 @@ function fieldAssignmentOf(readId, idMap) {
|
|
|
511
503
|
const access = read === undefined ? undefined : model_1.RNode.directParent(read, idMap);
|
|
512
504
|
/* `assign("f", v, envir = x)` writes into `x` as well */
|
|
513
505
|
const call = access === undefined ? undefined : model_1.RNode.directParent(access, idMap);
|
|
514
|
-
if (r_function_call_1.RFunctionCall.isNamed(call
|
|
506
|
+
if (r_function_call_1.RFunctionCall.isNamed(call, 'assign') && call.arguments.indexOf(access) >= 2) {
|
|
515
507
|
return call.info.id;
|
|
516
508
|
}
|
|
517
509
|
if (!r_access_1.RAccess.is(access) || access.accessed.info.id !== readId) {
|
|
@@ -537,7 +529,7 @@ function bindAccessedField(graph, readId, envState, idMap) {
|
|
|
537
529
|
if (!r_access_1.RAccess.is(access) || access.accessed.info.id !== readId) {
|
|
538
530
|
return;
|
|
539
531
|
}
|
|
540
|
-
const fieldName = accessedFieldName(
|
|
532
|
+
const fieldName = accessedFieldName(r_argument_1.RArgument.valueOf(access.access[0]), r_access_1.RAccess.isNamed(access));
|
|
541
533
|
linkFieldReads(graph, access.info.id, fieldName ? envState.current.memory.get(fieldName) : undefined, true);
|
|
542
534
|
}
|
|
543
535
|
/** The factory that creates and returns only `closure`, calling only known built-ins and not reflecting on its frame, with the names its frame binds. */
|
|
@@ -569,7 +561,7 @@ function factoryOf(closure, graph, known, idMap) {
|
|
|
569
561
|
}
|
|
570
562
|
/** The factory calls whose closure `call` may run, `undefined` if it may run one created any other way. */
|
|
571
563
|
function instancesOf(call, closure, factory, graph) {
|
|
572
|
-
if (!
|
|
564
|
+
if (!df_helper_1.Dataflow.hasEdge(graph, call, closure, edge_1.EdgeType.Calls)) {
|
|
573
565
|
return undefined;
|
|
574
566
|
}
|
|
575
567
|
const instances = [];
|
|
@@ -582,8 +574,8 @@ function instancesOf(call, closure, factory, graph) {
|
|
|
582
574
|
const vertex = graph.getVertex(target);
|
|
583
575
|
return vertex_2.DfgVertex.isFunctionCall(vertex) && !vertex_2.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Assignment);
|
|
584
576
|
};
|
|
585
|
-
const created = vertex_2.DfgVertex.isVariableDefinition(graph.getVertex(binding)) ?
|
|
586
|
-
const callees = created.length === 1 ?
|
|
577
|
+
const created = vertex_2.DfgVertex.isVariableDefinition(graph.getVertex(binding)) ? df_helper_1.Dataflow.targetsOf(graph, binding, edge_1.EdgeType.DefinedBy).filter(isCallOfAFunction) : [];
|
|
578
|
+
const callees = created.length === 1 ? df_helper_1.Dataflow.targetsOf(graph, created[0], edge_1.EdgeType.Calls) : [];
|
|
587
579
|
if (callees.length !== 1 || callees[0] !== factory) {
|
|
588
580
|
return undefined;
|
|
589
581
|
}
|
|
@@ -604,17 +596,17 @@ function separateClosureInstances(graph, known) {
|
|
|
604
596
|
if (found === undefined) {
|
|
605
597
|
continue;
|
|
606
598
|
}
|
|
607
|
-
const writes = superAssignments.flatMap(id =>
|
|
599
|
+
const writes = superAssignments.flatMap(id => df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Returns)).filter(target => {
|
|
608
600
|
const name = idMap.get(target);
|
|
609
601
|
return r_symbol_1.RSymbol.is(name) && found.locals.has(identifier_1.Identifier.getName(name.content));
|
|
610
602
|
});
|
|
611
603
|
/* someone outside the closure seeing the write would see it for every instance */
|
|
612
|
-
const seenOutside = (write) =>
|
|
604
|
+
const seenOutside = (write) => df_helper_1.Dataflow.sourcesOf(graph, write, ~edge_1.ControlFlowEdgeTypes).some(from => !vertex.subflow.graph.has(from));
|
|
613
605
|
if (writes.length === 0 || writes.some(seenOutside)) {
|
|
614
606
|
continue;
|
|
615
607
|
}
|
|
616
608
|
const calls = new Map();
|
|
617
|
-
for (const call of writes.flatMap(w =>
|
|
609
|
+
for (const call of writes.flatMap(w => df_helper_1.Dataflow.targetsOf(graph, w, edge_1.EdgeType.SideEffectOnCall))) {
|
|
618
610
|
calls.set(call, instancesOf(call, closure, found.factory, graph));
|
|
619
611
|
}
|
|
620
612
|
if (new Set([...calls.values()].flatMap(i => i ?? [])).size < 2) {
|
|
@@ -13,7 +13,6 @@ const identifier_1 = require("../../../../../environments/identifier");
|
|
|
13
13
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
14
14
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
15
15
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
16
|
-
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
17
16
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
18
17
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
19
18
|
const linker_1 = require("../../../../linker");
|
|
@@ -72,7 +71,7 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
72
71
|
const envState = stackEnvState
|
|
73
72
|
?? (r_symbol_1.RSymbol.is(head.value) ? (0, built_in_envir_utils_1.resolveSymbolToEnvir)(head.value.content, head.value.info.id, data)?.envDef.envState : undefined);
|
|
74
73
|
if (envState) {
|
|
75
|
-
const fieldName = (0, linker_1.accessedFieldName)(
|
|
74
|
+
const fieldName = (0, linker_1.accessedFieldName)(r_argument_1.RArgument.valueOf(args[1]), config.treatIndicesAsString);
|
|
76
75
|
const fieldDefs = fieldName
|
|
77
76
|
? ((0, built_in_stack_env_1.stackEnvInheritsFields)(head.value) ? resolve_helper_1.Resolve.byNameAndType(fieldName, envState, identifier_1.ReferenceType.Unknown) : envState.current.memory.get(fieldName))
|
|
78
77
|
: undefined;
|
|
@@ -99,12 +98,7 @@ function processAccess(name, args, rootId, data, config) {
|
|
|
99
98
|
entryPoint: rootId,
|
|
100
99
|
/** it is, to be precise, the accessed element we want to map to maybe */
|
|
101
100
|
in: r_argument_1.RArgument.isEmpty(head) ? info.in : info.in.map(ref => {
|
|
102
|
-
|
|
103
|
-
return (0, reference_to_maybe_1.makeReferenceMaybe)(ref, info.graph, info.environment, false);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return ref;
|
|
107
|
-
}
|
|
101
|
+
return ref.nodeId === head.value?.info.id ? (0, reference_to_maybe_1.makeReferenceMaybe)(ref, info.graph, info.environment, false) : ref;
|
|
108
102
|
})
|
|
109
103
|
};
|
|
110
104
|
}
|
|
@@ -69,8 +69,6 @@ export declare function markForcing(environment: REnvironmentInformation): void;
|
|
|
69
69
|
export declare function mayForce(environment: REnvironmentInformation): boolean;
|
|
70
70
|
/** The state a symbol reads, plus the maybe-writes of forcing a promise bound to it. */
|
|
71
71
|
export declare function ambientAccessOfSymbol<OtherInfo>(res: DataflowInformation, symbol: RSymbol<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
72
|
-
/** {@link optionsVariableReads} as references. */
|
|
73
|
-
export declare function readsOfOptionsVariable<OtherInfo>(symbol: RSymbol<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): IdentifierReference[];
|
|
74
72
|
/** Options that affect how values are printed and formatted (read by `print`, `format`, and `cat`). */
|
|
75
73
|
export declare const PrintingOptions: readonly string[];
|
|
76
74
|
/** How a call accesses the {@link AmbientStateName|ambient state}. */
|
|
@@ -152,6 +150,11 @@ export declare function writesOfHiddenBuiltIn(target: IdentifierDefinition, call
|
|
|
152
150
|
})[];
|
|
153
151
|
/** The states the call to the built-in `target` through a parameter reads, see {@link writesOfHiddenBuiltIn}. */
|
|
154
152
|
export declare function readsOfHiddenBuiltIn(target: IdentifierDefinition): string[];
|
|
153
|
+
/**
|
|
154
|
+
* Whether the call to `fn` only queries the state it may set, as `par("mar")`, `options("digits")` and `palette()`
|
|
155
|
+
* do, which hand that state back visibly where setting it returns the previous one invisibly.
|
|
156
|
+
*/
|
|
157
|
+
export declare function callOnlyQueries<OtherInfo>(fn: Identifier, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], environment: REnvironmentInformation): boolean;
|
|
155
158
|
/** Links state reads in a loop body to the body's own writes of a later iteration and returns them, as the first iteration reads what is there before the loop. */
|
|
156
159
|
export declare function linkAmbientStateWithinLoop(graph: DataflowGraph, reads: readonly IdentifierReference[], body: DataflowInformation): IdentifierReference[];
|
|
157
160
|
/** A scoped state change (`withr`, `rlang`): `with_*` undoes it after its code, `local_*` when the calling function returns. */
|
|
@@ -10,11 +10,11 @@ exports.ambientWritesBetween = ambientWritesBetween;
|
|
|
10
10
|
exports.markForcing = markForcing;
|
|
11
11
|
exports.mayForce = mayForce;
|
|
12
12
|
exports.ambientAccessOfSymbol = ambientAccessOfSymbol;
|
|
13
|
-
exports.readsOfOptionsVariable = readsOfOptionsVariable;
|
|
14
13
|
exports.applyAmbientStateAccess = applyAmbientStateAccess;
|
|
15
14
|
exports.applyAmbientStateOfCallee = applyAmbientStateOfCallee;
|
|
16
15
|
exports.writesOfHiddenBuiltIn = writesOfHiddenBuiltIn;
|
|
17
16
|
exports.readsOfHiddenBuiltIn = readsOfHiddenBuiltIn;
|
|
17
|
+
exports.callOnlyQueries = callOnlyQueries;
|
|
18
18
|
exports.linkAmbientStateWithinLoop = linkAmbientStateWithinLoop;
|
|
19
19
|
exports.processAmbientScope = processAmbientScope;
|
|
20
20
|
exports.evaluatesCapturedCode = evaluatesCapturedCode;
|
|
@@ -33,7 +33,6 @@ const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/
|
|
|
33
33
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
34
34
|
const environment_1 = require("../../../../../environments/environment");
|
|
35
35
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
36
|
-
const define_1 = require("../../../../../environments/define");
|
|
37
36
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
38
37
|
const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
39
38
|
const r_unary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
@@ -49,6 +48,8 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
49
48
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
50
49
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
51
50
|
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
51
|
+
const ListConstructors = new Set(['list', 'c']);
|
|
52
|
+
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
52
53
|
/**
|
|
53
54
|
* Graphics parameters and options, tracked as global pseudo variables (`#...`) so readers link to the calls that set them.
|
|
54
55
|
* Accumulating states only grow: `par(mar = ...)` keeps an earlier `par(mfrow = ...)`.
|
|
@@ -130,7 +131,7 @@ function withAccess(res, rootId, data, reads, writes = []) {
|
|
|
130
131
|
}
|
|
131
132
|
const cds = data.cds ? [...data.cds] : undefined;
|
|
132
133
|
const maybeWritten = writes.flatMap(w => typeof w === 'object' && w.mode === 'maybe' ? [w.name] : []);
|
|
133
|
-
const readRefs =
|
|
134
|
+
const readRefs = (0, arrays_1.uniqueArrayMerge)(reads, maybeWritten).map(name => ({ nodeId: rootId, name, type: identifier_1.ReferenceType.Variable, cds }));
|
|
134
135
|
/* the writes stay out of `out`: an assignment reads whatever else its source writes (`x <- y <- 3`) */
|
|
135
136
|
return {
|
|
136
137
|
...res,
|
|
@@ -154,7 +155,7 @@ function defineAmbient(environment, rootId, cds, writes) {
|
|
|
154
155
|
cds: isMaybe ? cds ?? [] : cds
|
|
155
156
|
};
|
|
156
157
|
/* the state is global, wherever the call happens, unless the call scopes it to the current frame */
|
|
157
|
-
environment =
|
|
158
|
+
environment = environment_1.REnvironment.define(def, mode !== 'local', environment, keep);
|
|
158
159
|
}
|
|
159
160
|
return environment;
|
|
160
161
|
}
|
|
@@ -224,7 +225,7 @@ function setAmbient(environment, name, definitions, keep = false) {
|
|
|
224
225
|
return { ...environment, current: environment.current.removeAll([{ name }]) };
|
|
225
226
|
}
|
|
226
227
|
for (const [i, def] of definitions.entries()) {
|
|
227
|
-
environment =
|
|
228
|
+
environment = environment_1.REnvironment.define({ ...def, name }, true, environment, keep || i > 0);
|
|
228
229
|
}
|
|
229
230
|
return environment;
|
|
230
231
|
}
|
|
@@ -258,10 +259,6 @@ function optionsVariableReads(symbol, data) {
|
|
|
258
259
|
}
|
|
259
260
|
return optionReads(undefined);
|
|
260
261
|
}
|
|
261
|
-
/** {@link optionsVariableReads} as references. */
|
|
262
|
-
function readsOfOptionsVariable(symbol, data) {
|
|
263
|
-
return optionsVariableReads(symbol, data).map(name => ({ nodeId: symbol.info.id, name, type: identifier_1.ReferenceType.Variable, cds: data.cds }));
|
|
264
|
-
}
|
|
265
262
|
/** Options affecting calls we cannot name (`scipen` changes every number-to-string conversion), so setting one stays an unknown side effect. */
|
|
266
263
|
const GlobalEffectOptions = new Set([
|
|
267
264
|
'scipen', 'OutDec', 'warn', 'error', 'expressions', 'encoding', 'stringsAsFactors', 'timeout', 'HTTPUserAgent',
|
|
@@ -288,7 +285,7 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
288
285
|
case "set-graphics" /* AmbientStateAccessType.SetGraphics */:
|
|
289
286
|
/* the call returns the previous state */
|
|
290
287
|
reads.push(exports.AmbientStateName.graphics);
|
|
291
|
-
if (
|
|
288
|
+
if (onlyQueries(access, args)) {
|
|
292
289
|
if (access.queryLinksTo) {
|
|
293
290
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId, access.queryLinksTo);
|
|
294
291
|
}
|
|
@@ -299,7 +296,7 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
299
296
|
break;
|
|
300
297
|
case "set-palette" /* AmbientStateAccessType.SetPalette */:
|
|
301
298
|
reads.push(exports.AmbientStateName.palette);
|
|
302
|
-
if (args
|
|
299
|
+
if (!onlyQueries(access, args)) {
|
|
303
300
|
writes.push(exports.AmbientStateName.palette);
|
|
304
301
|
}
|
|
305
302
|
break;
|
|
@@ -310,7 +307,7 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
310
307
|
}
|
|
311
308
|
case "get-option" /* AmbientStateAccessType.GetOption */: {
|
|
312
309
|
const first = args.find(a => a !== r_function_call_1.EmptyArgument && (a.name === undefined || identifier_1.Identifier.getName(a.name.content) === 'x'));
|
|
313
|
-
reads.push(...optionReads(
|
|
310
|
+
reads.push(...optionReads(stringValuesOf(r_argument_1.RArgument.valueOf(first), data)));
|
|
314
311
|
break;
|
|
315
312
|
}
|
|
316
313
|
case "set-options" /* AmbientStateAccessType.SetOptions */:
|
|
@@ -374,17 +371,17 @@ function registerFinalizer(res, args, rootId, data) {
|
|
|
374
371
|
return vertex_1.DfgVertex.isFunctionDefinition(definition) ? ambientWritesBetween(definition.subflow.environment, data.environment) : [];
|
|
375
372
|
});
|
|
376
373
|
const definition = { nodeId: rootId, name: exports.AmbientStateName.finalizers, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: data.cds ? [...data.cds] : [], value, writes, holder: r_symbol_1.RSymbol.is(holder) ? identifier_1.Identifier.getName(holder.content) : undefined };
|
|
377
|
-
return { ...res, environment:
|
|
374
|
+
return { ...res, environment: environment_1.REnvironment.define(definition, true, res.environment, true) };
|
|
378
375
|
}
|
|
379
376
|
/** `textConnection(object, open, local)` opened for writing binds `object` globally, or locally with `local = TRUE`. */
|
|
380
377
|
function openTextConnection(res, args, rootId, data) {
|
|
381
378
|
const bound = match_args_1.MatchArgs.toNames(args, ['object', 'open', 'local', 'name', 'encoding']);
|
|
382
379
|
const open = bound.get('open');
|
|
383
|
-
const modes = open === undefined ? ['r'] :
|
|
380
|
+
const modes = open === undefined ? ['r'] : stringValuesOf(open, data);
|
|
384
381
|
if (modes?.every(m => m.startsWith('r'))) {
|
|
385
382
|
return res;
|
|
386
383
|
}
|
|
387
|
-
const names =
|
|
384
|
+
const names = stringValuesOf(bound.get('object'), data);
|
|
388
385
|
if (names === undefined) {
|
|
389
386
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId);
|
|
390
387
|
return res;
|
|
@@ -395,7 +392,7 @@ function openTextConnection(res, args, rootId, data) {
|
|
|
395
392
|
let environment = res.environment;
|
|
396
393
|
for (const name of names) {
|
|
397
394
|
for (const [i, inFrame] of (scopes ?? [true, false]).entries()) {
|
|
398
|
-
environment =
|
|
395
|
+
environment = environment_1.REnvironment.define({ nodeId: rootId, name, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds }, !inFrame, environment, i > 0 || names.length > 1);
|
|
399
396
|
}
|
|
400
397
|
}
|
|
401
398
|
markForcing(environment);
|
|
@@ -598,12 +595,32 @@ function setOptions(res, args, rootId, data) {
|
|
|
598
595
|
}
|
|
599
596
|
return withAccess(res, rootId, data, reads, writes);
|
|
600
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Whether the call to `fn` only queries the state it may set, as `par("mar")`, `options("digits")` and `palette()`
|
|
600
|
+
* do, which hand that state back visibly where setting it returns the previous one invisibly.
|
|
601
|
+
*/
|
|
602
|
+
function callOnlyQueries(fn, args, environment) {
|
|
603
|
+
const targets = resolve_helper_1.Resolve.byNameAndType(fn, environment, identifier_1.ReferenceType.Function) ?? [];
|
|
604
|
+
return targets.length > 0 && targets.every(t => hiddenAccess(t).some(a => onlyQueries(a, args)));
|
|
605
|
+
}
|
|
606
|
+
function onlyQueries(access, args) {
|
|
607
|
+
switch (access.type) {
|
|
608
|
+
case "set-graphics" /* AmbientStateAccessType.SetGraphics */:
|
|
609
|
+
return args.length === 0 || (access.queryOnUnnamedStrings === true && isQuery(args));
|
|
610
|
+
case "set-options" /* AmbientStateAccessType.SetOptions */:
|
|
611
|
+
return isQuery(args);
|
|
612
|
+
case "set-palette" /* AmbientStateAccessType.SetPalette */:
|
|
613
|
+
return args.length === 0;
|
|
614
|
+
default:
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
601
618
|
/** `par()`, `par("mar", "usr")`, and `par(no.readonly = TRUE)` only query the graphics state */
|
|
602
619
|
function isQuery(args) {
|
|
603
620
|
return args.every(a => a === r_function_call_1.EmptyArgument
|
|
604
621
|
|| (a.name === undefined ? r_string_1.RString.is(a.value) : identifier_1.Identifier.getName(a.name.content) === 'no.readonly'));
|
|
605
622
|
}
|
|
606
|
-
function
|
|
623
|
+
function stringValuesOf(value, data) {
|
|
607
624
|
if (value === undefined) {
|
|
608
625
|
return undefined;
|
|
609
626
|
}
|
|
@@ -684,7 +701,7 @@ function scopedWrites(scope, args, bound, local) {
|
|
|
684
701
|
/* what falls to `...` names options, it is no formal of its own */
|
|
685
702
|
const formals = new Set([...bound.entries()].filter(([param]) => param !== '...').map(([, arg]) => arg.info.id));
|
|
686
703
|
const fromList = (value) => {
|
|
687
|
-
if (r_function_call_1.RFunctionCall.isNamed(value
|
|
704
|
+
if (r_function_call_1.RFunctionCall.isNamed(value, ListConstructors)) {
|
|
688
705
|
for (const entry of value.arguments) {
|
|
689
706
|
if (entry === r_function_call_1.EmptyArgument) {
|
|
690
707
|
continue;
|
|
@@ -804,7 +821,7 @@ function warningSites(root, graph, data, bodies) {
|
|
|
804
821
|
}
|
|
805
822
|
else if (r_function_call_1.RFunctionCall.is(node)) {
|
|
806
823
|
const targets = node.named ? resolve_helper_1.Resolve.byNameAndType(node.functionName.content, data.environment, identifier_1.ReferenceType.Function) ?? [] : [];
|
|
807
|
-
if (
|
|
824
|
+
if (r_function_call_1.RFunctionCall.isNamed(node, 'suppressWarnings') && targets.every(t => node_id_1.NodeId.isBuiltIn(t.nodeId))) {
|
|
808
825
|
return true;
|
|
809
826
|
}
|
|
810
827
|
const handlers = muffledHandlers(node, graph, data);
|
|
@@ -833,7 +850,7 @@ function warningSites(root, graph, data, bodies) {
|
|
|
833
850
|
/** The handlers of a `withCallingHandlers` whose first handler muffles every `warning` of its `expr`, `undefined` otherwise. */
|
|
834
851
|
function muffledHandlers(call, graph, data) {
|
|
835
852
|
const vertex = graph.getVertex(call.info.id);
|
|
836
|
-
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !
|
|
853
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !callsBuiltIn(call, 'withCallingHandlers', built_in_proc_name_1.BuiltInProcName.Try, graph, data)) {
|
|
837
854
|
return undefined;
|
|
838
855
|
}
|
|
839
856
|
const handlers = match_args_1.MatchArgs.toSpec(vertex.args, { expr: 'expr', '...': '...' }).get('...') ?? [];
|
|
@@ -842,12 +859,12 @@ function muffledHandlers(call, graph, data) {
|
|
|
842
859
|
const fn = r_argument_1.RArgument.is(handler) ? handler.value : undefined;
|
|
843
860
|
const body = r_function_definition_1.RFunctionDefinition.is(fn) ? fn.body : undefined;
|
|
844
861
|
const start = r_expression_list_1.RExpressionList.is(body) ? body.children[0] : body;
|
|
845
|
-
const restart = r_function_call_1.RFunctionCall.is(start) &&
|
|
862
|
+
const restart = r_function_call_1.RFunctionCall.is(start) && callsBuiltIn(start, 'invokeRestart', built_in_proc_name_1.BuiltInProcName.Default, graph, data) && start.arguments.length === 1 ? start.arguments[0] : undefined;
|
|
846
863
|
const muffles = node_value_1.NodeValue.stringsOf(r_argument_1.RArgument.valueOf(restart)?.info.id, data)?.join() === 'muffleWarning';
|
|
847
864
|
return muffles ? handlers.map(h => data.completeAst.idMap.get(h)).filter(assert_1.isNotUndefined) : undefined;
|
|
848
865
|
}
|
|
849
866
|
/** whether `call` surely calls the built-in `name`, its `origin` telling that nothing in between shadows it */
|
|
850
|
-
function
|
|
867
|
+
function callsBuiltIn(call, name, origin, graph, data) {
|
|
851
868
|
if (!vertex_1.DfgVertex.hasOrigin(graph.getVertex(call.info.id), origin)) {
|
|
852
869
|
return false;
|
|
853
870
|
}
|
|
@@ -10,7 +10,6 @@ const nse_1 = require("../nse");
|
|
|
10
10
|
const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
|
|
11
11
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
12
12
|
const log_1 = require("../../../../../../util/log");
|
|
13
|
-
const unpack_argument_1 = require("../argument/unpack-argument");
|
|
14
13
|
const make_argument_1 = require("../argument/make-argument");
|
|
15
14
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
16
15
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
@@ -20,11 +19,8 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
20
19
|
const logger_1 = require("../../../../../logger");
|
|
21
20
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
22
21
|
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
23
|
-
const overwrite_1 = require("../../../../../environments/overwrite");
|
|
24
22
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
25
|
-
const retriever_1 = require("../../../../../../r-bridge/retriever");
|
|
26
23
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
27
|
-
const define_1 = require("../../../../../environments/define");
|
|
28
24
|
const edge_1 = require("../../../../../graph/edge");
|
|
29
25
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
30
26
|
const named_call_handling_1 = require("../named-call-handling");
|
|
@@ -40,6 +36,8 @@ const built_in_list_1 = require("./built-in-list");
|
|
|
40
36
|
const built_in_class_generator_1 = require("./built-in-class-generator");
|
|
41
37
|
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
42
38
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
39
|
+
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
40
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
43
41
|
function toReplacementSymbol(target, prefix, superAssignment) {
|
|
44
42
|
return {
|
|
45
43
|
type: type_1.RType.Symbol,
|
|
@@ -63,7 +61,7 @@ function yieldsEnvironment(node, graph, data) {
|
|
|
63
61
|
}
|
|
64
62
|
const vertex = graph.getVertex(node.info.id);
|
|
65
63
|
return EnvironmentProducers.some(origin => vertex_1.DfgVertex.hasOrigin(vertex, origin))
|
|
66
|
-
|| (
|
|
64
|
+
|| (r_function_call_1.RFunctionCall.isNamed(node, 'environment')
|
|
67
65
|
&& resolve_helper_1.Resolve.isBuiltIn(node.functionName.content, data.environment, identifier_1.ReferenceType.Function));
|
|
68
66
|
}
|
|
69
67
|
function tryReplacement(rootId, functionName, data, superAssignment, args, beforeDefine) {
|
|
@@ -116,18 +114,18 @@ function isMaskedNamePair(name, rootId, data) {
|
|
|
116
114
|
}
|
|
117
115
|
for (const node of model_1.RNode.iterateParents(data.completeAst.idMap.get(rootId), data.completeAst.idMap)) {
|
|
118
116
|
if (!r_argument_1.RArgument.is(node)) {
|
|
119
|
-
return r_function_call_1.RFunctionCall.isNamed(node
|
|
117
|
+
return r_function_call_1.RFunctionCall.isNamed(node, data_masking_functions_1.DataMaskingFunctionNames);
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
return false;
|
|
123
121
|
}
|
|
124
122
|
/** Analyzes `a := b` as the named argument it is. */
|
|
125
123
|
function processMaskedNamePair(name, args, rootId, data) {
|
|
126
|
-
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' });
|
|
124
|
+
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default', keepArgumentGraphs: true });
|
|
127
125
|
const target = args[0];
|
|
128
126
|
(0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.First, {
|
|
129
127
|
kind: known_call_handling_1.NseKind.DataMasked,
|
|
130
|
-
evaluated: function_semantics_1.FunctionSemantics.call.nse.unquoted(r_argument_1.RArgument.
|
|
128
|
+
evaluated: function_semantics_1.FunctionSemantics.call.nse.unquoted(r_argument_1.RArgument.valueOf(target), nse_1.Unquote.Rlang)
|
|
131
129
|
});
|
|
132
130
|
return information;
|
|
133
131
|
}
|
|
@@ -139,7 +137,7 @@ function processAssignment(name,
|
|
|
139
137
|
/* we expect them to be ordered in the sense that we have (source, target): `<source> <- <target>` */
|
|
140
138
|
args, rootId, data, config) {
|
|
141
139
|
const information = processAssignmentTarget(name, args, rootId, data, config);
|
|
142
|
-
const source = config.callsSource ?
|
|
140
|
+
const source = config.callsSource ? r_argument_1.RArgument.valueOf(args[config.swapSourceAndTarget ? 0 : 1]) : undefined;
|
|
143
141
|
const vertex = source ? information.graph.getVertex(source.info.id) : undefined;
|
|
144
142
|
/* the function runs when the name is read, so what it reads is resolved there and not where it is bound */
|
|
145
143
|
if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
@@ -165,8 +163,8 @@ function processAssignmentTarget(name, args, rootId, data, config) {
|
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
165
|
const effectiveArgs = getEffectiveOrder(config, args);
|
|
168
|
-
const target =
|
|
169
|
-
const source =
|
|
166
|
+
const target = r_argument_1.RArgument.valueOf(effectiveArgs[0]);
|
|
167
|
+
const source = r_argument_1.RArgument.valueOf(effectiveArgs[1]);
|
|
170
168
|
if (target === undefined || source === undefined) {
|
|
171
169
|
logger_1.dataflowLogger.warn(`Assignment ${identifier_1.Identifier.toString(name.content)} has an undefined target or source, skipping`);
|
|
172
170
|
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
@@ -247,7 +245,7 @@ function processAssignmentTarget(name, args, rootId, data, config) {
|
|
|
247
245
|
const symbol = {
|
|
248
246
|
type: type_1.RType.Symbol,
|
|
249
247
|
info: target.info,
|
|
250
|
-
content:
|
|
248
|
+
content: r_string_1.RString.unquote(target.lexeme) + (config.targetSuffix ?? ''),
|
|
251
249
|
lexeme: target.lexeme,
|
|
252
250
|
location: target.location,
|
|
253
251
|
};
|
|
@@ -302,7 +300,7 @@ function valueEntryPointOf(sourceInfo) {
|
|
|
302
300
|
const seen = new Set();
|
|
303
301
|
let id = sourceInfo.entryPoint;
|
|
304
302
|
while (true) {
|
|
305
|
-
const returns =
|
|
303
|
+
const returns = df_helper_1.Dataflow.targetsOf(sourceInfo.graph, id, edge_1.EdgeType.Returns);
|
|
306
304
|
if (returns.length === 0) {
|
|
307
305
|
return id;
|
|
308
306
|
}
|
|
@@ -310,7 +308,7 @@ function valueEntryPointOf(sourceInfo) {
|
|
|
310
308
|
return undefined;
|
|
311
309
|
}
|
|
312
310
|
seen.add(id);
|
|
313
|
-
id = returns[0]
|
|
311
|
+
id = returns[0];
|
|
314
312
|
}
|
|
315
313
|
}
|
|
316
314
|
/**
|
|
@@ -333,7 +331,7 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
|
|
|
333
331
|
if (!envirResolution) {
|
|
334
332
|
return undefined;
|
|
335
333
|
}
|
|
336
|
-
const fieldNode =
|
|
334
|
+
const fieldNode = r_argument_1.RArgument.valueOf(target.access[0]);
|
|
337
335
|
if (!fieldNode) {
|
|
338
336
|
return undefined;
|
|
339
337
|
}
|
|
@@ -346,7 +344,7 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
|
|
|
346
344
|
definedAt: normalResult.entryPoint,
|
|
347
345
|
cds: data.cds ?? (config.makeMaybe ? [] : undefined)
|
|
348
346
|
};
|
|
349
|
-
const newEnvState =
|
|
347
|
+
const newEnvState = environment_1.REnvironment.define(fieldDef, false, envirResolution.envDef.envState);
|
|
350
348
|
const updatedEnvDef = {
|
|
351
349
|
...envirResolution.envDef,
|
|
352
350
|
nodeId: target.accessed.info.id,
|
|
@@ -358,7 +356,7 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
|
|
|
358
356
|
level: normalResult.environment.level
|
|
359
357
|
};
|
|
360
358
|
normalResult.graph.addEdge(normalResult.entryPoint, target.accessed.info.id, edge_1.EdgeType.Reads);
|
|
361
|
-
const environment =
|
|
359
|
+
const environment = environment_1.REnvironment.define(updatedEnvDef, false, strippedEnv);
|
|
362
360
|
if (updatedEnvDef.envId === undefined) {
|
|
363
361
|
return { ...normalResult, environment };
|
|
364
362
|
}
|
|
@@ -404,7 +402,7 @@ function processDefineArgument(name, args, rootId, data, config) {
|
|
|
404
402
|
const formals = config.sig ?? [];
|
|
405
403
|
const bound = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => r_argument_1.RArgument.isEmpty(a) ? undefined : a.name?.content), formals.map(([f]) => f));
|
|
406
404
|
const defineByCall = (node) => {
|
|
407
|
-
info.environment =
|
|
405
|
+
info.environment = environment_1.REnvironment.define(node, config.superAssignment, info.environment);
|
|
408
406
|
/* defined by the call; the read edge is left intact */
|
|
409
407
|
if (node.nodeId !== rootId) {
|
|
410
408
|
info.graph.setDefinitionOfVertex(node, [rootId]);
|
|
@@ -435,7 +433,7 @@ function processDefineArgument(name, args, rootId, data, config) {
|
|
|
435
433
|
}
|
|
436
434
|
/** Define `nodeToDefine` in the environment and wire the `DefinedBy` edges from it to its sources and the assignment root (dropping the child-added read edges). */
|
|
437
435
|
function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignment, data, assignmentConfig) {
|
|
438
|
-
information.environment =
|
|
436
|
+
information.environment = environment_1.REnvironment.define(nodeToDefine, assignmentConfig?.superAssignment, information.environment);
|
|
439
437
|
information.environment = (0, built_in_ambient_state_1.ambientWritesOfAssignment)(information.environment, nodeToDefine.name, rootIdOfAssignment, data.cds ? [...data.cds] : undefined, assignmentConfig?.superAssignment === true || data.environment.level === 0);
|
|
440
438
|
information.graph.setDefinitionOfVertex(nodeToDefine, sourceIds);
|
|
441
439
|
const nid = nodeToDefine.nodeId;
|
|
@@ -523,7 +521,7 @@ function processAssignmentToSymbol(config) {
|
|
|
523
521
|
...readFromSourceWritten
|
|
524
522
|
];
|
|
525
523
|
/* a quoted source (`delayedAssign`) writes nothing yet, its writes happen where it is forced (see `Deferred`) */
|
|
526
|
-
information.environment = quoteSource ? data.environment :
|
|
524
|
+
information.environment = quoteSource ? data.environment : environment_1.REnvironment.overwrite(sourceArg.environment, targetArg.environment);
|
|
527
525
|
if (config.beforeDefine) {
|
|
528
526
|
information.environment = config.beforeDefine(information);
|
|
529
527
|
}
|
|
@@ -531,7 +529,7 @@ function processAssignmentToSymbol(config) {
|
|
|
531
529
|
markAsAssignment(information, write, useSourceIds, rootId, data, config);
|
|
532
530
|
}
|
|
533
531
|
if (copied?.name !== undefined && copied.envId === undefined && information.environment.current.lookup(identifier_1.Identifier.getName(copied.name))?.includes(copied)) {
|
|
534
|
-
information.environment =
|
|
532
|
+
information.environment = environment_1.REnvironment.define({ ...copied, name: copied.name, envId: copied.nodeId }, false, information.environment);
|
|
535
533
|
}
|
|
536
534
|
information.graph.addEdge(rootId, targetArg.entryPoint, edge_1.EdgeType.Returns);
|
|
537
535
|
information.graph.addEdge(rootId, source.info.id, quoteSource ? edge_1.EdgeType.NonStandardEvaluation : edge_1.EdgeType.Reads);
|