@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
|
@@ -4,6 +4,7 @@ exports.processFunctionDefinition = processFunctionDefinition;
|
|
|
4
4
|
exports.retrieveActiveEnvironment = retrieveActiveEnvironment;
|
|
5
5
|
exports.updateNestedFunctionClosures = updateNestedFunctionClosures;
|
|
6
6
|
exports.callBoundInScope = callBoundInScope;
|
|
7
|
+
exports.nameReadsOf = nameReadsOf;
|
|
7
8
|
exports.updateNestedFunctionCalls = updateNestedFunctionCalls;
|
|
8
9
|
const processor_1 = require("../../../../../processor");
|
|
9
10
|
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
@@ -48,6 +49,8 @@ const query_fn_props_1 = require("../../../../../environments/query-fn-props");
|
|
|
48
49
|
const built_in_props_1 = require("../../../../../environments/built-in-props");
|
|
49
50
|
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
50
51
|
const group_generics_1 = require("../../../../../environments/group-generics");
|
|
52
|
+
const default_builtin_config_1 = require("../../../../../environments/default-builtin-config");
|
|
53
|
+
const r_primitives_generated_1 = require("../../../../../../data/r-primitives.generated");
|
|
51
54
|
const arg_matching_1 = require("../../../../../../util/arg-matching");
|
|
52
55
|
const defaultmap_1 = require("../../../../../../util/collections/defaultmap");
|
|
53
56
|
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
@@ -182,6 +185,12 @@ function processFunctionDefinition(name, args, rootId, data) {
|
|
|
182
185
|
subgraph.addEdge(rootId, hook.id, edge_1.EdgeType.Calls);
|
|
183
186
|
const hookExitPoints = vert.exitPoints.filter(e => e.type === 1 /* ExitPointType.Return */ || e.type === 4 /* ExitPointType.Error */);
|
|
184
187
|
if (hookExitPoints.length > 0) {
|
|
188
|
+
/* R prints the message of an error before the hook runs, so what the hook hands back instead still shows it */
|
|
189
|
+
for (const raised of afterHookExitPoints.filter(e => e.type === 4 /* ExitPointType.Error */)) {
|
|
190
|
+
for (const exit of hookExitPoints) {
|
|
191
|
+
subgraph.addEdge(exit.nodeId, raised.nodeId, edge_1.EdgeType.Reads);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
185
194
|
afterHookExitPoints = (0, info_1.overwriteExitPoints)(afterHookExitPoints, hookExitPoints);
|
|
186
195
|
}
|
|
187
196
|
}
|
|
@@ -255,10 +264,28 @@ function envStateReturnedAt(nodeId, graph, outEnvironment, data) {
|
|
|
255
264
|
return undefined;
|
|
256
265
|
}
|
|
257
266
|
const environment = { environment: outEnvironment };
|
|
267
|
+
if (isOwnFrame(node, graph, outEnvironment)) {
|
|
268
|
+
return outEnvironment;
|
|
269
|
+
}
|
|
258
270
|
return (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.List) ? (0, built_in_list_1.resolveListToEnvState)(node, environment) : undefined)
|
|
259
271
|
?? (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.ClassGenerator) ? (0, built_in_class_generator_1.resolveClassMethodsToEnvState)(node, environment) : undefined)
|
|
260
272
|
?? (r_symbol_1.RSymbol.is(node) ? resolve_helper_1.Resolve.byNameAndType(node.content, outEnvironment, identifier_1.ReferenceType.Variable)?.find(identifier_1.hasEnvState)?.envState : undefined);
|
|
261
273
|
}
|
|
274
|
+
/** Whether `node` is the frame of the function being defined: a call of `environment()` or a variable of that frame bound to one (`self <- environment()`), the frame then holds everything the body bound by the time it returns. */
|
|
275
|
+
function isOwnFrame(node, graph, outEnvironment) {
|
|
276
|
+
const isEnvironmentCall = (n) => {
|
|
277
|
+
const vertex = n === undefined ? undefined : graph.getVertex(n.info.id);
|
|
278
|
+
return r_function_call_1.RFunctionCall.isNamed(n, 'environment') && n.arguments.length === 0 && vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.onlyBuiltin;
|
|
279
|
+
};
|
|
280
|
+
if (isEnvironmentCall(node)) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
if (!r_symbol_1.RSymbol.is(node)) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
const defs = outEnvironment.current.memory.get(identifier_1.Identifier.getName(node.content));
|
|
287
|
+
return defs !== undefined && defs.length > 0 && defs.every(d => d.value?.some(v => isEnvironmentCall(graph.idMap?.get(v))) === true);
|
|
288
|
+
}
|
|
262
289
|
/** Retrieve the active environment when entering a function definition or call. */
|
|
263
290
|
function retrieveActiveEnvironment(callerEnvironment, baseEnvironment, ctx) {
|
|
264
291
|
callerEnvironment ??= ctx.env.makeCleanEnv();
|
|
@@ -363,7 +390,16 @@ function updateNestedFunctionClosures(graph, outEnvironment, openReads) {
|
|
|
363
390
|
}
|
|
364
391
|
/** 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. */
|
|
365
392
|
function callBoundInScope(call, graph) {
|
|
366
|
-
return !graph.isRoot(call) &&
|
|
393
|
+
return !graph.isRoot(call) && nameReadsOf(call, graph).some(r => boundBeforeClosure(r, call, graph));
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* The definitions the name of `call` reads, without what else it reads: the methods a built-in runs (`[.cls` for `x[i]`)
|
|
397
|
+
* and what they return, which say nothing about what the name is bound to.
|
|
398
|
+
*/
|
|
399
|
+
function nameReadsOf(call, graph) {
|
|
400
|
+
const vertex = graph.getVertex(call);
|
|
401
|
+
const name = vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.name !== undefined ? String(identifier_1.Identifier.getName(vertex.name)) : undefined;
|
|
402
|
+
return df_helper_1.Dataflow.targetsOf(graph, call, edge_1.EdgeType.Reads).filter(r => name === undefined || node_id_1.NodeId.recoverBareName(r, graph.idMap) === name);
|
|
367
403
|
}
|
|
368
404
|
/** Whether the local definition `def` is made before the closure holding the read `read` is created, on every way there: `h <- function() 2; g <- function() h()` binds `h` in the scope before `g` exists, so no call of `g` looks past the scope for it. */
|
|
369
405
|
function boundBeforeClosure(def, read, graph) {
|
|
@@ -437,7 +473,7 @@ function dispatchesOnClass(name, environment, infoOf) {
|
|
|
437
473
|
}
|
|
438
474
|
/** Links `call` to the S3 methods the analyzed code binds as `<name>.<class>`, returning their definition vertices and the dispatched objects. */
|
|
439
475
|
function linkOwnS3Methods(call, name, graph, environment, statement, ctx, infoOf) {
|
|
440
|
-
const defs = s3MethodPrefixesOf(name).flatMap(prefix => resolve_helper_1.Resolve.byNameAndType(prefix, environment, identifier_1.ReferenceType.S3MethodPrefix) ?? [])
|
|
476
|
+
const defs = (0, group_generics_1.s3MethodPrefixesOf)(name).flatMap(prefix => resolve_helper_1.Resolve.byNameAndType(prefix, environment, identifier_1.ReferenceType.S3MethodPrefix) ?? [])
|
|
441
477
|
.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId) && !program_order_1.ProgramOrder.definedLater(d.nodeId, statement, graph));
|
|
442
478
|
if (defs.length === 0) {
|
|
443
479
|
return { methods: [] };
|
|
@@ -450,12 +486,6 @@ function linkOwnS3Methods(call, name, graph, environment, statement, ctx, infoOf
|
|
|
450
486
|
}
|
|
451
487
|
return { methods: (0, dispatch_linking_1.linkedFunctionIds)(new Set(chosen.map(d => d.nodeId)), graph), objects: dispatched?.objects };
|
|
452
488
|
}
|
|
453
|
-
/** The names whose `<name>.<class>` methods a call of `name` may dispatch to: its own and that of the S3 group generic it is a member of. */
|
|
454
|
-
function s3MethodPrefixesOf(name) {
|
|
455
|
-
const plain = identifier_1.Identifier.getName(name);
|
|
456
|
-
const group = (0, group_generics_1.s3GroupGenericOf)(plain);
|
|
457
|
-
return group === undefined ? [plain] : [plain, group];
|
|
458
|
-
}
|
|
459
489
|
/** The arguments the S3 dispatch of a call of a built-in generic looks at the class of, `undefined` if they are not clear. */
|
|
460
490
|
function dispatchedArgumentsOf(call, node, name, graph, environment, ctx, infoOf) {
|
|
461
491
|
const args = call.args.filter(a => a !== r_function_call_1.EmptyArgument);
|
|
@@ -493,7 +523,7 @@ function dispatchedS3Methods(call, name, methods, graph, environment, statement,
|
|
|
493
523
|
return { objects: dispatched };
|
|
494
524
|
}
|
|
495
525
|
const classes = perArgument.flat();
|
|
496
|
-
const prefixes = s3MethodPrefixesOf(name);
|
|
526
|
+
const prefixes = (0, group_generics_1.s3MethodPrefixesOf)(name);
|
|
497
527
|
const pick = (stopAt) => {
|
|
498
528
|
const picked = new Set();
|
|
499
529
|
for (const cls of classes) {
|
|
@@ -545,7 +575,7 @@ function dispatchedObjectOf(vertex, graph) {
|
|
|
545
575
|
/** What the dispatch of `vertex` among `targets` rules out, S3 on the objects `s3Objects` and S4 on the classes of its arguments. */
|
|
546
576
|
function narrowedDispatchOf(narrower, vertex, s3Objects, targets, definedLater, info) {
|
|
547
577
|
const name = identifier_1.Identifier.getName(vertex.name);
|
|
548
|
-
const s3 = s3Objects === undefined ? undefined : narrower.s3(s3Objects, s3MethodPrefixesOf(vertex.name), targets, info);
|
|
578
|
+
const s3 = s3Objects === undefined ? undefined : narrower.s3(s3Objects, (0, group_generics_1.s3MethodPrefixesOf)(vertex.name), targets, info);
|
|
549
579
|
const s4 = narrower.reachesS4Method(targets) ? narrower.s4(vertex, name, targets, definedLater, info) : undefined;
|
|
550
580
|
if (s3 === undefined || s4 === undefined) {
|
|
551
581
|
return s3 ?? s4;
|
|
@@ -617,11 +647,44 @@ function nextMethodsPerCall(next, owner, dispatch, contexts, collected, graph) {
|
|
|
617
647
|
.map(([n, m]) => ({ call: n, methods: [], within: runsOf(m, new Set([...seen, m])) }))];
|
|
618
648
|
return within === undefined ? undefined : runsOf(owner, new Set([owner]));
|
|
619
649
|
}
|
|
650
|
+
/** the processors of calls that run their R code as it is, handing on what they get */
|
|
651
|
+
const RunsPlainCode = new Set([built_in_proc_name_1.BuiltInProcName.Default, built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, built_in_proc_name_1.BuiltInProcName.Apply]);
|
|
652
|
+
/** The internal generics and the S3 groups, which R code may dispatch to on whatever it is handed, without naming them as a call the signature database records (`x[i]`). */
|
|
653
|
+
const DispatchedInternally = [...default_builtin_config_1.InternalGenerics, ...group_generics_1.S3Groups];
|
|
654
|
+
/** Whether the `call` may hand on an object a method may get: a constant (`structure(1, class = "a")`) has no class. */
|
|
655
|
+
function handsObjects(call, idMap) {
|
|
656
|
+
return call.args.some(a => a !== r_function_call_1.EmptyArgument && !model_1.RConstant.is(r_argument_1.RArgument.valueOf(idMap?.get(a.nodeId))));
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* The generics a call of the built-in `name` may run on what it is handed besides its own: those the configuration states
|
|
660
|
+
* (`nrow(x)` asks `dim(x)`), else for a function of R code (`median`, `head`) every internal one as well as those its code
|
|
661
|
+
* calls (as the signature database knows), also through the default method of a generic it calls.
|
|
662
|
+
*/
|
|
663
|
+
function genericsRunWithin(name, ctx) {
|
|
664
|
+
const builtIn = ctx.env.builtInFunctionOf(name);
|
|
665
|
+
const stated = builtIn?.config?.dispatches;
|
|
666
|
+
const called = calleesOf(name, ctx)?.filter(c => default_builtin_config_1.RGenerics.has(c));
|
|
667
|
+
/* what the configuration states it dispatches to is all, a processor of its own models what the call does (`setMethod`), a primitive runs no R code, and a name flowR knows nothing of is no built-in */
|
|
668
|
+
if (stated !== undefined || (builtIn !== undefined && !RunsPlainCode.has(builtIn.processorName)) || r_primitives_generated_1.RPrimitives.has(String(identifier_1.Identifier.getName(name))) || (called === undefined && builtIn === undefined)) {
|
|
669
|
+
return stated ?? [];
|
|
670
|
+
}
|
|
671
|
+
const generic = default_builtin_config_1.RGenerics.has(identifier_1.Identifier.getName(name)) ? [identifier_1.Identifier.getName(name)] : [];
|
|
672
|
+
const viaDefaults = [...generic, ...called ?? []].flatMap(g => calleesOf(identifier_1.Identifier.make(`${g}.default`), ctx)?.filter(c => default_builtin_config_1.RGenerics.has(c)) ?? []);
|
|
673
|
+
return (0, arrays_1.uniqueArray)([...DispatchedInternally, ...called ?? [], ...viaDefaults].map(String));
|
|
674
|
+
}
|
|
675
|
+
/** What the R code of the package function `name` calls, `undefined` if the signature database knows no code for it. */
|
|
676
|
+
function calleesOf(name, ctx) {
|
|
677
|
+
return (0, query_fn_props_1.fnEntry)(name, ctx).entry?.callees;
|
|
678
|
+
}
|
|
620
679
|
/**
|
|
621
680
|
* Update the closure links of all nested function calls, done once at the end of the script.
|
|
622
681
|
* @lintIgnore vertex-has-origin
|
|
623
682
|
*/
|
|
624
683
|
function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
684
|
+
/* linking changes the graph after nearly every call it resolves, so the walks are not worth sharing */
|
|
685
|
+
graph.withoutSharedTargetWalks(() => linkNestedFunctionCalls(graph, outEnvironment, ctx));
|
|
686
|
+
}
|
|
687
|
+
function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
625
688
|
const { shadowing, generics } = namesShadowingBuiltIns(outEnvironment, graph);
|
|
626
689
|
let rootDefinitions;
|
|
627
690
|
const calls = graph.verticesOfType(vertex_1.VertexType.FunctionCall).toArray();
|
|
@@ -634,12 +697,18 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
634
697
|
const runsOnceAt = (0, defaultmap_1.memoize)((id) => program_order_1.ProgramOrder.runsOnceAt(id, graph));
|
|
635
698
|
const databaseInfoOf = (0, defaultmap_1.memoize)((name) => ctx.functionInfo(name));
|
|
636
699
|
/* the generics a built-in dispatches to on its own whose methods the code binds */
|
|
637
|
-
const
|
|
700
|
+
const runWithin = (0, defaultmap_1.memoize)((name) => genericsRunWithin(name, ctx));
|
|
701
|
+
const internalOf = (0, defaultmap_1.memoize)((name) => generics.size === 0 && shadowing.size === 0 ? [] : runWithin(name).filter(g => generics.has(g) || shadowing.has(g)));
|
|
638
702
|
const environmentAt = (0, defaultmap_1.memoize)((id) => {
|
|
639
703
|
const environment = graph.getVertex(id).environment;
|
|
640
704
|
return environment ? environment_1.REnvironment.overwrite(outEnvironment, environment) : outEnvironment;
|
|
641
705
|
});
|
|
642
706
|
const narrower = new dispatch_linking_1.DispatchNarrower(graph, ctx);
|
|
707
|
+
/* the bindings of names we cannot tell that run, i.e. those at the top or in a function the code calls */
|
|
708
|
+
const unknownMethodsAt = (environment_1.REnvironment.findBuiltIn(outEnvironment.current).unknownMethodsAt ?? []).filter(at => {
|
|
709
|
+
const fn = enclosingOf(at);
|
|
710
|
+
return fn === undefined || graph.edgesTo(fn).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls));
|
|
711
|
+
});
|
|
643
712
|
/* per function, the `NextMethod` calls of its body */
|
|
644
713
|
const namedNextCalls = new Map();
|
|
645
714
|
for (const [id, vertex] of calls) {
|
|
@@ -684,11 +753,15 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
684
753
|
}
|
|
685
754
|
continue;
|
|
686
755
|
}
|
|
756
|
+
/* a method the code binds by a name we cannot tell may be one the call dispatches to */
|
|
757
|
+
if (unknownMethodsAt.some(at => !program_order_1.ProgramOrder.definedLater(at, runsOnceAt(id), graph)) && ((handsObjects(vertex, graph.idMap) && runWithin(name).length > 0) || dispatchesOnClass(name, environmentAt(id), databaseInfoOf))) {
|
|
758
|
+
graph.markIdForUnknownSideEffects(id);
|
|
759
|
+
}
|
|
687
760
|
/* the code writes a `<name>.<class>`, so a built-in `name` that dispatches may reach it */
|
|
688
|
-
const mayDispatch = s3MethodPrefixesOf(name).some(p => generics.has(p));
|
|
761
|
+
const mayDispatch = (0, group_generics_1.s3MethodPrefixesOf)(name).some(p => generics.has(p));
|
|
689
762
|
/* a `setMethod("Arith", ...)` claims every member of the S4 group, so a built-in member may reach its methods */
|
|
690
763
|
const s4Groups = (0, group_generics_1.s4GroupGenericsOf)(identifier_1.Identifier.getName(name)).filter(g => shadowing.has(g));
|
|
691
|
-
const internal = internalOf(name);
|
|
764
|
+
const internal = handsObjects(vertex, graph.idMap) ? internalOf(name) : [];
|
|
692
765
|
if (onlyBuiltin && !mayDispatch && s4Groups.length === 0 && internal.length === 0 && !(!graph.isRoot(id) && shadowing.has(identifier_1.Identifier.getName(name)))) {
|
|
693
766
|
continue;
|
|
694
767
|
}
|
|
@@ -698,7 +771,7 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
698
771
|
/* the dispatch is decided anew, from every method the name may reach */
|
|
699
772
|
delete vertex.ruledOut;
|
|
700
773
|
delete vertex.ruledOutAt;
|
|
701
|
-
const targets = new Set(callBoundInScope(id, graph) ? (0, dispatch_linking_1.linkedFunctionIds)(new Set(
|
|
774
|
+
const targets = new Set(callBoundInScope(id, graph) ? (0, dispatch_linking_1.linkedFunctionIds)(new Set(nameReadsOf(id, graph)), graph) : df_helper_1.Dataflow.callTargetsOf(id, graph, effectiveEnvironment));
|
|
702
775
|
/* a dispatch depends on the classes of its arguments, so it waits for the value flow to be linked */
|
|
703
776
|
const dispatches = origin.includes(built_in_proc_name_1.BuiltInProcName.S3Dispatch) || narrower.reachesS4Method(targets) || mayDispatch && dispatchesOnClass(name, effectiveEnvironment, databaseInfoOf);
|
|
704
777
|
if (dispatches && !deferred.has(id)) {
|
|
@@ -747,7 +820,14 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
747
820
|
}
|
|
748
821
|
for (const method of internal.length === 0 ? [] : (0, dispatch_linking_1.internalGenericMethods)(internal, methodEnvironment(), graph).filter(m => !definedLater(m.nodeId))) {
|
|
749
822
|
graph.addEdge(id, method.nodeId, edge_1.EdgeType.Reads);
|
|
750
|
-
(0, dispatch_linking_1.linkedFunctionIds)(new Set([method.nodeId]), graph)
|
|
823
|
+
for (const target of (0, dispatch_linking_1.linkedFunctionIds)(new Set([method.nodeId]), graph)) {
|
|
824
|
+
targets.add(target);
|
|
825
|
+
/* the built-in goes on with what the method returns (`message(cnd)` prints what `conditionMessage` gives) */
|
|
826
|
+
const fn = graph.getVertex(target);
|
|
827
|
+
for (const exit of vertex_1.DfgVertex.isFunctionDefinition(fn) ? fn.exitPoints : []) {
|
|
828
|
+
graph.addEdge(id, exit.nodeId, edge_1.EdgeType.Reads);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
751
831
|
}
|
|
752
832
|
const decide = (info) => {
|
|
753
833
|
const decided = narrowedDispatchOf(narrower, vertex, s3Objects, targets, definedLater, info);
|
|
@@ -983,6 +1063,20 @@ function namesRemovedBy(call, idMap) {
|
|
|
983
1063
|
}
|
|
984
1064
|
return names;
|
|
985
1065
|
}
|
|
1066
|
+
/**
|
|
1067
|
+
* What a frame holds for a `<<-` within a function written in it: what it binds itself, and, as the emptied stand-in of a function around it,
|
|
1068
|
+
* what the frame it stands in for held, so `<<-` in a function three levels deep still finds the binding of the outermost one.
|
|
1069
|
+
*/
|
|
1070
|
+
function lexicalMemoryOf(frame) {
|
|
1071
|
+
const original = frame.superMemory;
|
|
1072
|
+
if (original === undefined || original.size === 0) {
|
|
1073
|
+
return frame.memory;
|
|
1074
|
+
}
|
|
1075
|
+
else if (frame.memory.size === 0) {
|
|
1076
|
+
return original;
|
|
1077
|
+
}
|
|
1078
|
+
return new Map([...original, ...frame.memory]);
|
|
1079
|
+
}
|
|
986
1080
|
function prepareFunctionEnvironment(data, rootId) {
|
|
987
1081
|
const level = data.environment.level;
|
|
988
1082
|
/* the enclosing frames are emptied, but a `<<-` binds lexically, so each stand-in keeps what its original held */
|
|
@@ -999,7 +1093,7 @@ function prepareFunctionEnvironment(data, rootId) {
|
|
|
999
1093
|
env.current.setClosureNodeId(rootId);
|
|
1000
1094
|
}
|
|
1001
1095
|
else {
|
|
1002
|
-
env.current.standsInFor(enclosing[level - 1 - i]
|
|
1096
|
+
env.current.standsInFor(lexicalMemoryOf(enclosing[level - 1 - i]));
|
|
1003
1097
|
}
|
|
1004
1098
|
}
|
|
1005
1099
|
return { ...data, environment: env };
|
|
@@ -23,5 +23,7 @@ export declare function lexicalDefinitions(name: BrandedIdentifier, call: Datafl
|
|
|
23
23
|
/** Processes a built-in 'get' function call. */
|
|
24
24
|
export declare function processGet<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
|
|
25
25
|
returnsValue?: boolean;
|
|
26
|
+
hasUnknownSideEffects?: boolean;
|
|
27
|
+
locks?: boolean;
|
|
26
28
|
sig?: FnSig;
|
|
27
29
|
}): DataflowInformation;
|
|
@@ -27,6 +27,7 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
27
27
|
const built_in_props_1 = require("../../../../../environments/built-in-props");
|
|
28
28
|
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
29
29
|
const linker_1 = require("../../../../linker");
|
|
30
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
30
31
|
function namesDenotedBy(node, data) {
|
|
31
32
|
const folded = (0, built_in_envir_utils_1.resolveConstantString)(node, data);
|
|
32
33
|
return folded === undefined ? node_value_1.NodeValue.stringsOf(node.info.id, data) ?? [] : [folded];
|
|
@@ -115,7 +116,7 @@ function lexicalDefinitions(name, call, graph) {
|
|
|
115
116
|
}
|
|
116
117
|
let level = 0;
|
|
117
118
|
for (let frame = call.environment?.current; frame !== undefined && !frame.builtInEnv && frame.globalEnv !== true; frame = frame.parent) {
|
|
118
|
-
const found = [...frame.
|
|
119
|
+
const found = [...frame.boundForSuper(name) ?? [], ...level > 0 ? left[level - 1]?.lookup(name) ?? [] : []];
|
|
119
120
|
definitions.push(...found);
|
|
120
121
|
if (found.some(d => d.cds === undefined)) {
|
|
121
122
|
return { definitions, definite: true };
|
|
@@ -126,7 +127,10 @@ function lexicalDefinitions(name, call, graph) {
|
|
|
126
127
|
}
|
|
127
128
|
/** Processes a built-in 'get' function call. */
|
|
128
129
|
function processGet(name, args, rootId, data, config = {}) {
|
|
129
|
-
const resolution = (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, ['envir', ...built_in_envir_utils_1.EnvirPositionFormals]);
|
|
130
|
+
const resolution = (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, ['envir', 'env', ...built_in_envir_utils_1.EnvirPositionFormals]);
|
|
131
|
+
if (config.locks) {
|
|
132
|
+
(0, built_in_ambient_state_1.markLocking)(data.environment);
|
|
133
|
+
}
|
|
130
134
|
const retrieve = r_argument_1.RArgument.unnamedValueOf(args[0]);
|
|
131
135
|
const targets = retrieve === undefined ? [] : synthesizeTargets(retrieve, name, rootId, data);
|
|
132
136
|
if (targets.length === 0) {
|
|
@@ -177,6 +181,9 @@ function processGet(name, args, rootId, data, config = {}) {
|
|
|
177
181
|
else if ((0, built_in_envir_utils_1.suppliesArg)(args, config.sig, built_in_envir_utils_1.EnvirPositionFormals)) {
|
|
178
182
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
179
183
|
}
|
|
184
|
+
if (config.hasUnknownSideEffects) {
|
|
185
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
186
|
+
}
|
|
180
187
|
const isolatedTarget = resolution?.envirData.environment.current.builtInEnv === true;
|
|
181
188
|
const readsToDrop = isolatedTarget
|
|
182
189
|
? new Set(named.filter(assert_1.isNotUndefined).map(t => t.entryPoint))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
-
import type
|
|
2
|
+
import { type DataflowInformation } from '../../../../../info';
|
|
3
3
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
4
4
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
5
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
@@ -4,6 +4,7 @@ exports.processIfThenElse = processIfThenElse;
|
|
|
4
4
|
const hooks_1 = require("../../../../../hooks");
|
|
5
5
|
const processor_1 = require("../../../../../processor");
|
|
6
6
|
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
7
|
+
const info_1 = require("../../../../../info");
|
|
7
8
|
const resolve_1 = require("../../../../../eval/resolve/resolve");
|
|
8
9
|
const known_call_handling_1 = require("../known-call-handling");
|
|
9
10
|
const common_1 = require("../common");
|
|
@@ -116,8 +117,9 @@ function processIfThenElse(name, args, rootId, data, config) {
|
|
|
116
117
|
});
|
|
117
118
|
// as an if always evaluates its condition, we add a 'reads'-edge
|
|
118
119
|
nextGraph.addEdge(rootId, cond.entryPoint, edge_1.EdgeType.Reads);
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
/* a branch's exit keeps the conditions it has within the branch, as the `return` of an `else if` without an `else` (#2810) */
|
|
121
|
+
const underBranch = (exits, when) => (exits ?? []).map(e => ({ ...e, cds: uncertain ? (0, info_1.withCds)(e.cds ?? data.cds, [{ id: rootId, when }]) : e.cds }));
|
|
122
|
+
const exitPoints = underBranch(then?.exitPoints, true).concat(underBranch(otherwise?.exitPoints, false));
|
|
121
123
|
const entryOrJoin = (branch) => branch ? control_flow_1.ControlFlow.entryOf(branch) : rootId;
|
|
122
124
|
const reachesJoin = then === undefined || otherwise === undefined
|
|
123
125
|
|| control_flow_1.ControlFlow.canComplete(then) || control_flow_1.ControlFlow.canComplete(otherwise);
|
|
@@ -60,6 +60,11 @@ export declare function attachLibrary(pack: BrandedNamespace, dependency: Packag
|
|
|
60
60
|
* global environment. A call nothing resolves may go to any of them.
|
|
61
61
|
*/
|
|
62
62
|
export declare function loadNodesForNamespace(env: REnvironmentInformation, pack?: BrandedNamespace): NodeId[];
|
|
63
|
+
/**
|
|
64
|
+
* The load calls that attached a package shipping the data set `name` (`starwars` of `dplyr`), which a read of the
|
|
65
|
+
* name that nothing defines has to keep: R finds the data set as lazy data of the attached package.
|
|
66
|
+
*/
|
|
67
|
+
export declare function dataLoadNodesForNamespace(env: REnvironmentInformation, name: BrandedIdentifier): NodeId[];
|
|
63
68
|
/**
|
|
64
69
|
* Processes `conflicted::conflict_prefer(name, winner)` and `conflicts_prefer(pkg::fn, ...)`: the preferred function is
|
|
65
70
|
* put on top of the search path, as conflicted does with its `.conflicts` entry, so the name resolves to it from then on.
|
|
@@ -4,6 +4,7 @@ exports.processLibrary = processLibrary;
|
|
|
4
4
|
exports.attachExportVertex = attachExportVertex;
|
|
5
5
|
exports.attachLibrary = attachLibrary;
|
|
6
6
|
exports.loadNodesForNamespace = loadNodesForNamespace;
|
|
7
|
+
exports.dataLoadNodesForNamespace = dataLoadNodesForNamespace;
|
|
7
8
|
exports.processPrefer = processPrefer;
|
|
8
9
|
exports.attachDependencyToEnvironment = attachDependencyToEnvironment;
|
|
9
10
|
exports.attachBaseRNamespaces = attachBaseRNamespaces;
|
|
@@ -42,6 +43,7 @@ const vertex_1 = require("../../../../../graph/vertex");
|
|
|
42
43
|
const r_base_packages_1 = require("../../../../../../util/r-base-packages");
|
|
43
44
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
44
45
|
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
46
|
+
const r_datasets_1 = require("../../../../../../util/r-datasets");
|
|
45
47
|
const built_in_load_1 = require("./built-in-load");
|
|
46
48
|
/**
|
|
47
49
|
* Process a library call like `library` or `require`
|
|
@@ -332,6 +334,26 @@ function loadNodesForNamespace(env, pack) {
|
|
|
332
334
|
}
|
|
333
335
|
return nodes;
|
|
334
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* The load calls that attached a package shipping the data set `name` (`starwars` of `dplyr`), which a read of the
|
|
339
|
+
* name that nothing defines has to keep: R finds the data set as lazy data of the attached package.
|
|
340
|
+
*/
|
|
341
|
+
function dataLoadNodesForNamespace(env, name) {
|
|
342
|
+
if (env.current.builtInEnv) {
|
|
343
|
+
return [];
|
|
344
|
+
}
|
|
345
|
+
const loads = new Map();
|
|
346
|
+
for (const e of environment_1.REnvironment.searchPath(env.current)) {
|
|
347
|
+
if (e.t === undefined) {
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
if (e.n !== undefined && e.d !== undefined) {
|
|
351
|
+
loads.set(e.n, [...loads.get(e.n) ?? [], e.d]);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
const pkg = loads.size === 0 ? undefined : (0, r_datasets_1.datasetShape)(name, undefined, p => loads.has(p))?.pkg;
|
|
355
|
+
return pkg === undefined ? [] : loads.get(pkg) ?? [];
|
|
356
|
+
}
|
|
335
357
|
/**
|
|
336
358
|
* Processes `conflicted::conflict_prefer(name, winner)` and `conflicts_prefer(pkg::fn, ...)`: the preferred function is
|
|
337
359
|
* put on top of the search path, as conflicted does with its `.conflicts` entry, so the name resolves to it from then on.
|
|
@@ -438,6 +460,7 @@ function attachResolved(dependency, envInfo, ctx, spec, definedAt, attaching, cd
|
|
|
438
460
|
const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
|
|
439
461
|
const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType);
|
|
440
462
|
layer.adoptMap(lazyExports(pack, exports, ctx, definedAt, cds, dependency.namespaceInfo));
|
|
463
|
+
layer.d = shipsData(pack) ? definedAt : undefined;
|
|
441
464
|
return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
|
|
442
465
|
}
|
|
443
466
|
/* as R does: the Depends first (at the default position, whatever `pos` says), then `pack`, then what its `.onAttach` attaches */
|
|
@@ -450,9 +473,14 @@ function attachResolved(dependency, envInfo, ctx, spec, definedAt, attaching, cd
|
|
|
450
473
|
const importsEnv = imports(new environment_1.Environment(below.current).asLibrary(pack, environment_1.EnvType.Imports), dependency.namespaceInfo, ctx);
|
|
451
474
|
const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace);
|
|
452
475
|
namespaceEnv.adoptMap(lazyExports(pack, exports, ctx, definedAt, cds, dependency.namespaceInfo));
|
|
476
|
+
namespaceEnv.d = shipsData(pack) ? definedAt : undefined;
|
|
453
477
|
const attached = { level: below.level, current: environment_1.REnvironment.attachAt(below.current, namespaceEnv, importsEnv, withStartupPosition(pack, below, spec).pos) };
|
|
454
478
|
return alongside(attached, onAttach);
|
|
455
479
|
}
|
|
480
|
+
/** whether `pack` ships data sets, which its load binds as lazy data */
|
|
481
|
+
function shipsData(pack) {
|
|
482
|
+
return (0, r_datasets_1.datasetsOf)(pack).length > 0;
|
|
483
|
+
}
|
|
456
484
|
/** `spec` with the position R gives a startup package, unless a position is given, see {@link startupAttachPosition} */
|
|
457
485
|
function withStartupPosition(pack, envInfo, spec) {
|
|
458
486
|
if (spec.pos !== undefined || spec.namespaceOnly) {
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.processLoadCall = processLoadCall;
|
|
4
4
|
exports.sexpTypeToReferenceType = sexpTypeToReferenceType;
|
|
5
5
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
6
|
+
const control_flow_1 = require("../../../../control-flow");
|
|
7
|
+
const built_in_expression_list_1 = require("./built-in-expression-list");
|
|
6
8
|
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
7
9
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
8
10
|
const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
|
|
@@ -16,7 +18,6 @@ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
|
|
|
16
18
|
const built_in_source_1 = require("./built-in-source");
|
|
17
19
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
18
20
|
const logger_1 = require("../../../../../logger");
|
|
19
|
-
const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
|
|
20
21
|
const edge_1 = require("../../../../../graph/edge");
|
|
21
22
|
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
22
23
|
const r_value_1 = require("../../../../../eval/values/r-value");
|
|
@@ -34,13 +35,13 @@ function processLoadCall(name, args, rootId, data) {
|
|
|
34
35
|
const { fileArg, envirArg } = loadArgsOf(args, data);
|
|
35
36
|
if (!fileArg) {
|
|
36
37
|
const fn = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' });
|
|
37
|
-
(0,
|
|
38
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
|
|
38
39
|
return fn.information;
|
|
39
40
|
}
|
|
40
41
|
const fn = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Load });
|
|
41
42
|
if (data.ctx.config.ignoreLoadCalls) {
|
|
42
43
|
logger_1.dataflowLogger.warn(`Skipping load call ${JSON.stringify(fileArg)} (disabled in config file)`);
|
|
43
|
-
(0,
|
|
44
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
|
|
44
45
|
return fn.information;
|
|
45
46
|
}
|
|
46
47
|
const envirResolution = envirArg ? (0, built_in_envir_utils_1.envirOf)((0, built_in_envir_utils_1.resolveArgToEnvirOrAmbiguous)(envirArg, data)) : undefined;
|
|
@@ -92,12 +93,12 @@ function processLoadCall(name, args, rootId, data) {
|
|
|
92
93
|
if (saved !== undefined) {
|
|
93
94
|
const loaded = withLoaded(saved.names.map(n => ({ name: n })), rootId, fn, [...(data.cds ?? []), { id: rootId, when: true }], data, envirResolution);
|
|
94
95
|
if (!saved.complete) {
|
|
95
|
-
(0,
|
|
96
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(loaded.graph, loaded.environment, rootId);
|
|
96
97
|
}
|
|
97
98
|
return loaded;
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
(0,
|
|
101
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
|
|
101
102
|
return fn.information;
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
@@ -163,12 +164,21 @@ function withLoaded(variables, rootId, fn, loadCds, data, envir) {
|
|
|
163
164
|
const location = data.completeAst.idMap.get(rootId)?.location ?? range_1.SourceRange.invalid();
|
|
164
165
|
let environment = fn.information.environment;
|
|
165
166
|
const out = [...fn.information.out];
|
|
167
|
+
/* the restored names are bound once the call completes, one after the other, and the program goes on from the last */
|
|
168
|
+
let flow = fn.information;
|
|
166
169
|
for (const variable of variables) {
|
|
167
170
|
const [next, defined] = defineLoadedVariable(variable, rootId, fn, environment, location, loadCds, data);
|
|
168
171
|
environment = next;
|
|
172
|
+
(0, built_in_expression_list_1.noteOwnMethod)(variable.name, environment, data.ctx);
|
|
169
173
|
out.push(defined);
|
|
174
|
+
for (const id of [`${defined.nodeId}:fdef`, defined.nodeId]) {
|
|
175
|
+
if (fn.information.graph.hasVertex(id)) {
|
|
176
|
+
control_flow_1.ControlFlow.continuesWith(fn.information.graph, flow, id);
|
|
177
|
+
flow = { ...flow, cfgExit: id };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
170
180
|
}
|
|
171
|
-
const result = { ...fn.information, environment, out };
|
|
181
|
+
const result = { ...fn.information, environment, out, cfgExit: flow.cfgExit };
|
|
172
182
|
return envir === undefined ? result : (0, built_in_envir_utils_1.routeWrittenToEnvir)(result, envir, rootId, data.environment, rootId);
|
|
173
183
|
}
|
|
174
184
|
function defineLoadedVariable(variable, rootId, fn, envir, loadLocation, loadCds, data) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
-
import { DataflowInformation } from '../../../../../info';
|
|
2
|
+
import { DataflowInformation, type ExitPoint } from '../../../../../info';
|
|
3
3
|
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
5
5
|
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
@@ -20,3 +20,8 @@ export interface LocalFunctionConfiguration {
|
|
|
20
20
|
export declare function processLocal<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: LocalFunctionConfiguration): DataflowInformation;
|
|
21
21
|
/** Evaluates `expr` in the environment `envir` pins down, or in a fresh frame on top of the current one, as `local` and `eval(expr, envir)` do. */
|
|
22
22
|
export declare function evaluateInEnvir<OtherInfo>(expr: RNode<OtherInfo & ParentInformation>, envir: EnvirResolution<OtherInfo> | undefined, rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
|
|
23
|
+
/**
|
|
24
|
+
* The exits that leave a construct `return` leaves only itself (`local`, `eval`). If there is such a `return`, it may preempt
|
|
25
|
+
* every other exit, which therefore only happens if the construct is not left that way.
|
|
26
|
+
*/
|
|
27
|
+
export declare function exitsPassingReturn(exits: readonly ExitPoint[], rootId: NodeId): ExitPoint[];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processLocal = processLocal;
|
|
4
4
|
exports.evaluateInEnvir = evaluateInEnvir;
|
|
5
|
+
exports.exitsPassingReturn = exitsPassingReturn;
|
|
5
6
|
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
6
7
|
const built_in_function_definition_1 = require("./built-in-function-definition");
|
|
7
8
|
const processor_1 = require("../../../../../processor");
|
|
@@ -12,11 +13,13 @@ const known_call_handling_1 = require("../known-call-handling");
|
|
|
12
13
|
const control_flow_1 = require("../../../../control-flow");
|
|
13
14
|
const common_1 = require("../common");
|
|
14
15
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
16
|
+
const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
15
17
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
18
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
17
19
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
18
20
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
19
21
|
const environment_1 = require("../../../../../environments/environment");
|
|
22
|
+
const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
|
|
20
23
|
/** Processes a built-in 'local' function call. */
|
|
21
24
|
function processLocal(name, args, rootId, data, config) {
|
|
22
25
|
if (args.length === 0) {
|
|
@@ -73,7 +76,7 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
73
76
|
const baseResult = {
|
|
74
77
|
hooks: dfExpr.hooks.concat(dfEnv.hooks),
|
|
75
78
|
environment: dfExpr.environment,
|
|
76
|
-
exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints
|
|
79
|
+
exitPoints: dfEnv.exitPoints.concat(exitsPassingReturn(dfExpr.exitPoints, rootId)),
|
|
77
80
|
graph,
|
|
78
81
|
entryPoint: rootId,
|
|
79
82
|
cfgEntry,
|
|
@@ -92,11 +95,43 @@ function evaluateInEnvir(expr, envir, rootId, data) {
|
|
|
92
95
|
(0, built_in_function_definition_1.updateNestedFunctionClosures)(dfExpr.graph, dfExpr.environment, []);
|
|
93
96
|
if (envir !== undefined) {
|
|
94
97
|
const environment = { level: data.environment.level, current: environment_1.REnvironment.adoptSearchPath(data.environment.current, dfExpr.environment.current) };
|
|
95
|
-
|
|
98
|
+
const own = envir.envirData.environment.current;
|
|
99
|
+
const idMap = data.completeAst.idMap;
|
|
100
|
+
/* a function the environment binds itself, as an active binding is, is looked up there: `evalq(a, e)` runs the `a` of `e` */
|
|
101
|
+
const boundInEnvir = (ref) => {
|
|
102
|
+
const defs = (ref.name === undefined ? undefined : own.lookup(identifier_1.Identifier.getName(ref.name)))?.filter(d => (0, identifier_1.isInGraphDefinition)(d) && d.value?.some(v => r_function_definition_1.RFunctionDefinition.is(idMap.get(v))));
|
|
103
|
+
for (const def of defs ?? []) {
|
|
104
|
+
dfExpr.graph.addEdge(ref.nodeId, def.nodeId, edge_1.EdgeType.Reads);
|
|
105
|
+
}
|
|
106
|
+
return defs !== undefined && defs.length > 0;
|
|
107
|
+
};
|
|
108
|
+
const linked = { ...dfExpr, environment, in: dfExpr.in.filter(r => !boundInEnvir(r)), unknownReferences: dfExpr.unknownReferences.filter(r => !boundInEnvir(r)) };
|
|
109
|
+
const routed = (0, built_in_envir_utils_1.routeWrittenToEnvir)(linked, envir, rootId, data.environment);
|
|
110
|
+
return { ...routed, environment: sessionStateWrittenBy(dfExpr, routed.environment) };
|
|
96
111
|
}
|
|
97
112
|
const environment = environment_1.REnvironment.popLocal(dfExpr.environment);
|
|
98
113
|
/* definitions of the local scope vanish with it, only what escaped it may bubble up */
|
|
99
114
|
const out = dfExpr.out.filter(o => o.name !== undefined && resolve_helper_1.Resolve.byNameAndType(o.name, environment, o.type)?.some(d => d.nodeId === o.nodeId));
|
|
100
115
|
return { ...dfExpr, environment, out };
|
|
101
116
|
}
|
|
117
|
+
/** The state of the session `dfExpr` writes (options, sinks, the device) is the same whatever environment it is evaluated in, so it stays written for the caller as well: `local(options(digits = 3), envir = e)`. */
|
|
118
|
+
function sessionStateWrittenBy(dfExpr, environment) {
|
|
119
|
+
for (const [name, definitions] of environment_1.REnvironment.findGlobal(dfExpr.environment.current).memory) {
|
|
120
|
+
for (const definition of ambient_state_name_1.AmbientStateName.is(name) ? definitions : []) {
|
|
121
|
+
if (dfExpr.graph.hasVertex(definition.nodeId)) {
|
|
122
|
+
/* the caller keeps what it knew besides, as the evaluation need not have replaced it */
|
|
123
|
+
environment = environment_1.REnvironment.define({ ...definition, name }, true, environment, true);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return environment;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The exits that leave a construct `return` leaves only itself (`local`, `eval`). If there is such a `return`, it may preempt
|
|
131
|
+
* every other exit, which therefore only happens if the construct is not left that way.
|
|
132
|
+
*/
|
|
133
|
+
function exitsPassingReturn(exits, rootId) {
|
|
134
|
+
const returns = exits.some(e => e.type === 1 /* ExitPointType.Return */);
|
|
135
|
+
return exits.filter(e => e.type !== 1 /* ExitPointType.Return */).map(e => returns && e.type !== 0 /* ExitPointType.Default */ ? { ...e, cds: (0, info_1.withCds)(e.cds, [{ id: rootId, when: true }]) } : e);
|
|
136
|
+
}
|
|
102
137
|
//# sourceMappingURL=built-in-local.js.map
|
|
@@ -45,6 +45,10 @@ function processRecall(name, args, rootId, data, config) {
|
|
|
45
45
|
}
|
|
46
46
|
if (closure) {
|
|
47
47
|
information.graph.addEdge(rootId, closure, edge_1.EdgeType.Calls);
|
|
48
|
+
/* `sys.function()` hands back the closure it runs in, which a call on its result (`sys.function()(n - 1)`) runs */
|
|
49
|
+
if (config?.unknownOnNonZeroArg) {
|
|
50
|
+
information.graph.addEdge(rootId, closure, edge_1.EdgeType.Returns);
|
|
51
|
+
}
|
|
48
52
|
// also kill the name of the recall function
|
|
49
53
|
const r = information.graph.getVertex(rootId);
|
|
50
54
|
if (vertex_1.DfgVertex.isFunctionCall(r)) {
|