@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
|
@@ -8,7 +8,7 @@ const edge_1 = require("../../../../../graph/edge");
|
|
|
8
8
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
9
9
|
const environment_1 = require("../../../../../environments/environment");
|
|
10
10
|
const built_in_library_1 = require("./built-in-library");
|
|
11
|
-
const
|
|
11
|
+
const frame_memory_1 = require("../../../../../environments/frame-memory");
|
|
12
12
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
13
13
|
const program_order_1 = require("../../../../program-order");
|
|
14
14
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
@@ -16,7 +16,7 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
|
|
|
16
16
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
17
|
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
18
18
|
const defaultmap_1 = require("../../../../../../util/collections/defaultmap");
|
|
19
|
-
const
|
|
19
|
+
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
20
20
|
/**
|
|
21
21
|
* Computes, for every function-definition vertex `F`, `summary(F) = own(F)` unioned with `summary(G)` over every transitive callee `G`.
|
|
22
22
|
* @param graph - the fully linked dataflow graph
|
|
@@ -27,14 +27,12 @@ const frame_reflection_1 = require("../../../../../fn/frame-reflection");
|
|
|
27
27
|
function computeCallGraphSummaries(graph, own) {
|
|
28
28
|
const summary = new Map();
|
|
29
29
|
const callees = new Map();
|
|
30
|
-
for (const [id, vertex] of graph.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
callees.set(id, (0, frame_reflection_1.callsIn)(vertex, graph).flatMap(([node]) => (0, frame_reflection_1.calledDefinitions)(graph, node)).toArray());
|
|
34
|
-
}
|
|
30
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
31
|
+
summary.set(id, new Set(own(id, vertex)));
|
|
32
|
+
callees.set(id, df_helper_1.Dataflow.callsIn(vertex, graph).flatMap(([node]) => df_helper_1.Dataflow.calleeIdsOf(graph, node)).toArray());
|
|
35
33
|
}
|
|
36
34
|
/* pull each callee's summary, its callers are revisited whenever a function grew */
|
|
37
|
-
|
|
35
|
+
df_helper_1.Dataflow.propagateToFixpoint(summary.keys(), callees, id => {
|
|
38
36
|
const effects = summary.get(id);
|
|
39
37
|
const before = effects.size;
|
|
40
38
|
for (const callee of callees.get(id) ?? []) {
|
|
@@ -65,7 +63,7 @@ function linkMaterializedExportsToLoaders(graph, environment) {
|
|
|
65
63
|
}
|
|
66
64
|
/* export node id -> its loading `library()`/`use()` call, from the final environment */
|
|
67
65
|
const loaders = new Map();
|
|
68
|
-
for (
|
|
66
|
+
for (const e of environment_1.REnvironment.frames(environment.current)) {
|
|
69
67
|
if (e.t !== environment_1.EnvType.Namespace) {
|
|
70
68
|
continue;
|
|
71
69
|
}
|
|
@@ -84,9 +82,9 @@ function linkMaterializedExportsToLoaders(graph, environment) {
|
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
/** The packages (see {@link EnvType}) attached directly within a function body, i.e. its own `library()` calls. */
|
|
87
|
-
function
|
|
85
|
+
function ownLibraryCalls(_id, fdef) {
|
|
88
86
|
const packages = [];
|
|
89
|
-
for (
|
|
87
|
+
for (const e of environment_1.REnvironment.frames(fdef.subflow.environment.current)) {
|
|
90
88
|
if (e.t === environment_1.EnvType.Namespace && e.n !== undefined) {
|
|
91
89
|
/* an export binding carries the loading `library()` call in `definedAt` */
|
|
92
90
|
let definedAt = node_id_1.NodeId.toBuiltIn(e.n);
|
|
@@ -103,10 +101,8 @@ function attachedPackages(_id, fdef) {
|
|
|
103
101
|
return packages;
|
|
104
102
|
}
|
|
105
103
|
/** The scopes outside a function's own frame, i.e. those a definition of its body can have escaped into. */
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
yield e;
|
|
109
|
-
}
|
|
104
|
+
function escapeTargetFrames(fdef) {
|
|
105
|
+
return environment_1.REnvironment.frames(fdef.subflow.environment.current.parent);
|
|
110
106
|
}
|
|
111
107
|
/**
|
|
112
108
|
* The non-built-in definitions a function body lets escape to an outer scope (e.g. a `<<-` super-assignment),
|
|
@@ -119,7 +115,12 @@ function escapedDefinitions(hidden) {
|
|
|
119
115
|
const defs = hidden.keys().filter(call => fdef.subflow.graph.has(call)).toArray();
|
|
120
116
|
for (const e of escapeTargetFrames(fdef)) {
|
|
121
117
|
let escaped = perFrame.get(e.memory);
|
|
122
|
-
if (escaped === undefined) {
|
|
118
|
+
if (escaped === undefined && e.memory instanceof frame_memory_1.Frame && e.memory.lazy() !== undefined) {
|
|
119
|
+
/* an attached package binds nothing but its exports, which are built-ins */
|
|
120
|
+
escaped = [];
|
|
121
|
+
perFrame.set(e.memory, escaped);
|
|
122
|
+
}
|
|
123
|
+
else if (escaped === undefined) {
|
|
123
124
|
/* a package frame holds thousands of entries and keeps none of them, so this walks them in place
|
|
124
125
|
* rather than through a spread/flatMap/filter/map chain that allocates an array per step */
|
|
125
126
|
const collected = [];
|
|
@@ -134,7 +135,10 @@ function escapedDefinitions(hidden) {
|
|
|
134
135
|
perFrame.set(e.memory, escaped);
|
|
135
136
|
}
|
|
136
137
|
for (const d of escaped) {
|
|
137
|
-
|
|
138
|
+
/* a package the caller attached is visible in the body, but only one the body attaches escapes it */
|
|
139
|
+
if (e.t === undefined || fdef.subflow.graph.has(d)) {
|
|
140
|
+
defs.push(d);
|
|
141
|
+
}
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
return defs;
|
|
@@ -142,11 +146,8 @@ function escapedDefinitions(hidden) {
|
|
|
142
146
|
}
|
|
143
147
|
/** Emits {@link EdgeType.SideEffectOnCall} edges for definitions that escape a function transitively. */
|
|
144
148
|
function propagateTransitiveDefinitions(graph, environment, ctx, summary) {
|
|
145
|
-
for (const [id
|
|
146
|
-
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, id)) {
|
|
149
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
150
|
+
for (const target of df_helper_1.Dataflow.calleeIdsOf(graph, id)) {
|
|
150
151
|
for (const def of summary.get(target) ?? []) {
|
|
151
152
|
/* an escaping package export is only in the environment; materialize its vertex on demand */
|
|
152
153
|
if (node_id_1.NodeId.isBuiltIn(def)) {
|
|
@@ -163,13 +164,13 @@ function propagateTransitiveDefinitions(graph, environment, ctx, summary) {
|
|
|
163
164
|
* @returns the enriched environment and whether it grew (so the caller can re-link and re-run to a fixpoint).
|
|
164
165
|
*/
|
|
165
166
|
function propagateTransitivePackages(graph, environment, ctx) {
|
|
166
|
-
const summary = computeCallGraphSummaries(graph,
|
|
167
|
+
const summary = computeCallGraphSummaries(graph, ownLibraryCalls);
|
|
167
168
|
const reachable = new Map(); // package -> its loading `library()` call
|
|
168
|
-
for (const [id
|
|
169
|
-
if (!
|
|
169
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
170
|
+
if (!graph.isRoot(id)) {
|
|
170
171
|
continue;
|
|
171
172
|
}
|
|
172
|
-
for (const target of
|
|
173
|
+
for (const target of df_helper_1.Dataflow.calleeIdsOf(graph, id)) {
|
|
173
174
|
for (const { pack, definedAt } of summary.get(target) ?? []) {
|
|
174
175
|
if (!reachable.has(pack)) {
|
|
175
176
|
reachable.set(pack, definedAt);
|
|
@@ -203,7 +204,7 @@ function hiddenBuiltInWrites(graph, environment) {
|
|
|
203
204
|
continue;
|
|
204
205
|
}
|
|
205
206
|
const own = vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function) ? undefined : vertex.name;
|
|
206
|
-
for (const target of
|
|
207
|
+
for (const target of df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Calls)) {
|
|
207
208
|
if (node_id_1.NodeId.isBuiltIn(target) && (own === undefined || node_id_1.NodeId.toBuiltIn(identifier_1.Identifier.getName(own)) !== target)) {
|
|
208
209
|
const targets = resolve_helper_1.Resolve.byNameAndType(node_id_1.NodeId.fromBuiltIn(target), { current: builtIns, level: 0 }, identifier_1.ReferenceType.Function) ?? [];
|
|
209
210
|
const defs = targets.flatMap(d => (0, built_in_ambient_state_1.writesOfHiddenBuiltIn)(d, id));
|
|
@@ -230,7 +231,7 @@ function linkHiddenReads(graph, reads) {
|
|
|
230
231
|
if (vertex.environment === undefined) {
|
|
231
232
|
continue;
|
|
232
233
|
}
|
|
233
|
-
for (const target of
|
|
234
|
+
for (const target of df_helper_1.Dataflow.calleeIdsOf(graph, id)) {
|
|
234
235
|
for (const call of summary.get(target) ?? []) {
|
|
235
236
|
for (const name of reads.get(call) ?? []) {
|
|
236
237
|
for (const def of resolve_helper_1.Resolve.byName(name, vertex.environment) ?? []) {
|
|
@@ -251,10 +252,7 @@ function escapedDefinitionMap(graph, hidden) {
|
|
|
251
252
|
const map = new Map(hidden.entries().map(([id, defs]) => [id, [...defs]]));
|
|
252
253
|
const definitionsOf = new defaultmap_1.DefaultMap(() => [], map);
|
|
253
254
|
const seen = new Set();
|
|
254
|
-
for (const [, vertex] of graph.
|
|
255
|
-
if (!vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
255
|
+
for (const [, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
258
256
|
const global = escapeTargetFrames(vertex).filter(e => e.t === undefined).reduce((_, e) => e, undefined);
|
|
259
257
|
/* a frame shared with an already-visited definition contributes the same entries */
|
|
260
258
|
if (global !== undefined && !seen.has(global.memory)) {
|
|
@@ -279,13 +277,13 @@ function propagateTransitiveEscapedDefinitions(graph, environment, defined, hidd
|
|
|
279
277
|
const defs = escapedDefinitionMap(graph, hidden);
|
|
280
278
|
const names = new Set();
|
|
281
279
|
let byName;
|
|
282
|
-
const definitionsNamed = (name) => (byName ??=
|
|
280
|
+
const definitionsNamed = (name) => (byName ??= df_helper_1.Dataflow.definitionsByName(graph)).get(name);
|
|
283
281
|
let grew = false;
|
|
284
|
-
for (const [id
|
|
285
|
-
if (!
|
|
282
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
283
|
+
if (!graph.isRoot(id)) {
|
|
286
284
|
continue;
|
|
287
285
|
}
|
|
288
|
-
for (const target of
|
|
286
|
+
for (const target of df_helper_1.Dataflow.calleeIdsOf(graph, id)) {
|
|
289
287
|
for (const def of (summary.get(target) ?? []).values().flatMap(nodeId => defs.get(nodeId) ?? [])) {
|
|
290
288
|
const nodeId = def.nodeId;
|
|
291
289
|
names.add(def.name);
|
|
@@ -300,7 +298,7 @@ function propagateTransitiveEscapedDefinitions(graph, environment, defined, hidd
|
|
|
300
298
|
if (resolve_helper_1.Resolve.byNameAndType(def.name, environment, def.type)?.some(d => d.nodeId === nodeId)) {
|
|
301
299
|
continue;
|
|
302
300
|
}
|
|
303
|
-
environment =
|
|
301
|
+
environment = environment_1.REnvironment.define(def, false, environment);
|
|
304
302
|
linkReadsAfter(graph, id, def, open, definitionsNamed);
|
|
305
303
|
grew = true;
|
|
306
304
|
}
|
|
@@ -315,7 +313,7 @@ function propagateTransitiveEscapedDefinitions(graph, environment, defined, hidd
|
|
|
315
313
|
function linkReadsAfter(graph, call, def, open, definitionsNamed) {
|
|
316
314
|
const before = graph.getVertex(call)?.environment;
|
|
317
315
|
const visible = before === undefined ? definitionsNamed(def.name) : resolve_helper_1.Resolve.byName(def.name, before)?.map(d => d.nodeId) ?? [];
|
|
318
|
-
const replaced = new Set([...visible, ...
|
|
316
|
+
const replaced = new Set([...visible, ...df_helper_1.Dataflow.sourcesOf(graph, call, edge_1.EdgeType.SideEffectOnCall)]);
|
|
319
317
|
const readers = new Set(open.filter(r => r.name === def.name).map(r => r.nodeId));
|
|
320
318
|
for (const [id] of graph.vertices(true)) {
|
|
321
319
|
/* an argument reads the value of a call, not a name the call may define (an ambient state is defined at its call) */
|
|
@@ -30,6 +30,8 @@ export interface ProcessAllArgumentInput<OtherInfo> {
|
|
|
30
30
|
readonly nonFunction?: ReadonlySet<NodeId>;
|
|
31
31
|
/** the arguments from this index on are alternatives of which at most one runs (the arms of `switch`) */
|
|
32
32
|
readonly alternativesFrom?: number;
|
|
33
|
+
/** keep the graph of each processed argument its own, for a caller marking what lies within an argument */
|
|
34
|
+
readonly keepGraphs?: boolean;
|
|
33
35
|
}
|
|
34
36
|
export interface ProcessAllArgumentResult {
|
|
35
37
|
readonly finalEnv: REnvironmentInformation;
|
|
@@ -56,7 +58,7 @@ export declare function convertFnArgument<OtherInfo>(this: void, arg: typeof Emp
|
|
|
56
58
|
*/
|
|
57
59
|
export declare function isPipedArgument<OtherInfo>(arg: unknown, functionRootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): boolean;
|
|
58
60
|
/** Processes all arguments for a function call, updating the given final graph and environment. */
|
|
59
|
-
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forced, patchData, nonFunction, alternativesFrom }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
|
|
61
|
+
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forced, patchData, nonFunction, alternativesFrom, keepGraphs }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
|
|
60
62
|
export interface PatchFunctionCallInput<OtherInfo> {
|
|
61
63
|
readonly nextGraph: DataflowGraph;
|
|
62
64
|
readonly rootId: NodeId;
|
|
@@ -17,14 +17,13 @@ const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
|
17
17
|
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
18
|
const identifier_1 = require("../../../../environments/identifier");
|
|
19
19
|
const built_in_ambient_state_1 = require("./built-in/built-in-ambient-state");
|
|
20
|
-
const overwrite_1 = require("../../../../environments/overwrite");
|
|
21
20
|
const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
|
|
22
21
|
const process_argument_1 = require("../process-argument");
|
|
23
22
|
const vertex_1 = require("../../../../graph/vertex");
|
|
24
23
|
const edge_1 = require("../../../../graph/edge");
|
|
25
24
|
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
26
25
|
const vertex_2 = require("../../../../graph/vertex");
|
|
27
|
-
const
|
|
26
|
+
const environment_1 = require("../../../../environments/environment");
|
|
28
27
|
function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
29
28
|
const valueVertex = graph.getVertex(value.entryPoint);
|
|
30
29
|
if (!valueVertex) {
|
|
@@ -80,7 +79,7 @@ function isPipedArgument(arg, functionRootId, data) {
|
|
|
80
79
|
return data.pipedArgument?.rootId === functionRootId && data.pipedArgument.argument === arg;
|
|
81
80
|
}
|
|
82
81
|
/** Processes all arguments for a function call, updating the given final graph and environment. */
|
|
83
|
-
function processAllArguments({ functionName, args, data, finalGraph, functionRootId, forced = [], patchData, nonFunction, alternativesFrom }) {
|
|
82
|
+
function processAllArguments({ functionName, args, data, finalGraph, functionRootId, forced = [], patchData, nonFunction, alternativesFrom, keepGraphs }) {
|
|
84
83
|
let finalEnv = functionName.environment;
|
|
85
84
|
const callArgs = [];
|
|
86
85
|
const processedArguments = [];
|
|
@@ -113,12 +112,12 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
113
112
|
forceVertexArgumentValueReferences(functionRootId, processed, processed.graph, data.environment);
|
|
114
113
|
}
|
|
115
114
|
processedArguments.push(processed);
|
|
116
|
-
finalEnv =
|
|
115
|
+
finalEnv = environment_1.REnvironment.overwrite(finalEnv, processed.environment);
|
|
117
116
|
if (beforeAlternatives !== undefined) {
|
|
118
|
-
afterAlternatives =
|
|
117
|
+
afterAlternatives = environment_1.REnvironment.append(afterAlternatives ?? beforeAlternatives, finalEnv);
|
|
119
118
|
}
|
|
120
|
-
/* nothing reads the argument's own graph past this point, only its entry point and references */
|
|
121
|
-
finalGraph.mergeWith(processed.graph, true, precomputed === undefined);
|
|
119
|
+
/* unless asked to keep it, nothing reads the argument's own graph past this point, only its entry point and references */
|
|
120
|
+
finalGraph.mergeWith(processed.graph, true, precomputed === undefined && !keepGraphs);
|
|
122
121
|
/* resolve reads within argument, we resolve before adding the `processed.environment` to avoid cyclic dependencies */
|
|
123
122
|
for (const original of [...processed.in, ...processed.unknownReferences]) {
|
|
124
123
|
const inId = original.nodeId;
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Deferred = void 0;
|
|
4
4
|
exports.verticesByName = verticesByName;
|
|
5
|
+
const r_string_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
5
6
|
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
6
7
|
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
7
8
|
const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
9
|
const identifier_1 = require("../../../../environments/identifier");
|
|
9
|
-
const retriever_1 = require("../../../../../r-bridge/retriever");
|
|
10
10
|
const edge_1 = require("../../../../graph/edge");
|
|
11
11
|
const vertex_1 = require("../../../../graph/vertex");
|
|
12
12
|
const happens_before_1 = require("../../../../../control-flow/happens-before");
|
|
13
13
|
const r_symbol_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
14
14
|
const linker_1 = require("../../../linker");
|
|
15
|
-
const frame_reflection_1 = require("../../../../fn/frame-reflection");
|
|
16
15
|
const r_function_definition_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
17
16
|
const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
|
|
17
|
+
const df_helper_1 = require("../../../../graph/df-helper");
|
|
18
18
|
/** The vertices of `type` by their unquoted name. */
|
|
19
19
|
function verticesByName(graph, type, idMap) {
|
|
20
20
|
const named = graph.vertexIdsOfType(type).filter(id => node_id_1.NodeId.recoverName(id, idMap) !== undefined);
|
|
21
|
-
return Map.groupBy(named, id =>
|
|
21
|
+
return Map.groupBy(named, id => r_string_1.RString.unquote(node_id_1.NodeId.recoverName(id, idMap)));
|
|
22
22
|
}
|
|
23
23
|
/** The names a deferred expression touches, each with the node touching it and whether it is written. */
|
|
24
24
|
function namesWithin(expr, graph, idMap) {
|
|
@@ -34,10 +34,10 @@ function namesWithin(expr, graph, idMap) {
|
|
|
34
34
|
/* a call reads the function it names, so `evalq(f())` needs the definition of `f` */
|
|
35
35
|
if (vertex_1.DfgVertex.isFunctionCall(graph.getVertex(inner.info.id))) {
|
|
36
36
|
names.push([inner.info.id, identifier_1.Identifier.getName(inner.functionName.content), false]);
|
|
37
|
-
for (const def of
|
|
37
|
+
for (const def of df_helper_1.Dataflow.sourcesOf(graph, inner.info.id, edge_1.EdgeType.SideEffectOnCall)) {
|
|
38
38
|
const name = node_id_1.NodeId.recoverName(def, idMap);
|
|
39
39
|
if (name !== undefined) {
|
|
40
|
-
names.push([def,
|
|
40
|
+
names.push([def, r_string_1.RString.unquote(name), true]);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -77,11 +77,11 @@ exports.Deferred = {
|
|
|
77
77
|
* With `viaClosures`, a closure reading a `delayedAssign` binding forces it when called.
|
|
78
78
|
*/
|
|
79
79
|
forcedAt(graph, binding, cfg, viaClosures = false) {
|
|
80
|
-
const reads =
|
|
80
|
+
const reads = df_helper_1.Dataflow.sourcesOf(graph, binding, edge_1.EdgeType.Reads);
|
|
81
81
|
const readSet = new Set(reads);
|
|
82
82
|
/* a closure reading it and the call of that closure may skip the read, so they never rule out a later force */
|
|
83
83
|
const calls = viaClosures
|
|
84
|
-
?
|
|
84
|
+
? df_helper_1.Dataflow.sourcesOf(graph, binding, edge_1.EdgeType.DefinesOnCall | edge_1.EdgeType.DefinedByOnCall).filter(r => !readSet.has(r))
|
|
85
85
|
: [];
|
|
86
86
|
if (reads.length < 2) {
|
|
87
87
|
return reads.concat(calls);
|
|
@@ -148,7 +148,7 @@ exports.Deferred = {
|
|
|
148
148
|
return always;
|
|
149
149
|
};
|
|
150
150
|
/* `delayedAssign` names its variable with a string literal, so the recovered name still carries quotes */
|
|
151
|
-
const bindingName = forces === undefined ? undefined :
|
|
151
|
+
const bindingName = forces === undefined ? undefined : r_string_1.RString.unquote(node_id_1.NodeId.recoverName(forces.binding, idMap) ?? '');
|
|
152
152
|
for (const [node, name, writes] of within) {
|
|
153
153
|
if (writes) {
|
|
154
154
|
/* a write of the bound name replaces the binding, so a read it definitely reaches sees only it */
|
|
@@ -25,6 +25,8 @@ export interface ProcessKnownFunctionCallInput<OtherInfo> {
|
|
|
25
25
|
readonly reverseOrder?: boolean;
|
|
26
26
|
/** which arguments are {@link NseKind.Reevaluated|reevaluated}, like a loop body */
|
|
27
27
|
readonly markAsNSE?: readonly number[];
|
|
28
|
+
/** see {@link ProcessAllArgumentInput#keepGraphs}, needed to mark what lies within an argument afterward */
|
|
29
|
+
readonly keepArgumentGraphs?: boolean;
|
|
28
30
|
/** allows passing a data processor in-between each argument */
|
|
29
31
|
readonly patchData?: (data: DataflowProcessorInformation<OtherInfo & ParentInformation>, arg: number) => DataflowProcessorInformation<OtherInfo & ParentInformation>;
|
|
30
32
|
/** Does the call have a side effect that we do not know a lot about which may have further consequences? */
|
|
@@ -87,17 +89,22 @@ export interface NseMarkOptions {
|
|
|
87
89
|
readonly kind?: NseKind;
|
|
88
90
|
/** ids an unquote escape splices back in, see {@link FunctionSemantics.call.nse.unquoted} */
|
|
89
91
|
readonly evaluated?: ReadonlySet<NodeId>;
|
|
92
|
+
/** the position of the argument filling the first parameter, see {@link nseArgumentPositions} */
|
|
93
|
+
readonly first?: number;
|
|
90
94
|
}
|
|
91
|
-
/**
|
|
92
|
-
|
|
95
|
+
/**
|
|
96
|
+
* The positions of the arguments `which` names among `count` arguments, where `first` is the position of the
|
|
97
|
+
* argument filling the first parameter (`-1` if none does), as a named one may come later (`mutate(z = 1, .data = d)`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function nseArgumentPositions(which: NseArguments | readonly number[] | undefined, count: number, first?: number): readonly number[];
|
|
93
100
|
/**
|
|
94
101
|
* Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}: a {@link NseKind.Quoted|quoted} one
|
|
95
102
|
* entirely, a {@link NseKind.DataMasked|data-masked} one only where {@link FunctionSemantics.call.nse.suppliedByMask} holds, and a
|
|
96
103
|
* {@link NseKind.Reevaluated|reevaluated} one as a whole but not within.
|
|
97
104
|
*/
|
|
98
|
-
export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[] | undefined, { kind, evaluated }?: NseMarkOptions): void;
|
|
105
|
+
export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[] | undefined, { kind, evaluated, first }?: NseMarkOptions): void;
|
|
99
106
|
/**
|
|
100
107
|
* The main processor for function calls for which we know the target but need not
|
|
101
108
|
* add any specific handling.
|
|
102
109
|
*/
|
|
103
|
-
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, sig, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
|
|
110
|
+
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, sig, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom, keepArgumentGraphs }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
|
|
@@ -47,24 +47,27 @@ var NseKind;
|
|
|
47
47
|
/** evaluated, just not exactly once (a loop body), so only the argument itself is marked */
|
|
48
48
|
NseKind["Reevaluated"] = "reevaluated";
|
|
49
49
|
})(NseKind || (exports.NseKind = NseKind = {}));
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The positions of the arguments `which` names among `count` arguments, where `first` is the position of the
|
|
52
|
+
* argument filling the first parameter (`-1` if none does), as a named one may come later (`mutate(z = 1, .data = d)`).
|
|
53
|
+
*/
|
|
54
|
+
function nseArgumentPositions(which, count, first = 0) {
|
|
52
55
|
if (typeof which !== 'string') {
|
|
53
56
|
return which ?? [];
|
|
54
57
|
}
|
|
55
58
|
const all = Array.from({ length: count }, (_, i) => i);
|
|
56
59
|
if (which === NseArguments.First) {
|
|
57
|
-
return
|
|
60
|
+
return first >= 0 && first < count ? [first] : [];
|
|
58
61
|
}
|
|
59
|
-
return which === NseArguments.AllButFirst ? all.
|
|
62
|
+
return which === NseArguments.AllButFirst ? all.filter(i => i !== first) : all;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}: a {@link NseKind.Quoted|quoted} one
|
|
63
66
|
* entirely, a {@link NseKind.DataMasked|data-masked} one only where {@link FunctionSemantics.call.nse.suppliedByMask} holds, and a
|
|
64
67
|
* {@link NseKind.Reevaluated|reevaluated} one as a whole but not within.
|
|
65
68
|
*/
|
|
66
|
-
function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which, { kind = NseKind.Quoted, evaluated } = {}) {
|
|
67
|
-
for (const i of nseArgumentPositions(which, processedArguments.length)) {
|
|
69
|
+
function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which, { kind = NseKind.Quoted, evaluated, first } = {}) {
|
|
70
|
+
for (const i of nseArgumentPositions(which, processedArguments.length, first)) {
|
|
68
71
|
if (i < processedArguments.length) {
|
|
69
72
|
markArgument(graph, rootId, processedArguments[i], kind, evaluated);
|
|
70
73
|
}
|
|
@@ -99,7 +102,7 @@ function markArgument(graph, rootId, arg, kind, evaluated) {
|
|
|
99
102
|
* The main processor for function calls for which we know the target but need not
|
|
100
103
|
* add any specific handling.
|
|
101
104
|
*/
|
|
102
|
-
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, sig, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }) {
|
|
105
|
+
function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, sig, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom, keepArgumentGraphs }) {
|
|
103
106
|
const functionName = (0, processor_1.processDataflowFor)(name, data);
|
|
104
107
|
const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
|
|
105
108
|
const functionCallName = name.content;
|
|
@@ -111,6 +114,7 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
|
|
|
111
114
|
data: origin === 'default' ? control_flow_1.ControlFlow.withinPromise(data, rootId) : data,
|
|
112
115
|
finalGraph,
|
|
113
116
|
functionRootId: rootId,
|
|
117
|
+
keepGraphs: keepArgumentGraphs,
|
|
114
118
|
patchData,
|
|
115
119
|
forced,
|
|
116
120
|
nonFunction,
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.markAsOnlyBuiltIn = markAsOnlyBuiltIn;
|
|
4
4
|
exports.processNamedCall = processNamedCall;
|
|
5
|
+
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
5
6
|
const built_in_ambient_state_1 = require("./built-in/built-in-ambient-state");
|
|
6
7
|
const function_semantics_1 = require("../../../../fn/function-semantics");
|
|
7
8
|
const info_1 = require("../../../../info");
|
|
8
9
|
const known_call_handling_1 = require("./known-call-handling");
|
|
9
|
-
const
|
|
10
|
+
const r_parameter_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
|
|
11
|
+
const r_string_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
12
|
+
const r_expression_list_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
13
|
+
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
14
|
+
const operators_1 = require("../../../../../r-bridge/lang-4.x/ast/model/operators");
|
|
10
15
|
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
11
16
|
const r_binary_op_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
12
17
|
const r_symbol_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
@@ -21,6 +26,7 @@ const resolve_helper_1 = require("../../../../environments/resolve-helper");
|
|
|
21
26
|
const assert_1 = require("../../../../../util/assert");
|
|
22
27
|
const built_in_props_1 = require("../../../../environments/built-in-props");
|
|
23
28
|
const query_fn_props_1 = require("../../../../environments/query-fn-props");
|
|
29
|
+
const environment_1 = require("../../../../environments/environment");
|
|
24
30
|
function mergeInformation(info, newInfo) {
|
|
25
31
|
if (info === undefined) {
|
|
26
32
|
return newInfo;
|
|
@@ -30,7 +36,7 @@ function mergeInformation(info, newInfo) {
|
|
|
30
36
|
in: info.in.concat(newInfo.in),
|
|
31
37
|
out: info.out.concat(newInfo.out),
|
|
32
38
|
graph: info.graph.mergeWith(newInfo.graph),
|
|
33
|
-
environment:
|
|
39
|
+
environment: environment_1.REnvironment.append(info.environment, newInfo.environment),
|
|
34
40
|
entryPoint: newInfo.entryPoint,
|
|
35
41
|
cfgEntry: newInfo.cfgEntry,
|
|
36
42
|
cfgExit: newInfo.cfgExit,
|
|
@@ -74,7 +80,7 @@ function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
|
|
|
74
80
|
const HandedFunction = identifier_1.ReferenceType.Function | identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument;
|
|
75
81
|
/** Whether `arg` hands over a function that may draw: a symbol bound to data (`d <- read.csv(f)`, `NA`) does not, nor does a built-in stating it does not (`mean`) */
|
|
76
82
|
function handsOverFunction(arg, data) {
|
|
77
|
-
const value =
|
|
83
|
+
const value = r_argument_1.RArgument.valueOf(arg);
|
|
78
84
|
if (!r_symbol_1.RSymbol.is(value)) {
|
|
79
85
|
return r_function_definition_1.RFunctionDefinition.is(value);
|
|
80
86
|
}
|
|
@@ -88,6 +94,35 @@ function rewrittenByReplacement(definition, data) {
|
|
|
88
94
|
const node = definition.type === identifier_1.ReferenceType.Unknown && at !== undefined ? data.completeAst.idMap.get(at) : undefined;
|
|
89
95
|
return r_function_call_1.RFunctionCall.is(node) || (r_binary_op_1.RBinaryOp.is(node) && r_function_call_1.RFunctionCall.is(node.lhs));
|
|
90
96
|
}
|
|
97
|
+
const bindingFrames = new WeakMap();
|
|
98
|
+
/** for each name the program binds, the functions binding it (`undefined` for the global frame or a `<<-`) */
|
|
99
|
+
function framesBinding(idMap) {
|
|
100
|
+
let frames = bindingFrames.get(idMap);
|
|
101
|
+
if (frames === undefined) {
|
|
102
|
+
const found = new Map();
|
|
103
|
+
for (const node of idMap.values()) {
|
|
104
|
+
const target = r_binary_op_1.RBinaryOp.is(node) && operators_1.OperatorDatabase[node.operator]?.usedAs === 'assignment' ? (node.operator.startsWith('-') ? node.rhs : node.lhs)
|
|
105
|
+
: r_parameter_1.RParameter.is(node) ? node.name : undefined;
|
|
106
|
+
const name = r_symbol_1.RSymbol.is(target) ? identifier_1.Identifier.getName(target.content) : r_string_1.RString.is(target) ? target.content.str : undefined;
|
|
107
|
+
if (name !== undefined) {
|
|
108
|
+
const global = r_binary_op_1.RBinaryOp.is(node) && (node.operator === '<<-' || node.operator === '->>');
|
|
109
|
+
const frame = global ? undefined : model_1.RNode.findEnclosing(node.info.id, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
110
|
+
found.set(name, new Set([...found.get(name) ?? [], frame]));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
bindingFrames.set(idMap, frames = found);
|
|
114
|
+
}
|
|
115
|
+
return frames;
|
|
116
|
+
}
|
|
117
|
+
/** whether the program binds `name` in a frame enclosing the function the call is in, which a built-in found there leaves out */
|
|
118
|
+
function mayBeShadowed(name, call, idMap) {
|
|
119
|
+
const frames = framesBinding(idMap).get(name);
|
|
120
|
+
if (frames === undefined || r_expression_list_1.RExpressionList.isImplicit(idMap.get(call))) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const own = model_1.RNode.findEnclosing(call, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
124
|
+
return frames.has(undefined) || [...model_1.RNode.iterateParents(idMap.get(own), idMap)].some(p => frames.has(p.info.id));
|
|
125
|
+
}
|
|
91
126
|
/**
|
|
92
127
|
* Processes a named function call within the dataflow analysis.
|
|
93
128
|
* For example, `myFunction(arg1, arg2)`, resolves against the environment.
|
|
@@ -95,7 +130,10 @@ function rewrittenByReplacement(definition, data) {
|
|
|
95
130
|
function processNamedCall(name, callArguments, rootId, data) {
|
|
96
131
|
const args = data.pipedArgument?.rootId === rootId ? [data.pipedArgument.argument, ...callArguments] : callArguments;
|
|
97
132
|
const resolved = resolve_helper_1.Resolve.byNameAndType(name.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
|
|
98
|
-
|
|
133
|
+
/* a function body sees its enclosing frames only where it is called, so a built-in there may be shadowed by the program */
|
|
134
|
+
const shadowable = resolved.length > 0 && data.environment.level > 0 && resolved.every(r => r.type === identifier_1.ReferenceType.BuiltInFunction)
|
|
135
|
+
&& mayBeShadowed(identifier_1.Identifier.getName(name.content), rootId, data.completeAst.idMap);
|
|
136
|
+
let defaultProcessor = resolved.length === 0 || shadowable;
|
|
99
137
|
/* a call whose meaning a later pass looks up in its environment has to keep it */
|
|
100
138
|
const keepEnvironment = resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.keepEnvironment === true);
|
|
101
139
|
/* a call marked as built-in only (see below) needs no environment snapshot */
|
|
@@ -126,21 +164,36 @@ function processNamedCall(name, callArguments, rootId, data) {
|
|
|
126
164
|
}
|
|
127
165
|
/* flowR models what a package function does with its arguments, but not which of its options it reads */
|
|
128
166
|
let packageFn = false;
|
|
167
|
+
const alternatives = [];
|
|
168
|
+
const processDefault = () => {
|
|
169
|
+
/* if we do not know where we land, we force! reuse `resolved`, data.environment did not change above */
|
|
170
|
+
const sig = resolved.length > 0 ? undefined : function_semantics_1.FunctionSemantics.call.signature.every;
|
|
171
|
+
alternatives.push((0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, sig, origin: 'default' }).information);
|
|
172
|
+
};
|
|
173
|
+
/* first, so the arguments keep the promise the shadowing function makes of them, which holds for a forcing built-in, too */
|
|
174
|
+
if (shadowable) {
|
|
175
|
+
processDefault();
|
|
176
|
+
}
|
|
129
177
|
for (const own of toRun) {
|
|
130
|
-
|
|
178
|
+
alternatives.push(own.processor(name, args, rootId, data));
|
|
131
179
|
const pkg = own.name === undefined ? undefined : identifier_1.Identifier.getNamespace(own.name);
|
|
132
180
|
/* unless flowR states how it accesses the state, as for `withr::with_options` */
|
|
133
181
|
packageFn ||= pkg !== undefined && !(own.config !== undefined && ('ambient' in own.config || 'scope' in own.config)) && !(0, r_base_packages_1.isBaseRPackage)(String(pkg));
|
|
134
182
|
}
|
|
135
|
-
if (defaultProcessor) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
information = mergeInformation(information,
|
|
183
|
+
if (defaultProcessor && !shadowable) {
|
|
184
|
+
processDefault();
|
|
185
|
+
}
|
|
186
|
+
for (const alternative of alternatives) {
|
|
187
|
+
information = mergeInformation(information, alternative);
|
|
140
188
|
}
|
|
141
|
-
|
|
189
|
+
if (!defaultProcessor && information && builtIn) {
|
|
142
190
|
markAsOnlyBuiltIn(information.graph, rootId, keepEnvironment);
|
|
143
191
|
}
|
|
192
|
+
/* an exit only some of the possible callees take is not certain */
|
|
193
|
+
if (information !== undefined && alternatives.length > 1) {
|
|
194
|
+
const inAll = (e) => alternatives.every(a => a.exitPoints.some(o => o.nodeId === e.nodeId && o.type === e.type));
|
|
195
|
+
information = { ...information, exitPoints: information.exitPoints.map(e => inAll(e) ? e : { ...e, cds: (0, info_1.withCds)(e.cds, [{ id: rootId, when: true }]) }) };
|
|
196
|
+
}
|
|
144
197
|
/* a function whose body we do not see may read any option or draw on the device */
|
|
145
198
|
if (information !== undefined && (unknownBody || packageFn)) {
|
|
146
199
|
/* a function handed in as a parameter may be anything, `runif` included, and a function handed a function may call it;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Nse = exports.Unquote = void 0;
|
|
4
|
+
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
4
5
|
const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
5
6
|
const r_unary_op_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
6
7
|
const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
@@ -9,7 +10,6 @@ const identifier_1 = require("../../../../environments/identifier");
|
|
|
9
10
|
const data_masking_functions_1 = require("../../../../environments/data-masking-functions");
|
|
10
11
|
const vertex_1 = require("../../../../graph/vertex");
|
|
11
12
|
const edge_1 = require("../../../../graph/edge");
|
|
12
|
-
const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
13
13
|
/** The escape a quoting function offers, a property of the function: `quote(!!x)` negates, `expr(!!x)` splices. */
|
|
14
14
|
var Unquote;
|
|
15
15
|
(function (Unquote) {
|
|
@@ -23,11 +23,11 @@ var Unquote;
|
|
|
23
23
|
/** `!!x` parses as `!(!x)`, so peel the run of `!` to reach the operand. */
|
|
24
24
|
function unquotedOperandOf(node, style) {
|
|
25
25
|
if (style === Unquote.Bquote) {
|
|
26
|
-
if (!r_function_call_1.RFunctionCall.isNamed(node
|
|
26
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node, '.') || node.arguments.length !== 1) {
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
const arg = node.arguments[0];
|
|
30
|
-
return r_argument_1.RArgument.
|
|
30
|
+
return r_argument_1.RArgument.valueOf(arg);
|
|
31
31
|
}
|
|
32
32
|
if (!isNegation(node) || !isNegation(node.operand)) {
|
|
33
33
|
return undefined;
|
|
@@ -137,7 +137,7 @@ exports.Nse = {
|
|
|
137
137
|
},
|
|
138
138
|
/** Whether `id` is a name the data mask supplies, i.e. a use the caller does not bind itself. */
|
|
139
139
|
suppliedByMask(graph, id, vertex = graph.getVertex(id)) {
|
|
140
|
-
return vertex_1.DfgVertex.isUse(vertex) && !graph.
|
|
140
|
+
return vertex_1.DfgVertex.isUse(vertex) && !graph.edgesFrom(id).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads));
|
|
141
141
|
},
|
|
142
142
|
/**
|
|
143
143
|
* Whether `id` is a name a data mask supplied, which the mark the masking call carries is what records.
|