@eagleoutice/flowr 2.14.3 → 2.15.0
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 +76 -63
- package/abstract-interpretation/absint-inference.d.ts +347 -0
- package/abstract-interpretation/{absint-visitor.js → absint-inference.js} +327 -97
- package/abstract-interpretation/abstract-semantics.d.ts +246 -0
- package/abstract-interpretation/abstract-semantics.js +3 -0
- package/abstract-interpretation/data-frame/{mappers/arguments.d.ts → arguments.d.ts} +18 -16
- package/abstract-interpretation/data-frame/{mappers/arguments.js → arguments.js} +20 -21
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +52 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1656 -0
- package/abstract-interpretation/data-frame/resolve-args.js +4 -4
- package/abstract-interpretation/data-frame/semantics.d.ts +15 -21
- package/abstract-interpretation/data-frame/semantics.js +27 -29
- package/abstract-interpretation/data-frame/shape-inference.d.ts +28 -24
- package/abstract-interpretation/data-frame/shape-inference.js +14 -79
- package/abstract-interpretation/domains/interval-domain.d.ts +5 -1
- package/abstract-interpretation/domains/interval-domain.js +25 -33
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +6 -3
- package/abstract-interpretation/domains/multi-value-state-domain.js +24 -4
- package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -6
- package/abstract-interpretation/domains/partial-product-domain.js +26 -43
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -6
- package/abstract-interpretation/domains/positive-interval-domain.js +3 -29
- package/abstract-interpretation/domains/product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.d.ts +6 -0
- package/abstract-interpretation/domains/set-range-domain.js +29 -62
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +9 -2
- package/abstract-interpretation/domains/state-abstract-domain.js +26 -37
- package/abstract-interpretation/domains/{state-domain-like.d.ts → state-domain.d.ts} +10 -6
- package/abstract-interpretation/domains/{state-domain-like.js → state-domain.js} +1 -1
- package/abstract-interpretation/value-semantics.d.ts +113 -0
- package/abstract-interpretation/value-semantics.js +115 -0
- package/benchmark/slicer.js +12 -6
- package/benchmark/stats/feature-counts.d.ts +2 -1
- package/benchmark/stats/feature-counts.js +25 -1
- package/benchmark/stats/stats.d.ts +4 -0
- package/benchmark/summarizer/second-phase/graph.js +7 -0
- package/cli/repl/commands/repl-parse.js +11 -22
- package/cli/repl/parser/slice-query-parser.d.ts +2 -0
- package/cli/repl/parser/slice-query-parser.js +1 -0
- package/config.d.ts +30 -205
- package/config.js +37 -3
- package/control-flow/cfg-properties.d.ts +5 -0
- package/control-flow/cfg-properties.js +25 -7
- package/control-flow/control-flow-graph.d.ts +11 -37
- package/control-flow/control-flow-graph.js +33 -77
- package/control-flow/semantic-cfg-guided-visitor.d.ts +63 -320
- package/control-flow/semantic-cfg-guided-visitor.js +65 -320
- package/dataflow/environments/built-in-config.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.d.ts +4 -0
- package/dataflow/environments/built-in-proc-name.js +4 -0
- package/dataflow/environments/built-in-props.d.ts +192 -82
- package/dataflow/environments/built-in-props.js +336 -106
- package/dataflow/environments/built-in.d.ts +21 -9
- package/dataflow/environments/built-in.js +43 -12
- package/dataflow/environments/default-builtin-config.d.ts +3219 -328
- package/dataflow/environments/default-builtin-config.js +804 -1031
- package/dataflow/environments/environment.d.ts +26 -49
- package/dataflow/environments/environment.js +34 -47
- package/dataflow/environments/group-generics.d.ts +36 -0
- package/dataflow/environments/group-generics.js +58 -0
- package/dataflow/environments/identifier.d.ts +106 -6
- package/dataflow/environments/identifier.js +19 -1
- package/dataflow/environments/query-fn-props.d.ts +16 -8
- package/dataflow/environments/query-fn-props.js +45 -21
- package/dataflow/environments/resolve-by-name.js +9 -2
- package/dataflow/environments/scoping.d.ts +5 -0
- package/dataflow/environments/scoping.js +11 -0
- package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
- package/dataflow/eval/resolve/alias-tracking.js +20 -2
- package/dataflow/eval/resolve/resolve-numbers.d.ts +182 -7
- package/dataflow/eval/resolve/resolve-numbers.js +44 -9
- package/dataflow/eval/resolve/resolve-strings.d.ts +79 -2
- package/dataflow/eval/resolve/resolve-strings.js +16 -7
- package/dataflow/eval/resolve/resolve.d.ts +5 -22
- package/dataflow/eval/resolve/resolve.js +24 -34
- package/dataflow/eval/values/general.d.ts +7 -1
- package/dataflow/eval/values/general.js +17 -3
- package/dataflow/eval/values/string/string-constants.d.ts +16 -15
- package/dataflow/eval/values/string/string-constants.js +59 -27
- package/dataflow/extractor.d.ts +2 -1
- package/dataflow/extractor.js +16 -4
- package/dataflow/fn/argument-roles.d.ts +35 -0
- package/dataflow/fn/argument-roles.js +252 -0
- package/dataflow/fn/class-declaration.d.ts +148 -0
- package/dataflow/fn/class-declaration.js +317 -0
- package/dataflow/fn/condition-handlers.d.ts +5 -0
- package/dataflow/fn/condition-handlers.js +13 -0
- package/dataflow/fn/exceptions-of-function.d.ts +21 -7
- package/dataflow/fn/exceptions-of-function.js +74 -43
- package/dataflow/fn/frame-reflection.d.ts +46 -0
- package/dataflow/fn/frame-reflection.js +169 -0
- package/dataflow/fn/function-props.d.ts +32 -0
- package/dataflow/fn/function-props.js +160 -0
- package/dataflow/fn/higher-order-function.d.ts +23 -5
- package/dataflow/fn/higher-order-function.js +64 -18
- package/dataflow/fn/strict-function.d.ts +24 -2
- package/dataflow/fn/strict-function.js +49 -19
- package/dataflow/graph/call-graph.js +10 -2
- package/dataflow/graph/df-helper.d.ts +1 -12
- package/dataflow/graph/df-helper.js +2 -19
- package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
- package/dataflow/graph/diff-dataflow-graph.js +2 -2
- package/dataflow/graph/graph.d.ts +39 -188
- package/dataflow/graph/graph.js +46 -163
- package/dataflow/graph/match-args.d.ts +34 -2
- package/dataflow/graph/match-args.js +45 -12
- package/dataflow/graph/vertex.d.ts +8 -0
- package/dataflow/info.d.ts +7 -5
- package/dataflow/info.js +1 -5
- package/dataflow/internal/control-flow.js +20 -17
- package/dataflow/internal/linker.d.ts +8 -37
- package/dataflow/internal/linker.js +22 -55
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +8 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +43 -50
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.d.ts +23 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.js +24 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +0 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +73 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +131 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +17 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +187 -99
- package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +0 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +31 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +101 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +23 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +22 -1
- package/dataflow/internal/process/functions/call/common.d.ts +4 -6
- package/dataflow/internal/process/functions/call/common.js +2 -2
- package/dataflow/internal/process/functions/call/deferred.d.ts +1 -1
- package/dataflow/internal/process/functions/call/deferred.js +2 -2
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +5 -3
- package/dataflow/internal/process/functions/call/known-call-handling.js +6 -4
- package/dataflow/internal/process/functions/call/named-call-handling.js +19 -13
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -2
- package/dataflow/internal/process/functions/call/quoted.js +144 -28
- package/dataflow/origin/dfg-get-origin.js +23 -10
- package/dataflow/processor.d.ts +2 -1
- package/dataflow/processor.js +6 -0
- package/documentation/data/interface/doc-writing-code.js +2 -0
- package/documentation/doc-util/doc-search.js +1 -1
- package/documentation/wiki-absint.d.ts +11 -14
- package/documentation/wiki-absint.js +73 -59
- package/documentation/wiki-core.js +64 -24
- package/documentation/wiki-linter.js +1 -0
- package/documentation/wiki-query.js +82 -264
- package/documentation/wiki-signature-database.js +23 -6
- package/gas.d.ts +91 -47
- package/gas.js +97 -13
- package/index.d.ts +31 -0
- package/index.js +52 -0
- package/linter/linter-rules.d.ts +87 -23
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.d.ts +1 -1
- package/linter/rules/dataframe-access-validation.js +10 -8
- package/linter/rules/dead-code.d.ts +1 -1
- package/linter/rules/deprecated-functions.js +14 -5
- package/linter/rules/file-path-validity.d.ts +1 -1
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -2
- package/linter/rules/network-functions.d.ts +10 -5
- package/linter/rules/network-functions.js +48 -36
- package/linter/rules/no-leaked-credentials.d.ts +1 -1
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +1 -1
- package/linter/rules/seeded-randomness.d.ts +3 -2
- package/linter/rules/seeded-randomness.js +7 -3
- package/linter/rules/software-has-license.d.ts +1 -1
- package/linter/rules/software-has-tests.d.ts +1 -1
- package/linter/rules/stop-with-call-arg.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +1 -1
- package/linter/rules/unclosed-connection.d.ts +3 -3
- package/linter/rules/unclosed-connection.js +3 -4
- package/linter/rules/undefined-symbol.d.ts +1 -1
- package/linter/rules/unescaped-arguments.d.ts +161 -0
- package/linter/rules/unescaped-arguments.js +293 -0
- package/linter/rules/unused-definition.d.ts +1 -1
- package/linter/rules/unused-definition.js +51 -6
- package/linter/rules/unused-import.d.ts +1 -1
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +3 -198
- package/project/context/flowr-analyzer-environment-context.d.ts +12 -1
- package/project/context/flowr-analyzer-environment-context.js +33 -1
- package/project/context/flowr-analyzer-files-context.d.ts +24 -1
- package/project/context/flowr-analyzer-files-context.js +42 -21
- package/project/context/flowr-analyzer-functions-context.d.ts +8 -0
- package/project/context/flowr-analyzer-functions-context.js +2 -0
- package/project/context/flowr-analyzer-gas-context.d.ts +9 -1
- package/project/context/flowr-analyzer-gas-context.js +21 -0
- package/project/context/flowr-file.d.ts +16 -1
- package/project/context/flowr-file.js +26 -2
- package/project/plugins/file-plugins/files/flowr-description-file.d.ts +19 -20
- package/project/plugins/file-plugins/files/flowr-description-file.js +55 -41
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +9 -4
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +11 -3
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +6 -9
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +5 -21
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +11 -12
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +48 -61
- package/project/plugins/file-plugins/files/flowr-news-file.d.ts +3 -12
- package/project/plugins/file-plugins/files/flowr-news-file.js +2 -19
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +145 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +676 -0
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +122 -422
- package/project/plugins/file-plugins/files/flowr-rda-file.js +517 -1005
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +8 -2
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -1
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +7 -2
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +9 -1
- package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +17 -0
- package/project/plugins/file-plugins/files/flowr-sysdata-file.js +40 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -0
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -1
- package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.d.ts +58 -0
- package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.js +95 -0
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +23 -0
- package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +33 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +33 -72
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +17 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +20 -37
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +29 -53
- package/project/plugins/package-version-plugins/package.js +2 -1
- package/project/plugins/plugin-registry.d.ts +3 -1
- package/project/plugins/plugin-registry.js +11 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +20 -4
- package/project/sigdb/build.d.ts +9 -15
- package/project/sigdb/build.js +63 -42
- package/project/sigdb/decode.d.ts +10 -4
- package/project/sigdb/decode.js +60 -21
- package/project/sigdb/memory-source.d.ts +4 -0
- package/project/sigdb/memory-source.js +8 -0
- package/project/sigdb/reader.d.ts +50 -100
- package/project/sigdb/reader.js +84 -105
- package/project/sigdb/schema.d.ts +102 -26
- package/project/sigdb/schema.js +14 -6
- package/project/sigdb/signature-db.d.ts +4 -0
- package/project/sigdb/signature-db.js +8 -1
- package/queries/base-query-format.d.ts +7 -0
- package/queries/base-query-format.js +29 -0
- package/queries/catalog/absint-query/absint-query-executor.js +8 -6
- package/queries/catalog/absint-query/absint-query-format.d.ts +20 -9
- package/queries/catalog/absint-query/absint-query-format.js +32 -19
- package/queries/catalog/call-context-query/call-context-query-executor.js +3 -3
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +14 -4
- package/queries/catalog/dependencies-query/function-info/read-functions.js +7 -121
- package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +1 -1
- package/queries/catalog/dependencies-query/function-info/statistics-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +4 -46
- package/queries/catalog/dependencies-query/function-info/write-functions.js +3 -76
- package/queries/catalog/dependencies-query/implicit-echo.js +2 -2
- package/queries/catalog/dependencies-query/link-devices.d.ts +2 -2
- package/queries/catalog/dependencies-query/link-devices.js +6 -7
- package/queries/catalog/dice-query/dice-query-executor.js +1 -1
- package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-executor.js +4 -0
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -1
- package/queries/catalog/files-query/files-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-source-functions.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -17
- package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -27
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +3 -8
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -11
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +4 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +60 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +35 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +63 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -6
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +3 -8
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -11
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +3 -8
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -12
- package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +3 -8
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -14
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/signature-query/signature-query-executor.d.ts +9 -9
- package/queries/catalog/signature-query/signature-query-executor.js +104 -95
- package/queries/catalog/signature-query/signature-query-format.d.ts +34 -8
- package/queries/catalog/signature-query/signature-query-format.js +16 -4
- package/queries/catalog/signature-query/signature-query-render.js +24 -4
- package/queries/catalog/slice-query-options.d.ts +14 -0
- package/queries/catalog/slice-query-options.js +15 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -3
- package/queries/catalog/static-slice-query/static-slice-query-format.js +7 -5
- package/queries/query-function-filter.d.ts +8 -3
- package/queries/query-function-filter.js +16 -6
- package/queries/query.d.ts +38 -38
- package/queries/query.js +30 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +5 -0
- package/r-bridge/lang-4.x/ast/model/model.js +14 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +17 -9
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +35 -27
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +33 -22
- package/reconstruct/reconstruct.d.ts +9 -20
- package/reconstruct/reconstruct.js +66 -28
- package/search/flowr-search-filters.d.ts +7 -6
- package/search/flowr-search-filters.js +6 -4
- package/search/search-executor/search-enrichers.d.ts +10 -10
- package/search/search-executor/search-enrichers.js +32 -3
- package/search/search-executor/search-transformer.js +15 -23
- package/slicing/criterion/parse.js +2 -12
- package/slicing/static/slice-call.js +1 -8
- package/slicing/static/static-slicer.js +1 -1
- package/util/collections/bimap.js +14 -6
- package/util/objects.js +16 -17
- package/util/r-value.d.ts +5 -4
- package/util/record.d.ts +38 -3
- package/util/record.js +48 -1
- package/util/simple-df/dfg-ascii.js +1 -1
- package/util/text/name-rank.js +8 -2
- package/util/text/strings.d.ts +5 -0
- package/util/text/strings.js +10 -0
- package/util/version.js +2 -2
- package/abstract-interpretation/absint-visitor.d.ts +0 -223
- package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +0 -19
- package/abstract-interpretation/data-frame/mappers/access-mapper.js +0 -151
- package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +0 -287
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +0 -1096
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +0 -15
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +0 -207
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +0 -6
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +0 -25
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +0 -31
- package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +0 -56
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FrameReflection = void 0;
|
|
4
|
+
exports.edgeTargets = edgeTargets;
|
|
5
|
+
exports.callsIn = callsIn;
|
|
6
|
+
exports.propagateToFixpoint = propagateToFixpoint;
|
|
7
|
+
exports.reflectiveRoles = reflectiveRoles;
|
|
8
|
+
const graph_1 = require("../graph/graph");
|
|
9
|
+
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
10
|
+
const edge_1 = require("../graph/edge");
|
|
11
|
+
const vertex_1 = require("../graph/vertex");
|
|
12
|
+
const built_in_props_1 = require("../environments/built-in-props");
|
|
13
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
14
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
15
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
16
|
+
/** The nodes at the far end of `node`'s outgoing edges of any of `types`, shared by every walk here and in the sibling analyses that follow specific edge kinds. */
|
|
17
|
+
function edgeTargets(graph, node, types) {
|
|
18
|
+
return [...graph.outgoingEdges(node) ?? graph_1.NoEdges].filter(([, edge]) => edge_1.DfEdge.includesType(edge, types)).map(([target]) => target);
|
|
19
|
+
}
|
|
20
|
+
/** The calls a definition's body reaches, id and vertex paired; shared by every walk here and in the sibling analyses that visit them all. */
|
|
21
|
+
function* callsIn(definition, graph) {
|
|
22
|
+
for (const node of definition.subflow.graph) {
|
|
23
|
+
const vertex = graph.getVertex(node);
|
|
24
|
+
if (vertex_1.FunctionCallVertex.is(vertex)) {
|
|
25
|
+
yield [node, vertex];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Recomputes `recompute(id)` for every node reachable from `seed` along the reverse of `successors`, so a
|
|
31
|
+
* change at a node is carried on to whatever points at it, until nothing grows anymore. `recompute` updates
|
|
32
|
+
* its node's value itself and reports whether it grew; shared by {@link propagateOverCalls} and
|
|
33
|
+
* {@link calculateExceptionsOfFunction}, which differ only in what "grew" means for the value they carry, and
|
|
34
|
+
* by {@link carriersOf} below, which grows a set rather than a bitfield.
|
|
35
|
+
*/
|
|
36
|
+
function propagateToFixpoint(seed, successors, recompute) {
|
|
37
|
+
const callers = new defaultmap_1.DefaultMap(() => []);
|
|
38
|
+
for (const [id, next] of successors) {
|
|
39
|
+
for (const to of next) {
|
|
40
|
+
callers.get(to).push(id);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const pending = [...seed];
|
|
44
|
+
const queued = new Set(pending);
|
|
45
|
+
while (pending.length > 0) {
|
|
46
|
+
const id = pending.pop();
|
|
47
|
+
queued.delete(id);
|
|
48
|
+
if (!recompute(id)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
for (const caller of callers.get(id)) {
|
|
52
|
+
if (!queued.has(caller)) {
|
|
53
|
+
queued.add(caller);
|
|
54
|
+
pending.push(caller);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* What `definition`'s body reaches about its own formals through the frame or call it sits in, as the
|
|
61
|
+
* {@link BuiltInFnInfo#frame} bits of the reflective calls it makes (`0` for none). `get("x", envir = e)` and
|
|
62
|
+
* `e$x` are followed to the name directly; `as.list(environment())` and a frame handed elsewhere mean any formal.
|
|
63
|
+
* @useInstead {@link FrameReflection.of}
|
|
64
|
+
*/
|
|
65
|
+
function reflectiveRolesOf(definition, graph, { known }) {
|
|
66
|
+
let roles = 0;
|
|
67
|
+
for (const [node, vertex] of callsIn(definition, graph)) {
|
|
68
|
+
const frame = known(vertex.name)?.frame ?? 0;
|
|
69
|
+
if (frame === 0 || (roles & frame) === frame || handedAnotherFrame(vertex, known)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!resolvedThroughout(node, definition, graph)) {
|
|
73
|
+
roles |= frame;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return roles;
|
|
77
|
+
}
|
|
78
|
+
/** What a function's body reaches about its own formals through reflection, rather than a direct read. */
|
|
79
|
+
exports.FrameReflection = {
|
|
80
|
+
name: 'FrameReflection',
|
|
81
|
+
/** The reflective {@link ArgProp} bits of one definition; see {@link reflectiveRolesOf}. */
|
|
82
|
+
of: reflectiveRolesOf
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* What `definition`'s body reaches about its own formals through the frame or call it sits in, as the
|
|
86
|
+
* {@link BuiltInFnInfo#frame} bits of the reflective calls it makes (`0` for none). `get("x", envir = e)` and
|
|
87
|
+
* `e$x` are followed to the name directly; `as.list(environment())` and a frame handed elsewhere mean any formal.
|
|
88
|
+
* @deprecated use {@link FrameReflection.of} instead
|
|
89
|
+
*/
|
|
90
|
+
function reflectiveRoles(definition, graph, known) {
|
|
91
|
+
return exports.FrameReflection.of(definition, graph, { known });
|
|
92
|
+
}
|
|
93
|
+
/** Whether the call was handed the frame to look at ({@link ArgProp.Handle}, as in `environment(g)`). */
|
|
94
|
+
function handedAnotherFrame(vertex, known) {
|
|
95
|
+
const sig = known(vertex.name)?.sig;
|
|
96
|
+
return sig !== undefined && built_in_props_1.FnSig.posWith(built_in_props_1.FnSig.layout(sig), vertex.args.length, built_in_props_1.ArgProp.Handle).length > 0;
|
|
97
|
+
}
|
|
98
|
+
/** Whether every consumer of what the reflective call at `frame` handed out resolves to a formal, and there is at least one. */
|
|
99
|
+
function resolvedThroughout(frame, definition, graph) {
|
|
100
|
+
const formals = new Set(Object.keys(definition.params).map(node_id_1.NodeId.normalize));
|
|
101
|
+
const carrying = carriersOf(frame, definition, graph);
|
|
102
|
+
let consumers = 0;
|
|
103
|
+
for (const node of definition.subflow.graph) {
|
|
104
|
+
const vertex = graph.getVertex(node);
|
|
105
|
+
if (!vertex_1.FunctionCallVertex.is(vertex) || carrying.has(node) || !consumes(vertex, carrying)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
consumers++;
|
|
109
|
+
if (!resolvedToAFormal(vertex, formals, graph)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return consumers > 0;
|
|
114
|
+
}
|
|
115
|
+
/** Every edge kind that carries a value on to whoever reads it next, for {@link carriersOf}. */
|
|
116
|
+
const CarryingEdges = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Returns | edge_1.EdgeType.Argument;
|
|
117
|
+
/** The nodes carrying what the reflective call handed out: the call itself, the names stored under it, and reads of them. */
|
|
118
|
+
function carriersOf(frame, definition, graph) {
|
|
119
|
+
const carrying = new Set([frame]);
|
|
120
|
+
const successors = new Map();
|
|
121
|
+
for (const node of definition.subflow.graph) {
|
|
122
|
+
const vertex = graph.getVertex(node);
|
|
123
|
+
/* a call reading the frame is what uses it, so it is a consumer rather than another name for it, and carries nothing on */
|
|
124
|
+
successors.set(node, vertex_1.FunctionCallVertex.is(vertex) && !passesOn(vertex) ? [] : edgeTargets(graph, node, CarryingEdges));
|
|
125
|
+
}
|
|
126
|
+
propagateToFixpoint(successors.keys(), successors, id => {
|
|
127
|
+
if (carrying.has(id) || !(successors.get(id) ?? []).some(to => carrying.has(to))) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
carrying.add(id);
|
|
131
|
+
return true;
|
|
132
|
+
});
|
|
133
|
+
return carrying;
|
|
134
|
+
}
|
|
135
|
+
/** Whether the call hands what it was given straight on: storing a frame under a name is no use of it. */
|
|
136
|
+
function passesOn(vertex) {
|
|
137
|
+
return vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Assignment) || vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.ExpressionList);
|
|
138
|
+
}
|
|
139
|
+
/** Whether one of the call's arguments is the value the reflective call handed out. */
|
|
140
|
+
function consumes(vertex, carrying) {
|
|
141
|
+
return argumentsOf(vertex).some(id => carrying.has(id));
|
|
142
|
+
}
|
|
143
|
+
/** The nodes a call was handed, whatever way the arguments were written. */
|
|
144
|
+
function argumentsOf(vertex) {
|
|
145
|
+
const ids = [];
|
|
146
|
+
for (const argument of vertex.args) {
|
|
147
|
+
if (typeof argument === 'object' && 'nodeId' in argument) {
|
|
148
|
+
ids.push(argument.nodeId);
|
|
149
|
+
if (graph_1.FunctionArgument.isNamed(argument) && argument.valueId !== undefined) {
|
|
150
|
+
ids.push(argument.valueId);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return ids;
|
|
155
|
+
}
|
|
156
|
+
/** Whether the access reads a formal directly, or via the constant naming it (`get("x", ...)`); a computed name (`get(nm, ...)`) does not. */
|
|
157
|
+
function resolvedToAFormal(vertex, formals, graph) {
|
|
158
|
+
const idMap = graph.idMap;
|
|
159
|
+
for (const node of [vertex.id, ...argumentsOf(vertex)]) {
|
|
160
|
+
if (node !== vertex.id && !model_1.RConstant.is(idMap?.get(node))) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (edgeTargets(graph, node, edge_1.EdgeType.Reads).some(to => formals.has(to))) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=frame-reflection.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DataflowGraph } from '../graph/graph';
|
|
2
|
+
import type { StatedProps } from '../environments/built-in-props';
|
|
3
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
|
+
import { type ArgumentRolesOptions, type FunctionArgumentRoles } from './argument-roles';
|
|
5
|
+
import { propagateToFixpoint } from './frame-reflection';
|
|
6
|
+
/** @see {@link propagateToFixpoint}, re-exported from where it lives so nothing importing it from here needs to change. */
|
|
7
|
+
export { propagateToFixpoint };
|
|
8
|
+
/** What flowR infers about a set of definitions, see {@link FunctionProps.of}. */
|
|
9
|
+
export interface InferredFunctions {
|
|
10
|
+
/** per definition, what its body states about the function itself */
|
|
11
|
+
readonly props: Record<NodeId, StatedProps>;
|
|
12
|
+
/** per definition, the {@link ArgProp} mask of each formal that carries one */
|
|
13
|
+
readonly roles: Record<NodeId, FunctionArgumentRoles>;
|
|
14
|
+
}
|
|
15
|
+
/** What to ask for beyond the definitions themselves, see {@link FunctionProps.of}. */
|
|
16
|
+
export interface FunctionPropsOptions extends ArgumentRolesOptions {
|
|
17
|
+
/** infer only what the formals do, or only what the function does; both when left out */
|
|
18
|
+
readonly only?: 'arguments' | 'function';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* What each of the `definitions` does, stated the way a built-in states it: {@link CallProp} bits for the
|
|
22
|
+
* function ({@link PropagatedProps} bits its callees carry over included) and {@link ArgProp} bits per formal,
|
|
23
|
+
* `Forced`/`Lazy` included. An unset bit reads as "nothing says so", never as "no".
|
|
24
|
+
* @useInstead {@link FunctionProps.of}
|
|
25
|
+
*/
|
|
26
|
+
declare function inferFunctions(this: void, definitions: readonly NodeId[], graph: DataflowGraph, options?: FunctionPropsOptions): InferredFunctions;
|
|
27
|
+
/** What the functions of a program do, inferred from what their bodies show. */
|
|
28
|
+
export declare const FunctionProps: {
|
|
29
|
+
readonly name: "FunctionProps";
|
|
30
|
+
/** What several definitions and their formals do; see {@link inferFunctions}. */
|
|
31
|
+
readonly of: typeof inferFunctions;
|
|
32
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FunctionProps = exports.propagateToFixpoint = void 0;
|
|
4
|
+
const edge_1 = require("../graph/edge");
|
|
5
|
+
const vertex_1 = require("../graph/vertex");
|
|
6
|
+
const built_in_props_1 = require("../environments/built-in-props");
|
|
7
|
+
const query_fn_props_1 = require("../environments/query-fn-props");
|
|
8
|
+
const identifier_1 = require("../environments/identifier");
|
|
9
|
+
const info_1 = require("../info");
|
|
10
|
+
const strict_function_1 = require("./strict-function");
|
|
11
|
+
const argument_roles_1 = require("./argument-roles");
|
|
12
|
+
const frame_reflection_1 = require("./frame-reflection");
|
|
13
|
+
Object.defineProperty(exports, "propagateToFixpoint", { enumerable: true, get: function () { return frame_reflection_1.propagateToFixpoint; } });
|
|
14
|
+
const logic_1 = require("../../util/logic");
|
|
15
|
+
/**
|
|
16
|
+
* What each of the `definitions` does, stated the way a built-in states it: {@link CallProp} bits for the
|
|
17
|
+
* function ({@link PropagatedProps} bits its callees carry over included) and {@link ArgProp} bits per formal,
|
|
18
|
+
* `Forced`/`Lazy` included. An unset bit reads as "nothing says so", never as "no".
|
|
19
|
+
* @useInstead {@link FunctionProps.of}
|
|
20
|
+
*/
|
|
21
|
+
function inferFunctions(definitions, graph, options = {}) {
|
|
22
|
+
const { ctx, only } = options;
|
|
23
|
+
const strict = strict_function_1.FunctionStrictnesses.of(definitions, graph, { ctx });
|
|
24
|
+
return {
|
|
25
|
+
props: only === 'arguments' ? {} : callProps(definitions, graph, strict, ctx),
|
|
26
|
+
roles: only === 'function' ? {} : argumentProps(definitions, graph, strict, options)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The {@link CallProp} mask of each definition, `Strict` included and what its callees carry mixed in. */
|
|
30
|
+
function callProps(definitions, graph, strict, ctx) {
|
|
31
|
+
const state = makeState(graph, ctx);
|
|
32
|
+
const props = new Map();
|
|
33
|
+
const callees = new Map();
|
|
34
|
+
/* a callee is asked about as well, whether or not it is one of the definitions to answer for */
|
|
35
|
+
const toVisit = [...definitions];
|
|
36
|
+
while (toVisit.length > 0) {
|
|
37
|
+
const id = toVisit.pop();
|
|
38
|
+
if (props.has(id)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const own = propsOf(id, state);
|
|
42
|
+
props.set(id, strict[id]?.strict === logic_1.Ternary.Always ? built_in_props_1.CallProps.join(own.stated, { props: built_in_props_1.CallProp.Strict }) : own.stated);
|
|
43
|
+
callees.set(id, own.callees);
|
|
44
|
+
toVisit.push(...own.callees);
|
|
45
|
+
}
|
|
46
|
+
propagateOverCalls(props, callees);
|
|
47
|
+
const all = {};
|
|
48
|
+
for (const id of definitions) {
|
|
49
|
+
const found = props.get(id);
|
|
50
|
+
if (built_in_props_1.CallProps.hasAny(found)) {
|
|
51
|
+
all[id] = found;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return all;
|
|
55
|
+
}
|
|
56
|
+
/** Hands {@link PropagatedProps} on to callers until nothing changes, so a chain of calls carries them however long it is. */
|
|
57
|
+
function propagateOverCalls(props, callees) {
|
|
58
|
+
(0, frame_reflection_1.propagateToFixpoint)(callees.keys(), callees, id => {
|
|
59
|
+
const before = props.get(id);
|
|
60
|
+
let grown = before ?? {};
|
|
61
|
+
for (const callee of callees.get(id) ?? []) {
|
|
62
|
+
grown = built_in_props_1.CallProps.join(grown, built_in_props_1.CallProps.filter(props.get(callee), built_in_props_1.PropagatedProps));
|
|
63
|
+
}
|
|
64
|
+
/* joining only ever adds, so nothing new means the same bits and the same number of tags */
|
|
65
|
+
if ((grown.props ?? 0) === (before?.props ?? 0) && (grown.tags?.length ?? 0) === (before?.tags?.length ?? 0)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
props.set(id, grown);
|
|
69
|
+
return true;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** The {@link ArgProp} mask of each formal, `Forced`/`Lazy` included. */
|
|
73
|
+
function argumentProps(definitions, graph, strict, options) {
|
|
74
|
+
const all = { ...argument_roles_1.ArgumentRoles.of(definitions, graph, options) };
|
|
75
|
+
for (const [id, { parameters }] of Object.entries(strict)) {
|
|
76
|
+
const roles = { ...all[id] };
|
|
77
|
+
for (const [formal, forced] of Object.entries(parameters)) {
|
|
78
|
+
const bit = forced === logic_1.Ternary.Always ? built_in_props_1.ArgProp.Forced : forced === logic_1.Ternary.Never ? built_in_props_1.ArgProp.Lazy : 0;
|
|
79
|
+
if (bit !== 0) {
|
|
80
|
+
roles[formal] = (roles[formal] ?? 0) | bit;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (Object.keys(roles).length > 0) {
|
|
84
|
+
all[id] = roles;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return all;
|
|
88
|
+
}
|
|
89
|
+
/** What the functions of a program do, inferred from what their bodies show. */
|
|
90
|
+
exports.FunctionProps = {
|
|
91
|
+
name: 'FunctionProps',
|
|
92
|
+
/** What several definitions and their formals do; see {@link inferFunctions}. */
|
|
93
|
+
of: inferFunctions
|
|
94
|
+
};
|
|
95
|
+
function makeState(graph, ctx) {
|
|
96
|
+
return { graph, info: (0, query_fn_props_1.builtInLookup)(ctx) };
|
|
97
|
+
}
|
|
98
|
+
function propsOf(id, state) {
|
|
99
|
+
const definition = state.graph.getVertex(id);
|
|
100
|
+
if (!vertex_1.FunctionDefinitionVertex.is(definition)) {
|
|
101
|
+
return { stated: {}, callees: [] };
|
|
102
|
+
}
|
|
103
|
+
let stated = {};
|
|
104
|
+
const callees = [];
|
|
105
|
+
for (const [node, vertex] of (0, frame_reflection_1.callsIn)(definition, state.graph)) {
|
|
106
|
+
const info = state.info(vertex.name);
|
|
107
|
+
const carried = built_in_props_1.CallProps.filter(info, built_in_props_1.PropagatedProps);
|
|
108
|
+
stated = built_in_props_1.CallProps.join(stated, {
|
|
109
|
+
props: (carried.props ?? 0) & (bindsOutside(vertex, info) ? ~0 : ~built_in_props_1.CallProp.Scope),
|
|
110
|
+
tags: carried.tags
|
|
111
|
+
});
|
|
112
|
+
if (built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name))) {
|
|
113
|
+
stated = built_in_props_1.CallProps.join(stated, { props: built_in_props_1.CallProp.Generic });
|
|
114
|
+
}
|
|
115
|
+
callees.push(...calledDefinitions(node, state));
|
|
116
|
+
}
|
|
117
|
+
if (returnsInvisibly(definition, state)) {
|
|
118
|
+
stated = built_in_props_1.CallProps.join(stated, { props: built_in_props_1.CallProp.Invisible });
|
|
119
|
+
}
|
|
120
|
+
return { stated, callees };
|
|
121
|
+
}
|
|
122
|
+
/** The definitions of the program the call resolved to, which are the ones stating what the call does. */
|
|
123
|
+
function calledDefinitions(node, state) {
|
|
124
|
+
return (0, frame_reflection_1.edgeTargets)(state.graph, node, edge_1.EdgeType.Calls).filter(target => vertex_1.FunctionDefinitionVertex.is(state.graph.getVertex(target)));
|
|
125
|
+
}
|
|
126
|
+
/** the assignments binding in the frame they run in, which is a scope of the function's own */
|
|
127
|
+
const FrameLocalBinders = new Set(['<-', '=', '->', ':=', 'assign']);
|
|
128
|
+
/** Whether the name is a replacement function binding in its own frame (`names(x) <- v`); the `<<-` twin does not. */
|
|
129
|
+
function isFrameLocalReplacement(name) {
|
|
130
|
+
return name.endsWith('<-') && !name.endsWith('<<-');
|
|
131
|
+
}
|
|
132
|
+
/** Whether the call binds a name beyond its own frame ({@link CallProp.Scope}): `y <<- 1`, `library(x)`, `assign` to an env do; `y <- 1` does not. */
|
|
133
|
+
function bindsOutside(vertex, info) {
|
|
134
|
+
const name = identifier_1.Identifier.getName(vertex.name);
|
|
135
|
+
if (!FrameLocalBinders.has(name) && !isFrameLocalReplacement(name)) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
const layout = info?.sig === undefined ? undefined : built_in_props_1.FnSig.layout(info.sig);
|
|
139
|
+
return layout !== undefined && built_in_props_1.FnSig.posWith(layout, vertex.args.length, built_in_props_1.ArgProp.Written).length > 0;
|
|
140
|
+
}
|
|
141
|
+
/** Whether every unconditional exit ends in a call returning invisibly; a bare value result (`function() 1`) never does. */
|
|
142
|
+
function returnsInvisibly(definition, state) {
|
|
143
|
+
const unconditional = definition.exitPoints.filter(e => (0, info_1.happensInEveryBranch)(e.cds)).map(e => e.nodeId);
|
|
144
|
+
return unconditional.length > 0 && unconditional.every(node => yieldsInvisibly(node, state, 0));
|
|
145
|
+
}
|
|
146
|
+
/** How far the result is followed through the blocks and `return`s wrapping it. */
|
|
147
|
+
const MaxDepth = 6;
|
|
148
|
+
function yieldsInvisibly(node, state, depth) {
|
|
149
|
+
const vertex = state.graph.getVertex(node);
|
|
150
|
+
if (vertex_1.FunctionCallVertex.is(vertex) && ((state.info(vertex.name)?.props ?? 0) & built_in_props_1.CallProp.Invisible) !== 0) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
if (depth >= MaxDepth) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
/* a block hands back its last expression and `return(x)` what it was given, so what they yield decides */
|
|
157
|
+
const returns = (0, frame_reflection_1.edgeTargets)(state.graph, node, edge_1.EdgeType.Returns);
|
|
158
|
+
return returns.length > 0 && returns.every(target => yieldsInvisibly(target, state, depth + 1));
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=function-props.js.map
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
2
|
import type { DataflowGraph } from '../graph/graph';
|
|
3
3
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
4
|
+
/** What to ask for beyond the definition itself, see {@link HigherOrderFunctions.of}. */
|
|
5
|
+
export interface HigherOrderFunctionsOptions {
|
|
6
|
+
/** how to ask what a built-in states, and to resolve the value an argument carries */
|
|
7
|
+
readonly ctx: ReadOnlyFlowrAnalyzerContext;
|
|
8
|
+
/** the graph with edges reversed, to speed up repeat queries over the same call sites */
|
|
9
|
+
readonly invertedGraph?: DataflowGraph;
|
|
10
|
+
}
|
|
4
11
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
* Whether the function is higher-order: it takes a function argument, may return one, or calls one of its own
|
|
13
|
+
* formals as a function. `function(x) x` alone is not higher-order.
|
|
14
|
+
* @useInstead {@link HigherOrderFunctions.of}
|
|
15
|
+
*/
|
|
16
|
+
declare function isHigherOrder(this: void, id: NodeId, graph: DataflowGraph, { ctx, invertedGraph }: HigherOrderFunctionsOptions): boolean;
|
|
17
|
+
/** Whether the functions of a program take, return, or call one of their own formals as a function. */
|
|
18
|
+
export declare const HigherOrderFunctions: {
|
|
19
|
+
readonly name: "HigherOrderFunctions";
|
|
20
|
+
/** Whether one definition is higher-order; see {@link isHigherOrder}. */
|
|
21
|
+
readonly of: typeof isHigherOrder;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Whether the function is higher-order: it takes a function argument, may return one, or calls one of its own
|
|
25
|
+
* formals as a function. `function(x) x` alone is not higher-order; pass an inverted graph to speed up repeat queries.
|
|
26
|
+
* @deprecated use {@link HigherOrderFunctions.of} instead
|
|
10
27
|
*/
|
|
11
28
|
export declare function isFunctionHigherOrder(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, invertedGraph?: DataflowGraph): boolean;
|
|
29
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HigherOrderFunctions = void 0;
|
|
3
4
|
exports.isFunctionHigherOrder = isFunctionHigherOrder;
|
|
4
5
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
5
6
|
const identifier_1 = require("../environments/identifier");
|
|
@@ -11,6 +12,8 @@ const config_1 = require("../../config");
|
|
|
11
12
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
12
13
|
const resolve_helper_1 = require("../environments/resolve-helper");
|
|
13
14
|
const graph_1 = require("../graph/graph");
|
|
15
|
+
const argument_roles_1 = require("./argument-roles");
|
|
16
|
+
const built_in_props_1 = require("../environments/built-in-props");
|
|
14
17
|
function isAnyReturnAFunction(def, graph) {
|
|
15
18
|
const workingQueue = def.exitPoints.map(d => graph.getVertex(d.nodeId)).filter(assert_1.isNotUndefined);
|
|
16
19
|
const seen = new Set();
|
|
@@ -24,8 +27,14 @@ function isAnyReturnAFunction(def, graph) {
|
|
|
24
27
|
return true;
|
|
25
28
|
}
|
|
26
29
|
const next = graph.outgoingEdges(current.id) ?? graph_1.NoEdges;
|
|
30
|
+
const isCall = vertex_1.FunctionCallVertex.is(current);
|
|
27
31
|
for (const [t, e] of next) {
|
|
28
|
-
|
|
32
|
+
/* a call hands back what its callee returns, which its `returns` edges name, and never the callee itself */
|
|
33
|
+
if (isCall && !edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
/* a returned name is followed to what it holds, as `g <- function() 1; g` hands back that function */
|
|
37
|
+
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy) && !node_id_1.NodeId.isBuiltIn(t)) {
|
|
29
38
|
const v = graph.getVertex(t);
|
|
30
39
|
if (v) {
|
|
31
40
|
workingQueue.push(v);
|
|
@@ -35,13 +44,10 @@ function isAnyReturnAFunction(def, graph) {
|
|
|
35
44
|
}
|
|
36
45
|
return false;
|
|
37
46
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Whether the argument hands over a built-in function (`f(print)`), which has no definition in the graph and
|
|
40
|
-
* hence no `function-definition` value to resolve to.
|
|
41
|
-
*/
|
|
47
|
+
/** Whether the argument hands over a built-in function (`f(print)`) rather than calling one (`lapply(1:3, f)`, which hands over its result). */
|
|
42
48
|
function readsBuiltInFunction(id, graph, ctx) {
|
|
43
49
|
for (const [target, edge] of graph.outgoingEdges(id) ?? graph_1.NoEdges) {
|
|
44
|
-
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) || !node_id_1.NodeId.isBuiltIn(target)) {
|
|
50
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) || edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) || !node_id_1.NodeId.isBuiltIn(target)) {
|
|
45
51
|
continue;
|
|
46
52
|
}
|
|
47
53
|
const defs = resolve_helper_1.Resolve.byNameAndType(node_id_1.NodeId.fromBuiltIn(target), ctx.env.makeCleanEnv(), identifier_1.ReferenceType.Function);
|
|
@@ -51,6 +57,29 @@ function readsBuiltInFunction(id, graph, ctx) {
|
|
|
51
57
|
}
|
|
52
58
|
return false;
|
|
53
59
|
}
|
|
60
|
+
/** The definitions the given node can hand over, to tell an argument being the definition under inspection from one holding another. */
|
|
61
|
+
function definitionsBehind(id, graph) {
|
|
62
|
+
const found = new Set();
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
const workingQueue = [id];
|
|
65
|
+
while (workingQueue.length > 0) {
|
|
66
|
+
const current = workingQueue.pop();
|
|
67
|
+
if (seen.has(current) || node_id_1.NodeId.isBuiltIn(current)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
seen.add(current);
|
|
71
|
+
if (vertex_1.FunctionDefinitionVertex.is(graph.getVertex(current))) {
|
|
72
|
+
found.add(current);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
for (const [t, e] of graph.outgoingEdges(current) ?? graph_1.NoEdges) {
|
|
76
|
+
if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy)) {
|
|
77
|
+
workingQueue.push(t);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return found;
|
|
82
|
+
}
|
|
54
83
|
function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
55
84
|
const callSites = invertedGraph?.outgoingEdges(def.id) ?? graph.ingoingEdges(def.id);
|
|
56
85
|
for (const [callerId, e] of callSites ?? []) {
|
|
@@ -65,6 +94,11 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
|
65
94
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
66
95
|
continue;
|
|
67
96
|
}
|
|
97
|
+
/* an apply-family call carries the callback among its arguments, which says nothing about the callback itself */
|
|
98
|
+
const behind = definitionsBehind(arg.nodeId, graph);
|
|
99
|
+
if (behind.size === 1 && behind.has(def.id)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
68
102
|
const value = node_value_1.NodeValue.inGraph.setOf(arg.nodeId, graph, ctx, { resolve: config_1.VariableResolve.Alias });
|
|
69
103
|
if (value?.elements.some(e => e.type === 'function-definition') || readsBuiltInFunction(arg.nodeId, graph, ctx)) {
|
|
70
104
|
return true;
|
|
@@ -73,23 +107,35 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
|
|
|
73
107
|
}
|
|
74
108
|
return false;
|
|
75
109
|
}
|
|
110
|
+
/** Whether the body uses a formal as a function ({@link ArgProp.Callee}), which no call site has to show. */
|
|
111
|
+
function callsAFormal(id, graph, ctx) {
|
|
112
|
+
const roles = argument_roles_1.ArgumentRoles.of([id], graph, { ctx })[id] ?? {};
|
|
113
|
+
return Object.values(roles).some(props => (props & built_in_props_1.ArgProp.Callee) !== 0);
|
|
114
|
+
}
|
|
76
115
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* if no function is passed as an argument.
|
|
81
|
-
* Please note that inspecting higher order functions can be sped up (if queries multiple times) by providing an inverted graph as well!
|
|
116
|
+
* Whether the function is higher-order: it takes a function argument, may return one, or calls one of its own
|
|
117
|
+
* formals as a function. `function(x) x` alone is not higher-order.
|
|
118
|
+
* @useInstead {@link HigherOrderFunctions.of}
|
|
82
119
|
*/
|
|
83
|
-
function
|
|
120
|
+
function isHigherOrder(id, graph, { ctx, invertedGraph }) {
|
|
84
121
|
const vert = graph.getVertex(id);
|
|
85
122
|
if (!vert || !vertex_1.FunctionDefinitionVertex.is(vert)) {
|
|
86
123
|
return false;
|
|
87
124
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
125
|
+
return isAnyReturnAFunction(vert, graph) || callsAFormal(id, graph, ctx) || inspectCallSitesArgumentsFns(vert, graph, ctx, invertedGraph);
|
|
126
|
+
}
|
|
127
|
+
/** Whether the functions of a program take, return, or call one of their own formals as a function. */
|
|
128
|
+
exports.HigherOrderFunctions = {
|
|
129
|
+
name: 'HigherOrderFunctions',
|
|
130
|
+
/** Whether one definition is higher-order; see {@link isHigherOrder}. */
|
|
131
|
+
of: isHigherOrder
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Whether the function is higher-order: it takes a function argument, may return one, or calls one of its own
|
|
135
|
+
* formals as a function. `function(x) x` alone is not higher-order; pass an inverted graph to speed up repeat queries.
|
|
136
|
+
* @deprecated use {@link HigherOrderFunctions.of} instead
|
|
137
|
+
*/
|
|
138
|
+
function isFunctionHigherOrder(id, graph, ctx, invertedGraph) {
|
|
139
|
+
return exports.HigherOrderFunctions.of(id, graph, { ctx, invertedGraph });
|
|
94
140
|
}
|
|
95
141
|
//# sourceMappingURL=higher-order-function.js.map
|
|
@@ -24,6 +24,8 @@ export interface FunctionStrictness {
|
|
|
24
24
|
* {@link ArgProp.Presence} is never evaluated, one stated {@link ArgProp.Forced} always is, and the calls
|
|
25
25
|
* reaching an argument only on the way the run takes are the ones flowR hands to the processor that says so
|
|
26
26
|
* (`switch` picking a branch, `try` reaching a handler, a hook running at exit).
|
|
27
|
+
* A body reading its own call or frame ({@link CallProp.Frame}: `match.call()`, `nargs()`,
|
|
28
|
+
* `as.list(environment())`) reaches every parameter without naming one, so none of them is answered `Never`.
|
|
27
29
|
* For a generic, the methods reached by S3 dispatch decide: they agree on a parameter or it is left open,
|
|
28
30
|
* while the object the dispatch is on is forced by the dispatch itself. A `NextMethod` carries the same
|
|
29
31
|
* question on to the methods it reaches, matched by the position the parameter is written in.
|
|
@@ -33,8 +35,28 @@ export interface FunctionStrictness {
|
|
|
33
35
|
* only claims certainty where the code gives it.
|
|
34
36
|
* What a built-in does with an argument comes from the {@link ArgProp} bits its signature states, so a
|
|
35
37
|
* configured or overwritten built-in is the one that answers when the analyzer context is handed along.
|
|
36
|
-
* @
|
|
38
|
+
* @useInstead {@link FunctionStrictnesses.of}
|
|
39
|
+
*/
|
|
40
|
+
declare function strictnessOfEach(this: void, ids: Iterable<NodeId>, graph: DataflowGraph, { ctx }?: FunctionStrictnessesOptions): Record<NodeId, FunctionStrictness>;
|
|
41
|
+
/** What to ask for beyond the definitions themselves, see {@link FunctionStrictnesses.of}. */
|
|
42
|
+
export interface FunctionStrictnessesOptions {
|
|
43
|
+
/** how to ask what a built-in states, so a configured or overwritten one answers */
|
|
44
|
+
readonly ctx?: ReadOnlyFlowrAnalyzerContext;
|
|
45
|
+
}
|
|
46
|
+
/** How the functions of a program treat their parameters, see {@link FunctionStrictness}. */
|
|
47
|
+
export declare const FunctionStrictnesses: {
|
|
48
|
+
readonly name: "FunctionStrictnesses";
|
|
49
|
+
/** The strictness of several definitions, sharing the work between them; see {@link strictnessOfEach}. */
|
|
50
|
+
readonly of: typeof strictnessOfEach;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Determines whether the function with the given id is strict, i.e., whether calling it forces its arguments.
|
|
54
|
+
* {@link Ternary#Always} says every call forces every parameter, {@link Ternary#Never} that no call forces
|
|
55
|
+
* all of them, and {@link Ternary#Maybe} that it depends on the path taken, on the caller, or on a function
|
|
56
|
+
* flowR could not resolve. A definition without parameters has nothing to leave unforced and is strict.
|
|
57
|
+
* @deprecated use {@link FunctionStrictnesses.of} instead
|
|
37
58
|
*/
|
|
38
59
|
export declare function strictnessOfFunction(id: NodeId, graph: DataflowGraph, ctx?: ReadOnlyFlowrAnalyzerContext): FunctionStrictness;
|
|
39
|
-
/**
|
|
60
|
+
/** @deprecated use {@link FunctionStrictnesses.of} instead */
|
|
40
61
|
export declare function strictnessOfFunctions(ids: Iterable<NodeId>, graph: DataflowGraph, ctx?: ReadOnlyFlowrAnalyzerContext): Record<NodeId, FunctionStrictness>;
|
|
62
|
+
export {};
|