@eagleoutice/flowr 2.17.5 → 2.17.6
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 +13 -51
- package/abstract-interpretation/absint-inference.d.ts +4 -4
- package/abstract-interpretation/absint-inference.js +11 -11
- package/abstract-interpretation/abstract-semantics.d.ts +2 -1
- package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
- package/abstract-interpretation/branch-paths-interpreter.js +60 -0
- package/abstract-interpretation/branch-paths.d.ts +60 -0
- package/abstract-interpretation/branch-paths.js +120 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +6 -1
- package/abstract-interpretation/data-frame/dataframe-semantics.js +60 -1
- package/abstract-interpretation/data-frame/semantics.js +4 -10
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/cli/repl/core.js +51 -0
- package/control-flow/cfg-dead-code.js +12 -7
- package/data/packed.d.ts +10 -0
- package/data/packed.js +33 -0
- package/data/r-base-guards.generated.d.ts +7 -0
- package/data/r-base-guards.generated.js +12 -0
- package/data/r-datasets.generated.d.ts +4 -0
- package/data/r-datasets.generated.js +10 -0
- package/data/r-formals.generated.d.ts +4 -0
- package/data/r-formals.generated.js +10 -0
- package/data/r-group-method-guards.generated.d.ts +3 -0
- package/data/r-group-method-guards.generated.js +8 -0
- package/dataflow/environments/ambient-effect.d.ts +1000 -0
- package/dataflow/environments/ambient-effect.js +234 -0
- package/dataflow/environments/ambient-state-name.d.ts +45 -2
- package/dataflow/environments/ambient-state-name.js +61 -3
- package/dataflow/environments/apply-kill.js +11 -4
- package/dataflow/environments/built-in-kinds.d.ts +4 -46
- package/dataflow/environments/built-in-kinds.js +6 -2
- package/dataflow/environments/built-in-props.d.ts +16 -4
- package/dataflow/environments/built-in-props.js +11 -3
- package/dataflow/environments/built-in.d.ts +6 -1
- package/dataflow/environments/built-in.js +13 -36
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +110 -52
- package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-language.js +11 -8
- package/dataflow/environments/default-builtin-config/dev-tooling.js +1 -1
- package/dataflow/environments/default-builtin-config/file-io.js +6 -4
- package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/graphics-devices.js +24 -14
- package/dataflow/environments/default-builtin-config/guard-builders.d.ts +16 -0
- package/dataflow/environments/default-builtin-config/guard-builders.js +29 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
- package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
- package/dataflow/environments/default-builtin-config/guards.js +211 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +3 -3
- package/dataflow/environments/default-builtin-config/index.js +22 -7
- package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
- package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
- package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
- package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/package-utils.js +5 -2
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
- package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
- package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
- package/dataflow/environments/default-builtin-config/shared-configs.d.ts +138 -77
- package/dataflow/environments/default-builtin-config/shared-configs.js +52 -88
- package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/statistics.js +4 -1
- package/dataflow/environments/diff.js +5 -2
- package/dataflow/environments/environment.d.ts +20 -0
- package/dataflow/environments/environment.js +39 -4
- package/dataflow/environments/group-generics.d.ts +5 -1
- package/dataflow/environments/group-generics.js +13 -3
- package/dataflow/environments/guard-facts.d.ts +169 -0
- package/dataflow/environments/guard-facts.js +26 -0
- package/dataflow/environments/identifier.d.ts +9 -1
- package/dataflow/environments/identifier.js +5 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -5
- package/dataflow/environments/query-fn-props.js +44 -21
- package/dataflow/environments/removal-marker.d.ts +2 -0
- package/dataflow/environments/removal-marker.js +5 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/extractor.js +24 -15
- package/dataflow/fn/condition-handlers.d.ts +2 -0
- package/dataflow/fn/condition-handlers.js +3 -1
- package/dataflow/fn/frame-reflection.d.ts +4 -2
- package/dataflow/fn/frame-reflection.js +16 -0
- package/dataflow/fn/function-props.js +15 -22
- package/dataflow/fn/function-semantics.d.ts +31 -1
- package/dataflow/fn/function-semantics.js +15 -0
- package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
- package/dataflow/fn/guards/built-in-guards.js +199 -0
- package/dataflow/fn/guards/call-contracts.d.ts +97 -0
- package/dataflow/fn/guards/call-contracts.js +331 -0
- package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
- package/dataflow/fn/guards/condition-grouping.js +135 -0
- package/dataflow/fn/guards/function-guards.d.ts +112 -0
- package/dataflow/fn/guards/function-guards.js +1549 -0
- package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
- package/dataflow/fn/guards/group-method-guards.js +56 -0
- package/dataflow/fn/guards/guard-claims.d.ts +125 -0
- package/dataflow/fn/guards/guard-claims.js +678 -0
- package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
- package/dataflow/fn/guards/guard-knowledge.js +180 -0
- package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
- package/dataflow/fn/guards/guard-term-syntax.js +210 -0
- package/dataflow/fn/guards/guard-term.d.ts +136 -0
- package/dataflow/fn/guards/guard-term.js +550 -0
- package/dataflow/fn/guards/stated-guards.d.ts +13 -0
- package/dataflow/fn/guards/stated-guards.js +35 -0
- package/dataflow/fn/higher-order-function.d.ts +2 -0
- package/dataflow/fn/higher-order-function.js +1 -0
- package/dataflow/fn/strict-function.d.ts +4 -0
- package/dataflow/fn/strict-function.js +66 -17
- package/dataflow/graph/ambient-access.d.ts +4 -1
- package/dataflow/graph/ambient-access.js +8 -2
- package/dataflow/graph/closure-frames.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +15 -0
- package/dataflow/graph/graph.d.ts +12 -6
- package/dataflow/graph/graph.js +21 -28
- package/dataflow/info.d.ts +2 -1
- package/dataflow/info.js +3 -1
- package/dataflow/internal/dispatch-linking.d.ts +3 -1
- package/dataflow/internal/dispatch-linking.js +1 -0
- package/dataflow/internal/linker.d.ts +2 -0
- package/dataflow/internal/linker.js +115 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -57
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +471 -295
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +13 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +106 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +24 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +33 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +23 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +347 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +110 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +28 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +16 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +37 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +55 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +64 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +160 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +142 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +23 -4
- package/dataflow/processor.d.ts +2 -0
- package/documentation/data/dfg/doc-ambient.d.ts +4 -0
- package/documentation/data/dfg/doc-ambient.js +74 -0
- package/documentation/wiki-dataflow-graph.js +10 -4
- package/documentation/wiki-linter.js +12 -0
- package/documentation/wiki-query.js +112 -1
- package/linter/linter-rules.d.ts +41 -1
- package/linter/linter-rules.js +5 -1
- package/linter/rules/call-contracts.d.ts +40 -0
- package/linter/rules/call-contracts.js +56 -0
- package/linter/rules/cmd-check/bogus-return.js +1 -1
- package/linter/rules/cmd-check/call-arguments.js +5 -6
- package/linter/rules/cmd-check/cmd-check-util.d.ts +0 -6
- package/linter/rules/cmd-check/cmd-check-util.js +0 -28
- package/linter/rules/cmd-check/package-hooks.js +2 -1
- package/linter/rules/cmd-check/s-three-method-consistency.js +1 -1
- package/linter/rules/interactive-functions.d.ts +30 -0
- package/linter/rules/interactive-functions.js +87 -0
- package/linter/rules/process-state-in-session.js +1 -1
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +8 -2
- package/linter/rules/undefined-symbol.js +18 -7
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/context/flowr-analyzer-dependencies-context.js +2 -1
- package/project/flowr-analyzer.d.ts +1 -0
- package/project/flowr-analyzer.js +5 -5
- package/project/sigdb/build.js +14 -4
- package/project/sigdb/decode.d.ts +3 -0
- package/project/sigdb/decode.js +10 -1
- package/project/sigdb/guarded-source.d.ts +6 -0
- package/project/sigdb/guarded-source.js +29 -0
- package/project/sigdb/reader.d.ts +5 -0
- package/project/sigdb/reader.js +27 -1
- package/project/sigdb/schema.d.ts +24 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +6 -3
- package/queries/catalog/absint-query/absint-query-format.js +57 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +6 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.js +48 -3
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +19 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +5 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.js +34 -2
- package/queries/catalog/config-query/config-query-format.d.ts +5 -2
- package/queries/catalog/config-query/config-query-format.js +41 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.js +19 -2
- package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +72 -0
- package/queries/catalog/data-columns-query/data-columns-query-format.js +215 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +38 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +18 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +8 -3
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
- package/queries/catalog/dependencies-query/function-info/tagged-functions.js +18 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
- package/queries/catalog/dice-query/dice-query-format.js +34 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -4
- package/queries/catalog/does-call-query/does-call-query-format.js +114 -2
- package/queries/catalog/files-query/files-query-format.d.ts +5 -2
- package/queries/catalog/files-query/files-query-format.js +45 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +6 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +303 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.js +37 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +18 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +5 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +29 -2
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +125 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +54 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +23 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +15 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +8 -2
- package/queries/catalog/linter-query/linter-query-format.js +69 -4
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
- package/queries/catalog/location-map-query/location-map-query-format.js +70 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +18 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +6 -3
- package/queries/catalog/origin-query/origin-query-format.js +29 -2
- package/queries/catalog/project-query/project-query-format.d.ts +6 -3
- package/queries/catalog/project-query/project-query-format.js +98 -2
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +6 -3
- package/queries/catalog/provenance-query/provenance-query-format.js +30 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +9 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +38 -2
- package/queries/catalog/search-query/search-query-format.d.ts +5 -2
- package/queries/catalog/search-query/search-query-format.js +23 -2
- package/queries/catalog/signature-query/signature-query-executor.js +3 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
- package/queries/catalog/signature-query/signature-query-render.js +23 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +55 -2
- package/queries/catalog/taint-query/taint-query-format.d.ts +6 -3
- package/queries/catalog/taint-query/taint-query-format.js +28 -2
- package/queries/query.d.ts +48 -27
- package/queries/query.js +6 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -0
- package/r-bridge/shell.js +7 -2
- package/reconstruct/reconstruct.js +18 -3
- package/slicing/static/removal-slice.js +4 -3
- package/slicing/static/slice-call.d.ts +11 -0
- package/slicing/static/slice-call.js +43 -2
- package/slicing/static/static-slicer.d.ts +2 -0
- package/slicing/static/static-slicer.js +137 -21
- package/slicing/static/visiting-queue.d.ts +2 -0
- package/slicing/static/visiting-queue.js +4 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +2 -0
- package/util/objects.js +5 -0
- package/util/r-datasets.d.ts +27 -0
- package/util/r-datasets.js +45 -0
- package/util/text/playground-link.d.ts +2 -0
- package/util/text/playground-link.js +2 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
- package/queries/catalog/absint-query/absint-query-executor.js +0 -61
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
- package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
- package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
- package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
- package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
- package/queries/catalog/config-query/config-query-executor.js +0 -45
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
- package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
- package/queries/catalog/dice-query/dice-query-executor.js +0 -37
- package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
- package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
- package/queries/catalog/files-query/files-query-executor.js +0 -47
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
- package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
- package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
- package/queries/catalog/linter-query/linter-query-executor.js +0 -62
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
- package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
- package/queries/catalog/origin-query/origin-query-executor.js +0 -31
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
- package/queries/catalog/project-query/project-query-executor.js +0 -103
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
- package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
- package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
- package/queries/catalog/search-query/search-query-executor.js +0 -25
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
- package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
- package/queries/catalog/taint-query/taint-query-executor.js +0 -30
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printMethodsOf = printMethodsOf;
|
|
4
|
+
exports.noteOwnMethod = noteOwnMethod;
|
|
5
|
+
exports.noteUnknownMethods = noteUnknownMethods;
|
|
6
|
+
exports.bindsUnknownNames = bindsUnknownNames;
|
|
7
|
+
exports.cannotBeFunction = cannotBeFunction;
|
|
3
8
|
exports.processExpressionList = processExpressionList;
|
|
4
9
|
const info_1 = require("../../../../../info");
|
|
5
10
|
const processor_1 = require("../../../../../processor");
|
|
@@ -8,13 +13,16 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
8
13
|
const common_1 = require("../common");
|
|
9
14
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
10
15
|
const built_in_library_1 = require("./built-in-library");
|
|
16
|
+
const r_base_packages_1 = require("../../../../../../util/r-base-packages");
|
|
11
17
|
const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
|
|
12
18
|
const graph_1 = require("../../../../../graph/graph");
|
|
19
|
+
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
13
20
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
14
21
|
const edge_1 = require("../../../../../graph/edge");
|
|
15
22
|
const control_flow_1 = require("../../../../control-flow");
|
|
16
23
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
17
24
|
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
25
|
+
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
18
26
|
const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
|
|
19
27
|
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
20
28
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
@@ -24,19 +32,20 @@ const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
|
24
32
|
const built_in_deferred_env_ops_1 = require("./built-in-deferred-env-ops");
|
|
25
33
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
26
34
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
27
|
-
const r_expression_list_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
28
|
-
const r_if_then_else_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
|
|
29
|
-
const r_while_loop_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-while-loop");
|
|
30
|
-
const r_for_loop_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop");
|
|
31
35
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
32
36
|
const defaultmap_1 = require("../../../../../../util/collections/defaultmap");
|
|
33
37
|
const objects_1 = require("../../../../../../util/objects");
|
|
34
38
|
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
35
39
|
const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
|
|
36
40
|
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
41
|
+
const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
42
|
+
const guard_facts_1 = require("../../../../../environments/guard-facts");
|
|
37
43
|
const dispatch_1 = require("../../../../../fn/dispatch");
|
|
38
44
|
const dispatch_linking_1 = require("../../../../dispatch-linking");
|
|
39
45
|
const environment_1 = require("../../../../../environments/environment");
|
|
46
|
+
const group_generics_1 = require("../../../../../environments/group-generics");
|
|
47
|
+
const default_builtin_config_1 = require("../../../../../environments/default-builtin-config");
|
|
48
|
+
const built_in_props_1 = require("../../../../../environments/built-in-props");
|
|
40
49
|
/** Whether the definitions of this list among the `targets` of a read cover every branch, alone or together. */
|
|
41
50
|
function coveredByListDefinitions(targets, listEnvironments) {
|
|
42
51
|
const own = targets.filter(t => listEnvironments.has(t.nodeId));
|
|
@@ -45,6 +54,189 @@ function coveredByListDefinitions(targets, listEnvironments) {
|
|
|
45
54
|
}
|
|
46
55
|
return own.length > 0 && (0, info_1.happensInEveryBranch)(own.flatMap(t => t.cds ?? []));
|
|
47
56
|
}
|
|
57
|
+
/** The functions an active binding (`makeActiveBinding`) bound by `target` runs, the binding itself or the call making it. */
|
|
58
|
+
function activeFunctionsOf(target, graph) {
|
|
59
|
+
const bindings = vertex_2.DfgVertex.isFunctionCall(graph.getVertex(target)) ? df_helper_1.Dataflow.sourcesOf(graph, target, edge_1.EdgeType.DefinedBy) : [target];
|
|
60
|
+
return bindings.flatMap(b => vertex_2.DfgVertex.isVariableDefinition(graph.getVertex(b)) ? df_helper_1.Dataflow.targetsOf(graph, b, edge_1.EdgeType.Calls) : [])
|
|
61
|
+
.filter(fn => vertex_2.DfgVertex.isFunctionDefinition(graph.getVertex(fn)));
|
|
62
|
+
}
|
|
63
|
+
/** The active bindings of an environment the name `holder` held that the expression assigns to (`e$s <- v`, `e[["s"]] <- v`, `assign("s", v, envir = e)`), with the call assigning and the functions each runs. */
|
|
64
|
+
function writtenActiveFields(holder, before, after, graph) {
|
|
65
|
+
const states = (env) => (resolve_helper_1.Resolve.byName(holder, env) ?? []).map(d => d.envState?.current).filter(assert_1.isNotUndefined);
|
|
66
|
+
const olds = states(before);
|
|
67
|
+
const fields = [];
|
|
68
|
+
for (const now of olds.length === 0 ? [] : states(after).filter(n => !olds.includes(n))) {
|
|
69
|
+
for (const [name, defs] of now.memory) {
|
|
70
|
+
const replaced = olds.flatMap(o => o.lookup(name) ?? []);
|
|
71
|
+
const added = defs.filter(d => !replaced.some(b => b.nodeId === d.nodeId) && !node_id_1.NodeId.isBuiltIn(d.definedAt));
|
|
72
|
+
for (const b of added.length > 0 ? replaced : []) {
|
|
73
|
+
const fns = activeFunctionsOf(b.nodeId, graph);
|
|
74
|
+
for (const d of fns.length > 0 ? added : []) {
|
|
75
|
+
fields.push([d.definedAt, b.nodeId, fns]);
|
|
76
|
+
/* the binding stays active, so the next access runs it again */
|
|
77
|
+
for (const fn of fns) {
|
|
78
|
+
graph.addEdge(d.nodeId, fn, edge_1.EdgeType.Calls);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return fields;
|
|
85
|
+
}
|
|
86
|
+
/** Every access of an active binding runs its function, whether through an environment (`e$ab`, `get("ab", e)`, `as.list(e)`) or by assigning to it (`ab <- 2`): a read becomes a call of it, as one of the list does (see `activeReads`), the calls accessing it call it too and are handed back. */
|
|
87
|
+
function callActiveBindingsAccessed(processed, before, graph, activeReads) {
|
|
88
|
+
const calls = [];
|
|
89
|
+
const readIds = new Set(activeReads.map(r => r.nodeId));
|
|
90
|
+
const call = (id, fns, binding) => {
|
|
91
|
+
const vertex = graph.getVertex(id);
|
|
92
|
+
if (vertex_2.DfgVertex.isUse(vertex)) {
|
|
93
|
+
const node = graph.idMap?.get(id);
|
|
94
|
+
if (!readIds.has(id) && node !== undefined && r_symbol_1.RSymbol.is(node)) {
|
|
95
|
+
readIds.add(id);
|
|
96
|
+
activeReads.push({ nodeId: id, name: node.content, cds: vertex.cds, type: identifier_1.ReferenceType.Variable });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (vertex_2.DfgVertex.isFunctionCall(vertex) && !fns.every(fn => df_helper_1.Dataflow.hasEdge(graph, id, fn, edge_1.EdgeType.Calls))) {
|
|
100
|
+
graph.addEdge(id, binding, edge_1.EdgeType.Reads);
|
|
101
|
+
for (const fn of fns) {
|
|
102
|
+
const definition = graph.getVertex(fn);
|
|
103
|
+
if (vertex_2.DfgVertex.isFunctionDefinition(definition) && graph.idMap !== undefined) {
|
|
104
|
+
/* an access is no call of its own, so the binding's function sees what is bound where the access is */
|
|
105
|
+
(0, linker_1.linkFunctionCallWithSingleTarget)(graph, definition, { ...vertex, environment: vertex.environment ?? before }, graph.idMap);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
calls.push(id);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
for (const [id] of processed.graph.vertices(true)) {
|
|
112
|
+
for (const target of df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads)) {
|
|
113
|
+
const fns = activeFunctionsOf(target, graph);
|
|
114
|
+
if (fns.length > 0) {
|
|
115
|
+
call(id, fns, target);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
for (const written of processed.out) {
|
|
120
|
+
const bound = written.name === undefined || !('definedAt' in written) ? [] : resolve_helper_1.Resolve.byName(written.name, before) ?? [];
|
|
121
|
+
for (const binding of bound) {
|
|
122
|
+
const fns = binding.nodeId === written.nodeId ? [] : activeFunctionsOf(binding.nodeId, graph);
|
|
123
|
+
if (fns.length > 0) {
|
|
124
|
+
call(written.definedAt, fns, binding.nodeId);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/* the environment is named where it is written or read, `assign("s", v, envir = e)` only reads `e` */
|
|
129
|
+
const used = processed.graph.vertexIdsOfType(vertex_1.VertexType.Use).map(id => graph.idMap?.get(id)).filter(r_symbol_1.RSymbol.is).map(s => s.content);
|
|
130
|
+
const holders = new Set([...processed.out.map(r => r.name).filter(assert_1.isNotUndefined), ...used].map(identifier_1.Identifier.getName));
|
|
131
|
+
for (const holder of holders) {
|
|
132
|
+
for (const [at, field, fns] of writtenActiveFields(holder, before, processed.environment, graph)) {
|
|
133
|
+
call(at, fns, field);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return calls;
|
|
137
|
+
}
|
|
138
|
+
/** A call handing an environment to a function reading it accesses the environment's active bindings, which only linking the call shows: `f <- function(env) env$a; f(e)`, as does a call of a function reading one it sees: `f <- function() ab; f()`. */
|
|
139
|
+
function bindingsCalledThroughCallees(processed, before, graph, known, linked) {
|
|
140
|
+
if (!(0, built_in_ambient_state_1.mayForce)(before)) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
const read = linked.flatMap(({ functionCall, called }) => [...transitivelyCalledDefinitions(called, graph, before)].flatMap(({ fn }) => activeBindingsReadIn(fn, functionCall, before, graph)));
|
|
144
|
+
return read.concat(callActiveBindingsAccessed(processed, before, graph, []).filter(id => !known.includes(id)).map(functionCall => {
|
|
145
|
+
const fns = new Set(df_helper_1.Dataflow.targetsOf(graph, functionCall, edge_1.EdgeType.Reads).flatMap(t => activeFunctionsOf(t, graph)));
|
|
146
|
+
for (const callee of df_helper_1.Dataflow.calleeIdsOf(graph, functionCall).filter(c => !fns.has(c))) {
|
|
147
|
+
readAccessesOfParameters(functionCall, graph.getVertex(callee), graph);
|
|
148
|
+
}
|
|
149
|
+
const called = [...fns].map(fn => graph.getVertex(fn)).filter(v => vertex_2.DfgVertex.isFunctionDefinition(v));
|
|
150
|
+
return { functionCall, called, propagateExitPoints: [] };
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
/** The active bindings the calls `linked` access through the environments their callees read or write once the calls ran those operations (see {@link instantiateEnvOps}): `g <- function(env) assign("s", 3, envir = env); g(e)`. */
|
|
154
|
+
function bindingsAccessedByEnvOps(linked, processed, before, after, graph) {
|
|
155
|
+
const found = [];
|
|
156
|
+
const runs = (functionCall, binding, fns, access) => {
|
|
157
|
+
graph.addEdge(functionCall, binding, edge_1.EdgeType.Reads);
|
|
158
|
+
if (access !== undefined) {
|
|
159
|
+
graph.addEdge(functionCall, access, edge_1.EdgeType.Reads);
|
|
160
|
+
}
|
|
161
|
+
found.push({ functionCall, called: fns.map(f => graph.getVertex(f)).filter(v => vertex_2.DfgVertex.isFunctionDefinition(v)), propagateExitPoints: [], alternatives: true });
|
|
162
|
+
};
|
|
163
|
+
for (const { functionCall, called } of linked) {
|
|
164
|
+
for (const { fn } of transitivelyCalledDefinitions(called, graph, before)) {
|
|
165
|
+
for (const op of fn.envOps?.filter(o => o.kind === vertex_1.EnvOpKind.Read) ?? []) {
|
|
166
|
+
for (const binding of df_helper_1.Dataflow.targetsOf(graph, op.id, edge_1.EdgeType.Reads)) {
|
|
167
|
+
const fns = activeFunctionsOf(binding, graph);
|
|
168
|
+
if (fns.length > 0) {
|
|
169
|
+
runs(functionCall, binding, fns, op.id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const used = new Set(processed.graph.vertexIdsOfType(vertex_1.VertexType.Use).map(id => graph.idMap?.get(id)).filter(r_symbol_1.RSymbol.is).map(s => identifier_1.Identifier.getName(s.content)));
|
|
176
|
+
for (const holder of used) {
|
|
177
|
+
for (const [at, field, fns] of writtenActiveFields(holder, before, after, graph)) {
|
|
178
|
+
runs(at, field, fns);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return found;
|
|
182
|
+
}
|
|
183
|
+
/** The active bindings the body of `fn` reads, which the call `functionCall` running it runs: those its reads are linked to, and those its free reads see where the call is (`environment`). */
|
|
184
|
+
function activeBindingsReadIn(fn, functionCall, environment, graph) {
|
|
185
|
+
const found = [];
|
|
186
|
+
const read = (id, binding) => {
|
|
187
|
+
const called = activeFunctionsOf(binding, graph).map(f => graph.getVertex(f)).filter(v => vertex_2.DfgVertex.isFunctionDefinition(v));
|
|
188
|
+
if (called.length > 0) {
|
|
189
|
+
/* the access runs the binding only as the call does */
|
|
190
|
+
graph.addEdge(functionCall, binding, edge_1.EdgeType.Reads);
|
|
191
|
+
graph.addEdge(functionCall, id, edge_1.EdgeType.Reads);
|
|
192
|
+
/* the body may not reach the access */
|
|
193
|
+
found.push({ functionCall, called, propagateExitPoints: [], alternatives: true });
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
for (const id of fn.subflow.graph) {
|
|
197
|
+
/* a free read of the body is bound where the function is called */
|
|
198
|
+
const bindings = df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall);
|
|
199
|
+
for (const binding of bindings) {
|
|
200
|
+
read(id, binding);
|
|
201
|
+
}
|
|
202
|
+
/* one the call of a function around the body is left to resolve (see `linkLiftedReads`) is read there, with the field it accesses */
|
|
203
|
+
const name = bindings.length === 0 && vertex_2.DfgVertex.isUse(graph.getVertex(id)) && graph.idMap !== undefined ? node_id_1.NodeId.recoverBareName(id, graph.idMap) : undefined;
|
|
204
|
+
for (const holder of name === undefined ? [] : resolve_helper_1.Resolve.byName(name, environment) ?? []) {
|
|
205
|
+
read(id, holder.nodeId);
|
|
206
|
+
if ((0, identifier_1.hasEnvState)(holder) && graph.idMap !== undefined) {
|
|
207
|
+
(0, linker_1.bindAccessedField)(graph, id, holder.envState, graph.idMap, functionCall);
|
|
208
|
+
const node = graph.idMap.get(id);
|
|
209
|
+
const access = node === undefined ? undefined : model_1.RNode.directParent(node, graph.idMap)?.info.id;
|
|
210
|
+
df_helper_1.Dataflow.targetsOf(graph, access ?? id, edge_1.EdgeType.Reads).forEach(field => read(id, field));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
for (const ref of fn.subflow.in) {
|
|
215
|
+
for (const binding of ref.name === undefined ? [] : resolve_helper_1.Resolve.byName(ref.name, environment) ?? []) {
|
|
216
|
+
read(ref.nodeId, binding.nodeId);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return found;
|
|
220
|
+
}
|
|
221
|
+
/** The call `call` runs the accesses of `callee` to what its parameters hold: `env$a` and `get(n, envir = env)` for the parameter `env`. */
|
|
222
|
+
function readAccessesOfParameters(call, callee, graph) {
|
|
223
|
+
const idMap = graph.idMap;
|
|
224
|
+
if (!vertex_2.DfgVertex.isFunctionDefinition(callee) || idMap === undefined) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
for (const param of Object.keys(callee.params)) {
|
|
228
|
+
for (const reader of df_helper_1.Dataflow.sourcesOf(graph, node_id_1.NodeId.normalize(param), edge_1.EdgeType.Reads)) {
|
|
229
|
+
const node = idMap.get(reader);
|
|
230
|
+
let access = node && model_1.RNode.directParent(node, idMap);
|
|
231
|
+
if (access !== undefined && r_argument_1.RArgument.is(access)) {
|
|
232
|
+
access = model_1.RNode.directParent(access, idMap);
|
|
233
|
+
}
|
|
234
|
+
if (access !== undefined && vertex_2.DfgVertex.isFunctionCall(graph.getVertex(access.info.id))) {
|
|
235
|
+
graph.addEdge(call, access.info.id, edge_1.EdgeType.Reads);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
48
240
|
/** @returns whether `read` sees a definition */
|
|
49
241
|
function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph, activeReads) {
|
|
50
242
|
const readName = identifier_1.Identifier.boundAs(read.name);
|
|
@@ -57,6 +249,17 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
|
|
|
57
249
|
}
|
|
58
250
|
}
|
|
59
251
|
if (probableTarget === undefined) {
|
|
252
|
+
/* a data set of an attached package (`starwars` after `library(dplyr)`) is bound by the load */
|
|
253
|
+
if (readName !== undefined && !(read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction)) {
|
|
254
|
+
const loads = (0, built_in_library_1.dataLoadNodesForNamespace)(environments, identifier_1.Identifier.getName(readName));
|
|
255
|
+
for (const load of loads) {
|
|
256
|
+
nextGraph.addEdge(read.nodeId, load, edge_1.EdgeType.Reads);
|
|
257
|
+
}
|
|
258
|
+
/* R finds the data set only as the binding that hid it is removed (`iris <- 1; rm(iris); iris`), a name found nowhere stays missing either way */
|
|
259
|
+
if (loads.length > 0 || r_base_packages_1.BaseDatasets.has(identifier_1.Identifier.getName(readName))) {
|
|
260
|
+
(0, apply_kill_1.readRemovals)(nextGraph, read.nodeId, readName, environments);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
60
263
|
return false;
|
|
61
264
|
}
|
|
62
265
|
const rid = read.nodeId;
|
|
@@ -124,46 +327,14 @@ function foldFrameIntoParent({ current, level }) {
|
|
|
124
327
|
}
|
|
125
328
|
return { current: parent, level: level - 1 };
|
|
126
329
|
}
|
|
127
|
-
/** Whether an error raised by the call `from` still leaves the expression it is written in: redoes what a `stop` written at that spot would have done, since we only learn a callee always throws after linking it here. */
|
|
128
|
-
function errorEscapes(from, expression, idMap, graph) {
|
|
129
|
-
for (let node = idMap.get(from); node !== undefined && node.info.id !== expression;) {
|
|
130
|
-
const parent = model_1.RNode.directParent(node, idMap);
|
|
131
|
-
if (parent === undefined) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
if (!errorPassesThrough(parent, node.info.id, graph)) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
node = parent;
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
/** Whether an error raised within the child `child` of `parent` is sure to be raised by `parent` as well. */
|
|
142
|
-
function errorPassesThrough(parent, child, graph) {
|
|
143
|
-
if (r_argument_1.RArgument.is(parent) || r_expression_list_1.RExpressionList.is(parent)) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
else if (r_function_call_1.RFunctionCall.is(parent)) {
|
|
147
|
-
/* a handler catches the error instead of passing it on */
|
|
148
|
-
return !vertex_2.DfgVertex.hasOrigin(graph.getVertex(parent.info.id), built_in_proc_name_1.BuiltInProcName.Try);
|
|
149
|
-
}
|
|
150
|
-
else if (r_if_then_else_1.RIfThenElse.is(parent) || r_while_loop_1.RWhileLoop.is(parent)) {
|
|
151
|
-
/* only the condition is guaranteed to be evaluated */
|
|
152
|
-
return parent.condition.info.id === child;
|
|
153
|
-
}
|
|
154
|
-
else if (r_for_loop_1.RForLoop.is(parent)) {
|
|
155
|
-
return parent.vector.info.id === child;
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
330
|
const PrintName = identifier_1.Identifier.make('print');
|
|
160
|
-
/** Printing a visible top-level value dispatches to the `print` methods in scope, so the expression calls them: those for the classes the value may have, and what their `NextMethod()` may run, every one if the classes are not known. */
|
|
331
|
+
/** Printing a visible top-level value (or one `capture.output` captures) dispatches to the `print` methods in scope, so the expression calls them: those for the classes the value may have, and what their `NextMethod()` may run, every one if the classes are not known. */
|
|
161
332
|
function printMethodsOf(id, environment, graph, info) {
|
|
162
333
|
/* printing runs what `print` dispatches to on its own, like `show` for an S4 object */
|
|
163
334
|
const internal = (0, dispatch_linking_1.internalGenericMethods)(info.ctx.env.builtInFunctionOf(PrintName)?.config?.dispatches ?? [], environment, graph);
|
|
164
335
|
const all = (resolve_helper_1.Resolve.byNameAndType('print', environment, identifier_1.ReferenceType.S3MethodPrefix)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId)) ?? []).concat(internal);
|
|
165
336
|
const classes = all.length === 0 ? undefined : (0, dispatch_1.s3DispatchClassesOf)(id, info);
|
|
166
|
-
const methods =
|
|
337
|
+
const methods = printedBy(classes, all, graph);
|
|
167
338
|
if (methods.length === 0) {
|
|
168
339
|
return [];
|
|
169
340
|
}
|
|
@@ -171,6 +342,10 @@ function printMethodsOf(id, environment, graph, info) {
|
|
|
171
342
|
graph.addEdge(id, method.nodeId, edge_1.EdgeType.Reads);
|
|
172
343
|
}
|
|
173
344
|
const called = [...(0, linker_1.getAllLinkedFunctionDefinitions)(new Set(methods.map(m => m.nodeId)), graph)[0]];
|
|
345
|
+
/* a method bound outside the graph at hand (of the code `capture.output` prints) is the closure its binding holds */
|
|
346
|
+
for (const value of methods.flatMap(m => graph.hasVertex(m.nodeId) || !(0, identifier_1.isInGraphDefinition)(m) ? [] : m.value ?? [])) {
|
|
347
|
+
graph.addEdge(id, value, edge_1.EdgeType.Calls);
|
|
348
|
+
}
|
|
174
349
|
/* what an internal generic returns, like `format` for a column, is what is printed */
|
|
175
350
|
const returning = new Set((0, dispatch_linking_1.linkedFunctionIds)(new Set(internal.map(m => m.nodeId)), graph));
|
|
176
351
|
for (const method of called) {
|
|
@@ -188,10 +363,117 @@ function printMethodsOf(id, environment, graph, info) {
|
|
|
188
363
|
}
|
|
189
364
|
return [{ functionCall: id, called, propagateExitPoints: [], alternatives: called.length > 1 }];
|
|
190
365
|
}
|
|
191
|
-
/**
|
|
366
|
+
/** A call of a built-in generic (`length(x)`, `x$a`, `x + 1`) may run the `<name>.<class>` methods the code itself binds for it, and `new` the `initialize` methods, so it changes what they change, each only maybe. */
|
|
367
|
+
function ownMethodsCalledBy(thisGraph, environment, graph, ctx) {
|
|
368
|
+
const methods = new Map();
|
|
369
|
+
const add = (call, ids) => methods.set(call, [...methods.get(call) ?? [], ...ids]);
|
|
370
|
+
/* the calls by each name whose `<name>.<class>` methods they may run */
|
|
371
|
+
const generics = new Map();
|
|
372
|
+
const methodsBound = environment_1.REnvironment.findBuiltIn(environment.current).methods === true;
|
|
373
|
+
for (const [id, call] of thisGraph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
374
|
+
if (!call.onlyBuiltin || call.name === undefined || !thisGraph.isRoot(id)) {
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
/* a built-in may run generics of its own as well (`nrow(x)` asks `dim(x)`) */
|
|
378
|
+
const prefixes = methodsBound ? [...isBuiltInGeneric(call.name, ctx) ? (0, group_generics_1.s3MethodPrefixesOf)(call.name) : [], ...ctx.env.builtInFunctionOf(call.name)?.config?.dispatches ?? []] : [];
|
|
379
|
+
prefixes.forEach(prefix => generics.set(prefix, [...generics.get(prefix) ?? [], id]));
|
|
380
|
+
if (call.initializer !== undefined) {
|
|
381
|
+
add(id, df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Calls).filter(t => !node_id_1.NodeId.isBuiltIn(t)));
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
for (const frame of generics.size > 0 ? environment_1.REnvironment.frames(environment.current) : []) {
|
|
385
|
+
/* the frames of the packages bind their own methods, which the configuration states */
|
|
386
|
+
if (frame.t !== undefined || frame.builtInEnv) {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
for (const [name, definitions] of frame.memory) {
|
|
390
|
+
for (let dot = name.indexOf('.', 1); dot > 0; dot = name.indexOf('.', dot + 1)) {
|
|
391
|
+
for (const call of generics.get(name.slice(0, dot)) ?? []) {
|
|
392
|
+
add(call, definitions.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId)).map(d => d.nodeId));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const found = [];
|
|
398
|
+
for (const [functionCall, ids] of methods) {
|
|
399
|
+
/* a method bound actively (`makeActiveBinding`) is the function the binding returns once run */
|
|
400
|
+
const returned = ids.flatMap(i => activeFunctionsOf(i, graph)).flatMap(fn => graph.getVertex(fn).exitPoints.map(e => e.nodeId));
|
|
401
|
+
const called = [...(0, linker_1.getAllLinkedFunctionDefinitions)(new Set([...ids, ...returned]), graph)[0]];
|
|
402
|
+
if (called.length > 0) {
|
|
403
|
+
found.push({ functionCall, called, propagateExitPoints: [], alternatives: true });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return found;
|
|
407
|
+
}
|
|
408
|
+
function isBuiltInGeneric(name, ctx) {
|
|
409
|
+
return default_builtin_config_1.InternalGenerics.has(identifier_1.Identifier.getName(name)) || built_in_props_1.CallProps.hasAny(ctx.env.builtInFunctionOf(name)?.config, built_in_props_1.CallProp.Generic);
|
|
410
|
+
}
|
|
411
|
+
/** Notes a binding of `name` a call of a built-in generic may dispatch to (`length.foo`, `Ops.foo`), as only then the calls look for such methods (see {@link ownMethodsCalledBy}). */
|
|
412
|
+
function noteOwnMethod(name, environment, ctx) {
|
|
413
|
+
const plain = identifier_1.Identifier.getName(name);
|
|
414
|
+
for (let dot = plain.indexOf('.', 1); dot > 0; dot = plain.indexOf('.', dot + 1)) {
|
|
415
|
+
const prefix = plain.slice(0, dot);
|
|
416
|
+
if ((0, group_generics_1.isGroupGeneric)(prefix) || isBuiltInGeneric(prefix, ctx)) {
|
|
417
|
+
environment_1.REnvironment.findBuiltIn(environment.current).methods = true;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/** Notes that the call `id` binds names we cannot tell (`list2env(l)`), which may be a method of any generic, so a call of one running after it runs what we cannot tell (see `updateNestedFunctionCalls`). */
|
|
423
|
+
function noteUnknownMethods(environment, id) {
|
|
424
|
+
const builtIn = environment_1.REnvironment.findBuiltIn(environment.current);
|
|
425
|
+
builtIn.methods = true;
|
|
426
|
+
(builtIn.unknownMethodsAt ??= []).push(id);
|
|
427
|
+
}
|
|
428
|
+
/** Marks `id` as binding names we cannot tell (`assign(nm, v, envir = e)`, `source(file)`), an unknown side effect that may bind a method as well, unless the `value` it binds (with `elements`, each of its elements) cannot be a function, as R only finds functions as methods. */
|
|
429
|
+
function bindsUnknownNames(graph, environment, id, value, ctx, elements = false) {
|
|
430
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, id);
|
|
431
|
+
if (!cannotBeFunction(value, environment, graph, ctx, elements)) {
|
|
432
|
+
noteUnknownMethods(environment, id);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/** How deep {@link cannotBeFunction} follows the values a symbol may hold. */
|
|
436
|
+
const MaxValueDepth = 8;
|
|
437
|
+
/** The values a definition binds: those it records, else the right-hand side of the plain assignment `x <- v` making it. */
|
|
438
|
+
function valuesBoundBy(definition, recorded, graph) {
|
|
439
|
+
if (recorded !== undefined && recorded.length > 0) {
|
|
440
|
+
return recorded.map(v => graph.idMap?.get(v)).filter(v => v !== undefined);
|
|
441
|
+
}
|
|
442
|
+
const node = graph.idMap?.get(definition);
|
|
443
|
+
const parent = node?.info.parent === undefined ? undefined : graph.idMap?.get(node.info.parent);
|
|
444
|
+
return r_binary_op_1.RBinaryOp.is(parent) && parent.lhs === node && ['<-', '=', '<<-'].includes(parent.operator) ? [parent.rhs] : [];
|
|
445
|
+
}
|
|
446
|
+
/** Whether the value of `node` (or with `elements` each of its elements) surely is no function: a constant, a call of a built-in stated to return no function, or a symbol bound only to such values. */
|
|
447
|
+
function cannotBeFunction(node, environment, graph, ctx, elements = false, depth = 0) {
|
|
448
|
+
if (model_1.RConstant.is(node)) {
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
else if (node === undefined || ctx === undefined || depth >= MaxValueDepth) {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
else if (r_symbol_1.RSymbol.is(node)) {
|
|
455
|
+
const definitions = resolve_helper_1.Resolve.byName(node.content, environment);
|
|
456
|
+
return definitions !== undefined && definitions.length > 0 && definitions.every(d => {
|
|
457
|
+
const values = (0, identifier_1.isInGraphDefinition)(d) && !node_id_1.NodeId.isBuiltIn(d.nodeId) ? valuesBoundBy(d.nodeId, d.value, graph) : [];
|
|
458
|
+
return values.length > 0 && values.every(v => v !== node && cannotBeFunction(v, environment, graph, ctx, elements, depth + 1));
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
else if (!r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
const name = node.functionName.content;
|
|
465
|
+
const callees = resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.Function);
|
|
466
|
+
if (callees === undefined || callees.length === 0 || callees.some(d => !node_id_1.NodeId.isBuiltIn(d.nodeId))) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
const returns = ctx.env.builtInFunctionOf(name)?.config?.guards?.[identifier_1.Identifier.getName(name)]?.returns;
|
|
470
|
+
const types = typeof returns !== 'object' || returns.dispatchesOn !== undefined ? undefined : elements ? returns.elements : returns.types;
|
|
471
|
+
return types !== undefined && (types & guard_facts_1.RValueType.Function) === 0;
|
|
472
|
+
}
|
|
473
|
+
/** Of the definitions `found` for `print`, those printing a value of the class vectors `classes` may run (all of them if the classes are not known), with any that is no `print.<class>` method; links the `NextMethod()` calls of each to the methods after it, any other one if the classes are not known. */
|
|
192
474
|
function printedBy(classes, found, graph) {
|
|
193
475
|
const methodOf = (d) => d.name === undefined ? undefined : /^print\.(.+)$/.exec(identifier_1.Identifier.getName(d.name))?.[1];
|
|
194
|
-
const { runs, next } = (0, dispatch_1.s3Dispatch)(classes, found, methodOf);
|
|
476
|
+
const { runs, next } = classes === undefined ? { runs: new Set(found), next: new Map(found.map(m => [m, new Set(found.filter(o => o !== m))])) } : (0, dispatch_1.s3Dispatch)(classes, found, methodOf);
|
|
195
477
|
for (const [method, after] of next) {
|
|
196
478
|
const targets = (0, dispatch_linking_1.linkedFunctionIds)(new Set([...after].map(m => m.nodeId)), graph);
|
|
197
479
|
for (const fn of (0, linker_1.getAllLinkedFunctionDefinitions)(new Set([method.nodeId]), graph)[0]) {
|
|
@@ -227,7 +509,10 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
|
|
|
227
509
|
const effects = nextGraph.unknownSideEffects;
|
|
228
510
|
for (const effect of inside.size < effects.size ? inside : effects) {
|
|
229
511
|
if (typeof effect !== 'object' && inside.has(effect) && effects.has(effect)) {
|
|
230
|
-
|
|
512
|
+
/* every call on the way makes it */
|
|
513
|
+
for (const call of [functionCall, ...chain ?? []]) {
|
|
514
|
+
nextGraph.addEdge(effect, call, edge_1.EdgeType.SideEffectOnCall);
|
|
515
|
+
}
|
|
231
516
|
}
|
|
232
517
|
}
|
|
233
518
|
// only merge the environments they have in common
|
|
@@ -304,12 +589,12 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
304
589
|
const invertExitCds = [];
|
|
305
590
|
const processedExpressions = [];
|
|
306
591
|
let defaultReturnExpr;
|
|
307
|
-
/* R prints what the top level of the analyzed script leaves visible, but not what a sourced file does */
|
|
308
592
|
const fileRoot = data.completeAst.ast.files.some(f => f.root.info.id === rootId);
|
|
309
|
-
|
|
593
|
+
/* R prints what the top level of the analyzed script leaves visible, but not what a sourced file does */
|
|
594
|
+
const autoPrint = (0, built_in_ambient_state_1.autoPrintsStatementsOf)(rootId, data);
|
|
310
595
|
let initialState;
|
|
311
596
|
const hooks = [];
|
|
312
|
-
for (const arg of args) {
|
|
597
|
+
for (const [index, arg] of args.entries()) {
|
|
313
598
|
const expression = r_argument_1.RArgument.unnamedValueOf(arg);
|
|
314
599
|
if (expression === undefined) {
|
|
315
600
|
processedExpressions.push(undefined);
|
|
@@ -348,15 +633,20 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
348
633
|
(initialState ??= new Set()).add(read);
|
|
349
634
|
}
|
|
350
635
|
}
|
|
636
|
+
const accessing = (0, built_in_ambient_state_1.mayForce)(environment) ? callActiveBindingsAccessed(processed, environment, nextGraph, activeReads) : [];
|
|
351
637
|
for (const read of activeReads) {
|
|
352
638
|
nextGraph.updateToFunctionCall({ tag: vertex_1.VertexType.FunctionCall, id: read.nodeId, name: read.name, args: [], environment, onlyBuiltin: false, cds: read.cds, origin: [built_in_proc_name_1.BuiltInProcName.Function] });
|
|
353
639
|
}
|
|
354
|
-
const calledEnvs = (0, linker_1.linkFunctionCalls)(nextGraph, idMap, processed.graph, activeReads.map(r => r.nodeId));
|
|
640
|
+
const calledEnvs = (0, linker_1.linkFunctionCalls)(nextGraph, idMap, processed.graph, [...activeReads.map(r => r.nodeId), ...accessing]);
|
|
641
|
+
if (accessing.length > 0 || calledEnvs.length > 0) {
|
|
642
|
+
calledEnvs.push(...bindingsCalledThroughCallees(processed, environment, nextGraph, accessing, calledEnvs));
|
|
643
|
+
}
|
|
644
|
+
calledEnvs.push(...ownMethodsCalledBy(processed.graph, environment, nextGraph, data.ctx));
|
|
355
645
|
if (printed) {
|
|
356
646
|
calledEnvs.push(...printMethodsOf(processed.entryPoint, environment, nextGraph, { graph: nextGraph, idMap, ctx: data.ctx, environment }));
|
|
357
647
|
}
|
|
358
648
|
for (const c of calledEnvs) {
|
|
359
|
-
if (c.propagateExitPoints.length > 0 && errorEscapes(c.functionCall, expression.info.id, idMap, nextGraph)) {
|
|
649
|
+
if (c.propagateExitPoints.length > 0 && (0, linker_1.errorEscapes)(c.functionCall, expression.info.id, idMap, nextGraph)) {
|
|
360
650
|
processed.exitPoints.push(...c.propagateExitPoints);
|
|
361
651
|
}
|
|
362
652
|
}
|
|
@@ -368,7 +658,12 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
368
658
|
(0, info_1.addNonDefaultExitPoints)(exitPoints, invertExitCds, data.cds, processed.exitPoints);
|
|
369
659
|
environment = exitPoints.length > 0 ? environment_1.REnvironment.overwrite(environment, processed.environment) : processed.environment;
|
|
370
660
|
// if the called function has global redefinitions, we have to keep them within our environment
|
|
661
|
+
const beforeCalls = environment;
|
|
371
662
|
environment = updateSideEffectsForCalledFunctions(calledEnvs, environment, nextGraph, processed.out, idMap, listEnvironments, data.ctx);
|
|
663
|
+
const viaEnvOps = calledEnvs.length > 0 && (0, built_in_ambient_state_1.mayForce)(environment) ? bindingsAccessedByEnvOps(calledEnvs, processed, beforeCalls, environment, nextGraph) : [];
|
|
664
|
+
if (viaEnvOps.length > 0) {
|
|
665
|
+
environment = updateSideEffectsForCalledFunctions(viaEnvOps, environment, nextGraph, processed.out, idMap, listEnvironments, data.ctx);
|
|
666
|
+
}
|
|
372
667
|
// removals are already reflected in the threaded environment; we only bubble them (net of later writes)
|
|
373
668
|
if (killed && processed.out.length > 0) {
|
|
374
669
|
killed = (0, apply_kill_1.cancelRevivedKills)(killed, processed.out);
|
|
@@ -386,6 +681,12 @@ function processExpressionList(name, args, rootId, data) {
|
|
|
386
681
|
if (control_flow_1.ControlFlow.alwaysExits(processed, context)) {
|
|
387
682
|
/* if there is an always-exit expression, there is no default return active anymore */
|
|
388
683
|
defaultReturnExpr = undefined;
|
|
684
|
+
for (const dead of args.slice(index + 1)) {
|
|
685
|
+
const id = r_argument_1.RArgument.unnamedValueOf(dead)?.info.id;
|
|
686
|
+
if (id !== undefined) {
|
|
687
|
+
data.unreachable?.add(id);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
389
690
|
break;
|
|
390
691
|
}
|
|
391
692
|
}
|
|
@@ -128,7 +128,8 @@ function processForLoop(name, args, rootId, data) {
|
|
|
128
128
|
entryPoint: name.info.id,
|
|
129
129
|
cfgEntry: control_flow_1.ControlFlow.entryOf(vector),
|
|
130
130
|
cfgExit: rootId,
|
|
131
|
-
|
|
131
|
+
/* unless the body certainly runs, it only jumps away when it runs */
|
|
132
|
+
exitPoints: (0, info_1.filterOutLoopExitPoints)(once ? body.exitPoints : body.exitPoints.map(e => ({ ...e, cds: [...e.cds ?? data.cds ?? [], cd[0]] }))),
|
|
132
133
|
environment: loopKill ? (0, apply_kill_1.applyKills)(loopEnvironment, loopKill) : loopEnvironment,
|
|
133
134
|
hooks: variable.hooks.concat(vector.hooks, once ? body.hooks : (0, hooks_1.hooksUnder)(body.hooks, cd)),
|
|
134
135
|
kill: loopKill,
|
|
@@ -16,6 +16,11 @@ export declare function retrieveActiveEnvironment(callerEnvironment: REnvironmen
|
|
|
16
16
|
export declare function updateNestedFunctionClosures(graph: DataflowGraph, outEnvironment: REnvironmentInformation, openReads: IdentifierReference[]): void;
|
|
17
17
|
/** Whether an enclosing scope binds the name of a call within a closure before the closure exists, see {@link boundBeforeClosure}: then the call reaches only what its reads do, and never looks further out, whatever the end of the script binds there. */
|
|
18
18
|
export declare function callBoundInScope(call: NodeId, graph: DataflowGraph): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The definitions the name of `call` reads, without what else it reads: the methods a built-in runs (`[.cls` for `x[i]`)
|
|
21
|
+
* and what they return, which say nothing about what the name is bound to.
|
|
22
|
+
*/
|
|
23
|
+
export declare function nameReadsOf(call: NodeId, graph: DataflowGraph): NodeId[];
|
|
19
24
|
/**
|
|
20
25
|
* Update the closure links of all nested function calls, done once at the end of the script.
|
|
21
26
|
* @lintIgnore vertex-has-origin
|