@eagleoutice/flowr 2.16.5 → 2.16.7
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 +21 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +11 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +6 -0
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +11 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -44
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +3 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +42 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/removal-slice.js +4 -2
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PrintingOptions =
|
|
3
|
+
exports.PrintingOptions = void 0;
|
|
4
4
|
exports.hidesBody = hidesBody;
|
|
5
5
|
exports.readsAllAmbientState = readsAllAmbientState;
|
|
6
6
|
exports.ambientWritesOfAssignment = ambientWritesOfAssignment;
|
|
@@ -49,63 +49,14 @@ const assert_1 = require("../../../../../../util/assert");
|
|
|
49
49
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
50
50
|
const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
51
51
|
const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
52
|
-
const ListConstructors = new Set(['list', 'c']);
|
|
53
52
|
const arrays_1 = require("../../../../../../util/collections/arrays");
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
exports.AmbientStateName = {
|
|
59
|
-
/** the graphics state (`par`, `layout`, ...) of the active device, which a new device starts afresh */
|
|
60
|
-
graphics: '#graphics',
|
|
61
|
-
/** the graphics states of the other open devices, the active one returns to one of them once it closes */
|
|
62
|
-
otherDevices: '#graphics:other',
|
|
63
|
-
/** the call that opened the active device, and those of the other open devices */
|
|
64
|
-
device: '#device',
|
|
65
|
-
otherDevicesOpenedBy: '#device:other',
|
|
66
|
-
/** the color palette, which, other than the graphics parameters, all devices share */
|
|
67
|
-
palette: '#palette',
|
|
68
|
-
/** the files on disk, which every call writing a file adds to and every call reading a file we cannot name reads */
|
|
69
|
-
files: '#files',
|
|
70
|
-
/** written by a call writing a file we cannot name, which every call reading a file reads */
|
|
71
|
-
anyFile: '#file:*',
|
|
72
|
-
/** the working directory `setwd` changes, which every call accessing a file reads to resolve a relative path */
|
|
73
|
-
workingDirectory: '#wd',
|
|
74
|
-
/** the state of the random number generator, which `set.seed` sets and every draw advances */
|
|
75
|
-
rng: '#rng',
|
|
76
|
-
/** the kind of generator, which `set.seed` keeps unless it is given one */
|
|
77
|
-
rngKind: '#rng:kind',
|
|
78
|
-
/** the global variable R keeps that state in, so assigning it sets {@link AmbientStateName.rng} as well */
|
|
79
|
-
rngVariable: '.Random.seed',
|
|
80
|
-
/** every option write, for readers that may read any option (`getOption(k)` with an unknown `k`, library functions) */
|
|
81
|
-
allOptions: '#options',
|
|
82
|
-
/** written by an `options(...)` call whose keys we cannot name, like the common `options(op)` restore */
|
|
83
|
-
unknownOption: '#option:*',
|
|
84
|
-
/** written along with the option `warn` when it may turn warnings into errors (`warn >= 2`), see {@link errorsOfWarnings} */
|
|
85
|
-
warnsAsErrors: '#warn-error',
|
|
86
|
-
/** the finalizers registered (`reg.finalizer`) and the removals that may release their objects, which `gc()` may run */
|
|
87
|
-
finalizers: '#finalizers',
|
|
88
|
-
/** marks `name` as bound to a text connection opened for writing, whose writes change it */
|
|
89
|
-
textConnection(name) {
|
|
90
|
-
return `#text-connection:${name}`;
|
|
91
|
-
},
|
|
92
|
-
/** the file named `stem` (`data` for `out/data.csv`), so a read of a named file only sees writes that may hit it */
|
|
93
|
-
file(stem) {
|
|
94
|
-
return `#file:${stem}`;
|
|
95
|
-
},
|
|
96
|
-
/** the pseudo variable holding the option `key`; setting the option replaces it */
|
|
97
|
-
option(key) {
|
|
98
|
-
return `#option:${key}`;
|
|
99
|
-
},
|
|
100
|
-
/** whether `name` is one of these pseudo variables */
|
|
101
|
-
is(name) {
|
|
102
|
-
return typeof name === 'string' && name.startsWith('#');
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const DeviceStates = [exports.AmbientStateName.graphics, exports.AmbientStateName.otherDevices, exports.AmbientStateName.device, exports.AmbientStateName.otherDevicesOpenedBy];
|
|
53
|
+
const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
|
|
54
|
+
const built_in_ambient_keys_1 = require("./built-in-ambient-keys");
|
|
55
|
+
const ListConstructors = new Set(['list', 'c']);
|
|
56
|
+
const DeviceStates = [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.otherDevices, ambient_state_name_1.AmbientStateName.device, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy];
|
|
106
57
|
const Accumulating = new Set([
|
|
107
|
-
...DeviceStates,
|
|
108
|
-
|
|
58
|
+
...DeviceStates, ambient_state_name_1.AmbientStateName.palette, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.unknownOption,
|
|
59
|
+
ambient_state_name_1.AmbientStateName.warnsAsErrors, ambient_state_name_1.AmbientStateName.files, ambient_state_name_1.AmbientStateName.rngKind, ambient_state_name_1.AmbientStateName.finalizers, ...ambient_state_name_1.KeyedAccumulators
|
|
109
60
|
]);
|
|
110
61
|
/** a write that may not happen: it reads what was there, so it can still replace the state and keep everything before reachable */
|
|
111
62
|
function maybe(name) {
|
|
@@ -113,7 +64,7 @@ function maybe(name) {
|
|
|
113
64
|
}
|
|
114
65
|
/** what reading the options `keys` reads, every option if the keys are unknown */
|
|
115
66
|
function optionReads(keys) {
|
|
116
|
-
return keys === undefined ? [
|
|
67
|
+
return keys === undefined ? [ambient_state_name_1.AmbientStateName.allOptions] : [...keys.map(ambient_state_name_1.AmbientStateName.option), ambient_state_name_1.AmbientStateName.unknownOption];
|
|
117
68
|
}
|
|
118
69
|
/** Whether calling `definition` runs a body flowR cannot see: a library function's, or whatever a parameter is bound to. */
|
|
119
70
|
function hidesBody(definition) {
|
|
@@ -121,11 +72,11 @@ function hidesBody(definition) {
|
|
|
121
72
|
}
|
|
122
73
|
/** A call into code flowR cannot see may read any option, draw random numbers (with `draws` advancing the generator), and with `graphics` draw on the device. */
|
|
123
74
|
function readsAllAmbientState(res, rootId, data, graphics, draws = true) {
|
|
124
|
-
const reads = [
|
|
75
|
+
const reads = [ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.rng];
|
|
125
76
|
if (graphics) {
|
|
126
|
-
reads.push(
|
|
77
|
+
reads.push(ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette);
|
|
127
78
|
}
|
|
128
|
-
return withAccess(res, rootId, data, reads, draws ? [maybe(
|
|
79
|
+
return withAccess(res, rootId, data, reads, draws ? [maybe(ambient_state_name_1.AmbientStateName.rng)] : []);
|
|
129
80
|
}
|
|
130
81
|
/** Adds the reads and writes of the ambient state to what a call does, see {@link AmbientStateName}. */
|
|
131
82
|
function withAccess(res, rootId, data, reads, writes = []) {
|
|
@@ -146,7 +97,7 @@ function withAccess(res, rootId, data, reads, writes = []) {
|
|
|
146
97
|
function defineAmbient(environment, rootId, cds, writes) {
|
|
147
98
|
for (const write of writes) {
|
|
148
99
|
const { name, mode } = typeof write === 'string' ? { name: write, mode: undefined } : write;
|
|
149
|
-
const accumulates = Accumulating.has(name) || name.startsWith(
|
|
100
|
+
const accumulates = Accumulating.has(name) || name.startsWith(ambient_state_name_1.AmbientStateName.file(''));
|
|
150
101
|
const keep = accumulates && (mode === undefined || mode === 'maybe');
|
|
151
102
|
/* an accumulating state only ever grows, its definitions are maybe so merging environments keeps them all; a reset is definite */
|
|
152
103
|
const isMaybe = keep || (accumulates && mode !== 'reset');
|
|
@@ -165,13 +116,13 @@ function defineAmbient(environment, rootId, cds, writes) {
|
|
|
165
116
|
/** What an assignment writes beyond its target: only a global `.Random.seed` sets {@link AmbientStateName.rng}. */
|
|
166
117
|
function ambientWritesOfAssignment(environment, target, rootId, cds, global) {
|
|
167
118
|
environment = ambientWritesOfRelease(environment, [target], rootId, cds);
|
|
168
|
-
return global && identifier_1.Identifier.getName(target) ===
|
|
119
|
+
return global && identifier_1.Identifier.getName(target) === ambient_state_name_1.AmbientStateName.rngVariable ? defineAmbient(environment, rootId, cds, [ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.rngKind]) : environment;
|
|
169
120
|
}
|
|
170
121
|
/** Rebinding or removing the names (all of them if `undefined`) may release an object a finalizer is registered for. */
|
|
171
122
|
function ambientWritesOfRelease(environment, names, rootId, cds) {
|
|
172
|
-
const holders = (resolve_helper_1.Resolve.byName(
|
|
123
|
+
const holders = (resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.finalizers, environment) ?? []).map(d => d.holder);
|
|
173
124
|
const released = holders.some(h => h === undefined || names === undefined || names.some(n => identifier_1.Identifier.getName(n) === h));
|
|
174
|
-
return released ? defineAmbient(environment, rootId, cds, [
|
|
125
|
+
return released ? defineAmbient(environment, rootId, cds, [ambient_state_name_1.AmbientStateName.finalizers]) : environment;
|
|
175
126
|
}
|
|
176
127
|
function* ambientDefinitionsBetween(after, before, skipUnchanged) {
|
|
177
128
|
let unchanged = before.current;
|
|
@@ -181,7 +132,7 @@ function* ambientDefinitionsBetween(after, before, skipUnchanged) {
|
|
|
181
132
|
continue;
|
|
182
133
|
}
|
|
183
134
|
for (const [name, definitions] of env.memory.entries()) {
|
|
184
|
-
if (!
|
|
135
|
+
if (!ambient_state_name_1.AmbientStateName.is(name)) {
|
|
185
136
|
continue;
|
|
186
137
|
}
|
|
187
138
|
const known = new Set((resolve_helper_1.Resolve.byName(name, before) ?? []).map(d => d.nodeId));
|
|
@@ -235,12 +186,12 @@ function setAmbient(environment, name, definitions, keep = false) {
|
|
|
235
186
|
/** A variable a text connection writes reads what is written to connections, `.Random.seed` reads the generator state, and `.Options` the options, see {@link optionsVariableReads}. */
|
|
236
187
|
function ambientReadsOfSymbol(symbol, data, forcing) {
|
|
237
188
|
const name = identifier_1.Identifier.getName(symbol.content);
|
|
238
|
-
if (forcing && resolve_helper_1.Resolve.byName(
|
|
189
|
+
if (forcing && resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.textConnection(name), data.environment)?.length) {
|
|
239
190
|
/* what is written to a connection we cannot name may be written to this one */
|
|
240
|
-
return [
|
|
191
|
+
return [ambient_state_name_1.AmbientStateName.anyFile];
|
|
241
192
|
}
|
|
242
|
-
else if (name ===
|
|
243
|
-
return [
|
|
193
|
+
else if (name === ambient_state_name_1.AmbientStateName.rngVariable) {
|
|
194
|
+
return [ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.rngKind];
|
|
244
195
|
}
|
|
245
196
|
else if (name !== '.Options') {
|
|
246
197
|
return [];
|
|
@@ -283,24 +234,24 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
283
234
|
const writes = [];
|
|
284
235
|
switch (access.type) {
|
|
285
236
|
case "read-graphics" /* AmbientStateAccessType.ReadGraphics */:
|
|
286
|
-
reads.push(
|
|
237
|
+
reads.push(ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette);
|
|
287
238
|
break;
|
|
288
239
|
case "set-graphics" /* AmbientStateAccessType.SetGraphics */:
|
|
289
240
|
/* the call returns the previous state */
|
|
290
|
-
reads.push(
|
|
241
|
+
reads.push(ambient_state_name_1.AmbientStateName.graphics);
|
|
291
242
|
if (onlyQueries(access, args)) {
|
|
292
243
|
if (access.queryLinksTo) {
|
|
293
244
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId, access.queryLinksTo);
|
|
294
245
|
}
|
|
295
246
|
}
|
|
296
247
|
else {
|
|
297
|
-
writes.push(
|
|
248
|
+
writes.push(ambient_state_name_1.AmbientStateName.graphics, ...access.keys === undefined ? [] : (0, built_in_ambient_keys_1.keyedWrites)(ambient_state_name_1.KeyedState.Par, (0, built_in_ambient_keys_1.keysOf)(access.keys, args, data)));
|
|
298
249
|
}
|
|
299
250
|
break;
|
|
300
251
|
case "set-palette" /* AmbientStateAccessType.SetPalette */:
|
|
301
|
-
reads.push(
|
|
252
|
+
reads.push(ambient_state_name_1.AmbientStateName.palette);
|
|
302
253
|
if (!onlyQueries(access, args)) {
|
|
303
|
-
writes.push(
|
|
254
|
+
writes.push(ambient_state_name_1.AmbientStateName.palette);
|
|
304
255
|
}
|
|
305
256
|
break;
|
|
306
257
|
case "read-options" /* AmbientStateAccessType.ReadOptions */: {
|
|
@@ -310,11 +261,19 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
310
261
|
}
|
|
311
262
|
case "get-option" /* AmbientStateAccessType.GetOption */: {
|
|
312
263
|
const first = args.find(a => a !== r_function_call_1.EmptyArgument && (a.name === undefined || identifier_1.Identifier.getName(a.name.content) === 'x'));
|
|
313
|
-
reads.push(...optionReads(stringValuesOf(r_argument_1.RArgument.valueOf(first), data)));
|
|
264
|
+
reads.push(...optionReads((0, built_in_ambient_keys_1.stringValuesOf)(r_argument_1.RArgument.valueOf(first), data)));
|
|
314
265
|
break;
|
|
315
266
|
}
|
|
316
267
|
case "set-options" /* AmbientStateAccessType.SetOptions */:
|
|
317
268
|
return setOptions(res, args, rootId, data);
|
|
269
|
+
case "set-keyed" /* AmbientStateAccessType.SetKeyed */:
|
|
270
|
+
writes.push(...(0, built_in_ambient_keys_1.keyedWrites)(access.state, (0, built_in_ambient_keys_1.keysOf)(access.keys, args, data)));
|
|
271
|
+
break;
|
|
272
|
+
case "set-state" /* AmbientStateAccessType.SetState */:
|
|
273
|
+
if (!onlyQueries(access, args)) {
|
|
274
|
+
writes.push(access.state);
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
318
277
|
case "open-device" /* AmbientStateAccessType.OpenDevice */:
|
|
319
278
|
return deviceAccess(res, rootId, data, 'open');
|
|
320
279
|
case "close-device" /* AmbientStateAccessType.CloseDevice */:
|
|
@@ -326,51 +285,51 @@ function applyAmbientStateAccess(res, args, rootId, data, access) {
|
|
|
326
285
|
return evaluatesCapturedCode(res, rootId, data);
|
|
327
286
|
case "set-rng" /* AmbientStateAccessType.SetRng */: {
|
|
328
287
|
const kindFrom = access.kindFrom ?? 1;
|
|
329
|
-
reads.push(
|
|
288
|
+
reads.push(ambient_state_name_1.AmbientStateName.rngKind);
|
|
330
289
|
if (kindFrom > 0) {
|
|
331
|
-
writes.push(
|
|
290
|
+
writes.push(ambient_state_name_1.AmbientStateName.rng);
|
|
332
291
|
}
|
|
333
292
|
if (args.some((a, i) => a !== r_function_call_1.EmptyArgument && (a.name === undefined ? i >= kindFrom : identifier_1.Identifier.getName(a.name.content) !== 'seed'))) {
|
|
334
|
-
writes.push(
|
|
293
|
+
writes.push(ambient_state_name_1.AmbientStateName.rngKind);
|
|
335
294
|
}
|
|
336
295
|
break;
|
|
337
296
|
}
|
|
338
297
|
case "draw-rng" /* AmbientStateAccessType.DrawRng */:
|
|
339
|
-
reads.push(
|
|
340
|
-
writes.push(
|
|
298
|
+
reads.push(ambient_state_name_1.AmbientStateName.rng);
|
|
299
|
+
writes.push(ambient_state_name_1.AmbientStateName.rng);
|
|
341
300
|
break;
|
|
342
301
|
case "read-files" /* AmbientStateAccessType.ReadFiles */: {
|
|
343
302
|
const stems = fileStems(res, rootId, data, access);
|
|
344
|
-
reads.push(
|
|
303
|
+
reads.push(ambient_state_name_1.AmbientStateName.workingDirectory, ...stems === undefined ? [ambient_state_name_1.AmbientStateName.files] : [...stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.anyFile]);
|
|
345
304
|
break;
|
|
346
305
|
}
|
|
347
306
|
case "write-files" /* AmbientStateAccessType.WriteFiles */: {
|
|
348
307
|
const stems = fileStems(res, rootId, data, access);
|
|
349
|
-
reads.push(
|
|
350
|
-
writes.push(...stems === undefined ? [
|
|
308
|
+
reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
|
|
309
|
+
writes.push(...stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile] : stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.files);
|
|
351
310
|
break;
|
|
352
311
|
}
|
|
353
312
|
case "set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */:
|
|
354
313
|
/* a relative `dir` resolves against the current one, which the call also returns */
|
|
355
|
-
reads.push(
|
|
356
|
-
writes.push(
|
|
314
|
+
reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
|
|
315
|
+
writes.push(ambient_state_name_1.AmbientStateName.workingDirectory);
|
|
357
316
|
break;
|
|
358
317
|
case "get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */:
|
|
359
|
-
reads.push(
|
|
318
|
+
reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
|
|
360
319
|
break;
|
|
361
320
|
case "open-text-connection" /* AmbientStateAccessType.OpenTextConnection */:
|
|
362
321
|
return openTextConnection(res, args, rootId, data);
|
|
363
322
|
case "register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */:
|
|
364
323
|
return registerFinalizer(res, args, rootId, data);
|
|
365
324
|
case "run-finalizers" /* AmbientStateAccessType.RunFinalizers */: {
|
|
366
|
-
const registered = (resolve_helper_1.Resolve.byName(
|
|
325
|
+
const registered = (resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.finalizers, data.environment) ?? []);
|
|
367
326
|
for (const fn of registered.flatMap(d => d.value ?? [])) {
|
|
368
327
|
res.graph.addEdge(rootId, fn, edge_1.EdgeType.Calls);
|
|
369
328
|
}
|
|
370
|
-
return withAccess(res, rootId, data, [
|
|
329
|
+
return withAccess(res, rootId, data, [ambient_state_name_1.AmbientStateName.finalizers], registered.flatMap(d => d.writes ?? []).map(maybe));
|
|
371
330
|
}
|
|
372
331
|
}
|
|
373
|
-
return withAccess(res, rootId, data, reads, writes);
|
|
332
|
+
return withAccess(res, rootId, data, reads, (0, arrays_1.uniqueArray)(writes));
|
|
374
333
|
}
|
|
375
334
|
/** `reg.finalizer(e, f)` keeps the functions `f` may be, and the name holding `e`, whose release lets `gc()` run them. */
|
|
376
335
|
function registerFinalizer(res, args, rootId, data) {
|
|
@@ -382,18 +341,18 @@ function registerFinalizer(res, args, rootId, data) {
|
|
|
382
341
|
const definition = res.graph.getVertex(id);
|
|
383
342
|
return vertex_1.DfgVertex.isFunctionDefinition(definition) ? ambientWritesBetween(definition.subflow.environment, data.environment) : [];
|
|
384
343
|
});
|
|
385
|
-
const definition = { nodeId: rootId, name:
|
|
344
|
+
const definition = { nodeId: rootId, name: ambient_state_name_1.AmbientStateName.finalizers, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: data.cds ? [...data.cds] : [], value, writes, holder: r_symbol_1.RSymbol.is(holder) ? identifier_1.Identifier.getName(holder.content) : undefined };
|
|
386
345
|
return { ...res, environment: environment_1.REnvironment.define(definition, true, res.environment, true) };
|
|
387
346
|
}
|
|
388
347
|
/** `textConnection(object, open, local)` opened for writing binds `object` globally, or locally with `local = TRUE`. */
|
|
389
348
|
function openTextConnection(res, args, rootId, data) {
|
|
390
349
|
const bound = match_args_1.MatchArgs.toNames(args, ['object', 'open', 'local', 'name', 'encoding']);
|
|
391
350
|
const open = bound.get('open');
|
|
392
|
-
const modes = open === undefined ? ['r'] : stringValuesOf(open, data);
|
|
351
|
+
const modes = open === undefined ? ['r'] : (0, built_in_ambient_keys_1.stringValuesOf)(open, data);
|
|
393
352
|
if (modes?.every(m => m.startsWith('r'))) {
|
|
394
353
|
return res;
|
|
395
354
|
}
|
|
396
|
-
const names = stringValuesOf(bound.get('object'), data);
|
|
355
|
+
const names = (0, built_in_ambient_keys_1.stringValuesOf)(bound.get('object'), data);
|
|
397
356
|
if (names === undefined) {
|
|
398
357
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId);
|
|
399
358
|
return res;
|
|
@@ -408,7 +367,7 @@ function openTextConnection(res, args, rootId, data) {
|
|
|
408
367
|
}
|
|
409
368
|
}
|
|
410
369
|
markForcing(environment);
|
|
411
|
-
return withAccess({ ...res, environment }, rootId, data, [], names.map(
|
|
370
|
+
return withAccess({ ...res, environment }, rootId, data, [], names.map(ambient_state_name_1.AmbientStateName.textConnection));
|
|
412
371
|
}
|
|
413
372
|
/** The stems of the files the call names, `undefined` unless every file argument is a known path to a file with an extension (a device's `plot%03d.png` or a directory may stand for others). */
|
|
414
373
|
function fileStems(res, rootId, data, { sig, numbered }) {
|
|
@@ -466,50 +425,66 @@ function applyWithUnknownArguments(res, rootId, data, access) {
|
|
|
466
425
|
const { reads, writes } = unknownArgumentAccess(access);
|
|
467
426
|
return withAccess(res, rootId, data, reads, writes);
|
|
468
427
|
}
|
|
469
|
-
const Devices = { reads: [], writes: [
|
|
470
|
-
const Quoted = { reads: [
|
|
428
|
+
const Devices = { reads: [], writes: [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device] };
|
|
429
|
+
const Quoted = { reads: [ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette], writes: [ambient_state_name_1.AmbientStateName.unknownOption, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette] };
|
|
471
430
|
/** What a call of the given kind may read and write when its arguments are unknown, as when only linking reveals it. */
|
|
472
431
|
const UnknownArgumentAccess = {
|
|
473
|
-
["set-options" /* AmbientStateAccessType.SetOptions */]: { reads: [
|
|
474
|
-
["get-option" /* AmbientStateAccessType.GetOption */]: { reads: [
|
|
475
|
-
["set-graphics" /* AmbientStateAccessType.SetGraphics */]: { reads: [
|
|
476
|
-
["read-graphics" /* AmbientStateAccessType.ReadGraphics */]: { reads: [
|
|
477
|
-
["set-palette" /* AmbientStateAccessType.SetPalette */]: { reads: [
|
|
432
|
+
["set-options" /* AmbientStateAccessType.SetOptions */]: { reads: [ambient_state_name_1.AmbientStateName.allOptions], writes: [ambient_state_name_1.AmbientStateName.unknownOption, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.warnsAsErrors] },
|
|
433
|
+
["get-option" /* AmbientStateAccessType.GetOption */]: { reads: [ambient_state_name_1.AmbientStateName.allOptions], writes: [] },
|
|
434
|
+
["set-graphics" /* AmbientStateAccessType.SetGraphics */]: { reads: [ambient_state_name_1.AmbientStateName.graphics], writes: [ambient_state_name_1.AmbientStateName.graphics] },
|
|
435
|
+
["read-graphics" /* AmbientStateAccessType.ReadGraphics */]: { reads: [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette], writes: [] },
|
|
436
|
+
["set-palette" /* AmbientStateAccessType.SetPalette */]: { reads: [ambient_state_name_1.AmbientStateName.palette], writes: [ambient_state_name_1.AmbientStateName.palette] },
|
|
478
437
|
["open-device" /* AmbientStateAccessType.OpenDevice */]: Devices,
|
|
479
438
|
["close-device" /* AmbientStateAccessType.CloseDevice */]: Devices,
|
|
480
439
|
["switch-device" /* AmbientStateAccessType.SwitchDevice */]: Devices,
|
|
481
440
|
["evaluate-quoted" /* AmbientStateAccessType.EvaluateQuoted */]: Quoted,
|
|
482
|
-
["set-rng" /* AmbientStateAccessType.SetRng */]: { reads: [
|
|
483
|
-
["draw-rng" /* AmbientStateAccessType.DrawRng */]: { reads: [
|
|
484
|
-
["read-files" /* AmbientStateAccessType.ReadFiles */]: { reads: [
|
|
485
|
-
["write-files" /* AmbientStateAccessType.WriteFiles */]: { reads: [
|
|
486
|
-
["set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */]: { reads: [
|
|
487
|
-
["get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */]: { reads: [
|
|
441
|
+
["set-rng" /* AmbientStateAccessType.SetRng */]: { reads: [ambient_state_name_1.AmbientStateName.rngKind], writes: [ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.rngKind] },
|
|
442
|
+
["draw-rng" /* AmbientStateAccessType.DrawRng */]: { reads: [ambient_state_name_1.AmbientStateName.rng], writes: [ambient_state_name_1.AmbientStateName.rng] },
|
|
443
|
+
["read-files" /* AmbientStateAccessType.ReadFiles */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory, ambient_state_name_1.AmbientStateName.files], writes: [] },
|
|
444
|
+
["write-files" /* AmbientStateAccessType.WriteFiles */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] },
|
|
445
|
+
["set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [ambient_state_name_1.AmbientStateName.workingDirectory] },
|
|
446
|
+
["get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [] },
|
|
488
447
|
["open-text-connection" /* AmbientStateAccessType.OpenTextConnection */]: { reads: [], writes: [] },
|
|
489
|
-
["register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */]: { reads: [], writes: [
|
|
490
|
-
["run-finalizers" /* AmbientStateAccessType.RunFinalizers */]: { reads: [
|
|
448
|
+
["register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */]: { reads: [], writes: [ambient_state_name_1.AmbientStateName.finalizers] },
|
|
449
|
+
["run-finalizers" /* AmbientStateAccessType.RunFinalizers */]: { reads: [ambient_state_name_1.AmbientStateName.finalizers], writes: [] }
|
|
491
450
|
};
|
|
492
451
|
function unknownArgumentAccess(access) {
|
|
493
|
-
|
|
494
|
-
|
|
452
|
+
switch (access.type) {
|
|
453
|
+
case "read-options" /* AmbientStateAccessType.ReadOptions */:
|
|
454
|
+
return { reads: optionReads(access.dispatchOn === undefined ? access.keys : undefined), writes: [] };
|
|
455
|
+
case "set-keyed" /* AmbientStateAccessType.SetKeyed */:
|
|
456
|
+
return { reads: [], writes: (0, built_in_ambient_keys_1.keyedWrites)(access.state, [ambient_state_name_1.UnknownKey]) };
|
|
457
|
+
case "set-state" /* AmbientStateAccessType.SetState */:
|
|
458
|
+
return { reads: [], writes: [access.state] };
|
|
459
|
+
default:
|
|
460
|
+
return UnknownArgumentAccess[access.type];
|
|
495
461
|
}
|
|
496
|
-
return { reads: optionReads(access.dispatchOn === undefined ? access.keys : undefined), writes: [] };
|
|
497
462
|
}
|
|
498
463
|
/** Graphics parameters are per device; within a function the open devices are unknown, so a device call only adds. */
|
|
499
464
|
function deviceAccess(res, rootId, data, kind) {
|
|
500
465
|
/* only a switch reads the state; what a closed device holds reaches its file through the plots on it (see LinkToLastPlot) */
|
|
501
|
-
const reads = kind === 'switch' ? [
|
|
466
|
+
const reads = kind === 'switch' ? [ambient_state_name_1.AmbientStateName.graphics] : [];
|
|
502
467
|
/* closing writes the file of the device, which its opening names unless we do not know the device closed */
|
|
503
|
-
const unnamedFile = kind === 'open' ? [] : [
|
|
468
|
+
const unnamedFile = kind === 'open' ? [] : [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files];
|
|
469
|
+
const cds = data.cds ? [...data.cds] : undefined;
|
|
504
470
|
if (data.environment.level > 0) {
|
|
505
|
-
|
|
471
|
+
/* a device the body opened itself is the one a later close in the same body closes:
|
|
472
|
+
`f <- function() { pdf("a.pdf"); plot(1); dev.off() }` writes `a.pdf` and no other file */
|
|
473
|
+
const here = kind === 'close' ? res.environment.current.memory.get(ambient_state_name_1.AmbientStateName.deviceOpenedHere) ?? [] : [];
|
|
474
|
+
for (const open of here) {
|
|
475
|
+
res.graph.addEdge(open.nodeId, rootId, edge_1.EdgeType.Reads);
|
|
476
|
+
}
|
|
477
|
+
let environment = { ...res.environment, current: res.environment.current.removeAll([{ name: ambient_state_name_1.AmbientStateName.deviceOpenedHere }]) };
|
|
478
|
+
if (kind === 'open') {
|
|
479
|
+
environment = defineAmbient(environment, rootId, cds, [{ name: ambient_state_name_1.AmbientStateName.deviceOpenedHere, mode: 'local' }]);
|
|
480
|
+
}
|
|
481
|
+
return withAccess({ ...res, environment }, rootId, data, reads, [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device, ...here.length > 0 ? [] : unnamedFile]);
|
|
506
482
|
}
|
|
507
|
-
const cds = data.cds ? [...data.cds] : undefined;
|
|
508
483
|
const lookup = (name) => resolve_helper_1.Resolve.byName(name, res.environment) ?? [];
|
|
509
|
-
const current = lookup(
|
|
510
|
-
const others = lookup(
|
|
511
|
-
const opener = lookup(
|
|
512
|
-
const otherOpeners = lookup(
|
|
484
|
+
const current = lookup(ambient_state_name_1.AmbientStateName.graphics);
|
|
485
|
+
const others = lookup(ambient_state_name_1.AmbientStateName.otherDevices);
|
|
486
|
+
const opener = lookup(ambient_state_name_1.AmbientStateName.device);
|
|
487
|
+
const otherOpeners = lookup(ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy);
|
|
513
488
|
let environment = res.environment;
|
|
514
489
|
const reset = (name) => defineAmbient(environment, rootId, cds, [{ name, mode: 'reset' }]);
|
|
515
490
|
/* a later plot depends on neither the close nor the closed device's state; a device only depends on its close so it does not catch later plots */
|
|
@@ -520,15 +495,15 @@ function deviceAccess(res, rootId, data, kind) {
|
|
|
520
495
|
};
|
|
521
496
|
switch (kind) {
|
|
522
497
|
case 'open':
|
|
523
|
-
environment = setAmbient(environment,
|
|
524
|
-
environment = setAmbient(environment,
|
|
525
|
-
environment = reset(
|
|
526
|
-
environment = reset(
|
|
498
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevices, [...others, ...current]);
|
|
499
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy, [...otherOpeners, ...opener]);
|
|
500
|
+
environment = reset(ambient_state_name_1.AmbientStateName.graphics);
|
|
501
|
+
environment = reset(ambient_state_name_1.AmbientStateName.device);
|
|
527
502
|
break;
|
|
528
503
|
case 'close':
|
|
529
504
|
closes(opener);
|
|
530
|
-
environment = setAmbient(environment,
|
|
531
|
-
environment = setAmbient(environment,
|
|
505
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.graphics, others);
|
|
506
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.device, otherOpeners);
|
|
532
507
|
break;
|
|
533
508
|
case 'close-all':
|
|
534
509
|
closes([...opener, ...otherOpeners]);
|
|
@@ -537,11 +512,11 @@ function deviceAccess(res, rootId, data, kind) {
|
|
|
537
512
|
}
|
|
538
513
|
break;
|
|
539
514
|
case 'switch':
|
|
540
|
-
environment = defineAmbient(environment, rootId, cds, [
|
|
541
|
-
environment = setAmbient(environment,
|
|
542
|
-
environment = setAmbient(environment,
|
|
543
|
-
environment = setAmbient(environment,
|
|
544
|
-
environment = setAmbient(environment,
|
|
515
|
+
environment = defineAmbient(environment, rootId, cds, [ambient_state_name_1.AmbientStateName.graphics]);
|
|
516
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.graphics, others, true);
|
|
517
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevices, current, true);
|
|
518
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.device, otherOpeners, true);
|
|
519
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy, opener, true);
|
|
545
520
|
break;
|
|
546
521
|
}
|
|
547
522
|
const known = kind === 'close' ? opener.length > 0 : kind === 'close-all' && opener.length + otherOpeners.length > 0;
|
|
@@ -578,7 +553,7 @@ function setOptions(res, args, rootId, data) {
|
|
|
578
553
|
}
|
|
579
554
|
if (arg.name !== undefined) {
|
|
580
555
|
const key = identifier_1.Identifier.getName(arg.name.content);
|
|
581
|
-
written.push(
|
|
556
|
+
written.push(ambient_state_name_1.AmbientStateName.option(key));
|
|
582
557
|
global ||= GlobalEffectOptions.has(key);
|
|
583
558
|
warnsAsErrors ||= key === 'warn' && !node_value_1.NodeValue.setOf(arg.value?.info.id, data)?.elements.every(belowTwo);
|
|
584
559
|
}
|
|
@@ -596,22 +571,22 @@ function setOptions(res, args, rootId, data) {
|
|
|
596
571
|
}
|
|
597
572
|
/* the call returns the previous values of what it sets, which only matters if that value is used */
|
|
598
573
|
const previous = resultIsUsed(rootId, data) ? written : [];
|
|
599
|
-
const reads = [...queried.map(
|
|
574
|
+
const reads = [...queried.map(ambient_state_name_1.AmbientStateName.option), ...previous];
|
|
600
575
|
if (args.length === 0 || unknownKeys) {
|
|
601
|
-
reads.push(
|
|
576
|
+
reads.push(ambient_state_name_1.AmbientStateName.allOptions);
|
|
602
577
|
}
|
|
603
578
|
if (reads.length > 0) {
|
|
604
|
-
reads.push(
|
|
579
|
+
reads.push(ambient_state_name_1.AmbientStateName.unknownOption);
|
|
605
580
|
}
|
|
606
581
|
const writes = [...written];
|
|
607
582
|
if (unknownKeys) {
|
|
608
|
-
writes.push(
|
|
583
|
+
writes.push(ambient_state_name_1.AmbientStateName.unknownOption);
|
|
609
584
|
}
|
|
610
585
|
if (warnsAsErrors) {
|
|
611
|
-
writes.push(
|
|
586
|
+
writes.push(ambient_state_name_1.AmbientStateName.warnsAsErrors);
|
|
612
587
|
}
|
|
613
588
|
if (writes.length > 0) {
|
|
614
|
-
writes.push(
|
|
589
|
+
writes.push(ambient_state_name_1.AmbientStateName.allOptions);
|
|
615
590
|
}
|
|
616
591
|
return withAccess(res, rootId, data, reads, writes);
|
|
617
592
|
}
|
|
@@ -631,6 +606,8 @@ function onlyQueries(access, args) {
|
|
|
631
606
|
return isQuery(args);
|
|
632
607
|
case "set-palette" /* AmbientStateAccessType.SetPalette */:
|
|
633
608
|
return args.length === 0;
|
|
609
|
+
case "set-state" /* AmbientStateAccessType.SetState */:
|
|
610
|
+
return access.queryWithoutArguments === true && args.length === 0;
|
|
634
611
|
default:
|
|
635
612
|
return false;
|
|
636
613
|
}
|
|
@@ -640,16 +617,6 @@ function isQuery(args) {
|
|
|
640
617
|
return args.every(a => a === r_function_call_1.EmptyArgument
|
|
641
618
|
|| (a.name === undefined ? r_string_1.RString.is(a.value) : identifier_1.Identifier.getName(a.name.content) === 'no.readonly'));
|
|
642
619
|
}
|
|
643
|
-
function stringValuesOf(value, data) {
|
|
644
|
-
if (value === undefined) {
|
|
645
|
-
return undefined;
|
|
646
|
-
}
|
|
647
|
-
else if (r_string_1.RString.is(value)) {
|
|
648
|
-
return [value.content.str];
|
|
649
|
-
}
|
|
650
|
-
const strings = node_value_1.NodeValue.stringsOf(value.info.id, data);
|
|
651
|
-
return strings === undefined || strings.length === 0 ? undefined : strings;
|
|
652
|
-
}
|
|
653
620
|
/** Whether the call's value may be used: anything but a non-final statement or the script's last statement (the last of a block is its value). */
|
|
654
621
|
function resultIsUsed(rootId, data) {
|
|
655
622
|
const node = data.completeAst.idMap.get(rootId);
|
|
@@ -662,7 +629,7 @@ function resultIsUsed(rootId, data) {
|
|
|
662
629
|
}
|
|
663
630
|
/** Links state reads in a loop body to the body's own writes of a later iteration and returns them, as the first iteration reads what is there before the loop. */
|
|
664
631
|
function linkAmbientStateWithinLoop(graph, reads, body) {
|
|
665
|
-
const ambient = reads.filter(r =>
|
|
632
|
+
const ambient = reads.filter(r => ambient_state_name_1.AmbientStateName.is(r.name));
|
|
666
633
|
for (const r of ambient) {
|
|
667
634
|
for (const def of resolve_helper_1.Resolve.byName(r.name, body.environment) ?? []) {
|
|
668
635
|
if (body.graph.hasVertex(def.nodeId)) {
|
|
@@ -695,8 +662,8 @@ function processAmbientScope(name, args, rootId, data, scope) {
|
|
|
695
662
|
/* afterward, what the scope changed is back to what it was before */
|
|
696
663
|
let environment = information.environment;
|
|
697
664
|
const restored = scope.state === 'device' ? DeviceStates
|
|
698
|
-
: scope.state === 'rng' ? [
|
|
699
|
-
: writes.map(w => typeof w === 'string' ? w : w.name).filter(n => n.startsWith('#option:') && n !==
|
|
665
|
+
: scope.state === 'rng' ? [ambient_state_name_1.AmbientStateName.rng]
|
|
666
|
+
: writes.map(w => typeof w === 'string' ? w : w.name).filter(n => n.startsWith('#option:') && n !== ambient_state_name_1.AmbientStateName.unknownOption);
|
|
700
667
|
for (const state of restored) {
|
|
701
668
|
const before = resolve_helper_1.Resolve.byName(state, data.environment);
|
|
702
669
|
/* an option nothing set before keeps the scope's definition, we cannot tell R's default apart */
|
|
@@ -706,15 +673,15 @@ function processAmbientScope(name, args, rootId, data, scope) {
|
|
|
706
673
|
}
|
|
707
674
|
if (scope.state === 'graphics') {
|
|
708
675
|
/* `with_par` restores the parameters it set, what its code set with `par` stays */
|
|
709
|
-
const kept = (resolve_helper_1.Resolve.byName(
|
|
710
|
-
environment = setAmbient(environment,
|
|
676
|
+
const kept = (resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.graphics, environment) ?? []).filter(d => d.nodeId !== rootId);
|
|
677
|
+
environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.graphics, kept);
|
|
711
678
|
}
|
|
712
679
|
return { ...information, environment };
|
|
713
680
|
}
|
|
714
681
|
/** what a scope call writes: the options it names, or the graphics state */
|
|
715
682
|
function scopedWrites(scope, args, bound, local) {
|
|
716
683
|
if (scope.state !== 'options') {
|
|
717
|
-
return { writes: [scope.state === 'rng' ?
|
|
684
|
+
return { writes: [scope.state === 'rng' ? ambient_state_name_1.AmbientStateName.rng : ambient_state_name_1.AmbientStateName.graphics], unknown: false };
|
|
718
685
|
}
|
|
719
686
|
const keys = [];
|
|
720
687
|
let unknown = false;
|
|
@@ -753,12 +720,12 @@ function scopedWrites(scope, args, bound, local) {
|
|
|
753
720
|
}
|
|
754
721
|
}
|
|
755
722
|
/* we do not resolve the value a scope sets, so setting `warn` may turn warnings into errors */
|
|
756
|
-
const names = keys.map(
|
|
723
|
+
const names = keys.map(ambient_state_name_1.AmbientStateName.option).concat(keys.includes('warn') ? [ambient_state_name_1.AmbientStateName.warnsAsErrors] : []);
|
|
757
724
|
const writes = names.map(name => local ? { name, mode: 'local' } : name);
|
|
758
725
|
if (unknown) {
|
|
759
|
-
writes.push(
|
|
726
|
+
writes.push(local ? { name: ambient_state_name_1.AmbientStateName.unknownOption, mode: 'local' } : ambient_state_name_1.AmbientStateName.unknownOption);
|
|
760
727
|
}
|
|
761
|
-
writes.push(
|
|
728
|
+
writes.push(local ? { name: ambient_state_name_1.AmbientStateName.allOptions, mode: 'local' } : ambient_state_name_1.AmbientStateName.allOptions);
|
|
762
729
|
return { writes, unknown: unknown || keys.some(k => GlobalEffectOptions.has(k)) };
|
|
763
730
|
}
|
|
764
731
|
/** Evaluating captured code may access any state; `Quoted.finalize` drops the writes again once the code is known to change none. */
|
|
@@ -816,8 +783,8 @@ function belowTwo(value) {
|
|
|
816
783
|
/** With `warn >= 2` R turns warnings into errors, so whatever may warn in `block` is a maybe error exit reading the options that may set `warn`. */
|
|
817
784
|
function errorsOfWarnings(block, after, graph, data) {
|
|
818
785
|
const lookup = (name) => [...resolve_helper_1.Resolve.byName(name, data.environment) ?? [], ...resolve_helper_1.Resolve.byName(name, after) ?? []];
|
|
819
|
-
const marked = new Set(lookup(
|
|
820
|
-
const sources = new Set([...lookup(
|
|
786
|
+
const marked = new Set(lookup(ambient_state_name_1.AmbientStateName.warnsAsErrors).map(d => d.nodeId));
|
|
787
|
+
const sources = new Set([...lookup(ambient_state_name_1.AmbientStateName.option('warn')).filter(d => marked.has(d.nodeId)), ...lookup(ambient_state_name_1.AmbientStateName.unknownOption)].map(d => d.nodeId));
|
|
821
788
|
if (sources.size === 0) {
|
|
822
789
|
return [];
|
|
823
790
|
}
|
|
@@ -5,7 +5,7 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
|
|
|
5
5
|
import { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
6
6
|
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
7
7
|
import type { MergeableRecord } from '../../../../../../util/objects';
|
|
8
|
-
import {
|
|
8
|
+
import { Identifier } from '../../../../../environments/identifier';
|
|
9
9
|
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
|
|
10
10
|
/** the function reference extracted from an argument passed to a higher-order call */
|
|
11
11
|
export interface ResolvedFunctionArgument {
|
|
@@ -34,6 +34,11 @@ export interface BuiltInApplyConfiguration extends MergeableRecord {
|
|
|
34
34
|
readonly resolveValue?: boolean;
|
|
35
35
|
/** the call reaches beyond what we can see even when the callee resolves, like `rlang::exec` */
|
|
36
36
|
readonly hasUnknownSideEffects?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Set for `do.call`: it is processed like the call it makes, so `do.call(f, list(1, b = 2))` is processed like
|
|
39
|
+
* `f(1, b = 2)` and returns what `f` returns.
|
|
40
|
+
*/
|
|
41
|
+
readonly isTheCall?: boolean;
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Process an apply call like `vapply` or `mapply`.
|