@eagleoutice/flowr 2.17.3 → 2.17.5
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 -52
- package/abstract-interpretation/absint-inference.js +1 -2
- package/abstract-interpretation/data-frame/arguments.d.ts +14 -3
- package/abstract-interpretation/data-frame/arguments.js +34 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +7 -15
- package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -2
- package/abstract-interpretation/data-frame/semantics.d.ts +8 -1
- package/abstract-interpretation/data-frame/semantics.js +14 -6
- package/abstract-interpretation/domains/state-abstract-domain.js +28 -18
- package/abstract-interpretation/domains/state-map.d.ts +43 -0
- package/abstract-interpretation/domains/state-map.js +147 -0
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +8 -7
- package/cli/repl/commands/repl-dataflow.js +5 -5
- package/cli/repl/commands/repl-execute.js +3 -2
- package/cli/repl/commands/repl-parse.js +2 -1
- package/cli/repl/commands/repl-signature.d.ts +1 -1
- package/cli/repl/completion.d.ts +23 -0
- package/cli/repl/completion.js +9 -0
- package/cli/repl/core.d.ts +0 -23
- package/cli/repl/core.js +0 -5
- package/cli/repl/parser/slice-query-parser.d.ts +1 -1
- package/cli/repl/parser/slice-query-parser.js +3 -3
- package/cli/repl/print-version.d.ts +1 -1
- package/cli/repl/print-version.js +2 -1
- package/cli/repl/server/connection.d.ts +1 -1
- package/cli/repl/server/connection.js +7 -9
- package/cli/slicer-app.js +2 -1
- package/clones/algorithms/baxter-ast.d.ts +33 -0
- package/clones/algorithms/baxter-ast.js +70 -0
- package/clones/algorithms/greedy-string-tiling.d.ts +17 -0
- package/clones/algorithms/greedy-string-tiling.js +56 -0
- package/clones/algorithms/winnowing.d.ts +27 -0
- package/clones/algorithms/winnowing.js +66 -0
- package/clones/clone-ast.d.ts +75 -0
- package/clones/clone-ast.js +174 -0
- package/clones/clone-dataflow.d.ts +11 -0
- package/clones/clone-dataflow.js +83 -0
- package/clones/clone-detector.d.ts +116 -0
- package/clones/clone-detector.js +200 -0
- package/clones/clone-index.d.ts +54 -0
- package/clones/clone-index.js +56 -0
- package/config.d.ts +21 -2
- package/config.js +7 -1
- package/control-flow/basic-cfg-guided-visitor.js +1 -2
- package/control-flow/happens-before.d.ts +2 -0
- package/control-flow/happens-before.js +15 -9
- package/control-flow/simple-visitor.js +2 -4
- package/core/steps/all/core/00-parse.js +2 -1
- package/core/steps/all/core/01-parse-tree-sitter.js +2 -1
- package/core/steps/all/core/10-normalize.js +2 -1
- package/core/steps/all/core/11-normalize-tree-sitter.js +2 -1
- package/core/steps/all/static-slicing/00-slice.js +2 -1
- package/core/steps/all/static-slicing/10-reconstruct.js +2 -1
- package/core/steps/pipeline/create-pipeline.js +1 -2
- package/core/steps/pipeline/default-pipelines.d.ts +1 -1
- package/core/steps/pipeline/default-pipelines.js +5 -4
- package/core/steps/pipeline-step.d.ts +3 -1
- package/core/steps/pipeline-step.js +5 -0
- package/data/r-base-primitives.generated.d.ts +2 -1
- package/dataflow/cluster.js +1 -2
- package/dataflow/environments/ambient-state-name.d.ts +14 -22
- package/dataflow/environments/ambient-state-name.js +4 -18
- package/dataflow/environments/apply-kill.d.ts +9 -20
- package/dataflow/environments/apply-kill.js +51 -25
- package/dataflow/environments/built-in-config.d.ts +7 -15
- package/dataflow/environments/built-in-config.js +15 -16
- package/dataflow/environments/built-in-eval-name.d.ts +5 -6
- package/dataflow/environments/built-in-eval-name.js +4 -5
- package/dataflow/environments/built-in-kinds.d.ts +111 -0
- package/dataflow/environments/built-in-kinds.js +35 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +11 -0
- package/dataflow/environments/built-in-props.d.ts +66 -172
- package/dataflow/environments/built-in-props.js +47 -151
- package/dataflow/environments/built-in.d.ts +42 -76
- package/dataflow/environments/built-in.js +46 -66
- package/dataflow/environments/data-masking-functions.d.ts +2 -2
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +7 -0
- package/dataflow/environments/default-builtin-config/base-functions.js +339 -0
- package/dataflow/environments/default-builtin-config/base-language.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/base-language.js +66 -0
- package/dataflow/environments/default-builtin-config/base-operators.d.ts +58 -0
- package/dataflow/environments/default-builtin-config/base-operators.js +169 -0
- package/dataflow/environments/default-builtin-config/database-access.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/database-access.js +16 -0
- package/dataflow/environments/default-builtin-config/define-helpers.d.ts +45 -0
- package/dataflow/environments/default-builtin-config/define-helpers.js +50 -0
- package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/dev-tooling.js +63 -0
- package/dataflow/environments/default-builtin-config/file-io.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/file-io.js +81 -0
- package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/graphics-devices.js +57 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +18 -0
- package/dataflow/environments/default-builtin-config/index.js +114 -0
- package/dataflow/environments/default-builtin-config/media-formats.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/media-formats.js +41 -0
- package/dataflow/environments/default-builtin-config/misc-packages.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/misc-packages.js +18 -0
- package/dataflow/environments/default-builtin-config/network-access.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/network-access.js +47 -0
- package/dataflow/environments/default-builtin-config/object-systems.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/object-systems.js +39 -0
- package/dataflow/environments/default-builtin-config/package-data-table.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/package-data-table.js +18 -0
- package/dataflow/environments/default-builtin-config/package-spatial.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/package-spatial.js +32 -0
- package/dataflow/environments/default-builtin-config/package-tidyverse.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/package-tidyverse.js +96 -0
- package/dataflow/environments/default-builtin-config/package-utils.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/package-utils.js +35 -0
- package/dataflow/environments/default-builtin-config/package-withr.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/package-withr.js +41 -0
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/parallel-execution.js +31 -0
- package/dataflow/environments/default-builtin-config/session-interactive.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/session-interactive.js +31 -0
- package/dataflow/environments/default-builtin-config/shared-configs.d.ts +267 -0
- package/dataflow/environments/default-builtin-config/shared-configs.js +483 -0
- package/dataflow/environments/default-builtin-config/shared-signatures.d.ts +21 -0
- package/dataflow/environments/default-builtin-config/shared-signatures.js +32 -0
- package/dataflow/environments/default-builtin-config/statistics.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/statistics.js +32 -0
- package/dataflow/environments/default-builtin-config/unit-testing.d.ts +3 -0
- package/dataflow/environments/default-builtin-config/unit-testing.js +13 -0
- package/dataflow/environments/environment.d.ts +28 -52
- package/dataflow/environments/environment.js +24 -71
- package/dataflow/environments/group-generics.d.ts +12 -19
- package/dataflow/environments/group-generics.js +17 -14
- package/dataflow/environments/identifier.d.ts +72 -427
- package/dataflow/environments/identifier.js +34 -145
- package/dataflow/environments/pkg-name.d.ts +197 -0
- package/dataflow/environments/pkg-name.js +3 -0
- package/dataflow/environments/query-fn-props.d.ts +27 -76
- package/dataflow/environments/query-fn-props.js +34 -95
- package/dataflow/environments/resolve-by-name.d.ts +6 -16
- package/dataflow/environments/resolve-by-name.js +23 -35
- package/dataflow/environments/scoping.d.ts +5 -5
- package/dataflow/environments/scoping.js +13 -5
- package/dataflow/eval/resolve/alias-tracking.d.ts +31 -68
- package/dataflow/eval/resolve/alias-tracking.js +611 -126
- package/dataflow/eval/resolve/match-arguments.d.ts +5 -3
- package/dataflow/eval/resolve/resolve-argument.d.ts +11 -11
- package/dataflow/eval/resolve/resolve-argument.js +35 -35
- package/dataflow/eval/resolve/resolve-field.d.ts +10 -0
- package/dataflow/eval/resolve/resolve-field.js +127 -0
- package/dataflow/eval/resolve/resolve-numbers.d.ts +1 -178
- package/dataflow/eval/resolve/resolve-numbers.js +2 -13
- package/dataflow/eval/resolve/resolve-replacement.d.ts +10 -0
- package/dataflow/eval/resolve/resolve-replacement.js +80 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +3 -95
- package/dataflow/eval/resolve/resolve-strings.js +2 -17
- package/dataflow/eval/resolve/resolve-working-directory.js +3 -4
- package/dataflow/eval/resolve/resolve.d.ts +13 -10
- package/dataflow/eval/resolve/resolve.js +81 -32
- package/dataflow/eval/values/general.d.ts +6 -24
- package/dataflow/eval/values/general.js +12 -29
- package/dataflow/eval/values/lists/list-constants.d.ts +11 -0
- package/dataflow/eval/values/lists/list-constants.js +65 -0
- package/dataflow/eval/values/r-value.d.ts +20 -23
- package/dataflow/eval/values/r-value.js +22 -17
- package/dataflow/extractor.d.ts +2 -10
- package/dataflow/extractor.js +134 -62
- package/dataflow/fn/argument-roles.d.ts +2 -4
- package/dataflow/fn/argument-roles.js +49 -23
- package/dataflow/fn/class-declaration.d.ts +36 -52
- package/dataflow/fn/class-declaration.js +22 -56
- package/dataflow/fn/condition-handlers.d.ts +2 -1
- package/dataflow/fn/dispatch.d.ts +70 -0
- package/dataflow/fn/dispatch.js +434 -0
- package/dataflow/fn/exceptions-of-function.d.ts +1 -2
- package/dataflow/fn/exceptions-of-function.js +36 -106
- package/dataflow/fn/frame-reflection.d.ts +1 -3
- package/dataflow/fn/frame-reflection.js +8 -16
- package/dataflow/fn/function-props.d.ts +2 -5
- package/dataflow/fn/function-props.js +27 -36
- package/dataflow/fn/function-semantics.d.ts +14 -26
- package/dataflow/fn/function-semantics.js +4 -18
- package/dataflow/fn/higher-order-function.js +2 -4
- package/dataflow/fn/strict-function.d.ts +10 -35
- package/dataflow/fn/strict-function.js +126 -138
- package/dataflow/graph/ambient-access.d.ts +51 -0
- package/dataflow/graph/ambient-access.js +80 -0
- package/dataflow/graph/call-graph.d.ts +9 -29
- package/dataflow/graph/call-graph.js +17 -41
- package/dataflow/graph/closure-frames.d.ts +46 -0
- package/dataflow/graph/closure-frames.js +225 -0
- package/dataflow/graph/dataflowgraph-builder.d.ts +25 -96
- package/dataflow/graph/dataflowgraph-builder.js +29 -97
- package/dataflow/graph/df-helper.d.ts +48 -187
- package/dataflow/graph/df-helper.js +107 -207
- package/dataflow/graph/diff-dataflow-graph.d.ts +5 -15
- package/dataflow/graph/diff-dataflow-graph.js +25 -25
- package/dataflow/graph/edge.js +1 -1
- package/dataflow/graph/graph-helper.d.ts +10 -46
- package/dataflow/graph/graph-helper.js +16 -50
- package/dataflow/graph/graph.d.ts +44 -97
- package/dataflow/graph/graph.js +83 -79
- package/dataflow/graph/match-args.d.ts +21 -88
- package/dataflow/graph/match-args.js +284 -97
- package/dataflow/graph/vertex.d.ts +101 -128
- package/dataflow/graph/vertex.js +23 -20
- package/dataflow/hooks.d.ts +7 -14
- package/dataflow/hooks.js +15 -13
- package/dataflow/info.d.ts +2 -17
- package/dataflow/internal/dispatch-linking.d.ts +71 -0
- package/dataflow/internal/dispatch-linking.js +332 -0
- package/dataflow/internal/linker.d.ts +48 -50
- package/dataflow/internal/linker.js +458 -155
- package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +7 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +10 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +25 -69
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +292 -89
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +10 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +66 -45
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +15 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +85 -64
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +15 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +416 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +37 -54
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +192 -111
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +60 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +80 -76
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +1 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +4 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +436 -140
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +18 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +90 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +9 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +9 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +10 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +8 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +20 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +17 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +117 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +8 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +18 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -34
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +42 -56
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +4 -18
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +16 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +18 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +130 -65
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +39 -21
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +587 -107
- package/dataflow/internal/process/functions/call/common.d.ts +8 -24
- package/dataflow/internal/process/functions/call/common.js +24 -24
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -27
- package/dataflow/internal/process/functions/call/deferred.js +6 -27
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +7 -50
- package/dataflow/internal/process/functions/call/known-call-handling.js +14 -50
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -4
- package/dataflow/internal/process/functions/call/named-call-handling.js +14 -35
- package/dataflow/internal/process/functions/call/nse-kind.d.ts +24 -0
- package/dataflow/internal/process/functions/call/nse-kind.js +30 -0
- package/dataflow/internal/process/functions/call/nse.d.ts +2 -9
- package/dataflow/internal/process/functions/call/nse.js +6 -13
- package/dataflow/internal/process/functions/call/quoted.d.ts +4 -15
- package/dataflow/internal/process/functions/call/quoted.js +26 -62
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +3 -6
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +29 -11
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/program-order.d.ts +3 -10
- package/dataflow/internal/program-order.js +19 -10
- package/dataflow/origin/dfg-get-origin.js +2 -1
- package/documentation/data/faq/faqs.js +16 -1
- package/documentation/data/interface/doc-writing-code.js +5 -7
- package/documentation/doc-capabilities.js +3 -3
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-code.d.ts +0 -5
- package/documentation/doc-util/doc-code.js +2 -22
- package/documentation/doc-util/doc-query.d.ts +1 -2
- package/documentation/doc-util/doc-query.js +4 -5
- package/documentation/doc-util/doc-search.js +1 -1
- package/documentation/wiki-analyzer.js +4 -3
- package/documentation/wiki-core.js +5 -5
- package/documentation/wiki-dataflow-graph.js +6 -0
- package/documentation/wiki-interface.js +2 -1
- package/documentation/wiki-linter.js +15 -3
- package/documentation/wiki-linting-and-testing.js +15 -2
- package/documentation/wiki-query.js +114 -31
- package/index.d.ts +3 -1
- package/index.js +6 -3
- package/linter/linter-executor.js +1 -1
- package/linter/linter-rules.d.ts +37 -8
- package/linter/linter-rules.js +8 -1
- package/linter/linter-util.d.ts +3 -3
- package/linter/linter-util.js +1 -1
- package/linter/rules/absolute-path.js +5 -5
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -1
- package/linter/rules/cmd-check/call-arguments.d.ts +3 -2
- package/linter/rules/cmd-check/call-arguments.js +5 -5
- package/linter/rules/cmd-check/cmd-check-util.d.ts +9 -8
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -1
- package/linter/rules/cmd-check/dependency-declaration.js +3 -3
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +3 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +2 -1
- package/linter/rules/cmd-check/file-checks.d.ts +2 -2
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -1
- package/linter/rules/cmd-check/global-environment-modification.d.ts +6 -5
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -1
- package/linter/rules/cmd-check/non-ascii-code.js +1 -1
- package/linter/rules/cmd-check/package-files.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.d.ts +5 -4
- package/linter/rules/cmd-check/package-runtime.js +4 -4
- package/linter/rules/cmd-check/rd-files.js +2 -1
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +3 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +2 -1
- package/linter/rules/code-clones.d.ts +57 -0
- package/linter/rules/code-clones.js +53 -0
- package/linter/rules/deprecated-functions.js +5 -8
- package/linter/rules/file-path-validity.js +11 -9
- package/linter/rules/function-finder-util.d.ts +4 -2
- package/linter/rules/function-finder-util.js +2 -2
- package/linter/rules/naming-convention.d.ts +6 -5
- package/linter/rules/naming-convention.js +2 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -1
- package/linter/rules/no-leaked-credentials.js +1 -1
- package/linter/rules/overwritten-file.d.ts +2 -1
- package/linter/rules/overwritten-file.js +2 -4
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +3 -3
- package/linter/rules/process-state-in-session.d.ts +7 -6
- package/linter/rules/process-state-in-session.js +1 -1
- package/linter/rules/roxygen-arguments.d.ts +1 -1
- package/linter/rules/secret-exfiltration.d.ts +3 -2
- package/linter/rules/secret-exfiltration.js +9 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/unclosed-connection.js +1 -2
- package/linter/rules/undefined-symbol-util.d.ts +3 -2
- package/linter/rules/undefined-symbol.d.ts +3 -2
- package/linter/rules/unescaped-arguments.d.ts +1 -1
- package/linter/rules/unescaped-arguments.js +6 -8
- package/linter/rules/unused-definition.d.ts +4 -3
- package/linter/rules/unused-definition.js +10 -12
- package/linter/rules/unused-import.d.ts +6 -5
- package/linter/rules/unused-import.js +20 -6
- package/package.json +1 -1
- package/project/attached-packages.d.ts +5 -4
- package/project/cache/flowr-analyzer-cache.d.ts +14 -1
- package/project/cache/flowr-analyzer-cache.js +40 -3
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +0 -6
- package/project/cache/flowr-analyzer-controlflow-cache.js +7 -27
- package/project/context/flowr-analyzer-context.d.ts +2 -2
- package/project/context/flowr-analyzer-context.js +2 -2
- package/project/context/flowr-analyzer-dependencies-context.d.ts +12 -12
- package/project/context/flowr-analyzer-environment-context.d.ts +3 -3
- package/project/context/flowr-analyzer-environment-context.js +3 -3
- package/project/context/flowr-analyzer-files-context.d.ts +8 -0
- package/project/context/flowr-analyzer-files-context.js +51 -6
- package/project/context/flowr-analyzer-functions-context.d.ts +9 -7
- package/project/context/flowr-analyzer-gas-context.d.ts +25 -0
- package/project/context/flowr-analyzer-gas-context.js +34 -4
- package/project/dependency-version-space.d.ts +30 -29
- package/project/dependency-version-space.js +1 -2
- package/project/flowr-analyzer-builder.d.ts +2 -3
- package/project/flowr-analyzer.d.ts +35 -12
- package/project/flowr-analyzer.js +18 -33
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +15 -17
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +57 -163
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -3
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -3
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +5 -4
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +2 -2
- package/project/plugins/package-version-plugins/package.d.ts +6 -5
- package/project/plugins/package-version-plugins/package.js +1 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -3
- package/project/sigdb/build.js +1 -1
- package/project/sigdb/decode.d.ts +8 -7
- package/project/sigdb/decode.js +1 -2
- package/project/sigdb/dict.d.ts +2 -1
- package/project/sigdb/dict.js +2 -2
- package/project/sigdb/index-format.d.ts +2 -1
- package/project/sigdb/manifest.d.ts +1 -1
- package/project/sigdb/memory-source.d.ts +18 -17
- package/project/sigdb/on-demand/package-sources.d.ts +4 -3
- package/project/sigdb/on-demand/recoverer.d.ts +2 -1
- package/project/sigdb/on-demand/remote-sources.d.ts +2 -1
- package/project/sigdb/reader.d.ts +85 -80
- package/project/sigdb/reader.js +0 -4
- package/project/sigdb/schema.d.ts +9 -8
- package/project/sigdb/signature-db.d.ts +6 -6
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +6 -0
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +50 -0
- package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +54 -0
- package/queries/catalog/ambient-access-query/ambient-access-query-format.js +45 -0
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +2 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
- package/queries/catalog/call-graph-query/expand-library-internals.d.ts +3 -2
- package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +6 -0
- package/queries/catalog/code-clones-query/code-clones-query-executor.js +38 -0
- package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +54 -0
- package/queries/catalog/code-clones-query/code-clones-query-format.js +73 -0
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +4 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +3 -3
- package/queries/catalog/dependencies-query/data-flow.d.ts +5 -4
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +5 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -10
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +4 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +12 -12
- package/queries/catalog/dependencies-query/dependency-values.d.ts +9 -0
- package/queries/catalog/dependencies-query/dependency-values.js +13 -0
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -4
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +4 -2
- package/queries/catalog/dependencies-query/plot-description.d.ts +1 -1
- package/queries/catalog/dependencies-query/plot-description.js +2 -2
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -1
- package/queries/catalog/dice-query/dice-query-format.js +1 -0
- package/queries/catalog/does-call-query/does-call-query-executor.js +1 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -0
- package/queries/catalog/does-call-query/does-call-query-format.js +1 -0
- package/queries/catalog/files-query/files-query-format.d.ts +1 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +2 -1
- package/queries/catalog/function-info-query/function-origin.d.ts +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +5 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +9 -9
- package/queries/catalog/input-sources-query/simple-input-classifier.js +1 -1
- package/queries/catalog/linter-query/linter-query-executor.js +4 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
- package/queries/catalog/linter-query/linter-query-format.js +16 -11
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/project-query/project-query-format.d.ts +2 -1
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/signature-query/signature-query-executor.d.ts +10 -7
- package/queries/catalog/signature-query/signature-query-executor.js +14 -15
- package/queries/catalog/signature-query/signature-query-format.d.ts +21 -20
- package/queries/catalog/signature-query/signature-query-render.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +9 -5
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/catalog/taint-query/taint-query-format.d.ts +1 -1
- package/queries/query.d.ts +61 -10
- package/queries/query.js +59 -37
- package/r-bridge/data/data.d.ts +39 -28
- package/r-bridge/data/data.js +37 -28
- package/r-bridge/init.js +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +10 -1
- package/r-bridge/lang-4.x/ast/model/model.js +30 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +21 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +25 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -3
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +5 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -7
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +7 -2
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +14 -6
- package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/visitor.js +2 -2
- package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/type.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +3 -2
- package/r-bridge/parser.d.ts +8 -2
- package/r-bridge/parser.js +6 -0
- package/r-bridge/shell-executor.d.ts +2 -2
- package/r-bridge/shell-executor.js +3 -2
- package/r-bridge/shell.d.ts +2 -2
- package/r-bridge/shell.js +3 -2
- package/reconstruct/auto-select/magic-comments.js +1 -1
- package/reconstruct/reconstruct.d.ts +0 -5
- package/reconstruct/reconstruct.js +6 -5
- package/search/flowr-search-builder.d.ts +14 -0
- package/search/flowr-search-builder.js +7 -0
- package/search/flowr-search-executor.js +2 -2
- package/search/flowr-search-filters.js +10 -11
- package/search/flowr-search.js +1 -1
- package/search/search-executor/search-enrichers.d.ts +2 -0
- package/search/search-executor/search-enrichers.js +6 -1
- package/search/search-executor/search-generators.d.ts +2 -3
- package/search/search-executor/search-generators.js +18 -14
- package/search/search-executor/search-mappers.js +1 -1
- package/search/search-executor/search-transformer.d.ts +2 -2
- package/search/search-executor/search-transformer.js +6 -6
- package/search/search-logger.d.ts +1 -0
- package/search/search-logger.js +6 -0
- package/slicing/criterion/parse.d.ts +2 -1
- package/slicing/criterion/parse.js +2 -1
- package/slicing/static/removal-slice.js +2 -1
- package/slicing/static/slice-call.d.ts +30 -4
- package/slicing/static/slice-call.js +74 -9
- package/slicing/static/slicer-types.d.ts +2 -1
- package/slicing/static/static-slicer.js +66 -11
- package/slicing/static/visiting-queue.d.ts +2 -0
- package/slicing/static/visiting-queue.js +4 -0
- package/taint-analysis/builder/report-template.d.ts +3 -3
- package/util/arg-matching.d.ts +1 -1
- package/util/collections/relation.d.ts +23 -0
- package/util/collections/relation.js +63 -0
- package/util/fixpoint.d.ts +65 -0
- package/util/fixpoint.js +216 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/json.d.ts +4 -0
- package/util/json.js +12 -3
- package/util/mermaid/cfg.js +1 -2
- package/util/mermaid/dfg.d.ts +1 -1
- package/util/mermaid/dfg.js +1 -1
- package/util/mermaid/mermaid.d.ts +2 -1
- package/util/monoid.d.ts +26 -0
- package/util/monoid.js +31 -0
- package/util/prefix.d.ts +1 -1
- package/util/r-base-packages.d.ts +10 -7
- package/util/r-base-packages.js +11 -6
- package/util/r-package-urls.d.ts +10 -9
- package/util/r-value.js +2 -1
- package/util/r-version-order.d.ts +2 -0
- package/util/r-version-order.js +19 -0
- package/util/r-version.d.ts +2 -1
- package/util/r-version.js +2 -14
- package/util/range.d.ts +38 -29
- package/util/range.js +10 -5
- package/util/simple-df/dfg-ascii.js +2 -2
- package/util/text/ansi.d.ts +13 -9
- package/util/text/ansi.js +4 -6
- package/util/text/strings.d.ts +10 -3
- package/util/text/strings.js +10 -1
- package/util/version.d.ts +1 -1
- package/util/version.js +2 -1
- package/dataflow/environments/default-builtin-config.d.ts +0 -8856
- package/dataflow/environments/default-builtin-config.js +0 -1735
- package/r-bridge/lang-4.x/ast/model/operators.d.ts +0 -33
- package/r-bridge/lang-4.x/ast/model/operators.js +0 -54
- package/taint-analysis/eval/eval.d.ts +0 -1
- package/taint-analysis/eval/eval.js +0 -124
- package/taint-analysis/eval/instrumentation.d.ts +0 -59
- package/taint-analysis/eval/instrumentation.js +0 -124
|
@@ -18,7 +18,7 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
18
18
|
const AttachableLiterals = new Set(['list', 'data.frame']);
|
|
19
19
|
/** Processes `attach(what, ...)`, injecting the tracked env's known definitions into a new scope layer below `.GlobalEnv`. */
|
|
20
20
|
function processAttach(name, args, rootId, data,
|
|
21
|
-
/* the search path it writes is applied by the registration, see {@link
|
|
21
|
+
/* the search path it writes is applied by the registration, see {@link BuiltInFnInfo} */
|
|
22
22
|
_config = {}) {
|
|
23
23
|
const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Attach }).information;
|
|
24
24
|
const whatArg = args.length >= 1 ? args[0] : undefined;
|
|
@@ -63,7 +63,7 @@ _config = {}) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Processes `detach(name)` and `unloadNamespace(ns)`: the search path entry named (`package:x`, `"x"`, a position, the
|
|
65
65
|
* topmost one if nothing is given) is removed, uncovering what it masked. The entry is read with the keys of the
|
|
66
|
-
* call's search path {@link
|
|
66
|
+
* call's search path {@link BuiltInFnInfo|ambient} write.
|
|
67
67
|
*/
|
|
68
68
|
function processDetach(name, args, rootId, data, config = {}) {
|
|
69
69
|
const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Detach }).information;
|
|
@@ -5,13 +5,13 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
5
5
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
6
6
|
import type { DataflowInformation } from '../../../../../info';
|
|
7
7
|
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
8
|
-
import type
|
|
8
|
+
import { type REnvironmentInformation } from '../../../../../environments/environment';
|
|
9
9
|
import type { ClassDeclarationConfig } from '../../../../../fn/class-declaration';
|
|
10
10
|
/** Processes an `R6Class`/`setRefClass` generator call, tagging it so the assignment layer can record its method list. */
|
|
11
11
|
export declare function processClassGenerator<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
|
|
12
12
|
readonly classDecl?: ClassDeclarationConfig;
|
|
13
13
|
}): DataflowInformation;
|
|
14
|
-
/** The
|
|
14
|
+
/** The env an instance of a class generator's class carries: its `public`/`methods` and `fields`/`private` lists (via {@link resolveListToEnvState}), or an empty one, as every R6 or reference class object is an environment, shared by every variable holding it. */
|
|
15
15
|
export declare function resolveClassMethodsToEnvState<OtherInfo>(source: RNode<OtherInfo & ParentInformation>, data: Pick<DataflowProcessorInformation<never>, 'environment'>): REnvironmentInformation | undefined;
|
|
16
16
|
/** The method env an instance from `<Cls>$new(...)`/`<Cls>[["new"]](...)` carries, from the generator's recorded `returnsEnvState`; `undefined` otherwise. */
|
|
17
17
|
export declare function resolveConstructorInstanceEnvState<OtherInfo>(source: RNode<OtherInfo & ParentInformation>, data: Pick<DataflowProcessorInformation<never>, 'environment'>): REnvironmentInformation | undefined;
|
|
@@ -7,6 +7,7 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
7
7
|
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
8
8
|
const known_call_handling_1 = require("../known-call-handling");
|
|
9
9
|
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
10
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
10
11
|
const built_in_list_1 = require("./built-in-list");
|
|
11
12
|
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
12
13
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
@@ -27,7 +28,7 @@ function processClassGenerator(name, args, rootId, data, config) {
|
|
|
27
28
|
(0, built_in_s_four_1.linkS4Declaration)(info, rootId, data);
|
|
28
29
|
return info;
|
|
29
30
|
}
|
|
30
|
-
/** The
|
|
31
|
+
/** The env an instance of a class generator's class carries: its `public`/`methods` and `fields`/`private` lists (via {@link resolveListToEnvState}), or an empty one, as every R6 or reference class object is an environment, shared by every variable holding it. */
|
|
31
32
|
function resolveClassMethodsToEnvState(source, data) {
|
|
32
33
|
if (!r_function_call_1.RFunctionCall.isNamed(source)) {
|
|
33
34
|
return undefined;
|
|
@@ -39,7 +40,7 @@ function resolveClassMethodsToEnvState(source, data) {
|
|
|
39
40
|
const resolved = list === undefined ? undefined : (0, built_in_list_1.resolveListToEnvState)(list, envState ? { environment: envState } : data, values);
|
|
40
41
|
envState = resolved ?? envState;
|
|
41
42
|
}
|
|
42
|
-
return envState;
|
|
43
|
+
return envState ?? environment_1.REnvironment.pushLocal(data.environment);
|
|
43
44
|
}
|
|
44
45
|
const ConstructorField = 'new';
|
|
45
46
|
/** The method env an instance from `<Cls>$new(...)`/`<Cls>[["new"]](...)` carries, from the generator's recorded `returnsEnvState`; `undefined` otherwise. */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DataflowProcessorInformation } from '../../../../../processor';
|
|
2
|
+
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
3
|
+
import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import type { DataflowGraph } from '../../../../../graph/graph';
|
|
5
|
+
import { type DataflowGraphVertexFunctionDefinition, type DeferredEnvOp } from '../../../../../graph/vertex';
|
|
6
|
+
import { type REnvironmentInformation } from '../../../../../environments/environment';
|
|
7
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
|
|
8
|
+
/** The calls of a function body `roots` whose environment operation depends on the call of the function: a name not written down, or a read or removal in an environment the body does not bind (what a body defines in such an environment under a name written down already reaches the caller, see {@link InGraphIdentifierDefinition#envWrites}). */
|
|
9
|
+
export declare function deferredEnvOps<OtherInfo>(roots: Iterable<NodeId>, graph: DataflowGraph, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DeferredEnvOp[] | undefined;
|
|
10
|
+
/** Runs the {@link deferredEnvOps} of the function `fn` for the call `call`, which runs `fn` itself or through the `chain` of calls in the functions it runs, the last one calling `fn`: the names they compute from parameters resolve with the values the call of `fn` hands over, and an environment a free variable or a parameter names is the one it holds at `call`, if `call` runs `fn` itself, else only the global environment is known to be the same. */
|
|
11
|
+
export declare function instantiateEnvOps(call: NodeId, fn: DataflowGraphVertexFunctionDefinition, chain: readonly NodeId[], environment: REnvironmentInformation, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): REnvironmentInformation;
|
|
12
|
+
/** Whether the call `call` of `fn` replayed the replacement or assignment `write` of its body (see {@link EnvOpKind.Replace} and {@link EnvOpKind.Define}) into the environment it hands over, so what it writes is known there. */
|
|
13
|
+
export declare function replayedAt(write: NodeId, fn: DataflowGraphVertexFunctionDefinition, call: NodeId, graph: DataflowGraph): boolean;
|
|
14
|
+
/** The definitions the function `fn` makes in the frame of its caller (`assign("x", v, envir = parent.frame())`) for the call `call` within another function: the reads of that frame may see them, which the frame does not know of when it is processed, as it learns of the callee later (the top level runs them in {@link instantiateEnvOps}). */
|
|
15
|
+
export declare function linkCallerFrameWrites(call: NodeId, fn: DataflowGraphVertexFunctionDefinition, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): void;
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deferredEnvOps = deferredEnvOps;
|
|
4
|
+
exports.instantiateEnvOps = instantiateEnvOps;
|
|
5
|
+
exports.replayedAt = replayedAt;
|
|
6
|
+
exports.linkCallerFrameWrites = linkCallerFrameWrites;
|
|
7
|
+
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
|
+
const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
|
+
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
10
|
+
const r_number_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
11
|
+
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
12
|
+
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
13
|
+
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
14
|
+
const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
15
|
+
const vertex_1 = require("../../../../../graph/vertex");
|
|
16
|
+
const edge_1 = require("../../../../../graph/edge");
|
|
17
|
+
const df_helper_1 = require("../../../../../graph/df-helper");
|
|
18
|
+
const function_semantics_1 = require("../../../../../fn/function-semantics");
|
|
19
|
+
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
20
|
+
const environment_1 = require("../../../../../environments/environment");
|
|
21
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
22
|
+
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
23
|
+
const apply_kill_1 = require("../../../../../environments/apply-kill");
|
|
24
|
+
const node_value_1 = require("../../../../../eval/resolve/node-value");
|
|
25
|
+
const linker_1 = require("../../../../linker");
|
|
26
|
+
const shared_configs_1 = require("../../../../../environments/default-builtin-config/shared-configs");
|
|
27
|
+
const built_in_stack_env_1 = require("./built-in-stack-env");
|
|
28
|
+
const built_in_envir_utils_1 = require("./built-in-envir-utils");
|
|
29
|
+
const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
30
|
+
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
31
|
+
const OpOfProcessor = {
|
|
32
|
+
[built_in_proc_name_1.BuiltInProcName.Assignment]: vertex_1.EnvOpKind.Define,
|
|
33
|
+
[built_in_proc_name_1.BuiltInProcName.Get]: vertex_1.EnvOpKind.Read,
|
|
34
|
+
[built_in_proc_name_1.BuiltInProcName.Rm]: vertex_1.EnvOpKind.Remove
|
|
35
|
+
};
|
|
36
|
+
/** The formal of `rm` naming what it removes by value, its `...` names them unevaluated. */
|
|
37
|
+
const RemovedByValue = 'list';
|
|
38
|
+
/** The calls of a function body `roots` whose environment operation depends on the call of the function: a name not written down, or a read or removal in an environment the body does not bind (what a body defines in such an environment under a name written down already reaches the caller, see {@link InGraphIdentifierDefinition#envWrites}). */
|
|
39
|
+
function deferredEnvOps(roots, graph, data) {
|
|
40
|
+
let ops;
|
|
41
|
+
for (const id of roots) {
|
|
42
|
+
const vertex = graph.getVertex(id);
|
|
43
|
+
const node = data.completeAst.idMap.get(id);
|
|
44
|
+
if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.TableAssignment)) {
|
|
45
|
+
/* `t[, a := v]` changes the table the parameter `t` holds, which is the caller's */
|
|
46
|
+
for (const target of df_helper_1.Dataflow.sourcesOf(graph, id, edge_1.EdgeType.DefinedBy).filter(t => heldByParameter(t, graph, data.completeAst.idMap))) {
|
|
47
|
+
(ops ??= []).push({ id: target, kind: vertex_1.EnvOpKind.ChangeInPlace, names: [], literals: [], envir: target, returns: false });
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
else if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Replacement)) {
|
|
52
|
+
const op = replacementOf(id, node, graph, data.completeAst.idMap, data.environment);
|
|
53
|
+
if (op !== undefined) {
|
|
54
|
+
(ops ??= []).push(op);
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
else if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const defs = df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Calls).some(t => !node_id_1.NodeId.isBuiltIn(t)) ? undefined : resolve_helper_1.Resolve.byNameAndType(node.functionName.content, data.environment, identifier_1.ReferenceType.Function);
|
|
62
|
+
const builtIn = defs?.length === 1 && defs[0].type === identifier_1.ReferenceType.BuiltInFunction ? defs[0] : undefined;
|
|
63
|
+
if (builtIn?.processorName === built_in_proc_name_1.BuiltInProcName.Local && builtIn.config !== undefined) {
|
|
64
|
+
const evaluated = evaluatedDefinitions(node, builtIn.config, graph, data.completeAst.idMap, data.environment);
|
|
65
|
+
if (evaluated.length > 0) {
|
|
66
|
+
(ops ??= []).push(...evaluated);
|
|
67
|
+
}
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const kind = builtIn?.processorName === undefined ? undefined : OpOfProcessor[builtIn.processorName];
|
|
71
|
+
const config = builtIn?.config;
|
|
72
|
+
if (kind === undefined || config?.sig === undefined || (kind === vertex_1.EnvOpKind.Define && config.targetVariable !== true)) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const formals = config.sig.map(([name]) => name);
|
|
76
|
+
const bound = function_semantics_1.FunctionSemantics.call.match.toNames(node.arguments, formals);
|
|
77
|
+
const named = r_argument_1.RArgument.valueOf(bound.get(kind === vertex_1.EnvOpKind.Remove ? RemovedByValue : formals[0]));
|
|
78
|
+
const envir = r_argument_1.RArgument.valueOf(bound.get('envir'));
|
|
79
|
+
/* `rm` takes the names in its `...` as written */
|
|
80
|
+
const literals = kind === vertex_1.EnvOpKind.Remove ? node.arguments.flatMap(a => r_argument_1.RArgument.isEmpty(a) || (a.name !== undefined && formals.includes(a.name.content)) ? [] : [literalName(a.value)]) : [];
|
|
81
|
+
const computed = named !== undefined && !r_string_1.RString.is(named);
|
|
82
|
+
/* without an environment, the operation works on the frame of the call, which no caller sees */
|
|
83
|
+
if (envir === undefined || (named === undefined && literals.length === 0) || literals.includes(undefined)
|
|
84
|
+
|| (kind === vertex_1.EnvOpKind.Define && !computed && !heldByParameter(envir.info.id, graph, data.completeAst.idMap) && callerGenerations(envir, data.environment, graph, data.completeAst.idMap) === undefined)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
(ops ??= []).push({
|
|
88
|
+
id,
|
|
89
|
+
kind,
|
|
90
|
+
names: named === undefined ? [] : [named.info.id],
|
|
91
|
+
literals: literals,
|
|
92
|
+
envir: envir.info.id,
|
|
93
|
+
value: kind === vertex_1.EnvOpKind.Define ? r_argument_1.RArgument.valueOf(bound.get(formals[1]))?.info.id : undefined,
|
|
94
|
+
returns: config.returnsValue !== false
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return ops;
|
|
98
|
+
}
|
|
99
|
+
/** What `local(expr, envir)` and `evalq(expr, envir)` define in an environment a parameter holds: the body evaluates `expr` in a frame of its own, as it cannot know the environment, its call defines into the one it hands over. */
|
|
100
|
+
function evaluatedDefinitions(node, config, graph, idMap, environment) {
|
|
101
|
+
const bound = function_semantics_1.FunctionSemantics.call.match.toNames(node.arguments, [config.args.expr, config.args.env]);
|
|
102
|
+
const envir = r_argument_1.RArgument.valueOf(bound.get(config.args.env));
|
|
103
|
+
const expr = r_argument_1.RArgument.valueOf(bound.get(config.args.expr));
|
|
104
|
+
if (expr === undefined || envir === undefined || !(heldByParameter(envir.info.id, graph, idMap) || callerGenerations(envir, environment, graph, idMap) !== undefined)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const ops = [];
|
|
108
|
+
for (const id of model_1.RNode.collectAllIdsWithStop(expr, r_function_definition_1.RFunctionDefinition.is)) {
|
|
109
|
+
const name = literalName(idMap.get(id));
|
|
110
|
+
/* a super assignment defines outside the evaluation */
|
|
111
|
+
if (name !== undefined && vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(id)) && !df_helper_1.Dataflow.definedBySuperAssignment(graph, id)) {
|
|
112
|
+
ops.push({ id: node.info.id, kind: vertex_1.EnvOpKind.Define, names: [], literals: [name], envir: envir.info.id, value: id, returns: true });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return ops;
|
|
116
|
+
}
|
|
117
|
+
/** `env$x <- value` or `env[["x"]] <- value` in a body where `env` is a parameter: the call decides whether it writes into an environment the caller holds or into a copy of a list, see {@link EnvOpKind.Replace}. */
|
|
118
|
+
function replacementOf(id, node, graph, idMap, environment) {
|
|
119
|
+
const access = r_access_1.RAccess.is(node) ? node : undefined;
|
|
120
|
+
const assignment = access && model_1.RNode.directParent(access, idMap);
|
|
121
|
+
const value = r_binary_op_1.RBinaryOp.is(assignment) && assignment.lhs === access && ReplacedBy.has(assignment.operator) ? assignment.rhs : undefined;
|
|
122
|
+
const target = value !== undefined && r_symbol_1.RSymbol.is(access?.accessed) ? access : undefined;
|
|
123
|
+
const field = target !== undefined && target.access.length === 1 && FieldAccess.has(target.operator) ? r_argument_1.RArgument.valueOf(target.access[0]) : undefined;
|
|
124
|
+
if (target === undefined || field === undefined || !(heldByParameter(target.accessed.info.id, graph, idMap) || callerGenerations(target.accessed, environment, graph, idMap) !== undefined)) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
const literal = target.operator === '$' || r_string_1.RString.is(field) ? literalName(field) : undefined;
|
|
128
|
+
return { id, kind: vertex_1.EnvOpKind.Replace, names: literal === undefined ? [field.info.id] : [], literals: literal === undefined ? [] : [literal], envir: target.accessed.info.id, value: value?.info.id, returns: true };
|
|
129
|
+
}
|
|
130
|
+
/** the assignments a replacement rebinds its target in the frame of the body with */
|
|
131
|
+
const ReplacedBy = new Set(['<-', '=']);
|
|
132
|
+
/** the accesses naming a single variable of an environment */
|
|
133
|
+
const FieldAccess = new Set(['$', '[[']);
|
|
134
|
+
/** Whether `id` reads a parameter, which holds what the call hands over (the body cannot know the environment it may hold). */
|
|
135
|
+
function heldByParameter(id, graph, idMap) {
|
|
136
|
+
const closure = frameOf(idMap.get(id));
|
|
137
|
+
const held = readBindings(closure?.info.id ?? id, graph);
|
|
138
|
+
return held.length === 1 && idMap.get(held[0])?.info.role === "param-n" /* RoleInParent.ParameterName */;
|
|
139
|
+
}
|
|
140
|
+
/** What `id` reads, the target of a replacement (`env$x <- v`) reads the variable it rebinds besides the replacement itself. */
|
|
141
|
+
function readBindings(id, graph) {
|
|
142
|
+
return df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads).filter(t => !vertex_1.DfgVertex.isFunctionCall(graph.getVertex(t)));
|
|
143
|
+
}
|
|
144
|
+
/** How many calls up the frame `node` names lies: 1 for the caller (`parent.frame()`, directly or by a variable bound to it only), `n` for `parent.frame(n)` with a constant `n`, `undefined` for any other environment. */
|
|
145
|
+
function callerGenerations(node, environment, graph, idMap) {
|
|
146
|
+
if (!r_symbol_1.RSymbol.is(node)) {
|
|
147
|
+
return frameGenerations(node, environment);
|
|
148
|
+
}
|
|
149
|
+
const held = readBindings(node.info.id, graph).map(d => frameGenerations(idMap.get(df_helper_1.Dataflow.assignedValueOf(d, graph) ?? ''), environment));
|
|
150
|
+
return held.length > 0 && held.every(g => g !== undefined && g === held[0]) ? held[0] : undefined;
|
|
151
|
+
}
|
|
152
|
+
/** {@link callerGenerations} of a `parent.frame` call itself. */
|
|
153
|
+
function frameGenerations(node, environment) {
|
|
154
|
+
if ((0, built_in_stack_env_1.stackEnvKindOf)(node, { environment }) === shared_configs_1.StackEnvKind.CallerFrame) {
|
|
155
|
+
return 1;
|
|
156
|
+
}
|
|
157
|
+
const call = r_function_call_1.RFunctionCall.isNamed(node, 'parent.frame') && node.arguments.length === 1 ? node : undefined;
|
|
158
|
+
const count = call === undefined ? undefined : r_argument_1.RArgument.valueOf(call.arguments[0]);
|
|
159
|
+
const n = r_number_1.RNumber.is(count) ? count.content.num : undefined;
|
|
160
|
+
return call !== undefined && n !== undefined && Number.isInteger(n) && n > 1 && resolve_helper_1.Resolve.isBuiltIn(call.functionName.content, environment, identifier_1.ReferenceType.Function) ? n : undefined;
|
|
161
|
+
}
|
|
162
|
+
/** The closure whose frame `environment(fn)` names, see {@link closureFrameResolution}. */
|
|
163
|
+
function frameOf(node) {
|
|
164
|
+
const fn = r_function_call_1.RFunctionCall.isNamed(node, 'environment') && node.arguments.length === 1 ? r_argument_1.RArgument.valueOf(node.arguments[0]) : undefined;
|
|
165
|
+
return r_symbol_1.RSymbol.is(fn) ? fn : undefined;
|
|
166
|
+
}
|
|
167
|
+
function literalName(node) {
|
|
168
|
+
return r_symbol_1.RSymbol.is(node) ? identifier_1.Identifier.getName(node.content) : r_string_1.RString.is(node) ? node.content.str : undefined;
|
|
169
|
+
}
|
|
170
|
+
/** The parameter of the function run that `id` reads, if it reads just that. */
|
|
171
|
+
function parameterReadBy(id, { fn, graph }) {
|
|
172
|
+
const vertex = graph.getVertex(id);
|
|
173
|
+
const bindings = vertex_1.DfgVertex.isUse(vertex) || (vertex_1.DfgVertex.isVariableDefinition(vertex) && vertex.par) ? readBindings(id, graph) : [];
|
|
174
|
+
return bindings.length === 1 && Object.hasOwn(fn.params, bindings[0]) ? bindings[0] : undefined;
|
|
175
|
+
}
|
|
176
|
+
/** What the call hands to `parameter`, matched as R matches arguments. */
|
|
177
|
+
function handedTo(parameter, { fn, via, graph, idMap }) {
|
|
178
|
+
const call = graph.getVertex(via);
|
|
179
|
+
if (!vertex_1.DfgVertex.isFunctionCall(call)) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const formals = {};
|
|
183
|
+
for (const p of Object.keys(fn.params)) {
|
|
184
|
+
const name = idMap.get(node_id_1.NodeId.normalize(p));
|
|
185
|
+
if (r_symbol_1.RSymbol.is(name)) {
|
|
186
|
+
formals[identifier_1.Identifier.getName(name.content)] = name.info.id;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return (function_semantics_1.FunctionSemantics.call.match.toSpec(call.args, formals).get(parameter) ?? []).map(a => r_argument_1.RArgument.valueOf(idMap.get(a))?.info.id ?? a);
|
|
190
|
+
}
|
|
191
|
+
/** What the call hands over for `id`, if that just reads a parameter, else `id` itself. */
|
|
192
|
+
function valueAt(id, run) {
|
|
193
|
+
const parameter = parameterReadBy(id, run);
|
|
194
|
+
const handed = parameter === undefined ? [] : handedTo(parameter, run);
|
|
195
|
+
return handed.length === 1 ? handed[0] : id;
|
|
196
|
+
}
|
|
197
|
+
function envAtCall(envir, environment, run) {
|
|
198
|
+
const node = run.idMap.get(envir);
|
|
199
|
+
const stack = (0, built_in_stack_env_1.stackEnvKindOf)(node, { environment });
|
|
200
|
+
/* run by a call of another function, only the global environment is the same for both */
|
|
201
|
+
if (stack === shared_configs_1.StackEnvKind.Global) {
|
|
202
|
+
return stack;
|
|
203
|
+
}
|
|
204
|
+
else if (run.direct && callerGenerations(node, environment, run.graph, run.idMap) === 1) {
|
|
205
|
+
return shared_configs_1.StackEnvKind.CallerFrame;
|
|
206
|
+
}
|
|
207
|
+
const closure = frameOf(node);
|
|
208
|
+
const symbol = closure ?? node;
|
|
209
|
+
if (!r_symbol_1.RSymbol.is(symbol)) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
/* a parameter holds what the call hands over, any other binding of the body is its own */
|
|
213
|
+
const bound = readBindings(symbol.info.id, run.graph).some(b => run.fn.subflow.graph.has(b));
|
|
214
|
+
/* a free variable of a function defined at the top is a global one, which a call at the top sees as the function does */
|
|
215
|
+
if (!run.direct && (bound || environment.level > 0 || model_1.RNode.strictlyEnclosingFunction(run.fn.id, run.idMap) !== undefined)) {
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const handed = bound ? run.idMap.get(valueAt(symbol.info.id, run)) : symbol;
|
|
219
|
+
/* the call may hand over the frame of a closure itself, `put(environment(g))` */
|
|
220
|
+
const handedFrame = handed === symbol ? undefined : frameOf(handed);
|
|
221
|
+
const held = handedFrame ?? handed;
|
|
222
|
+
if (!r_symbol_1.RSymbol.is(held) || (held === symbol && bound)) {
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
else if (closure !== undefined || handedFrame !== undefined) {
|
|
226
|
+
/* the frame of the closure the variable holds, tracked on the variable, see `closureFrameResolution` */
|
|
227
|
+
const defs = resolve_helper_1.Resolve.byName(held.content, environment);
|
|
228
|
+
const def = defs?.length === 1 && !node_id_1.NodeId.isBuiltIn(defs[0].definedAt) ? defs[0] : undefined;
|
|
229
|
+
return def === undefined ? undefined : { holders: [{ ...def, envState: def.envState ?? environment_1.REnvironment.pushLocal(environment), envId: def.envId ?? def.nodeId, closureFrame: true }] };
|
|
230
|
+
}
|
|
231
|
+
const holders = resolve_helper_1.Resolve.byNameAndType(held.content, environment, identifier_1.ReferenceType.Variable);
|
|
232
|
+
if (holders === undefined || holders.length === 0 || !holders.every(h => (0, identifier_1.hasEnvState)(h) && h.name !== undefined && h.closureFrame !== true)) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
return { holders: holders };
|
|
236
|
+
}
|
|
237
|
+
/** Each function the calls `calls` run on the way to `fn`, the last one calling `fn`, with the call running it. */
|
|
238
|
+
function contextOfChain(calls, fn, idMap) {
|
|
239
|
+
const context = new Map([[fn, calls[calls.length - 1]]]);
|
|
240
|
+
for (let i = 0; i < calls.length - 1; i++) {
|
|
241
|
+
const runs = model_1.RNode.strictlyEnclosingFunction(calls[i + 1], idMap);
|
|
242
|
+
if (runs !== undefined) {
|
|
243
|
+
context.set(runs, calls[i]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return context;
|
|
247
|
+
}
|
|
248
|
+
/** The names `name` computes in the run: a parameter takes what the call hands over, anything else is resolved for the call it runs in. */
|
|
249
|
+
function namesAt(name, run, ctx) {
|
|
250
|
+
const node = run.idMap.get(name);
|
|
251
|
+
if (r_string_1.RString.is(node)) {
|
|
252
|
+
return [node.content.str];
|
|
253
|
+
}
|
|
254
|
+
const info = resolve_helper_1.Resolve.info(run.graph, ctx);
|
|
255
|
+
const parameter = parameterReadBy(name, run);
|
|
256
|
+
if (parameter !== undefined) {
|
|
257
|
+
const handed = handedTo(parameter, run);
|
|
258
|
+
const names = handed.map(a => node_value_1.NodeValue.stringsOf(a, { ...info, callContext: run.context }));
|
|
259
|
+
return handed.length === 0 || names.includes(undefined) ? undefined : names.flat();
|
|
260
|
+
}
|
|
261
|
+
return node_value_1.NodeValue.stringsOf(name, { ...info, callContext: run.context });
|
|
262
|
+
}
|
|
263
|
+
/** Runs the {@link deferredEnvOps} of the function `fn` for the call `call`, which runs `fn` itself or through the `chain` of calls in the functions it runs, the last one calling `fn`: the names they compute from parameters resolve with the values the call of `fn` hands over, and an environment a free variable or a parameter names is the one it holds at `call`, if `call` runs `fn` itself, else only the global environment is known to be the same. */
|
|
264
|
+
function instantiateEnvOps(call, fn, chain, environment, graph, ctx) {
|
|
265
|
+
const idMap = graph.idMap;
|
|
266
|
+
if (fn.envOps === undefined || idMap === undefined) {
|
|
267
|
+
return environment;
|
|
268
|
+
}
|
|
269
|
+
const calls = [call, ...chain];
|
|
270
|
+
const run = { fn, via: chain.at(-1) ?? call, direct: chain.length === 0, graph, idMap, context: contextOfChain(calls, fn.id, idMap) };
|
|
271
|
+
const callCds = graph.getVertex(call)?.cds;
|
|
272
|
+
for (const op of fn.envOps) {
|
|
273
|
+
if (op.kind === vertex_1.EnvOpKind.ChangeInPlace) {
|
|
274
|
+
environment = changeInPlaceAt(op, run, call, environment);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const names = op.names.map(n => namesAt(n, run, ctx));
|
|
278
|
+
const at = envAtCall(op.envir, environment, run);
|
|
279
|
+
if (at === undefined || names.some(n => n === undefined || n.length === 0) || (op.kind === vertex_1.EnvOpKind.Replace && at !== shared_configs_1.StackEnvKind.CallerFrame && (typeof at !== 'object' || !at.holders.every(h => h.closureFrame === true || (0, built_in_envir_utils_1.holdsValueOf)(h, graph, built_in_envir_utils_1.EnvironmentProducers))))) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const all = [...op.literals, ...names.flat()];
|
|
283
|
+
const holders = typeof at === 'object' ? at.holders : [];
|
|
284
|
+
/* with several names or environments, each is only maybe the one */
|
|
285
|
+
const cds = callCds ?? (all.length > 1 || holders.length > 1 ? [] : undefined);
|
|
286
|
+
/* what a call within another function hands over is kept by that call only, which a slice reaches through the value in the body */
|
|
287
|
+
const value = op.value === undefined || !run.direct ? op.value : valueAt(op.value, run);
|
|
288
|
+
/* every call on the way makes the change */
|
|
289
|
+
for (const c of op.kind === vertex_1.EnvOpKind.Read ? [] : calls) {
|
|
290
|
+
graph.addEdge(value ?? op.id, c, edge_1.EdgeType.SideEffectOnCall);
|
|
291
|
+
}
|
|
292
|
+
environment = applyOp(op, value, all, at, environment, cds, call, graph);
|
|
293
|
+
}
|
|
294
|
+
return environment;
|
|
295
|
+
}
|
|
296
|
+
/** Binds the variable the call hands to the parameter of the {@link EnvOpKind.ChangeInPlace} `op`, and what else holds its object, to the change. */
|
|
297
|
+
function changeInPlaceAt(op, run, call, environment) {
|
|
298
|
+
const parameter = run.direct ? readBindings(op.envir, run.graph).find(b => Object.hasOwn(run.fn.params, b)) : undefined;
|
|
299
|
+
const args = parameter === undefined ? [] : handedTo(parameter, run);
|
|
300
|
+
const handed = args.length === 1 ? run.idMap.get(args[0]) : undefined;
|
|
301
|
+
if (!r_symbol_1.RSymbol.is(handed)) {
|
|
302
|
+
return environment;
|
|
303
|
+
}
|
|
304
|
+
run.graph.addEdge(op.id, call, edge_1.EdgeType.SideEffectOnCall);
|
|
305
|
+
const [rebound] = (0, built_in_envir_utils_1.rebindAliases)(environment, handed.content, op.id, call);
|
|
306
|
+
/* the caller's variable may still hold the table as it was, the change joins its binding */
|
|
307
|
+
return environment_1.REnvironment.define({ name: handed.content, nodeId: op.id, definedAt: call, type: identifier_1.ReferenceType.Variable, cds: [] }, false, rebound);
|
|
308
|
+
}
|
|
309
|
+
function applyOp(op, value, names, at, environment, cds, call, graph) {
|
|
310
|
+
const update = (state, global, closureFrame = false) => {
|
|
311
|
+
switch (op.kind) {
|
|
312
|
+
case vertex_1.EnvOpKind.Define:
|
|
313
|
+
case vertex_1.EnvOpKind.Replace: {
|
|
314
|
+
let next = state;
|
|
315
|
+
const type = referenceTypeOf(value === undefined ? undefined : graph.getVertex(value), graph);
|
|
316
|
+
for (const name of names) {
|
|
317
|
+
next = environment_1.REnvironment.define({ name, nodeId: value ?? op.id, definedAt: value === undefined ? op.id : call, type, cds }, global && next.level > 0, next);
|
|
318
|
+
}
|
|
319
|
+
return next;
|
|
320
|
+
}
|
|
321
|
+
case vertex_1.EnvOpKind.Remove: {
|
|
322
|
+
const kills = names.map(name => ({ kind: 'named', reference: { nodeId: op.id, name, cds, type: identifier_1.ReferenceType.Variable }, killedBy: op.id }));
|
|
323
|
+
/* the frame of a closure records the removal, see `removeFromCustomEnv` */
|
|
324
|
+
return global ? (0, apply_kill_1.applyGlobalKills)(state, kills) : (0, apply_kill_1.applyKills)(state, kills, closureFrame);
|
|
325
|
+
}
|
|
326
|
+
case vertex_1.EnvOpKind.Read: {
|
|
327
|
+
const found = [];
|
|
328
|
+
for (const def of names.flatMap(name => resolve_helper_1.Resolve.byName(name, state) ?? [])) {
|
|
329
|
+
if (!node_id_1.NodeId.isBuiltIn(def.nodeId)) {
|
|
330
|
+
graph.addEdge(op.id, def.nodeId, op.returns ? edge_1.EdgeType.Reads | edge_1.EdgeType.Returns : edge_1.EdgeType.Reads);
|
|
331
|
+
found.push(def.nodeId);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
(0, linker_1.recordFound)(graph, op.id, found, call);
|
|
335
|
+
return state;
|
|
336
|
+
}
|
|
337
|
+
case vertex_1.EnvOpKind.ChangeInPlace:
|
|
338
|
+
/* replayed by `changeInPlaceAt`, it names no environment */
|
|
339
|
+
return state;
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
if (at === shared_configs_1.StackEnvKind.Global || at === shared_configs_1.StackEnvKind.CallerFrame) {
|
|
343
|
+
return update(environment, at === shared_configs_1.StackEnvKind.Global);
|
|
344
|
+
}
|
|
345
|
+
for (const holder of at.holders) {
|
|
346
|
+
environment = (0, built_in_envir_utils_1.rebindHolders)(environment, holder, update(holder.envState, false, holder.closureFrame === true), call);
|
|
347
|
+
}
|
|
348
|
+
return environment;
|
|
349
|
+
}
|
|
350
|
+
/** Whether the call `call` of `fn` replayed the replacement or assignment `write` of its body (see {@link EnvOpKind.Replace} and {@link EnvOpKind.Define}) into the environment it hands over, so what it writes is known there. */
|
|
351
|
+
function replayedAt(write, fn, call, graph) {
|
|
352
|
+
const op = fn.envOps?.find(o => o.id === write && (o.kind === vertex_1.EnvOpKind.Replace || o.kind === vertex_1.EnvOpKind.Define));
|
|
353
|
+
if (op?.value === undefined || graph.idMap === undefined) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
const value = valueAt(op.value, { fn, via: call, direct: true, graph, idMap: graph.idMap });
|
|
357
|
+
return df_helper_1.Dataflow.hasEdge(graph, value, call, edge_1.EdgeType.SideEffectOnCall);
|
|
358
|
+
}
|
|
359
|
+
/** What a definition of the value `vertex` binds, as an assignment does: a function, a value, or what a read, call, or other definition hands on. */
|
|
360
|
+
function referenceTypeOf(vertex, graph) {
|
|
361
|
+
if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
362
|
+
return identifier_1.ReferenceType.Function;
|
|
363
|
+
}
|
|
364
|
+
else if (vertex_1.DfgVertex.isVariableDefinition(vertex)) {
|
|
365
|
+
return df_helper_1.Dataflow.targetsOf(graph, vertex.id, edge_1.EdgeType.DefinedBy).some(t => vertex_1.DfgVertex.isFunctionDefinition(graph.getVertex(t))) ? identifier_1.ReferenceType.Function : identifier_1.ReferenceType.Unknown;
|
|
366
|
+
}
|
|
367
|
+
return vertex_1.DfgVertex.isUse(vertex) || vertex_1.DfgVertex.isFunctionCall(vertex) ? identifier_1.ReferenceType.Unknown : identifier_1.ReferenceType.Variable;
|
|
368
|
+
}
|
|
369
|
+
/** The definitions the function `fn` makes in the frame of its caller (`assign("x", v, envir = parent.frame())`) for the call `call` within another function: the reads of that frame may see them, which the frame does not know of when it is processed, as it learns of the callee later (the top level runs them in {@link instantiateEnvOps}). */
|
|
370
|
+
function linkCallerFrameWrites(call, fn, graph, ctx) {
|
|
371
|
+
const idMap = graph.idMap;
|
|
372
|
+
const enclosing = idMap === undefined ? undefined : model_1.RNode.strictlyEnclosingFunction(call, idMap);
|
|
373
|
+
const frame = enclosing === undefined ? undefined : idMap?.get(enclosing);
|
|
374
|
+
if (fn.envOps === undefined || idMap === undefined || !r_function_definition_1.RFunctionDefinition.is(frame)) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const run = { fn, via: call, direct: true, graph, idMap, context: contextOfChain([call], fn.id, idMap) };
|
|
378
|
+
for (const op of fn.envOps) {
|
|
379
|
+
const generations = op.kind === vertex_1.EnvOpKind.Read || op.kind === vertex_1.EnvOpKind.Remove ? undefined : op.generations ?? callerGenerations(idMap.get(op.envir), fn.subflow.environment, graph, idMap);
|
|
380
|
+
if (generations === undefined) {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
else if (generations > 1) {
|
|
384
|
+
/* `parent.frame(n)` of the callee is `parent.frame(n - 1)` of the function the call is in, which runs it by this call */
|
|
385
|
+
graph.addEdge(op.value ?? op.id, call, edge_1.EdgeType.SideEffectOnCall);
|
|
386
|
+
handOnToCallers({ ...op, generations: generations - 1 }, frame.info.id, graph, ctx);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const names = op.names.map(n => namesAt(n, run, ctx));
|
|
390
|
+
if (names.includes(undefined)) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
const all = new Set([...op.literals, ...names.flat()]);
|
|
394
|
+
const value = op.value === undefined ? op.id : valueAt(op.value, run);
|
|
395
|
+
graph.addEdge(value, call, edge_1.EdgeType.SideEffectOnCall);
|
|
396
|
+
for (const id of model_1.RNode.collectAllIdsWithStop(frame.body, r_function_definition_1.RFunctionDefinition.is)) {
|
|
397
|
+
const name = vertex_1.DfgVertex.isUse(graph.getVertex(id)) ? node_id_1.NodeId.recoverBareName(id, idMap) : undefined;
|
|
398
|
+
if (name !== undefined && all.has(name)) {
|
|
399
|
+
graph.addEdge(id, value, edge_1.EdgeType.Reads);
|
|
400
|
+
graph.addEdge(id, op.id, edge_1.EdgeType.Reads);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/** Registers `op` with the function `fn`, so the calls of it, linked already or later, replay it in their frame in turn. */
|
|
406
|
+
function handOnToCallers(op, fn, graph, ctx) {
|
|
407
|
+
const definition = graph.getVertex(fn);
|
|
408
|
+
if (!vertex_1.DfgVertex.isFunctionDefinition(definition) || definition.envOps?.some(o => o.id === op.id && o.generations === op.generations)) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
definition.envOps = [...definition.envOps ?? [], op];
|
|
412
|
+
for (const caller of df_helper_1.Dataflow.sourcesOf(graph, fn, edge_1.EdgeType.Calls)) {
|
|
413
|
+
linkCallerFrameWrites(caller, definition, graph, ctx);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
//# sourceMappingURL=built-in-deferred-env-ops.js.map
|