@eagleoutice/flowr 2.14.4 → 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 -313
- package/dataflow/environments/default-builtin-config.js +803 -1012
- package/dataflow/environments/environment.d.ts +26 -49
- package/dataflow/environments/environment.js +34 -47
- package/dataflow/environments/group-generics.d.ts +11 -2
- package/dataflow/environments/group-generics.js +22 -3
- 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 +17 -5
- 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 +49 -4
- 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 +90 -26
- package/project/sigdb/schema.js +12 -6
- 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/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 +5 -10
- package/queries/catalog/signature-query/signature-query-executor.js +87 -93
- package/queries/catalog/signature-query/signature-query-format.d.ts +20 -5
- package/queries/catalog/signature-query/signature-query-format.js +16 -4
- package/queries/catalog/signature-query/signature-query-render.js +18 -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/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
|
@@ -1,1096 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapDataFrameFunctionCall = mapDataFrameFunctionCall;
|
|
4
|
-
const config_1 = require("../../../config");
|
|
5
|
-
const make_argument_1 = require("../../../dataflow/internal/process/functions/call/argument/make-argument");
|
|
6
|
-
const built_in_source_1 = require("../../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
7
|
-
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
8
|
-
const retriever_1 = require("../../../r-bridge/retriever");
|
|
9
|
-
const assert_1 = require("../../../util/assert");
|
|
10
|
-
const dataframe_domain_1 = require("../dataframe-domain");
|
|
11
|
-
const resolve_args_1 = require("../resolve-args");
|
|
12
|
-
const semantics_1 = require("../semantics");
|
|
13
|
-
const arguments_1 = require("./arguments");
|
|
14
|
-
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
15
|
-
const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
|
-
const resolve_helper_1 = require("../../../dataflow/environments/resolve-helper");
|
|
17
|
-
const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
18
|
-
const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
|
|
19
|
-
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
20
|
-
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
21
|
-
const r_unary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
|
|
22
|
-
const r_function_call_2 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
23
|
-
/**
|
|
24
|
-
* Represents the different types of data frames in R
|
|
25
|
-
*/
|
|
26
|
-
var DataFrameType;
|
|
27
|
-
(function (DataFrameType) {
|
|
28
|
-
DataFrameType["DataFrame"] = "data.frame";
|
|
29
|
-
DataFrameType["Tibble"] = "tibble";
|
|
30
|
-
DataFrameType["DataTable"] = "data.table";
|
|
31
|
-
})(DataFrameType || (DataFrameType = {}));
|
|
32
|
-
/**
|
|
33
|
-
* Mapper for mapping the supported concrete data frame functions to mapper functions,
|
|
34
|
-
* including information about the origin library of the functions and the type of the returned data frame.
|
|
35
|
-
*/
|
|
36
|
-
const DataFrameFunctionMapper = {
|
|
37
|
-
'data.frame': { mapper: mapDataFrameCreate, library: 'base', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
38
|
-
'as.data.frame': { mapper: mapDataFrameConvert, library: 'base', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
39
|
-
'read.table': { mapper: mapDataFrameRead, library: 'utils', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
40
|
-
'read.csv': { mapper: mapDataFrameRead, library: 'utils', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
41
|
-
'read.csv2': { mapper: mapDataFrameRead, library: 'utils', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
42
|
-
'read.delim': { mapper: mapDataFrameRead, library: 'utils', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
43
|
-
'read.delim2': { mapper: mapDataFrameRead, library: 'utils', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
44
|
-
'read_table': { mapper: mapDataFrameRead, library: 'readr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
45
|
-
'read_csv': { mapper: mapDataFrameRead, library: 'readr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
46
|
-
'read_csv2': { mapper: mapDataFrameRead, library: 'readr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
47
|
-
'read_tsv': { mapper: mapDataFrameRead, library: 'readr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
48
|
-
'read_delim': { mapper: mapDataFrameRead, library: 'readr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
49
|
-
'cbind': { mapper: mapDataFrameColBind, library: 'base', returnType: DataFrameType.DataFrame },
|
|
50
|
-
'rbind': { mapper: mapDataFrameRowBind, library: 'base', returnType: DataFrameType.DataFrame },
|
|
51
|
-
'head': { mapper: mapDataFrameHeadTail, library: 'utils', returnType: DataFrameType.DataFrame },
|
|
52
|
-
'tail': { mapper: mapDataFrameHeadTail, library: 'utils', returnType: DataFrameType.DataFrame },
|
|
53
|
-
'subset': { mapper: mapDataFrameSubset, library: 'base', returnType: DataFrameType.DataFrame },
|
|
54
|
-
'filter': { mapper: mapDataFrameFilter, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
55
|
-
'select': { mapper: mapDataFrameSelect, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
56
|
-
'mutate': { mapper: mapDataFrameMutate, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
57
|
-
'transform': { mapper: mapDataFrameMutate, library: 'base', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
58
|
-
'group_by': { mapper: mapDataFrameGroupBy, library: 'dplyr', returnType: DataFrameType.Tibble, alwaysDataFrame: true },
|
|
59
|
-
'summarise': { mapper: mapDataFrameSummarize, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
60
|
-
'summarize': { mapper: mapDataFrameSummarize, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
61
|
-
'inner_join': { mapper: mapDataFrameJoin, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
62
|
-
'left_join': { mapper: mapDataFrameJoin, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
63
|
-
'right_join': { mapper: mapDataFrameJoin, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
64
|
-
'full_join': { mapper: mapDataFrameJoin, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
65
|
-
'merge': { mapper: mapDataFrameJoin, library: 'base', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
66
|
-
'relocate': { mapper: mapDataFrameIdentity, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true },
|
|
67
|
-
'arrange': { mapper: mapDataFrameIdentity, library: 'dplyr', returnType: DataFrameType.DataFrame, alwaysDataFrame: true }
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* List of other data frame functions that are not explicitly supported but may return data frames.
|
|
71
|
-
*/
|
|
72
|
-
const OtherDataFrameFunctions = [
|
|
73
|
-
{
|
|
74
|
-
type: 'entry_point',
|
|
75
|
-
names: ['as.data.frame.matrix'], // S3 dispatch of `as.data.frame`
|
|
76
|
-
library: 'base',
|
|
77
|
-
returnType: DataFrameType.DataFrame
|
|
78
|
-
}, {
|
|
79
|
-
type: 'entry_point',
|
|
80
|
-
names: ['anova', 'AIC', 'BIC'],
|
|
81
|
-
library: 'anova',
|
|
82
|
-
returnType: DataFrameType.DataFrame
|
|
83
|
-
}, {
|
|
84
|
-
type: 'entry_point',
|
|
85
|
-
names: ['Anova', 'Manova'],
|
|
86
|
-
library: 'car',
|
|
87
|
-
returnType: DataFrameType.DataFrame
|
|
88
|
-
}, {
|
|
89
|
-
type: 'entry_point',
|
|
90
|
-
names: ['data_frame', 'as_data_frame'],
|
|
91
|
-
library: 'dplyr',
|
|
92
|
-
returnType: DataFrameType.DataFrame
|
|
93
|
-
}, {
|
|
94
|
-
type: 'entry_point',
|
|
95
|
-
names: ['tbl', 'as.tbl'],
|
|
96
|
-
library: 'dplyr',
|
|
97
|
-
returnType: DataFrameType.Tibble
|
|
98
|
-
}, {
|
|
99
|
-
type: 'entry_point',
|
|
100
|
-
names: ['read_fwf', 'read_log'],
|
|
101
|
-
library: 'readr',
|
|
102
|
-
returnType: DataFrameType.Tibble
|
|
103
|
-
}, {
|
|
104
|
-
type: 'entry_point',
|
|
105
|
-
names: ['read_excel', 'read_xls', 'read_xlsx'],
|
|
106
|
-
library: 'readxl',
|
|
107
|
-
returnType: DataFrameType.Tibble
|
|
108
|
-
}, {
|
|
109
|
-
type: 'entry_point',
|
|
110
|
-
names: ['tibble', 'tibble_row', 'as_tibble', 'tribble'],
|
|
111
|
-
library: 'tibble',
|
|
112
|
-
returnType: DataFrameType.Tibble
|
|
113
|
-
}, {
|
|
114
|
-
type: 'entry_point',
|
|
115
|
-
names: ['data.table', 'as.data.table', 'fread'],
|
|
116
|
-
library: 'data.table',
|
|
117
|
-
returnType: DataFrameType.DataTable
|
|
118
|
-
}, {
|
|
119
|
-
type: 'transformation',
|
|
120
|
-
names: ['na.omit'],
|
|
121
|
-
library: 'stats',
|
|
122
|
-
returnType: DataFrameType.DataFrame,
|
|
123
|
-
dataFrame: { pos: 0, name: 'object' }
|
|
124
|
-
}, {
|
|
125
|
-
type: 'transformation',
|
|
126
|
-
names: ['unique', 'droplevels'],
|
|
127
|
-
library: 'base',
|
|
128
|
-
returnType: DataFrameType.DataFrame,
|
|
129
|
-
dataFrame: { pos: 0, name: 'x' }
|
|
130
|
-
}, {
|
|
131
|
-
type: 'transformation',
|
|
132
|
-
names: ['aggregate'],
|
|
133
|
-
library: 'stats',
|
|
134
|
-
returnType: DataFrameType.DataFrame,
|
|
135
|
-
dataFrame: { pos: 0, name: 'x' }
|
|
136
|
-
}, {
|
|
137
|
-
type: 'transformation',
|
|
138
|
-
names: ['with', 'within'],
|
|
139
|
-
library: 'base',
|
|
140
|
-
returnType: DataFrameType.DataFrame,
|
|
141
|
-
dataFrame: { pos: 0, name: 'data' }
|
|
142
|
-
}, {
|
|
143
|
-
type: 'transformation',
|
|
144
|
-
names: ['reshape'],
|
|
145
|
-
library: 'stats',
|
|
146
|
-
returnType: DataFrameType.DataFrame,
|
|
147
|
-
dataFrame: { pos: 0, name: 'data' }
|
|
148
|
-
}, {
|
|
149
|
-
type: 'transformation',
|
|
150
|
-
names: ['melt'],
|
|
151
|
-
library: 'reshape2',
|
|
152
|
-
returnType: DataFrameType.DataFrame,
|
|
153
|
-
dataFrame: { pos: 0, name: 'data' }
|
|
154
|
-
}, {
|
|
155
|
-
type: 'transformation',
|
|
156
|
-
names: [
|
|
157
|
-
'transmute', 'distinct', 'distinct_prepare', 'group_by_prepare', 'rename', 'rename_with', 'reframe',
|
|
158
|
-
'slice', 'slice_head', 'slice_tail', 'slice_min', 'slice_max', 'slice_sample'
|
|
159
|
-
],
|
|
160
|
-
library: 'dplyr',
|
|
161
|
-
returnType: DataFrameType.DataFrame,
|
|
162
|
-
alwaysDataFrame: true,
|
|
163
|
-
dataFrame: { pos: 0, name: '.data' }
|
|
164
|
-
}, {
|
|
165
|
-
type: 'transformation',
|
|
166
|
-
names: [
|
|
167
|
-
'filter_if', 'filter_at', 'filter_all', 'select_if', 'select_at', 'select_all',
|
|
168
|
-
'mutate_if', 'mutate_at', 'mutate_all', 'transmute_if', 'transmute_at', 'transmute_all',
|
|
169
|
-
'distinct_if', 'distinct_at', 'distinct_all', 'group_by_if', 'group_by_at', 'group_by_all',
|
|
170
|
-
'summarize_if', 'summarise_if', 'summarize_at', 'summarise_at', 'summarize_all', 'summarise_all',
|
|
171
|
-
'arrange_if', 'arrange_at', 'arrange_all', 'rename_if', 'rename_at', 'rename_all'
|
|
172
|
-
],
|
|
173
|
-
library: 'dplyr',
|
|
174
|
-
returnType: DataFrameType.Tibble,
|
|
175
|
-
alwaysDataFrame: true,
|
|
176
|
-
dataFrame: { pos: 0, name: '.tbl' }
|
|
177
|
-
}, {
|
|
178
|
-
type: 'transformation',
|
|
179
|
-
names: [
|
|
180
|
-
'semi_join', 'anti_join', 'nest_join', 'cross_join',
|
|
181
|
-
'ungroup', 'count', 'tally', 'add_count', 'add_tally',
|
|
182
|
-
'rows_insert', 'rows_append', 'rows_update', 'rows_patch', 'rows_upsert', 'rows_delete'
|
|
183
|
-
],
|
|
184
|
-
library: 'dplyr',
|
|
185
|
-
returnType: DataFrameType.DataFrame,
|
|
186
|
-
alwaysDataFrame: true,
|
|
187
|
-
dataFrame: { pos: 0, name: 'x' }
|
|
188
|
-
}, {
|
|
189
|
-
type: 'transformation',
|
|
190
|
-
names: ['bind_cols', 'bind_rows'],
|
|
191
|
-
library: 'dplyr',
|
|
192
|
-
returnType: DataFrameType.DataFrame,
|
|
193
|
-
alwaysDataFrame: true
|
|
194
|
-
}, {
|
|
195
|
-
type: 'transformation',
|
|
196
|
-
names: [
|
|
197
|
-
'drop_na', 'replace_na', 'pivot_longer', 'pivot_wider',
|
|
198
|
-
'separate', 'separate_wider_position', 'separate_wider_delim', 'unite'
|
|
199
|
-
],
|
|
200
|
-
library: 'tidyr',
|
|
201
|
-
returnType: DataFrameType.DataFrame,
|
|
202
|
-
dataFrame: { pos: 0, name: 'data' }
|
|
203
|
-
}, {
|
|
204
|
-
type: 'transformation',
|
|
205
|
-
names: ['add_column', 'add_row', 'add_case'],
|
|
206
|
-
library: 'tibble',
|
|
207
|
-
returnType: DataFrameType.Tibble,
|
|
208
|
-
alwaysDataFrame: true,
|
|
209
|
-
dataFrame: { pos: 0, name: '.data' }
|
|
210
|
-
}, {
|
|
211
|
-
type: 'transformation',
|
|
212
|
-
names: ['melt', 'dcast'],
|
|
213
|
-
library: 'data.table',
|
|
214
|
-
returnType: DataFrameType.DataTable,
|
|
215
|
-
dataFrame: { pos: 0, name: 'data' }
|
|
216
|
-
}, {
|
|
217
|
-
type: 'modification',
|
|
218
|
-
names: ['setNames'],
|
|
219
|
-
library: 'stats',
|
|
220
|
-
constraintType: semantics_1.ConstraintType.OperandModification,
|
|
221
|
-
returnType: DataFrameType.DataFrame,
|
|
222
|
-
dataFrame: { pos: 0, name: 'object' }
|
|
223
|
-
}, {
|
|
224
|
-
type: 'modification',
|
|
225
|
-
names: ['unname'],
|
|
226
|
-
library: 'base',
|
|
227
|
-
constraintType: semantics_1.ConstraintType.OperandModification,
|
|
228
|
-
returnType: DataFrameType.DataFrame,
|
|
229
|
-
dataFrame: { pos: 0, name: 'obj' }
|
|
230
|
-
}
|
|
231
|
-
];
|
|
232
|
-
/** Shared parameters of the `read.csv`/`read.delim` wrappers around `read.table`, which only differ in their separator. */
|
|
233
|
-
const ReadTableVariantParams = {
|
|
234
|
-
fileName: { pos: 0, name: 'file' },
|
|
235
|
-
header: { pos: 1, name: 'header', default: true },
|
|
236
|
-
separator: { pos: 2, name: 'sep', default: ',' },
|
|
237
|
-
quote: { pos: 3, name: 'quote', default: '"' },
|
|
238
|
-
comment: { pos: 6, name: 'comment.char', default: '' },
|
|
239
|
-
skipLines: { pos: -1, name: 'skip', default: 0 },
|
|
240
|
-
checkNames: { pos: -1, name: 'check.names', default: true },
|
|
241
|
-
noDupNames: { pos: -1, name: 'check.names', default: true },
|
|
242
|
-
text: { pos: -1, name: 'text' },
|
|
243
|
-
critical: [
|
|
244
|
-
{ pos: -1, name: 'row.names' },
|
|
245
|
-
{ pos: -1, name: 'col.names' },
|
|
246
|
-
{ pos: -1, name: 'nrows', default: -1 },
|
|
247
|
-
{ pos: -1, name: 'strip.white', default: false },
|
|
248
|
-
{ pos: -1, name: 'blank.lines.skip', default: true },
|
|
249
|
-
{ pos: -1, name: 'allow.escapes', default: false },
|
|
250
|
-
]
|
|
251
|
-
};
|
|
252
|
-
/** Shared parameters of the readr `read_csv`/`read_tsv` wrappers around `read_delim`, which only differ in their separator. */
|
|
253
|
-
const ReadrDelimitedParams = {
|
|
254
|
-
fileName: { pos: 0, name: 'file' },
|
|
255
|
-
header: { pos: 1, name: 'col_names', default: true },
|
|
256
|
-
separator: { pos: -1, default: ',' },
|
|
257
|
-
quote: { pos: 8, name: 'quote', default: '"' },
|
|
258
|
-
comment: { pos: 9, name: 'comment', default: '' },
|
|
259
|
-
skipLines: { pos: 11, name: 'skip', default: 0 },
|
|
260
|
-
checkNames: { pos: -1, default: false },
|
|
261
|
-
noDupNames: { pos: -1, default: true },
|
|
262
|
-
critical: [
|
|
263
|
-
{ pos: 3, name: 'col_select' },
|
|
264
|
-
{ pos: 4, name: 'id' },
|
|
265
|
-
{ pos: 10, name: 'trim_ws', default: true },
|
|
266
|
-
{ pos: 12, name: 'n_max', default: Infinity },
|
|
267
|
-
{ pos: 14, name: 'name_repair', default: 'unique' },
|
|
268
|
-
{ pos: 18, name: 'skip_empty_rows', default: true }
|
|
269
|
-
],
|
|
270
|
-
noEmptyNames: true
|
|
271
|
-
};
|
|
272
|
-
/** Shared parameters of the dplyr `*_join` functions, which only differ in the sides they keep. */
|
|
273
|
-
const DplyrJoinParams = {
|
|
274
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
275
|
-
otherDataFrame: { pos: 1, name: 'y' },
|
|
276
|
-
by: { pos: 2, name: 'by' },
|
|
277
|
-
joinAll: { pos: -1, default: false },
|
|
278
|
-
joinLeft: { pos: -1, default: false },
|
|
279
|
-
joinRight: { pos: -1, default: false },
|
|
280
|
-
critical: [{ pos: -1, name: 'keep' }]
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Mapper for defining the location of all relevant function parameters for each supported data frame function of {@link DataFrameFunctionMapper}.
|
|
284
|
-
*/
|
|
285
|
-
const DataFrameFunctionParamsMapper = {
|
|
286
|
-
'data.frame': {
|
|
287
|
-
checkNames: { pos: -1, name: 'check.names', default: true },
|
|
288
|
-
noDupNames: { pos: -1, name: 'check.names', default: true },
|
|
289
|
-
special: ['row.names', 'check.rows', 'check.names', 'fix.empty.names', 'stringsAsFactors'],
|
|
290
|
-
critical: [{ pos: -1, name: 'row.names' }]
|
|
291
|
-
},
|
|
292
|
-
'as.data.frame': {
|
|
293
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
294
|
-
critical: []
|
|
295
|
-
},
|
|
296
|
-
'read.table': {
|
|
297
|
-
fileName: { pos: 0, name: 'file' },
|
|
298
|
-
header: { pos: 1, name: 'header', default: false },
|
|
299
|
-
separator: { pos: 2, name: 'sep', default: '\\s' },
|
|
300
|
-
quote: { pos: 3, name: 'quote', default: '"\'' },
|
|
301
|
-
skipLines: { pos: 12, name: 'skip', default: 0 },
|
|
302
|
-
checkNames: { pos: 13, name: 'check.names', default: true },
|
|
303
|
-
noDupNames: { pos: 13, name: 'check.names', default: true },
|
|
304
|
-
comment: { pos: 17, name: 'comment.char', default: '#' },
|
|
305
|
-
text: { pos: 23, name: 'text' },
|
|
306
|
-
critical: [
|
|
307
|
-
{ pos: 6, name: 'row.names' },
|
|
308
|
-
{ pos: 7, name: 'col.names' },
|
|
309
|
-
{ pos: 11, name: 'nrows', default: -1 },
|
|
310
|
-
{ pos: 15, name: 'strip.white', default: false },
|
|
311
|
-
{ pos: 16, name: 'blank.lines.skip', default: true },
|
|
312
|
-
{ pos: 18, name: 'allow.escapes', default: false },
|
|
313
|
-
]
|
|
314
|
-
},
|
|
315
|
-
'read.csv': { ...ReadTableVariantParams, separator: { pos: 2, name: 'sep', default: ',' } },
|
|
316
|
-
'read.csv2': { ...ReadTableVariantParams, separator: { pos: 2, name: 'sep', default: ';' } },
|
|
317
|
-
'read.delim': { ...ReadTableVariantParams, separator: { pos: 2, name: 'sep', default: '\\t' } },
|
|
318
|
-
'read.delim2': { ...ReadTableVariantParams, separator: { pos: 2, name: 'sep', default: '\\t' } },
|
|
319
|
-
'read_table': {
|
|
320
|
-
fileName: { pos: 0, name: 'file' },
|
|
321
|
-
header: { pos: 1, name: 'col_names', default: true },
|
|
322
|
-
separator: { pos: -1, default: '\\s' },
|
|
323
|
-
quote: { pos: -1, default: '"' },
|
|
324
|
-
skipLines: { pos: 5, name: 'skip', default: 0 },
|
|
325
|
-
comment: { pos: 9, name: 'comment', default: '' },
|
|
326
|
-
checkNames: { pos: -1, default: false },
|
|
327
|
-
noDupNames: { pos: -1, default: true },
|
|
328
|
-
critical: [
|
|
329
|
-
{ pos: 6, name: 'n_max', default: Infinity },
|
|
330
|
-
{ pos: 11, name: 'skip_empty_rows', default: true }
|
|
331
|
-
],
|
|
332
|
-
noEmptyNames: true
|
|
333
|
-
},
|
|
334
|
-
'read_csv': { ...ReadrDelimitedParams, separator: { pos: -1, default: ',' } },
|
|
335
|
-
'read_csv2': { ...ReadrDelimitedParams, separator: { pos: -1, default: ';' } },
|
|
336
|
-
'read_tsv': { ...ReadrDelimitedParams, separator: { pos: -1, default: '\\t' } },
|
|
337
|
-
'read_delim': {
|
|
338
|
-
fileName: { pos: 0, name: 'file' },
|
|
339
|
-
separator: { pos: 1, name: 'delim', default: '\t' },
|
|
340
|
-
quote: { pos: 2, name: 'quote', default: '"' },
|
|
341
|
-
header: { pos: 5, name: 'col_names', default: true },
|
|
342
|
-
comment: { pos: 12, name: 'comment', default: '' },
|
|
343
|
-
skipLines: { pos: 14, name: 'skip', default: 0 },
|
|
344
|
-
checkNames: { pos: -1, default: false },
|
|
345
|
-
noDupNames: { pos: -1, default: true },
|
|
346
|
-
critical: [
|
|
347
|
-
{ pos: 3, name: 'escape_backslash', default: false },
|
|
348
|
-
{ pos: 4, name: 'escape_double', default: true },
|
|
349
|
-
{ pos: 7, name: 'col_select' },
|
|
350
|
-
{ pos: 8, name: 'id' },
|
|
351
|
-
{ pos: 13, name: 'trim_ws', default: false },
|
|
352
|
-
{ pos: 15, name: 'n_max', default: Infinity },
|
|
353
|
-
{ pos: 17, name: 'name_repair', default: 'unique' },
|
|
354
|
-
{ pos: 21, name: 'skip_empty_rows', default: true }
|
|
355
|
-
],
|
|
356
|
-
noEmptyNames: true
|
|
357
|
-
},
|
|
358
|
-
'cbind': {
|
|
359
|
-
special: ['deparse.level', 'make.row.names', 'stringsAsFactors', 'factor.exclude']
|
|
360
|
-
},
|
|
361
|
-
'rbind': {
|
|
362
|
-
special: ['deparse.level', 'make.row.names', 'stringsAsFactors', 'factor.exclude']
|
|
363
|
-
},
|
|
364
|
-
'head': {
|
|
365
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
366
|
-
amount: { pos: 1, name: 'n', default: 6 }
|
|
367
|
-
},
|
|
368
|
-
'tail': {
|
|
369
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
370
|
-
amount: { pos: 1, name: 'n', default: 6 }
|
|
371
|
-
},
|
|
372
|
-
'subset': {
|
|
373
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
374
|
-
subset: { pos: 1, name: 'subset' },
|
|
375
|
-
select: { pos: 2, name: 'select' },
|
|
376
|
-
drop: { pos: 3, name: 'drop', default: false }
|
|
377
|
-
},
|
|
378
|
-
'filter': {
|
|
379
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
380
|
-
special: ['.by', '.preserve']
|
|
381
|
-
},
|
|
382
|
-
'select': {
|
|
383
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
384
|
-
special: []
|
|
385
|
-
},
|
|
386
|
-
'mutate': {
|
|
387
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
388
|
-
special: ['.by', '.keep', '.before', '.after'],
|
|
389
|
-
critical: [{ pos: -1, name: '.keep' }],
|
|
390
|
-
checkNames: false,
|
|
391
|
-
noDupNames: false
|
|
392
|
-
},
|
|
393
|
-
'transform': {
|
|
394
|
-
dataFrame: { pos: 0, name: '_data' },
|
|
395
|
-
special: [],
|
|
396
|
-
checkNames: true,
|
|
397
|
-
noDupNames: true
|
|
398
|
-
},
|
|
399
|
-
'group_by': {
|
|
400
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
401
|
-
by: { pos: 1 },
|
|
402
|
-
special: ['.add', '.drop']
|
|
403
|
-
},
|
|
404
|
-
'summarise': {
|
|
405
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
406
|
-
special: ['.by', '.groups']
|
|
407
|
-
},
|
|
408
|
-
'summarize': {
|
|
409
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
410
|
-
special: ['.by', '.groups']
|
|
411
|
-
},
|
|
412
|
-
'inner_join': { ...DplyrJoinParams },
|
|
413
|
-
'left_join': { ...DplyrJoinParams, joinLeft: { pos: -1, default: true } },
|
|
414
|
-
'right_join': { ...DplyrJoinParams, joinRight: { pos: -1, default: true } },
|
|
415
|
-
'full_join': { ...DplyrJoinParams, joinAll: { pos: -1, default: true } },
|
|
416
|
-
'merge': {
|
|
417
|
-
dataFrame: { pos: 0, name: 'x' },
|
|
418
|
-
otherDataFrame: { pos: 1, name: 'y' },
|
|
419
|
-
by: { pos: 2, name: 'by' },
|
|
420
|
-
joinAll: { pos: 5, name: 'all', default: false },
|
|
421
|
-
joinLeft: { pos: 6, name: 'all.x', default: false },
|
|
422
|
-
joinRight: { pos: 7, name: 'all.y', default: false },
|
|
423
|
-
critical: [
|
|
424
|
-
{ pos: 3, name: 'by.x' },
|
|
425
|
-
{ pos: 4, name: 'by.y' }
|
|
426
|
-
]
|
|
427
|
-
},
|
|
428
|
-
'relocate': {
|
|
429
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
430
|
-
special: ['.before', '.after'],
|
|
431
|
-
disallowNamedArgs: true
|
|
432
|
-
},
|
|
433
|
-
'arrange': {
|
|
434
|
-
dataFrame: { pos: 0, name: '.data' },
|
|
435
|
-
special: ['.by_group', '.locale']
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
/** Records an access to the given columns of `operand`, ignoring an empty access. */
|
|
439
|
-
function pushAccessedCols(result, operand, columns) {
|
|
440
|
-
if (columns.length > 0) {
|
|
441
|
-
result.push({ operation: 'accessCols', operand, columns });
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Records the accessed columns of `operand` split by how they are indexed, as accessing a column by name and
|
|
446
|
-
* accessing it by index are separate operations.
|
|
447
|
-
* @param result - The operations recorded so far, appended to in place.
|
|
448
|
-
* @param operand - The data frame the columns are accessed on.
|
|
449
|
-
* @param columns - The accessed columns, by name or by index.
|
|
450
|
-
* @param absoluteIndices - Whether negative indices deselect the column they name and thus access the same column.
|
|
451
|
-
*/
|
|
452
|
-
function pushAccessedColsByIndexing(result, operand, columns, absoluteIndices = false) {
|
|
453
|
-
pushAccessedCols(result, operand, columns.filter(col => typeof col === 'string'));
|
|
454
|
-
const indices = columns.filter(col => typeof col === 'number');
|
|
455
|
-
pushAccessedCols(result, operand, absoluteIndices ? indices.map(Math.abs) : indices);
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Maps a concrete data frame function call to abstract data frame operations.
|
|
459
|
-
* @param node - The R node of the function call
|
|
460
|
-
* @param inference - The data frame shape inference visitor
|
|
461
|
-
* @param dfg - The data flow graph for resolving the arguments
|
|
462
|
-
* @param ctx - The current flowR analyzer context
|
|
463
|
-
* @returns The mapped abstract data frame operations for the function call, or `undefined` if the node does not represent a data frame function call
|
|
464
|
-
*/
|
|
465
|
-
function mapDataFrameFunctionCall(node, inference, dfg, ctx) {
|
|
466
|
-
if (!r_function_call_1.RFunctionCall.is(node) || !node.named) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
const resolveInfo = { graph: dfg, idMap: dfg.idMap, full: true, resolve: config_1.VariableResolve.Alias, ctx };
|
|
470
|
-
const functionName = identifier_1.Identifier.getName(node.functionName.content);
|
|
471
|
-
if (isDataFrameFunction(functionName)) {
|
|
472
|
-
const mapping = DataFrameFunctionMapper[functionName];
|
|
473
|
-
const params = DataFrameFunctionParamsMapper[functionName];
|
|
474
|
-
const args = (0, arguments_1.getFunctionArguments)(node, dfg);
|
|
475
|
-
if ((0, arguments_1.hasCriticalArgument)(args, params.critical, resolveInfo)) {
|
|
476
|
-
return [{ operation: 'unknown', operand: undefined }];
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
return mapping.mapper(args, params, inference, resolveInfo) ?? (mapping.alwaysDataFrame ? [{ operation: 'unknown', operand: undefined }] : undefined);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
const mapping = getOtherDataFrameFunction(functionName);
|
|
484
|
-
if (mapping === undefined) {
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
else if (mapping.type === 'entry_point') {
|
|
488
|
-
return [{ operation: 'unknown', operand: undefined }];
|
|
489
|
-
}
|
|
490
|
-
else if (mapping.type === 'transformation') {
|
|
491
|
-
const args = (0, arguments_1.getFunctionArguments)(node, dfg);
|
|
492
|
-
return mapDataFrameUnknown(args, mapping, inference, resolveInfo) ?? (mapping.alwaysDataFrame ? [{ operation: 'unknown', operand: undefined }] : undefined);
|
|
493
|
-
}
|
|
494
|
-
else if (mapping.type === 'modification') {
|
|
495
|
-
const args = (0, arguments_1.getFunctionArguments)(node, dfg);
|
|
496
|
-
return mapDataFrameUnknown(args, { ...mapping, constraintType: semantics_1.ConstraintType.OperandModification }, inference, resolveInfo);
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
(0, assert_1.assertUnreachable)(mapping);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
function isDataFrameFunction(functionName) {
|
|
504
|
-
// a check with `functionName in DataFrameFunctionMapper` would return true for "toString"
|
|
505
|
-
return Object.hasOwn(DataFrameFunctionMapper, functionName);
|
|
506
|
-
}
|
|
507
|
-
function getOtherDataFrameFunction(functionName) {
|
|
508
|
-
return OtherDataFrameFunctions.find(entry => entry.names.includes(functionName));
|
|
509
|
-
}
|
|
510
|
-
function mapDataFrameCreate(args, params, inference, info) {
|
|
511
|
-
const checkNames = (0, arguments_1.getArgumentValue)(args, params.checkNames, info);
|
|
512
|
-
const noDupNames = (0, arguments_1.getArgumentValue)(args, params.noDupNames, info);
|
|
513
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
514
|
-
const argNames = args.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
515
|
-
const argLengths = args.map(arg => resolve_helper_1.Resolve.argument.vectorLength(arg, info));
|
|
516
|
-
const allVectors = argLengths.every(assert_1.isNotUndefined);
|
|
517
|
-
const rows = allVectors ? Math.max(...argLengths, 0) : undefined;
|
|
518
|
-
let colnames = argNames;
|
|
519
|
-
// over-approximate the column names if arguments are present but cannot be resolved to values
|
|
520
|
-
if (!allVectors || typeof checkNames !== 'boolean' || typeof noDupNames !== 'boolean') {
|
|
521
|
-
colnames = undefined;
|
|
522
|
-
}
|
|
523
|
-
else if (rows === 0) {
|
|
524
|
-
colnames = [];
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
colnames = (0, arguments_1.filterValidNames)(colnames, checkNames, noDupNames);
|
|
528
|
-
}
|
|
529
|
-
return [{
|
|
530
|
-
operation: 'create',
|
|
531
|
-
operand: undefined,
|
|
532
|
-
colnames,
|
|
533
|
-
rows
|
|
534
|
-
}];
|
|
535
|
-
}
|
|
536
|
-
function mapDataFrameConvert(args, params, inference, info) {
|
|
537
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
538
|
-
if (r_argument_1.RArgument.isEmpty(dataFrame) || dataFrame?.value === undefined) {
|
|
539
|
-
return [{ operation: 'unknown', operand: undefined }];
|
|
540
|
-
}
|
|
541
|
-
return [{
|
|
542
|
-
operation: 'identity',
|
|
543
|
-
operand: dataFrame.value.info.id
|
|
544
|
-
}];
|
|
545
|
-
}
|
|
546
|
-
function mapDataFrameRead(args, params, inference, info) {
|
|
547
|
-
const fileNameArg = (0, arguments_1.getFunctionArgument)(args, params.fileName, info);
|
|
548
|
-
const textArg = params.text ? (0, arguments_1.getFunctionArgument)(args, params.text, info) : undefined;
|
|
549
|
-
const { source, request } = getRequestFromRead(fileNameArg, textArg, params, info);
|
|
550
|
-
const header = (0, arguments_1.getArgumentValue)(args, params.header, info);
|
|
551
|
-
const separator = (0, arguments_1.getArgumentValue)(args, params.separator, info);
|
|
552
|
-
const quote = (0, arguments_1.getArgumentValue)(args, params.quote, info);
|
|
553
|
-
const comment = (0, arguments_1.getArgumentValue)(args, params.comment, info);
|
|
554
|
-
const skipLines = (0, arguments_1.getArgumentValue)(args, params.skipLines, info);
|
|
555
|
-
const checkNames = (0, arguments_1.getArgumentValue)(args, params.checkNames, info);
|
|
556
|
-
const noDupNames = (0, arguments_1.getArgumentValue)(args, params.noDupNames, info);
|
|
557
|
-
const validArguments = typeof header === 'boolean' && typeof separator === 'string' && typeof quote === 'string' && typeof comment === 'string' &&
|
|
558
|
-
typeof skipLines === 'number' && typeof checkNames === 'boolean' && typeof noDupNames === 'boolean';
|
|
559
|
-
if (request === undefined || !info.ctx.config.abstractInterpretation.dataFrame.readLoadedData.readExternalFiles || !validArguments) {
|
|
560
|
-
return [{
|
|
561
|
-
operation: 'read',
|
|
562
|
-
operand: undefined,
|
|
563
|
-
source,
|
|
564
|
-
colnames: undefined,
|
|
565
|
-
rows: undefined
|
|
566
|
-
}];
|
|
567
|
-
}
|
|
568
|
-
const LineCommentRegex = new RegExp(`\\s*[${(0, arguments_1.escapeRegExp)(comment, true)}].*`);
|
|
569
|
-
let firstLine = undefined;
|
|
570
|
-
let firstLineNumber = 0;
|
|
571
|
-
let rowCount = 0;
|
|
572
|
-
const parseLine = (line, lineNumber) => {
|
|
573
|
-
const text = comment ? line.toString().replace(LineCommentRegex, '') : line.toString();
|
|
574
|
-
if (text.length > 0 && lineNumber >= (skipLines ?? 0)) {
|
|
575
|
-
if (firstLine === undefined) {
|
|
576
|
-
firstLine = getEntriesFromCsvLine(text, separator, quote, comment);
|
|
577
|
-
firstLineNumber = lineNumber;
|
|
578
|
-
}
|
|
579
|
-
if (!header || lineNumber > firstLineNumber) {
|
|
580
|
-
rowCount++;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
const allLines = (0, arguments_1.parseRequestContent)(request, parseLine, info.ctx.config.abstractInterpretation.dataFrame.readLoadedData.maxReadLines);
|
|
585
|
-
let colnames;
|
|
586
|
-
if (header) {
|
|
587
|
-
colnames = (0, arguments_1.filterValidNames)(firstLine, checkNames, noDupNames, params.noEmptyNames);
|
|
588
|
-
}
|
|
589
|
-
else if (firstLine !== undefined) {
|
|
590
|
-
colnames = Array(firstLine.length).fill(undefined);
|
|
591
|
-
}
|
|
592
|
-
return [{
|
|
593
|
-
operation: 'read',
|
|
594
|
-
operand: undefined,
|
|
595
|
-
source,
|
|
596
|
-
colnames,
|
|
597
|
-
rows: allLines ? rowCount : [rowCount, Infinity]
|
|
598
|
-
}];
|
|
599
|
-
}
|
|
600
|
-
function mapDataFrameColBind(args, params, inference, info) {
|
|
601
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
602
|
-
const dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, inference));
|
|
603
|
-
if (dataFrame === undefined) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
else if (args.length === 1) {
|
|
607
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
608
|
-
}
|
|
609
|
-
const result = [];
|
|
610
|
-
let operand = dataFrame.value;
|
|
611
|
-
let colnames = [];
|
|
612
|
-
for (const arg of args) {
|
|
613
|
-
if (arg !== dataFrame && arg !== r_function_call_2.EmptyArgument) {
|
|
614
|
-
const otherDataFrame = inference.getAbstractValue(arg.value);
|
|
615
|
-
if (otherDataFrame !== undefined) {
|
|
616
|
-
result.push({
|
|
617
|
-
operation: 'concatCols',
|
|
618
|
-
operand: operand?.info.id,
|
|
619
|
-
other: otherDataFrame
|
|
620
|
-
});
|
|
621
|
-
operand = undefined;
|
|
622
|
-
// added columns are top if argument cannot be resolved to constant (vector-like) value
|
|
623
|
-
}
|
|
624
|
-
else if (resolve_helper_1.Resolve.argument.value(arg, info) !== undefined) {
|
|
625
|
-
const colname = resolve_helper_1.Resolve.argument.toName(arg, info);
|
|
626
|
-
colnames?.push(colname);
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
colnames = undefined;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
if (colnames === undefined || colnames.length > 0) {
|
|
634
|
-
result.push({
|
|
635
|
-
operation: 'addCols',
|
|
636
|
-
operand: operand?.info.id,
|
|
637
|
-
colnames
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
return result;
|
|
641
|
-
}
|
|
642
|
-
function mapDataFrameRowBind(args, params, inference, info) {
|
|
643
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
644
|
-
const dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, inference));
|
|
645
|
-
if (dataFrame === undefined) {
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
else if (args.length === 1) {
|
|
649
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
650
|
-
}
|
|
651
|
-
const result = [];
|
|
652
|
-
let operand = dataFrame.value;
|
|
653
|
-
let rows = 0;
|
|
654
|
-
for (const arg of args) {
|
|
655
|
-
if (arg !== dataFrame && arg !== r_function_call_2.EmptyArgument) {
|
|
656
|
-
const otherDataFrame = inference.getAbstractValue(arg.value);
|
|
657
|
-
if (otherDataFrame !== undefined) {
|
|
658
|
-
result.push({
|
|
659
|
-
operation: 'concatRows',
|
|
660
|
-
operand: operand?.info.id,
|
|
661
|
-
other: otherDataFrame
|
|
662
|
-
});
|
|
663
|
-
operand = undefined;
|
|
664
|
-
// number of added rows is top if arguments cannot be resolved to constant (vector-like) value
|
|
665
|
-
}
|
|
666
|
-
else if (resolve_helper_1.Resolve.argument.value(arg, info) !== undefined) {
|
|
667
|
-
rows = rows !== undefined ? rows + 1 : undefined;
|
|
668
|
-
}
|
|
669
|
-
else {
|
|
670
|
-
rows = undefined;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
if (rows === undefined || rows > 0) {
|
|
675
|
-
result.push({
|
|
676
|
-
operation: 'addRows',
|
|
677
|
-
operand: operand?.info.id,
|
|
678
|
-
rows
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
return result;
|
|
682
|
-
}
|
|
683
|
-
function mapDataFrameHeadTail(args, params, inference, info) {
|
|
684
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
685
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
const result = [];
|
|
689
|
-
const amount = (0, arguments_1.getArgumentValue)(args, params.amount, info);
|
|
690
|
-
let rows = undefined;
|
|
691
|
-
let cols = undefined;
|
|
692
|
-
if (typeof amount === 'number') {
|
|
693
|
-
rows = amount;
|
|
694
|
-
}
|
|
695
|
-
else if (Array.isArray(amount) && amount.length <= 2 && amount.every(value => typeof value === 'number')) {
|
|
696
|
-
rows = amount[0];
|
|
697
|
-
cols = amount[1];
|
|
698
|
-
}
|
|
699
|
-
result.push({
|
|
700
|
-
operation: rows === undefined || rows >= 0 ? 'subsetRows' : 'removeRows',
|
|
701
|
-
operand: dataFrame.value.info.id,
|
|
702
|
-
rows: rows !== undefined ? Math.abs(rows) : undefined
|
|
703
|
-
});
|
|
704
|
-
if (cols !== undefined) {
|
|
705
|
-
result.push({
|
|
706
|
-
operation: cols >= 0 ? 'subsetCols' : 'removeCols',
|
|
707
|
-
operand: undefined,
|
|
708
|
-
colnames: Array(Math.abs(cols)).fill(undefined)
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
return result;
|
|
712
|
-
}
|
|
713
|
-
function mapDataFrameSubset(args, params, inference, info) {
|
|
714
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
715
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
else if (args.length === 1) {
|
|
719
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
720
|
-
}
|
|
721
|
-
const result = [];
|
|
722
|
-
let operand = dataFrame.value;
|
|
723
|
-
const filterArg = (0, arguments_1.getFunctionArgument)(args, params.subset, info);
|
|
724
|
-
const filterValue = resolve_helper_1.Resolve.argument.value(filterArg, info);
|
|
725
|
-
const selectArg = (0, arguments_1.getFunctionArgument)(args, params.select, info);
|
|
726
|
-
const dropArg = (0, arguments_1.getFunctionArgument)(args, params.drop, info);
|
|
727
|
-
const condition = typeof filterValue === 'boolean' ? filterValue : undefined;
|
|
728
|
-
const filterNames = (0, arguments_1.getUnresolvedSymbolsInExpression)(filterArg, info.graph);
|
|
729
|
-
const { selectedCols, unselectedCols } = getSelectedColumns([selectArg], info);
|
|
730
|
-
const accessedCols = [...filterNames, ...selectedCols ?? [], ...unselectedCols ?? []];
|
|
731
|
-
const mixedAccess = accessedCols.some(col => typeof col === 'string') && accessedCols.some(col => typeof col === 'number');
|
|
732
|
-
const duplicateCols = accessedCols.some((col, index, list) => col !== undefined && list.indexOf(col) !== index);
|
|
733
|
-
pushAccessedColsByIndexing(result, operand?.info.id, accessedCols, true);
|
|
734
|
-
if (filterArg !== undefined && filterArg !== r_function_call_2.EmptyArgument) {
|
|
735
|
-
result.push({
|
|
736
|
-
operation: 'filterRows',
|
|
737
|
-
operand: operand?.info.id,
|
|
738
|
-
condition: condition
|
|
739
|
-
});
|
|
740
|
-
operand = undefined;
|
|
741
|
-
}
|
|
742
|
-
if (!dropArg || accessedCols.length > 1) {
|
|
743
|
-
if (unselectedCols === undefined || unselectedCols.length > 0) {
|
|
744
|
-
result.push({
|
|
745
|
-
operation: 'removeCols',
|
|
746
|
-
operand: operand?.info.id,
|
|
747
|
-
colnames: unselectedCols?.map(col => typeof col === 'string' ? col : undefined)
|
|
748
|
-
});
|
|
749
|
-
operand = undefined;
|
|
750
|
-
}
|
|
751
|
-
if (selectedCols === undefined || selectedCols.length > 0) {
|
|
752
|
-
result.push({
|
|
753
|
-
operation: 'subsetCols',
|
|
754
|
-
operand: operand?.info.id,
|
|
755
|
-
colnames: selectedCols?.map(col => typeof col === 'string' ? col : undefined),
|
|
756
|
-
...(duplicateCols || mixedAccess ? { options: { duplicateCols: true } } : {})
|
|
757
|
-
});
|
|
758
|
-
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
759
|
-
operand = undefined;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
return result;
|
|
763
|
-
}
|
|
764
|
-
function mapDataFrameFilter(args, params, inference, info) {
|
|
765
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
766
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
767
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
else if (args.length === 1) {
|
|
771
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
772
|
-
}
|
|
773
|
-
const result = [];
|
|
774
|
-
const filterArgs = args.filter(arg => arg !== dataFrame);
|
|
775
|
-
const filterValues = filterArgs.map(arg => resolve_helper_1.Resolve.argument.value(arg, info));
|
|
776
|
-
const accessedNames = filterArgs.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph).map(identifier_1.Identifier.getName));
|
|
777
|
-
const condition = filterValues.every(value => typeof value === 'boolean') ? filterValues.every(Boolean) : undefined;
|
|
778
|
-
pushAccessedCols(result, dataFrame.value.info.id, accessedNames);
|
|
779
|
-
result.push({
|
|
780
|
-
operation: 'filterRows',
|
|
781
|
-
operand: dataFrame.value.info.id,
|
|
782
|
-
condition: condition
|
|
783
|
-
});
|
|
784
|
-
return result;
|
|
785
|
-
}
|
|
786
|
-
function mapDataFrameSelect(args, params, inference, info) {
|
|
787
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
788
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
789
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
const result = [];
|
|
793
|
-
let operand = dataFrame.value;
|
|
794
|
-
const selectArgs = args.filter(arg => arg !== dataFrame);
|
|
795
|
-
let { selectedCols, unselectedCols } = getSelectedColumns(selectArgs, info);
|
|
796
|
-
const accessedCols = [...selectedCols ?? [], ...unselectedCols ?? []];
|
|
797
|
-
const mixedAccess = accessedCols.some(col => typeof col === 'string') && accessedCols.some(col => typeof col === 'number');
|
|
798
|
-
const duplicateAccess = accessedCols.some((col, _, list) => col !== undefined && list.filter(other => other === col).length > 1);
|
|
799
|
-
const renamedCols = selectArgs.some(r_argument_1.RArgument.isNamed);
|
|
800
|
-
// map to top if columns are selected mixed by string and number, or are selected duplicate
|
|
801
|
-
if (mixedAccess || duplicateAccess) {
|
|
802
|
-
selectedCols = undefined;
|
|
803
|
-
unselectedCols = [];
|
|
804
|
-
}
|
|
805
|
-
pushAccessedColsByIndexing(result, operand?.info.id, accessedCols, true);
|
|
806
|
-
if (unselectedCols === undefined || unselectedCols.length > 0) {
|
|
807
|
-
result.push({
|
|
808
|
-
operation: 'removeCols',
|
|
809
|
-
operand: operand?.info.id,
|
|
810
|
-
colnames: unselectedCols?.map(col => typeof col === 'string' ? col : undefined)
|
|
811
|
-
});
|
|
812
|
-
operand = undefined;
|
|
813
|
-
}
|
|
814
|
-
if (selectedCols === undefined || selectedCols.length > 0 || unselectedCols?.length === 0) {
|
|
815
|
-
result.push({
|
|
816
|
-
operation: 'subsetCols',
|
|
817
|
-
operand: operand?.info.id,
|
|
818
|
-
colnames: selectedCols?.map(col => typeof col === 'string' ? col : undefined),
|
|
819
|
-
...(renamedCols ? { options: { renamedCols: true } } : {})
|
|
820
|
-
});
|
|
821
|
-
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
822
|
-
operand = undefined;
|
|
823
|
-
}
|
|
824
|
-
return result;
|
|
825
|
-
}
|
|
826
|
-
function mapDataFrameMutate(args, params, inference, info) {
|
|
827
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
828
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
829
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
else if (args.length === 1) {
|
|
833
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
834
|
-
}
|
|
835
|
-
const result = [];
|
|
836
|
-
let operand = dataFrame.value;
|
|
837
|
-
const mutateArgs = args.filter(arg => arg !== dataFrame);
|
|
838
|
-
let deletedCols = mutateArgs
|
|
839
|
-
.filter(arguments_1.isRNull)
|
|
840
|
-
.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
841
|
-
let mutatedCols = mutateArgs
|
|
842
|
-
.filter(arg => !(0, arguments_1.isRNull)(arg))
|
|
843
|
-
.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
844
|
-
// only column names that are not created by mutation are preconditions on the operand
|
|
845
|
-
const accessedNames = mutateArgs
|
|
846
|
-
.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph).map(identifier_1.Identifier.toString))
|
|
847
|
-
.filter(arg => !mutatedCols?.includes(arg));
|
|
848
|
-
deletedCols = (0, arguments_1.filterValidNames)(deletedCols, params.checkNames, params.noDupNames, undefined, true);
|
|
849
|
-
mutatedCols = (0, arguments_1.filterValidNames)(mutatedCols, params.checkNames, params.noDupNames, undefined, true);
|
|
850
|
-
pushAccessedCols(result, operand?.info.id, accessedNames);
|
|
851
|
-
if (mutatedCols === undefined || mutatedCols.length > 0 || deletedCols?.length === 0) {
|
|
852
|
-
result.push({
|
|
853
|
-
operation: 'mutateCols',
|
|
854
|
-
operand: operand?.info.id,
|
|
855
|
-
colnames: mutatedCols
|
|
856
|
-
});
|
|
857
|
-
operand = undefined;
|
|
858
|
-
}
|
|
859
|
-
if (deletedCols === undefined || deletedCols.length > 0) {
|
|
860
|
-
result.push({
|
|
861
|
-
operation: 'removeCols',
|
|
862
|
-
operand: operand?.info.id,
|
|
863
|
-
colnames: deletedCols,
|
|
864
|
-
options: { maybe: true }
|
|
865
|
-
});
|
|
866
|
-
// eslint-disable-next-line no-useless-assignment -- ends the chain
|
|
867
|
-
operand = undefined;
|
|
868
|
-
}
|
|
869
|
-
return result;
|
|
870
|
-
}
|
|
871
|
-
function mapDataFrameGroupBy(args, params, inference, info) {
|
|
872
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
873
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
874
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
else if (args.length === 1) {
|
|
878
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
879
|
-
}
|
|
880
|
-
const result = [];
|
|
881
|
-
const byArgs = args.filter(arg => arg !== dataFrame);
|
|
882
|
-
const accessedNames = byArgs.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph)).map(identifier_1.Identifier.toString);
|
|
883
|
-
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));
|
|
884
|
-
const mutatedCols = byArgs.some(r_argument_1.RArgument.isNamed) || byNames.some(assert_1.isUndefined);
|
|
885
|
-
pushAccessedCols(result, dataFrame.value.info.id, accessedNames);
|
|
886
|
-
result.push({
|
|
887
|
-
operation: 'groupBy',
|
|
888
|
-
operand: dataFrame.value.info.id,
|
|
889
|
-
by: byNames,
|
|
890
|
-
...(mutatedCols ? { options: { mutatedCols: true } } : {})
|
|
891
|
-
});
|
|
892
|
-
return result;
|
|
893
|
-
}
|
|
894
|
-
function mapDataFrameSummarize(args, params, inference, info) {
|
|
895
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
896
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
897
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
898
|
-
return;
|
|
899
|
-
}
|
|
900
|
-
const result = [];
|
|
901
|
-
const summarizeArgs = args.filter(arg => arg !== dataFrame);
|
|
902
|
-
const summarizedCols = summarizeArgs.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
|
|
903
|
-
// only column names that are not created by summarize are preconditions on the operand
|
|
904
|
-
const accessedNames = summarizeArgs
|
|
905
|
-
.flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph).map(identifier_1.Identifier.toString))
|
|
906
|
-
.filter(arg => !summarizedCols.includes(arg));
|
|
907
|
-
pushAccessedCols(result, dataFrame.value.info.id, accessedNames);
|
|
908
|
-
result.push({
|
|
909
|
-
operation: 'summarize',
|
|
910
|
-
operand: dataFrame.value.info.id,
|
|
911
|
-
colnames: summarizedCols
|
|
912
|
-
});
|
|
913
|
-
return result;
|
|
914
|
-
}
|
|
915
|
-
function mapDataFrameJoin(args, params, inference, info) {
|
|
916
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
917
|
-
const joinAll = (0, arguments_1.getArgumentValue)(args, params.joinAll, info);
|
|
918
|
-
const joinLeft = (0, arguments_1.getArgumentValue)(args, params.joinLeft, info);
|
|
919
|
-
const joinRight = (0, arguments_1.getArgumentValue)(args, params.joinRight, info);
|
|
920
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
else if (args.length === 1) {
|
|
924
|
-
return [{ operation: 'identity', operand: dataFrame.value.info.id }];
|
|
925
|
-
}
|
|
926
|
-
else if (typeof joinAll !== 'boolean' || typeof joinLeft !== 'boolean' || typeof joinRight !== 'boolean') {
|
|
927
|
-
return [{ operation: 'unknown', operand: dataFrame.value.info.id }];
|
|
928
|
-
}
|
|
929
|
-
const result = [];
|
|
930
|
-
const otherArg = (0, arguments_1.getFunctionArgument)(args, params.otherDataFrame, info);
|
|
931
|
-
const byArg = (0, arguments_1.getFunctionArgument)(args, params.by, info);
|
|
932
|
-
const otherDataFrame = inference.getAbstractValue(otherArg) ?? dataframe_domain_1.DataFrameDomain.top(info.ctx.config.abstractInterpretation.dataFrame.maxColNames);
|
|
933
|
-
let byCols;
|
|
934
|
-
const joinType = getJoinType(joinAll, joinLeft, joinRight);
|
|
935
|
-
if (byArg !== undefined) {
|
|
936
|
-
const byValue = resolve_helper_1.Resolve.argument.value(byArg, info);
|
|
937
|
-
if (typeof byValue === 'string' || typeof byValue === 'number') {
|
|
938
|
-
byCols = [byValue];
|
|
939
|
-
}
|
|
940
|
-
else if (Array.isArray(byValue) && (byValue.every(by => typeof by === 'string') || byValue.every(by => typeof by === 'number'))) {
|
|
941
|
-
byCols = byValue;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
pushAccessedColsByIndexing(result, dataFrame.value.info.id, byCols ?? []);
|
|
945
|
-
result.push({
|
|
946
|
-
operation: 'join',
|
|
947
|
-
operand: dataFrame.value.info.id,
|
|
948
|
-
other: otherDataFrame,
|
|
949
|
-
by: byCols?.map(by => typeof by === 'string' ? by : undefined),
|
|
950
|
-
options: { join: joinType, natural: byArg === undefined }
|
|
951
|
-
});
|
|
952
|
-
return result;
|
|
953
|
-
}
|
|
954
|
-
function mapDataFrameIdentity(args, params, inference, info) {
|
|
955
|
-
args = (0, arguments_1.getEffectiveArgs)(args, params.special);
|
|
956
|
-
const dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
957
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
else if (params.disallowNamedArgs && args.some(r_argument_1.RArgument.isNamed)) {
|
|
961
|
-
return [{ operation: 'unknown', operand: dataFrame.value.info.id }];
|
|
962
|
-
}
|
|
963
|
-
return [{
|
|
964
|
-
operation: 'identity',
|
|
965
|
-
operand: dataFrame.value.info.id
|
|
966
|
-
}];
|
|
967
|
-
}
|
|
968
|
-
function mapDataFrameUnknown(args, params, inference, info) {
|
|
969
|
-
let dataFrame;
|
|
970
|
-
if (params.dataFrame !== undefined) {
|
|
971
|
-
dataFrame = (0, arguments_1.getFunctionArgument)(args, params.dataFrame, info);
|
|
972
|
-
}
|
|
973
|
-
else {
|
|
974
|
-
dataFrame = args.find(arg => (0, arguments_1.isDataFrameArgument)(arg, inference));
|
|
975
|
-
}
|
|
976
|
-
if (!(0, arguments_1.isDataFrameArgument)(dataFrame, inference)) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
return [{
|
|
980
|
-
operation: 'unknown',
|
|
981
|
-
operand: dataFrame.value.info.id,
|
|
982
|
-
...(params.constraintType !== undefined ? { type: params.constraintType } : {})
|
|
983
|
-
}];
|
|
984
|
-
}
|
|
985
|
-
function getRequestFromRead(fileNameArg, textArg, params, info) {
|
|
986
|
-
let source;
|
|
987
|
-
let request;
|
|
988
|
-
if (fileNameArg !== undefined && fileNameArg !== r_function_call_2.EmptyArgument) {
|
|
989
|
-
const fileName = resolve_helper_1.Resolve.argument.value(fileNameArg, info);
|
|
990
|
-
if (typeof fileName === 'string') {
|
|
991
|
-
const text = (0, resolve_args_1.unescapeSpecialChars)(fileName);
|
|
992
|
-
source = fileName;
|
|
993
|
-
const referenceChain = fileNameArg.info.file ? [fileNameArg.info.file] : [];
|
|
994
|
-
const sources = (0, built_in_source_1.findSource)(info.ctx.config.solver.resolveSource, fileName, { referenceChain, ctx: info.ctx });
|
|
995
|
-
if (sources?.length === 1) {
|
|
996
|
-
source = sources[0];
|
|
997
|
-
// create request from resolved source file path
|
|
998
|
-
request = { request: 'file', content: sources[0] };
|
|
999
|
-
}
|
|
1000
|
-
else if (params.text === undefined && text.includes('\n')) {
|
|
1001
|
-
// create request from string if file name argument contains newline
|
|
1002
|
-
request = (0, retriever_1.requestFromInput)(text);
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
else if (textArg !== undefined && textArg !== r_function_call_2.EmptyArgument) {
|
|
1007
|
-
const text = resolve_helper_1.Resolve.argument.value(textArg, info);
|
|
1008
|
-
if (typeof text === 'string') {
|
|
1009
|
-
request = (0, retriever_1.requestFromInput)((0, resolve_args_1.unescapeSpecialChars)(text));
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
if (request?.request === 'file' && info.ctx.files.hasCached(request.content)) {
|
|
1013
|
-
request = info.ctx.files.resolveRequest(request).r;
|
|
1014
|
-
}
|
|
1015
|
-
return { source, request };
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* Gets all entries from a line of a CSV file using a custom separator char, quote char, and comment char
|
|
1019
|
-
*/
|
|
1020
|
-
function getEntriesFromCsvLine(line, sep = ',', quote = '"', comment = '', trim = true) {
|
|
1021
|
-
sep = sep.length > 0 ? sep : '\\s'; // default to whitespace separator
|
|
1022
|
-
sep = (0, arguments_1.escapeRegExp)(sep, true); // only allow tokens like `\s`, `\t`, or `\n` in separator, quote, and comment chars
|
|
1023
|
-
quote = (0, arguments_1.escapeRegExp)(quote);
|
|
1024
|
-
comment = (0, arguments_1.escapeRegExp)(comment);
|
|
1025
|
-
const quantifier = sep === '\\s' ? '+' : '*'; // do not allow unquoted empty entries in whitespace-separated files
|
|
1026
|
-
const LineCommentRegex = new RegExp(`[${comment}].*`);
|
|
1027
|
-
const CsvEntryRegex = new RegExp(`(?<=^|[${sep}])(?:[${quote}]((?:[^${quote}]|[${quote}]{2})*)[${quote}]|([^${sep}]${quantifier}))`, 'g');
|
|
1028
|
-
const DoubleQuoteRegex = new RegExp(`([${quote}])\\1`, 'g'); // regex for doubled quotes like `""` or `''`
|
|
1029
|
-
return (comment ? line.replace(LineCommentRegex, '') : line)
|
|
1030
|
-
.matchAll(CsvEntryRegex)
|
|
1031
|
-
.map(match => match[1]?.replace(DoubleQuoteRegex, '$1') ?? match[2])
|
|
1032
|
-
.map(entry => trim ? entry.trim() : entry)
|
|
1033
|
-
.toArray();
|
|
1034
|
-
}
|
|
1035
|
-
/**
|
|
1036
|
-
* 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.
|
|
1037
|
-
*/
|
|
1038
|
-
function getSelectedColumns(args, info) {
|
|
1039
|
-
let selectedCols = [];
|
|
1040
|
-
let unselectedCols = [];
|
|
1041
|
-
const joinColumns = (columns1, columns2) => columns1 !== undefined && columns2 !== undefined ? [...columns1, ...columns2] : undefined;
|
|
1042
|
-
for (const arg of args) {
|
|
1043
|
-
if (arg !== undefined && arg !== r_function_call_2.EmptyArgument) {
|
|
1044
|
-
if (r_function_call_1.RFunctionCall.isNamed(arg.value) && identifier_1.Identifier.getName(arg.value.functionName.content) === 'c') {
|
|
1045
|
-
const result = getSelectedColumns(arg.value.arguments, info);
|
|
1046
|
-
selectedCols = joinColumns(selectedCols, result.selectedCols);
|
|
1047
|
-
unselectedCols = joinColumns(unselectedCols, result.unselectedCols);
|
|
1048
|
-
}
|
|
1049
|
-
else if (r_unary_op_1.RUnaryOp.is(arg.value) && arg.value.operator === '+' && info.idMap !== undefined) {
|
|
1050
|
-
const result = getSelectedColumns([(0, make_argument_1.toUnnamedArgument)(arg.value.operand, info.idMap)], info);
|
|
1051
|
-
selectedCols = joinColumns(selectedCols, result.selectedCols);
|
|
1052
|
-
unselectedCols = joinColumns(unselectedCols, result.unselectedCols);
|
|
1053
|
-
}
|
|
1054
|
-
else if (r_unary_op_1.RUnaryOp.is(arg.value) && arg.value.operator === '-' && info.idMap !== undefined) {
|
|
1055
|
-
const result = getSelectedColumns([(0, make_argument_1.toUnnamedArgument)(arg.value.operand, info.idMap)], info);
|
|
1056
|
-
selectedCols = joinColumns(selectedCols, result.unselectedCols);
|
|
1057
|
-
unselectedCols = joinColumns(unselectedCols, result.selectedCols);
|
|
1058
|
-
}
|
|
1059
|
-
else if (r_binary_op_1.RBinaryOp.is(arg.value) && arg.value.operator === ':' && info.idMap !== undefined) {
|
|
1060
|
-
const values = resolve_helper_1.Resolve.argument.value((0, make_argument_1.toUnnamedArgument)(arg.value, info.idMap), { ...info, resolve: config_1.VariableResolve.Disabled });
|
|
1061
|
-
if (Array.isArray(values) && values.every(value => typeof value === 'number')) {
|
|
1062
|
-
selectedCols = joinColumns(selectedCols, values.filter(value => value >= 0));
|
|
1063
|
-
unselectedCols = joinColumns(unselectedCols, values.filter(value => value < 0).map(Math.abs));
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
selectedCols = undefined;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
else if (r_symbol_1.RSymbol.is(arg.value) || r_string_1.RString.is(arg.value)) {
|
|
1070
|
-
selectedCols?.push(resolve_helper_1.Resolve.argument.symbolName(arg, info));
|
|
1071
|
-
}
|
|
1072
|
-
else if (r_number_1.RNumber.is(arg.value)) {
|
|
1073
|
-
selectedCols?.push(arg.value.content.num);
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
selectedCols = undefined;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
return { selectedCols, unselectedCols };
|
|
1081
|
-
}
|
|
1082
|
-
function getJoinType(joinAll, joinLeft, joinRight) {
|
|
1083
|
-
if (joinAll || (joinLeft && joinRight)) {
|
|
1084
|
-
return 'full';
|
|
1085
|
-
}
|
|
1086
|
-
else if (joinLeft) {
|
|
1087
|
-
return 'left';
|
|
1088
|
-
}
|
|
1089
|
-
else if (joinRight) {
|
|
1090
|
-
return 'right';
|
|
1091
|
-
}
|
|
1092
|
-
else {
|
|
1093
|
-
return 'inner';
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
//# sourceMappingURL=function-mapper.js.map
|