@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,1656 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataFrameShapeSemantics = void 0;
|
|
4
|
+
const config_1 = require("../../config");
|
|
5
|
+
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
6
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
7
|
+
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
8
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
9
|
+
const make_argument_1 = require("../../dataflow/internal/process/functions/call/argument/make-argument");
|
|
10
|
+
const built_in_source_1 = require("../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
11
|
+
const r_access_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
12
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
13
|
+
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
14
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
15
|
+
const r_number_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
16
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
17
|
+
const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
18
|
+
const r_unary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
19
|
+
const retriever_1 = require("../../r-bridge/retriever");
|
|
20
|
+
const assert_1 = require("../../util/assert");
|
|
21
|
+
const record_1 = require("../../util/record");
|
|
22
|
+
const value_semantics_1 = require("../value-semantics");
|
|
23
|
+
const arguments_1 = require("./arguments");
|
|
24
|
+
const dataframe_domain_1 = require("./dataframe-domain");
|
|
25
|
+
const resolve_args_1 = require("./resolve-args");
|
|
26
|
+
const semantics_1 = require("./semantics");
|
|
27
|
+
/**
|
|
28
|
+
* Represents the different types of data frames in R
|
|
29
|
+
*/
|
|
30
|
+
var DataFrameType;
|
|
31
|
+
(function (DataFrameType) {
|
|
32
|
+
DataFrameType["DataFrame"] = "data.frame";
|
|
33
|
+
DataFrameType["Tibble"] = "tibble";
|
|
34
|
+
DataFrameType["DataTable"] = "data.table";
|
|
35
|
+
})(DataFrameType || (DataFrameType = {}));
|
|
36
|
+
/** Shared parameters of the `read.csv`/`read.delim` wrappers around `read.table`, which only differ in their separator. */
|
|
37
|
+
const ReadTableVariantParams = {
|
|
38
|
+
fileName: { pos: 0, name: 'file' },
|
|
39
|
+
header: { pos: 1, name: 'header', default: true },
|
|
40
|
+
separator: { pos: 2, name: 'sep', default: ',' },
|
|
41
|
+
quote: { pos: 3, name: 'quote', default: '"' },
|
|
42
|
+
comment: { pos: 6, name: 'comment.char', default: '' },
|
|
43
|
+
skipLines: { pos: -1, name: 'skip', default: 0 },
|
|
44
|
+
checkNames: { pos: -1, name: 'check.names', default: true },
|
|
45
|
+
noDupNames: { pos: -1, name: 'check.names', default: true },
|
|
46
|
+
text: { pos: -1, name: 'text' },
|
|
47
|
+
critical: [
|
|
48
|
+
{ pos: -1, name: 'row.names' },
|
|
49
|
+
{ pos: -1, name: 'col.names' },
|
|
50
|
+
{ pos: -1, name: 'nrows', default: -1 },
|
|
51
|
+
{ pos: -1, name: 'strip.white', default: false },
|
|
52
|
+
{ pos: -1, name: 'blank.lines.skip', default: true },
|
|
53
|
+
{ pos: -1, name: 'allow.escapes', default: false },
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
/** Shared parameters of the readr `read_csv`/`read_tsv` wrappers around `read_delim`, which only differ in their separator. */
|
|
57
|
+
const ReadrDelimitedParams = {
|
|
58
|
+
fileName: { pos: 0, name: 'file' },
|
|
59
|
+
header: { pos: 1, name: 'col_names', default: true },
|
|
60
|
+
separator: { pos: -1, default: ',' },
|
|
61
|
+
quote: { pos: 8, name: 'quote', default: '"' },
|
|
62
|
+
comment: { pos: 9, name: 'comment', default: '' },
|
|
63
|
+
skipLines: { pos: 11, name: 'skip', default: 0 },
|
|
64
|
+
checkNames: { pos: -1, default: false },
|
|
65
|
+
noDupNames: { pos: -1, default: true },
|
|
66
|
+
critical: [
|
|
67
|
+
{ pos: 3, name: 'col_select' },
|
|
68
|
+
{ pos: 4, name: 'id' },
|
|
69
|
+
{ pos: 10, name: 'trim_ws', default: true },
|
|
70
|
+
{ pos: 12, name: 'n_max', default: Infinity },
|
|
71
|
+
{ pos: 14, name: 'name_repair', default: 'unique' },
|
|
72
|
+
{ pos: 18, name: 'skip_empty_rows', default: true }
|
|
73
|
+
],
|
|
74
|
+
noEmptyNames: true
|
|
75
|
+
};
|
|
76
|
+
/** Shared parameters of the dplyr `*_join` functions, which only differ in the sides they keep. */
|
|
77
|
+
const DplyrJoinParams = {
|
|
78
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
79
|
+
otherDataFrame: { pos: 1, name: 'y' },
|
|
80
|
+
by: { pos: 2, name: 'by' },
|
|
81
|
+
joinAll: { pos: -1, default: false },
|
|
82
|
+
joinLeft: { pos: -1, default: false },
|
|
83
|
+
joinRight: { pos: -1, default: false },
|
|
84
|
+
critical: [{ pos: -1, name: 'keep' }]
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The abstract semantics of the supported concrete data frame functions, access operations, and replacement functions,
|
|
88
|
+
* mapping each supported function to the abstract data frame operations the function is composed of,
|
|
89
|
+
* including information about the type of the returned data frame
|
|
90
|
+
* and the location of all relevant function parameters (see {@link FunctionParameterLocation}).
|
|
91
|
+
*/
|
|
92
|
+
const DataFrameSemantics = {
|
|
93
|
+
functionCalls: {
|
|
94
|
+
'base::data.frame': applyFunctionCall(mapDataFrameCreate, {
|
|
95
|
+
checkNames: { pos: -1, name: 'check.names', default: true },
|
|
96
|
+
noDupNames: { pos: -1, name: 'check.names', default: true },
|
|
97
|
+
special: ['row.names', 'check.rows', 'check.names', 'fix.empty.names', 'stringsAsFactors'],
|
|
98
|
+
critical: [{ pos: -1, name: 'row.names' }]
|
|
99
|
+
}, DataFrameType.DataFrame, true),
|
|
100
|
+
'base::as.data.frame': applyFunctionCall(mapDataFrameConvert, {
|
|
101
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
102
|
+
critical: []
|
|
103
|
+
}, DataFrameType.DataFrame, true),
|
|
104
|
+
'utils::read.table': applyFunctionCall(mapDataFrameRead, {
|
|
105
|
+
fileName: { pos: 0, name: 'file' },
|
|
106
|
+
header: { pos: 1, name: 'header', default: false },
|
|
107
|
+
separator: { pos: 2, name: 'sep', default: '\\s' },
|
|
108
|
+
quote: { pos: 3, name: 'quote', default: '"\'' },
|
|
109
|
+
skipLines: { pos: 12, name: 'skip', default: 0 },
|
|
110
|
+
checkNames: { pos: 13, name: 'check.names', default: true },
|
|
111
|
+
noDupNames: { pos: 13, name: 'check.names', default: true },
|
|
112
|
+
comment: { pos: 17, name: 'comment.char', default: '#' },
|
|
113
|
+
text: { pos: 23, name: 'text' },
|
|
114
|
+
critical: [
|
|
115
|
+
{ pos: 6, name: 'row.names' },
|
|
116
|
+
{ pos: 7, name: 'col.names' },
|
|
117
|
+
{ pos: 11, name: 'nrows', default: -1 },
|
|
118
|
+
{ pos: 15, name: 'strip.white', default: false },
|
|
119
|
+
{ pos: 16, name: 'blank.lines.skip', default: true },
|
|
120
|
+
{ pos: 18, name: 'allow.escapes', default: false },
|
|
121
|
+
]
|
|
122
|
+
}, DataFrameType.DataFrame, true),
|
|
123
|
+
'utils::read.csv': applyFunctionCall(mapDataFrameRead, {
|
|
124
|
+
...ReadTableVariantParams,
|
|
125
|
+
separator: { pos: 2, name: 'sep', default: ',' }
|
|
126
|
+
}, DataFrameType.DataFrame, true),
|
|
127
|
+
'utils::read.csv2': applyFunctionCall(mapDataFrameRead, {
|
|
128
|
+
...ReadTableVariantParams,
|
|
129
|
+
separator: { pos: 2, name: 'sep', default: ';' }
|
|
130
|
+
}, DataFrameType.DataFrame, true),
|
|
131
|
+
'utils::read.delim': applyFunctionCall(mapDataFrameRead, {
|
|
132
|
+
...ReadTableVariantParams,
|
|
133
|
+
separator: { pos: 2, name: 'sep', default: '\\t' }
|
|
134
|
+
}, DataFrameType.DataFrame, true),
|
|
135
|
+
'utils::read.delim2': applyFunctionCall(mapDataFrameRead, {
|
|
136
|
+
...ReadTableVariantParams,
|
|
137
|
+
separator: { pos: 2, name: 'sep', default: '\\t' }
|
|
138
|
+
}, DataFrameType.DataFrame, true),
|
|
139
|
+
'readr::read_table': applyFunctionCall(mapDataFrameRead, {
|
|
140
|
+
fileName: { pos: 0, name: 'file' },
|
|
141
|
+
header: { pos: 1, name: 'col_names', default: true },
|
|
142
|
+
separator: { pos: -1, default: '\\s' },
|
|
143
|
+
quote: { pos: -1, default: '"' },
|
|
144
|
+
skipLines: { pos: 5, name: 'skip', default: 0 },
|
|
145
|
+
comment: { pos: 9, name: 'comment', default: '' },
|
|
146
|
+
checkNames: { pos: -1, default: false },
|
|
147
|
+
noDupNames: { pos: -1, default: true },
|
|
148
|
+
critical: [
|
|
149
|
+
{ pos: 6, name: 'n_max', default: Infinity },
|
|
150
|
+
{ pos: 11, name: 'skip_empty_rows', default: true }
|
|
151
|
+
],
|
|
152
|
+
noEmptyNames: true
|
|
153
|
+
}, DataFrameType.Tibble, true),
|
|
154
|
+
'readr::read_csv': applyFunctionCall(mapDataFrameRead, {
|
|
155
|
+
...ReadrDelimitedParams,
|
|
156
|
+
separator: { pos: -1, default: ',' }
|
|
157
|
+
}, DataFrameType.Tibble, true),
|
|
158
|
+
'readr::read_csv2': applyFunctionCall(mapDataFrameRead, {
|
|
159
|
+
...ReadrDelimitedParams,
|
|
160
|
+
separator: { pos: -1, default: ';' }
|
|
161
|
+
}, DataFrameType.Tibble, true),
|
|
162
|
+
'readr::read_tsv': applyFunctionCall(mapDataFrameRead, {
|
|
163
|
+
...ReadrDelimitedParams,
|
|
164
|
+
separator: { pos: -1, default: '\\t' }
|
|
165
|
+
}, DataFrameType.Tibble, true),
|
|
166
|
+
'readr::read_delim': applyFunctionCall(mapDataFrameRead, {
|
|
167
|
+
fileName: { pos: 0, name: 'file' },
|
|
168
|
+
separator: { pos: 1, name: 'delim', default: '\t' },
|
|
169
|
+
quote: { pos: 2, name: 'quote', default: '"' },
|
|
170
|
+
header: { pos: 5, name: 'col_names', default: true },
|
|
171
|
+
comment: { pos: 12, name: 'comment', default: '' },
|
|
172
|
+
skipLines: { pos: 14, name: 'skip', default: 0 },
|
|
173
|
+
checkNames: { pos: -1, default: false },
|
|
174
|
+
noDupNames: { pos: -1, default: true },
|
|
175
|
+
critical: [
|
|
176
|
+
{ pos: 3, name: 'escape_backslash', default: false },
|
|
177
|
+
{ pos: 4, name: 'escape_double', default: true },
|
|
178
|
+
{ pos: 7, name: 'col_select' },
|
|
179
|
+
{ pos: 8, name: 'id' },
|
|
180
|
+
{ pos: 13, name: 'trim_ws', default: false },
|
|
181
|
+
{ pos: 15, name: 'n_max', default: Infinity },
|
|
182
|
+
{ pos: 17, name: 'name_repair', default: 'unique' },
|
|
183
|
+
{ pos: 21, name: 'skip_empty_rows', default: true }
|
|
184
|
+
],
|
|
185
|
+
noEmptyNames: true
|
|
186
|
+
}, DataFrameType.Tibble, true),
|
|
187
|
+
'base::cbind': applyFunctionCall(mapDataFrameColBind, {
|
|
188
|
+
special: ['deparse.level', 'make.row.names', 'stringsAsFactors', 'factor.exclude']
|
|
189
|
+
}, DataFrameType.DataFrame),
|
|
190
|
+
'base::rbind': applyFunctionCall(mapDataFrameRowBind, {
|
|
191
|
+
special: ['deparse.level', 'make.row.names', 'stringsAsFactors', 'factor.exclude']
|
|
192
|
+
}, DataFrameType.DataFrame),
|
|
193
|
+
'utils::head': applyFunctionCall(mapDataFrameHeadTail, {
|
|
194
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
195
|
+
amount: { pos: 1, name: 'n', default: 6 }
|
|
196
|
+
}, DataFrameType.DataFrame),
|
|
197
|
+
'utils::tail': applyFunctionCall(mapDataFrameHeadTail, {
|
|
198
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
199
|
+
amount: { pos: 1, name: 'n', default: 6 },
|
|
200
|
+
fromEnd: true
|
|
201
|
+
}, DataFrameType.DataFrame),
|
|
202
|
+
'base::subset': applyFunctionCall(mapDataFrameSubset, {
|
|
203
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
204
|
+
subset: { pos: 1, name: 'subset' },
|
|
205
|
+
select: { pos: 2, name: 'select' },
|
|
206
|
+
drop: { pos: 3, name: 'drop', default: false }
|
|
207
|
+
}, DataFrameType.DataFrame),
|
|
208
|
+
'dplyr::filter': applyFunctionCall(mapDataFrameFilter, {
|
|
209
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
210
|
+
special: ['.by', '.preserve']
|
|
211
|
+
}, DataFrameType.DataFrame, true),
|
|
212
|
+
'dplyr::select': applyFunctionCall(mapDataFrameSelect, {
|
|
213
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
214
|
+
special: []
|
|
215
|
+
}, DataFrameType.DataFrame, true),
|
|
216
|
+
'dplyr::mutate': applyFunctionCall(mapDataFrameMutate, {
|
|
217
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
218
|
+
special: ['.by', '.keep', '.before', '.after'],
|
|
219
|
+
critical: [{ pos: -1, name: '.keep' }],
|
|
220
|
+
checkNames: false,
|
|
221
|
+
noDupNames: false
|
|
222
|
+
}, DataFrameType.DataFrame, true),
|
|
223
|
+
'base::transform': applyFunctionCall(mapDataFrameMutate, {
|
|
224
|
+
dataFrame: { pos: 0, name: '_data' },
|
|
225
|
+
special: [],
|
|
226
|
+
checkNames: true,
|
|
227
|
+
noDupNames: true
|
|
228
|
+
}, DataFrameType.DataFrame, true),
|
|
229
|
+
'dplyr::group_by': applyFunctionCall(mapDataFrameGroupBy, {
|
|
230
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
231
|
+
by: { pos: 1 },
|
|
232
|
+
special: ['.add', '.drop']
|
|
233
|
+
}, DataFrameType.Tibble, true),
|
|
234
|
+
'dplyr::summarise': applyFunctionCall(mapDataFrameSummarize, {
|
|
235
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
236
|
+
special: ['.by', '.groups']
|
|
237
|
+
}, DataFrameType.DataFrame, true),
|
|
238
|
+
'dplyr::summarize': applyFunctionCall(mapDataFrameSummarize, {
|
|
239
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
240
|
+
special: ['.by', '.groups']
|
|
241
|
+
}, DataFrameType.DataFrame, true),
|
|
242
|
+
'dplyr::inner_join': applyFunctionCall(mapDataFrameJoin, {
|
|
243
|
+
...DplyrJoinParams
|
|
244
|
+
}, DataFrameType.DataFrame, true),
|
|
245
|
+
'dplyr::left_join': applyFunctionCall(mapDataFrameJoin, {
|
|
246
|
+
...DplyrJoinParams,
|
|
247
|
+
joinLeft: { pos: -1, default: true }
|
|
248
|
+
}, DataFrameType.DataFrame, true),
|
|
249
|
+
'dplyr::right_join': applyFunctionCall(mapDataFrameJoin, {
|
|
250
|
+
...DplyrJoinParams,
|
|
251
|
+
joinRight: { pos: -1, default: true },
|
|
252
|
+
}, DataFrameType.DataFrame, true),
|
|
253
|
+
'dplyr::full_join': applyFunctionCall(mapDataFrameJoin, {
|
|
254
|
+
...DplyrJoinParams,
|
|
255
|
+
joinAll: { pos: -1, default: true }
|
|
256
|
+
}, DataFrameType.DataFrame, true),
|
|
257
|
+
'base::merge': applyFunctionCall(mapDataFrameJoin, {
|
|
258
|
+
dataFrame: { pos: 0, name: 'x' },
|
|
259
|
+
otherDataFrame: { pos: 1, name: 'y' },
|
|
260
|
+
by: { pos: 2, name: 'by' },
|
|
261
|
+
joinAll: { pos: 5, name: 'all', default: false },
|
|
262
|
+
joinLeft: { pos: 6, name: 'all.x', default: false },
|
|
263
|
+
joinRight: { pos: 7, name: 'all.y', default: false },
|
|
264
|
+
critical: [
|
|
265
|
+
{ pos: 3, name: 'by.x' },
|
|
266
|
+
{ pos: 4, name: 'by.y' }
|
|
267
|
+
]
|
|
268
|
+
}, DataFrameType.DataFrame, true),
|
|
269
|
+
'dplyr::relocate': applyFunctionCall(mapDataFrameIdentity, {
|
|
270
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
271
|
+
special: ['.before', '.after'],
|
|
272
|
+
disallowNamedArgs: true
|
|
273
|
+
}, DataFrameType.DataFrame, true),
|
|
274
|
+
'dplyr::arrange': applyFunctionCall(mapDataFrameIdentity, {
|
|
275
|
+
dataFrame: { pos: 0, name: '.data' },
|
|
276
|
+
special: ['.by_group', '.locale']
|
|
277
|
+
}, DataFrameType.DataFrame, true),
|
|
278
|
+
/* Other functions that are not explicitly supported but always return data frames */
|
|
279
|
+
'base::as.data.frame.matrix': applyEntryPoint(DataFrameType.DataFrame), // S3 dispatch of `as.data.frame`
|
|
280
|
+
'stats::anova': applyEntryPoint(DataFrameType.DataFrame),
|
|
281
|
+
'stats::AIC': applyEntryPoint(DataFrameType.DataFrame),
|
|
282
|
+
'stats::BIC': applyEntryPoint(DataFrameType.DataFrame),
|
|
283
|
+
'car::Anova': applyEntryPoint(DataFrameType.DataFrame),
|
|
284
|
+
'car::Manova': applyEntryPoint(DataFrameType.DataFrame),
|
|
285
|
+
'dplyr::data_frame': applyEntryPoint(DataFrameType.DataFrame),
|
|
286
|
+
'dplyr::as_data_frame': applyEntryPoint(DataFrameType.DataFrame),
|
|
287
|
+
'dplyr::tbl': applyEntryPoint(DataFrameType.Tibble),
|
|
288
|
+
'dplyr::as.tbl': applyEntryPoint(DataFrameType.Tibble),
|
|
289
|
+
'readr::read_fwf': applyEntryPoint(DataFrameType.Tibble),
|
|
290
|
+
'readr::read_log': applyEntryPoint(DataFrameType.Tibble),
|
|
291
|
+
'readxl::read_excel': applyEntryPoint(DataFrameType.Tibble),
|
|
292
|
+
'readxl::read_xls': applyEntryPoint(DataFrameType.Tibble),
|
|
293
|
+
'readxl::read_xlsx': applyEntryPoint(DataFrameType.Tibble),
|
|
294
|
+
'tibble::tibble': applyEntryPoint(DataFrameType.Tibble),
|
|
295
|
+
'tibble::tibble_row': applyEntryPoint(DataFrameType.Tibble),
|
|
296
|
+
'tibble::as_tibble': applyEntryPoint(DataFrameType.Tibble),
|
|
297
|
+
'tibble::tribble': applyEntryPoint(DataFrameType.Tibble),
|
|
298
|
+
'dplyr::tibble': applyEntryPoint(DataFrameType.Tibble), // re-export of `tibble::tibble`
|
|
299
|
+
'dplyr::as_tibble': applyEntryPoint(DataFrameType.Tibble), // re-export of `tibble::as_tibble`
|
|
300
|
+
'dplyr::tribble': applyEntryPoint(DataFrameType.Tibble), // re-export of `tibble::tribble`
|
|
301
|
+
'data.table::data.table': applyEntryPoint(DataFrameType.DataTable),
|
|
302
|
+
'data.table::as.data.table': applyEntryPoint(DataFrameType.DataTable),
|
|
303
|
+
'data.table::fread': applyEntryPoint(DataFrameType.DataTable),
|
|
304
|
+
/* Other transformations that are not explicitly supported but return data frames if an argument is a data frame */
|
|
305
|
+
'stats::na.omit': applyUnknownCall({ pos: 0, name: 'object' }, DataFrameType.DataFrame),
|
|
306
|
+
'base::unique': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame),
|
|
307
|
+
'base::droplevels': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame),
|
|
308
|
+
'stats::aggregate': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame),
|
|
309
|
+
'base::with': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
310
|
+
'base::within': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
311
|
+
'stats::reshape': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
312
|
+
'reshape2::melt': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
313
|
+
'data.table::melt': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataTable),
|
|
314
|
+
'data.table::dcast': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataTable),
|
|
315
|
+
'tidyr::drop_na': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
316
|
+
'tidyr::replace_na': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
317
|
+
'tidyr::pivot_longer': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
318
|
+
'tidyr::pivot_wider': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
319
|
+
'tidyr::separate': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
320
|
+
'tidyr::separate_wider_position': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
321
|
+
'tidyr::separate_wider_delim': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
322
|
+
'tidyr::unite': applyUnknownCall({ pos: 0, name: 'data' }, DataFrameType.DataFrame),
|
|
323
|
+
'dplyr::transmute': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
324
|
+
'dplyr::distinct': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
325
|
+
'dplyr::distinct_prepare': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
326
|
+
'dplyr::group_by_prepare': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
327
|
+
'dplyr::rename': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
328
|
+
'dplyr::rename_with': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
329
|
+
'dplyr::reframe': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
330
|
+
'dplyr::slice': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
331
|
+
'dplyr::slice_head': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
332
|
+
'dplyr::slice_tail': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
333
|
+
'dplyr::slice_min': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
334
|
+
'dplyr::slice_max': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
335
|
+
'dplyr::slice_sample': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.DataFrame, true),
|
|
336
|
+
'dplyr::filter_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
337
|
+
'dplyr::filter_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
338
|
+
'dplyr::filter_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
339
|
+
'dplyr::select_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
340
|
+
'dplyr::select_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
341
|
+
'dplyr::select_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
342
|
+
'dplyr::mutate_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
343
|
+
'dplyr::mutate_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
344
|
+
'dplyr::mutate_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
345
|
+
'dplyr::transmute_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
346
|
+
'dplyr::transmute_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
347
|
+
'dplyr::transmute_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
348
|
+
'dplyr::distinct_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
349
|
+
'dplyr::distinct_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
350
|
+
'dplyr::distinct_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
351
|
+
'dplyr::group_by_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
352
|
+
'dplyr::group_by_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
353
|
+
'dplyr::group_by_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
354
|
+
'dplyr::summarize_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
355
|
+
'dplyr::summarise_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
356
|
+
'dplyr::summarize_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
357
|
+
'dplyr::summarise_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
358
|
+
'dplyr::summarize_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
359
|
+
'dplyr::summarise_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
360
|
+
'dplyr::arrange_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
361
|
+
'dplyr::arrange_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
362
|
+
'dplyr::arrange_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
363
|
+
'dplyr::rename_if': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
364
|
+
'dplyr::rename_at': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
365
|
+
'dplyr::rename_all': applyUnknownCall({ pos: 0, name: '.tbl' }, DataFrameType.Tibble, true),
|
|
366
|
+
'dplyr::semi_join': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
367
|
+
'dplyr::anti_join': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
368
|
+
'dplyr::nest_join': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
369
|
+
'dplyr::cross_join': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
370
|
+
'dplyr::ungroup': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
371
|
+
'dplyr::count': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
372
|
+
'dplyr::tally': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
373
|
+
'dplyr::add_count': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
374
|
+
'dplyr::add_tally': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
375
|
+
'dplyr::rows_insert': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
376
|
+
'dplyr::rows_append': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
377
|
+
'dplyr::rows_update': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
378
|
+
'dplyr::rows_patch': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
379
|
+
'dplyr::rows_upsert': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
380
|
+
'dplyr::rows_delete': applyUnknownCall({ pos: 0, name: 'x' }, DataFrameType.DataFrame, true),
|
|
381
|
+
'dplyr::bind_cols': applyUnknownCall(undefined, DataFrameType.DataFrame, true),
|
|
382
|
+
'dplyr::bind_rows': applyUnknownCall(undefined, DataFrameType.DataFrame, true),
|
|
383
|
+
'tibble::add_column': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.Tibble, true),
|
|
384
|
+
'tibble::add_row': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.Tibble, true),
|
|
385
|
+
'tibble::add_case': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.Tibble, true),
|
|
386
|
+
'dplyr::add_row': applyUnknownCall({ pos: 0, name: '.data' }, DataFrameType.Tibble, true), // re-export of `tibble::add_row`
|
|
387
|
+
/* Other functions that are not explicitly supported but modify their data frame argument in place */
|
|
388
|
+
'stats::setNames': applyUnknownCall({ pos: 0, name: 'object' }, DataFrameType.DataFrame, false, semantics_1.ConstraintType.OperandModification),
|
|
389
|
+
'base::unname': applyUnknownCall({ pos: 0, name: 'obj' }, DataFrameType.DataFrame, false, semantics_1.ConstraintType.OperandModification)
|
|
390
|
+
},
|
|
391
|
+
accessCalls: {
|
|
392
|
+
'base::$': applyAccessCall(mapDataFrameAccess),
|
|
393
|
+
'base::[': applyAccessCall(mapDataFrameAccess),
|
|
394
|
+
'base::[[': applyAccessCall(mapDataFrameAccess)
|
|
395
|
+
},
|
|
396
|
+
replacementCall: {
|
|
397
|
+
'base::$<-': applyReplacementCall(mapDataFrameAccessAssignment),
|
|
398
|
+
'base::[<-': applyReplacementCall(mapDataFrameAccessAssignment),
|
|
399
|
+
'base::[[<-': applyReplacementCall(mapDataFrameAccessAssignment),
|
|
400
|
+
'base::names<-': applyReplacementCall(mapDataFrameColNamesAssignment),
|
|
401
|
+
'base::colnames<-': applyReplacementCall(mapDataFrameColNamesAssignment),
|
|
402
|
+
'base::rownames<-': applyReplacementCall(mapDataFrameRowNamesAssignment),
|
|
403
|
+
'base::dimnames<-': applyReplacementCall(mapDataFrameDimNamesAssignment)
|
|
404
|
+
},
|
|
405
|
+
conditionSemantics: {}
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* The abstract semantics of the data frame shape inference, applying the abstract semantics defined for the supported
|
|
409
|
+
* data frame functions, access operations, and replacement functions (see {@link DataFrameSemantics}).
|
|
410
|
+
*
|
|
411
|
+
* Besides the defined semantics, all other replacement functions applied to a data frame are over-approximated
|
|
412
|
+
* by mapping the modified data frame operand to the `unknown` abstract operation.
|
|
413
|
+
*
|
|
414
|
+
* The semantics store the abstract data frame operations the expressions of the analyzed program are mapped to,
|
|
415
|
+
* which can be retrieved with {@link getAbstractOperations} after the analysis was performed.
|
|
416
|
+
*/
|
|
417
|
+
class DataFrameShapeSemantics extends value_semantics_1.ValueSemantics {
|
|
418
|
+
/** The map storing the abstract data frame operations the expressions of the analyzed program are mapped to */
|
|
419
|
+
operations;
|
|
420
|
+
/**
|
|
421
|
+
* Creates the abstract semantics of the data frame shape inference.
|
|
422
|
+
* @param options - The options of the semantics, i.e. whether the mapped abstract operations should be stored
|
|
423
|
+
*/
|
|
424
|
+
constructor({ trackOperations = true } = {}) {
|
|
425
|
+
const operations = trackOperations ? new Map() : undefined;
|
|
426
|
+
super(createDataFrameSemantics(operations));
|
|
427
|
+
this.operations = operations;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Gets the mapped abstract data frame operations for an AST node (this only includes direct function calls, replacement calls, or access operations).
|
|
431
|
+
* This requires that the abstract interpretation visitor applying the semantics has been completed, or at least started.
|
|
432
|
+
* @param id - The ID of the node to get the mapped abstract operations for
|
|
433
|
+
* @returns The mapped abstract data frame operations for the node, or `undefined` if no abstract operation was mapped for the node or storing mapped abstract operations is disabled via the options.
|
|
434
|
+
*/
|
|
435
|
+
getAbstractOperations(id) {
|
|
436
|
+
return id !== undefined ? this.operations?.get(id) : undefined;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Applies the abstract semantics defined for the called replacement function, or over-approximates
|
|
440
|
+
* the modified data frame operand of any other replacement function by the `unknown` abstract operation.
|
|
441
|
+
*/
|
|
442
|
+
handleReplacementCall(state, vertex, ctx, target, source) {
|
|
443
|
+
if (this.getSemantics('replacementCall', vertex, ctx) !== undefined) {
|
|
444
|
+
super.handleReplacementCall(state, vertex, ctx, target, source);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
applyUnknownAssignment(state, vertex, ctx, this.operations);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
exports.DataFrameShapeSemantics = DataFrameShapeSemantics;
|
|
452
|
+
/**
|
|
453
|
+
* Creates the declarative definition of the abstract semantics of the data frame domain (see {@link DataFrameSemantics}).
|
|
454
|
+
* @param operations - An optional map to store the abstract data frame operations the expressions are mapped to
|
|
455
|
+
* @returns The definition of the abstract semantics of the data frame domain
|
|
456
|
+
*/
|
|
457
|
+
function createDataFrameSemantics(operations) {
|
|
458
|
+
return {
|
|
459
|
+
functionCalls: record_1.Record.mapProps(DataFrameSemantics.functionCalls, semantics => semantics(operations)),
|
|
460
|
+
accessCalls: record_1.Record.mapProps(DataFrameSemantics.accessCalls, semantics => semantics(operations)),
|
|
461
|
+
replacementCall: record_1.Record.mapProps(DataFrameSemantics.replacementCall, semantics => semantics(operations)),
|
|
462
|
+
conditionSemantics: record_1.Record.mapProps(DataFrameSemantics.conditionSemantics, (semantics) => semantics(operations))
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Creates the abstract semantics of a data frame function, by mapping calls of the function to abstract data frame operations and applying their semantics.
|
|
467
|
+
* @param mapper - The mapper function mapping the arguments of the function call to abstract data frame operations
|
|
468
|
+
* @param params - The expected location of all relevant function parameters, including all `critical` parameters whose presence makes the call unsupported
|
|
469
|
+
* @param returnType - The type of the data frame returned by the function
|
|
470
|
+
* @param alwaysReturnsDataFrame - Whether the function always returns a data frame, so that unsuccessful mappings are over-approximated by the `unknown` operation
|
|
471
|
+
* @returns The function call semantics applying the abstract data frame operations of the function
|
|
472
|
+
*/
|
|
473
|
+
function applyFunctionCall(mapper, params, returnType, alwaysReturnsDataFrame) {
|
|
474
|
+
return operations => (state, vertex, ctx) => {
|
|
475
|
+
const resolveInfo = getResolveInfo(ctx);
|
|
476
|
+
const node = ctx.getAstNode(vertex.id);
|
|
477
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
let result;
|
|
481
|
+
const args = (0, arguments_1.getFunctionArguments)(node, ctx.dfg);
|
|
482
|
+
if ((0, arguments_1.hasCriticalArgument)(args, params.critical, resolveInfo)) {
|
|
483
|
+
result = [{ operation: 'unknown', operand: undefined }];
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
result = mapper(args, params, ctx, resolveInfo) ?? (alwaysReturnsDataFrame ? [{ operation: 'unknown', operand: undefined }] : undefined);
|
|
487
|
+
}
|
|
488
|
+
applyDataFrameExpression(state, node, result, ctx, operations);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Creates the abstract semantics of a data frame function that is not explicitly supported but always returns a data frame, such as `tibble(id = 1:5)`.
|
|
493
|
+
* @param returnType - The type of the data frame returned by the function
|
|
494
|
+
* @returns The function call semantics over-approximating the result of the function by the `unknown` operation
|
|
495
|
+
*/
|
|
496
|
+
function applyEntryPoint(returnType) {
|
|
497
|
+
return applyFunctionCall(() => [{ operation: 'unknown', operand: undefined }], {}, returnType);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Creates the abstract semantics of a data frame function that is not explicitly supported but returns or modifies a data frame, such as `na.omit(df)`.
|
|
501
|
+
* @param dataFrame - The expected location of the data frame parameter (if `undefined`, the first argument that is a data frame is used)
|
|
502
|
+
* @param returnType - The type of the data frame returned by the function
|
|
503
|
+
* @param alwaysReturnsDataFrame - Whether the function always returns a data frame, so that unsuccessful mappings are over-approximated by the `unknown` operation
|
|
504
|
+
* @param constraintType - The optional constraint type to overwrite the default type of the `unknown` operation (e.g. for functions modifying their operand in place)
|
|
505
|
+
* @returns The function call semantics over-approximating the result of the function by the `unknown` operation
|
|
506
|
+
*/
|
|
507
|
+
function applyUnknownCall(dataFrame, returnType, alwaysReturnsDataFrame, constraintType) {
|
|
508
|
+
return applyFunctionCall(mapDataFrameUnknown, { dataFrame, constraintType }, returnType, alwaysReturnsDataFrame);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Creates the abstract semantics of a data frame access operation, by mapping the access to abstract data frame operations and applying their semantics.
|
|
512
|
+
* @param mapper - The mapper function mapping the access operation to abstract data frame operations
|
|
513
|
+
* @returns The access call semantics applying the abstract data frame operations of the access operation
|
|
514
|
+
*/
|
|
515
|
+
function applyAccessCall(mapper) {
|
|
516
|
+
return operations => (state, vertex, ctx) => {
|
|
517
|
+
const node = ctx.getAstNode(vertex.id);
|
|
518
|
+
if (!r_access_1.RAccess.is(node)) {
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
applyDataFrameExpression(state, node, mapper(node, ctx, getResolveInfo(ctx)), ctx, operations);
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Creates the abstract semantics of a data frame replacement function, by mapping the replacement call to abstract data frame operations and applying their semantics.
|
|
526
|
+
* @param mapper - The mapper function mapping the replacement call to abstract data frame operations
|
|
527
|
+
* @returns The replacement call semantics applying the abstract data frame operations of the replacement function
|
|
528
|
+
*/
|
|
529
|
+
function applyReplacementCall(mapper) {
|
|
530
|
+
return operations => (state, vertex, ctx, target, source) => {
|
|
531
|
+
const node = ctx.getAstNode(vertex.id);
|
|
532
|
+
const expression = ctx.getAstNode(source);
|
|
533
|
+
if (node === undefined || ctx.getAstNode(target) === undefined || expression === undefined) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
applyDataFrameExpression(state, node, mapper(node, expression, ctx, getResolveInfo(ctx)), ctx, operations);
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Applies the abstract semantics of a replacement function that is not explicitly supported, such as `levels(df) <- c("A", "B")`,
|
|
541
|
+
* by over-approximating the modified data frame operand with the `unknown` abstract operation.
|
|
542
|
+
* @param state - The abstract state to apply the semantics to
|
|
543
|
+
* @param vertex - The dataflow graph vertex of the replacement call
|
|
544
|
+
* @param ctx - The context of the abstract interpretation analysis
|
|
545
|
+
* @param operations - An optional map to store the mapped abstract data frame operations in
|
|
546
|
+
*/
|
|
547
|
+
function applyUnknownAssignment(state, vertex, ctx, operations) {
|
|
548
|
+
const node = ctx.getAstNode(vertex.id);
|
|
549
|
+
const operand = node !== undefined ? getReplacementOperand(node, ctx) : undefined;
|
|
550
|
+
if (node === undefined || operand === undefined) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
applyDataFrameExpression(state, node, [{
|
|
554
|
+
operation: 'unknown',
|
|
555
|
+
operand: operand.value.info.id,
|
|
556
|
+
type: semantics_1.ConstraintType.OperandModification
|
|
557
|
+
}], ctx, operations);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Creates the resolve information for resolving the arguments of a data frame function call.
|
|
561
|
+
*/
|
|
562
|
+
function getResolveInfo(ctx) {
|
|
563
|
+
return { graph: ctx.dfg, idMap: ctx.ast.idMap, full: true, resolve: config_1.VariableResolve.Alias, ctx: ctx.context };
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Applies the semantics of abstract data frame operations to an abstract state,
|
|
567
|
+
* by storing the inferred abstract value either at the modified operand or at the result of the expression, depending on the {@link ConstraintType} of the operation.
|
|
568
|
+
* @param state - The abstract state to apply the semantics to
|
|
569
|
+
* @param node - The R node of the expression the abstract operations were mapped from
|
|
570
|
+
* @param operations - The abstract data frame operations to apply
|
|
571
|
+
* @param ctx - The context of the abstract interpretation analysis
|
|
572
|
+
* @param operationsMap - An optional map to store the mapped abstract data frame operations in
|
|
573
|
+
*/
|
|
574
|
+
function applyDataFrameExpression(state, node, operations, ctx, operationsMap) {
|
|
575
|
+
if (operations === undefined) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
operationsMap?.set(node.info.id, operations);
|
|
579
|
+
const maxColNames = ctx.context.config.abstractInterpretation.dataFrame.maxColNames;
|
|
580
|
+
let value = dataframe_domain_1.DataFrameDomain.top(maxColNames);
|
|
581
|
+
for (const { operation, operand, type, options, ...args } of operations) {
|
|
582
|
+
const operandValue = operand !== undefined ? ctx.getAbstractValue(operand, state) : value;
|
|
583
|
+
value = (0, semantics_1.applyDataFrameSemantics)(operation, operandValue ?? dataframe_domain_1.DataFrameDomain.top(maxColNames), args, options);
|
|
584
|
+
const constraintType = type ?? (0, semantics_1.getConstraintType)(operation);
|
|
585
|
+
if (operand !== undefined && constraintType === semantics_1.ConstraintType.OperandModification) {
|
|
586
|
+
state.set(operand, value);
|
|
587
|
+
for (const origin of ctx.getVariableOrigins(operand)) {
|
|
588
|
+
state.set(origin, value);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else if (constraintType === semantics_1.ConstraintType.ResultPostcondition) {
|
|
592
|
+
state.set(node.info.id, value);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Maps a data frame creation function, such as `data.frame(id = 1:5, name = c("A", "B"))`, to abstract data frame operations.
|
|
598
|
+
*/
|
|
599
|
+
function mapDataFrameCreate(args, params, ctx, info) {
|
|
600
|
+
const checkNames = (0, arguments_1.getArgumentValue)(args, params.checkNames, info);
|
|
601
|
+
const noDupNames = (0, arguments_1.getArgumentValue)(args, params.noDupNames, info);
|
|
602
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
603
|
+
const argNames = args.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
604
|
+
const argLengths = args.map(arg => resolve_helper_1.Resolve.argument.vectorLength(arg, info));
|
|
605
|
+
const allVectors = argLengths.every(assert_1.isNotUndefined);
|
|
606
|
+
const rows = allVectors ? Math.max(...argLengths, 0) : undefined;
|
|
607
|
+
let colnames = argNames;
|
|
608
|
+
// over-approximate the column names if arguments are present but cannot be resolved to values
|
|
609
|
+
if (!allVectors || typeof checkNames !== 'boolean' || typeof noDupNames !== 'boolean') {
|
|
610
|
+
colnames = undefined;
|
|
611
|
+
}
|
|
612
|
+
else if (rows === 0) {
|
|
613
|
+
colnames = [];
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
colnames = (0, arguments_1.filterValidNames)(colnames, checkNames, noDupNames);
|
|
617
|
+
}
|
|
618
|
+
return [{
|
|
619
|
+
operation: 'create',
|
|
620
|
+
operand: undefined,
|
|
621
|
+
colnames,
|
|
622
|
+
rows
|
|
623
|
+
}];
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Maps a data frame conversion function, such as `as.data.frame(x)`, to abstract data frame operations.
|
|
627
|
+
*/
|
|
628
|
+
function mapDataFrameConvert(args, params, ctx, info) {
|
|
629
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
630
|
+
if (r_argument_1.RArgument.isEmpty(dataFrame) || !r_argument_1.RArgument.isWithValue(dataFrame)) {
|
|
631
|
+
return [{ operation: 'unknown', operand: undefined }];
|
|
632
|
+
}
|
|
633
|
+
return [{
|
|
634
|
+
operation: 'identity',
|
|
635
|
+
operand: dataFrame.value.info.id
|
|
636
|
+
}];
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Maps a data frame read function, such as `read.csv("file.csv")`, to abstract data frame operations.
|
|
640
|
+
* If reading external files is enabled in the configuration, the content of the read file or text is parsed to infer the column names and the number of rows.
|
|
641
|
+
*/
|
|
642
|
+
function mapDataFrameRead(args, params, ctx, info) {
|
|
643
|
+
const fileNameArg = (0, arguments_1.getFunctionArgument)(args, params.fileName, info);
|
|
644
|
+
const textArg = params.text ? (0, arguments_1.getFunctionArgument)(args, params.text, info) : undefined;
|
|
645
|
+
const { source, request } = getRequestFromRead(fileNameArg, textArg, params, info);
|
|
646
|
+
const header = (0, arguments_1.getArgumentValue)(args, params.header, info);
|
|
647
|
+
const separator = (0, arguments_1.getArgumentValue)(args, params.separator, info);
|
|
648
|
+
const quote = (0, arguments_1.getArgumentValue)(args, params.quote, info);
|
|
649
|
+
const comment = (0, arguments_1.getArgumentValue)(args, params.comment, info);
|
|
650
|
+
const skipLines = (0, arguments_1.getArgumentValue)(args, params.skipLines, info);
|
|
651
|
+
const checkNames = (0, arguments_1.getArgumentValue)(args, params.checkNames, info);
|
|
652
|
+
const noDupNames = (0, arguments_1.getArgumentValue)(args, params.noDupNames, info);
|
|
653
|
+
const validArguments = typeof header === 'boolean' && typeof separator === 'string' && typeof quote === 'string' && typeof comment === 'string' &&
|
|
654
|
+
typeof skipLines === 'number' && typeof checkNames === 'boolean' && typeof noDupNames === 'boolean';
|
|
655
|
+
if (request === undefined || !info.ctx.config.abstractInterpretation.dataFrame.readLoadedData.readExternalFiles || !validArguments) {
|
|
656
|
+
return [{
|
|
657
|
+
operation: 'read',
|
|
658
|
+
operand: undefined,
|
|
659
|
+
source,
|
|
660
|
+
colnames: undefined,
|
|
661
|
+
rows: undefined
|
|
662
|
+
}];
|
|
663
|
+
}
|
|
664
|
+
const LineCommentRegex = new RegExp(`\\s*[${(0, arguments_1.escapeRegExp)(comment, true)}].*`);
|
|
665
|
+
let firstLine = undefined;
|
|
666
|
+
let firstLineNumber = 0;
|
|
667
|
+
let rowCount = 0;
|
|
668
|
+
const parseLine = (line, lineNumber) => {
|
|
669
|
+
const text = comment ? line.toString().replace(LineCommentRegex, '') : line.toString();
|
|
670
|
+
if (text.length > 0 && lineNumber >= (skipLines ?? 0)) {
|
|
671
|
+
if (firstLine === undefined) {
|
|
672
|
+
firstLine = getEntriesFromCsvLine(text, separator, quote, comment);
|
|
673
|
+
firstLineNumber = lineNumber;
|
|
674
|
+
}
|
|
675
|
+
if (!header || lineNumber > firstLineNumber) {
|
|
676
|
+
rowCount++;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
const allLines = (0, arguments_1.parseRequestContent)(request, parseLine, info.ctx.config.abstractInterpretation.dataFrame.readLoadedData.maxReadLines);
|
|
681
|
+
let colnames;
|
|
682
|
+
if (header) {
|
|
683
|
+
colnames = (0, arguments_1.filterValidNames)(firstLine, checkNames, noDupNames, params.noEmptyNames);
|
|
684
|
+
}
|
|
685
|
+
else if (firstLine !== undefined) {
|
|
686
|
+
colnames = Array(firstLine.length).fill(undefined);
|
|
687
|
+
}
|
|
688
|
+
return [{
|
|
689
|
+
operation: 'read',
|
|
690
|
+
operand: undefined,
|
|
691
|
+
source,
|
|
692
|
+
colnames,
|
|
693
|
+
rows: allLines ? rowCount : [rowCount, Infinity]
|
|
694
|
+
}];
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Maps a function adding columns to a data frame, such as `cbind(df, id = 1:5)`, to abstract data frame operations.
|
|
698
|
+
*/
|
|
699
|
+
function mapDataFrameColBind(args, params, ctx, info) {
|
|
700
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
701
|
+
const dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, ctx));
|
|
702
|
+
if (dataFrame === undefined) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
else if (args.length === 1) {
|
|
706
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
707
|
+
}
|
|
708
|
+
const result = [];
|
|
709
|
+
let operand = dataFrame.value;
|
|
710
|
+
let colnames = [];
|
|
711
|
+
for (const arg of args) {
|
|
712
|
+
if (arg !== dataFrame && r_argument_1.RArgument.isNotEmpty(arg)) {
|
|
713
|
+
const otherDataFrame = ctx.getAbstractValue(arg.value);
|
|
714
|
+
if (otherDataFrame !== undefined) {
|
|
715
|
+
result.push({
|
|
716
|
+
operation: 'concatCols',
|
|
717
|
+
operand: operand?.info.id,
|
|
718
|
+
other: otherDataFrame
|
|
719
|
+
});
|
|
720
|
+
operand = undefined;
|
|
721
|
+
// added columns are top if argument cannot be resolved to constant (vector-like) value
|
|
722
|
+
}
|
|
723
|
+
else if (resolve_helper_1.Resolve.argument.value(arg, info) !== undefined) {
|
|
724
|
+
const colname = resolve_helper_1.Resolve.argument.toName(arg, info);
|
|
725
|
+
colnames?.push(colname);
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
colnames = undefined;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (colnames === undefined || colnames.length > 0) {
|
|
733
|
+
result.push({
|
|
734
|
+
operation: 'addCols',
|
|
735
|
+
operand: operand?.info.id,
|
|
736
|
+
colnames
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
return result;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Maps a function adding rows to a data frame, such as `rbind(df, c(1, "A"))`, to abstract data frame operations.
|
|
743
|
+
*/
|
|
744
|
+
function mapDataFrameRowBind(args, params, ctx, info) {
|
|
745
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
746
|
+
const dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, ctx));
|
|
747
|
+
if (dataFrame === undefined) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
else if (args.length === 1) {
|
|
751
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
752
|
+
}
|
|
753
|
+
const result = [];
|
|
754
|
+
let operand = dataFrame.value;
|
|
755
|
+
let rows = 0;
|
|
756
|
+
for (const arg of args) {
|
|
757
|
+
if (arg !== dataFrame && r_argument_1.RArgument.isNotEmpty(arg)) {
|
|
758
|
+
const otherDataFrame = ctx.getAbstractValue(arg.value);
|
|
759
|
+
if (otherDataFrame !== undefined) {
|
|
760
|
+
result.push({
|
|
761
|
+
operation: 'concatRows',
|
|
762
|
+
operand: operand?.info.id,
|
|
763
|
+
other: otherDataFrame
|
|
764
|
+
});
|
|
765
|
+
operand = undefined;
|
|
766
|
+
// number of added rows is top if arguments cannot be resolved to constant (vector-like) value
|
|
767
|
+
}
|
|
768
|
+
else if (resolve_helper_1.Resolve.argument.value(arg, info) !== undefined) {
|
|
769
|
+
rows = rows !== undefined ? rows + 1 : undefined;
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
rows = undefined;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (rows === undefined || rows > 0) {
|
|
777
|
+
result.push({
|
|
778
|
+
operation: 'addRows',
|
|
779
|
+
operand: operand?.info.id,
|
|
780
|
+
rows
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
return result;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Maps a function returning the first or last rows of a data frame, such as `head(df, 3)` or `tail(df, 3)`, to abstract data frame operations.
|
|
787
|
+
*/
|
|
788
|
+
function mapDataFrameHeadTail(args, params, ctx, info) {
|
|
789
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
790
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
const result = [];
|
|
794
|
+
const amount = (0, arguments_1.getArgumentValue)(args, params.amount, info);
|
|
795
|
+
let rows = undefined;
|
|
796
|
+
let cols = undefined;
|
|
797
|
+
if (typeof amount === 'number') {
|
|
798
|
+
rows = amount;
|
|
799
|
+
}
|
|
800
|
+
else if (Array.isArray(amount) && amount.length <= 2 && amount.every(value => typeof value === 'number')) {
|
|
801
|
+
rows = amount[0];
|
|
802
|
+
cols = amount[1];
|
|
803
|
+
}
|
|
804
|
+
const amountOfRows = rows !== undefined ? wholeAmount(rows, params.fromEnd) : undefined;
|
|
805
|
+
if (rows !== undefined && rows < 0) {
|
|
806
|
+
result.push({ operation: 'removeRows', operand: dataFrame.value.info.id, rows: amountOfRows });
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
/* `head`/`tail` take what the frame has, so asking for more than it holds is not asking for `NA` rows */
|
|
810
|
+
result.push({ operation: 'subsetRows', operand: dataFrame.value.info.id, rows: amountOfRows, options: { atMost: true } });
|
|
811
|
+
}
|
|
812
|
+
if (cols !== undefined) {
|
|
813
|
+
result.push({
|
|
814
|
+
operation: cols >= 0 ? 'subsetCols' : 'removeCols',
|
|
815
|
+
operand: undefined,
|
|
816
|
+
colnames: unnamedColumns(wholeAmount(cols, params.fromEnd))
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
return result;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* How many entries `head`/`tail` keep or drop for a fractional count. R rounds differently on each side: `head`
|
|
823
|
+
* takes the floor of what it keeps and the ceiling of what it drops, while `tail` rounds either way (`fromEnd`).
|
|
824
|
+
*/
|
|
825
|
+
function wholeAmount(amount, fromEnd) {
|
|
826
|
+
const size = Math.abs(amount);
|
|
827
|
+
if (fromEnd) {
|
|
828
|
+
return amount < 0 ? Math.floor(size) : Math.round(size);
|
|
829
|
+
}
|
|
830
|
+
return amount < 0 ? Math.ceil(size) : Math.floor(size);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* The most columns an answer names one by one. A count comes out of the analyzed source, so it may say anything
|
|
834
|
+
* at all -- `head(df, c(2, 2e9))` asks for two billion -- and no answer is worth the memory of writing that out.
|
|
835
|
+
*/
|
|
836
|
+
const MaxNamedColumns = 4096;
|
|
837
|
+
/**
|
|
838
|
+
* The `count` columns an operation names without knowing what they are called, or `undefined` when there are more
|
|
839
|
+
* of them than {@link MaxNamedColumns}, which widens the answer instead of allocating for it.
|
|
840
|
+
*/
|
|
841
|
+
function unnamedColumns(count) {
|
|
842
|
+
return Number.isSafeInteger(count) && count >= 0 && count <= MaxNamedColumns ? Array(count).fill(undefined) : undefined;
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Maps a function subsetting the rows and columns of a data frame, such as `subset(df, id > 1, select = c(id, name))`, to abstract data frame operations.
|
|
846
|
+
*/
|
|
847
|
+
function mapDataFrameSubset(args, params, ctx, info) {
|
|
848
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
849
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
else if (args.length === 1) {
|
|
853
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
854
|
+
}
|
|
855
|
+
const result = [];
|
|
856
|
+
let operand = dataFrame.value;
|
|
857
|
+
const filterArg = (0, arguments_1.getFunctionArgument)(args, params.subset, info);
|
|
858
|
+
const filterValue = resolve_helper_1.Resolve.argument.value(filterArg, info);
|
|
859
|
+
const selectArg = (0, arguments_1.getFunctionArgument)(args, params.select, info);
|
|
860
|
+
const dropArg = (0, arguments_1.getFunctionArgument)(args, params.drop, info);
|
|
861
|
+
const condition = typeof filterValue === 'boolean' ? filterValue : undefined;
|
|
862
|
+
const filterNames = (0, arguments_1.getUnresolvedSymbolsInExpression)(filterArg, info.graph);
|
|
863
|
+
const { selectedCols, unselectedCols } = getSelectedColumns([selectArg], info);
|
|
864
|
+
const accessedCols = [...filterNames, ...selectedCols ?? [], ...unselectedCols ?? []];
|
|
865
|
+
const mixedAccess = accessedCols.some(isColName) && accessedCols.some(isIndex);
|
|
866
|
+
const duplicateCols = accessedCols.some((col, index, list) => col !== undefined && list.indexOf(col) !== index);
|
|
867
|
+
if (accessedCols.some(isColName)) {
|
|
868
|
+
result.push({
|
|
869
|
+
operation: 'accessCols',
|
|
870
|
+
operand: operand?.info.id,
|
|
871
|
+
columns: accessedCols.filter(isColName)
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
if (accessedCols.some(isIndex)) {
|
|
875
|
+
result.push({
|
|
876
|
+
operation: 'accessCols',
|
|
877
|
+
operand: operand?.info.id,
|
|
878
|
+
columns: accessedCols.filter(isIndex).map(Math.abs)
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
if (filterArg !== undefined && r_argument_1.RArgument.isNotEmpty(filterArg)) {
|
|
882
|
+
result.push({
|
|
883
|
+
operation: 'filterRows',
|
|
884
|
+
operand: operand?.info.id,
|
|
885
|
+
condition: condition
|
|
886
|
+
});
|
|
887
|
+
operand = undefined;
|
|
888
|
+
}
|
|
889
|
+
if (dropArg === undefined || accessedCols.length > 1) {
|
|
890
|
+
if (unselectedCols === undefined || unselectedCols.length > 0) {
|
|
891
|
+
result.push({
|
|
892
|
+
operation: 'removeCols',
|
|
893
|
+
operand: operand?.info.id,
|
|
894
|
+
colnames: unselectedCols?.map(toColName)
|
|
895
|
+
});
|
|
896
|
+
operand = undefined;
|
|
897
|
+
}
|
|
898
|
+
if (selectedCols === undefined || selectedCols.length > 0) {
|
|
899
|
+
result.push({
|
|
900
|
+
operation: 'subsetCols',
|
|
901
|
+
operand: operand?.info.id,
|
|
902
|
+
colnames: selectedCols?.map(toColName),
|
|
903
|
+
...(duplicateCols || mixedAccess ? { options: { duplicateCols: true } } : {})
|
|
904
|
+
});
|
|
905
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
906
|
+
operand = undefined;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return result;
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Maps a function filtering the rows of a data frame, such as `filter(df, id > 1)`, to abstract data frame operations.
|
|
913
|
+
*/
|
|
914
|
+
function mapDataFrameFilter(args, params, ctx, info) {
|
|
915
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
916
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
917
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
else if (args.length === 1) {
|
|
921
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
922
|
+
}
|
|
923
|
+
const result = [];
|
|
924
|
+
const filterArgs = args.filter(arg => arg !== dataFrame);
|
|
925
|
+
const filterValues = filterArgs.map(arg => resolve_helper_1.Resolve.argument.value(arg, info));
|
|
926
|
+
const accessedNames = filterArgs.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph));
|
|
927
|
+
const condition = filterValues.every(value => typeof value === 'boolean') ? filterValues.every(Boolean) : undefined;
|
|
928
|
+
if (accessedNames.length > 0) {
|
|
929
|
+
result.push({
|
|
930
|
+
operation: 'accessCols',
|
|
931
|
+
operand: dataFrame.value.info.id,
|
|
932
|
+
columns: accessedNames
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
result.push({
|
|
936
|
+
operation: 'filterRows',
|
|
937
|
+
operand: dataFrame.value.info.id,
|
|
938
|
+
condition: condition
|
|
939
|
+
});
|
|
940
|
+
return result;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Maps a function selecting the columns of a data frame, such as `select(df, id, name)` or `select(df, -id)`, to abstract data frame operations.
|
|
944
|
+
*/
|
|
945
|
+
function mapDataFrameSelect(args, params, ctx, info) {
|
|
946
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
947
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
948
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
const result = [];
|
|
952
|
+
let operand = dataFrame.value;
|
|
953
|
+
const selectArgs = args.filter(arg => arg !== dataFrame);
|
|
954
|
+
let { selectedCols, unselectedCols } = getSelectedColumns(selectArgs, info);
|
|
955
|
+
const accessedCols = [...selectedCols ?? [], ...unselectedCols ?? []];
|
|
956
|
+
const mixedAccess = accessedCols.some(isColName) && accessedCols.some(isIndex);
|
|
957
|
+
const duplicateAccess = accessedCols.some((col, _, list) => col !== undefined && list.filter(other => other === col).length > 1);
|
|
958
|
+
const renamedCols = selectArgs.some(r_argument_1.RArgument.isNamed);
|
|
959
|
+
// map to top if columns are selected mixed by string and number, or are selected duplicate
|
|
960
|
+
if (mixedAccess || duplicateAccess) {
|
|
961
|
+
selectedCols = undefined;
|
|
962
|
+
unselectedCols = [];
|
|
963
|
+
}
|
|
964
|
+
if (accessedCols.some(isColName)) {
|
|
965
|
+
result.push({
|
|
966
|
+
operation: 'accessCols',
|
|
967
|
+
operand: operand?.info.id,
|
|
968
|
+
columns: accessedCols.filter(isColName)
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
if (accessedCols.some(isIndex)) {
|
|
972
|
+
result.push({
|
|
973
|
+
operation: 'accessCols',
|
|
974
|
+
operand: operand?.info.id,
|
|
975
|
+
columns: accessedCols.filter(isIndex).map(Math.abs)
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
if (unselectedCols === undefined || unselectedCols.length > 0) {
|
|
979
|
+
result.push({
|
|
980
|
+
operation: 'removeCols',
|
|
981
|
+
operand: operand?.info.id,
|
|
982
|
+
colnames: unselectedCols?.map(toColName)
|
|
983
|
+
});
|
|
984
|
+
operand = undefined;
|
|
985
|
+
}
|
|
986
|
+
if (selectedCols === undefined || selectedCols.length > 0 || unselectedCols?.length === 0) {
|
|
987
|
+
result.push({
|
|
988
|
+
operation: 'subsetCols',
|
|
989
|
+
operand: operand?.info.id,
|
|
990
|
+
colnames: selectedCols?.map(toColName),
|
|
991
|
+
...(renamedCols ? { options: { renamedCols: true } } : {})
|
|
992
|
+
});
|
|
993
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
994
|
+
operand = undefined;
|
|
995
|
+
}
|
|
996
|
+
return result;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Maps a function creating, modifying, or deleting the columns of a data frame, such as `mutate(df, id = id + 1)` or `transform(df, id = NULL)`, to abstract data frame operations.
|
|
1000
|
+
*/
|
|
1001
|
+
function mapDataFrameMutate(args, params, ctx, info) {
|
|
1002
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
1003
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1004
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
else if (args.length === 1) {
|
|
1008
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
1009
|
+
}
|
|
1010
|
+
const result = [];
|
|
1011
|
+
let operand = dataFrame.value;
|
|
1012
|
+
const mutateArgs = args.filter(arg => arg !== dataFrame);
|
|
1013
|
+
let deletedCols = mutateArgs
|
|
1014
|
+
.filter(arguments_1.isRNull)
|
|
1015
|
+
.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
1016
|
+
let mutatedCols = mutateArgs
|
|
1017
|
+
.filter(arg => !(0, arguments_1.isRNull)(arg))
|
|
1018
|
+
.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
1019
|
+
// only column names that are not created by mutation are preconditions on the operand
|
|
1020
|
+
const accessedNames = mutateArgs
|
|
1021
|
+
.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph))
|
|
1022
|
+
.filter(arg => !mutatedCols?.includes(arg));
|
|
1023
|
+
deletedCols = (0, arguments_1.filterValidNames)(deletedCols, params.checkNames, params.noDupNames, undefined, true);
|
|
1024
|
+
mutatedCols = (0, arguments_1.filterValidNames)(mutatedCols, params.checkNames, params.noDupNames, undefined, true);
|
|
1025
|
+
if (accessedNames.length > 0) {
|
|
1026
|
+
result.push({
|
|
1027
|
+
operation: 'accessCols',
|
|
1028
|
+
operand: operand?.info.id,
|
|
1029
|
+
columns: accessedNames
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
if (mutatedCols === undefined || mutatedCols.length > 0 || deletedCols?.length === 0) {
|
|
1033
|
+
result.push({
|
|
1034
|
+
operation: 'mutateCols',
|
|
1035
|
+
operand: operand?.info.id,
|
|
1036
|
+
colnames: mutatedCols
|
|
1037
|
+
});
|
|
1038
|
+
operand = undefined;
|
|
1039
|
+
}
|
|
1040
|
+
if (deletedCols === undefined || deletedCols.length > 0) {
|
|
1041
|
+
result.push({
|
|
1042
|
+
operation: 'removeCols',
|
|
1043
|
+
operand: operand?.info.id,
|
|
1044
|
+
colnames: deletedCols,
|
|
1045
|
+
options: { maybe: true }
|
|
1046
|
+
});
|
|
1047
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
1048
|
+
operand = undefined;
|
|
1049
|
+
}
|
|
1050
|
+
return result;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Maps a function grouping the rows of a data frame by columns, such as `group_by(df, id)`, to abstract data frame operations.
|
|
1054
|
+
*/
|
|
1055
|
+
function mapDataFrameGroupBy(args, params, ctx, info) {
|
|
1056
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
1057
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1058
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
else if (args.length === 1) {
|
|
1062
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
1063
|
+
}
|
|
1064
|
+
const result = [];
|
|
1065
|
+
const byArgs = args.filter(arg => arg !== dataFrame);
|
|
1066
|
+
const accessedNames = byArgs.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph));
|
|
1067
|
+
const byNames = byArgs.map(arg => r_argument_1.RArgument.isNamed(arg) ? resolve_helper_1.Resolve.argument.toName(arg, info) : resolve_helper_1.Resolve.argument.symbolName(arg, info));
|
|
1068
|
+
const mutatedCols = byArgs.some(r_argument_1.RArgument.isNamed) || byNames.some(assert_1.isUndefined);
|
|
1069
|
+
if (accessedNames.length > 0) {
|
|
1070
|
+
result.push({
|
|
1071
|
+
operation: 'accessCols',
|
|
1072
|
+
operand: dataFrame.value.info.id,
|
|
1073
|
+
columns: accessedNames
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
result.push({
|
|
1077
|
+
operation: 'groupBy',
|
|
1078
|
+
operand: dataFrame.value.info.id,
|
|
1079
|
+
by: byNames,
|
|
1080
|
+
...(mutatedCols ? { options: { mutatedCols: true } } : {})
|
|
1081
|
+
});
|
|
1082
|
+
return result;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Maps a function summarizing the columns of a data frame, such as `summarize(df, mean = mean(score))`, to abstract data frame operations.
|
|
1086
|
+
*/
|
|
1087
|
+
function mapDataFrameSummarize(args, params, ctx, info) {
|
|
1088
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
1089
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1090
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const result = [];
|
|
1094
|
+
const summarizeArgs = args.filter(arg => arg !== dataFrame);
|
|
1095
|
+
const summarizedCols = summarizeArgs.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
1096
|
+
// only column names that are not created by summarize are preconditions on the operand
|
|
1097
|
+
const accessedNames = summarizeArgs
|
|
1098
|
+
.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph))
|
|
1099
|
+
.filter(arg => !summarizedCols.includes(arg));
|
|
1100
|
+
if (accessedNames.length > 0) {
|
|
1101
|
+
result.push({
|
|
1102
|
+
operation: 'accessCols',
|
|
1103
|
+
operand: dataFrame.value.info.id,
|
|
1104
|
+
columns: accessedNames
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
result.push({
|
|
1108
|
+
operation: 'summarize',
|
|
1109
|
+
operand: dataFrame.value.info.id,
|
|
1110
|
+
colnames: summarizedCols
|
|
1111
|
+
});
|
|
1112
|
+
return result;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Maps a function joining two data frames, such as `left_join(df1, df2, by = "id")` or `merge(df1, df2)`, to abstract data frame operations.
|
|
1116
|
+
*/
|
|
1117
|
+
function mapDataFrameJoin(args, params, ctx, info) {
|
|
1118
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1119
|
+
const joinAll = (0, arguments_1.getArgumentValue)(args, params.joinAll, info);
|
|
1120
|
+
const joinLeft = (0, arguments_1.getArgumentValue)(args, params.joinLeft, info);
|
|
1121
|
+
const joinRight = (0, arguments_1.getArgumentValue)(args, params.joinRight, info);
|
|
1122
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
else if (args.length === 1) {
|
|
1126
|
+
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
1127
|
+
}
|
|
1128
|
+
else if (typeof joinAll !== 'boolean' || typeof joinLeft !== 'boolean' || typeof joinRight !== 'boolean') {
|
|
1129
|
+
return [{ operation: 'unknown', operand: dataFrame.value.info.id }];
|
|
1130
|
+
}
|
|
1131
|
+
const result = [];
|
|
1132
|
+
const otherArg = (0, arguments_1.getFunctionArgument)(args, params.otherDataFrame, info);
|
|
1133
|
+
const byArg = (0, arguments_1.getFunctionArgument)(args, params.by, info);
|
|
1134
|
+
const otherDataFrame = ctx.getAbstractValue(otherArg) ?? dataframe_domain_1.DataFrameDomain.top(info.ctx.config.abstractInterpretation.dataFrame.maxColNames);
|
|
1135
|
+
let byCols;
|
|
1136
|
+
const joinType = getJoinType(joinAll, joinLeft, joinRight);
|
|
1137
|
+
if (byArg !== undefined) {
|
|
1138
|
+
const byValue = resolve_helper_1.Resolve.argument.value(byArg, info);
|
|
1139
|
+
if (isColName(byValue) || isIndex(byValue)) {
|
|
1140
|
+
byCols = [byValue];
|
|
1141
|
+
}
|
|
1142
|
+
else if (Array.isArray(byValue) && (byValue.every(isColName) || byValue.every(isIndex))) {
|
|
1143
|
+
byCols = byValue;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (byCols?.some(isColName)) {
|
|
1147
|
+
result.push({
|
|
1148
|
+
operation: 'accessCols',
|
|
1149
|
+
operand: dataFrame.value.info.id,
|
|
1150
|
+
columns: byCols.filter(isColName)
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
if (byCols?.some(isIndex)) {
|
|
1154
|
+
result.push({
|
|
1155
|
+
operation: 'accessCols',
|
|
1156
|
+
operand: dataFrame.value.info.id,
|
|
1157
|
+
columns: byCols.filter(isIndex)
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
result.push({
|
|
1161
|
+
operation: 'join',
|
|
1162
|
+
operand: dataFrame.value.info.id,
|
|
1163
|
+
other: otherDataFrame,
|
|
1164
|
+
by: byCols?.map(toColName),
|
|
1165
|
+
options: { join: joinType, natural: byArg === undefined }
|
|
1166
|
+
});
|
|
1167
|
+
return result;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Maps a function that does not change the shape of a data frame, such as `relocate(df, id)` or `arrange(df, id)`, to abstract data frame operations.
|
|
1171
|
+
*/
|
|
1172
|
+
function mapDataFrameIdentity(args, params, ctx, info) {
|
|
1173
|
+
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
1174
|
+
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1175
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
else if (params.disallowNamedArgs && args.some(r_argument_1.RArgument.isNamed)) {
|
|
1179
|
+
return [{ operation: 'unknown', operand: dataFrame.value.info.id }];
|
|
1180
|
+
}
|
|
1181
|
+
return [{
|
|
1182
|
+
operation: 'identity',
|
|
1183
|
+
operand: dataFrame.value.info.id
|
|
1184
|
+
}];
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Maps a function that is not explicitly supported but returns or modifies a data frame, such as `na.omit(df)` or `setNames(df, "id")`, to abstract data frame operations.
|
|
1188
|
+
*/
|
|
1189
|
+
function mapDataFrameUnknown(args, params, ctx, info) {
|
|
1190
|
+
let dataFrame;
|
|
1191
|
+
if (params.dataFrame !== undefined) {
|
|
1192
|
+
dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
1193
|
+
}
|
|
1194
|
+
else {
|
|
1195
|
+
dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, ctx));
|
|
1196
|
+
}
|
|
1197
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
return [{
|
|
1201
|
+
operation: 'unknown',
|
|
1202
|
+
operand: dataFrame.value.info.id,
|
|
1203
|
+
...(params.constraintType !== undefined ? { type: params.constraintType } : {})
|
|
1204
|
+
}];
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Maps a data frame access operation, such as `df$id`, `df["id"]`, or `df[1, 2]`, to abstract data frame operations.
|
|
1208
|
+
*/
|
|
1209
|
+
function mapDataFrameAccess(access, ctx, info) {
|
|
1210
|
+
if (r_access_1.RAccess.isNamed(access)) {
|
|
1211
|
+
return mapDataFrameNamedColumnAccess(access, ctx, info);
|
|
1212
|
+
}
|
|
1213
|
+
else {
|
|
1214
|
+
return mapDataFrameIndexColRowAccess(access, ctx, info);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Maps a string-based access of a data frame column, such as `df$id`, to abstract data frame operations.
|
|
1219
|
+
*/
|
|
1220
|
+
function mapDataFrameNamedColumnAccess(access, ctx, info) {
|
|
1221
|
+
const dataFrame = access.accessed;
|
|
1222
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
const colname = resolve_helper_1.Resolve.argument.symbolName(access.access[0], info);
|
|
1226
|
+
return [{
|
|
1227
|
+
operation: 'accessCols',
|
|
1228
|
+
operand: dataFrame.info.id,
|
|
1229
|
+
columns: colname ? [colname] : undefined
|
|
1230
|
+
}];
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Maps an index-based access of the rows and columns of a data frame, such as `df[1, ]` or `df[["id"]]`, to abstract data frame operations.
|
|
1234
|
+
*/
|
|
1235
|
+
function mapDataFrameIndexColRowAccess(access, ctx, info) {
|
|
1236
|
+
const dataFrame = access.accessed;
|
|
1237
|
+
const drop = (0, arguments_1.getArgumentValue)(access.access, 'drop', info);
|
|
1238
|
+
const exact = (0, arguments_1.getArgumentValue)(access.access, 'exact', info);
|
|
1239
|
+
const args = access.access.filter(arg => r_argument_1.RArgument.isEmpty(arg) || r_argument_1.RArgument.isUnnamed(arg));
|
|
1240
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
else if (args.every(r_argument_1.RArgument.isEmpty)) {
|
|
1244
|
+
return [{ operation: 'identity', operand: dataFrame.info.id }];
|
|
1245
|
+
}
|
|
1246
|
+
const result = [];
|
|
1247
|
+
const rowArg = args.length < 2 ? undefined : args[0];
|
|
1248
|
+
const colArg = args.length < 2 ? args[0] : args[1];
|
|
1249
|
+
let rows = undefined;
|
|
1250
|
+
let columns = undefined;
|
|
1251
|
+
if (rowArg !== undefined && r_argument_1.RArgument.isNotEmpty(rowArg)) {
|
|
1252
|
+
const rowValue = resolve_helper_1.Resolve.argument.value(rowArg, info);
|
|
1253
|
+
if (isIndex(rowValue)) {
|
|
1254
|
+
rows = [rowValue];
|
|
1255
|
+
}
|
|
1256
|
+
else if (Array.isArray(rowValue) && rowValue.every(isIndex)) {
|
|
1257
|
+
rows = rowValue;
|
|
1258
|
+
}
|
|
1259
|
+
result.push({
|
|
1260
|
+
operation: 'accessRows',
|
|
1261
|
+
operand: dataFrame.info.id,
|
|
1262
|
+
rows: rows?.map(Math.abs)
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
if (colArg !== undefined && r_argument_1.RArgument.isNotEmpty(colArg)) {
|
|
1266
|
+
const colValue = resolve_helper_1.Resolve.argument.value(colArg, info);
|
|
1267
|
+
if (isIndex(colValue)) {
|
|
1268
|
+
columns = [colValue];
|
|
1269
|
+
}
|
|
1270
|
+
else if (isColName(colValue) && exact !== false) {
|
|
1271
|
+
columns = [colValue];
|
|
1272
|
+
}
|
|
1273
|
+
else if (Array.isArray(colValue) && colValue.every(isIndex)) {
|
|
1274
|
+
columns = colValue;
|
|
1275
|
+
}
|
|
1276
|
+
else if (Array.isArray(colValue) && colValue.every(isColName) && exact !== false) {
|
|
1277
|
+
columns = colValue;
|
|
1278
|
+
}
|
|
1279
|
+
result.push({
|
|
1280
|
+
operation: 'accessCols',
|
|
1281
|
+
operand: dataFrame.info.id,
|
|
1282
|
+
columns: columns?.every(isIndex) ? columns.map(Math.abs) : columns
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
// The data frame extent is dropped if the operator `[[` is used, the argument `drop` is true, or only one column is accessed
|
|
1286
|
+
const dropExtent = access.operator === '[[' ? true :
|
|
1287
|
+
args.length === 2 && typeof drop === 'boolean' ? drop :
|
|
1288
|
+
rowArg !== undefined && columns?.length === 1 && (isColName(columns[0]) || columns[0] > 0);
|
|
1289
|
+
if (!dropExtent) {
|
|
1290
|
+
const rowSubset = rows === undefined || rows.every(row => row >= 0);
|
|
1291
|
+
const colSubset = columns === undefined || columns.every(col => isColName(col) || col >= 0);
|
|
1292
|
+
const rowZero = rows?.length === 1 && rows[0] === 0;
|
|
1293
|
+
const colZero = columns?.length === 1 && columns[0] === 0;
|
|
1294
|
+
const duplicateCols = columns?.some((col, index, list) => list.indexOf(col) !== index);
|
|
1295
|
+
let operand = dataFrame;
|
|
1296
|
+
if (rowArg !== undefined && r_argument_1.RArgument.isNotEmpty(rowArg)) {
|
|
1297
|
+
if (rowSubset) {
|
|
1298
|
+
result.push({
|
|
1299
|
+
operation: 'subsetRows',
|
|
1300
|
+
operand: operand?.info.id,
|
|
1301
|
+
rows: rowZero ? 0 : rows?.filter(index => index !== 0).length
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
else {
|
|
1305
|
+
result.push({
|
|
1306
|
+
operation: 'removeRows',
|
|
1307
|
+
operand: operand?.info.id,
|
|
1308
|
+
rows: rowZero ? 0 : rows?.filter(index => index !== 0).length,
|
|
1309
|
+
/* R drops nothing for an index beyond the extent, so the semantics has to know how far they reach */
|
|
1310
|
+
maxIndex: rows !== undefined ? Math.max(...rows.map(Math.abs)) : undefined
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
operand = undefined;
|
|
1314
|
+
}
|
|
1315
|
+
if (colArg !== undefined && r_argument_1.RArgument.isNotEmpty(colArg)) {
|
|
1316
|
+
if (colSubset) {
|
|
1317
|
+
result.push({
|
|
1318
|
+
operation: 'subsetCols',
|
|
1319
|
+
operand: operand?.info.id,
|
|
1320
|
+
colnames: colZero ? [] : columns?.map(toColName),
|
|
1321
|
+
...(duplicateCols ? { options: { duplicateCols: true } } : {})
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
else {
|
|
1325
|
+
result.push({
|
|
1326
|
+
operation: 'removeCols',
|
|
1327
|
+
operand: operand?.info.id,
|
|
1328
|
+
colnames: columns?.map(toColName),
|
|
1329
|
+
maxIndex: columns?.every(isIndex) ? Math.max(...columns.map(Math.abs)) : undefined
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
1333
|
+
operand = undefined;
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
return result;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Maps an assignment to a data frame access, such as `df$id <- 1:5`, `df[] <- NULL`, or `df[1, 2] <- 0`, to abstract data frame operations.
|
|
1340
|
+
*/
|
|
1341
|
+
function mapDataFrameAccessAssignment(node, expression, ctx, info) {
|
|
1342
|
+
if (!r_access_1.RAccess.is(node)) {
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
else if (r_access_1.RAccess.isNamed(node)) {
|
|
1346
|
+
return mapDataFrameNamedColumnAssignment(node, expression, ctx, info);
|
|
1347
|
+
}
|
|
1348
|
+
else if (node.access.every(r_argument_1.RArgument.isEmpty)) {
|
|
1349
|
+
return mapDataFrameContentAssignment(node, expression, ctx);
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
return mapDataFrameIndexColRowAssignment(node, expression, ctx, info);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Maps an assignment to the content of a data frame, such as `df[] <- NULL`, to abstract data frame operations.
|
|
1357
|
+
*/
|
|
1358
|
+
function mapDataFrameContentAssignment(access, expression, ctx) {
|
|
1359
|
+
const dataFrame = access.accessed;
|
|
1360
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
if ((0, arguments_1.isRNull)(expression)) {
|
|
1364
|
+
return [{
|
|
1365
|
+
operation: 'subsetCols',
|
|
1366
|
+
operand: dataFrame.info.id,
|
|
1367
|
+
colnames: [],
|
|
1368
|
+
type: semantics_1.ConstraintType.OperandModification
|
|
1369
|
+
}];
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
return [{
|
|
1373
|
+
operation: 'identity',
|
|
1374
|
+
operand: dataFrame.info.id,
|
|
1375
|
+
type: semantics_1.ConstraintType.OperandModification
|
|
1376
|
+
}];
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Maps an assignment to a string-based access of a data frame column, such as `df$id <- 1:5`, to abstract data frame operations.
|
|
1381
|
+
*/
|
|
1382
|
+
function mapDataFrameNamedColumnAssignment(access, expression, ctx, info) {
|
|
1383
|
+
const dataFrame = access.accessed;
|
|
1384
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx)) {
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
const colname = resolve_helper_1.Resolve.argument.symbolName(access.access[0], info);
|
|
1388
|
+
if ((0, arguments_1.isRNull)(expression)) {
|
|
1389
|
+
return [{
|
|
1390
|
+
operation: 'removeCols',
|
|
1391
|
+
operand: dataFrame.info.id,
|
|
1392
|
+
colnames: colname ? [colname] : undefined,
|
|
1393
|
+
type: semantics_1.ConstraintType.OperandModification,
|
|
1394
|
+
options: { maybe: true }
|
|
1395
|
+
}];
|
|
1396
|
+
}
|
|
1397
|
+
else {
|
|
1398
|
+
return [{
|
|
1399
|
+
operation: 'assignCols',
|
|
1400
|
+
operand: dataFrame.info.id,
|
|
1401
|
+
columns: colname ? [colname] : undefined
|
|
1402
|
+
}];
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Maps an assignment to an index-based access of the rows and columns of a data frame, such as `df[1, 2] <- 0`, to abstract data frame operations.
|
|
1407
|
+
*/
|
|
1408
|
+
function mapDataFrameIndexColRowAssignment(access, expression, ctx, info) {
|
|
1409
|
+
const dataFrame = access.accessed;
|
|
1410
|
+
const args = access.access.filter(arg => r_argument_1.RArgument.isEmpty(arg) || r_argument_1.RArgument.isUnnamed(arg));
|
|
1411
|
+
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, ctx) || args.every(r_argument_1.RArgument.isEmpty)) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const result = [];
|
|
1415
|
+
const rowArg = args.length < 2 ? undefined : args[0];
|
|
1416
|
+
const colArg = args.length < 2 ? args[0] : args[1];
|
|
1417
|
+
if (rowArg !== undefined && r_argument_1.RArgument.isNotEmpty(rowArg)) {
|
|
1418
|
+
const rowValue = resolve_helper_1.Resolve.argument.value(rowArg, info);
|
|
1419
|
+
let rows = undefined;
|
|
1420
|
+
if (isIndex(rowValue)) {
|
|
1421
|
+
rows = [rowValue];
|
|
1422
|
+
}
|
|
1423
|
+
else if (Array.isArray(rowValue) && rowValue.every(isIndex)) {
|
|
1424
|
+
rows = rowValue;
|
|
1425
|
+
}
|
|
1426
|
+
result.push({
|
|
1427
|
+
operation: 'assignRows',
|
|
1428
|
+
operand: dataFrame.info.id,
|
|
1429
|
+
rows
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
if (colArg !== undefined && r_argument_1.RArgument.isNotEmpty(colArg)) {
|
|
1433
|
+
const colValue = resolve_helper_1.Resolve.argument.value(colArg, info);
|
|
1434
|
+
let columns = undefined;
|
|
1435
|
+
if (isColName(colValue)) {
|
|
1436
|
+
columns = [colValue];
|
|
1437
|
+
}
|
|
1438
|
+
else if (isIndex(colValue)) {
|
|
1439
|
+
columns = [colValue];
|
|
1440
|
+
}
|
|
1441
|
+
else if (Array.isArray(colValue) && (colValue.every(isColName) || colValue.every(isIndex))) {
|
|
1442
|
+
columns = colValue;
|
|
1443
|
+
}
|
|
1444
|
+
if ((0, arguments_1.isRNull)(expression)) {
|
|
1445
|
+
result.push({
|
|
1446
|
+
operation: 'removeCols',
|
|
1447
|
+
operand: dataFrame.info.id,
|
|
1448
|
+
colnames: columns?.map(toColName),
|
|
1449
|
+
type: semantics_1.ConstraintType.OperandModification,
|
|
1450
|
+
options: { maybe: true }
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
else {
|
|
1454
|
+
result.push({
|
|
1455
|
+
operation: 'assignCols',
|
|
1456
|
+
operand: dataFrame.info.id,
|
|
1457
|
+
columns
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
return result;
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Maps an assignment to the column names of a data frame, such as `colnames(df) <- c("id", "name")`, to abstract data frame operations.
|
|
1465
|
+
*/
|
|
1466
|
+
function mapDataFrameColNamesAssignment(node, expression, ctx, info) {
|
|
1467
|
+
const operand = getReplacementOperand(node, ctx);
|
|
1468
|
+
if (operand === undefined) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
const argument = info.idMap !== undefined ? (0, make_argument_1.toUnnamedArgument)(expression, info.idMap) : undefined;
|
|
1472
|
+
const assignedNames = resolve_helper_1.Resolve.argument.stringVector(argument, info);
|
|
1473
|
+
// the assignment is only partial if the replacement is nested in another replacement, such as `colnames(df)[1:2] <- ...`
|
|
1474
|
+
const parent = hasParentReplacement(node, ctx) ? ctx.getAstNode(node.info.parent) : undefined;
|
|
1475
|
+
return [{
|
|
1476
|
+
operation: 'setColNames',
|
|
1477
|
+
operand: operand.value.info.id,
|
|
1478
|
+
colnames: assignedNames,
|
|
1479
|
+
...(parent !== undefined ? { options: { partial: true } } : {})
|
|
1480
|
+
}];
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* Maps an assignment to the row names of a data frame, such as `rownames(df) <- c("a", "b")`, to abstract data frame operations.
|
|
1484
|
+
*/
|
|
1485
|
+
function mapDataFrameRowNamesAssignment(node, _expression, ctx) {
|
|
1486
|
+
const operand = getReplacementOperand(node, ctx);
|
|
1487
|
+
if (operand === undefined) {
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
return [{
|
|
1491
|
+
operation: 'identity',
|
|
1492
|
+
operand: operand.value.info.id,
|
|
1493
|
+
type: semantics_1.ConstraintType.OperandModification
|
|
1494
|
+
}];
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Maps an assignment to the dimension names of a data frame, such as `dimnames(df) <- list(NULL, c("id"))`, to abstract data frame operations.
|
|
1498
|
+
*/
|
|
1499
|
+
function mapDataFrameDimNamesAssignment(node, _expression, ctx) {
|
|
1500
|
+
const operand = getReplacementOperand(node, ctx);
|
|
1501
|
+
if (operand === undefined) {
|
|
1502
|
+
return;
|
|
1503
|
+
}
|
|
1504
|
+
return [{
|
|
1505
|
+
operation: 'setColNames',
|
|
1506
|
+
operand: operand.value.info.id,
|
|
1507
|
+
colnames: undefined
|
|
1508
|
+
}];
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Gets the data frame operand of a replacement function call, such as `df` in `colnames(df) <- "id"`.
|
|
1512
|
+
* @param node - The R node of the replacement function call
|
|
1513
|
+
* @param ctx - The context of the abstract interpretation analysis
|
|
1514
|
+
* @returns The argument of the data frame operand, or `undefined` if the call has no single argument that is a data frame
|
|
1515
|
+
*/
|
|
1516
|
+
function getReplacementOperand(node, ctx) {
|
|
1517
|
+
if (!r_function_call_1.RFunctionCall.isNamed(node) || node.arguments.length !== 1) {
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
const operand = node.arguments[0];
|
|
1521
|
+
return (0, arguments_1.isDataFrameArgument)(operand, ctx) ? operand : undefined;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Checks whether a replacement function call is nested in another replacement function call, such as `colnames(df)[1:2] <- ...`.
|
|
1525
|
+
*/
|
|
1526
|
+
function hasParentReplacement(node, ctx) {
|
|
1527
|
+
const parentVertex = ctx.getDfgVertex(node.info.parent);
|
|
1528
|
+
return vertex_1.FunctionCallVertex.hasOrigin(parentVertex, built_in_proc_name_1.BuiltInProcName.Replacement);
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Gets the source and the parse request of the file or text that is read by a data frame read function (see {@link mapDataFrameRead}).
|
|
1532
|
+
*/
|
|
1533
|
+
function getRequestFromRead(fileNameArg, textArg, params, info) {
|
|
1534
|
+
let source;
|
|
1535
|
+
let request;
|
|
1536
|
+
if (fileNameArg !== undefined && r_argument_1.RArgument.isNotEmpty(fileNameArg)) {
|
|
1537
|
+
const fileName = resolve_helper_1.Resolve.argument.value(fileNameArg, info);
|
|
1538
|
+
if (typeof fileName === 'string') {
|
|
1539
|
+
const text = (0, resolve_args_1.unescapeSpecialChars)(fileName);
|
|
1540
|
+
source = fileName;
|
|
1541
|
+
const referenceChain = fileNameArg.info.file ? [fileNameArg.info.file] : [];
|
|
1542
|
+
const sources = (0, built_in_source_1.findSource)(info.ctx.config.solver.resolveSource, fileName, { referenceChain, ctx: info.ctx });
|
|
1543
|
+
if (sources?.length === 1) {
|
|
1544
|
+
source = sources[0];
|
|
1545
|
+
// create request from resolved source file path
|
|
1546
|
+
request = { request: 'file', content: sources[0] };
|
|
1547
|
+
}
|
|
1548
|
+
else if (params.text === undefined && text.includes('\n')) {
|
|
1549
|
+
// create request from string if file name argument contains newline
|
|
1550
|
+
request = (0, retriever_1.requestFromInput)(text);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
else if (textArg !== undefined && r_argument_1.RArgument.isNotEmpty(textArg)) {
|
|
1555
|
+
const text = resolve_helper_1.Resolve.argument.value(textArg, info);
|
|
1556
|
+
if (typeof text === 'string') {
|
|
1557
|
+
request = (0, retriever_1.requestFromInput)((0, resolve_args_1.unescapeSpecialChars)(text));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
if (request?.request === 'file' && info.ctx.files.hasCached(request.content)) {
|
|
1561
|
+
request = info.ctx.files.resolveRequest(request).r;
|
|
1562
|
+
}
|
|
1563
|
+
return { source, request };
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Gets all entries from a line of a CSV file using a custom separator char, quote char, and comment char
|
|
1567
|
+
*/
|
|
1568
|
+
function getEntriesFromCsvLine(line, sep = ',', quote = '"', comment = '', trim = true) {
|
|
1569
|
+
sep = sep.length > 0 ? sep : '\\s'; // default to whitespace separator
|
|
1570
|
+
sep = (0, arguments_1.escapeRegExp)(sep, true); // only allow tokens like `\s`, `\t`, or `\n` in separator, quote, and comment chars
|
|
1571
|
+
quote = (0, arguments_1.escapeRegExp)(quote);
|
|
1572
|
+
comment = (0, arguments_1.escapeRegExp)(comment);
|
|
1573
|
+
const quantifier = sep === '\\s' ? '+' : '*'; // do not allow unquoted empty entries in whitespace-separated files
|
|
1574
|
+
const LineCommentRegex = new RegExp(`[${comment}].*`);
|
|
1575
|
+
const CsvEntryRegex = new RegExp(`(?<=^|[${sep}])(?:[${quote}]((?:[^${quote}]|[${quote}]{2})*)[${quote}]|([^${sep}]${quantifier}))`, 'g');
|
|
1576
|
+
const DoubleQuoteRegex = new RegExp(`([${quote}])\\1`, 'g'); // regex for doubled quotes like `""` or `''`
|
|
1577
|
+
return (comment ? line.replace(LineCommentRegex, '') : line)
|
|
1578
|
+
.matchAll(CsvEntryRegex)
|
|
1579
|
+
.map(match => match[1]?.replace(DoubleQuoteRegex, '$1') ?? match[2])
|
|
1580
|
+
.map(entry => trim ? entry.trim() : entry)
|
|
1581
|
+
.toArray();
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Resolves all selected columns in a select expression, such as `id`, `"id"`, `1`, `c(id, name)`, `c("id", "name")`, `1:2`, `-id`, `-1`, `-c(id, name)`, `c(-1, -2)`, etc.
|
|
1585
|
+
*/
|
|
1586
|
+
function getSelectedColumns(args, info) {
|
|
1587
|
+
let selectedCols = [];
|
|
1588
|
+
let unselectedCols = [];
|
|
1589
|
+
const joinColumns = (columns1, columns2) => columns1 !== undefined && columns2 !== undefined ? [...columns1, ...columns2] : undefined;
|
|
1590
|
+
for (const arg of args) {
|
|
1591
|
+
if (arg !== undefined && r_argument_1.RArgument.isNotEmpty(arg)) {
|
|
1592
|
+
if (r_function_call_1.RFunctionCall.isNamed(arg.value) && identifier_1.Identifier.getName(arg.value.functionName.content) === 'c') {
|
|
1593
|
+
const result = getSelectedColumns(arg.value.arguments, info);
|
|
1594
|
+
selectedCols = joinColumns(selectedCols, result.selectedCols);
|
|
1595
|
+
unselectedCols = joinColumns(unselectedCols, result.unselectedCols);
|
|
1596
|
+
}
|
|
1597
|
+
else if (r_unary_op_1.RUnaryOp.is(arg.value) && arg.value.operator === '+' && info.idMap !== undefined) {
|
|
1598
|
+
const result = getSelectedColumns([(0, make_argument_1.toUnnamedArgument)(arg.value.operand, info.idMap)], info);
|
|
1599
|
+
selectedCols = joinColumns(selectedCols, result.selectedCols);
|
|
1600
|
+
unselectedCols = joinColumns(unselectedCols, result.unselectedCols);
|
|
1601
|
+
}
|
|
1602
|
+
else if (r_unary_op_1.RUnaryOp.is(arg.value) && arg.value.operator === '-' && info.idMap !== undefined) {
|
|
1603
|
+
const result = getSelectedColumns([(0, make_argument_1.toUnnamedArgument)(arg.value.operand, info.idMap)], info);
|
|
1604
|
+
selectedCols = joinColumns(selectedCols, result.unselectedCols);
|
|
1605
|
+
unselectedCols = joinColumns(unselectedCols, result.selectedCols);
|
|
1606
|
+
}
|
|
1607
|
+
else if (r_binary_op_1.RBinaryOp.is(arg.value) && arg.value.operator === ':' && info.idMap !== undefined) {
|
|
1608
|
+
const values = resolve_helper_1.Resolve.argument.value((0, make_argument_1.toUnnamedArgument)(arg.value, info.idMap), { ...info, resolve: config_1.VariableResolve.Disabled });
|
|
1609
|
+
if (Array.isArray(values) && values.every(isIndex)) {
|
|
1610
|
+
selectedCols = joinColumns(selectedCols, values.filter(value => value >= 0));
|
|
1611
|
+
unselectedCols = joinColumns(unselectedCols, values.filter(value => value < 0).map(Math.abs));
|
|
1612
|
+
}
|
|
1613
|
+
else {
|
|
1614
|
+
selectedCols = undefined;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
else if (r_symbol_1.RSymbol.is(arg.value) || r_string_1.RString.is(arg.value)) {
|
|
1618
|
+
selectedCols?.push(resolve_helper_1.Resolve.argument.symbolName(arg, info));
|
|
1619
|
+
}
|
|
1620
|
+
else if (r_number_1.RNumber.is(arg.value)) {
|
|
1621
|
+
selectedCols?.push(arg.value.content.num);
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
selectedCols = undefined;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
return { selectedCols, unselectedCols };
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Gets the type of a join operation based on whether all rows of the left, the right, or both data frames are kept (see {@link mapDataFrameJoin}).
|
|
1632
|
+
*/
|
|
1633
|
+
function getJoinType(joinAll, joinLeft, joinRight) {
|
|
1634
|
+
if (joinAll || (joinLeft && joinRight)) {
|
|
1635
|
+
return 'full';
|
|
1636
|
+
}
|
|
1637
|
+
else if (joinLeft) {
|
|
1638
|
+
return 'left';
|
|
1639
|
+
}
|
|
1640
|
+
else if (joinRight) {
|
|
1641
|
+
return 'right';
|
|
1642
|
+
}
|
|
1643
|
+
else {
|
|
1644
|
+
return 'inner';
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
function isColName(value) {
|
|
1648
|
+
return typeof value === 'string';
|
|
1649
|
+
}
|
|
1650
|
+
function isIndex(value) {
|
|
1651
|
+
return typeof value === 'number';
|
|
1652
|
+
}
|
|
1653
|
+
function toColName(value) {
|
|
1654
|
+
return isColName(value) ? value : undefined;
|
|
1655
|
+
}
|
|
1656
|
+
//# sourceMappingURL=dataframe-semantics.js.map
|