@eagleoutice/flowr 2.17.5 → 2.17.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -51
- package/abstract-interpretation/absint-inference.d.ts +4 -4
- package/abstract-interpretation/absint-inference.js +11 -11
- package/abstract-interpretation/abstract-semantics.d.ts +2 -1
- package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
- package/abstract-interpretation/branch-paths-interpreter.js +60 -0
- package/abstract-interpretation/branch-paths.d.ts +60 -0
- package/abstract-interpretation/branch-paths.js +120 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +6 -1
- package/abstract-interpretation/data-frame/dataframe-semantics.js +60 -1
- package/abstract-interpretation/data-frame/semantics.js +4 -10
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/cli/repl/core.js +51 -0
- package/control-flow/cfg-dead-code.js +12 -7
- package/data/packed.d.ts +10 -0
- package/data/packed.js +33 -0
- package/data/r-base-guards.generated.d.ts +7 -0
- package/data/r-base-guards.generated.js +12 -0
- package/data/r-datasets.generated.d.ts +4 -0
- package/data/r-datasets.generated.js +10 -0
- package/data/r-formals.generated.d.ts +4 -0
- package/data/r-formals.generated.js +10 -0
- package/data/r-group-method-guards.generated.d.ts +3 -0
- package/data/r-group-method-guards.generated.js +8 -0
- package/dataflow/environments/ambient-effect.d.ts +1000 -0
- package/dataflow/environments/ambient-effect.js +234 -0
- package/dataflow/environments/ambient-state-name.d.ts +45 -2
- package/dataflow/environments/ambient-state-name.js +61 -3
- package/dataflow/environments/apply-kill.js +11 -4
- package/dataflow/environments/built-in-kinds.d.ts +4 -46
- package/dataflow/environments/built-in-kinds.js +6 -2
- package/dataflow/environments/built-in-props.d.ts +16 -4
- package/dataflow/environments/built-in-props.js +11 -3
- package/dataflow/environments/built-in.d.ts +6 -1
- package/dataflow/environments/built-in.js +13 -36
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +110 -52
- package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-language.js +11 -8
- package/dataflow/environments/default-builtin-config/dev-tooling.js +1 -1
- package/dataflow/environments/default-builtin-config/file-io.js +6 -4
- package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/graphics-devices.js +24 -14
- package/dataflow/environments/default-builtin-config/guard-builders.d.ts +16 -0
- package/dataflow/environments/default-builtin-config/guard-builders.js +29 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
- package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
- package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
- package/dataflow/environments/default-builtin-config/guards.js +211 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +3 -3
- package/dataflow/environments/default-builtin-config/index.js +22 -7
- package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
- package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
- package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
- package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/package-utils.js +5 -2
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
- package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
- package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
- package/dataflow/environments/default-builtin-config/shared-configs.d.ts +138 -77
- package/dataflow/environments/default-builtin-config/shared-configs.js +52 -88
- package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/statistics.js +4 -1
- package/dataflow/environments/diff.js +5 -2
- package/dataflow/environments/environment.d.ts +20 -0
- package/dataflow/environments/environment.js +39 -4
- package/dataflow/environments/group-generics.d.ts +5 -1
- package/dataflow/environments/group-generics.js +13 -3
- package/dataflow/environments/guard-facts.d.ts +169 -0
- package/dataflow/environments/guard-facts.js +26 -0
- package/dataflow/environments/identifier.d.ts +9 -1
- package/dataflow/environments/identifier.js +5 -0
- package/dataflow/environments/pkg-name.d.ts +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -5
- package/dataflow/environments/query-fn-props.js +44 -21
- package/dataflow/environments/removal-marker.d.ts +2 -0
- package/dataflow/environments/removal-marker.js +5 -0
- package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
- package/dataflow/eval/resolve/resolve-strings.js +2 -2
- package/dataflow/extractor.js +24 -15
- package/dataflow/fn/condition-handlers.d.ts +2 -0
- package/dataflow/fn/condition-handlers.js +3 -1
- package/dataflow/fn/frame-reflection.d.ts +4 -2
- package/dataflow/fn/frame-reflection.js +16 -0
- package/dataflow/fn/function-props.js +15 -22
- package/dataflow/fn/function-semantics.d.ts +31 -1
- package/dataflow/fn/function-semantics.js +15 -0
- package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
- package/dataflow/fn/guards/built-in-guards.js +199 -0
- package/dataflow/fn/guards/call-contracts.d.ts +97 -0
- package/dataflow/fn/guards/call-contracts.js +331 -0
- package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
- package/dataflow/fn/guards/condition-grouping.js +135 -0
- package/dataflow/fn/guards/function-guards.d.ts +112 -0
- package/dataflow/fn/guards/function-guards.js +1549 -0
- package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
- package/dataflow/fn/guards/group-method-guards.js +56 -0
- package/dataflow/fn/guards/guard-claims.d.ts +125 -0
- package/dataflow/fn/guards/guard-claims.js +678 -0
- package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
- package/dataflow/fn/guards/guard-knowledge.js +180 -0
- package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
- package/dataflow/fn/guards/guard-term-syntax.js +210 -0
- package/dataflow/fn/guards/guard-term.d.ts +136 -0
- package/dataflow/fn/guards/guard-term.js +550 -0
- package/dataflow/fn/guards/stated-guards.d.ts +13 -0
- package/dataflow/fn/guards/stated-guards.js +35 -0
- package/dataflow/fn/higher-order-function.d.ts +2 -0
- package/dataflow/fn/higher-order-function.js +1 -0
- package/dataflow/fn/strict-function.d.ts +4 -0
- package/dataflow/fn/strict-function.js +66 -17
- package/dataflow/graph/ambient-access.d.ts +4 -1
- package/dataflow/graph/ambient-access.js +8 -2
- package/dataflow/graph/closure-frames.js +1 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +15 -0
- package/dataflow/graph/graph.d.ts +12 -6
- package/dataflow/graph/graph.js +21 -28
- package/dataflow/info.d.ts +2 -1
- package/dataflow/info.js +3 -1
- package/dataflow/internal/dispatch-linking.d.ts +3 -1
- package/dataflow/internal/dispatch-linking.js +1 -0
- package/dataflow/internal/linker.d.ts +2 -0
- package/dataflow/internal/linker.js +115 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -57
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +471 -295
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +13 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +106 -19
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +24 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +33 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +23 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +347 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +110 -16
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +28 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +16 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +37 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +55 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +64 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +160 -20
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +6 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +142 -4
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +23 -4
- package/dataflow/processor.d.ts +2 -0
- package/documentation/data/dfg/doc-ambient.d.ts +4 -0
- package/documentation/data/dfg/doc-ambient.js +74 -0
- package/documentation/wiki-dataflow-graph.js +10 -4
- package/documentation/wiki-linter.js +12 -0
- package/documentation/wiki-query.js +112 -1
- package/linter/linter-rules.d.ts +41 -1
- package/linter/linter-rules.js +5 -1
- package/linter/rules/call-contracts.d.ts +40 -0
- package/linter/rules/call-contracts.js +56 -0
- package/linter/rules/cmd-check/bogus-return.js +1 -1
- package/linter/rules/cmd-check/call-arguments.js +5 -6
- package/linter/rules/cmd-check/cmd-check-util.d.ts +0 -6
- package/linter/rules/cmd-check/cmd-check-util.js +0 -28
- package/linter/rules/cmd-check/package-hooks.js +2 -1
- package/linter/rules/cmd-check/s-three-method-consistency.js +1 -1
- package/linter/rules/interactive-functions.d.ts +30 -0
- package/linter/rules/interactive-functions.js +87 -0
- package/linter/rules/process-state-in-session.js +1 -1
- package/linter/rules/undefined-symbol-util.d.ts +1 -1
- package/linter/rules/undefined-symbol-util.js +8 -2
- package/linter/rules/undefined-symbol.js +18 -7
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +1 -1
- package/project/context/flowr-analyzer-dependencies-context.js +2 -1
- package/project/flowr-analyzer.d.ts +1 -0
- package/project/flowr-analyzer.js +5 -5
- package/project/sigdb/build.js +14 -4
- package/project/sigdb/decode.d.ts +3 -0
- package/project/sigdb/decode.js +10 -1
- package/project/sigdb/guarded-source.d.ts +6 -0
- package/project/sigdb/guarded-source.js +29 -0
- package/project/sigdb/reader.d.ts +5 -0
- package/project/sigdb/reader.js +27 -1
- package/project/sigdb/schema.d.ts +24 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +6 -3
- package/queries/catalog/absint-query/absint-query-format.js +57 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +6 -2
- package/queries/catalog/ambient-access-query/ambient-access-query-format.js +48 -3
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +19 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +5 -2
- package/queries/catalog/code-clones-query/code-clones-query-format.js +34 -2
- package/queries/catalog/config-query/config-query-format.d.ts +5 -2
- package/queries/catalog/config-query/config-query-format.js +41 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -2
- package/queries/catalog/control-flow-query/control-flow-query-format.js +19 -2
- package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +72 -0
- package/queries/catalog/data-columns-query/data-columns-query-format.js +215 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +38 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +18 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +8 -3
- package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
- package/queries/catalog/dependencies-query/function-info/tagged-functions.js +18 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
- package/queries/catalog/dice-query/dice-query-format.js +34 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -4
- package/queries/catalog/does-call-query/does-call-query-format.js +114 -2
- package/queries/catalog/files-query/files-query-format.d.ts +5 -2
- package/queries/catalog/files-query/files-query-format.js +45 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +6 -3
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +303 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.js +37 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +18 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +5 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +29 -2
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +125 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +54 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +23 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +15 -2
- package/queries/catalog/linter-query/linter-query-format.d.ts +8 -2
- package/queries/catalog/linter-query/linter-query-format.js +69 -4
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
- package/queries/catalog/location-map-query/location-map-query-format.js +70 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +18 -2
- package/queries/catalog/origin-query/origin-query-format.d.ts +6 -3
- package/queries/catalog/origin-query/origin-query-format.js +29 -2
- package/queries/catalog/project-query/project-query-format.d.ts +6 -3
- package/queries/catalog/project-query/project-query-format.js +98 -2
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +6 -3
- package/queries/catalog/provenance-query/provenance-query-format.js +30 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +9 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +38 -2
- package/queries/catalog/search-query/search-query-format.d.ts +5 -2
- package/queries/catalog/search-query/search-query-format.js +23 -2
- package/queries/catalog/signature-query/signature-query-executor.js +3 -1
- package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
- package/queries/catalog/signature-query/signature-query-render.js +23 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +55 -2
- package/queries/catalog/taint-query/taint-query-format.d.ts +6 -3
- package/queries/catalog/taint-query/taint-query-format.js +28 -2
- package/queries/query.d.ts +48 -27
- package/queries/query.js +6 -4
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -0
- package/r-bridge/shell.js +7 -2
- package/reconstruct/reconstruct.js +18 -3
- package/slicing/static/removal-slice.js +4 -3
- package/slicing/static/slice-call.d.ts +11 -0
- package/slicing/static/slice-call.js +43 -2
- package/slicing/static/static-slicer.d.ts +2 -0
- package/slicing/static/static-slicer.js +137 -21
- package/slicing/static/visiting-queue.d.ts +2 -0
- package/slicing/static/visiting-queue.js +4 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/objects.d.ts +2 -0
- package/util/objects.js +5 -0
- package/util/r-datasets.d.ts +27 -0
- package/util/r-datasets.js +45 -0
- package/util/text/playground-link.d.ts +2 -0
- package/util/text/playground-link.js +2 -0
- package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
- package/queries/catalog/absint-query/absint-query-executor.js +0 -61
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
- package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
- package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
- package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
- package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
- package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
- package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
- package/queries/catalog/config-query/config-query-executor.js +0 -45
- package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
- package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
- package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
- package/queries/catalog/dice-query/dice-query-executor.js +0 -37
- package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
- package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
- package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
- package/queries/catalog/files-query/files-query-executor.js +0 -47
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
- package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
- package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
- package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
- package/queries/catalog/linter-query/linter-query-executor.js +0 -62
- package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
- package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
- package/queries/catalog/origin-query/origin-query-executor.js +0 -31
- package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
- package/queries/catalog/project-query/project-query-executor.js +0 -103
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
- package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
- package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
- package/queries/catalog/search-query/search-query-executor.js +0 -25
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
- package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
- package/queries/catalog/taint-query/taint-query-executor.js +0 -30
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallContracts = void 0;
|
|
4
|
+
const general_1 = require("../../eval/values/general");
|
|
5
|
+
const resolve_helper_1 = require("../../environments/resolve-helper");
|
|
6
|
+
const r_value_1 = require("../../eval/values/r-value");
|
|
7
|
+
const identifier_1 = require("../../environments/identifier");
|
|
8
|
+
const df_helper_1 = require("../../graph/df-helper");
|
|
9
|
+
const query_fn_props_1 = require("../../environments/query-fn-props");
|
|
10
|
+
const guard_term_1 = require("./guard-term");
|
|
11
|
+
const guard_term_syntax_1 = require("./guard-term-syntax");
|
|
12
|
+
const built_in_guards_1 = require("./built-in-guards");
|
|
13
|
+
const function_guards_1 = require("./function-guards");
|
|
14
|
+
const stated_guards_1 = require("./stated-guards");
|
|
15
|
+
const guard_knowledge_1 = require("./guard-knowledge");
|
|
16
|
+
const guard_claims_1 = require("./guard-claims");
|
|
17
|
+
const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
|
|
18
|
+
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
19
|
+
const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
20
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
21
|
+
const built_in_proc_name_1 = require("../../environments/built-in-proc-name");
|
|
22
|
+
const vertex_1 = require("../../graph/vertex");
|
|
23
|
+
const match_args_1 = require("../../graph/match-args");
|
|
24
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
25
|
+
const r_s3_generics_generated_1 = require("../../../data/r-s3-generics.generated");
|
|
26
|
+
const arrays_1 = require("../../../util/collections/arrays");
|
|
27
|
+
/** the replacement functions that rewrite a function, after which its formals and checks are no longer those of its definition */
|
|
28
|
+
const FormalsRewriters = new Set(['formals<-', 'body<-', 'args<-']);
|
|
29
|
+
/** How many combinations of the values the arguments may hold a condition is evaluated for. */
|
|
30
|
+
const MaxCombinations = 64;
|
|
31
|
+
/** How many nodes {@link readsParameter} looks at before it gives up. */
|
|
32
|
+
const MaxReads = 1024;
|
|
33
|
+
const LoadingCalls = new Set(['loadNamespace', 'requireNamespace', 'attachNamespace', 'registerS3method', 'source', 'sys.source', 'attach']);
|
|
34
|
+
/** Whether something besides the program may register S3 methods: a package it loads, attaches, or reaches into. */
|
|
35
|
+
function loadsPackages(graph, ctx) {
|
|
36
|
+
if (ctx.deps.getDependencies().length > 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
for (const [, vertex] of graph.vertices(true)) {
|
|
40
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const namespace = identifier_1.Identifier.getNamespace(vertex.name);
|
|
44
|
+
if (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Library) || (namespace !== undefined && !(0, r_base_packages_1.isBaseRPackage)(namespace)) || LoadingCalls.has(identifier_1.Identifier.getName(vertex.name))) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/** The scope to work out the contracts of the calls of the analyzed program in, sharing what they have in common. */
|
|
51
|
+
function of(graph, ctx, idMap = graph.idMap) {
|
|
52
|
+
const bindings = df_helper_1.Dataflow.definitionsByName(graph);
|
|
53
|
+
let loads;
|
|
54
|
+
return {
|
|
55
|
+
graph, idMap, ctx, facts: (0, guard_knowledge_1.guardFactsOf)(ctx),
|
|
56
|
+
mayAddMethods: generic => [...bindings.keys()].some(name => name.startsWith(`${generic}.`)) || (loads ??= loadsPackages(graph, ctx)),
|
|
57
|
+
rewritesFormals: [...graph.verticesOfType(vertex_1.VertexType.FunctionCall)].some(([, v]) => FormalsRewriters.has(identifier_1.Identifier.getName(v.name))),
|
|
58
|
+
definitions: new Map(),
|
|
59
|
+
functions: new Map()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Whether `a` and `b` name the same release of R, as what the closures of R check only changes between those. */
|
|
63
|
+
function sameRelease(a, b) {
|
|
64
|
+
return a.split('.').slice(0, 2).join('.') === b.split('.').slice(0, 2).join('.');
|
|
65
|
+
}
|
|
66
|
+
/** The conditions of the guards stated without a program, read back into terms over the formals. */
|
|
67
|
+
function statedClauses(name, stated, formals, scope) {
|
|
68
|
+
const texts = stated.because?.map(b => b.requires) ?? [stated.requires];
|
|
69
|
+
const terms = texts.flatMap(text => {
|
|
70
|
+
const term = text === '' ? undefined : (0, guard_term_syntax_1.parseGuardTerm)(text, formals, scope.facts);
|
|
71
|
+
return term === undefined ? [] : guard_term_1.GuardTerm.conjuncts(term);
|
|
72
|
+
});
|
|
73
|
+
/* a value without a class attribute may still run a method another package registers for its implicit class */
|
|
74
|
+
const open = (stated.dispatches !== undefined || r_s3_generics_generated_1.RS3Generics.genericFormals[String(name)] !== undefined) && scope.mayAddMethods(name);
|
|
75
|
+
return terms.filter(t => !open || !guard_term_1.GuardTerm.mentions(t, 'is.object'));
|
|
76
|
+
}
|
|
77
|
+
/** What is stated of a function by name: what the signature database answers (given a context to ask it in), or else flowR's table of the base packages. */
|
|
78
|
+
function statedOf(name, ctx) {
|
|
79
|
+
return (ctx === undefined ? undefined : (0, query_fn_props_1.fnEntry)(name, ctx).entry?.guards) ?? (0, built_in_guards_1.builtInGuards)(identifier_1.Identifier.getName(name), identifier_1.Identifier.getNamespace(name));
|
|
80
|
+
}
|
|
81
|
+
/** The contract of a function by name: what its closure checks as the base table or the signature database states it, or else what R checks of the function written in C. */
|
|
82
|
+
function ofFunction(name, scope) {
|
|
83
|
+
const key = identifier_1.Identifier.toString(name);
|
|
84
|
+
if (!scope.functions.has(key)) {
|
|
85
|
+
scope.functions.set(key, contractOfFunction(name, scope));
|
|
86
|
+
}
|
|
87
|
+
return scope.functions.get(key);
|
|
88
|
+
}
|
|
89
|
+
function contractOfFunction(name, scope) {
|
|
90
|
+
const { ctx, facts } = scope;
|
|
91
|
+
const [bare, namespace] = [identifier_1.Identifier.getName(name), identifier_1.Identifier.getNamespace(name)];
|
|
92
|
+
const formals = (0, query_fn_props_1.builtInLookup)(ctx)(name)?.sig?.map(([formal]) => formal) ?? (0, query_fn_props_1.fnEntry)(name, ctx).entry?.signature.map(p => p.name);
|
|
93
|
+
if (formals === undefined) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const stated = statedOf(name, ctx);
|
|
97
|
+
const version = ctx.rVersionKnown ? ctx.resolvedRVersion : undefined;
|
|
98
|
+
const ofC = namespace === undefined || (0, r_base_packages_1.isBaseRPackage)(namespace) ? (0, built_in_guards_1.builtInClauses)(bare, facts) : undefined;
|
|
99
|
+
const origin = stated?.origin;
|
|
100
|
+
let clauses = [];
|
|
101
|
+
if (stated !== undefined && origin !== undefined && origin.source !== 'builtin') {
|
|
102
|
+
clauses = origin.source === 'base-table' && version !== undefined && !sameRelease(origin.r, version) ? [] : statedClauses(bare, stated, formals, scope);
|
|
103
|
+
}
|
|
104
|
+
else if (ofC !== undefined) {
|
|
105
|
+
clauses = ofC.map(c => c.requires);
|
|
106
|
+
}
|
|
107
|
+
else if (stated !== undefined) {
|
|
108
|
+
clauses = statedClauses(bare, stated, formals, scope);
|
|
109
|
+
}
|
|
110
|
+
const required = stated?.required ?? [];
|
|
111
|
+
return clauses.length === 0 && required.length === 0 ? undefined : { formals, required, clauses, source: origin?.source ?? 'builtin', stated };
|
|
112
|
+
}
|
|
113
|
+
/** The contract inferred for a definition of the program, none once the program rewrites functions. */
|
|
114
|
+
function ofDefinition(definition, scope) {
|
|
115
|
+
if (scope.rewritesFormals) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (!scope.definitions.has(definition)) {
|
|
119
|
+
const node = scope.idMap.get(definition);
|
|
120
|
+
// eslint-disable-next-line flowr/use-instead -- FunctionSemantics exposes this module, so it cannot be imported here
|
|
121
|
+
const guards = r_function_definition_1.RFunctionDefinition.is(node) ? (0, function_guards_1.guardsOfFunctions)([definition], scope.graph, { ctx: scope.ctx })[definition] : undefined;
|
|
122
|
+
/* a definition that asks nothing of its calls has no contract to check them against */
|
|
123
|
+
scope.definitions.set(definition, guards === undefined || !r_function_definition_1.RFunctionDefinition.is(node) || (guards.clauses.length === 0 && guards.required.length === 0) ? undefined : {
|
|
124
|
+
formals: node.parameters.map(p => p.name.content),
|
|
125
|
+
required: guards.required,
|
|
126
|
+
clauses: guards.clauses.map(c => c.requires),
|
|
127
|
+
source: 'program',
|
|
128
|
+
definition,
|
|
129
|
+
guards
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return scope.definitions.get(definition);
|
|
133
|
+
}
|
|
134
|
+
/** The contract of what the call reaches: the one definition of the program it calls, or a function of R flowR knows the guards of. */
|
|
135
|
+
function ofCall(call, scope) {
|
|
136
|
+
const { graph } = scope;
|
|
137
|
+
const origins = df_helper_1.Dataflow.origin(graph, call) ?? [];
|
|
138
|
+
if (origins.length === 1 && origins[0].type === 3 /* OriginType.BuiltInFunctionOrigin */) {
|
|
139
|
+
return ofFunction(origins[0].fn.name, scope);
|
|
140
|
+
}
|
|
141
|
+
const definitions = df_helper_1.Dataflow.calleeDefinitionsOf(graph, call);
|
|
142
|
+
return definitions.length !== 1 || (0, function_guards_1.readsViaParameter)(origins, graph) || origins.some(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */) ? undefined : ofDefinition(definitions[0].info.id, scope);
|
|
143
|
+
}
|
|
144
|
+
/** The contract in the form the signature database stores and the browsers show, see {@link StatedGuards}. */
|
|
145
|
+
function stated(contract, idMap) {
|
|
146
|
+
return contract.stated ?? (contract.guards === undefined ? undefined : (0, stated_guards_1.statedGuardsOf)(contract.guards, idMap));
|
|
147
|
+
}
|
|
148
|
+
/** Whether what the expression holds may depend on a parameter of a function, which value resolution answers with what the calls flowR sees hand over, and not for every call. */
|
|
149
|
+
function readsParameter(node, scope) {
|
|
150
|
+
const seen = new Set();
|
|
151
|
+
const todo = [node];
|
|
152
|
+
for (let at = todo.pop(); at !== undefined; at = todo.pop()) {
|
|
153
|
+
if (seen.has(at.info.id)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
else if (seen.size >= MaxReads) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
seen.add(at.info.id);
|
|
160
|
+
if (r_symbol_1.RSymbol.is(at)) {
|
|
161
|
+
const sources = df_helper_1.Dataflow.valueSources(at.info.id, scope.graph);
|
|
162
|
+
if (sources === undefined || sources.some(s => (0, function_guards_1.isParameter)(s, scope.idMap))) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
todo.push(...sources.flatMap(s => s === at.info.id ? [] : [scope.idMap.get(s)].filter(n => n !== undefined)));
|
|
166
|
+
}
|
|
167
|
+
todo.push(...model_1.RNode.directChildren(at).filter(c => c !== r_function_call_1.EmptyArgument));
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
/** A number as literals of the types it may have, as the value domain does not tell `1` from `1L`. */
|
|
172
|
+
function numberLiterals(num, complex) {
|
|
173
|
+
if (complex || Number.isNaN(num)) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
else if (!Number.isFinite(num)) {
|
|
177
|
+
return [{ kind: 'constant', lexeme: num > 0 ? 'Inf' : '-Inf', value: num }];
|
|
178
|
+
}
|
|
179
|
+
const double = { kind: 'constant', lexeme: String(num), value: num };
|
|
180
|
+
return Number.isInteger(num) && Math.abs(num) <= 2147483647 ? [{ kind: 'constant', lexeme: `${num}L`, value: num }, double] : [double];
|
|
181
|
+
}
|
|
182
|
+
/** The literals a single value may be written as, `undefined` if it is none. */
|
|
183
|
+
function scalarLiterals(value) {
|
|
184
|
+
if (typeof value !== 'object' || value === null) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
switch (value.type) {
|
|
188
|
+
case 'string':
|
|
189
|
+
return (0, r_value_1.isValue)(value.value) ? [guard_term_1.GuardTerm.string(value.value.str)] : undefined;
|
|
190
|
+
case 'logical':
|
|
191
|
+
return typeof value.value === 'boolean' ? [value.value ? guard_term_1.GuardTerm.True : guard_term_1.GuardTerm.False] : undefined;
|
|
192
|
+
case 'number':
|
|
193
|
+
return (0, r_value_1.isValue)(value.value) ? numberLiterals(value.value.num, value.value.complexNumber) : undefined;
|
|
194
|
+
case 'interval': {
|
|
195
|
+
const [start, end] = [scalarLiterals(value.start), scalarLiterals(value.end)];
|
|
196
|
+
return value.startInclusive && value.endInclusive && start !== undefined && start[0]?.value === end?.[0]?.value ? start : undefined;
|
|
197
|
+
}
|
|
198
|
+
default:
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/** The terms a value may be written as without attributes: a literal, `NULL`, or a `c(...)` of literals of one type, `undefined` if it is none of those. */
|
|
203
|
+
function literalsOf(value) {
|
|
204
|
+
if (typeof value === 'object' && value !== null && value.type === 'null') {
|
|
205
|
+
return [{ kind: 'constant', lexeme: 'NULL' }];
|
|
206
|
+
}
|
|
207
|
+
else if (typeof value !== 'object' || value === null || value.type !== 'vector') {
|
|
208
|
+
return scalarLiterals(value);
|
|
209
|
+
}
|
|
210
|
+
else if (!Array.isArray(value.elements)) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
const elements = value.elements.map(scalarLiterals);
|
|
214
|
+
if (elements.length === 0) {
|
|
215
|
+
return [{ kind: 'constant', lexeme: 'NULL' }];
|
|
216
|
+
}
|
|
217
|
+
else if (elements.includes(undefined) || new Set(elements.map(e => e?.length)).size !== 1 || new Set(elements.map(e => typeof e?.[0].value)).size !== 1) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
/* the elements have one type: all integers or all doubles for numbers */
|
|
221
|
+
const variants = elements[0].map((_, at) => elements.map(e => e[at]));
|
|
222
|
+
return variants.map(v => guard_term_1.GuardTerm.known('c', ...v));
|
|
223
|
+
}
|
|
224
|
+
/** The literals the argument may hold, `undefined` if not all of them are known. */
|
|
225
|
+
function argumentLiterals(node, vertex, scope) {
|
|
226
|
+
if (readsParameter(node, scope)) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const values = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(node, { graph: scope.graph, environment: vertex.environment, ctx: scope.ctx }));
|
|
230
|
+
if (values?.type !== 'set' || values.elements.length === 0) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
const literals = values.elements.map(literalsOf);
|
|
234
|
+
return literals.includes(undefined) ? undefined : literals.flat();
|
|
235
|
+
}
|
|
236
|
+
/** Every way of choosing one of the literals per placeholder, `undefined` if there are too many. */
|
|
237
|
+
function combinations(choices) {
|
|
238
|
+
let result = [new Map()];
|
|
239
|
+
for (const [name, literals] of choices) {
|
|
240
|
+
result = result.flatMap(binding => literals.map(l => new Map([...binding, [name, l]])));
|
|
241
|
+
if (result.length > MaxCombinations) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return result;
|
|
246
|
+
}
|
|
247
|
+
/** The literals as R prints them, a number once, rather than as each of the types it may have. */
|
|
248
|
+
function shown(literals) {
|
|
249
|
+
const asDouble = (text) => text.replace(/(?<=[0-9])L\b/g, '');
|
|
250
|
+
return (0, arrays_1.uniqueArray)(literals.map(l => asDouble(guard_term_1.GuardTerm.render(l))));
|
|
251
|
+
}
|
|
252
|
+
/** What of the contract the call breaks for sure, each condition with the values it fails for. */
|
|
253
|
+
function breaches(call, contract, scope) {
|
|
254
|
+
const { graph, facts } = scope;
|
|
255
|
+
const vertex = graph.getVertex(call);
|
|
256
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
const given = match_args_1.MatchArgs.toSpec(vertex.args, Object.fromEntries(contract.formals.map(f => [f, f])));
|
|
260
|
+
const result = match_args_1.MatchArgs.handsOnDots(vertex.args, graph) ? [] : contract.required.filter(f => f !== '...' && (given.get(f)?.length ?? 0) === 0).map(formal => ({ kind: 'missing', formal }));
|
|
261
|
+
const args = new Map();
|
|
262
|
+
const binding = (0, function_guards_1.callBinding)(vertex, contract.formals, graph, node => {
|
|
263
|
+
const placeholder = `#${String(node.info.id)}`;
|
|
264
|
+
args.set(placeholder, { node });
|
|
265
|
+
return guard_term_1.GuardTerm.formal(placeholder);
|
|
266
|
+
});
|
|
267
|
+
const literalsAt = (placeholder) => {
|
|
268
|
+
const argument = args.get(placeholder);
|
|
269
|
+
if (argument !== undefined && argument.literals === undefined) {
|
|
270
|
+
/* what no value is known for is still given, so it is no longer missing */
|
|
271
|
+
argument.literals = argumentLiterals(argument.node, vertex, scope) ?? [{ kind: 'free', name: placeholder }];
|
|
272
|
+
}
|
|
273
|
+
return argument?.literals ?? [];
|
|
274
|
+
};
|
|
275
|
+
for (const clause of contract.clauses) {
|
|
276
|
+
const { requires } = (0, function_guards_1.atCall)(clause, binding, undefined, facts);
|
|
277
|
+
const placeholders = [...guard_term_1.GuardTerm.formalsOf(requires)];
|
|
278
|
+
const bindings = combinations(new Map(placeholders.map(p => [p, literalsAt(p)])));
|
|
279
|
+
if (bindings === undefined || !bindings.every(b => guard_term_1.GuardTerm.isFalse(guard_term_1.GuardTerm.substituteCondition(requires, b, undefined, facts)))) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const values = contract.formals.flatMap(formal => {
|
|
283
|
+
const bound = binding.binding.get(formal);
|
|
284
|
+
const literals = bound?.kind === 'formal' && placeholders.includes(bound.name) ? literalsAt(bound.name) : [];
|
|
285
|
+
const node = bound?.kind === 'formal' ? args.get(bound.name)?.node : undefined;
|
|
286
|
+
return literals.length === 0 ? [] : [[formal, model_1.RConstant.is(node) ? node.lexeme : shown(literals).join(' or ')]];
|
|
287
|
+
});
|
|
288
|
+
result.push({ kind: 'fails', condition: (0, guard_claims_1.readingOf)(clause, facts) ?? guard_term_1.GuardTerm.render(clause), values });
|
|
289
|
+
}
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
292
|
+
/** The breach in words, as `m >= 0 fails for m = -1`. */
|
|
293
|
+
function describe(breach) {
|
|
294
|
+
return breach.kind === 'missing' ? `${breach.formal} is not given` : `${breach.condition} fails for ${breach.values.map(([formal, value]) => `${formal} = ${value}`).join(', ')}`;
|
|
295
|
+
}
|
|
296
|
+
/** The contract the call reaches and what of it the call breaks for sure, `undefined` if flowR knows no contract of what it calls. */
|
|
297
|
+
function check(call, scope) {
|
|
298
|
+
const contract = ofCall(call, scope);
|
|
299
|
+
return contract === undefined ? undefined : { contract, breaches: breaches(call, contract, scope) };
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The one layer to ask what a function asks of its calls, its *contract*, and whether a call keeps it: stated by the signature database or
|
|
303
|
+
* flowR's tables for a function by name, or inferred from a definition of the program by the guards analysis, see {@link FunctionGuards}.
|
|
304
|
+
* The conditions of the guards of the callee are taken to the call as the guard analysis takes them to a caller, and a call only breaks
|
|
305
|
+
* a condition if it fails for every value the arguments may hold.
|
|
306
|
+
* @helper api
|
|
307
|
+
*/
|
|
308
|
+
exports.CallContracts = {
|
|
309
|
+
name: 'CallContracts',
|
|
310
|
+
/** The scope to ask for the contracts of one analyzed program in. */
|
|
311
|
+
of,
|
|
312
|
+
/** What is stated of a function by name, without a program. */
|
|
313
|
+
statedOf,
|
|
314
|
+
/** The contract of a function by name. */
|
|
315
|
+
ofFunction,
|
|
316
|
+
/** The contract inferred for a definition of the program. */
|
|
317
|
+
ofDefinition,
|
|
318
|
+
/** The contract of what a call reaches. */
|
|
319
|
+
ofCall,
|
|
320
|
+
/** The contract in the form the signature database stores and the browsers show. */
|
|
321
|
+
stated,
|
|
322
|
+
/** What of a contract a call breaks for sure. */
|
|
323
|
+
breaches,
|
|
324
|
+
/** The contract of what a call reaches and what of it the call breaks. */
|
|
325
|
+
check,
|
|
326
|
+
/** A breach in words. */
|
|
327
|
+
describe,
|
|
328
|
+
/** The replacement functions that rewrite a function, after which its contract no longer holds. */
|
|
329
|
+
FormalsRewriters
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=call-contracts.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The parts of `text` separated by `separator` outside of any parentheses, brackets, braces, or strings. */
|
|
2
|
+
export declare function splitTopLevel(this: void, text: string, separator: string): string[];
|
|
3
|
+
/**
|
|
4
|
+
* The condition with its grouping made explicit, so no reader has to know how `and`, `unless`, `||`, and `&&` bind:
|
|
5
|
+
* `a && b || c unless d && e` reads as `((a && b) || c) unless (d && e)`. A connective binds tighter the later it is in {@link Connectives},
|
|
6
|
+
* and a case `if (w): c` keeps its condition `w` and groups what holds then.
|
|
7
|
+
*/
|
|
8
|
+
export declare function grouped(this: void, text: string): string;
|
|
9
|
+
/** The conditions joined by `&&`, those that would mix with it in parentheses. */
|
|
10
|
+
export declare function allOf(this: void, conditions: readonly string[]): string;
|
|
11
|
+
/** The formals in groups of those that `links` tie together, each group in the order of `formals` and the groups by their first formal, so what depends on each other reads together. */
|
|
12
|
+
export declare function linkedGroups(this: void, formals: readonly string[], links: readonly (readonly string[])[]): string[][];
|
|
13
|
+
/**
|
|
14
|
+
* The relations with each comparison once: a comparison that holds unless `u1` and holds unless `u2` holds unless both do,
|
|
15
|
+
* written with what both offer said once, `c || (a1 && a2)` for `c || a1` and `c || a2`, and a comparison stated as well with its sides swapped is the same one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mergedRelations<T extends {
|
|
18
|
+
readonly holds: string;
|
|
19
|
+
readonly unless?: string;
|
|
20
|
+
}>(this: void, relations: readonly T[]): T[];
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* How a condition of a contract groups, without anything else of flowR, so the pages showing contracts can use it as well.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.splitTopLevel = splitTopLevel;
|
|
7
|
+
exports.grouped = grouped;
|
|
8
|
+
exports.allOf = allOf;
|
|
9
|
+
exports.linkedGroups = linkedGroups;
|
|
10
|
+
exports.mergedRelations = mergedRelations;
|
|
11
|
+
/** The parts of `text` separated by `separator` outside of any parentheses, brackets, braces, or strings. */
|
|
12
|
+
function splitTopLevel(text, separator) {
|
|
13
|
+
const parts = [];
|
|
14
|
+
let depth = 0, quote, start = 0;
|
|
15
|
+
for (let i = 0; i < text.length; i++) {
|
|
16
|
+
const c = text[i];
|
|
17
|
+
if (quote !== undefined) {
|
|
18
|
+
quote = c === '\\' ? (i++, quote) : c === quote ? undefined : quote;
|
|
19
|
+
}
|
|
20
|
+
else if (c === '"' || c === "'" || c === '`') {
|
|
21
|
+
quote = c;
|
|
22
|
+
}
|
|
23
|
+
else if ('([{'.includes(c)) {
|
|
24
|
+
depth++;
|
|
25
|
+
}
|
|
26
|
+
else if (')]}'.includes(c)) {
|
|
27
|
+
depth--;
|
|
28
|
+
}
|
|
29
|
+
else if (depth === 0 && text.startsWith(separator, i)) {
|
|
30
|
+
parts.push(text.slice(start, i));
|
|
31
|
+
start = i + separator.length;
|
|
32
|
+
i += separator.length - 1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return [...parts, text.slice(start)];
|
|
36
|
+
}
|
|
37
|
+
/** the connectives a condition is written with, from the one binding loosest */
|
|
38
|
+
const Connectives = [' and ', ' unless ', ' || ', ' && '];
|
|
39
|
+
/** `text`, in parentheses if it has a connective outside of any other than the one it is joined by, so the two never mix */
|
|
40
|
+
function enclosed(text, within) {
|
|
41
|
+
return Connectives.some(c => c !== within && splitTopLevel(text, c).length > 1) ? `(${text})` : text;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The condition with its grouping made explicit, so no reader has to know how `and`, `unless`, `||`, and `&&` bind:
|
|
45
|
+
* `a && b || c unless d && e` reads as `((a && b) || c) unless (d && e)`. A connective binds tighter the later it is in {@link Connectives},
|
|
46
|
+
* and a case `if (w): c` keeps its condition `w` and groups what holds then.
|
|
47
|
+
*/
|
|
48
|
+
function grouped(text) {
|
|
49
|
+
const [head, ...rest] = /^if \(/.test(text) ? splitTopLevel(text, ': ') : [text];
|
|
50
|
+
if (rest.length > 0) {
|
|
51
|
+
return `${head}: ${grouped(rest.join(': '))}`;
|
|
52
|
+
}
|
|
53
|
+
for (const connective of Connectives) {
|
|
54
|
+
const parts = splitTopLevel(text, connective);
|
|
55
|
+
if (parts.length > 1) {
|
|
56
|
+
return parts.map(part => enclosed(grouped(part), connective)).join(connective);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return text;
|
|
60
|
+
}
|
|
61
|
+
/** The conditions joined by `&&`, those that would mix with it in parentheses. */
|
|
62
|
+
function allOf(conditions) {
|
|
63
|
+
return conditions.map(c => enclosed(c, ' && ')).join(' && ');
|
|
64
|
+
}
|
|
65
|
+
/** The formals in groups of those that `links` tie together, each group in the order of `formals` and the groups by their first formal, so what depends on each other reads together. */
|
|
66
|
+
function linkedGroups(formals, links) {
|
|
67
|
+
const groupOf = new Map(formals.map(f => [f, new Set([f])]));
|
|
68
|
+
for (const link of links) {
|
|
69
|
+
const merged = new Set(link.filter(f => groupOf.has(f)).flatMap(f => [...groupOf.get(f) ?? []]));
|
|
70
|
+
merged.forEach(f => groupOf.set(f, merged));
|
|
71
|
+
}
|
|
72
|
+
return formals.filter((f, at) => formals.findIndex(g => groupOf.get(g) === groupOf.get(f)) === at).map(first => formals.filter(f => groupOf.get(first) === groupOf.get(f)));
|
|
73
|
+
}
|
|
74
|
+
/** the comparisons a relation is written with, each with the one that reads the same with its sides swapped */
|
|
75
|
+
const Mirrored = { ' == ': ' == ', ' != ': ' != ', ' <= ': ' >= ', ' >= ': ' <= ', ' < ': ' > ', ' > ': ' < ' };
|
|
76
|
+
/** `text` without parentheses around all of it */
|
|
77
|
+
function bare(text) {
|
|
78
|
+
if (!text.startsWith('(') || !text.endsWith(')')) {
|
|
79
|
+
return text;
|
|
80
|
+
}
|
|
81
|
+
let depth = 0, quote;
|
|
82
|
+
for (let i = 0; i < text.length - 1; i++) {
|
|
83
|
+
const c = text[i];
|
|
84
|
+
if (quote !== undefined) {
|
|
85
|
+
quote = c === '\\' ? (i++, quote) : c === quote ? undefined : quote;
|
|
86
|
+
}
|
|
87
|
+
else if (c === '"' || c === "'" || c === '`') {
|
|
88
|
+
quote = c;
|
|
89
|
+
}
|
|
90
|
+
else if (c === '(' || c === ')') {
|
|
91
|
+
depth += c === '(' ? 1 : -1;
|
|
92
|
+
if (depth === 0) {
|
|
93
|
+
return text;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return bare(text.slice(1, -1));
|
|
98
|
+
}
|
|
99
|
+
/** the same comparison for `a == b` and `b == a`, and for `a <= b` and `b >= a` */
|
|
100
|
+
function sameComparison(holds) {
|
|
101
|
+
for (const [op, mirror] of Object.entries(Mirrored)) {
|
|
102
|
+
const sides = splitTopLevel(holds, op);
|
|
103
|
+
if (sides.length === 2) {
|
|
104
|
+
return sides[0] <= sides[1] ? holds : sides[1] + mirror + sides[0];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return holds;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The relations with each comparison once: a comparison that holds unless `u1` and holds unless `u2` holds unless both do,
|
|
111
|
+
* written with what both offer said once, `c || (a1 && a2)` for `c || a1` and `c || a2`, and a comparison stated as well with its sides swapped is the same one.
|
|
112
|
+
*/
|
|
113
|
+
function mergedRelations(relations) {
|
|
114
|
+
const merged = new Map();
|
|
115
|
+
for (const relation of relations) {
|
|
116
|
+
const key = sameComparison(relation.holds);
|
|
117
|
+
const entry = merged.get(key) ?? { first: relation, unless: [] };
|
|
118
|
+
entry.unless.push(relation.unless === undefined || relation.unless === '' ? undefined : splitTopLevel(bare(relation.unless), ' || '));
|
|
119
|
+
merged.set(key, entry);
|
|
120
|
+
}
|
|
121
|
+
return [...merged.values()].map(({ first, unless }) => {
|
|
122
|
+
if (unless.length === 1) {
|
|
123
|
+
return first;
|
|
124
|
+
}
|
|
125
|
+
else if (unless.includes(undefined)) {
|
|
126
|
+
return { ...first, unless: undefined };
|
|
127
|
+
}
|
|
128
|
+
const offers = unless;
|
|
129
|
+
const common = offers[0].filter(d => offers.every(u => u.includes(d)));
|
|
130
|
+
const rests = offers.map(u => u.filter(d => !common.includes(d))).filter((rest, at, all) => all.findIndex(r => r.join() === rest.join()) === at);
|
|
131
|
+
const own = rests.some(r => r.length === 0) ? [] : [rests.length === 1 ? rests[0].join(' || ') : `(${allOf(rests.map(r => r.join(' || ')))})`];
|
|
132
|
+
return { ...first, unless: [...common, ...own].join(' || ') };
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=condition-grouping.js.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `FunctionSemantics` facade wires these together, so a sibling here has to call the backing function directly; going through `FunctionSemantics` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
|
|
3
|
+
* @lintIgnore use-instead
|
|
4
|
+
*/
|
|
5
|
+
import type { DataflowGraph } from '../../graph/graph';
|
|
6
|
+
import { type Origin } from '../../origin/dfg-get-origin';
|
|
7
|
+
import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
|
|
8
|
+
import { type ArgProps } from '../../environments/built-in-props';
|
|
9
|
+
import { type BrandedIdentifier } from '../../environments/identifier';
|
|
10
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
|
|
11
|
+
import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
12
|
+
import type { AstIdMap, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
13
|
+
import { GuardTerm, type GuardBinding, type GuardOuter } from './guard-term';
|
|
14
|
+
import type { GuardFactsLookup } from '../../environments/guard-facts';
|
|
15
|
+
import { type ClaimedRelation, type ConditionalClaim, type FormalClaim } from './guard-claims';
|
|
16
|
+
/** One condition every normal return of a function has passed; if it does not hold, the call fails. */
|
|
17
|
+
export interface GuardClause {
|
|
18
|
+
/** the condition, see {@link GuardTerm} */
|
|
19
|
+
readonly requires: GuardTerm;
|
|
20
|
+
/** the condition in R syntax */
|
|
21
|
+
readonly rendered: string;
|
|
22
|
+
/** what fails if the condition does not hold: a `stop`, a condition of a `stopifnot`, or the call that rejects its argument */
|
|
23
|
+
readonly at: NodeId;
|
|
24
|
+
/** `explicit` if the function checks this itself, or `implicit` if R fails on it, as `"a" + 1` does */
|
|
25
|
+
readonly kind: 'explicit' | 'implicit';
|
|
26
|
+
/** the failure comes before anything else the function does beyond computing a value, so nothing is left to undo */
|
|
27
|
+
readonly pure: boolean;
|
|
28
|
+
/** the calls this was inherited through, outermost first, if the condition is that of a function called */
|
|
29
|
+
readonly via?: readonly NodeId[];
|
|
30
|
+
/** what the failure says: the literal message of a `stop`, or what R typically says when it rejects a value */
|
|
31
|
+
readonly message?: string;
|
|
32
|
+
/** what held on the way to the condition, outermost first, which {@link FunctionGuards.requires} only has as alternatives */
|
|
33
|
+
readonly under?: readonly GuardTerm[];
|
|
34
|
+
}
|
|
35
|
+
/** What a function asks for of the calls it can return from, see {@link guardsOfFunctions}. */
|
|
36
|
+
export interface FunctionGuards {
|
|
37
|
+
/** every condition found */
|
|
38
|
+
readonly clauses: readonly GuardClause[];
|
|
39
|
+
/** per formal, what the conditions say about it */
|
|
40
|
+
readonly formals: Readonly<Record<BrandedIdentifier, FormalClaim>>;
|
|
41
|
+
/** what the conditions say of formals relative to each other, like `length(x) >= m` */
|
|
42
|
+
readonly relations: readonly ClaimedRelation[];
|
|
43
|
+
/** what the conditions say of a formal unless something else lets the call through */
|
|
44
|
+
readonly conditional: readonly ConditionalClaim[];
|
|
45
|
+
/** per formal, the conditions the function checks itself that read it (from `stopifnot`, `if` and `stop`, ...), in R syntax: what {@link FunctionGuards.formals} has no words for, like `x %% 2 == 0`, is here as well */
|
|
46
|
+
readonly conditions: Readonly<Record<BrandedIdentifier, readonly string[]>>;
|
|
47
|
+
/** the formals a call has to supply, as it fails otherwise */
|
|
48
|
+
readonly required: readonly BrandedIdentifier[];
|
|
49
|
+
/** all conditions in R syntax, an empty string if there are none */
|
|
50
|
+
readonly requires: string;
|
|
51
|
+
/** the conditions that fail before any side effect in R syntax, an empty string if there are none: the tightest precondition that guarantees a clean failure */
|
|
52
|
+
readonly pure: string;
|
|
53
|
+
/** what holds of the value a call returns normally, said as of a formal */
|
|
54
|
+
readonly returns?: FormalClaim;
|
|
55
|
+
/** the formal every normal return hands back unchanged */
|
|
56
|
+
readonly passes?: BrandedIdentifier;
|
|
57
|
+
}
|
|
58
|
+
/** What to ask for beyond the definitions, see {@link guardsOfFunctions}. */
|
|
59
|
+
export interface FunctionGuardsOptions {
|
|
60
|
+
/** how to ask what a built-in states, so a configured or overwritten one answers, in the R version analyzed for */
|
|
61
|
+
readonly ctx?: ReadOnlyFlowrAnalyzerContext;
|
|
62
|
+
}
|
|
63
|
+
/** Whether the id is that of a parameter of a function definition. */
|
|
64
|
+
export declare function isParameter(this: void, id: NodeId, idMap: AstIdMap): boolean;
|
|
65
|
+
/** Whether a read among the origins may hold what a parameter holds, which depends on the call, so the calls flowR sees say nothing about the others. */
|
|
66
|
+
export declare function readsViaParameter(this: void, origins: readonly Origin[], graph: DataflowGraph): boolean;
|
|
67
|
+
/** What the caller states the value of an argument as, `undefined` if it cannot. */
|
|
68
|
+
export type ArgumentTerm = (value: RNodeWithParent) => GuardTerm | undefined;
|
|
69
|
+
/** What the given arguments of the call bind the formals `names` of the callee to, seen from the caller, with whether that leaves no formal unbound. */
|
|
70
|
+
declare function bindingOfArguments(this: void, vertex: DataflowGraphVertexFunctionCall, args: DataflowGraphVertexFunctionCall['args'], names: readonly BrandedIdentifier[], graph: DataflowGraph, termOfArgument: ArgumentTerm): {
|
|
71
|
+
readonly binding: GuardBinding;
|
|
72
|
+
readonly complete: boolean;
|
|
73
|
+
};
|
|
74
|
+
/** What a call binds the formals of its callee to, see {@link callBinding}. */
|
|
75
|
+
export interface CallBinding {
|
|
76
|
+
/** what the formals stand for for sure */
|
|
77
|
+
readonly binding: GuardBinding;
|
|
78
|
+
/** if the call hands on dots, what they stand for if the dots name nothing */
|
|
79
|
+
readonly besides?: ReturnType<typeof bindingOfArguments>;
|
|
80
|
+
/** the call leaves the dots of the callee without a name */
|
|
81
|
+
readonly dotsUnnamed: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What the call binds the formals `names` of its callee to, by R's argument matching, the way the contract of a callee is inherited:
|
|
85
|
+
* `termOfArgument` states the value of an argument in the words of the caller.
|
|
86
|
+
*/
|
|
87
|
+
export declare function callBinding(this: void, vertex: DataflowGraphVertexFunctionCall, names: readonly BrandedIdentifier[], graph: DataflowGraph, termOfArgument: ArgumentTerm): CallBinding;
|
|
88
|
+
/**
|
|
89
|
+
* A condition of a callee in the words of a caller binding its formals by `call`, see {@link callBinding}, with `outer` stating what the callee reads from outside:
|
|
90
|
+
* `requires` holds for sure, and `unlessNamed`, if the call hands on dots, holds as long as they name nothing.
|
|
91
|
+
*/
|
|
92
|
+
export declare function atCall(this: void, condition: GuardTerm, call: CallBinding, outer: GuardOuter | undefined, facts: GuardFactsLookup): {
|
|
93
|
+
readonly requires: GuardTerm;
|
|
94
|
+
readonly unlessNamed?: GuardTerm;
|
|
95
|
+
};
|
|
96
|
+
/** The literal message a call like `stop("...")` raises. */
|
|
97
|
+
export declare function messageOf(this: void, node: RNodeWithParent | undefined): string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* What each of the `definitions` asks of the calls it returns from, a *necessary* condition: a call that returns normally
|
|
100
|
+
* has passed all of it, with the formals standing for the values they hold at the guard.
|
|
101
|
+
* Whatever flowR cannot state with certainty is left out rather than guessed, so it only ever claims too little.
|
|
102
|
+
* What is out of reach is what code flowR does not see does to the frame of the function (like `sys.function`-based writes), and an S3 method of `is.numeric` or `length` breaking their contract.
|
|
103
|
+
* @useInstead {@link FunctionSemantics.guards}
|
|
104
|
+
*/
|
|
105
|
+
export declare function guardsOfFunctions(this: void, definitions: readonly NodeId[], graph: DataflowGraph, options?: FunctionGuardsOptions): Record<NodeId, FunctionGuards>;
|
|
106
|
+
/** The clauses a function checks itself, per formal they read. */
|
|
107
|
+
export declare function conditionsPerFormal(this: void, clauses: readonly GuardClause[]): Record<BrandedIdentifier, string[]>;
|
|
108
|
+
/** All of the given clauses and those failing cleanly, in R syntax. */
|
|
109
|
+
export declare function summarizeClauses(this: void, clauses: readonly GuardClause[]): Pick<FunctionGuards, 'requires' | 'pure'>;
|
|
110
|
+
/** What the guards of each of the definitions add to the {@link ArgProp}s of its formals, keyed by the id of each formal's name. */
|
|
111
|
+
export declare function guardRoles(this: void, definitions: readonly NodeId[], graph: DataflowGraph, options?: FunctionGuardsOptions): Record<NodeId, Record<NodeId, ArgProps>>;
|
|
112
|
+
export {};
|