@eagleoutice/flowr 2.16.2 → 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 +10 -0
- package/dataflow/environments/built-in-props.js +25 -1
- 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 +188 -14
- package/dataflow/environments/default-builtin-config.js +125 -65
- 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 +0 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.js +2 -3
- 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 +16 -11
- 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 +3 -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 +5 -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 +4 -3
- 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 +518 -1
- 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/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -14
- package/linter/rules/no-leaked-credentials.js +4 -4
- package/linter/rules/problematic-inputs.js +2 -1
- 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.js +10 -9
- 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 +24 -32
- 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-sources-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.js +28 -29
- 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-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
|
@@ -19,13 +19,13 @@ const r_argument_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
|
19
19
|
const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
|
|
20
20
|
const auto_select_defaults_1 = require("./auto-select/auto-select-defaults");
|
|
21
21
|
const identifier_1 = require("../dataflow/environments/identifier");
|
|
22
|
-
const
|
|
22
|
+
const source_inline_map_1 = require("./inline/source-inline-map");
|
|
23
23
|
const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
|
|
24
24
|
function plain(text) {
|
|
25
25
|
return [{ line: Array.isArray(text) ? identifier_1.Identifier.toString(text) : text, indent: 0 }];
|
|
26
26
|
}
|
|
27
27
|
exports.reconstructLogger = log_1.log.getSubLogger({ name: 'reconstruct' });
|
|
28
|
-
function
|
|
28
|
+
function reconstructableSource(n) {
|
|
29
29
|
const lexeme = model_1.RNode.lexeme(n);
|
|
30
30
|
if (lexeme !== undefined) {
|
|
31
31
|
return lexeme;
|
|
@@ -37,7 +37,7 @@ function getLexeme(n) {
|
|
|
37
37
|
function synthesizeExpressionListLexeme(n) {
|
|
38
38
|
const inner = n.children
|
|
39
39
|
.filter(c => !r_comment_1.RComment.is(c))
|
|
40
|
-
.map(c =>
|
|
40
|
+
.map(c => reconstructableSource(c))
|
|
41
41
|
.filter(c => c.length > 0)
|
|
42
42
|
.join('; ');
|
|
43
43
|
const start = r_expression_list_1.RExpressionList.groupStart(n);
|
|
@@ -55,13 +55,13 @@ function getArgumentLexeme(n) {
|
|
|
55
55
|
if (n === undefined || r_argument_1.RArgument.isEmpty(n)) {
|
|
56
56
|
return '';
|
|
57
57
|
}
|
|
58
|
-
return n.info.fullLexeme ?? (n.value !== undefined ?
|
|
58
|
+
return n.info.fullLexeme ?? (n.value !== undefined ? reconstructableSource(n.value) : reconstructableSource(n));
|
|
59
59
|
}
|
|
60
60
|
function reconstructAsLeaf(leaf, configuration) {
|
|
61
61
|
return isSelected(configuration, leaf) ? foldToConst(leaf) : [];
|
|
62
62
|
}
|
|
63
63
|
function foldToConst(n) {
|
|
64
|
-
return plain(
|
|
64
|
+
return plain(reconstructableSource(n));
|
|
65
65
|
}
|
|
66
66
|
function indentBy(lines, indent) {
|
|
67
67
|
return lines.map(({ line, indent: i }) => ({ line, indent: i + indent }));
|
|
@@ -69,12 +69,7 @@ function indentBy(lines, indent) {
|
|
|
69
69
|
function reconstructExpressionList(exprList, _grouping, expressions, config) {
|
|
70
70
|
const subExpressions = expressions.filter(e => e.length > 0);
|
|
71
71
|
if (subExpressions.length === 0) {
|
|
72
|
-
|
|
73
|
-
return plain('{}');
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
72
|
+
return isSelected(config, exprList) ? plain('{}') : [];
|
|
78
73
|
}
|
|
79
74
|
else if (subExpressions.length === 1) {
|
|
80
75
|
if (!isSelected(config, exprList)) {
|
|
@@ -124,28 +119,12 @@ function evaluatesToRhs(n) {
|
|
|
124
119
|
return info?.usedAs === 'assignment' && info.stringUsedInRAst !== type_1.RawRType.RightAssign;
|
|
125
120
|
}
|
|
126
121
|
function reconstructBinaryOp(n, lhs, rhs, config) {
|
|
127
|
-
if (lhs.length === 0
|
|
128
|
-
if (isSelected(config, n)) {
|
|
129
|
-
return plain(getLexeme(n));
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else if (lhs.length === 0) {
|
|
122
|
+
if (lhs.length === 0 || rhs.length === 0) {
|
|
136
123
|
// dropping the lhs is only sound if the operator evaluates to its rhs, otherwise we have to keep the operation
|
|
137
|
-
if (isSelected(config, n) && !evaluatesToRhs(n)) {
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
return rhs;
|
|
141
|
-
}
|
|
142
|
-
else if (rhs.length === 0) {
|
|
143
|
-
if (isSelected(config, n)) {
|
|
144
|
-
return plain(getLexeme(n));
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
return lhs;
|
|
124
|
+
if (isSelected(config, n) && !(rhs.length > 0 && evaluatesToRhs(n))) {
|
|
125
|
+
return foldToConst(n);
|
|
148
126
|
}
|
|
127
|
+
return lhs.length === 0 ? rhs : lhs;
|
|
149
128
|
}
|
|
150
129
|
return reconstructRawBinaryOperator(lhs, r_pipe_1.RPipe.is(n) ? '|>' : n.operator, rhs);
|
|
151
130
|
}
|
|
@@ -156,28 +135,7 @@ function reconstructForLoop(loop, variable, vector, body, config) {
|
|
|
156
135
|
else if (body.length === 0 && variable.length === 0 && vector.length === 0) {
|
|
157
136
|
return [];
|
|
158
137
|
}
|
|
159
|
-
|
|
160
|
-
// 'inline'
|
|
161
|
-
return [{
|
|
162
|
-
line: `for(${getLexeme(loop.variable)} in ${getLexeme(loop.vector)}) ${body.length === 0 ? '{}' : body[0].line}`,
|
|
163
|
-
indent: 0
|
|
164
|
-
}];
|
|
165
|
-
}
|
|
166
|
-
else if (body[0].line === '{' && body[body.length - 1].line === '}') {
|
|
167
|
-
// 'block'
|
|
168
|
-
return [
|
|
169
|
-
{ line: `for(${getLexeme(loop.variable)} in ${getLexeme(loop.vector)}) {`, indent: 0 },
|
|
170
|
-
...body.slice(1, body.length - 1),
|
|
171
|
-
{ line: '}', indent: 0 }
|
|
172
|
-
];
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
// unknown
|
|
176
|
-
return [
|
|
177
|
-
{ line: `for(${getLexeme(loop.variable)} in ${getLexeme(loop.vector)})`, indent: 0 },
|
|
178
|
-
...indentBy(body, 1)
|
|
179
|
-
];
|
|
180
|
-
}
|
|
138
|
+
return reconstructBodyWithHeader({ line: `for(${reconstructableSource(loop.variable)} in ${reconstructableSource(loop.vector)})`, indent: 0 }, body, ' {}');
|
|
181
139
|
}
|
|
182
140
|
function reconstructBodyWithHeader(header, body, onEmpty) {
|
|
183
141
|
if (body.length === 0) {
|
|
@@ -212,7 +170,7 @@ function reconstructIfThenElse(ifThenElse, condition, then, otherwise, config) {
|
|
|
212
170
|
otherwise ??= [];
|
|
213
171
|
if (then.length === 0 && otherwise.length === 0) {
|
|
214
172
|
if (isSelected(config, ifThenElse)) {
|
|
215
|
-
return [{ line: `if(${
|
|
173
|
+
return [{ line: `if(${reconstructableSource(ifThenElse.condition)}) { }`, indent: 0 }];
|
|
216
174
|
}
|
|
217
175
|
else if (condition.length > 0) {
|
|
218
176
|
return condition;
|
|
@@ -223,7 +181,7 @@ function reconstructIfThenElse(ifThenElse, condition, then, otherwise, config) {
|
|
|
223
181
|
}
|
|
224
182
|
else if (otherwise.length === 0) {
|
|
225
183
|
if (isSelected(config, ifThenElse)) {
|
|
226
|
-
return reconstructBodyWithHeader({ line: `if(${
|
|
184
|
+
return reconstructBodyWithHeader({ line: `if(${reconstructableSource(ifThenElse.condition)})`, indent: 0 }, then, '{}');
|
|
227
185
|
}
|
|
228
186
|
else {
|
|
229
187
|
return then;
|
|
@@ -231,7 +189,7 @@ function reconstructIfThenElse(ifThenElse, condition, then, otherwise, config) {
|
|
|
231
189
|
}
|
|
232
190
|
else if (then.length === 0) {
|
|
233
191
|
if (isSelected(config, ifThenElse)) {
|
|
234
|
-
return reconstructBodyWithHeader({ line: `if(${
|
|
192
|
+
return reconstructBodyWithHeader({ line: `if(${reconstructableSource(ifThenElse.condition)}) { } else`, indent: 0 }, then, '{}');
|
|
235
193
|
}
|
|
236
194
|
else {
|
|
237
195
|
return otherwise;
|
|
@@ -245,7 +203,7 @@ function reconstructIfThenElse(ifThenElse, condition, then, otherwise, config) {
|
|
|
245
203
|
}
|
|
246
204
|
}
|
|
247
205
|
return [
|
|
248
|
-
{ line: `if(${
|
|
206
|
+
{ line: `if(${reconstructableSource(ifThenElse.condition)}) ${then[0].line} ${then.length === 1 ? 'else' : ''}`, indent: 0 },
|
|
249
207
|
...thenRemainder,
|
|
250
208
|
{ line: `${otherwise[0].line}`, indent: 0 },
|
|
251
209
|
...indentBy(otherwise.splice(1), 1)
|
|
@@ -259,35 +217,13 @@ function reconstructWhileLoop(loop, condition, body, configuration) {
|
|
|
259
217
|
else if (body.length === 0 && condition.length === 0) {
|
|
260
218
|
return [];
|
|
261
219
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
else if (body[0].line === '{' && body[body.length - 1].line === '}') {
|
|
267
|
-
// 'block'
|
|
268
|
-
return [
|
|
269
|
-
{ line: `while(${getLexeme(loop.condition)}) {`, indent: 0 },
|
|
270
|
-
...body.slice(1, body.length - 1),
|
|
271
|
-
{ line: '}', indent: 0 }
|
|
272
|
-
];
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
// unknown
|
|
276
|
-
return [
|
|
277
|
-
{ line: `while(${getLexeme(loop.condition)})`, indent: 0 },
|
|
278
|
-
...indentBy(body, 1)
|
|
279
|
-
];
|
|
280
|
-
}
|
|
220
|
+
return reconstructBodyWithHeader({ line: `while(${reconstructableSource(loop.condition)})`, indent: 0 }, body, ' {}');
|
|
221
|
+
}
|
|
222
|
+
function parameterSource(p) {
|
|
223
|
+
return p.defaultValue === undefined ? reconstructableSource(p) : `${reconstructableSource(p.name)}=${reconstructableSource(p.defaultValue)}`;
|
|
281
224
|
}
|
|
282
225
|
function reconstructParameters(parameters) {
|
|
283
|
-
return parameters.map(
|
|
284
|
-
if (p.defaultValue !== undefined) {
|
|
285
|
-
return `${getLexeme(p.name)}=${getLexeme(p.defaultValue)}`;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
return getLexeme(p);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
226
|
+
return parameters.map(parameterSource);
|
|
291
227
|
}
|
|
292
228
|
function isNotEmptyArgument(a) {
|
|
293
229
|
return a !== r_function_call_1.EmptyArgument;
|
|
@@ -299,11 +235,11 @@ function reconstructFoldAccess(node, accessed, access) {
|
|
|
299
235
|
else if (access.every(a => a === r_function_call_1.EmptyArgument || a.length === 0)) {
|
|
300
236
|
return accessed;
|
|
301
237
|
}
|
|
302
|
-
return
|
|
238
|
+
return foldToConst(node);
|
|
303
239
|
}
|
|
304
240
|
function reconstructArgument(argument, name, value) {
|
|
305
241
|
if (argument.name !== undefined && name !== undefined && name.length > 0) {
|
|
306
|
-
return plain(`${
|
|
242
|
+
return plain(`${reconstructableSource(argument.name)}=${argument.value ? reconstructableSource(argument.value) : ''}`);
|
|
307
243
|
}
|
|
308
244
|
else {
|
|
309
245
|
return value ?? [];
|
|
@@ -311,31 +247,20 @@ function reconstructArgument(argument, name, value) {
|
|
|
311
247
|
}
|
|
312
248
|
function reconstructParameter(parameter, name, defaultValue, configuration) {
|
|
313
249
|
if (isSelected(configuration, parameter)) {
|
|
314
|
-
return
|
|
315
|
-
}
|
|
316
|
-
if (parameter.defaultValue !== undefined && name.length > 0) {
|
|
317
|
-
return plain(`${getLexeme(parameter.name)}=${getLexeme(parameter.defaultValue)}`);
|
|
318
|
-
}
|
|
319
|
-
else if (parameter.defaultValue !== undefined && name.length === 0) {
|
|
320
|
-
return defaultValue ?? [];
|
|
250
|
+
return foldToConst(parameter);
|
|
321
251
|
}
|
|
322
|
-
|
|
252
|
+
if (parameter.defaultValue === undefined) {
|
|
323
253
|
return name;
|
|
324
254
|
}
|
|
255
|
+
return name.length > 0 ? plain(parameterSource(parameter)) : defaultValue ?? [];
|
|
325
256
|
}
|
|
326
257
|
/** whether any ancestor of `n` is part of the reconstruction and hence may consume the value of `n` */
|
|
327
258
|
function hasSelectedAncestor(n, config) {
|
|
328
259
|
const { idMap } = config.fullAst;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const parent = idMap.get(parentId);
|
|
332
|
-
if (parent === undefined) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
else if (isSelected(config, parent)) {
|
|
260
|
+
for (const parent of model_1.RNode.iterateParents(n, idMap)) {
|
|
261
|
+
if (isSelected(config, parent)) {
|
|
336
262
|
return true;
|
|
337
263
|
}
|
|
338
|
-
parentId = parent.info.parent;
|
|
339
264
|
}
|
|
340
265
|
return false;
|
|
341
266
|
}
|
|
@@ -390,7 +315,7 @@ function reconstructSpecialInfixFunctionCall(args, call) {
|
|
|
390
315
|
const lhsLexeme = getArgumentLexeme(call.arguments[0]);
|
|
391
316
|
const rhsLexeme = getArgumentLexeme(call.arguments[1]);
|
|
392
317
|
if (lhsLexeme.length === 0 || rhsLexeme.length === 0) {
|
|
393
|
-
return
|
|
318
|
+
return foldToConst(call);
|
|
394
319
|
}
|
|
395
320
|
return plain(`${lhsLexeme} ${identifier_1.Identifier.toString(call.functionName.content)} ${rhsLexeme}`);
|
|
396
321
|
}
|
|
@@ -408,7 +333,7 @@ function tryInlineSourceCall(call, config) {
|
|
|
408
333
|
// cyclic source() - keep the literal call and mark the cycle edge
|
|
409
334
|
config.warnings?.push({ kind: 'cycle', callId: id, path });
|
|
410
335
|
exports.reconstructLogger.warn(`cyclic source() not inlined at node ${JSON.stringify(id)}: ${JSON.stringify(path)}`);
|
|
411
|
-
const literal =
|
|
336
|
+
const literal = foldToConst(call);
|
|
412
337
|
literal.push({ line: `# [flowR] cyclic source() not inlined: ${path ?? '<unknown>'}`, indent: 0 });
|
|
413
338
|
return literal;
|
|
414
339
|
}
|
|
@@ -420,9 +345,8 @@ function tryInlineSourceCall(call, config) {
|
|
|
420
345
|
return stripOuterExpressionList(reconstructFileCode(config.fullAst, targetFile, childConfig));
|
|
421
346
|
}
|
|
422
347
|
// a selected source() that we could not link to a file (dynamic/missing path): keep it verbatim
|
|
423
|
-
if (
|
|
424
|
-
const
|
|
425
|
-
const path = arg !== undefined && arg !== r_function_call_1.EmptyArgument && r_string_1.RString.is(arg.value) ? arg.value.content.str : undefined;
|
|
348
|
+
if (r_function_call_1.RFunctionCall.isNamed(call, 'source')) {
|
|
349
|
+
const path = (0, source_inline_map_1.sourcePathOf)(call);
|
|
426
350
|
config.warnings?.push({ kind: 'unresolved', callId: id, path });
|
|
427
351
|
exports.reconstructLogger.warn(`unresolved source() not inlined at node ${JSON.stringify(id)}: ${JSON.stringify(path)}`);
|
|
428
352
|
}
|
|
@@ -449,7 +373,7 @@ function reconstructFunctionCall(call, functionName, args, configuration) {
|
|
|
449
373
|
return reconstructSpecialInfixFunctionCall(args, call);
|
|
450
374
|
}
|
|
451
375
|
if (call.named && selected) {
|
|
452
|
-
return
|
|
376
|
+
return foldToConst(call);
|
|
453
377
|
}
|
|
454
378
|
if (functionName.length === 0 && args.every(a => a === undefined || a.length === 0)) {
|
|
455
379
|
return [];
|
|
@@ -466,7 +390,7 @@ function reconstructFunctionCall(call, functionName, args, configuration) {
|
|
|
466
390
|
return functionName;
|
|
467
391
|
}
|
|
468
392
|
else {
|
|
469
|
-
return
|
|
393
|
+
return foldToConst(call);
|
|
470
394
|
}
|
|
471
395
|
}
|
|
472
396
|
/** The fold functions used to reconstruct the ast in {@link reconstructToCode}. */
|
|
@@ -17,26 +17,15 @@ function flowrSearchToMermaid(search, conf) {
|
|
|
17
17
|
out.push((0, flowr_search_traverse_1.traverseFlowrSearchBuilderType)(search, ({ type, name, args }) => `${count}("<b>${name}</b>(${argsToMermaidString(args)})<br/>_${type}_")`, (acc, { name, args, type }) => `${acc} --> ${++count}["<b>${name}</b>(${argsToMermaidString(args)})<br/>_${type}_"]`));
|
|
18
18
|
return out.join('\n');
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function argsToString(args, escape) {
|
|
21
21
|
if (args === undefined) {
|
|
22
22
|
return '';
|
|
23
23
|
}
|
|
24
|
-
return Object.entries(args).map(([key, value]) => `${key}: ${(0, flowr_search_filters_1.isBinaryTree)(value) ? '_' +
|
|
25
|
-
: mermaid_1.Mermaid.escape(JSON.stringify(value))}`)
|
|
26
|
-
.join(', ');
|
|
27
|
-
}
|
|
28
|
-
function argsToAsciiString(args) {
|
|
29
|
-
if (args === undefined) {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
else if (Object.keys(args).length === 1) {
|
|
33
|
-
const key = Object.keys(args)[0];
|
|
34
|
-
const value = args[key];
|
|
35
|
-
return `${key}: ${(0, flowr_search_filters_1.isBinaryTree)(value) ? '_' + (0, flowr_search_filters_1.binaryTreeToString)(value.tree) + '_' : JSON.stringify(value)}`;
|
|
36
|
-
}
|
|
37
|
-
return Object.entries(args).map(([key, value]) => `${key}: ${(0, flowr_search_filters_1.isBinaryTree)(value) ? '_' + (0, flowr_search_filters_1.binaryTreeToString)(value.tree) + '_' : JSON.stringify(value)}`)
|
|
24
|
+
return Object.entries(args).map(([key, value]) => `${key}: ${(0, flowr_search_filters_1.isBinaryTree)(value) ? '_' + escape((0, flowr_search_filters_1.binaryTreeToString)(value.tree)) + '_' : escape(JSON.stringify(value))}`)
|
|
38
25
|
.join(', ');
|
|
39
26
|
}
|
|
27
|
+
const argsToMermaidString = (args) => argsToString(args, mermaid_1.Mermaid.escape);
|
|
28
|
+
const argsToAsciiString = (args) => argsToString(args, s => s);
|
|
40
29
|
/**
|
|
41
30
|
* Converts a {@link FlowrSearchLike} object to an ASCII representation.
|
|
42
31
|
*/
|
|
@@ -47,7 +47,7 @@ async function generateGet(input, { filter: { line, column, id, name, nameIsRege
|
|
|
47
47
|
}
|
|
48
48
|
if (line && line < 0) {
|
|
49
49
|
(0, assert_1.guard)(normalize.ast.files.length === 1, 'Currently, negative line numbers are only supported for single-file inputs');
|
|
50
|
-
const maxLines = normalize.ast.files[0].root.info.fullRange
|
|
50
|
+
const maxLines = range_1.SourceRange.getEndLine(normalize.ast.files[0].root.info.fullRange) ??
|
|
51
51
|
(id ? (await getAllNodes(input)) : potentials).reduce((maxLine, { location }) => location && location[2] > maxLine ? location[2] : maxLine, 0);
|
|
52
52
|
line = maxLines + line + 1;
|
|
53
53
|
}
|
|
@@ -5,7 +5,6 @@ const assert_1 = require("../../../util/assert");
|
|
|
5
5
|
const fold_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/fold");
|
|
6
6
|
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
7
7
|
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
|
-
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
9
8
|
exports.DefaultAllVariablesFilter = {
|
|
10
9
|
minimumSize: 1,
|
|
11
10
|
maximumSize: 1,
|
|
@@ -40,7 +39,7 @@ const defaultAllVariablesCollectorFolds = {
|
|
|
40
39
|
foldFunctionCall: (c, a, b) => {
|
|
41
40
|
const args = b.flatMap(b => b !== r_function_call_1.EmptyArgument ? b.flat() : []);
|
|
42
41
|
if (c.named) {
|
|
43
|
-
return
|
|
42
|
+
return r_function_call_1.RFunctionCall.isNamed(c, 'library') ? args.slice(1) : args;
|
|
44
43
|
}
|
|
45
44
|
else {
|
|
46
45
|
return [...a.filter(x => x !== r_function_call_1.EmptyArgument), ...args];
|
|
@@ -7,6 +7,7 @@ exports.envFingerprint = envFingerprint;
|
|
|
7
7
|
exports.fingerprint = fingerprint;
|
|
8
8
|
const object_hash_1 = __importDefault(require("object-hash"));
|
|
9
9
|
const environment_1 = require("../../dataflow/environments/environment");
|
|
10
|
+
const frame_memory_1 = require("../../dataflow/environments/frame-memory");
|
|
10
11
|
const HashOptions = {
|
|
11
12
|
algorithm: 'md5',
|
|
12
13
|
excludeKeys: (key) => key === 'id' || key === 'value',
|
|
@@ -32,15 +33,23 @@ function definitionHash(definition) {
|
|
|
32
33
|
}
|
|
33
34
|
function memoryHash(memory) {
|
|
34
35
|
let hash = memoryHashes.get(memory);
|
|
35
|
-
if (hash
|
|
36
|
+
if (hash !== undefined) {
|
|
37
|
+
return hash;
|
|
38
|
+
}
|
|
39
|
+
const lazy = memory instanceof frame_memory_1.Frame ? memory.lazy() : undefined;
|
|
40
|
+
if (lazy !== undefined) {
|
|
41
|
+
/* an attached package's exports: hashing what they bind would build a definition for every one of them */
|
|
42
|
+
hash = (0, object_hash_1.default)(`${lazy.origin}|${[...lazy.keys()].join(',')}`, HashOptions);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
36
45
|
const entries = [];
|
|
37
46
|
for (const [name, definitions] of memory) {
|
|
38
47
|
entries.push(`${String(name)}=${definitions.map(definitionHash).join(',')}`);
|
|
39
48
|
}
|
|
40
49
|
entries.sort();
|
|
41
50
|
hash = (0, object_hash_1.default)(entries, HashOptions);
|
|
42
|
-
memoryHashes.set(memory, hash);
|
|
43
51
|
}
|
|
52
|
+
memoryHashes.set(memory, hash);
|
|
44
53
|
return hash;
|
|
45
54
|
}
|
|
46
55
|
function frameHash(frame) {
|
|
@@ -3,7 +3,7 @@ import type { VisitingQueue } from './visiting-queue';
|
|
|
3
3
|
import { type Fingerprint } from './fingerprint';
|
|
4
4
|
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
5
5
|
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
6
|
-
import { type DataflowGraph, type
|
|
6
|
+
import { type DataflowGraph, type ReadonlyOutgoingEdges } from '../../dataflow/graph/graph';
|
|
7
7
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import type { DataflowInformation } from '../../dataflow/info';
|
|
9
9
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
@@ -14,12 +14,6 @@ import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/deco
|
|
|
14
14
|
export declare function getAllFunctionCallTargetsForSlice(dataflowGraph: DataflowGraph, callerInfo: DataflowGraphVertexFunctionCall, baseEnvironment: REnvironmentInformation, ctx: ReadOnlyFlowrAnalyzerContext): [ReadonlySet<DataflowGraphVertexInfo>, REnvironmentInformation];
|
|
15
15
|
/** Links the call `callerInfo` to the definitions it resolves to, or to the closures of its arguments if it resolves to none. */
|
|
16
16
|
export declare function sliceForCall(current: NodeToSlice, callerInfo: DataflowGraphVertexFunctionCall, { graph }: DataflowInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): void;
|
|
17
|
-
/**
|
|
18
|
-
* Finds the nearest enclosing function-definition node for the given id by walking up the AST parent chain.
|
|
19
|
-
* Used by `includeCallees` to detect the function-definition boundary a node sits inside, as backward slicing
|
|
20
|
-
* does not otherwise visit the function-definition vertex itself (nothing within the body links to it).
|
|
21
|
-
*/
|
|
22
|
-
export declare function findEnclosingFunctionDefinition(id: NodeId, idMap: AstIdMap): NodeId | undefined;
|
|
23
17
|
/**
|
|
24
18
|
* For `includeCallees`: decides whether the current slice of a function definition's body actually depends on
|
|
25
19
|
* the function's interface, i.e., whether the callers can influence the sliced result at all. This is the case iff
|
|
@@ -38,4 +32,4 @@ export declare function sliceReachesFunctionInterface(fnDefId: NodeId, graph: Da
|
|
|
38
32
|
*/
|
|
39
33
|
export declare function includeCalleesOfDefinition(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, baseEnvironment: REnvironmentInformation, baseEnvFingerprint: Fingerprint): NodeId[];
|
|
40
34
|
/** Returns true if we found at least one return edge */
|
|
41
|
-
export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges:
|
|
35
|
+
export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: ReadonlyOutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllFunctionCallTargetsForSlice = getAllFunctionCallTargetsForSlice;
|
|
4
4
|
exports.sliceForCall = sliceForCall;
|
|
5
|
-
exports.findEnclosingFunctionDefinition = findEnclosingFunctionDefinition;
|
|
6
5
|
exports.sliceReachesFunctionInterface = sliceReachesFunctionInterface;
|
|
7
6
|
exports.includeCalleesOfDefinition = includeCalleesOfDefinition;
|
|
8
7
|
exports.handleReturns = handleReturns;
|
|
@@ -18,12 +17,11 @@ const built_in_function_definition_1 = require("../../dataflow/internal/process/
|
|
|
18
17
|
const static_slicer_1 = require("./static-slicer");
|
|
19
18
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
20
19
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
21
|
-
const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
|
|
22
20
|
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
23
|
-
const
|
|
21
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
24
22
|
const NoCallTargets = new Set();
|
|
25
23
|
const linkedByGraph = new WeakMap();
|
|
26
|
-
function
|
|
24
|
+
function linkedFunctionsOf(defs, graph) {
|
|
27
25
|
let known = linkedByGraph.get(graph);
|
|
28
26
|
if (known === undefined) {
|
|
29
27
|
linkedByGraph.set(graph, known = new Map());
|
|
@@ -43,8 +41,8 @@ function getAllFunctionCallTargetsForSlice(dataflowGraph, callerInfo, baseEnviro
|
|
|
43
41
|
// bind with call-local environments during slicing
|
|
44
42
|
const activeEnvironment = callerInfo.environment === undefined ? baseEnvironment : (0, built_in_function_definition_1.retrieveActiveEnvironment)(callerInfo.environment, baseEnvironment, ctx);
|
|
45
43
|
const resolved = (resolve_helper_1.Resolve.byName(callerInfo.name, activeEnvironment) ?? []).filter(d => !node_id_1.NodeId.isBuiltIn(d.definedAt));
|
|
46
|
-
const functionCallDefs = [...resolved.map(d => d.nodeId), ...
|
|
47
|
-
const functionCallTargets = functionCallDefs.length === 0 ? NoCallTargets :
|
|
44
|
+
const functionCallDefs = [...resolved.map(d => d.nodeId), ...df_helper_1.Dataflow.targetsOf(dataflowGraph, callerInfo.id, edge_1.EdgeType.Calls)];
|
|
45
|
+
const functionCallTargets = functionCallDefs.length === 0 ? NoCallTargets : linkedFunctionsOf(functionCallDefs, dataflowGraph);
|
|
48
46
|
return [functionCallTargets, activeEnvironment];
|
|
49
47
|
}
|
|
50
48
|
function linkCallTargets(onlyForSideEffects, functionCallTargets, activeEnvironment, activeEnvironmentFingerprint, queue) {
|
|
@@ -81,19 +79,11 @@ function sliceForCall(current, callerInfo, { graph }, queue, ctx) {
|
|
|
81
79
|
}
|
|
82
80
|
for (const arg of callerInfo.args) {
|
|
83
81
|
const reference = graph_1.FunctionArgument.getReference(arg);
|
|
84
|
-
if (reference && !
|
|
85
|
-
linkCallTargets(false,
|
|
82
|
+
if (reference && !df_helper_1.Dataflow.hasEdge(graph, callerInfo.id, reference, edge_1.EdgeType.Returns)) {
|
|
83
|
+
linkCallTargets(false, linkedFunctionsOf([reference], graph), activeEnvironment, activeEnvironmentFingerprint, queue);
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Finds the nearest enclosing function-definition node for the given id by walking up the AST parent chain.
|
|
91
|
-
* Used by `includeCallees` to detect the function-definition boundary a node sits inside, as backward slicing
|
|
92
|
-
* does not otherwise visit the function-definition vertex itself (nothing within the body links to it).
|
|
93
|
-
*/
|
|
94
|
-
function findEnclosingFunctionDefinition(id, idMap) {
|
|
95
|
-
return model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
96
|
-
}
|
|
97
87
|
/**
|
|
98
88
|
* For `includeCallees`: decides whether the current slice of a function definition's body actually depends on
|
|
99
89
|
* the function's interface, i.e., whether the callers can influence the sliced result at all. This is the case iff
|
|
@@ -117,7 +107,7 @@ function sliceReachesFunctionInterface(fnDefId, graph, queue, idMap, ctx) {
|
|
|
117
107
|
if (!queue.hasId(bodyId)) {
|
|
118
108
|
continue;
|
|
119
109
|
}
|
|
120
|
-
const captures =
|
|
110
|
+
const captures = df_helper_1.Dataflow.targetsOf(graph, bodyId, edge_1.EdgeType.DefinedByOnCall);
|
|
121
111
|
if (captures.some(target => !node_id_1.NodeId.isBuiltIn(target) && !bodyIds.has(target))) {
|
|
122
112
|
return true;
|
|
123
113
|
}
|
|
@@ -146,7 +136,7 @@ const CalleeBoundaryEdges = edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Calls;
|
|
|
146
136
|
* @returns the enqueued ids
|
|
147
137
|
*/
|
|
148
138
|
function includeCalleesOfDefinition(fnDefId, graph, queue, baseEnvironment, baseEnvFingerprint) {
|
|
149
|
-
const added =
|
|
139
|
+
const added = df_helper_1.Dataflow.sourcesOf(graph, fnDefId, CalleeBoundaryEdges);
|
|
150
140
|
for (const source of added) {
|
|
151
141
|
queue.add(source, baseEnvironment, baseEnvFingerprint, false);
|
|
152
142
|
}
|
|
@@ -10,7 +10,6 @@ const visiting_queue_1 = require("./visiting-queue");
|
|
|
10
10
|
const slice_call_1 = require("./slice-call");
|
|
11
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
12
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
|
-
const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
|
|
14
13
|
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
15
14
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
16
15
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
@@ -46,6 +45,7 @@ function staticSlice(options) {
|
|
|
46
45
|
const basePrint = ctx.env.getCleanEnvFingerprint();
|
|
47
46
|
const queue = new visiting_queue_1.VisitingQueue(options.threshold ?? 75, cache, graph, ctx.gas.scope(options.gas), [emptyEnv, basePrint]);
|
|
48
47
|
const enclosingHandled = new Set();
|
|
48
|
+
const missesSeeds = sliceGraph === undefined ? outsideSeedRun(ids, idMap, direction, graph) : undefined;
|
|
49
49
|
const enqueue = (id, env, print) => {
|
|
50
50
|
if (!queue.hasId(id)) {
|
|
51
51
|
queue.add(id, env, print, true);
|
|
@@ -86,8 +86,12 @@ function staticSlice(options) {
|
|
|
86
86
|
exports.slicerLogger.warn(`id: ${id} must be in graph but can not be found, keep in slice to be sure`);
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const [currentVertex,
|
|
89
|
+
const [currentVertex, allEdges] = currentInfo;
|
|
90
90
|
const strictlyEnclosing = model_1.RNode.strictlyEnclosingFunction(id, idMap);
|
|
91
|
+
/* code in a function links to what it meets at all its calls, so also to what cannot meet the seeds; forward,
|
|
92
|
+
a function links to all its calls, and none running before the seeds can */
|
|
93
|
+
const currentEdges = missesSeeds !== undefined && (strictlyEnclosing !== undefined || direction === slice_direction_1.SliceDirection.Forward)
|
|
94
|
+
? withoutMissed(allEdges, missesSeeds) : allEdges;
|
|
91
95
|
if (!enclosingHandled.has(strictlyEnclosing)) {
|
|
92
96
|
enclosingHandled.add(strictlyEnclosing);
|
|
93
97
|
definitionWithHolders(strictlyEnclosing, idMap, graph, trackCallees ? undefined : openedBodies).forEach(outer => enqueue(outer, emptyEnv, basePrint));
|
|
@@ -121,6 +125,12 @@ function staticSlice(options) {
|
|
|
121
125
|
if (vertex_1.DfgVertex.isFunctionCall(currentVertex)) {
|
|
122
126
|
(0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
|
|
123
127
|
}
|
|
128
|
+
/* forward, a definition a call hands to a read in its body has both edges itself */
|
|
129
|
+
if (direction === slice_direction_1.SliceDirection.Forward) {
|
|
130
|
+
for (const target of handedOnCall(currentEdges)) {
|
|
131
|
+
queue.add(target, baseEnvironment, baseEnvFingerprint, false);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
124
134
|
if (!onlyForSideEffects && (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment)) {
|
|
125
135
|
return;
|
|
126
136
|
}
|
|
@@ -158,6 +168,71 @@ function staticSlice(options) {
|
|
|
158
168
|
const result = ctx.config.solver.slicer?.autoExtend ? extendSlices(status.result, idMap) : status.result;
|
|
159
169
|
return { ...status, slicedFor: ids, result, freeNames: freeNamesOf(result, info.graph) };
|
|
160
170
|
}
|
|
171
|
+
/** The `edges` without those to what `misses` names. */
|
|
172
|
+
function withoutMissed(edges, misses) {
|
|
173
|
+
for (const [target] of edges) {
|
|
174
|
+
if (misses(target)) {
|
|
175
|
+
return new Map([...edges].filter(([t]) => !misses(t)));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return edges;
|
|
179
|
+
}
|
|
180
|
+
/** The calls handing a definition over and the reads it is handed to, if its edges have both. */
|
|
181
|
+
function handedOnCall(edges) {
|
|
182
|
+
let defines = false;
|
|
183
|
+
let definedBy = false;
|
|
184
|
+
const targets = [];
|
|
185
|
+
for (const [target, e] of edges) {
|
|
186
|
+
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinesOnCall)) {
|
|
187
|
+
defines = true;
|
|
188
|
+
targets.push(target);
|
|
189
|
+
}
|
|
190
|
+
else if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.DefinedByOnCall)) {
|
|
191
|
+
definedBy = true;
|
|
192
|
+
targets.push(target);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return defines && definedBy ? targets : [];
|
|
196
|
+
}
|
|
197
|
+
/** The top-level statement `id` is part of, as its file root and its index there. */
|
|
198
|
+
function topLevelStatement(id, idMap) {
|
|
199
|
+
let node = idMap.get(id);
|
|
200
|
+
for (let parent = node && model_1.RNode.directParent(node, idMap); node !== undefined && parent !== undefined; node = parent, parent = model_1.RNode.directParent(parent, idMap)) {
|
|
201
|
+
if (parent.info.parent === undefined) {
|
|
202
|
+
return [parent.info.id, node.info.index];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Whether a node cannot meet the seeds: backward, it runs only after them, as its top-level statement follows
|
|
209
|
+
* theirs; forward, it is a call running only before them, outside of any function. `undefined` if a seed is in a
|
|
210
|
+
* function, which may run any time.
|
|
211
|
+
*/
|
|
212
|
+
function outsideSeedRun(ids, idMap, direction, graph) {
|
|
213
|
+
const backward = direction === slice_direction_1.SliceDirection.Backward;
|
|
214
|
+
const bounds = new Map();
|
|
215
|
+
for (const id of ids) {
|
|
216
|
+
const at = topLevelStatement(id, idMap);
|
|
217
|
+
if (at === undefined || model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is) !== undefined) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
const bound = bounds.get(at[0]) ?? at[1];
|
|
221
|
+
bounds.set(at[0], backward ? Math.max(bound, at[1]) : Math.min(bound, at[1]));
|
|
222
|
+
}
|
|
223
|
+
const known = new Map();
|
|
224
|
+
return id => {
|
|
225
|
+
let misses = known.get(id);
|
|
226
|
+
if (misses === undefined) {
|
|
227
|
+
const at = topLevelStatement(id, idMap);
|
|
228
|
+
const bound = at === undefined ? undefined : bounds.get(at[0]);
|
|
229
|
+
misses = at !== undefined && bound !== undefined && (backward ? at[1] > bound
|
|
230
|
+
: at[1] < bound && vertex_1.DfgVertex.isFunctionCall(graph.getVertex(id)) && model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is) === undefined);
|
|
231
|
+
known.set(id, misses);
|
|
232
|
+
}
|
|
233
|
+
return misses;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
161
236
|
/** The calls writing output (`cat`, `print`, ...: a side effect linked to `sink`) within the functions the call `seeds` run, transitively. */
|
|
162
237
|
function outputWithinCallees(seeds, graph) {
|
|
163
238
|
const writers = new Set();
|
|
@@ -173,11 +248,11 @@ function outputWithinCallees(seeds, graph) {
|
|
|
173
248
|
const seen = new Set();
|
|
174
249
|
const calls = [...seeds].filter(id => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(id)));
|
|
175
250
|
while (calls.length > 0) {
|
|
176
|
-
for (const target of
|
|
251
|
+
for (const target of df_helper_1.Dataflow.calleeIdsOf(graph, calls.pop()).filter(t => !seen.has(t))) {
|
|
177
252
|
seen.add(target);
|
|
178
253
|
const callee = graph.getVertex(target);
|
|
179
254
|
found.push(...[...callee.subflow.graph].filter(inner => writers.has(inner)));
|
|
180
|
-
calls.push(...[...
|
|
255
|
+
calls.push(...[...df_helper_1.Dataflow.callsIn(callee, graph)].map(([inner]) => inner));
|
|
181
256
|
}
|
|
182
257
|
}
|
|
183
258
|
return found;
|
|
@@ -194,7 +269,7 @@ function definitionWithHolders(definition, idMap, graph, opened) {
|
|
|
194
269
|
const outer = [definitionNode.info.id];
|
|
195
270
|
for (const node of model_1.RNode.iterateParents(definitionNode, idMap)) {
|
|
196
271
|
if (r_function_definition_1.RFunctionDefinition.is(node) || (r_expression_list_1.RExpressionList.is(node) && node.grouping?.[0].lexeme !== '(')
|
|
197
|
-
|| (opened !== undefined && r_argument_1.RArgument.is(node) && (opened.has(definitionNode.info.id) ||
|
|
272
|
+
|| (opened !== undefined && r_argument_1.RArgument.is(node) && (opened.has(definitionNode.info.id) || df_helper_1.Dataflow.targetsOf(graph, node.info.parent ?? '', edge_1.EdgeType.Calls).some(fn => opened.has(fn))))) {
|
|
198
273
|
break;
|
|
199
274
|
}
|
|
200
275
|
if (graph.hasVertex(node.info.id)) {
|
|
@@ -214,7 +289,7 @@ function freeNamesOf(slice, graph) {
|
|
|
214
289
|
if (!vertex_1.DfgVertex.isUse(graph.getVertex(id))) {
|
|
215
290
|
continue;
|
|
216
291
|
}
|
|
217
|
-
const defined =
|
|
292
|
+
const defined = df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads).some(t => slice.has(t) || node_id_1.NodeId.isBuiltIn(t));
|
|
218
293
|
const name = defined ? undefined : node_id_1.NodeId.recoverName(id, graph.idMap);
|
|
219
294
|
if (name !== undefined) {
|
|
220
295
|
free.add(name);
|
|
@@ -204,7 +204,7 @@ function cartesianProduct(...arrays) {
|
|
|
204
204
|
}
|
|
205
205
|
/** merge two arrays, removing duplicates */
|
|
206
206
|
function uniqueArrayMerge(left, right) {
|
|
207
|
-
return
|
|
207
|
+
return uniqueArray([...left, ...right]);
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* Returns a duplicate-free array.
|
package/util/collections/set.js
CHANGED